diff -Nru metview-5.17.4/cmake/compiler_flags/GNU_Fortran.cmake metview-5.19.2/cmake/compiler_flags/GNU_Fortran.cmake --- metview-5.17.4/cmake/compiler_flags/GNU_Fortran.cmake 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/cmake/compiler_flags/GNU_Fortran.cmake 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,7 @@ # nor does it submit to any jurisdiction. set( CMAKE_Fortran_FLAGS_RELEASE "-O3 -DNDEBUG -funroll-all-loops -finline-functions" CACHE STRING "Fortran compiler flags for Release builds" FORCE ) -set( CMAKE_Fortran_FLAGS_BIT "-O2 -DNDEBUG -fno-range-check -fconvert=big-endian" CACHE STRING "Fortran compiler flags for Bit-reproducible builds" FORCE ) +set( CMAKE_Fortran_FLAGS_BIT "-O2 -DNDEBUG -fno-range-check" CACHE STRING "Fortran compiler flags for Bit-reproducible builds" FORCE ) set( CMAKE_Fortran_FLAGS_DEBUG "-O0 -g -fcheck=bounds -fbacktrace -finit-real=snan" CACHE STRING "Fortran compiler flags for Debug builds" FORCE ) set( CMAKE_Fortran_FLAGS_PRODUCTION "-O2 -g" CACHE STRING "Fortran compiler flags for Production builds." FORCE ) set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "Fortran compiler flags for RelWithDebInfo builds." FORCE ) diff -Nru metview-5.17.4/cmake/ecbuild_add_executable.cmake metview-5.19.2/cmake/ecbuild_add_executable.cmake --- metview-5.17.4/cmake/ecbuild_add_executable.cmake 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/cmake/ecbuild_add_executable.cmake 2023-07-15 08:28:47.000000000 +0000 @@ -21,6 +21,7 @@ # [ OBJECTS [ ...] ] # [ TEMPLATES [ ...] ] # [ LIBS [ ...] ] +# [ NO_AS_NEEDED ] # [ INCLUDES [ ...] ] # [ DEFINITIONS [ ...] ] # [ PERSISTENT [ ...] ] @@ -62,6 +63,9 @@ # LIBS : optional # list of libraries to link against (CMake targets or external libraries) # +# NO_AS_NEEDED: optional +# add --no-as-needed linker flag, to prevent stripping libraries that looks like are not used +# # INCLUDES : optional # list of paths to add to include directories # @@ -137,7 +141,7 @@ function( ecbuild_add_executable ) - set( options NOINSTALL AUTO_VERSION ) + set( options NOINSTALL AUTO_VERSION NO_AS_NEEDED ) set( single_value_args TARGET COMPONENT LINKER_LANGUAGE VERSION OUTPUT_NAME ) set( multi_value_args SOURCES SOURCES_GLOB SOURCES_EXCLUDE_REGEX OBJECTS TEMPLATES LIBS INCLUDES DEPENDS PERSISTENT DEFINITIONS @@ -238,7 +242,11 @@ list(REMOVE_ITEM _PAR_LIBS debug) list(REMOVE_ITEM _PAR_LIBS optimized) ecbuild_filter_list(LIBS LIST ${_PAR_LIBS} LIST_INCLUDE lib LIST_EXCLUDE skipped_lib) - target_link_libraries( ${_PAR_TARGET} ${lib} ) + if ( _PAR_NO_AS_NEEDED AND CMAKE_SYSTEM_NAME MATCHES "Linux" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU" ) + target_link_libraries( ${_PAR_TARGET} -Wl,--no-as-needed ${lib} ) + else() + target_link_libraries( ${_PAR_TARGET} ${lib} ) + endif() ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): linking with [${lib}]") ecbuild_debug("ecbuild_add_executable(${_PAR_TARGET}): [${skipped_lib}] not found - not linking") endif() diff -Nru metview-5.17.4/cmake/ecbuild_add_test.cmake metview-5.19.2/cmake/ecbuild_add_test.cmake --- metview-5.17.4/cmake/ecbuild_add_test.cmake 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/cmake/ecbuild_add_test.cmake 2023-07-15 08:28:47.000000000 +0000 @@ -27,6 +27,7 @@ # [ OMP ] # [ ENABLED ON|OFF ] # [ LIBS [ ...] ] +# [ NO_AS_NEEDED ] # [ INCLUDES [ ...] ] # [ DEFINITIONS [ ...] ] # [ PERSISTENT [ ...] ] @@ -105,6 +106,9 @@ # LIBS : optional # list of libraries to link against (CMake targets or external libraries) # +# NO_AS_NEEDED: optional +# add --no-as-needed linker flag, to prevent stripping libraries that looks like are not used +# # INCLUDES : optional # list of paths to add to include directories # @@ -177,7 +181,7 @@ function( ecbuild_add_test ) - set( options ) + set( options NO_AS_NEEDED ) set( single_value_args TARGET ENABLED COMMAND TYPE LINKER_LANGUAGE MPI OMP WORKING_DIRECTORY ) set( multi_value_args SOURCES OBJECTS LIBS INCLUDES TEST_DEPENDS DEPENDS LABELS ARGS PERSISTENT DEFINITIONS RESOURCES TEST_DATA CFLAGS @@ -336,7 +340,11 @@ list(REMOVE_ITEM _PAR_LIBS optimized) ecbuild_filter_list(LIBS LIST ${_PAR_LIBS} LIST_INCLUDE lib LIST_EXCLUDE skipped_lib) ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): linking with [${lib}]") - target_link_libraries( ${_PAR_TARGET} ${lib} ) + if ( _PAR_NO_AS_NEEDED AND CMAKE_SYSTEM_NAME MATCHES "Linux" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU" ) + target_link_libraries( ${_PAR_TARGET} -Wl,--no-as-needed ${lib} ) + else() + target_link_libraries( ${_PAR_TARGET} ${lib} ) + endif() ecbuild_debug("ecbuild_add_test(${_PAR_TARGET}): [${skipped_lib}] not found - not linking") endif() diff -Nru metview-5.17.4/cmake/FindNetCDF.cmake metview-5.19.2/cmake/FindNetCDF.cmake --- metview-5.17.4/cmake/FindNetCDF.cmake 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/cmake/FindNetCDF.cmake 2023-07-15 08:28:47.000000000 +0000 @@ -57,7 +57,7 @@ ## Library names for each component set( NetCDF_C_LIBRARY_NAME netcdf ) -set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 ) +set( NetCDF_CXX_LIBRARY_NAME netcdf_c++4 netcdf-cxx4 ) set( NetCDF_CXX_LEGACY_LIBRARY_NAME netcdf_c++ ) set( NetCDF_Fortran_LIBRARY_NAME netcdff ) @@ -120,7 +120,7 @@ find_library(NetCDF_${_comp}_LIBRARY NAMES ${NetCDF_${_comp}_LIBRARY_NAME} DOC "netcdf ${_comp} library" - HINTS ${_search_hints} + HINTS ${_search_hints_${_comp}} ${_search_hints} PATH_SUFFIXES lib ../../lib ) mark_as_advanced(NetCDF_${_comp}_LIBRARY) diff -Nru metview-5.17.4/cmake/VERSION metview-5.19.2/cmake/VERSION --- metview-5.17.4/cmake/VERSION 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/cmake/VERSION 2023-07-15 08:28:47.000000000 +0000 @@ -1 +1 @@ -3.7.0 +3.7.2 diff -Nru metview-5.17.4/CMakeLists.txt metview-5.19.2/CMakeLists.txt --- metview-5.17.4/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -6,7 +6,7 @@ #set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}" ) -project( MetviewMiniBundle VERSION 5.17.4 LANGUAGES C CXX ) +project( MetviewMiniBundle VERSION 5.19.2 LANGUAGES C CXX ) set(CPACK_PACKAGE_NAME Metview) # so that the source tarball will have the name 'Metview' @@ -82,11 +82,11 @@ set(FDB_DIR "/dummy/path/for/bundle") endif() - my_bundle_pkg( PROJECT eckit GIT "ssh://git@git.ecmwf.int/ecsdk/eckit" TAG 1.20.2 ) - my_bundle_pkg( PROJECT atlas GIT "ssh://git@git.ecmwf.int/atlas/atlas" TAG 0.30.0 ) - my_bundle_pkg( PROJECT mir GIT "ssh://git@git.ecmwf.int/mir/mir" TAG 1.13.0 ) - my_bundle_pkg( PROJECT mars-client GIT "ssh://git@git.ecmwf.int/mars/mars-client" TAG 6.33.14 ) - my_bundle_pkg( PROJECT metview GIT "ssh://git@git.ecmwf.int/metv/metview" TAG 5.17.4 ) + my_bundle_pkg( PROJECT eckit GIT "ssh://git@git.ecmwf.int/ecsdk/eckit" TAG 1.24.3 ) + my_bundle_pkg( PROJECT atlas GIT "ssh://git@git.ecmwf.int/atlas/atlas" TAG 0.34.0 ) + my_bundle_pkg( PROJECT mir GIT "ssh://git@git.ecmwf.int/mir/mir" TAG 1.17.2 ) + my_bundle_pkg( PROJECT mars-client GIT "ssh://git@git.ecmwf.int/mars/mars-client" TAG 6.33.15 ) + my_bundle_pkg( PROJECT metview GIT "ssh://git@git.ecmwf.int/metv/metview" TAG 5.19.2 ) ecbuild_dont_pack(FILES configure.sh;ecmwf;make-tarball.sh;test-tarball.sh;configure.clang.sh;bamboo) diff -Nru metview-5.17.4/debian/changelog metview-5.19.2/debian/changelog --- metview-5.17.4/debian/changelog 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/changelog 2023-07-15 08:28:25.000000000 +0000 @@ -1,3 +1,46 @@ +metview (5.19.2-1) unstable; urgency=medium + + * New upstream release + * Rebase patches + + -- Alastair McKinstry Sat, 15 Jul 2023 09:28:25 +0100 + +metview (5.19.1-3) unstable; urgency=medium + + * Move from libnercdf-legacy-cxx-dev. Closes: #1038596 + + -- Alastair McKinstry Mon, 19 Jun 2023 19:57:51 +0100 + +metview (5.19.1-2) unstable; urgency=medium + + * Push to unstable + + -- Alastair McKinstry Sun, 11 Jun 2023 12:28:05 +0100 + +metview (5.19.1-1) experimental; urgency=medium + + * New upstream release + + -- Alastair McKinstry Sun, 21 May 2023 20:29:18 +0100 + +metview (5.19.0-1) experimental; urgency=medium + + * New upstream release + * Standards-Version: 4.6.2 + * B-D on fdb >= 5.11.7-2 for latest rebuild against eckit, etc + + -- Alastair McKinstry Mon, 10 Apr 2023 08:26:43 +0100 + +metview (5.18.0-1) experimental; urgency=medium + + * New upstream release + * Change B-D libncurses5-dev -> libncurses-dev + * Update d/copyright removing obsolete files + * Remove obsolete ecbuild.patch + * Set *.mv script fragments non-exec + + -- Alastair McKinstry Fri, 10 Mar 2023 11:39:05 +0000 + metview (5.17.4-1) unstable; urgency=medium * New upstream release diff -Nru metview-5.17.4/debian/control metview-5.19.2/debian/control --- metview-5.17.4/debian/control 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/control 2023-07-15 08:28:25.000000000 +0000 @@ -9,7 +9,7 @@ flex, bison, libtirpc-dev, - libncurses5-dev, + libncurses-dev, libjemalloc-dev, libpng-dev, libssl-dev, @@ -19,7 +19,7 @@ libmetkit-dev, libmetkit-utils, fdb5, - libfdb5-dev, + libfdb5-dev (>= 5.11.7-2), odc [!powerpc !armel !armhf !i386 !mipsel], libodc-dev [!powerpc !armel !armhf !i386 !mipsel], libfftw3-dev, @@ -51,11 +51,11 @@ libproj-dev, libqt5svg5-dev, libgd-dev, imagemagick, - libnetcdf-dev, libnetcdf-cxx-legacy-dev, + libnetcdf-dev, libnetcdf-c++4-dev, flextra, flexpart, libgeotiff-dev -Standards-Version: 4.6.1 +Standards-Version: 4.6.2 Homepage: https://confluence.ecmwf.int/display/METV/Metview Vcs-Browser: https://salsa.debian.org:/science-team/metview.git Vcs-Git: https://salsa.debian.org:/science-team/metview.git diff -Nru metview-5.17.4/debian/copyright metview-5.19.2/debian/copyright --- metview-5.17.4/debian/copyright 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/copyright 2023-07-15 08:28:25.000000000 +0000 @@ -39,37 +39,3 @@ On Debian systems, the full text of the GNU General Public License version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. - -Files: src/libMars/langy.c - src/libMars-ecregrid/langy.c - src/Macro/macroy.c - src/Macro/beauy.c -Copyright: 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. -License: GPL-3 - On Debian systems, the full text of the GNU General Public - License version 3 can be found in the file - `/usr/share/common-licenses/GPL-3'. - . - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - . - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - . - As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - . - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. diff -Nru metview-5.17.4/debian/patches/fix-scripts.patch metview-5.19.2/debian/patches/fix-scripts.patch --- metview-5.17.4/debian/patches/fix-scripts.patch 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/patches/fix-scripts.patch 2023-07-15 08:28:25.000000000 +0000 @@ -12,14 +12,6 @@ # **************************** LICENSE START *********************************** # # Copyright 2012 ECMWF and INPE. This software is distributed under the terms ---- a/metview/scripts/metview_help -+++ b/metview/scripts/metview_help -@@ -1,4 +1,4 @@ -- -+#!/bin/sh - # **************************** LICENSE START *********************************** - # - # Copyright 2014 ECMWF and INPE. This software is distributed under the terms --- a/metview/scripts/mv_flextra_prep.mv +++ b/metview/scripts/mv_flextra_prep.mv @@ -1,3 +1,4 @@ diff -Nru metview-5.17.4/debian/patches/mir-atlas.patch metview-5.19.2/debian/patches/mir-atlas.patch --- metview-5.17.4/debian/patches/mir-atlas.patch 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/patches/mir-atlas.patch 2023-07-15 08:28:25.000000000 +0000 @@ -5,7 +5,7 @@ --- a/mir/src/mir/CMakeLists.txt +++ b/mir/src/mir/CMakeLists.txt -@@ -940,7 +940,7 @@ +@@ -930,7 +930,7 @@ SOURCES ${mir_srcs}) if(mir_HAVE_ATLAS) diff -Nru metview-5.17.4/debian/patches/no-zero-size-arrays.patch metview-5.19.2/debian/patches/no-zero-size-arrays.patch --- metview-5.17.4/debian/patches/no-zero-size-arrays.patch 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/patches/no-zero-size-arrays.patch 2023-07-15 08:28:25.000000000 +0000 @@ -5,7 +5,7 @@ --- a/metview/src/Macro/mvimportDesktop.c +++ b/metview/src/Macro/mvimportDesktop.c -@@ -77,11 +77,13 @@ +@@ -77,10 +77,13 @@ translation python_translations[] = { {"class", "class_"}}; @@ -13,12 +13,12 @@ +// translation macro_translations[] = {}; -translation* translations = macro_translations; --size_t num_translations = sizeof(macro_translations) / sizeof(translation); -+//translation* translations = macro_translations; -+//size_t num_translations = sizeof(macro_translations) / sizeof(translation); - +-size_t num_translations = sizeof(macro_translations) / sizeof(translation); ++// translation* translations = macro_translations; ++// size_t num_translations = sizeof(macro_translations) / sizeof(translation); ++ +translation *translations = NULL; +size_t num_translations = 0; + const char* import(FILE* f, const char* icon, const char* className); - static void formula1(FILE* f, const char* ref, math* m, math* p); diff -Nru metview-5.17.4/debian/patches/series metview-5.19.2/debian/patches/series --- metview-5.17.4/debian/patches/series 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/patches/series 2023-07-15 08:28:25.000000000 +0000 @@ -7,6 +7,5 @@ use-external-eckit-atlas.patch python3.patch mir-atlas.patch -# ecbuild.patch no-masks-download.patch g++-12-fix.patch diff -Nru metview-5.17.4/debian/patches/soname-version.patch metview-5.19.2/debian/patches/soname-version.patch --- metview-5.17.4/debian/patches/soname-version.patch 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/patches/soname-version.patch 2023-07-15 08:28:25.000000000 +0000 @@ -29,7 +29,7 @@ DEFINITIONS ${METVIEW_EXTRA_DEFINITIONS} --- a/mir/src/mir/CMakeLists.txt +++ b/mir/src/mir/CMakeLists.txt -@@ -936,6 +936,8 @@ +@@ -932,6 +932,8 @@ TARGET mir INSTALL_HEADERS LISTED HEADER_DESTINATION ${INSTALL_INCLUDE_DIR}/mir @@ -40,7 +40,7 @@ PUBLIC_INCLUDES $ $ --- a/metview/src/libMetview/CMakeLists.txt +++ b/metview/src/libMetview/CMakeLists.txt -@@ -88,7 +88,9 @@ +@@ -89,7 +89,9 @@ ecbuild_add_library( TARGET Metview diff -Nru metview-5.17.4/debian/patches/use-external-eckit-atlas.patch metview-5.19.2/debian/patches/use-external-eckit-atlas.patch --- metview-5.17.4/debian/patches/use-external-eckit-atlas.patch 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/patches/use-external-eckit-atlas.patch 2023-07-15 08:28:25.000000000 +0000 @@ -18,10 +18,10 @@ set(FDB_DIR "/dummy/path/for/bundle") endif() -- my_bundle_pkg( PROJECT eckit GIT "ssh://git@git.ecmwf.int/ecsdk/eckit" TAG 1.20.2 ) -- my_bundle_pkg( PROJECT atlas GIT "ssh://git@git.ecmwf.int/atlas/atlas" TAG 0.30.0 ) -+# my_bundle_pkg( PROJECT eckit GIT "ssh://git@git.ecmwf.int/ecsdk/eckit" TAG 1.20.2 ) -+# my_bundle_pkg( PROJECT atlas GIT "ssh://git@git.ecmwf.int/atlas/atlas" TAG 0.30.0 ) - my_bundle_pkg( PROJECT mir GIT "ssh://git@git.ecmwf.int/mir/mir" TAG 1.13.0 ) - my_bundle_pkg( PROJECT mars-client GIT "ssh://git@git.ecmwf.int/mars/mars-client" TAG 6.33.14 ) - my_bundle_pkg( PROJECT metview GIT "ssh://git@git.ecmwf.int/metv/metview" TAG 5.17.4 ) +- my_bundle_pkg( PROJECT eckit GIT "ssh://git@git.ecmwf.int/ecsdk/eckit" TAG 1.24.3 ) +- my_bundle_pkg( PROJECT atlas GIT "ssh://git@git.ecmwf.int/atlas/atlas" TAG 0.34.0 ) ++# my_bundle_pkg( PROJECT eckit GIT "ssh://git@git.ecmwf.int/ecsdk/eckit" TAG 1.24.3 ) ++# my_bundle_pkg( PROJECT atlas GIT "ssh://git@git.ecmwf.int/atlas/atlas" TAG 0.34.0 ) + my_bundle_pkg( PROJECT mir GIT "ssh://git@git.ecmwf.int/mir/mir" TAG 1.17.2 ) + my_bundle_pkg( PROJECT mars-client GIT "ssh://git@git.ecmwf.int/mars/mars-client" TAG 6.33.15 ) + my_bundle_pkg( PROJECT metview GIT "ssh://git@git.ecmwf.int/metv/metview" TAG 5.19.2 ) diff -Nru metview-5.17.4/debian/rules metview-5.19.2/debian/rules --- metview-5.17.4/debian/rules 2022-12-05 10:13:39.000000000 +0000 +++ metview-5.19.2/debian/rules 2023-07-15 08:28:25.000000000 +0000 @@ -113,7 +113,7 @@ chmod 644 debian/metview/$(MV_DIR)/metview_*.common chmod 644 debian/metview/$(MV_DIR)/metview_stat chmod 644 debian/metview/$(MV_DIR)/metview_patches - # chmod 644 debian/metview/usr/share/images/metview/* + chmod 644 debian/metview/usr/lib/*/metview/*.mv file debian/metview/$(MV_DIR)/* | grep ELF | cut -f1 -d: | xargs chrpath -d chrpath -d debian/libmetview0d/usr/lib/*/lib*so.* diff -Nru metview-5.17.4/mars-client/tests/CMakeLists.txt metview-5.19.2/mars-client/tests/CMakeLists.txt --- metview-5.17.4/mars-client/tests/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mars-client/tests/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -79,12 +79,19 @@ list( APPEND _test_data ${t}.refdata.mir ${t}.inpdata ) endforeach() -ecbuild_get_test_multidata( TARGET get_configs NAMES mars-client-baseconfigs.tar.gz:b7a2b3d3b159813d0b63dc706cc7ed76 EXTRACT ) +ecbuild_get_test_multidata( TARGET get_configs NAMES mars-client-test-configs.tar.gz:15bfc319ff03a6db165f1096cc468fd8 EXTRACT ) ecbuild_get_test_multidata( TARGET get_data NAMES ${_test_data} ) ecbuild_add_resources( TARGET tests_run_mars SOURCES_PACK ${_test_reqs} ) +set( MIR_HOME ${CMAKE_CURRENT_BINARY_DIR} ) +if( EXISTS "${CMAKE_BINARY_DIR}/etc/mir/config.yaml" ) # for bundles + set( MIR_HOME ${CMAKE_BINARY_DIR} ) +elseif( EXISTS "${mir_BASE_DIR}/etc/mir/config.yaml" ) # for individual packages + set( MIR_HOME ${mir_BASE_DIR} ) +endif() + foreach( _req ${_test_reqs} ) string(REGEX REPLACE "[^A-Za-z0-9]" "_" _tst ${_req}) @@ -99,7 +106,7 @@ TESTS_DIR=${CMAKE_CURRENT_BINARY_DIR} MARS_HOME=${CMAKE_CURRENT_BINARY_DIR} MARS_PPROC_BACKEND=MIR - MIR_HOME=${CMAKE_CURRENT_BINARY_DIR} + MIR_HOME=${MIR_HOME} ) endforeach() diff -Nru metview-5.17.4/mars-client/VERSION metview-5.19.2/mars-client/VERSION --- metview-5.17.4/mars-client/VERSION 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mars-client/VERSION 2023-07-15 08:28:47.000000000 +0000 @@ -1 +1 @@ -6.33.14 +6.33.15 diff -Nru metview-5.17.4/metview/.clang-format metview-5.19.2/metview/.clang-format --- metview-5.17.4/metview/.clang-format 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/.clang-format 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ Language: Cpp AccessModifierOffset: -4 AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: true +AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left AlignOperands: true diff -Nru metview-5.17.4/metview/CMakeLists.txt metview-5.19.2/metview/CMakeLists.txt --- metview-5.17.4/metview/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -44,7 +44,7 @@ set(ORIGINAL_INSTALL_BIN_DIR ${INSTALL_BIN_DIR}) # will restore at the end set(INSTALL_BIN_DIR "${MV_BIN_DIR}" CACHE PATH "Metview installation directory for executable files") -project(metview VERSION 5.17.4 LANGUAGES C CXX) +project(metview LANGUAGES C CXX) set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE OFF) @@ -87,6 +87,8 @@ option( ENABLE_CODES_UI "enable building of CodesUI" OFF ) option( ENABLE_STVL "enable STVL access module" OFF ) option( ENABLE_STATIONS_DB "enable database of WMO stations" ON ) +option( ENABLE_FLEXTRA_TEST "enable testing FLEXTRA simulations" OFF) +option( ENABLE_FLEXPART_TEST "enable testing FLEXPART simulations" OFF) #option( ENABLE_CODE_WEBHELP "enable inline web help in code editor" OFF ) diff -Nru metview-5.17.4/metview/.gitignore metview-5.19.2/metview/.gitignore --- metview-5.17.4/metview/.gitignore 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/.gitignore 2023-07-15 08:28:47.000000000 +0000 @@ -47,3 +47,6 @@ src/images/._mv_iconlist_ src/images/._mv_viewinfo_ + +# mac +.DS_Store diff -Nru metview-5.17.4/metview/scripts/CMakeLists.txt metview-5.19.2/metview/scripts/CMakeLists.txt --- metview-5.17.4/metview/scripts/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/scripts/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -9,9 +9,10 @@ MarsTiggeWrapper MarsOdbWrapper generate_video - mv_compress mv_mail mv_uniquename + mv_compress mv_mail + mv_extract mv_eccharts.py - mv_odbsql mv_obstat + mv_odbsql mv_mars_catalog.py mv_flextra_prep.mv mv_flextra_prep mv_flextra_run mv_flexpart_run mv_flexpart_pp diff -Nru metview-5.17.4/metview/scripts/metview_base.in metview-5.19.2/metview/scripts/metview_base.in --- metview-5.17.4/metview/scripts/metview_base.in 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/scripts/metview_base.in 2023-07-15 08:28:47.000000000 +0000 @@ -957,6 +957,7 @@ # set up the file viewers if [[ "${uname_}" == 'Darwin' ]]; then + MV_BROWSER_NAME=${MV_BROWSER_NAME:=open} METVIEW_PS_VIEWER=${METVIEW_PS_VIEWER:=open} METVIEW_PDF_VIEWER=${METVIEW_PDF_VIEWER:=open} METVIEW_PNG_VIEWER=${METVIEW_PNG_VIEWER:=open} @@ -964,6 +965,7 @@ METVIEW_GIF_VIEWER=${METVIEW_GIF_VIEWER:=open} METVIEW_TIFF_VIEWER=${METVIEW_TIFF_VIEWER:=open} METVIEW_RASTER_EDITOR=${METVIEW_RASTER_EDITOR:=open} + METVIEW_TEXT_VIEWER=${METVIEW_TEXT_VIEWER:=open} METVIEW_GRAPHICS_SYSTEM=${METVIEW_GRAPHICS_SYSTEM:="native"} MV_VAPOR_BIN=${MV_VAPOR_BIN:="/Applications/VAPOR/VAPOR.app/Contents/MacOS/"} # MARS_NOFORK=1 @@ -979,6 +981,7 @@ METVIEW_JPEG_VIEWER=${METVIEW_JPEG_VIEWER:=display} METVIEW_GIF_VIEWER=${METVIEW_GIF_VIEWER:=display} METVIEW_TIFF_VIEWER=${METVIEW_TIFF_VIEWER:=display} + METVIEW_TEXT_VIEWER=${METVIEW_TEXT_VIEWER:=$METVIEW_EDITOR} METVIEW_RASTER_EDITOR=${METVIEW_RASTER_EDITOR:=gimp} METVIEW_KML_VIEWER=${METVIEW_KML_VIEWER:=google-earth} diff -Nru metview-5.17.4/metview/scripts/metview_help metview-5.19.2/metview/scripts/metview_help --- metview-5.17.4/metview/scripts/metview_help 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/scripts/metview_help 2023-07-15 08:28:47.000000000 +0000 @@ -1,3 +1,4 @@ +#!/bin/bash # **************************** LICENSE START *********************************** # @@ -130,6 +131,8 @@ [$METVIEW_GIF_VIEWER] METVIEW_KML_VIEWER external application to view KML icons [$METVIEW_KML_VIEWER] + METVIEW_TEXT_VIEWER external application to view text files + [$METVIEW_TEXT_VIEWER] METVIEW_RASTER_EDITOR external application to edit raster images [$METVIEW_RASTER_EDITOR] diff -Nru metview-5.17.4/metview/scripts/metview_local2.ecm_lnx64 metview-5.19.2/metview/scripts/metview_local2.ecm_lnx64 --- metview-5.17.4/metview/scripts/metview_local2.ecm_lnx64 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/scripts/metview_local2.ecm_lnx64 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ # ensure that ncdump and ncgen are available for the netCDF examiner -if [ $METVIEW_GUI_BUILT = true -a $METVIEW_MODE != batch ] +if [ $METVIEW_GUI_BUILT = true -a $METVIEW_MODE != batch ] && $(module is-avail netcdf4) then if [ x$LMOD_VERSION = x ] then diff -Nru metview-5.17.4/metview/scripts/mv_compress metview-5.19.2/metview/scripts/mv_compress --- metview-5.17.4/metview/scripts/mv_compress 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/scripts/mv_compress 2023-07-15 08:28:47.000000000 +0000 @@ -56,6 +56,7 @@ f_LOG="" useFixedName=0 retVal=0 +COMPRESS_ONLY=0 while [ "$1" != "" ] do @@ -109,10 +110,30 @@ COMPRESS_CMD="" SUFFIX="tar" ;; - tzip) - COMPRESS_CMD="zip -r" - SUFFIX="tar.zip" - ;; + tz) + COMPRESS_CMD="compress -c" + SUFFIX="tar.z" + ;; + #zip) + # COMPRESS_CMD="zip -r -" + # SUFFIX="zip" + # ;; + + gz) + COMPRESS_CMD="gzip -c" + SUFFIX="gz" + COMPRESS_ONLY=1 + ;; + bz2) + COMPRESS_CMD="bzip2 -c" + SUFFIX="bz2" + COMPRESS_ONLY=1 + ;; + z) + COMPRESS_CMD="compress -f -c" + SUFFIX="Z" + COMPRESS_ONLY=1 + ;; *) print_err "No method is specified (via the -m flag)!" exit 1 @@ -138,6 +159,23 @@ cd $METVIEW_USER_DIRECTORY #-------------------------------------------------- +# Compress only tasks +#-------------------------------------------------- + +if [ $COMPRESS_ONLY -eq 1 ] ;then + + for n + do + f_SRC="$METVIEW_USER_DIRECTORY"/"$n" + f_RES="$METVIEW_USER_DIRECTORY""/""$n""."$SUFFIX + if [ -f "$f_SRC" ] ; then + $(${COMPRESS_CMD} "${f_SRC}" > "$f_RES") + fi + done + exit 0 +fi + +#-------------------------------------------------- # Calls mvimport for the icons to be compressed. # this will find all the linked and embedded icons! #-------------------------------------------------- diff -Nru metview-5.17.4/metview/scripts/mv_extract metview-5.19.2/metview/scripts/mv_extract --- metview-5.17.4/metview/scripts/mv_extract 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/scripts/mv_extract 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,201 @@ +#!/bin/bash + +# **************************** LICENSE START *********************************** +# +# Copyright 2013 ECMWF and INPE. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +set -x + +function print_err() +{ + echo ${text_ERR} $* >> "${f_LOG}" +} + +function print_warn() +{ + echo "WARNING: " $* >> "${f_LOG}" +} + +text_ERR="ERROR: script `basename $0` FAILED! " + +function unique_name() +{ + local f_INP=$1 + local suffixes="" + local suffix="" + + if [[ $# -eq 2 ]] ; then + suffixes=$2 + fi + + d=$(dirname "$f_INP") + fname=$(basename "$f_INP") + + for s in $(echo $suffixes | tr "," "\n") ; do + t=${f_INP##*$s} + if [ -z $t ] ; then + suffix=$s + break + fi + done + + n=$(basename "$f_INP" "$suffix") + cd "$d" + + if [[ $(find . -maxdepth 1 -name "$n" | wc -l) -eq 0 ]] ; then + echo $n + return + fi + + maxNum=$(find . -maxdepth 1 -name "*" | wc -l) + + i=1 + fn="$n"_$i + while [ $i -lt $maxNum ] ; do + fn="$n"_$i + if [[ $(find . -maxdepth 1 -name "$fn" | wc -l) -eq 0 ]] ; then + echo $fn + exit 0 + fi + i=$(($i + 1)) + done + + echo "$n"_$maxNum +} + +# strip the suffix from a filename using a potential list of suffixes +function target_filename() +{ + local f_INP=$1 + local suffixes="" + + if [[ $# -eq 2 ]] ; then + suffixes=$2 + fi + + d=$(dirname "$f_INP") + fname=$(basename "$f_INP") + + for s in $(echo $suffixes | tr "," "\n") ; do + t=${f_INP##*$s} + if [ -z $t ] ; then + suffix=$s + echo $(basename "$f_INP" $suffix) + return + fi + done + + echo "$f_INP" +} + +#-------------------------------------------- +# Main +#-------------------------------------------- + +f_INPUT=$1 +METHOD=$2 +MODE=$3 + +if [ $# -eq 0 ] ; then + print_err "No input path specified!" + exit 1 +fi + +if [[ $MODE != "ext" && $MODE != "sub" && $MODE != "exam" ]] ; then + print_err "Invalid MODE=$MODE specified!" + exit 1 +fi + +REDIRECT=0 +TMP_SUFFIX=".tar_contents.txt" + +case $METHOD in + tar_gz) + EXTRACT_CMD="tar -xzvf" + EXAMINE_CMD="tar -tzvf" + SUFFIX=".tar.gz,.tgz,.tar.gzip" + ;; + tar_bz2) + EXTRACT_CMD="tar -xjvf" + EXAMINE_CMD="tar -tjvf" + SUFFIX=".tar.bz2,.tbz,.tar.bzip2,.tar.bzip" + ;; + tar_z) + EXTRACT_CMD="tar -xzvf" + EXAMINE_CMD="tar -tzvf" + SUFFIX=".tar.z,.tz,.tar.Z" + ;; + tar) + EXTRACT_CMD="tar -xvf" + EXAMINE_CMD="tar -tvf" + SUFFIX=".tar" + ;; + zip) + EXTRACT_CMD="unzip" + EXAMINE_CMD="unzip -l" + SUFFIX=".zip,.ZIP" + ;; + gz) + EXTRACT_CMD="gunzip" + if [[ $MODE == "sub" ]] ; then + EXTRACT_CMD="gunzip -c" + REDIRECT=1 + fi + SUFFIX=".gz,.gzip" + ;; + bz2) + EXTRACT_CMD="bzip2" + if [[ $MODE == "sub" ]] ; then + EXTRACT_CMD="bzip2 -c" + REDIRECT=1 + fi + SUFFIX=".bz2,.bzip2,.bz,.bzip2" + ;; + z) + EXTRACT_CMD="uncompress" + if [[ $MODE == "sub" ]] ; then + EXTRACT_CMD="uncompress -c" + REDIRECT=1 + fi + SUFFIX=".z,.Z" + ;; + *) + print_err "No METHOD valid is specified" + exit 1 + ;; +esac + +# figure out input dir and enter it +d_INPUT=$(dirname "$f_INPUT") +cd $d_INPUT +#echo "d_INPUT=$d_INPUT" +#echo "EXTRACT_CMD=$EXTRACT_CMD" + +if [[ $MODE == "ext" ]] ; then + #echo "no subdir f_INPUT=$f_INPUT" + $($EXTRACT_CMD "$f_INPUT") +elif [[ $MODE == "sub" ]] ; then + d_OUTPUT=$(unique_name "$f_INPUT" $SUFFIX) + #echo "subdir d_OUTPUT=$d_OUTPUT" + mkdir "$d_OUTPUT" + cd "$d_OUTPUT" + if [[ $REDIRECT -ne 1 ]] ; then + $($EXTRACT_CMD "$f_INPUT") + else + target=$(target_filename "$f_INPUT" $SUFFIX) + #echo "target=$target" + $($EXTRACT_CMD "$f_INPUT" > "$target") + fi +else + d_OUTPUT=$TMPDIR/$(basename "$f_INPUT")${TMP_SUFFIX} + $($EXAMINE_CMD "$f_INPUT" > "${d_OUTPUT}") + $METVIEW_TEXT_VIEWER "$d_OUTPUT" +fi + + +exit 0 diff -Nru metview-5.17.4/metview/scripts/mv_obstat metview-5.19.2/metview/scripts/mv_obstat --- metview-5.17.4/metview/scripts/mv_obstat 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/scripts/mv_obstat 1970-01-01 00:00:00.000000000 +0000 @@ -1,292 +0,0 @@ -#!/bin/bash - -# **************************** LICENSE START *********************************** -# -# Copyright 2012 ECMWF and INPE. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ - - -set -a -set -x - -# ---------------------------------------------------------------- -# Script to run OBSTAT in a properly set environment. -# -# OBSTAT = flexible ODB and BUFR feedback observation statistics -# and plot application. Can be run on your workstation or the -# linux_cluster -# ----------------------------------------------------------------- - -# Include the control variables set via the Metview interface -if [[ $# -ne 0 ]] ; then - . $1 -fi - - -FIRSTCYCLE=${FIRTSCYCLE:-"2010081512"} -LASTCYCLE=${LASTCYCLE:-"2010081512"} - -# a 4-letter expver (e.g. 0001 for oper, 0028 for e-suite, -# eixd for rd, ER40 for ERA-40) -EXPVER1=${EXPVER1:-"0001"} - -# rd, od, e4 or ei -CLASS1=${CLASS1:-"od"} - -# DA, DCDA or SCDA -STREAM1=${STREAM1:-"DCDA"} - -# Activate the three next lines to overlay plots for two experiments (optional) -#EXPVER2=0029 -#CLASS2=od -#STREAM2=DA - -# yes: generates generic statistics for all data present in the input database -LALLDATA=${LALLDATA:-"no"} - -# yes: make obstat plot -OBSTATPLOT=${OBSTATPLOT:-"yes"} - -# yes: make varbc time series plot -VARBC_PARAMS=no - -# yes: produce condition number plot -CONDITION_NUMBER=no - -# yes: produce one normalized high resolution grib for the whole period -GEOGRIB_AVE_PERIOD=${GEOGRIB_AVE_PERIOD:-"yes"} - -# yes: concatenate scat data for the whole period -SCAT_PERIOD=${SCAT_PERIOD:-"yes"} - -# yes: produce ascii for the production of data coverage maps -LCOVERAGE=no - -# yes: the fast mode obstat plot where the obstat statistics -# files are retrieved from ecfs, i.e. without need to retrieve -# and process feedback/ODB files. This restrict the statistics -# to the prepIFS/ops specified regions/instruments (not valid for gridded statistics) - -USE_ECFSLOG=${USE_ECFSLOG:-"no"} - -# yes: produce departure, varBC or condition number webplots; -# no: only produce postscript files -WEBPLOTS=no - -# A3, A4 or EPS (A4, A3: size of plot; -# EPS: one plot per page, suitable for publications) -LAYOUT=A4 - -# Default for short comment string for obstat plots (OBSTATPLOT=yes) -COMMENT=${COMMENT:-""} -if [[ x$COMMENT != x ]] ; then - if [[ x$EXPVER2 = x ]] ; then - COMMENT="/$STREAM1 " - else - COMMENT="/$STREAM1 (black) v. $EXPVER2/$STREAM2" - fi -fi - -# Activate the line below to define your personal web folder name. Only relevant -# when WEBPLOTS=yes. -#WEBNOTE='Operations 0001 ' - -# ------------------------------------------------------------------------- -# Settings required for user specific obstat statistics recalculated from -# BUFR feedback or ODB-files, i.e. if USE_ECFSLOG='no'. -# Also controls the observing system selection for time series plots -#--------------------------------------------------------------------------- - -# stat definition file -STATDEF=${STATDEF:-"/home/mo/obstat/OBSTAT/stat.ref"} -#PARAMS="/home/mo/obstat/obstat/data/params.txt" -#FLAGS="/home/mo/obstat/obstat/data/flags.txt" - -cluster=$( echo $HOST | cut -c1-3) -if [[ $cluster = bee || $ARCH = rs6000 ]] ; then - # linux cluster or AIX server - mkdir $SCRATCH/OBSTATG - STOREDIR=${STOREDIR:-"$SCRATCH/OBSTAT_GRIB/"} # directory for ODB and feedback files - EXEDIR=${EXEDIR:-"$SCRATCH/OBSTAT_GRIB/tmp_"} # work directory with text and ps files -else - # workstation - mkdir /tmp/OBSTAT_GRIB - STOREDIR=${STOREDIR:-"$SCRATCH/"} # directory for ODB and feedback files - EXEDIR=${EXEDIR:-"$SCRATCH/tmp_"} -fi -GRIBDIR=${GRIBDIR:-"$SCRATCH/$EXPVER1"} # GRIB storage directory - -# ODB storage directory -ODBDIR=${ODBDIR:-"$SCRATCH/$EXPVER1"} - -# put yes to calculate stats from ODB or BUFR feedback files (valid for ascii stats) -STACALC=${STACALC:-"yes"} - -# put yes to accumulate stat-files cycle by cycle (valid for ascii stats) -STAACCUM=${STAACCUM:-"no"} - -# Determine which ODB or BUFR feedback files to extract, possibly a -# subset of observation types, i.e. only conventional data - -# format of obs files : BUFR, ODB, USER -OBSFORMAT=${OBSFORMAT:-"ODB"} - -#USERDATA="$SCRATCH/data" #Uncomment if OBSFORMAT=USE -UPDSOFT=${UPDSOFT:-"true"} - -#------------------------------ -# Check obs format -#------------------------------ - -if [[ $OBSFORMAT = ODB ]] ; then - - # Define ODB file type, i.e. CCMA, ECMA or ODBCMP - ODBFILETYPE=${ODBFILETYPE:-"ECMA"} - - # yes: retrieve odb data from ecfs - # no: assumes odb data to be available in $STOREDIR - RETRIEVEODB=${RETRIEVEODB:-"yes"} - - # List of ODB databases to process - if [[ $ODBFILETYPE = CCMA || $ODBFILETYPE = MONDB ]] ; then - # For CCMA data all data is in one ODB database, so the default is - # datalist="oneodb". - # For specialized tasks, i.e. field-of-view related statistics for TOVS data, - # the user must use datalist="tovs" which allows obstat use use an sql that - # extract TOVS specific items from the CCMA. Other specialized requests are - # ahown as comments here below. - - ##datalist="tovs" - ##datalist="reo3" - ##datalist="conv" - datalist="oneodb" - else - # Specify list of ODB databases to process - # Some examples are included as commnets below - - ##datalist="conv satob scatt ssmi msu ssu amsua amsub hirs geos reo3 airs iasi gpsro tmi mhs ssmis amsre" - datalist="tmi" - fi - - -elif [[ $OBSFORMAT = BUFR ]] ; then - # Specify list of BUFR feedback files to process - # Some examples are commented out below - - ##datalist="fbconv fbscat fbssmi fbrad1c fbgeos fbtovs fbreo3 fbairs" - datalist="fbssmi" - -elif [[ $OBSFORMAT = USER ]] ; then - - datalist="reo3" - DATA_INTERFACE="/home/mo/obstat/obstat/data/data_interface" - -else - echo "OBSFORMAT $OBSFORMAT is not implemented at ECMWF" - exit 1 -fi - - -#--------------------------------------------------------------------------------- -# More specialized control switches that usually are kept at the default values -# are specified below -#---------------------------------------------------------------------------------- - -# put yes (recommended) to avoid storing many ODB or BUFR feedback files -FBKCLEAN=${FBKCLEAN:-"yes"} - -# put yes to delete intermediate stat-files after merging -STACLEAN=${STACLEAN:-"no"} - -# put yes to generate a postscript plot -STAPLOT=${STAPLOT:-"yes"} - - -#STATFILE=statbcbc.txt #(optional) file to plot (STAPLOT=yes) - # if statfile is not specified it writes stat$EXPVER.txt -#STATFILE=$HOME/obstat/stat.ref - -# OVERFILE is used to do specialized comparison of two experiments (optional) -# If both EXPVER1 and EXPVER2 are specified the user specified OVERFILE is not used. -# OVERFILE="$STOREDIR/tmp$EXPVER2/stat$EXPVER2.txt" - -#TSTEP=6 # Set timestep in hours between analyses. Typically 12 or 6. - # For fast mode options TSTEP must be at least equal to the - # 3D-Var/4D-Var assimilation period. This makes it possible do - # statistics in steps of e.g. 24 hours. -# Select a NSEW box for obstat ODS file ASCII print out of observation statistics - -#ODSNORTH=49. -#ODSSOUTH=40. -#ODSEAST=145. -#ODSWEST=138. -#ODSFLAGFILTER=5 - -#-------------------------------------- -# Further control of plot layout -#-------------------------------------- - -# put yes to replace rms by std.dev -STDEV=${STDEV:-"yes"} - -WHISKERS=yes # put yes to get st.dev box and min/max whiskers on histogram plots -FIXEDAXES=yes # put yes to get fixed preselected axis limits on obstat plots -PLOTBIAS=yes # put yes to include bias correction curves on satellite data plots -PLOTAISRBIAS=no # put yes to include AIRS bias correction curves on AIRS data plots -HUMMINLEV=70. # limit TEMP humidity vertical scale to HUMMINLEV hPa - - - - -# Use these to raise the print level of diagnostic output and possibly stop it early -# verbosity level (0 to 5) -IVERB=0 - -# if specified, number of bufr reads before stopping -#IMAXREAD=1000 - -# EMOS cycle used for BUFR tables and EMOS libraries -EMOS_CYCLE=000360 - -# put yes to merge stat-files into one -STAMERGE=${STAMERGE:-"yes"} - -# put yes to gzip stat files to save space -GZIPSTAT=no - -# Default script directory, libraries and sql -GRIB_API_VERSION=1.9.2; export GRIB_API_VERSION - -DATADIR=${DATADIR:-"/home/mo/obstat/OBSTAT/data"} - -LIBS="/home/mo/obstat/OBSTAT/lib/current/${ARCH}" - -GRIB_API_INCLUDE="-I/usr/local/lib/metaps/lib/grib_api/jasper/include -I/usr/local/lib/metaps/lib/grib_api/${GRIB_API_VERSION}/include" - -GRIB_API_LIB="-L/usr/local/lib/metaps/lib/grib_api/${GRIB_API_VERSION}/lib -lgrib_api_f90 -lgrib_api -L/usr/local/lib/metaps/lib/grib_api/jasper/lib -ljasper" - -OBSTAT_LIB="$LIBS/libobstat.a" - - -#To speed up ploting it is possible to avoid relinking obstat executable(s)and -# instead use the default(s) specified below. -BINDIR="/home/mo/obstat/OBSTAT/bin/current/${ARCH}" -if [[ $ARCH = linux ]] ; then - OBSTATPLOTEXE="$BINDIR/obstat_plot.x_linux" - TIMESERIESPLOTEXE="$BINDIR/obstat_timeseries.x_linux" - GEOPLOTEXE="$BINDIR/sat_geo_plot_linux" - SCATTERPLOTEXE="$BINDIR/sat_scat_plot_linux" - NORMALIZEGRIBEXE="$BINDIR/obstat_normalize_grib" - ADDGRIBEXE="$BINDIR/obstat_add_grib" - CONSCATEXE="$BINDIR/obstat_normalize_scat" -fi - -#---------------------------------------- -# Perform obstat in fast or slow mode -#---------------------------------------- -$DATADIR/obstat_interface - diff -Nru metview-5.17.4/metview/scripts/mv_uniquename metview-5.19.2/metview/scripts/mv_uniquename --- metview-5.17.4/metview/scripts/mv_uniquename 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/scripts/mv_uniquename 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -#!/bin/bash - -# **************************** LICENSE START *********************************** -# -# Copyright 2013 ECMWF and INPE. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ - -f_INP=$1 -suffix="" - -if [ $# -eq 2 ] ; then - suffix=$2 -fi - -d=`dirname "$f_INP"` -n=`basename "$f_INP" "$suffix"` -cd "$d" - -if `find -maxdepth 1 -name "$n" | wc -l` -eq 1 ] ; then - echo $d - exit -fi - -maxNum=`find -maxdepth 1 -name "*" | wc -l` - -i=1 -fn="$n"_$i -while [ $i -lt $maxNum ] ; do - fn="$n"_$i - if [ `find -maxdepth 1 -name "$fn" | wc -l` -eq 0 ] ; then - echo $fn - exit - fi - result=`expr $a + $a` - i=`expr $i + 1` -done - -echo "$n"_$maxNum - -exit diff -Nru metview-5.17.4/metview/scripts/ObstatToolWrapper metview-5.19.2/metview/scripts/ObstatToolWrapper --- metview-5.17.4/metview/scripts/ObstatToolWrapper 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/scripts/ObstatToolWrapper 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -#!/bin/bash - -# **************************** LICENSE START *********************************** -# -# Copyright 2012 ECMWF and INPE. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ - - -# ----------------------------------------- -# ECMWF extras for setting magmlx environment -# for Obstat Scatter tool -# ----------------------------------------- - -# set up the environment -. /usr/local/share/ecmwf/use/sh.newmagics++ - - -# run the specified module -if [ x$1 != x ] -then - exe=$1 - shift - $METVIEW_BIN/$exe $* -fi diff -Nru metview-5.17.4/metview/share/metview/app-defaults/FrameKeyProfile_all.xml metview-5.19.2/metview/share/metview/app-defaults/FrameKeyProfile_all.xml --- metview-5.17.4/metview/share/metview/app-defaults/FrameKeyProfile_all.xml 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/FrameKeyProfile_all.xml 2023-07-15 08:28:47.000000000 +0000 @@ -108,7 +108,6 @@ - @@ -254,14 +253,4 @@ - - - - - - - - - - diff -Nru metview-5.17.4/metview/share/metview/app-defaults/highlighter_dark.json metview-5.19.2/metview/share/metview/app-defaults/highlighter_dark.json --- metview-5.17.4/metview/share/metview/app-defaults/highlighter_dark.json 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/highlighter_dark.json 2023-07-15 08:28:47.000000000 +0000 @@ -119,5 +119,73 @@ "colour" : "rgb(170,177,190)", "bold" : "false" } - ] + ], + +"python": [ + { + "name": "builtin_function", + "pattern": "\\bmv.[A-Za-z0-9_]+(?=\\()", + "colour": "rgb(190,214,255)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "number", + "pattern": "\\b([0-9]+\\.?[0-9]*)\\b", + "colour": "rgb(127,179,71)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "keyword", + "pattern": "\\b(and|as|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|is|lambda|not|or|pass|raise|return|try|while|with|yield)\\b", + "colour": "rgb(133,153,0)", + "bold": "true", + "caseInsensitive": "true" + }, + { + "name": "string", + "pattern": "(\"[^\"]*\")|('[^']*')", + "colour": "rgb(255,198,0)", + "bold": "false", + "caseInsensitive": "true" + } +], +"request": [ + { + "name": "verb", + "pattern": "^\\s*(\\w+)\\s*(?=,)", + "colour": "rgb(190,214,255)", + "bold": "true", + "caseInsensitive": "true" + }, + { + "name": "value", + "pattern": "(?<==)\\s*(\\w+)\\s*(?=,)?", + "colour": "rgb(255,198,0)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "value_last", + "pattern": "(?<==)\\s*\\b(\\S+)$AAAAA", + "colour": "rgb(255,198,0)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "number", + "pattern": "(?<==)\\s*([0-9]+\\.?[0-9]*)\\s*(?=,)?", + "colour": "rgb(127,179,71)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "string", + "pattern": "(\"[^\"]*\")|('[^']*')", + "colour": "rgb(255,198,0)", + "bold": "false", + "caseInsensitive": "true" + } +] } diff -Nru metview-5.17.4/metview/share/metview/app-defaults/highlighter_light.json metview-5.19.2/metview/share/metview/app-defaults/highlighter_light.json --- metview-5.17.4/metview/share/metview/app-defaults/highlighter_light.json 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/highlighter_light.json 2023-07-15 08:28:47.000000000 +0000 @@ -114,5 +114,72 @@ "colour" : "rgb(0,0,0)", "bold" : "false" } + ], + "python": [ + { + "name": "builtin_function", + "pattern": "\\bmv.[A-Za-z0-9_]+(?=\\()", + "colour": "rgb(255,119,119)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "number", + "pattern": "\\b([0-9]+\\.?[0-9]*)\\b", + "colour": "rgb(0,0,255)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "keyword", + "pattern": "\\b(and|as|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|is|lambda|not|or|pass|raise|return|try|while|with|yield)\\b", + "colour": "rgb(0,0,128)", + "bold": "true", + "caseInsensitive": "true" + }, + { + "name": "string", + "pattern": "(\"[^\"]*\")|('[^']*')", + "colour": "rgb(128,0,0)", + "bold": "false", + "caseInsensitive": "true" + } + ], + "request": [ + { + "name": "verb", + "pattern": "^\\s*(\\w+)\\s*(?=,)", + "colour": "rgb(255,119,119)", + "bold": "true", + "caseInsensitive": "true" + }, + { + "name": "value", + "pattern": "(?<==)\\s*(\\w+)\\s*(?=,)?", + "colour": "rgb(128,0,0)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "value_last", + "pattern": "(?<==)\\s*\\b(\\S+)$AAAAA", + "colour": "rgb(128,0,0)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "number", + "pattern": "(?<==)\\s*([0-9]+\\.?[0-9]*)\\s*(?=,)?", + "colour": "rgb(0,0,255)", + "bold": "false", + "caseInsensitive": "true" + }, + { + "name": "string", + "pattern": "(\"[^\"]*\")|('[^']*')", + "colour": "rgb(128,0,0)", + "bold": "false", + "caseInsensitive": "true" + } ] } diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/dark/extract.svg metview-5.19.2/metview/share/metview/app-defaults/images/dark/extract.svg --- metview-5.17.4/metview/share/metview/app-defaults/images/dark/extract.svg 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/dark/extract.svg 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,300 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + ECMWF + + + en-GB + + + Metview icon + + + Metview icon + + + + + + + + + + + diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/dark/gui_edit.svg metview-5.19.2/metview/share/metview/app-defaults/images/dark/gui_edit.svg --- metview-5.17.4/metview/share/metview/app-defaults/images/dark/gui_edit.svg 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/dark/gui_edit.svg 2023-07-15 08:28:47.000000000 +0000 @@ -7,60 +7,60 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="34.133335" - height="34.133335" - id="svg2" - version="1.1" - inkscape:version="1.0 (4035a4f, 2020-05-01)" + viewBox="0 0 32 32" sodipodi:docname="gui_edit.svg" - viewBox="0 0 32 32"> + inkscape:version="1.0 (4035a4f, 2020-05-01)" + version="1.1" + id="svg2" + height="34.133335" + width="34.133335"> + style="stop-color:#f1f1f1;stop-opacity:1;" /> + style="stop-color:#dddddd;stop-opacity:1;" /> + inkscape:window-y="25" + inkscape:window-x="27" + inkscape:window-height="795" + inkscape:window-width="1414" + inkscape:snap-to-guides="false" + inkscape:snap-grids="true" + showgrid="true" + inkscape:current-layer="layer1" + inkscape:document-units="px" + inkscape:cy="17.066668" + inkscape:cx="17.066668" + inkscape:zoom="17.724608" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + borderopacity="1.0" + bordercolor="#666666" + pagecolor="#ffffff" + id="base" + inkscape:snap-global="false"> + originy="0" + originx="0" + snapvisiblegridlinesonly="true" + enabled="true" + visible="true" + empspacing="5" + id="grid2985" + type="xygrid" /> @@ -94,38 +94,33 @@ - + inkscape:groupmode="layer" + inkscape:label="Layer 1"> - + style="fill:none;fill-opacity:1;stroke:#ececec;stroke-width:1.19986;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + + + + style="fill:none;stroke:#ececec;stroke-width:1.875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 19.79371,1024.4263 0.082,23.6605" + id="path917" /> diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/dark/logpanel.svg metview-5.19.2/metview/share/metview/app-defaults/images/dark/logpanel.svg --- metview-5.17.4/metview/share/metview/app-defaults/images/dark/logpanel.svg 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/dark/logpanel.svg 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + ECMWF + + + en-GB + + + Metview icon + + + Metview icon + + + + + + + + + + diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/dark/python_edit.svg metview-5.19.2/metview/share/metview/app-defaults/images/dark/python_edit.svg --- metview-5.17.4/metview/share/metview/app-defaults/images/dark/python_edit.svg 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/dark/python_edit.svg 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + ECMWF + + + en-GB + + + Metview icon + + + Metview icon + + + + + + + + + + + diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/desktop_light.qrc metview-5.19.2/metview/share/metview/app-defaults/images/desktop_light.qrc --- metview-5.17.4/metview/share/metview/app-defaults/images/desktop_light.qrc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/desktop_light.qrc 2023-07-15 08:28:47.000000000 +0000 @@ -49,6 +49,7 @@ light/examine.svg light/expand_left.svg light/expand_right.svg + light/extract.svg light/saveas_teal.svg light/filter.svg light/filter_decor.svg @@ -113,5 +114,6 @@ light/visualise.svg light/warning.svg light/wastebasket.svg + light/web_link.svg diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/light/extract.svg metview-5.19.2/metview/share/metview/app-defaults/images/light/extract.svg --- metview-5.17.4/metview/share/metview/app-defaults/images/light/extract.svg 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/light/extract.svg 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,300 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + ECMWF + + + en-GB + + + Metview icon + + + Metview icon + + + + + + + + + + + diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/light/gui_edit.svg metview-5.19.2/metview/share/metview/app-defaults/images/light/gui_edit.svg --- metview-5.17.4/metview/share/metview/app-defaults/images/light/gui_edit.svg 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/light/gui_edit.svg 2023-07-15 08:28:47.000000000 +0000 @@ -7,60 +7,60 @@ xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - viewBox="0 0 32 32" - sodipodi:docname="gui_edit.svg" - inkscape:version="1.0 (4035a4f, 2020-05-01)" - version="1.1" - id="svg2" + width="34.133335" height="34.133335" - width="34.133335"> + id="svg2" + version="1.1" + inkscape:version="1.0 (4035a4f, 2020-05-01)" + sodipodi:docname="gui_edit.svg" + viewBox="0 0 32 32"> + id="stop3776" /> + id="stop3778" /> + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="17.724608" + inkscape:cx="17.066668" + inkscape:cy="17.066668" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="true" + inkscape:snap-grids="true" + inkscape:snap-to-guides="false" + inkscape:window-width="1414" + inkscape:window-height="795" + inkscape:window-x="27" + inkscape:window-y="25" + inkscape:window-maximized="0" + inkscape:document-rotation="0"> + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" + originx="0" + originy="0" + spacingx="1" + spacingy="1" /> @@ -94,38 +94,33 @@ - + id="layer1" + transform="translate(0,-1020.3622)"> - + width="27.737642" + height="28.109545" + x="2.1311784" + y="1022.1215" + ry="0" /> + + + + id="path917" + d="m 19.79371,1024.4263 0.082,23.6605" + style="fill:none;stroke:#333333;stroke-width:1.875;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/light/logpanel.svg metview-5.19.2/metview/share/metview/app-defaults/images/light/logpanel.svg --- metview-5.17.4/metview/share/metview/app-defaults/images/light/logpanel.svg 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/light/logpanel.svg 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + ECMWF + + + en-GB + + + Metview icon + + + Metview icon + + + + + + + + + + diff -Nru metview-5.17.4/metview/share/metview/app-defaults/images/MacroEdit_light.qrc metview-5.19.2/metview/share/metview/app-defaults/images/MacroEdit_light.qrc --- metview-5.17.4/metview/share/metview/app-defaults/images/MacroEdit_light.qrc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/images/MacroEdit_light.qrc 2023-07-15 08:28:47.000000000 +0000 @@ -10,6 +10,7 @@ light/help.svg light/print.svg light/log.svg + light/logpanel.svg light/narrow_arrow_left.svg light/monitor.svg light/macro.svg diff -Nru metview-5.17.4/metview/share/metview/app-defaults/uitheme_dark.json metview-5.19.2/metview/share/metview/app-defaults/uitheme_dark.json --- metview-5.17.4/metview/share/metview/app-defaults/uitheme_dark.json 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/uitheme_dark.json 2023-07-15 08:28:47.000000000 +0000 @@ -81,6 +81,7 @@ { "GENERIC":{ "text":"p:text", + "highlightedtext":"p:highlightedtext", "subtext":"rgb(170,170,170)", "accenttext":"rgb(68,146,245)", "subwindow":"rgb(90,90,90)", @@ -113,7 +114,8 @@ "waiting_status":"rgb(255,188,46)", "error_status":"rgb(255,0,0)", "drag_count_pen":"p:text", - "drag_count_brush":"rgb(255,230,191)" + "drag_count_brush":"rgb(255,230,191)", + "broken_link":"rgb(232,98,62)" } }, { @@ -139,7 +141,8 @@ "bg_brush":"p:midlight", "helper_brush":"rgb(48,48,48)", "drag_label_border":"rgb(27,136,196)", - "warning_pen":"rgb(234,215,150)" + "warning_pen":"rgb(234,215,150)", + "name_warn_sh": "QLabel{color: rgb(221,125,57);background: transparent;}" } }, { @@ -152,8 +155,14 @@ } }, { + "lineedit":{ + "error_text":"rgb(255,0,0)", + "warning_sh":"QLineEdit{color: rgb(221,125,57); border: 2px solid rgb(165,102,18);}" + } + }, + { "searchline":{ - "normal":"QLineEdit{backgrouund: background: rgb(96, 95, 95); color: rgb(227,227,227);}", + "normal":"QLineEdit{background: background: rgb(96, 95, 95); color: rgb(227,227,227);}", "not_found":"QLineEdit{background: rgb(96, 95, 95); color: rgb(148,24,24);}" } }, diff -Nru metview-5.17.4/metview/share/metview/app-defaults/uitheme_light.json metview-5.19.2/metview/share/metview/app-defaults/uitheme_light.json --- metview-5.17.4/metview/share/metview/app-defaults/uitheme_light.json 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/app-defaults/uitheme_light.json 2023-07-15 08:28:47.000000000 +0000 @@ -60,6 +60,7 @@ { "GENERIC":{ "text":"p:text", + "highlightedtext":"p:highlightedtext", "subtext":"rgb(80,80,80)", "accenttext":"rgb(8,76,179)", "subwindow":"rgb(202,202,202)", @@ -92,7 +93,8 @@ "waiting_status":"rgb(255,188,46)", "error_status":"rgb(255,0,0)", "drag_count_pen":"p:text", - "drag_count_brush":"rgb(255,230,191)" + "drag_count_brush":"rgb(255,230,191)", + "broken_link":"rgb(232,98,62)" } }, { @@ -118,7 +120,8 @@ "bg_brush":"p:midlight", "helper_brush":"rgb(212,212,212)", "drag_label_border":"rgb(27,136,196)", - "warning_pen":"rgb(205,135,60)" + "warning_pen":"rgb(205,135,60)", + "name_warn_sh": "QLabel{color: rgb(165,108,23);background: transparent;}" } }, { @@ -131,8 +134,14 @@ } }, { + "lineedit":{ + "error_text":"rgb(255,0,0)", + "warning_sh":"QLineEdit{color: rgb(165,108,23); border: 2px solid rgb(165,108,23);}" + } + }, + { "searchline":{ - "normal":"QLineEdit{backgrouund: background: rgb(96, 95, 95); color: rgb(227,227,227);}", + "normal":"QLineEdit{background: background: rgb(96, 95, 95); color: rgb(227,227,227);}", "not_found":"QLineEdit{background: rgb(96, 95, 95); color: rgb(148,24,24);}" } }, diff -Nru metview-5.17.4/metview/share/metview/eccharts/layers.json metview-5.19.2/metview/share/metview/eccharts/layers.json --- metview-5.17.4/metview/share/metview/eccharts/layers.json 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/eccharts/layers.json 2023-07-15 08:28:47.000000000 +0000 @@ -2871,6 +2871,27 @@ ], "title" : "Total precipitation rate" }, + "tcw" : { + "description" : "Total column water", + "group" : "0010 High resolution forecast (HRES)", + "keywords" : [ + "deterministic", + "water", + "ice", + "cloud", + "water vapour", + "precipitable water" + ], + "style" : "sh_tcw_f5t100", + "styles" : [ + "sh_tcw_f5t100", + "sh_all_f05t300lst", + "ct_t2_f5t150_black", + "ct_t2_f5t150_blue", + "tcw_extra1" + ], + "title" : "Total column water" + }, "visibility" : { "description" : "Visibility from HRES forecast", "group" : "0010 High resolution forecast (HRES)", diff -Nru metview-5.17.4/metview/share/metview/eccharts/layers_mars.json metview-5.19.2/metview/share/metview/eccharts/layers_mars.json --- metview-5.17.4/metview/share/metview/eccharts/layers_mars.json 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/eccharts/layers_mars.json 2023-07-15 08:28:47.000000000 +0000 @@ -1283,6 +1283,16 @@ "proc" : "compute_sum", "shortName" : "prate" }, + "tcw" : { + "mars" : { + "class" : "od", + "levtype" : "sfc", + "param" : "136.128", + "stream" : "oper", + "type" : "fc" + }, + "shortName" : "tcw" + }, "visibility" : { "mars" : { "class" : "od", diff -Nru metview-5.17.4/metview/share/metview/eccharts/style_previews/CMakeLists.txt metview-5.19.2/metview/share/metview/eccharts/style_previews/CMakeLists.txt --- metview-5.17.4/metview/share/metview/eccharts/style_previews/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/eccharts/style_previews/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -67,7 +67,7 @@ # CMake configure time metview_download_resource (${STYLE_PREVIEWS_TAR_DIR} # dest dir ${STYLE_PREVIEWS_TAR_NAME} # dest file - http://download.ecmwf.org/test-data/metview/eccharts/${STYLE_PREVIEWS_TAR_NAME} # source + https://get.ecmwf.int/repository/test-data/metview/eccharts/${STYLE_PREVIEWS_TAR_NAME} # source CMD_RESULT) if(CMD_RESULT) diff -Nru metview-5.17.4/metview/share/metview/eccharts/styles.json metview-5.19.2/metview/share/metview/eccharts/styles.json --- metview-5.17.4/metview/share/metview/eccharts/styles.json 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/eccharts/styles.json 2023-07-15 08:28:47.000000000 +0000 @@ -2795,6 +2795,19 @@ "sst_cf" ] }, + "sh_tcw_f5t100" : { + "colours" : [ + "blue", + "red" + ], + "keywords" : [ + "tcw", + "total column water" + ], + "layers" : [ + "tcw" + ] + }, "sh_viobrn_fM50t50lst_less" : { "colours" : [ "violet", diff -Nru metview-5.17.4/metview/share/metview/etc/AnnotationViewDef metview-5.19.2/metview/share/metview/etc/AnnotationViewDef --- metview-5.17.4/metview/share/metview/etc/AnnotationViewDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/AnnotationViewDef 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ %include MagicsColours.txt } = BLACK -SUBPAGE_FRAME_LINE_STYLE +SUBPAGE_FRAME_LINE_STYLE [interface = line_style] { SOLID ; SOLID DOT ; DOT diff -Nru metview-5.17.4/metview/share/metview/etc/AxisDef metview-5.19.2/metview/share/metview/etc/AxisDef --- metview-5.17.4/metview/share/metview/etc/AxisDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/AxisDef 2023-07-15 08:28:47.000000000 +0000 @@ -458,7 +458,7 @@ &PARAMSHARE&THICKNESS } = 1 - AXIS_GRID_LINE_STYLE + AXIS_GRID_LINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/CoastDef metview-5.19.2/metview/share/metview/etc/CoastDef --- metview-5.17.4/metview/share/metview/etc/CoastDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/CoastDef 2023-07-15 08:28:47.000000000 +0000 @@ -69,8 +69,7 @@ &PARAMSHARE&COLOUR } = Black - SUBPAGE_FRAME_LINE_STYLE - [ visible = false ] + SUBPAGE_FRAME_LINE_STYLE [interface = line_style, visible = false ] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -91,7 +90,7 @@ &PARAMSHARE&QUALITY } = MEDIUM - MAP_COASTLINE_STYLE + MAP_COASTLINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -111,7 +110,7 @@ &PARAMSHARE&ONOFF } = ON - MAP_GRID_LINE_STYLE + MAP_GRID_LINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/ContDef metview-5.19.2/metview/share/metview/etc/ContDef --- metview-5.17.4/metview/share/metview/etc/ContDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/ContDef 2023-07-15 08:28:47.000000000 +0000 @@ -306,7 +306,7 @@ SPLIT } = NOT_SPLIT - CONTOUR_LINE_STYLE + CONTOUR_LINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -331,7 +331,7 @@ * } = 4 - CONTOUR_HIGHLIGHT_STYLE + CONTOUR_HIGHLIGHT_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -351,7 +351,7 @@ @ } = 0.0 - CONTOUR_BELOW_LINE_STYLE + CONTOUR_BELOW_LINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = DASH @@ -366,7 +366,7 @@ &PARAMSHARE&COLOUR } = BLUE - CONTOUR_BELOW_HIGHLIGHT_STYLE + CONTOUR_BELOW_HIGHLIGHT_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = DASH @@ -386,7 +386,7 @@ &PARAMSHARE&ONOFF } = ON - CONTOUR_SPLIT_LINE_STYLE + CONTOUR_SPLIT_LINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -401,7 +401,7 @@ &PARAMSHARE&COLOUR } = BLACK - CONTOUR_ABOVE_LINE_STYLE + CONTOUR_ABOVE_LINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -416,7 +416,7 @@ &PARAMSHARE&COLOUR } = RED - CONTOUR_ABOVE_HIGHLIGHT_STYLE + CONTOUR_ABOVE_HIGHLIGHT_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/ecmwf.def metview-5.19.2/metview/share/metview/etc/ecmwf.def --- metview-5.17.4/metview/share/metview/etc/ecmwf.def 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/ecmwf.def 2023-07-15 08:28:47.000000000 +0000 @@ -242,6 +242,13 @@ MINIMUM VERTICAL GRADIENT OF REFRACTIVITY INSIDE TRAPPING LAYER ; DNDZN ; 228015 ; 015.228 MODEL BATHYMETRY ; WMB ; 219 MONTGOMERY POTENTIAL ; MONT ; 053 +MOST-UNSTABLE CAPE ; MUCAPE ; 228235 +MOST-UNSTABLE CIN ; MUCIN ; 228236 +DEPARTURE LEVEL OF THE MOST UNSTABLE PARCEL EXPRESSED AS PRESSURE ; MUDLP ; 228237 +MIXED-LAYER CAPE IN THE LOWEST 50 hPa ; MLCAPE50 ; 228231 +MIXED-LAYER CIN IN THE LOWEST 50 hPa ; MLCIN50 ; 228232 +MIXED-LAYER CAPE IN THE LOWEST 100 hPa ; MLCAPE100 ; 228233 +MIXED-LAYER CIN IN THE LOWEST 100 hPa ; MLCIN100 ; 228234 NORMALIZED ENERGY FLUX INTO WAVES ; PHIAW ; 211 NORMALIZED ENERGY FLUX INTO OCEAN ; PHIOC ; 212 NORMALIZED STRESS INTO OCEAN ; TAUOC ; 214 @@ -738,6 +745,7 @@ ULYSSES ; UL CAMS Research ; CR GLOBAL FIRE ; GW + MACHINE LEARNING ; ML ! Member stats AUSTRIA ; AT @@ -4155,6 +4163,7 @@ CO ; COMPLEX SO ; SECOND ORDER AV ; ARCHIVED VALUE + CCSDS OFF } = OFF @@ -4640,6 +4649,7 @@ CO ; COMPLEX SO ; SECOND ORDER AV ; ARCHIVED VALUE + CCSDS OFF } = OFF @@ -7342,6 +7352,7 @@ CO ; COMPLEX SO ; SECOND ORDER AV ; ARCHIVED VALUE + CCSDS OFF } = OFF diff -Nru metview-5.17.4/metview/share/metview/etc/FunctionList.txt metview-5.19.2/metview/share/metview/etc/FunctionList.txt --- metview-5.17.4/metview/share/metview/etc/FunctionList.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/FunctionList.txt 2023-07-15 08:28:47.000000000 +0000 @@ -1,27 +1,28 @@ -url: https://confluence.ecmwf.int/display/METV/ -date: Date+Functions -definition: Definition+Functions -fieldset: Fieldset+Functions -geopoints: Geopoints+Functions -geopointet: Geopointset+Functions -info: Information+Functions -io: File+Functions -list: List+Functions -netcdf: NetCDF+Functions -number: Number+Functions -odb: ODB+Functions -plot: Plotting+Functions -string: String+Functions -system: Macro+System+Functions -table: Table+Functions -timing: Timing+Functions -thermo: Thermodynamic+Functions -unix: UNIX+Interfacing+Functions -vector: Vector+Functions -mvl: The+Metview+Macro+Library -flexpart: FLEXPART+Functions -flextra: FLEXTRA+Functions -ui: UI+Functions +script_url: https://metview.readthedocs.io/en/latest/api/functions/ +icon_url: https://metview.readthedocs.io/en/latest/gen_files/icon_functions/ +macro_url: https://metview.readthedocs.io/en/latest/metview/macro/functions/ +date: date +definition: definition +fieldset: fieldset +geopoints: geopints +geopointset: geopointset +info: util +io: file +list: list +netcdf: netcdf +number: number +odb: odb +plot: plot +string: string +system: util +table: table +timing: util +thermo: thermo +unix: util +vector: vector +flexpart: flexpart +flextra: flextra +ui: ui -------------------------------------------- abs type: script @@ -34,6 +35,7 @@ desc: [fieldset] Arc cosine addmonths type: script + lang: macro desc: [date] Adds months to a date animated_gif_output type: icon @@ -43,13 +45,16 @@ type: icon append type: script + lang: macro desc: [io] Writes/appends the given data to file. args: (string, any) desc: [io] Writes/appends the given data to file. args: (filehandler, any) arguments type: script + lang: macro desc: [info] Returns the list of the calling arguments of the current function ascii type: script + lang: macro desc: [string] Returns the corresponding ASCII character asin type: script @@ -102,6 +107,10 @@ desc: [geopoints] Returns a list of column names for a geopoints variable compute type: icon +convolve + type: script + lang: python + desc: [fieldset] Performs spatial convolution on a Fieldset corr_a type: script desc: [fieldset] Computes the area-weighted correlation for each field in a fieldset @@ -133,13 +142,14 @@ desc: [fieldset] Returns information on missing values in fieldsets date type: script - desc: [date] Returns a list/vector of dates from the given geopoints. + lang: macro desc: [date] Creates a date from a number or a string dates type: script desc: [geopoints] Returns a list/vector of dates from the given geopoints. day type: script + lang: macro desc: [date] Converts a number to a value suitable for date computations desc: [date] Extract a date component db_info @@ -149,9 +159,11 @@ type: icon describe type: script - desc: [info] Describes available function + lang: python + desc: [fieldset] Prints summary of the contents of a Fieldset dictionary type: script + lang: macro desc: [info] Returns the list of all the documented functions dimension_names type: script @@ -175,6 +187,7 @@ type: icon dow type: script + lang: macro desc: [date] Extract a date component download type: icon @@ -182,6 +195,7 @@ type: icon dtype type: script + lang: macro desc: [vector] Returns a string describing the vector's internal storage type duplicate type: script @@ -206,18 +220,21 @@ desc: [ui] Actives an interactive data examiner window on the given data exist type: script + lang: macro desc: [io] Determines whether the given file exists. Returns 1 or 0. args: (string) exp type: script desc: [fieldset] Exponential fail type: script + lang: macro desc: [system] Prints all its arguments and stop in error fetch type: script desc: [system] Returns the item stored in the named cache (or nil). args: (string) file type: script + lang: macro desc: [io] Returns a file handler for the specified filename. args: (string) filetype type: script @@ -271,6 +288,7 @@ type: icon getenv type: script + lang: macro desc: [unix] Return the value of a shell variable desc: [unix] Return the value of a shell variable gfind @@ -323,6 +341,7 @@ desc: [fieldset] Computes grid cell area for each gridpoints in a field hour type: script + lang: macro desc: [date] Converts a number to a value suitable for date computations desc: [date] Extract a date component hovmoeller_area @@ -339,6 +358,7 @@ type: icon in type: script + lang: macro desc: [list] Test if a value is in a list indexes type: script @@ -366,9 +386,11 @@ desc: [info] Returns 1 if the given feature is available, otherwise 0. Feature names: 'odb' juldate type: script + lang: macro desc: [date] Extract a date component julday type: script + lang: macro desc: [date] Extract a date component kml_output type: icon @@ -378,12 +400,14 @@ desc: [fieldset] Returns the grid point latitudes as a vector (or list of vectors) length type: script + lang: macro desc: [string] Returns the length of a string. levels type: script desc: [geopoints] Returns a list/vector of heights from the given geopoints. list type: script + lang: macro desc: [list] Builds a list from its arguments log type: script @@ -400,6 +424,7 @@ desc: [fieldset] Builds an output fieldset using the values in the first as indices into the second lowercase type: script + lang: macro desc: [string] Sets to unique case of letters magml type: icon @@ -478,6 +503,7 @@ desc: [fieldset] Minimum minute type: script + lang: macro desc: [date] Converts a number to a value suitable for date computations desc: [date] Extract a date component minvalue @@ -490,6 +516,7 @@ type: icon month type: script + lang: macro desc: [date] Extract a date component msymb type: icon @@ -540,6 +567,7 @@ desc: [io] Forces a new page on PostScript output nice type: script + lang: macro desc: [unix] Nice (nice value) nobitmap type: script @@ -547,9 +575,11 @@ desc: [fieldset] Clear bitmap of 1st fieldset assigning value instead now type: script + lang: macro desc: [date] Returns the current date and time number type: script + lang: macro desc: [number] Returns the number represented by the string obsfilter type: icon @@ -568,6 +598,7 @@ type: icon parse type: script + lang: macro desc: [string] Splits a string into tokens. paxis type: icon @@ -580,12 +611,14 @@ percentile type: icon percentile -percentile type: script desc: [vector] Returns a set of percentiles of a list of vector variables desc: [vector] Returns a set of percentiles of a vector pgraph type: icon +pl_to_pl + type: script + desc: [fieldset] Interpolates pressure level fields to pressure levels plot_page type: icon plot_subpage @@ -598,18 +631,26 @@ polar_vector type: script desc: [geopoints] Combines two 1-parameter geopoints variables into polar vector style +poly_mask: + type: script + desc: [fieldset] Generates polygon masks for a Fieldset pott_m type: icon pott_p type: icon precision type: script + lang: macro desc: [number] Sets the printing precision for floating point values. pressure type: script desc: [fieldset] Creates fields of pressure or thickness (input in lat/lon only). +pressure_derivative + type: script + desc: [fieldset] Computes the verical pressure derivative print type: script + lang: macro desc: [io] Prints all its arguments ps_output type: icon @@ -624,9 +665,14 @@ desc: [fieldset] Releases unused memory putenv type: script + lang: macro desc: [unix] Sets the value of an environment variable. pwind type: icon +q_vector + type: script + lang: python + desc: [fieldset] Computes the Q-vector random_vector type: script desc: [fieldset] Builds a new vector either with 'n' random value between 0 and 1 @@ -636,8 +682,6 @@ read type: script desc: [io] Reads the given file and returns a variable of the appropriate type. args: (string) -read_mir - type: icon read_request type: script desc: [fieldset] Reads the given request file and returns a list of dictionaries. args: (string) @@ -669,13 +713,16 @@ type: icon rmask type: script - desc: [fieldset] Generates masks based on a radius around a point for fieldsets + desc: [fieldset] Generates masks based on a radius around a point for Fieldsets rms type: script - desc: [fieldset] Returns the rms of two fieldsets desc: [fieldset] Returns the root mean square of all the fields of a variable +rms + type: script + desc: [fieldset] Computes the area-weighted root mean square for a Fieldset round type: script + lang: macro desc: [number] Rounds spurious decimals in a value. rttov_run type: icon @@ -690,9 +737,11 @@ type: icon search type: script + lang: macro desc: [string] Search for a given substring. second type: script + lang: macro desc: [date] Converts a number to a value suitable for date computations desc: [date] Extract a date component seqpott_m @@ -738,6 +787,7 @@ desc: [fieldset] Signum shell type: script + lang: macro desc: [unix] Execute a shell command sin type: script @@ -747,9 +797,18 @@ desc: [fieldset] Generates a field with the sine of the gridpoint latitudes sleep type: script + lang: macro desc: [unix] Sleep (number of seconds) slider type: icon +smooth_gaussian + type: script + lang: python + desc: [fieldset] Performs spatial smoothing on a Fieldset +smooth_n_points + type: script + lang: python + desc: [fieldset] Performs spatial smoothing on a Fieldset sort type: script desc: [vector] Sorts a vector according to an operator '<' (default) or '>' @@ -757,9 +816,11 @@ desc: [fieldset] Sorts a fieldset sort_and_indices type: script + lang: macro desc: [list] Sorts a list or indices (sort/sort_indices/sort_and_indices) sort_indices type: script + lang: macro desc: [vector] Sorts a vector according to an operator '<' (default) or '>' desc: [list] Sorts a list or indices (sort/sort_indices/sort_and_indices) spec_contour @@ -769,6 +830,10 @@ sqrt type: script desc: [fieldset] Square root +static_stability + type: script + lang: python + desc: [fieldset] Computes the static stability stations type: icon stdev @@ -782,18 +847,23 @@ desc: [geopoints] Returns a list/vector of station ids from the given geopoints. stop type: script + lang: macro desc: [system] Prints all its arguments and stop the macro stopwatch_laptime type: script + lang: macro desc: [timing] Provides stopwatch timings stopwatch_reset type: script + lang: macro desc: [timing] Provides stopwatch timings stopwatch_start type: script + lang: macro desc: [timing] Provides stopwatch timings stopwatch_stop type: script + lang: macro desc: [timing] Provides stopwatch timings store type: script @@ -805,6 +875,7 @@ desc: [geopoints] Filters from the first geopoints variable points that exist in the second substring type: script + lang: macro desc: [string] Returns a substring. sum type: script @@ -842,6 +913,7 @@ desc: [geopoints] Returns a list/vector of times from the given geopoints. tmpfile type: script + lang: macro desc: [io] Return a unique filename for a temporary file. toggle type: icon @@ -849,9 +921,11 @@ type: icon tolist type: script + lang: macro desc: [vector] Converts a vector into a list of numbers type type: script + lang: macro desc: [info] Returns the type of an expression ui_float type: icon @@ -862,6 +936,7 @@ desc: [fieldset] Creates fields of pressure or thickness (accepts several grid types) unique type: script + lang: macro desc: [vector] Returns a vector with all the unique items in the input vector desc: [list] Returns a list with all the unique items in the input list unithickness @@ -872,6 +947,7 @@ desc: [fieldset] Universal vertical integration, also for sparse vertical data uppercase type: script + lang: macro desc: [string] Sets to unique case of letters uvwind type: icon @@ -909,9 +985,11 @@ desc: [netcdf] Returns a list of the names of the given netcdf file's variables. vector type: script + lang: macro desc: [list] Builds a new vector either with 'n' zero elements or populated from a list vector_set_default_type type: script + lang: macro desc: [vector] Sets the default internal storage type for all subsequent vectors velpot type: icon @@ -927,6 +1005,7 @@ type: icon waitmode type: script + lang: macro desc: [system] Causes Macro to always wait(1)/not wait(0) for functions to complete before continuing. wmsclient type: icon @@ -943,12 +1022,15 @@ desc: [geopoints] Combines two 1-parameter geopoints variables into u/v vector style year type: script + lang: macro desc: [date] Extract a date component yymmdd type: script + lang: macro desc: [date] Extract a date component yyyymmdd type: script + lang: macro desc: [date] Extract a date component # MVL functions absolute_vorticity diff -Nru metview-5.17.4/metview/share/metview/etc/GraphDef metview-5.19.2/metview/share/metview/etc/GraphDef --- metview-5.17.4/metview/share/metview/etc/GraphDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/GraphDef 2023-07-15 08:28:47.000000000 +0000 @@ -111,7 +111,7 @@ &PARAMSHARE&COLOUR } = BLUE - GRAPH_LINE_STYLE + GRAPH_LINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -158,7 +158,7 @@ DROP ; DROP } = IGNORE - GRAPH_MISSING_DATA_STYLE + GRAPH_MISSING_DATA_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = DASH @@ -183,7 +183,7 @@ @ } = 0. - GRAPH_BAR_LINE_STYLE + GRAPH_BAR_LINE_STYLE [interface = line_style] { &PARAMSHARE&LINE_STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/grib_def/definitions/grib2/localConcepts/65535/units.def metview-5.19.2/metview/share/metview/etc/grib_def/definitions/grib2/localConcepts/65535/units.def --- metview-5.17.4/metview/share/metview/etc/grib_def/definitions/grib2/localConcepts/65535/units.def 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/grib_def/definitions/grib2/localConcepts/65535/units.def 2023-07-15 08:28:47.000000000 +0000 @@ -62,7 +62,7 @@ centre = 65535; } -#FLEXPART response function for mass mixing ratio +#FLEXPART response function for mass ratio 'kg s m**-3' = { discipline = 0 ; parameterCategory = 20 ; diff -Nru metview-5.17.4/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/name.def metview-5.19.2/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/name.def --- metview-5.17.4/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/name.def 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/name.def 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -#Mass density (concentration) -'Mass density (concentration)' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 0 ; - } - -#Mass mixing ratio -'Mass mixing ratio' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 2 ; - } - -#FLEXPART tracer mass concentration -'FLEXPART tracer mass concentration' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 192 ; - } - -#FLEXPART tracer mass ratio -'FLEXPART tracer mass ratio' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 193 ; - } - -#FLEXPART particle resident time -'FLEXPART particle resident time' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 194 ; - } - -#FLEXPART response function for mass concentration -'FLEXPART response function for mass concentration' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 195 ; - } - -#FLEXPART response function for mass ratio -'FLEXPART response function for mass ratio' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 196 ; - } - -#FLEXPART dry deposition concentration -'FLEXPART dry deposition concentration' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 197 ; - } - -#FLEXPART wet deposition concentration -'FLEXPART wet deposition concentration' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 198 ; - } - -#FLEXPART dry deposition mixing ratio -'FLEXPART dry deposition mixing ratio' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 199 ; - } - -#FLEXPART wet deposition mixing ratio -'FLEXPART wet deposition mixing ratio' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 200 ; - } - -#FLEXPART eastward flux -'FLEXPART eastward flux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 201 ; - } - -#FLEXPART westward flux -'FLEXPART westward flux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 202 ; - } - -#FLEXPART southward flux -'FLEXPART southward flux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 203 ; - } - -#FLEXPART northward flux -'FLEXPART northward flux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 204 ; - } - -#FLEXPART upward flux -'FLEXPART upward flux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 205 ; - } - -#FLEXPART downward flux -'FLEXPART downward flux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 206 ; - } diff -Nru metview-5.17.4/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/paramId.def metview-5.19.2/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/paramId.def --- metview-5.17.4/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/paramId.def 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/paramId.def 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -#Mass density (concentration) -'20000' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 0 ; - } - -#Mass mixing ratio -'20002' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 2 ; - } - -#FLEXPART tracer mass concentration -'20192' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 192 ; - } - -#FLEXPART tracer mass ratio -'20193' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 193 ; - } - -#FLEXPART particle resident time -'20194' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 194 ; - } - -#FLEXPART response function for mass concentration -'20195' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 195 ; - } - -#FLEXPART response function for mass ratio -'20196' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 196 ; - } - -#FLEXPART dry deposition concentration -'20197' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 197 ; - } - -#FLEXPART wet deposition concentration -'20198' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 198 ; - } - -#FLEXPART dry deposition mixing ratio -'20199' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 199 ; - } - -#FLEXPART wet deposition mixing ratio -'20200' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 200 ; - } - -#FLEXPART eastward flux -'20201' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 201 ; - } - -#FLEXPART westward flux -'20202' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 202 ; - } - -#FLEXPART southward flux -'20203' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 203 ; - } - -#FLEXPART northward flux -'20204' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 204 ; - } - -#FLEXPART upward flux -'20205' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 205 ; - } - -#FLEXPART downward flux -'20206' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 206 ; - } diff -Nru metview-5.17.4/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/shortName.def metview-5.19.2/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/shortName.def --- metview-5.17.4/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/shortName.def 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/shortName.def 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -#Mass density (concentration) -'mdc' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 0 ; - } - -#Mass mixing ratio -'mmr' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 2 ; - } - -#FLEXPART tracer mass concentration -'ftmc' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 192 ; - } - -#FLEXPART tracer mass ratio -'ftmr' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 193 ; - } - -#FLEXPART particle resident time -'fprt' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 194 ; - } - -#FLEXPART response function for mass concentration -'frfmc' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 195 ; - } - -#FLEXPART response function for mass ratio -'frfmr' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 196 ; - } - -#FLEXPART dry deposition concentration -'fddc' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 197 ; - } - -#FLEXPART wet deposition concentration -'fwdc' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 198 ; - } - -#FLEXPART dry deposition mixing ratio -'fddmr' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 199 ; - } - -#FLEXPART wet deposition mixing ratio -'fwdmr' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 200 ; - } - -#FLEXPART eastward flux -'feflux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 201 ; - } - -#FLEXPART westward flux -'fwflux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 202 ; - } - -#FLEXPART southward flux -'fsflux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 203 ; - } - -#FLEXPART northward flux -'fnflux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 204 ; - } - -#FLEXPART upward flux -'fuflux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 205 ; - } - -#FLEXPART downward flux -'fdflux' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 206 ; - } diff -Nru metview-5.17.4/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/units.def metview-5.19.2/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/units.def --- metview-5.17.4/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/units.def 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/grib_def/flexpart/grib2/localConcepts/65535/units.def 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -#Mass density (concentration) -'kg m**-3' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 0 ; - } - -#Mass mixing ratio -'kg kg**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 2 ; - } - -#FLEXPART tracer mass concentration -'ng m**-3' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 192 ; - } - -#FLEXPART tracer mass ratio -'ppt by mass' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 193 ; - } - -#FLEXPART particle resident time -'s' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 194 ; - } - -#FLEXPART response function for mass concentration -'m**3 s kg**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 195 ; - } - -#FLEXPART response function for mass ratio -'kg s m**-3' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 196 ; - } - -#FLEXPART dry deposition concentration -'kg m**-2' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 197 ; - } - -#FLEXPART wet deposition concentration -'kg m**-2' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 198 ; - } - -#FLEXPART dry deposition mixing ratio -'kg kg**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 199 ; - } - -#FLEXPART wet deposition mixing ratio -'kg kg**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 200 ; -} - -#FLEXPART eastward flux -'kg m**-2 s**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 201 ; - } - -#FLEXPART westward flux -'kg m**-2 s**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 202 ; - } - -#FLEXPART southward flux -'kg m**-2 s**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 203 ; - } - -#FLEXPART northward flux -'kg m**-2 s**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 204 ; - } - -#FLEXPART upward flux -'kg m**-2 s**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 205 ; - } - -#FLEXPART downward flux -'kg m**-2 s**-1' = { - discipline = 0 ; - parameterCategory = 20 ; - parameterNumber = 206 ; - } - - diff -Nru metview-5.17.4/metview/share/metview/etc/mars.chk metview-5.19.2/metview/share/metview/etc/mars.chk --- metview-5.17.4/metview/share/metview/etc/mars.chk 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/mars.chk 2023-07-15 08:28:47.000000000 +0000 @@ -99,11 +99,14 @@ %if TYPE = CL %then %unset STEP -%if ( LEVTYPE = O2D %or LEVTYPE = O3D ) %then +%if (( LEVTYPE = O2D %or LEVTYPE = O3D ) %and CLASS = EP) %then %unset REPRES %unset LEVELIST %unset DOMAIN +%if LEVTYPE = O2D %then + %unset LEVELIST + %if LEVTYPE = SFC %or LEVTYPE = WAVE %then %unset LEVELIST @@ -382,6 +385,9 @@ STREAM = WAEF %or STREAM = WEHS %or STREAM = WEOV %or + STREAM = WEEF %or + STREAM = WEEH %or + STREAM = WEES %or STREAM = WAMO %or STREAM = SCWV %or STREAM = DCWV %or @@ -431,6 +437,10 @@ STREAM <> EWDA %and STREAM <> WEOV %and + STREAM <> WEEF %and + STREAM <> WEEH %and + STREAM <> WEES %and + STREAM <> MNFW %and STREAM <> MFHW %and STREAM <> MFAW %and diff -Nru metview-5.17.4/metview/share/metview/etc/MarsRules metview-5.19.2/metview/share/metview/etc/MarsRules --- metview-5.17.4/metview/share/metview/etc/MarsRules 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MarsRules 2023-07-15 08:28:47.000000000 +0000 @@ -99,11 +99,14 @@ %if TYPE = CL %then %unset STEP -%if ( LEVTYPE = O2D %or LEVTYPE = O3D ) %then +%if (( LEVTYPE = O2D %or LEVTYPE = O3D ) %and CLASS = EP) %then %unset REPRES %unset LEVELIST %unset DOMAIN +%if LEVTYPE = O2D %then + %unset LEVELIST + %if LEVTYPE = SFC %or LEVTYPE = WAVE %then %unset LEVELIST @@ -382,6 +385,9 @@ STREAM = WAEF %or STREAM = WEHS %or STREAM = WEOV %or + STREAM = WEEF %or + STREAM = WEEH %or + STREAM = WEES %or STREAM = WAMO %or STREAM = SCWV %or STREAM = DCWV %or @@ -431,6 +437,10 @@ STREAM <> EWDA %and STREAM <> WEOV %and + STREAM <> WEEF %and + STREAM <> WEEH %and + STREAM <> WEES %and + STREAM <> MNFW %and STREAM <> MFHW %and STREAM <> MFAW %and diff -Nru metview-5.17.4/metview/share/metview/etc/MAXISDef metview-5.19.2/metview/share/metview/etc/MAXISDef --- metview-5.17.4/metview/share/metview/etc/MAXISDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MAXISDef 2023-07-15 08:28:47.000000000 +0000 @@ -49,7 +49,7 @@ &PARAMSHARE&COLOUR } = AUTOMATIC - AXIS_LINE_STYLE + AXIS_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -70,7 +70,7 @@ &PARAMSHARE&COLOUR } = BLACK - AXIS_GRID_LINE_STYLE + AXIS_GRID_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -90,7 +90,7 @@ &PARAMSHARE&COLOUR } = AUTOMATIC - AXIS_GRID_REFERENCE_LINE_STYLE + AXIS_GRID_REFERENCE_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -308,7 +308,7 @@ &PARAMSHARE&COLOUR } = BLACK - AXIS_MINOR_GRID_LINE_STYLE + AXIS_MINOR_GRID_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/MBOXPLOTDef metview-5.19.2/metview/share/metview/etc/MBOXPLOTDef --- metview-5.17.4/metview/share/metview/etc/MBOXPLOTDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MBOXPLOTDef 2023-07-15 08:28:47.000000000 +0000 @@ -93,7 +93,7 @@ } = 1 BOXPLOT_BOX_BORDER_LINE_STYLE - [ help_text = 'Line style of the box border ' ] + [ help_text = 'Line style of the box border ', interface = line_style ] { SOLID; SOLID DASH; DASH @@ -122,7 +122,7 @@ } = 3 BOXPLOT_MEDIAN_LINE_STYLE - [ help_text = 'Line style of the median line ' ] + [ help_text = 'Line style of the median line ', interface = line_style ] { SOLID; SOLID DASH; DASH @@ -171,7 +171,7 @@ } = 1 BOXPLOT_WHISKER_BOX_BORDER_LINE_STYLE - [ help_text = 'Line style of the whisker box border ' ] + [ help_text = 'Line style of the whisker box border ', interface = line_style ] { SOLID; SOLID DASH; DASH @@ -193,7 +193,7 @@ } = 3 BOXPLOT_WHISKER_LINE_STYLE - [ help_text = 'Line style of the whisker line ' ] + [ help_text = 'Line style of the whisker line ', interface = line_style ] { SOLID; SOLID DASH; DASH diff -Nru metview-5.17.4/metview/share/metview/etc/MCOASTDef metview-5.19.2/metview/share/metview/etc/MCOASTDef --- metview-5.17.4/metview/share/metview/etc/MCOASTDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MCOASTDef 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,7 @@ &PARAMSHARE&COLOUR } = BLACK - MAP_COASTLINE_STYLE + MAP_COASTLINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -78,7 +78,7 @@ OFF;OFF } = OFF - MAP_RIVERS_STYLE + MAP_RIVERS_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -166,7 +166,7 @@ &PARAMSHARE&COLOUR } = EVERGREEN - MAP_BOUNDARIES_STYLE + MAP_BOUNDARIES_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -187,7 +187,7 @@ OFF; OFF } = ON - MAP_DISPUTED_BOUNDARIES_STYLE + MAP_DISPUTED_BOUNDARIES_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = DASH @@ -406,7 +406,7 @@ / } = '' - MAP_ADMINISTRATIVE_BOUNDARIES_STYLE + MAP_ADMINISTRATIVE_BOUNDARIES_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = DASH @@ -427,7 +427,7 @@ OFF; OFF } = ON - MAP_GRID_LINE_STYLE + MAP_GRID_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -468,7 +468,7 @@ OFF; OFF } = OFF - MAP_GRID_FRAME_LINE_STYLE + MAP_GRID_FRAME_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -582,7 +582,7 @@ &PARAMSHARE&COLOUR } = BLUE - MAP_USER_LAYER_STYLE + MAP_USER_LAYER_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/MGRAPHDef metview-5.19.2/metview/share/metview/etc/MGRAPHDef --- metview-5.17.4/metview/share/metview/etc/MGRAPHDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MGRAPHDef 2023-07-15 08:28:47.000000000 +0000 @@ -46,7 +46,7 @@ OFF; OFF } = ON - GRAPH_LINE_STYLE + GRAPH_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -98,7 +98,7 @@ * } = 1 - GRAPH_SYMBOL_OUTLINE_STYLE + GRAPH_SYMBOL_OUTLINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -130,7 +130,7 @@ DROP;DROP } = IGNORE - GRAPH_MISSING_DATA_STYLE + GRAPH_MISSING_DATA_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = DASH @@ -189,7 +189,7 @@ LINEBAR;LINEBAR } = BAR - GRAPH_BAR_LINE_STYLE + GRAPH_BAR_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/MLEGENDDef metview-5.19.2/metview/share/metview/etc/MLEGENDDef --- metview-5.17.4/metview/share/metview/etc/MLEGENDDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MLEGENDDef 2023-07-15 08:28:47.000000000 +0000 @@ -220,7 +220,7 @@ OFF; OFF } = OFF - LEGEND_BORDER_LINE_STYLE + LEGEND_BORDER_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -299,7 +299,7 @@ &PARAMSHARE&COLOUR } = BLACK - LEGEND_HISTOGRAM_GRID_LINE_STYLE + LEGEND_HISTOGRAM_GRID_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/MSYMBDef metview-5.19.2/metview/share/metview/etc/MSYMBDef --- metview-5.17.4/metview/share/metview/etc/MSYMBDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MSYMBDef 2023-07-15 08:28:47.000000000 +0000 @@ -56,7 +56,7 @@ * } = 1 - SYMBOL_OUTLINE_STYLE + SYMBOL_OUTLINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID @@ -83,7 +83,7 @@ * } = 1 - SYMBOL_CONNECT_LINE_STYLE + SYMBOL_CONNECT_LINE_STYLE [interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/MTAYLORDef metview-5.19.2/metview/share/metview/etc/MTAYLORDef --- metview-5.17.4/metview/share/metview/etc/MTAYLORDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MTAYLORDef 2023-07-15 08:28:47.000000000 +0000 @@ -50,7 +50,7 @@ } = 1 TAYLOR_PRIMARY_GRID_LINE_STYLE - [ help_text = 'Line Style used to plot the primary grid' ] + [ help_text = 'Line Style used to plot the primary grid', interface = line_style ] { SOLID; SOLID DASH; DASH @@ -78,7 +78,7 @@ } = 2 TAYLOR_REFERENCE_LINE_STYLE - [ help_text = 'Line Style used to plot the primary grid' ] + [ help_text = 'Line Style used to plot the primary grid', interface = line_style ] { SOLID; SOLID DASH; DASH @@ -138,7 +138,7 @@ } = 1 TAYLOR_SECONDARY_GRID_LINE_STYLE - [ help_text = 'Line Style used to plot the primary grid' ] + [ help_text = 'Line Style used to plot the primary grid', interface = line_style ] { SOLID; SOLID DASH; DASH diff -Nru metview-5.17.4/metview/share/metview/etc/MTEXTDef metview-5.19.2/metview/share/metview/etc/MTEXTDef --- metview-5.17.4/metview/share/metview/etc/MTEXTDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MTEXTDef 2023-07-15 08:28:47.000000000 +0000 @@ -156,7 +156,7 @@ OFF; OFF } = OFF - TEXT_BORDER_LINE_STYLE + TEXT_BORDER_LINE_STYLE [ interface = line_style ] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/MWINDDef metview-5.19.2/metview/share/metview/etc/MWINDDef --- metview-5.17.4/metview/share/metview/etc/MWINDDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/MWINDDef 2023-07-15 08:28:47.000000000 +0000 @@ -193,7 +193,7 @@ * } = -1.0E+21 - WIND_FLAG_STYLE + WIND_FLAG_STYLE [ interface = line_style ] { &PARAMSHARE&STYLE } = SOLID @@ -266,7 +266,7 @@ * } = 1 - WIND_ARROW_STYLE + WIND_ARROW_STYLE [ interface = line_style ] { &PARAMSHARE&STYLE } = SOLID @@ -301,7 +301,7 @@ &PARAMSHARE&COLOUR } = BLUE - WIND_STREAMLINE_STYLE + WIND_STREAMLINE_STYLE [ interface = line_style ] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/ObjectList metview-5.19.2/metview/share/metview/etc/ObjectList --- metview-5.17.4/metview/share/metview/etc/ObjectList 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/ObjectList 2023-07-15 08:28:47.000000000 +0000 @@ -67,7 +67,7 @@ lock_icon = '$METVIEW_DIR_SHARE/icons/lock_icon.icon', bugs_report = '$METVIEW_BIN/BugsReport', # vismod_table = '$TMPDIR/VisModTable' #VisMod - actions = execute/visualise/edit/examine/save/analyse/duplicate/print/link/delete/clear/send/compress/extract/export_macro/export_python/metzoom + actions = execute/visualise/edit/examine/save/analyse/duplicate/print/link/delete/clear/property/send/compress/archive/extract/extract_subfolder/export_macro/export_python/metzoom # actions = execute/visualise/edit/examine/save/duplicate/print/link/delete @@ -1740,8 +1740,8 @@ check = False, default_object = False, type = File, - can_have_log = False, - pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', + can_have_log = False, + pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', default_name = Tar File, editor_type = NoEditor, default_method = Examine @@ -1751,8 +1751,8 @@ check = False, default_object = False, type = File, - can_have_log = False, - pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', + can_have_log = False, + pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', default_name = TarGz File, editor_type = NoEditor, default_method = Examine @@ -1762,19 +1762,64 @@ check = False, default_object = False, type = File, - can_have_log = False, - pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', + can_have_log = False, + pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', default_name = TarBz2 File, editor_type = NoEditor, default_method = Examine object, + class = TAR_Z, + check = False, + default_object = False, + type = File, + can_have_log = False, + pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', + default_name = TarZ File, + editor_type = NoEditor, + default_method = Examine + +object, + class = GZ, + check = False, + default_object = False, + type = File, + can_have_log = False, + pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', + default_name = Gz File, + editor_type = NoEditor, + default_method = Examine + +object, + class = BZ2, + check = False, + default_object = False, + type = File, + can_have_log = False, + pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', + default_name = Bzip2 File, + editor_type = NoEditor, + default_method = Examine + + +object, + class = Z, + check = False, + default_object = False, + type = File, + can_have_log = False, + pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', + default_name = Z File, + editor_type = NoEditor, + default_method = Examine + +object, class = ZIP, check = False, default_object = False, type = File, - can_have_log = False, - pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', + can_have_log = False, + pixmap = '$METVIEW_DIR_SHARE/icons/TAR.icon', default_name = Zip File, editor_type = NoEditor, default_method = Examine @@ -1873,7 +1918,7 @@ ################################################################## state, - action = edit/duplicate/delete/cut/copy/copy_path/destroy/clear/send/compress/rename, + action = edit/duplicate/delete/cut/copy/copy_path/destroy/clear/property/send/compress/archive/rename, service = MetviewUI state, @@ -2035,63 +2080,109 @@ state, class = TAR, - action = execute, - service = '(x=\`dirname "%s"\`;cd \"\$x\" ; tar -xvf \"%s\")' + action = extract, + service = '(mv_extract \"%s\" tar ext)' state, class = TAR, - action = extract, - service = '(x=\`dirname "%s"\`;cd \"\$x\" ; y=\`$METVIEW_BIN/mv_uniquename "%s" .tar\`; mkdir \"\$y\"; cd \"\$y\"; tar -xvf \"%s\")' + action = extract_subfolder, + service = '(mv_extract \"%s\" tar sub)' state, class = TAR, action = examine, - service = '(y=$TMPDIR/\`basename "%s"\`.tar_contents;tar -tvf \"%s\" > \"\$y\";$METVIEW_EDITOR \"\$y\")' + service = '(mv_extract \"%s\" tar exam)' state, class = TAR_GZ, - action = execute, - service = '(x=\`dirname "%s"\`;cd \"\$x\" ; tar -xzvf \"%s\")' + action = extract, + service = '(mv_extract \"%s\" tar_gz ext)' state, class = TAR_GZ, - action = extract, - service = '(x=\`dirname "%s"\`;cd \"\$x\" ; y=\`$METVIEW_BIN/mv_uniquename "%s" .tar.gz\`; mkdir \"\$y\"; cd \"\$y\"; tar -xzvf \"%s\")' + action = extract_subfolder, + service = '(mv_extract \"%s\" tar_gz sub)' state, class = TAR_GZ, action = examine, - service = '(y=$TMPDIR/\`basename "%s"\`.tar_contents;tar -tzvf \"%s\" > \"\$y\";$METVIEW_EDITOR \"\$y\")' + service = '(mv_extract \"%s\" tar_gz exam)' state, class = TAR_BZ2, - action = execute, - service = '(x=\`dirname "%s"\`;cd \"\$x\" ; tar -xjvf \"%s\")' + action = extract, + service = '(mv_extract \"%s\" tar_bz2 ext)' state, class = TAR_BZ2, - action = extract, - service = '(x=\`dirname "%s"\`;cd \"\$x\" ; y=\`$METVIEW_BIN/mv_uniquename "%s" .tar.bz2 \`; mkdir \"\$y\"; cd \"\$y\"; tar -xjvf \"%s\")' + action = extract_subfolder, + service = '(mv_extract \"%s\" tar_bz2 sub)' state, class = TAR_BZ2, action = examine, - service = '(y=$TMPDIR/\`basename "%s"\`.tar_contents;tar -tjvf \"%s\" > \"\$y\";$METVIEW_EDITOR \"\$y\")' + service = '(mv_extract \"%s\" tar_bz2 exam)' + +state, + class = TAR_Z, + action = extract, + service = '(mv_extract \"%s\" tar_z ext)' + +state, + class = TAR_Z, + action = extract_subfolder, + service = '(mv_extract \"%s\" tar_z sub)' + +state, + class = TAR_Z, + action = examine, + service = '(mv_extract \"%s\" tar_z exam)' + +state, + class = GZ, + action = extract, + service = '(mv_extract \"%s\" gz ext)' + +state, + class = GZ, + action = extract_subfolder, + service = '(mv_extract \"%s\" gz sub)' + +state, + class = BZ2, + action = extract, + service = '(mv_extract \"%s\" bz2 ext)' + +state, + class = BZ2, + action = extract_subfolder, + service = '(mv_extract \"%s\" bz2 sub)' + +state, + class = Z, + action = extract, + service = '(mv_extract \"%s\" z ext)' + +state, + class = Z, + action = extract_subfolder, + service = '(mv_extract \"%s\" z sub)' state, class = ZIP, - action = execute, - service = '(x=\`dirname "%s"\`;cd \"\$x\" ; unzip \"%s\")' + action = extract, + #service = '(x=\`dirname "%s"\`;cd \"\$x\" ; unzip \"%s\")' + service = '(mv_extract \"%s\" zip ext)' state, class = ZIP, - action = extract, - service = '(x=\`dirname "%s"\`;cd \"\$x\" ; y=\`$METVIEW_BIN/mv_uniquename "%s" .zip\`; mkdir \"\$y\"; cd \"\$y\"; unzip \"%s\")' + action = extract_subfolder, + service = '(mv_extract \"%s\" zip sub)' state, class = ZIP, - action = examine, - service = '(y=$TMPDIR/\`basename "%s"\`.zip_contents;unzip -l \"%s\" > \"\$y\";$METVIEW_EDITOR \"\$y\")' + action = examine, + service = '(mv_extract \"%s\" zip exam)' state, class = STATIONS, @@ -2159,43 +2250,62 @@ desktop_icon_group_tool, name = send, - service = UiAppManager, + service = UiAppManager, action = SENDMAIL desktop_icon_group_tool, - name = compress_tgz, - param = tgz, - output = TAR_GZ, + name = archive_tgz, + param = tgz, + output = TAR_GZ, service = MvCompress, - action = COMPRESS + action = ARCHIVE desktop_icon_group_tool, - name = compress_tar, + name = archive_tar, param = tar, output = TAR, service = MvCompress, - action = COMPRESS + action = ARCHIVE desktop_icon_group_tool, - name = compress_tbz, + name = archive_tbz, param = tbz, output = TAR_BZ2, service = MvCompress, - action = COMPRESS + action = ARCHIVE desktop_icon_group_tool, - name = compress_tzip, - param = tzip, - output = TAR_ZIP, + name = archive_tz, + param = tz, + output = TAR_Z, service = MvCompress, - action = COMPRESS + action = ARCHIVE desktop_icon_group_tool, - name = compress_zip, + name = archive_zip, param = zip, output = ZIP, service = MvCompress, - action = COMPRESS + action = ARCHIVE +desktop_icon_group_tool, + name = compress_gz, + param = gz, + output = GZ, + service = MvCompress, + action = COMPRESS +desktop_icon_group_tool, + name = compress_bz2, + param = bz2, + output = BZ2, + service = MvCompress, + action = COMPRESS + +desktop_icon_group_tool, + name = compress_z, + param = z, + output = Z, + service = MvCompress, + action = COMPRESS diff -Nru metview-5.17.4/metview/share/metview/etc/obsgroups.def metview-5.19.2/metview/share/metview/etc/obsgroups.def --- metview-5.17.4/metview/share/metview/etc/obsgroups.def 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/obsgroups.def 2023-07-15 08:28:47.000000000 +0000 @@ -59,5 +59,10 @@ 61 ; TOVS MULTISENSOR ; TOVS_MS 62 ; Cloud reflectivity ; CLOUD_R 63 ; Cloud Lidar ; CLOUD_L +64 ; Satellite Lightning ; SATELLITE_LIGHTNING +65 ; GEOS VIS ; GEOS_VIS 66 ; OCONV ; OCONV +67 ; MWTS3 All-sky ; MWTS3_AS +68 ; GIIRS ; GIIRS +69 ; HIRAS ; HIRAS 99 ; TEST ; TEST diff -Nru metview-5.17.4/metview/share/metview/etc/reportypes.def metview-5.19.2/metview/share/metview/etc/reportypes.def --- metview-5.17.4/metview/share/metview/etc/reportypes.def 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/reportypes.def 2023-07-15 08:28:47.000000000 +0000 @@ -67,6 +67,7 @@ GOES 16 GEOS Radiances ; 4025 GOES 17 GEOS Radiances ; 4026 GOES 18 GEOS Radiances ; 4027 +METEOSAT 12 GEOS Allsky Radiances ; 4028 ERS 2 GOME O3 ; 5001 METEOSAT 8 SEVIRI O3 ; 5002 METEOSAT 9 SEVIRI O3 ; 5003 @@ -134,7 +135,7 @@ NPP VIIRS aerosol optical thickness ; 5065 CALIPSO attenuated aerosol lidar backscatter ; 5066 ENVISAT AATSR Aerosol ; 5067 -NPP OMPS O3 ; 5068 +NPP OMPS-nadir O3 ; 5068 TOMS ADEOS-I ; 5069 NIMBUS 4 BUV ; 5070 METOP-A GOME-2 PMAP ; 5071 @@ -158,7 +159,10 @@ METOP-C IASI Layer integrated mass density ; 5089 NOAA 20 VIIRS aerosol optical depth ; 5090 NPP VIIRS aerosol optical depth ; 5091 -NPP OMPS-LP O3 ; 5092 +NPP OMPS-limb O3 ; 5092 +NOAA 21 OMPS-nadir O3 ; 5093 +NOAA 21 VIIRS aerosol optical depth ; 5094 +NOAA 21 OMPS-limb O3 ; 5096 ENVISAT MERIS TCWV ; 6001 Sentinel 3A OLCI TCWV ; 6002 Sentinel 3B OLCI TCWV ; 6003 @@ -193,6 +197,8 @@ COSMIC2 E6 GPSRO ; 7029 SPIRE Lemur 3U GPSRO ; 7030 Sentinel 6A GPSRO ; 7031 +FY-3E GPSRO ; 7032 +PlanetiQ GPSRO ; 7033 METEOSAT 2 AMV ; 8001 METEOSAT 3 AMV ; 8002 METEOSAT 4 AMV ; 8003 @@ -258,6 +264,8 @@ Sentinel 3B AMV ; 8063 Mixed Sentinel AMV ; 8064 GOES 18 AMV ; 8065 +NOAA 21 AMV ; 8066 +METEOSAT 12 AMV ; 8067 Old ERS 1 Scatterometer ; 9001 New ERS 1 Scatterometer ; 9002 ERS 2 Scatterometer ; 9003 @@ -464,6 +472,7 @@ NOAA 5 VTPR2 Radiances ; 33004 NPP ATMS Radiances ; 34001 NOAA 20 ATMS Radiances ; 34002 +NOAA 21 ATMS Radiances ; 34003 TERRA MOPITT layer integrated mass density with averaging kernels and a priori profile ; 35001 ERS-2 GOME layer integrated mass density with averaging kernels ; 35002 ENVISAT SCIAMACHY layer integrated mass density with averaging kernels ; 35003 @@ -485,8 +494,10 @@ METOP-C GOME-2 layer integrated mass density with averaging kernels ; 35019 METOP-C GOME-2 layer integrated mass density with averaging kernels and a priori profile ; 35020 METOP-C IASI layer volumetric mixing ratio with averaging kernels and a priori profile ; 35021 +OCO-2 OCO layer volumetric mixing ratio with averaging kernels and a priori profile ; 35022 NPP CRIS Radiances ; 36001 NOAA 20 CRIS Radiances ; 36002 +NOAA 21 CRIS Radiances ; 36003 ENVISAT RALT WAVE ; 37001 JASON 1 RALT WAVE ; 37002 JASON 2 RALT WAVE ; 37003 @@ -511,6 +522,7 @@ MeteoFrance SST ; 40003 OSTIA ; 40004 OSISAF SEA ICE ; 40005 +AVHRR CCI snow cover ; 40006 GCOM-W1 AMSR-2 Radiances All-sky ; 41001 SAPHIR All-sky ; 42001 AMSUB NOAA 15 AMSUB Radiances All-sky ; 43001 @@ -528,6 +540,7 @@ ENVISAT AATSR brightness teperatures ; 48001 NPP ATMS Radiances All-sky ; 49001 NOAA 20 ATMS Radiances All-sky ; 49002 +NOAA 21 ATMS Radiances All-sky ; 49003 GPM GMI Radiances All-sky ; 50001 METOP-B GODAE sea surface temperature ; 51001 Meteosat 9 GODAE sea surface temperature ; 51002 @@ -560,6 +573,12 @@ UKMO TOVS ; 60001 CloudSat CPR reflectivity ; 61001 Calipso CALIOP backscatter ; 62001 +GOES 16 GLM Lightning ; 63001 +METEOSAT 11 SEVIRI Reflectances ; 64001 +GOES 18 ABI Reflectances ; 64002 +METEOSAT 10 SEVIRI Reflectances ; 64003 +GOES 16 ABI Reflectances ; 64004 +METEOSAT 9 SEVIRI Reflectances ; 64005 ARGO float ; 65001 Animal borne sensor ; 65002 Ocean Station Vessel On Station ; 65049 @@ -577,6 +596,11 @@ BUFR moored buoy subsurface ; 65083 BUFR drifting buoy subsurface ; 65084 Uncrewed surface vessel subsurface ; 65090 +FY-3E MWTS3 Radiances All-sky ; 66001 +FY-4A GIIRS Radiances ; 67001 +FY-4B GIIRS Radiances ; 67002 +FY-3D HIRAS Radiances ; 68001 +FY-3E HIRAS-2 Radiances ; 68002 TEST REPORTYPE 1 ; 98001 TEST REPORTYPE 2 ; 98002 TEST REPORTYPE 3 ; 98003 diff -Nru metview-5.17.4/metview/share/metview/etc/rt_by_obsgroup.chk metview-5.19.2/metview/share/metview/etc/rt_by_obsgroup.chk --- metview-5.17.4/metview/share/metview/etc/rt_by_obsgroup.chk 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/rt_by_obsgroup.chk 2023-07-15 08:28:47.000000000 +0000 @@ -11,19 +11,19 @@ %set REPORTYPE = 3001/3002/3003/3004/3005 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = GEOS ) %and %not REPORTYPE %then - %set REPORTYPE = 4002/4003/4004/4005/4006/4007/4008/4009/4010/4011/4012/4013/4014/4015/4016/4017/4018/4019/4020/4021/4022/4023/4024/4025/4026/4027 + %set REPORTYPE = 4002/4003/4004/4005/4006/4007/4008/4009/4010/4011/4012/4013/4014/4015/4016/4017/4018/4019/4020/4021/4022/4023/4024/4025/4026/4027/4028 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = RESAT ) %and %not REPORTYPE %then - %set REPORTYPE = 5001/5002/5003/5004/5005/5006/5007/5008/5009/5010/5011/5012/5013/5014/5015/5016/5017/5018/5019/5020/5021/5022/5023/5024/5025/5026/5027/5028/5029/5030/5031/5032/5033/5034/5035/5036/5037/5038/5039/5040/5041/5042/5043/5044/5045/5046/5047/5048/5049/5050/5051/5052/5053/5054/5055/5056/5057/5058/5059/5060/5061/5062/5063/5064/5065/5066/5067/5068/5069/5070/5071/5072/5073/5074/5075/5076/5077/5078/5079/5080/5081/5082/5083/5084/5085/5086/5087/5088/5089/5090/5091/5092 + %set REPORTYPE = 5001/5002/5003/5004/5005/5006/5007/5008/5009/5010/5011/5012/5013/5014/5015/5016/5017/5018/5019/5020/5021/5022/5023/5024/5025/5026/5027/5028/5029/5030/5031/5032/5033/5034/5035/5036/5037/5038/5039/5040/5041/5042/5043/5044/5045/5046/5047/5048/5049/5050/5051/5052/5053/5054/5055/5056/5057/5058/5059/5060/5061/5062/5063/5064/5065/5066/5067/5068/5069/5070/5071/5072/5073/5074/5075/5076/5077/5078/5079/5080/5081/5082/5083/5084/5085/5086/5087/5088/5089/5090/5091/5092/5093/5094/5096 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = MERIS ) %and %not REPORTYPE %then %set REPORTYPE = 6001/6002/6003 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = GPSRO ) %and %not REPORTYPE %then - %set REPORTYPE = 7001/7002/7003/7004/7005/7006/7007/7008/7009/7010/7011/7012/7013/7014/7015/7016/7017/7018/7019/7020/7021/7022/7023/7024/7025/7026/7027/7028/7029/7030/7031 + %set REPORTYPE = 7001/7002/7003/7004/7005/7006/7007/7008/7009/7010/7011/7012/7013/7014/7015/7016/7017/7018/7019/7020/7021/7022/7023/7024/7025/7026/7027/7028/7029/7030/7031/7032/7033 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = SATOB ) %and %not REPORTYPE %then - %set REPORTYPE = 8001/8002/8003/8004/8005/8006/8007/8008/8009/8010/8011/8012/8013/8014/8015/8016/8017/8018/8019/8020/8021/8022/8023/8024/8025/8026/8027/8028/8029/8030/8031/8032/8033/8034/8035/8036/8037/8038/8039/8040/8041/8042/8043/8044/8045/8046/8047/8048/8049/8050/8051/8052/8053/8054/8055/8056/8057/8058/8059/8060/8061/8062/8063/8064/8065 + %set REPORTYPE = 8001/8002/8003/8004/8005/8006/8007/8008/8009/8010/8011/8012/8013/8014/8015/8016/8017/8018/8019/8020/8021/8022/8023/8024/8025/8026/8027/8028/8029/8030/8031/8032/8033/8034/8035/8036/8037/8038/8039/8040/8041/8042/8043/8044/8045/8046/8047/8048/8049/8050/8051/8052/8053/8054/8055/8056/8057/8058/8059/8060/8061/8062/8063/8064/8065/8066/8067 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = SCATT ) %and %not REPORTYPE %then %set REPORTYPE = 9001/9002/9003/9004/9005/9006/9007/9008/9009/9010/9011/9012/9013/9014/9015 @@ -98,13 +98,13 @@ %set REPORTYPE = 33001/33002/33003/33004 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = ATMS ) %and %not REPORTYPE %then - %set REPORTYPE = 34001/34002 + %set REPORTYPE = 34001/34002/34003 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = RESAT_AK ) %and %not REPORTYPE %then - %set REPORTYPE = 35001/35002/35003/35004/35005/35006/35007/35008/35009/35010/35011/35012/35013/35014/35015/35016/35017/35018/35019/35020/35021 + %set REPORTYPE = 35001/35002/35003/35004/35005/35006/35007/35008/35009/35010/35011/35012/35013/35014/35015/35016/35017/35018/35019/35020/35021/35022 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = CRIS ) %and %not REPORTYPE %then - %set REPORTYPE = 36001/36002 + %set REPORTYPE = 36001/36002/36003 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = WAVE_IP ) %and %not REPORTYPE %then %set REPORTYPE = 37001/37002/37003/37004/37005/37006/37007/37008/37009/37010/37012/37013 @@ -116,7 +116,7 @@ %set REPORTYPE = 39001/39002/39003/39004/39005 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = SFC_MS ) %and %not REPORTYPE %then - %set REPORTYPE = 40001/40002/40003/40004/40005 + %set REPORTYPE = 40001/40002/40003/40004/40005/40006 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = AMSR2_AS ) %and %not REPORTYPE %then %set REPORTYPE = 41001 @@ -140,7 +140,7 @@ %set REPORTYPE = 48001 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = ATMS_AS ) %and %not REPORTYPE %then - %set REPORTYPE = 49001/49002 + %set REPORTYPE = 49001/49002/49003 %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = GMI_AS ) %and %not REPORTYPE %then %set REPORTYPE = 50001 @@ -181,9 +181,24 @@ %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = CLOUD_L ) %and %not REPORTYPE %then %set REPORTYPE = 62001 +%if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = SATELLITE_LIGHTNING ) %and %not REPORTYPE %then + %set REPORTYPE = 63001 + +%if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = GEOS_VIS ) %and %not REPORTYPE %then + %set REPORTYPE = 64001/64002/64003/64004/64005 + %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = OCONV ) %and %not REPORTYPE %then %set REPORTYPE = 65001/65002/65049/65050/65051/65052/65053/65054/65056/65057/65061/65062/65063/65064/65083/65084/65090 +%if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = MWTS3_AS ) %and %not REPORTYPE %then + %set REPORTYPE = 66001 + +%if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = GIIRS ) %and %not REPORTYPE %then + %set REPORTYPE = 67001/67002 + +%if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = HIRAS ) %and %not REPORTYPE %then + %set REPORTYPE = 68001/68002 + %if (TYPE = OFB %or TYPE = MFB %or TYPE = OAI %or TYPE = SFB %or TYPE = FSOIFB %or TYPE = FCDFB) %and (OBSGROUP = TEST ) %and %not REPORTYPE %then %set REPORTYPE = 98001/98002/98003/98004/98005/98006/98007/98008/98009/98010/98011/98012/98013/98014/98015/98016/98017/98018/98019/98020/98021/98022/98023/98024/98025/98026/98027/98028/98029/98030/98031/98032/98033/98034/98035/98036/98037/98038/98039/98040 diff -Nru metview-5.17.4/metview/share/metview/etc/SubpageFrameDef metview-5.19.2/metview/share/metview/etc/SubpageFrameDef --- metview-5.17.4/metview/share/metview/etc/SubpageFrameDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/SubpageFrameDef 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,7 @@ %include MagicsColours.txt } = BLACK -SUBPAGE_FRAME_LINE_STYLE +SUBPAGE_FRAME_LINE_STYLE [ interface = line_style ] { SOLID ; SOLID DOT ; DOT diff -Nru metview-5.17.4/metview/share/metview/etc/TextDef metview-5.19.2/metview/share/metview/etc/TextDef --- metview-5.17.4/metview/share/metview/etc/TextDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/TextDef 2023-07-15 08:28:47.000000000 +0000 @@ -478,7 +478,7 @@ &PARAMSHARE&COLOUR } = BLUE - TEXT_BORDER_LINE_STYLE + TEXT_BORDER_LINE_STYLE [ interface = line_style ] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -601,7 +601,7 @@ &PARAMSHARE&COLOUR } = BLUE - LEGEND_BORDER_LINE_STYLE + LEGEND_BORDER_LINE_STYLE [ interface = line_style ] { &PARAMSHARE&LINE_STYLE } = SOLID @@ -702,7 +702,7 @@ # &PARAMSHARE&COLOUR # } = BLUE -# IMAGE_LEGEND_BORDER_LINE_STYLE +# IMAGE_LEGEND_BORDER_LINE_STYLE [ interface = line_style ] # { # &PARAMSHARE&LINE_STYLE # } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/UiSpec.FolderView metview-5.19.2/metview/share/metview/etc/UiSpec.FolderView --- metview-5.17.4/metview/share/metview/etc/UiSpec.FolderView 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/UiSpec.FolderView 2023-07-15 08:28:47.000000000 +0000 @@ -3,10 +3,24 @@ #------------------------------------ icon_menu, + id = extract, + type = submenu, + label = 'Extract ...', + icon = extract + +icon_menu, + cmd = extract, + label = 'here', + parent_menu = extract + +icon_menu, + cmd = extract_subfolder, + label = 'to subfolder', + parent_menu = extract + +icon_menu, cmd = execute, - label = 'E&xecute', - icon = execute - + label = 'E&xecute' icon_menu, cmd = visualise, @@ -44,7 +58,7 @@ label = Clear result icon_menu, - cmd = export_macro, + cmd = export_macro, label = Generate Macro, icon = macro @@ -117,11 +131,16 @@ icon = editrename icon_menu, + id = property, + cmd = property, + label = 'Properties' + +icon_menu, id = delete, - cmd = delete, + cmd = delete, label = 'Move to &wastebasket', shortcut = Del, - icon = wastebasket, + icon = wastebasket, group = true icon_menu, @@ -163,49 +182,54 @@ service = icon_group_tool icon_menu, - id = compress, + id = archive, type = submenu, - label = 'Archive as ...' + label = 'Archive as ...' icon_menu, - cmd = compress_tgz, + cmd = archive_tgz, label = 'TAR/&GZ', - parent_menu = compress, + parent_menu = archive, service = icon_group_tool icon_menu, type = separator, - parent_menu = compress + parent_menu = archive icon_menu, - cmd = compress_tbz, - label = 'TAR/&BZIP', - parent_menu = compress, + cmd = archive_tbz, + label = 'TAR/&BZIP2', + parent_menu = archive, service = icon_group_tool -#icon_menu, -# cmd = compress_tzip, -# label = 'TAR/ZI&P', -# parent_menu = compress, -# service = icon_group_tool - icon_menu, - cmd = compress_tar, + cmd = archive_tar, label = '&TAR', - parent_menu = compress, + parent_menu = archive, service = icon_group_tool #icon_menu, -# cmd = compress_zip, -# label = '&ZIP', -# parent_menu = compress, -# service = icon_group_tool +# cmd = archive_zip, +# label = '&ZIP', +# parent_menu = archive, +# service = icon_group_tool +icon_menu, + id = compress, + type = submenu, + label = 'Compress as ...' icon_menu, - cmd = extract, - label = 'Extract' + cmd = compress_gz, + label = 'GZIP', + parent_menu = compress, + service = icon_group_tool +icon_menu, + cmd = compress_bz2, + label = 'BZIP2', + parent_menu = compress, + service = icon_group_tool #------------------------------------ # Icon group context menu @@ -230,4 +254,7 @@ icon_menu_id = send group_menu, + icon_menu_id = archive + +group_menu, icon_menu_id = compress diff -Nru metview-5.17.4/metview/share/metview/etc/UiSpec.IconFolderView metview-5.19.2/metview/share/metview/etc/UiSpec.IconFolderView --- metview-5.17.4/metview/share/metview/etc/UiSpec.IconFolderView 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/UiSpec.IconFolderView 2023-07-15 08:28:47.000000000 +0000 @@ -116,7 +116,7 @@ desktop_menu, cmd = recheck_type, - label = '&Recheck file types' + label = '&Recheck icon types' desktop_menu, cmd = reload, diff -Nru metview-5.17.4/metview/share/metview/etc/WindDef metview-5.19.2/metview/share/metview/etc/WindDef --- metview-5.17.4/metview/share/metview/etc/WindDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/WindDef 2023-07-15 08:28:47.000000000 +0000 @@ -271,7 +271,7 @@ &PARAMSHARE&COLOUR } = BLUE - WIND_STREAMLINE_STYLE + WIND_STREAMLINE_STYLE [ interface = line_style ] { &PARAMSHARE&LINE_STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/WsMarkerDef metview-5.19.2/metview/share/metview/etc/WsMarkerDef --- metview-5.17.4/metview/share/metview/etc/WsMarkerDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/WsMarkerDef 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ * } = 1 - LINE_STYLE [ribbon_interface = line_style] + LINE_STYLE [ribbon_interface = line_style, interface = line_style ] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/WsPlacemarkDef metview-5.19.2/metview/share/metview/etc/WsPlacemarkDef --- metview-5.17.4/metview/share/metview/etc/WsPlacemarkDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/WsPlacemarkDef 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ * } = 1 - LINE_STYLE [ribbon_interface = line_style] + LINE_STYLE [ribbon_interface = line_style, interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/WsShapeDef metview-5.19.2/metview/share/metview/etc/WsShapeDef --- metview-5.17.4/metview/share/metview/etc/WsShapeDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/WsShapeDef 2023-07-15 08:28:47.000000000 +0000 @@ -45,7 +45,7 @@ * } = 1 - LINE_STYLE [ribbon_interface = line_style] + LINE_STYLE [ribbon_interface = line_style, interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/WsTextDef metview-5.19.2/metview/share/metview/etc/WsTextDef --- metview-5.17.4/metview/share/metview/etc/WsTextDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/WsTextDef 2023-07-15 08:28:47.000000000 +0000 @@ -72,7 +72,7 @@ * } = 1 - LINE_STYLE [ ribbon_interface = line_style] + LINE_STYLE [ ribbon_interface = line_style, interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/etc/WsWmoSymbolDef metview-5.19.2/metview/share/metview/etc/WsWmoSymbolDef --- metview-5.17.4/metview/share/metview/etc/WsWmoSymbolDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/etc/WsWmoSymbolDef 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ * } = 1 - LINE_STYLE [ribbon_interface = line_style] + LINE_STYLE [ribbon_interface = line_style, interface = line_style] { &PARAMSHARE&STYLE } = SOLID diff -Nru metview-5.17.4/metview/share/metview/icons_mv5/CMakeLists.txt metview-5.19.2/metview/share/metview/icons_mv5/CMakeLists.txt --- metview-5.17.4/metview/share/metview/icons_mv5/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/icons_mv5/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -122,7 +122,6 @@ MXSECTION.xpm MXSECTIONVIEW.xpm MXSECTVIEW.xpm - OBSTAT_SCATTER.xpm OBSTAT_CURVE.xpm OBSTAT.xpm OVERLAY_CONTROL.xpm PAXIS.xpm PCOAST.xpm diff -Nru metview-5.17.4/metview/share/metview/icons_mv5/OBSTAT_CURVE.xpm metview-5.19.2/metview/share/metview/icons_mv5/OBSTAT_CURVE.xpm --- metview-5.17.4/metview/share/metview/icons_mv5/OBSTAT_CURVE.xpm 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/icons_mv5/OBSTAT_CURVE.xpm 1970-01-01 00:00:00.000000000 +0000 @@ -1,499 +0,0 @@ -/* XPM */ -static char * OBSTAT_CURVE_xpm[] = { -"32 32 464 2", -" c None", -". c #FFFFFF", -"+ c #CFCFCF", -"@ c #AFAFAF", -"# c #B0B0B0", -"$ c #DEDEDE", -"% c #DBDBDB", -"& c #303435", -"* c #1F2629", -"= c #3E4D52", -"- c #445154", -"; c #465255", -"> c #4B5357", -", c #4E5458", -"' c #505758", -") c #545859", -"! c #565A5B", -"~ c #575A5B", -"{ c #565A5A", -"] c #535758", -"^ c #515457", -"/ c #515656", -"( c #505355", -"_ c #4D5253", -": c #4C5252", -"< c #4C5253", -"[ c #4A5152", -"} c #4A4F51", -"| c #494F52", -"1 c #474F50", -"2 c #474E4F", -"3 c #181B1B", -"4 c #4B4D4D", -"5 c #F5F5F5", -"6 c #5C6060", -"7 c #466571", -"8 c #8CC2D5", -"9 c #99C8D9", -"0 c #A3CEDB", -"a c #AFD2DF", -"b c #B9D8E3", -"c c #C4DEE6", -"d c #CEE2E9", -"e c #D8E7ED", -"f c #E2ECF1", -"g c #EAF2F3", -"h c #E6EEF0", -"i c #E0EAEC", -"j c #DAE7E8", -"k c #D6E3E5", -"l c #D2E0E4", -"m c #CEDDE1", -"n c #CADADF", -"o c #C7D7DC", -"p c #C3D5DA", -"q c #BED2D8", -"r c #BDD1D5", -"s c #B9D0D4", -"t c #B8CDD3", -"u c #B4CCD0", -"v c #B1C9CE", -"w c #434B4B", -"x c #9B9B9B", -"y c #0C0E0F", -"z c #77B1C5", -"A c #89C0D3", -"B c #94C6D7", -"C c #A0CCDB", -"D c #AAD1DD", -"E c #B6D6E2", -"F c #C0DCE5", -"G c #CCE1E8", -"H c #D5E6EC", -"I c #DEEBEF", -"J c #E7F0F2", -"K c #E6F0F0", -"L c #E2ECED", -"M c #DDE7EB", -"N c #D7E4E8", -"O c #D3E1E4", -"P c #CFDEE2", -"Q c #CBDBDF", -"R c #C8D8DC", -"S c #C4D6DB", -"T c #C0D3D9", -"U c #BDD2D7", -"V c #BBCFD3", -"W c #B8CDD2", -"X c #B5CDD0", -"Y c #B3CCD0", -"Z c #8C9EA3", -"` c #3D4040", -" . c #0A0C0D", -".. c #79B8CE", -"+. c #85BDD2", -"@. c #91C4D6", -"#. c #9DCADA", -"$. c #A9D0DC", -"%. c #B3D5E1", -"&. c #BEDBE5", -"*. c #C8DFE7", -"=. c #D2E5EB", -"-. c #DBEAEE", -";. c #E5EFF1", -">. c #C3D3DA", -",. c #B8CED2", -"'. c #B4CAD1", -"). c #B0C7CE", -"!. c #B9CDD2", -"~. c #D1DFE3", -"{. c #CDDCDF", -"]. c #C8D9DE", -"^. c #C4D7DA", -"/. c #C2D5D8", -"(. c #BFD2D6", -"_. c #BBD1D5", -":. c #B9CFD4", -"<. c #B7CCD2", -"[. c #B4CBD0", -"}. c #9CB1B6", -"|. c #323333", -"1. c #75B6CD", -"2. c #82BCD1", -"3. c #8DC2D5", -"4. c #9AC8D9", -"5. c #A4CEDB", -"6. c #B0D3E0", -"7. c #BBD8E3", -"8. c #C5DFE7", -"9. c #CFE2EB", -"0. c #D9E9ED", -"a. c #E2EEF1", -"b. c #26617B", -"c. c #5795A1", -"d. c #5694A0", -"e. c #5794A2", -"f. c #396E87", -"g. c #CEDDDF", -"h. c #CADADD", -"i. c #C5D7DC", -"j. c #C3D4DA", -"k. c #B8CED1", -"l. c #B4CBD1", -"m. c #9DB1B6", -"n. c #090C0D", -"o. c #71B4CB", -"p. c #7DBAD0", -"q. c #8AC0D4", -"r. c #96C6D6", -"s. c #A1CCDB", -"t. c #ACD2DF", -"u. c #B7D7E2", -"v. c #C1DDE6", -"w. c #CCE1E9", -"x. c #DFEBEF", -"y. c #377087", -"z. c #A3E5E0", -"A. c #366F86", -"B. c #C2D6DB", -"C. c #C0D3D7", -"D. c #BDD2D6", -"E. c #9DB1B5", -"F. c #6EB2C9", -"G. c #7BB8CE", -"H. c #86BED3", -"I. c #93C5D5", -"J. c #A9D0DD", -"K. c #B4D5E1", -"L. c #BFDAE5", -"M. c #C8E0E7", -"N. c #D3E6EA", -"O. c #2F6880", -"P. c #9EBAC3", -"Q. c #9BB8C2", -"R. c #99B5BF", -"S. c #A5C0C7", -"T. c #BFD1D6", -"U. c #B9CFD3", -"V. c #B5CCD2", -"W. c #9EB2B5", -"X. c #6AAFC9", -"Y. c #77B6CD", -"Z. c #82BCD2", -"`. c #8FC3D5", -" + c #9AC9D9", -".+ c #A6CEDC", -"++ c #B1D3E0", -"@+ c #BBD9E4", -"#+ c #C6DFE7", -"$+ c #CFE4EB", -"%+ c #D9E9EE", -"&+ c #145671", -"*+ c #438996", -"=+ c #428996", -"-+ c #428895", -";+ c #377086", -">+ c #C5D8DB", -",+ c #C1D6D9", -"'+ c #BED3D7", -")+ c #BBD2D4", -"!+ c #B9CED3", -"~+ c #9FB2B7", -"{+ c #313232", -"]+ c #66AEC8", -"^+ c #73B3CC", -"/+ c #7FBAD0", -"(+ c #8CC1D4", -"_+ c #97C7D8", -":+ c #A3CDDB", -"<+ c #AED2DF", -"[+ c #B9D7E3", -"}+ c #C2DDE6", -"|+ c #CDE1E9", -"1+ c #D6E7ED", -"2+ c #347087", -"3+ c #175872", -"4+ c #77C5C3", -"5+ c #376F85", -"6+ c #C6D7DC", -"7+ c #C2D6D9", -"8+ c #BDD0D6", -"9+ c #9FB3B7", -"0+ c #63ACC7", -"a+ c #6FB3CB", -"b+ c #7CB9CE", -"c+ c #88BFD3", -"d+ c #94C5D7", -"e+ c #9ECBDA", -"f+ c #A9D1DD", -"g+ c #C9E0E8", -"h+ c #D4E6EA", -"i+ c #175873", -"j+ c #386F85", -"k+ c #C7D8DD", -"l+ c #C1D5D8", -"m+ c #BBD0D5", -"n+ c #5EAAC5", -"o+ c #6AB0C9", -"p+ c #90C3D5", -"q+ c #A3CCD9", -"r+ c #356D86", -"s+ c #376F87", -"t+ c #396F87", -"u+ c #3B7189", -"v+ c #215F79", -"w+ c #376F86", -"x+ c #C1D5D9", -"y+ c #BBD0D4", -"z+ c #B8CED3", -"A+ c #A0B3B6", -"B+ c #080B0C", -"C+ c #5AA8C4", -"D+ c #67AEC8", -"E+ c #73B5CC", -"F+ c #80BBD0", -"G+ c #9FC8D8", -"H+ c #377085", -"I+ c #9AC3C1", -"J+ c #1A5974", -"K+ c #185873", -"L+ c #386F87", -"M+ c #C7D9DC", -"N+ c #C0D2D8", -"O+ c #A0B4B8", -"P+ c #56A5C4", -"Q+ c #7CB9CF", -"R+ c #88C0D3", -"S+ c #9BC6D7", -"T+ c #377084", -"U+ c #387087", -"V+ c #CCDCDE", -"W+ c #C7D8DB", -"X+ c #BDD3D7", -"Y+ c #BBCFD4", -"Z+ c #A0B4B7", -"`+ c #313234", -" @ c #52A4C2", -".@ c #5FABC5", -"+@ c #6CB1C9", -"@@ c #78B6CD", -"#@ c #90C4D6", -"$@ c #98C5D6", -"%@ c #366F84", -"&@ c #387085", -"*@ c #A2B4B9", -"=@ c #080A0C", -"-@ c #4EA2C0", -";@ c #5BA8C4", -">@ c #68AEC9", -",@ c #74B5CC", -"'@ c #81BBD1", -")@ c #94C3D5", -"!@ c #387086", -"~@ c #A3B6B9", -"{@ c #313434", -"]@ c #4A9FBF", -"^@ c #57A6C4", -"/@ c #5FA6C2", -"(@ c #33778C", -"_@ c #418594", -":@ c #448795", -"<@ c #478894", -"[@ c #2F6A80", -"}@ c #12556B", -"|@ c #33717D", -"1@ c #32717C", -"2@ c #32707C", -"3@ c #225F75", -"4@ c #A3B5B8", -"5@ c #070A0B", -"6@ c #469DBD", -"7@ c #53A4C2", -"8@ c #56A1BC", -"9@ c #468E90", -"0@ c #78C8AE", -"a@ c #74C4AC", -"b@ c #2C687E", -"c@ c #1D6270", -"d@ c #7ED795", -"e@ c #2B6B78", -"f@ c #A3B7BA", -"g@ c #419BBC", -"h@ c #4FA2C1", -"i@ c #539EBA", -"j@ c #1E6270", -"k@ c #2B6B79", -"l@ c #A3B7BB", -"m@ c #303232", -"n@ c #3D99BB", -"o@ c #4BA0BF", -"p@ c #4F9CB9", -"q@ c #2D6B79", -"r@ c #A4B7BA", -"s@ c #3997B9", -"t@ c #469EBD", -"u@ c #4C9AB8", -"v@ c #1E6370", -"w@ c #A7B8BC", -"x@ c #3494B8", -"y@ c #439CBC", -"z@ c #4798B7", -"A@ c #458E90", -"B@ c #2C687D", -"C@ c #2D6C79", -"D@ c #A6B9BC", -"E@ c #3093B7", -"F@ c #3F99BB", -"G@ c #4497B7", -"H@ c #2B687D", -"I@ c #2B6C79", -"J@ c #A8B8BC", -"K@ c #2B91B5", -"L@ c #3A97BA", -"M@ c #4499B8", -"N@ c #2B7285", -"O@ c #398390", -"P@ c #3D8491", -"Q@ c #408692", -"R@ c #195874", -"S@ c #2B6780", -"T@ c #2D6781", -"U@ c #2E6981", -"V@ c #215D77", -"W@ c #326E85", -"X@ c #336E86", -"Y@ c #367087", -"Z@ c #1D5C77", -"`@ c #346D84", -" # c #356D85", -".# c #346E85", -"+# c #216073", -"@# c #326E7D", -"## c #326C7C", -"$# c #306D7C", -"%# c #356C80", -"&# c #A8B9BD", -"*# c #288EB3", -"=# c #3796B8", -"-# c #449CBE", -";# c #52A4C1", -"># c #6BB0CA", -",# c #84BDD2", -"'# c #90C3D6", -")# c #A6CFDC", -"!# c #B2D4E0", -"~# c #C7DFE7", -"{# c #D0E4EB", -"]# c #DAE9EE", -"^# c #E3EEF1", -"/# c #EAF0F2", -"(# c #E4ECEE", -"_# c #E0EAEB", -":# c #DAE6E8", -"<# c #CDDCE1", -"[# c #A9B9BD", -"}# c #238CB2", -"|# c #3193B7", -"1# c #3F9ABB", -"2# c #4DA0BF", -"3# c #E1ECEF", -"4# c #E0EAED", -"5# c #DBE7E9", -"6# c #D7E4E6", -"7# c #CFDEE0", -"8# c #A9BABE", -"9# c #1E85AC", -"0# c #2C91B6", -"a# c #3B98BA", -"b# c #489FBE", -"c# c #A0CBDB", -"d# c #CAE1E8", -"e# c #D4E6EC", -"f# c #DEEBEE", -"g# c #E7EFF2", -"h# c #E8F0F0", -"i# c #D0DEE2", -"j# c #9EAEB0", -"k# c #3A3B3B", -"l# c #495052", -"m# c #10536C", -"n# c #298EB4", -"o# c #449DBE", -"p# c #A7CFDC", -"q# c #BDD9E4", -"r# c #E5EEF1", -"s# c #EAF0F1", -"t# c #E4ECEF", -"u# c #DFE8EB", -"v# c #555B5E", -"w# c #8D8D8D", -"x# c #CDCDCD", -"y# c #141A1C", -"z# c #19313B", -"A# c #1E4857", -"B# c #224A59", -"C# c #2A4E5A", -"D# c #2F505D", -"E# c #35545F", -"F# c #395560", -"G# c #405A63", -"H# c #445B63", -"I# c #495E66", -"J# c #506268", -"K# c #546369", -"L# c #59666B", -"M# c #5C686B", -"N# c #616B6E", -"O# c #666D70", -"P# c #696F70", -"Q# c #6E7072", -"R# c #6B6F70", -"S# c #696E6F", -"T# c #676C6D", -"U# c #656A6B", -"V# c #62696A", -"W# c #606869", -"X# c #2F3333", -"Y# c #2F2F2F", -"Z# c #EEEEEE", -"`# c #FDFDFD", -" $ c #B6B6B6", -".$ c #979797", -"+$ c #989898", -"@$ c #C7C7C7", -". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", -". . . . + @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ # $ . . . ", -". . % & * = - ; > , ' ) ! ~ { ) ] ^ / ( _ : < [ } | 1 2 3 4 5 . ", -". . 6 7 8 9 0 a b c d e f g h i j k l m n o p q r s t u v w x . ", -". . y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ` . ", -". . ...+.@.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.}.|.. ", -". . .1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.l g.h.i.j.q r :.k.l.m.|.. ", -". . n.o.p.q.r.s.t.u.v.w.H x.y.z.z.z.A.l P Q R B.C.D.V W X E.|.. ", -". . n.F.G.H.I.#.J.K.L.M.N.-.y.z.z.z.O.P.Q.R.S.^./.T._.U.V.W.|.. ", -". . n.X.Y.Z.`. +.+++@+#+$+%+y.z.z.z.&+*+=+-+;+>+,+'+)+!+k.~+{+. ", -". . n.]+^+/+(+_+:+<+[+}+|+1+2+z.z.z.3+4+4+4+5+6+7+C.8+V t 9+{+. ", -". . n.0+a+b+c+d+e+f+K.L.g+h+2+z.z.z.i+4+4+4+j+k+^.l+r m+U.9+{+. ", -". . n.n+o+Y.Z.p+ +q+r+s+t+u+v+z.z.z.i+4+4+4+w+].>+x+'+y+z+A+{+. ", -". . B+C+D+E+F+(+_+G+H+I+I+I+J+z.z.z.K+4+4+4+L+n M+p N+r y+O+{+. ", -". . B+P+0+a+Q+R+B S+T+I+I+I+J+z.z.z.K+4+4+4+U+V+W+^.T X+Y+Z+`+. ", -". . B+ @.@+@@@+.#@$@%@I+I+I+J+z.z.z.K+4+4+4+&@{.].>+x+'+y+*@`+. ", -". . =@-@;@>@,@'@8 )@%@I+I+I+J+z.z.z.K+4+4+4+!@m n o p q r ~@{@. ", -". . =@]@^@/@(@_@:@<@[@I+I+I+J+z.z.z.K+4+4+4+}@|@1@2@3@T U 4@{@. ", -". . 5@6@7@8@9@0@0@a@b@I+I+I+J+z.z.z.K+4+4+4+c@d@d@d@e@/.(.f@{@. ", -". . 5@g@h@i@9@0@0@a@b@I+I+I+J+z.z.z.K+4+4+4+j@d@d@d@k@j.q l@m@. ", -". . 5@n@o@p@9@0@0@a@b@I+I+I+J+z.z.z.K+4+4+4+j@d@d@d@q@B.C.r@`+. ", -". . 5@s@t@u@9@0@0@a@b@I+I+I+J+z.z.z.K+4+4+4+v@d@d@d@q@^./.w@`+. ", -". . 5@x@y@z@A@0@0@a@B@I+I+I+J+z.z.z.K+4+4+4+v@d@d@d@C@>+,+D@`+. ", -". . 5@E@F@G@A@0@0@a@H@I+I+I+J+z.z.z.K+4+4+4+v@d@d@d@I@6+7+J@{@. ", -". . 5@K@L@M@N@O@P@Q@R@S@T@U@V@W@X@Y@Z@`@ #.#+#@###$#%#k+^.&#{@. ", -". . 5@*#=#-#;#n+>#Y.,#'# +)#!#@+~#{#]#^#/#(#_#:#k ~.<#].>+[#{@. ", -". . 5@}#|#1#2#C+D+E+F+(+_+:+<+b c d 1+3#g h 4#5#6#l 7#n M+8#{@. ", -". . 5@9#0#a#b#P+0+a+Q+R+B c#D E F d#e#f#g#h#L M N O i#V+W+j#k#. ", -". . l#m#n#=#o# @.@+@@@+.#@#.p#%.q#*.=.-.r#s#t#u#:#k ~.{.].v#w#. ", -". . x#y#z#A#B#C#D#E#F#G#H#I#J#K#L#M#N#O#P#Q#R#S#T#U#V#W#X#Y#Z#. ", -". . . `# $.$.$.$.$.$.$.$.$.$.$.$.$.$.$.$.$.$.$.$.$.$.$+$@$. . . ", -". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "}; diff -Nru metview-5.17.4/metview/share/metview/icons_mv5/OBSTAT_SCATTER.xpm metview-5.19.2/metview/share/metview/icons_mv5/OBSTAT_SCATTER.xpm --- metview-5.17.4/metview/share/metview/icons_mv5/OBSTAT_SCATTER.xpm 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/icons_mv5/OBSTAT_SCATTER.xpm 1970-01-01 00:00:00.000000000 +0000 @@ -1,552 +0,0 @@ -/* XPM */ -static char * OBSTAT_SCATTER_xpm[] = { -"32 32 517 2", -" c None", -". c #FFFFFF", -"+ c #C6C6C6", -"@ c #7A7B7C", -"# c #747676", -"$ c #767676", -"% c #757676", -"& c #757575", -"* c #747575", -"= c #747474", -"- c #79797A", -"; c #C4C4C4", -"> c #414345", -", c #232B2E", -"' c #556F79", -") c #5E7982", -"! c #647C84", -"~ c #6C7F86", -"{ c #728288", -"] c #77848A", -"^ c #7E888C", -"/ c #858B8F", -"( c #898E8F", -"_ c #898E8E", -": c #858B8D", -"< c #82888B", -"[ c #7F878A", -"} c #7C8586", -"| c #7B8585", -"1 c #798184", -"2 c #757F82", -"3 c #738081", -"4 c #727D7F", -"5 c #6F7B7E", -"6 c #6D7A7D", -"7 c #6B787B", -"8 c #667377", -"9 c #2B3030", -"0 c #3E3E3E", -"a c #CBCBCB", -"b c #1F272A", -"c c #86BED2", -"d c #92C4D5", -"e c #9DCADA", -"f c #A9D0DC", -"g c #B3D5E1", -"h c #BEDBE5", -"i c #C8DFE7", -"j c #D2E5EB", -"k c #DBEAEE", -"l c #E5EFF1", -"m c #EAF0F1", -"n c #E4ECEF", -"o c #DFE8EB", -"p c #DAE6E8", -"q c #D6E3E5", -"r c #D1DFE3", -"s c #CDDCDF", -"t c #C8D9DE", -"u c #C5D8DB", -"v c #C1D5D9", -"w c #B5C9CC", -"x c #425952", -"y c #54766D", -"z c #54756D", -"A c #53756D", -"B c #627877", -"C c #272C2D", -"D c #C3C3C3", -"E c #40636E", -"F c #82BCD1", -"G c #8EC2D5", -"H c #9AC8D9", -"I c #A4CEDB", -"J c #B0D3E0", -"K c #BBD8E3", -"L c #C5DEE7", -"M c #CEE2EB", -"N c #D9E9ED", -"O c #E2EEF1", -"P c #ECF2F3", -"Q c #E4EEEF", -"R c #E0EAEB", -"S c #DAE7E8", -"T c #D2E0E4", -"U c #CEDDE1", -"V c #CADADF", -"W c #C7D9DC", -"X c #C3D5DA", -"Y c #B3C5CA", -"Z c #568076", -"` c #7BC3AD", -" . c #617C79", -".. c #637073", -"+. c #7A7A7A", -"@. c #727575", -"#. c #406472", -"$. c #7FBAD0", -"%. c #8AC0D4", -"&. c #96C7D6", -"*. c #A1CCDB", -"=. c #AED2DF", -"-. c #B7D7E2", -";. c #C1DDE6", -">. c #CCE1E9", -",. c #D5E6EC", -"'. c #DEEBEF", -"). c #E7F0F2", -"!. c #E6F0F0", -"~. c #E2ECED", -"{. c #DDE7EB", -"]. c #D7E4E8", -"^. c #D3E1E4", -"/. c #D0DEE0", -"(. c #CCDCDE", -"_. c #C8D8DC", -":. c #C4D6DB", -"<. c #B4C5CA", -"[. c #578176", -"}. c #6A787B", -"|. c #3E6470", -"1. c #7BB8CE", -"2. c #86BED3", -"3. c #93C5D5", -"4. c #9ECBDA", -"5. c #A9D0DD", -"6. c #B4D5E1", -"7. c #BFDAE5", -"8. c #C8E0E7", -"9. c #D3E6EA", -"0. c #E6EFF1", -"a. c #E8F0F1", -"b. c #E2ECEE", -"c. c #DEE8EB", -"d. c #DAE5E8", -"e. c #D4E3E5", -"f. c #B6C8CB", -"g. c #568174", -"h. c #617E7A", -"i. c #727375", -"j. c #3C6370", -"k. c #77B6CD", -"l. c #82BCD2", -"m. c #90C3D5", -"n. c #9AC9D9", -"o. c #A6CFDC", -"p. c #B1D3E0", -"q. c #BBD9E4", -"r. c #C6DFE7", -"s. c #CFE4EB", -"t. c #D9E9EE", -"u. c #EAF2F3", -"v. c #969792", -"w. c #8E887E", -"x. c #8B867E", -"y. c #8A867C", -"z. c #88847B", -"A. c #868279", -"B. c #807D74", -"C. c #3B4F48", -"D. c #57766F", -"E. c #57756E", -"F. c #56756F", -"G. c #667E7C", -"H. c #6A787A", -"I. c #386170", -"J. c #73B5CC", -"K. c #80BAD0", -"L. c #8CC1D4", -"M. c #97C7D8", -"N. c #A3CDDB", -"O. c #B9D7E3", -"P. c #C2DDE6", -"Q. c #CDE1E9", -"R. c #D6E7EC", -"S. c #DFECEF", -"T. c #E9F0F3", -"U. c #E6EEF1", -"V. c #908A7E", -"W. c #DDB383", -"X. c #DCB082", -"Y. c #DBB080", -"Z. c #DAB081", -"`. c #D9AE7F", -" + c #D8AE7E", -".+ c #838177", -"++ c #BDD2D7", -"@+ c #BBCFD3", -"#+ c #B8CDD2", -"$+ c #B5CDD0", -"%+ c #69787A", -"&+ c #376070", -"*+ c #6FB3CB", -"=+ c #7CB9CE", -"-+ c #88C0D3", -";+ c #94C5D7", -">+ c #AAD1DD", -",+ c #B4D6E2", -"'+ c #C9E0E8", -")+ c #D4E6EA", -"!+ c #DDEBEE", -"~+ c #E6EFF2", -"{+ c #918B7F", -"]+ c #DFB282", -"^+ c #DDB183", -"/+ c #DCB181", -"(+ c #D9AF80", -"_+ c #D8AF7F", -":+ c #D9AF7F", -"<+ c #838279", -"[+ c #BFD2D6", -"}+ c #BBD1D5", -"|+ c #B9CFD4", -"1+ c #B7CCD2", -"2+ c #36606F", -"3+ c #6CB1C9", -"4+ c #78B6CD", -"5+ c #84BDD2", -"6+ c #90C3D6", -"7+ c #9BC9D9", -"8+ c #B2D4E0", -"9+ c #C7DFE7", -"0+ c #D0E4EB", -"a+ c #E3EEF1", -"b+ c #E4ECEE", -"c+ c #928B80", -"d+ c #DFB283", -"e+ c #DCB283", -"f+ c #DBB081", -"g+ c #DCB080", -"h+ c #848278", -"i+ c #BED2D8", -"j+ c #BBD2D6", -"k+ c #B9CED3", -"l+ c #B8CED1", -"m+ c #335F6F", -"n+ c #68AEC9", -"o+ c #74B5CC", -"p+ c #81BBD1", -"q+ c #8CC2D4", -"r+ c #97C8D8", -"s+ c #B9D8E3", -"t+ c #C4DEE6", -"u+ c #CEE2E9", -"v+ c #D6E7ED", -"w+ c #E1ECEF", -"x+ c #E6EEF0", -"y+ c #948C81", -"z+ c #E0B383", -"A+ c #848178", -"B+ c #C0D3D7", -"C+ c #BDD2D6", -"D+ c #315D6D", -"E+ c #64ADC8", -"F+ c #71B3CB", -"G+ c #7DB9CF", -"H+ c #94C6D7", -"I+ c #A0CCDB", -"J+ c #B6D6E2", -"K+ c #C0DCE5", -"L+ c #CAE0E8", -"M+ c #D4E6EC", -"N+ c #DEEBEE", -"O+ c #948B81", -"P+ c #E0B284", -"Q+ c #DEB282", -"R+ c #DCB180", -"S+ c #D8AE7F", -"T+ c #858379", -"U+ c #C1D5D8", -"V+ c #BDD1D6", -"W+ c #B9CFD3", -"X+ c #2F5B6C", -"Y+ c #5FABC5", -"Z+ c #6DB2C9", -"`+ c #78B6CE", -" @ c #85BDD2", -".@ c #90C4D6", -"+@ c #A7CFDC", -"@@ c #9BB8C3", -"#@ c #9DB4BD", -"$@ c #A3B8C0", -"%@ c #ACBDC2", -"&@ c #B5C1C5", -"*@ c #BDC5C7", -"=@ c #C2C7C7", -"-@ c #827B72", -";@ c #D9AF81", -">@ c #D8AD7F", -",@ c #D7AD80", -"'@ c #D6AD7E", -")@ c #D5AB7D", -"!@ c #858279", -"~@ c #C1D6D9", -"{@ c #BED3D7", -"]@ c #BBD2D4", -"^@ c #6D7A7B", -"/@ c #717375", -"(@ c #2C5B6C", -"_@ c #5CA8C4", -":@ c #68AFC9", -"<@ c #75B6CC", -"[@ c #8DC2D5", -"}@ c #99C8D9", -"|@ c #5C555A", -"1@ c #A0555E", -"2@ c #A45760", -"3@ c #A65761", -"4@ c #A95A61", -"5@ c #AC5A63", -"6@ c #B05C63", -"7@ c #634F4F", -"8@ c #979793", -"9@ c #939492", -"0@ c #92938F", -"a@ c #8F918D", -"b@ c #8D908C", -"c@ c #8A8E8A", -"d@ c #9EA6A6", -"e@ c #BDD1D5", -"f@ c #BBD0D5", -"g@ c #295A6A", -"h@ c #58A6C4", -"i@ c #71B4CB", -"j@ c #7DBAD0", -"k@ c #89C0D4", -"l@ c #96C6D6", -"m@ c #6C5861", -"n@ c #DE5765", -"o@ c #E15968", -"p@ c #E45A68", -"q@ c #E75C68", -"r@ c #EB5E6A", -"s@ c #EF5F6B", -"t@ c #836C6F", -"u@ c #D0DEE2", -"v@ c #C7D8DD", -"w@ c #C4D7DA", -"x@ c #28596A", -"y@ c #54A4C2", -"z@ c #61AAC7", -"A@ c #6EB2C9", -"B@ c #6A5861", -"C@ c #DD5765", -"D@ c #E05968", -"E@ c #E35A68", -"F@ c #E65B68", -"G@ c #E95E6A", -"H@ c #ED5E6A", -"I@ c #846D70", -"J@ c #BBD0D4", -"K@ c #6D7B7D", -"L@ c #25566A", -"M@ c #4FA3C1", -"N@ c #5DAAC5", -"O@ c #6AAFC9", -"P@ c #69585F", -"Q@ c #DC5665", -"R@ c #E05967", -"S@ c #E65B69", -"T@ c #856D70", -"U@ c #C0D2D8", -"V@ c #6F7B7D", -"W@ c #245669", -"X@ c #4CA0BF", -"Y@ c #5AA8C3", -"Z@ c #66AEC8", -"`@ c #72B4CB", -" # c #68585F", -".# c #DB5665", -"+# c #E15967", -"@# c #E45A69", -"## c #E85D6A", -"$# c #856D6F", -"%# c #CFDEE2", -"&# c #C0D3D9", -"*# c #BDD3D7", -"=# c #6D7B7E", -"-# c #215567", -";# c #489EBE", -"># c #55A5C2", -",# c #63ACC7", -"'# c #6EB2CB", -")# c #88BED3", -"!# c #67575F", -"~# c #DA5665", -"{# c #826C6F", -"]# c #C5D6DB", -"^# c #1F5567", -"/# c #449CBE", -"(# c #52A4C1", -"_# c #5EAAC5", -":# c #6AB0C9", -"<# c #64555F", -"[# c #D95665", -"}# c #DD5665", -"|# c #CEDDDF", -"1# c #CADADD", -"2# c #C5D7DC", -"3# c #1B5367", -"4# c #265570", -"5# c #213E5E", -"6# c #25405F", -"7# c #284161", -"8# c #2C4261", -"9# c #2E4564", -"0# c #314664", -"a# c #342F39", -"b# c #6B606A", -"c# c #6E616A", -"d# c #75646D", -"e# c #78676D", -"f# c #7E6A6F", -"g# c #836C71", -"h# c #888082", -"i# c #DDE7E9", -"j# c #D7E4E6", -"k# c #CBDBDF", -"l# c #195066", -"m# c #1D415C", -"n# c #3E5CBF", -"o# c #374B6B", -"p# c #DDE9EB", -"q# c #D5E1E4", -"r# c #D0DEE3", -"s# c #C7D9DD", -"t# c #C2D5D8", -"u# c #707C7F", -"v# c #165064", -"w# c #1C405C", -"x# c #DAE9EE", -"y# c #D2E0E3", -"z# c #707375", -"A# c #144F64", -"B# c #1A405C", -"C# c #344A69", -"D# c #E2EAED", -"E# c #DBE7E9", -"F# c #CBDBDD", -"G# c #C6D7DC", -"H# c #C2D6D9", -"I# c #727E7F", -"J# c #114E64", -"K# c #183E5C", -"L# c #334A69", -"M# c #CAE1E8", -"N# c #D9E4E8", -"O# c #727D80", -"P# c #0F4D63", -"Q# c #173D5C", -"R# c #324969", -"S# c #BDD9E4", -"T# c #E5EEF1", -"U# c #EAF0F2", -"V# c #DFE9EB", -"W# c #CDDCE1", -"X# c #7D7F80", -"Y# c #0D465A", -"Z# c #163A58", -"`# c #344EA1", -" $ c #2E4462", -".$ c #D8E7ED", -"+$ c #E2ECF1", -"@$ c #E0EAED", -"#$ c #CFDEE0", -"$$ c #677174", -"%$ c #7C7D7D", -"&$ c #D7D7D7", -"*$ c #0E1A1E", -"=$ c #1B6D8F", -"-$ c #215D77", -";$ c #29627A", -">$ c #2F647D", -",$ c #38687F", -"'$ c #406C81", -")$ c #477084", -"!$ c #608EA1", -"~$ c #ACD2DF", -"{$ c #B6D7E2", -"]$ c #CCE1E8", -"^$ c #E7EFF2", -"/$ c #C4D5D9", -"($ c #212223", -"_$ c #CFCFCF", -":$ c #5A5E60", -"<$ c #0C1317", -"[$ c #1A4353", -"}$ c #1F4B5D", -"|$ c #25505E", -"1$ c #2C5461", -"2$ c #325663", -"3$ c #395A65", -"4$ c #3E5C67", -"5$ c #445F69", -"6$ c #4A626A", -"7$ c #4F666C", -"8$ c #54686E", -"9$ c #596B6F", -"0$ c #5F6E72", -"a$ c #647073", -"b$ c #697175", -"c$ c #6D7476", -"d$ c #717778", -"e$ c #747879", -"f$ c #717677", -"g$ c #6F7474", -"h$ c #6C7273", -"i$ c #6B7071", -"j$ c #696F71", -"k$ c #5F6566", -"l$ c #1A1B1B", -"m$ c #5D5D5D", -"n$ c #DFDFDF", -"o$ c #949494", -"p$ c #8F8F8F", -"q$ c #939393", -"r$ c #DDDDDD", -". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", -". . . + @ # # # # $ $ $ $ $ $ % & & * * * = & & & & & - ; . . . ", -". . > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 5 6 7 8 9 0 . . ", -". a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D . ", -". @ E F G H I J K L M N O P Q R S q T U V W X Y Z ` ` ` ...+.. ", -". @.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.` ` ` .}.* . ", -". @.|.1.2.3.4.5.6.7.8.9.k 0.a.b.c.d.e.r s t u f.g.` ` ` h.}.* . ", -". i.j.k.l.m.n.o.p.q.r.s.t.O u.n R v.w.x.y.z.A.B.C.D.E.F.G.H.* . ", -". i.I.J.K.L.M.N.=.O.P.Q.R.S.T.U.~.V.W.X.Y.Z.`. +.+++@+#+$+%+* . ", -". i.&+*+=+-+;+4.>+,+7.'+)+!+~+a.b.{+]+^+/+(+_+:+<+[+}+|+1+7 * . ", -". i.2+3+4+5+6+7+o.8+q.9+0+t.a+u.b+c+d+e+f+g+(+`.h+i+j+k+l+7 * . ", -". i.m+n+o+p+q+r+N.=.s+t+u+v+w+u.x+y+z+W.X.Y.Z.`.A+B+C+@+#+7 & . ", -". i.D+E+F+G+-+H+I+>+J+K+L+M+N+~+a.O+P+Q+^+R+:+S+T+U+V+}+W+7 & . ", -". i.X+Y+Z+`+ @.@e +@@@#@$@%@&@*@=@-@X.;@>@,@'@)@!@~@{@]@k+^@& . ", -". /@(@_@:@<@p+[@}@I |@1@2@3@4@5@6@7@8@9@0@a@b@c@d@X B+e@f@6 & . ", -". /@g@h@E+i@j@k@l@I+m@n@o@p@q@r@s@t@~.{.].^.u@(.v@w@U+e@f@6 & . ", -". /@x@y@z@A@1.c d e B@C@D@E@F@G@H@I@n o p q r s t u v {@J@K@& . ", -". /@L@M@N@O@k.F G H P@Q@R@E@S@G@r@T@Q R S q T U V W X U@e@V@& . ", -". /@W@X@Y@Z@`@$.%.M. #.#n@+#@###r@$#!.~.{.].^.%#(._.:.&#*#=#& . ", -". /@-#;#>#,#'#1.)#3.!#~#C@R@E@F@G@{#a.b.c.d.e.r s t ]#v {@5 & . ", -". /@^#/#(#_#:#k.l.m.<#[#}#R@E@F@G@{#u.n R S q T |#1#2#X i+5 & . ", -". /@3#4#5#6#7#8#9#0#a#b#c#d#e#f#g#h#T.U.~.i#j#T %#k#_.:. & . ", -". /@l#m#n#n#n#n#n#n#o#4.>+,+7.'+)+!+~+a.b.p#d.q#r#(.s#w@t#u#& . ", -". /@v#w#n#n#n#n#n#n#o#7+o.8+q.9+0+x#a+u.b+R S q y#|#1#2#~@u#& . ", -". z#A#B#n#n#n#n#n#n#C#r+N.=.s+t+u+v+w+u.x+D#E#j#T %#F#G#H#I#& . ", -". z#J#K#n#n#n#n#n#n#L#H+I+>+J+K+M#M+N+~+a.~.{.N#q#u@(.v@w@O#& . ", -". z#P#Q#n#n#n#n#n#n#R#.@e +@g S#i j x#T#U#Q V#p q r W#t u O#& . ", -". X#Y#Z#`#`#`#`#`#`# $[@H I J s+t+u+.$+$u.x+@$E#j#T #$F#G#$$%$. ", -". &$*$=$-$;$>$,$'$)$!$%.l@I+~${$K+]$,.'.^$!.~.{.].^.u@(./$($_$. ", -". . :$<$[$}$|$1$2$3$4$5$6$7$8$9$0$a$b$c$d$e$f$g$h$i$j$k$l$m$. . ", -". . . n$o$p$p$p$p$p$p$p$p$p$p$p$p$p$p$p$p$p$p$p$p$p$p$q$r$. . . ", -". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "}; diff -Nru metview-5.17.4/metview/share/metview/icons_mv5/OBSTAT.xpm metview-5.19.2/metview/share/metview/icons_mv5/OBSTAT.xpm --- metview-5.17.4/metview/share/metview/icons_mv5/OBSTAT.xpm 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/share/metview/icons_mv5/OBSTAT.xpm 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* XPM */ -static char *Obstat[] = { -/* columns rows colors chars-per-pixel */ -"16 16 1 1", -" c #DC243A", -/* pixels */ -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" " -}; diff -Nru metview-5.17.4/metview/src/AppMod/MvCompress.cc metview-5.19.2/metview/src/AppMod/MvCompress.cc --- metview-5.17.4/metview/src/AppMod/MvCompress.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/AppMod/MvCompress.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,9 +10,11 @@ #include #include +#include #include #include #include +#include #include "fstream_mars_fix.h" #include "Metview.h" @@ -24,19 +26,12 @@ int ac; char** av; -class Base : public MvService -{ -protected: - Base(const char* a) : - MvService(a) {} -}; - -class MvCompress : public Base +class MvCompress : public MvService { public: - MvCompress() : - Base("COMPRESS") {} - void serve(MvRequest&, MvRequest&); + MvCompress(const char* name) : + MvService(name) {} + void serve(MvRequest&, MvRequest&) override; }; void MvCompress::serve(MvRequest& in, MvRequest& out) @@ -48,34 +43,23 @@ if (!in.getValue("ITEMS", vals)) return; - const char* id = in("PARAM"); - if (!id) - return; - - //Dump file name + tar file name - std::string fLog(marstmp()); std::string method; - - if (strcmp(id, "tar") == 0) { - method = "tar"; - } - else if (strcmp(id, "tgz") == 0) { - method = "tgz"; - } - else if (strcmp(id, "tbz") == 0) { - method = "tbz"; - } - else if (strcmp(id, "tzip") == 0) { - method = "tzip"; - } - else if (strcmp(id, "zip") == 0) { - method = "zip"; + if (const char* ch = in("PARAM")) { + auto id = std::string(ch); + std::vector methods = {"tar", "tgz", "tbz", "tz", "zip", "gz", "bz2", "z"}; + if (std::find(methods.begin(), methods.end(), id) == methods.end()) { + return; + } + method = id; } else { return; } - //Compress command + // Dump file name + tar file name + std::string fLog(marstmp()); + + // Compress command std::string cmd = std::string(getenv("METVIEW_BIN")) + "/mv_compress "; cmd += " -m \"" + method + "\" -l \"" + fLog + "\" "; @@ -84,12 +68,10 @@ } cmd += " 2>&1"; - //COUT << "command " << cmd << std::endl; - int ret = system(cmd.c_str()); - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { std::ifstream inLog(fLog.c_str()); std::string line; @@ -99,11 +81,11 @@ if (WEXITSTATUS(ret) == 255) { msg = "MvCompress-> Some of the icons could not be archived!"; - st = "WARNING"; + st = "WARNING"; setError(0, msg.c_str()); - //marslog(LOG_WARN,"%s",msg.c_str()); + // marslog(LOG_WARN,"%s",msg.c_str()); while (getline(inLog, line)) { - //marslog(LOG_WARN,"%s",line.c_str()); + // marslog(LOG_WARN,"%s",line.c_str()); detailed += line + "\n"; } inLog.close(); @@ -120,17 +102,17 @@ } setError(1, msg.c_str()); - //marslog(LOG_EROR,"%s",msg.c_str()); + // marslog(LOG_EROR,"%s",msg.c_str()); while (getline(inLog, line)) { - //marslog(LOG_EROR,"%s",line.c_str()); + // marslog(LOG_EROR,"%s",line.c_str()); detailed += line + "\n"; } inLog.close(); } - out = MvRequest("MESSAGE"); - out("STATUS") = st.c_str(); - out("TEXT") = msg.c_str(); + out = MvRequest("MESSAGE"); + out("STATUS") = st.c_str(); + out("TEXT") = msg.c_str(); out("DETAILED") = detailed.c_str(); if (st == "ERROR") { @@ -147,7 +129,8 @@ MvApplication theApp(argc, argv, "MvCompress"); - MvCompress cmp; + MvCompress arch("ARCHIVE"); + MvCompress cmp("COMPRESS"); theApp.run(); } diff -Nru metview-5.17.4/metview/src/AppMod/MvMailTo.cc metview-5.19.2/metview/src/AppMod/MvMailTo.cc --- metview-5.17.4/metview/src/AppMod/MvMailTo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/AppMod/MvMailTo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -73,15 +73,15 @@ std::string dateStr = QDateTime::currentDateTime().toString("yyyyMMdd_hhmm").toStdString(); - //Dump file name + tar file name + // Dump file name + tar file name std::string fDump(marstmp()); std::string compressMethod = "tgz"; std::string compressSuffix = "tar.gz"; - std::string fCompress = std::string(mdirname(fDump.c_str())) + "/mv_icons_" + + std::string fCompress = std::string(mdirname(fDump.c_str())) + "/mv_icons_" + userName + "_" + dateStr + "." + compressSuffix; std::string fLog = fDump + ".log"; - //Compress command + // Compress command std::string cmd = std::string(getenv("METVIEW_BIN")) + "/mv_compress "; cmd += " -f \"" + fCompress + "\" -d \"" + fDump + "\" -m \"" + compressMethod + "\" -l \"" + fLog + "\" "; for (auto& val : vals) { @@ -89,12 +89,12 @@ } cmd += " 2>&1"; - //COUT << "command " << cmd << std::endl; + // COUT << "command " << cmd << std::endl; int ret = system(cmd.c_str()); - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { std::ifstream inLog(fLog.c_str()); std::string line; @@ -110,10 +110,10 @@ else if (WEXITSTATUS(ret) > 1) { std::ostringstream oss; oss << "MvMail-> Compressing icons failed with exit code: " << WEXITSTATUS(ret); - //setError(1, oss.str().c_str()); + // setError(1, oss.str().c_str()); marslog(LOG_EROR, "Compressing icons failed with exit code: %d !", WEXITSTATUS(ret)); while (getline(inLog, line)) { - //setError(1, line.c_str()); + // setError(1, line.c_str()); marslog(LOG_EROR, "%s", line.c_str()); } inLog.close(); @@ -123,30 +123,30 @@ //----------------------------------- // Mail dialog //----------------------------------- - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("MvMailTo"); MvQApplication app(argc, argv, appName.c_str(), {"mail", "window"}); auto* md = new MvQMailDialog(fCompress, fDump); md->show(); - //Enter the app loop + // Enter the app loop app.exec(); - //Now we have left the qt event loop + // Now we have left the qt event loop //----------------------------------- // Send mail //----------------------------------- if (md->result() == QDialog::Rejected || md->to().isEmpty()) { - //This should be deleted - //fCompress + // This should be deleted + // fCompress delete md; exit(0); } - //mail command reuse log + // mail command reuse log cmd = std::string(getenv("METVIEW_BIN")) + "/mv_mail "; cmd += " -t \"" + md->to().toStdString() + "\" "; @@ -158,7 +158,7 @@ cmd += " -s \"" + md->subject().toStdString() + "\" "; if (!md->message().isEmpty()) { - //Write message into file + // Write message into file std::string fMessage = fDump + ".msg"; std::ofstream outMsg(fMessage.c_str()); outMsg << md->message().toStdString() << std::endl; @@ -169,19 +169,19 @@ cmd += " -f \"" + fCompress + "\" -l \"" + fLog + "\""; - //cmd+= " -t \"" + md->to().toStdString() + "\" " + - // (!md->cc().isEmpty())?( "-c \"" + md->cc().toStdString() + "\" " - // "\" -s \"" + md->subject().toStdString() + "\" -m \"" + md->message().toStdString() + - // "\" -f \"" + fCompress + "\" -l \"" + fLog + "\"" ; + // cmd+= " -t \"" + md->to().toStdString() + "\" " + + // (!md->cc().isEmpty())?( "-c \"" + md->cc().toStdString() + "\" " + // "\" -s \"" + md->subject().toStdString() + "\" -m \"" + md->message().toStdString() + + // "\" -f \"" + fCompress + "\" -l \"" + fLog + "\"" ; cmd += " 2>&1"; - //COUT << "command " << cmd << std::endl; + // COUT << "command " << cmd << std::endl; ret = system(cmd.c_str()); - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { std::ifstream inLog(fLog.c_str()); std::string line; @@ -200,7 +200,7 @@ msg = ss.str(); } - //setError(1, msg.c_str()); + // setError(1, msg.c_str()); marslog(LOG_EROR, "%s", msg.c_str()); while (getline(inLog, line)) { marslog(LOG_EROR, "%s", line.c_str()); @@ -210,8 +210,8 @@ MvRequest out("MESSAGE"); - out("STATUS") = st.c_str(); - out("TEXT") = msg.c_str(); + out("STATUS") = st.c_str(); + out("TEXT") = msg.c_str(); out("DETAILED") = detailed.c_str(); out.save(outPath.c_str()); diff -Nru metview-5.17.4/metview/src/AppMod/MvQSavePool.cc metview-5.19.2/metview/src/AppMod/MvQSavePool.cc --- metview-5.17.4/metview/src/AppMod/MvQSavePool.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/AppMod/MvQSavePool.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,12 +35,12 @@ selectedFile_ = lst[0]; } - //We leave the event loop + // We leave the event loop QApplication::quit(); } void MvQSavePool::slotCancel() { - //We leave the event loop + // We leave the event loop QApplication::quit(); } diff -Nru metview-5.17.4/metview/src/AppMod/MvQSavePool.h metview-5.19.2/metview/src/AppMod/MvQSavePool.h --- metview-5.17.4/metview/src/AppMod/MvQSavePool.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/AppMod/MvQSavePool.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,14 +20,14 @@ public: MvQSavePool(QString); - ~MvQSavePool(); + ~MvQSavePool() override; QString selectedFile() const { return selectedFile_; } public slots: void slotAccept(); void slotCancel(); -protected: - MvQFileDialog* fDialog_; +private: + MvQFileDialog* fDialog_{nullptr}; QString selectedFile_; }; diff -Nru metview-5.17.4/metview/src/AppMod/MvWsToRequest.cc metview-5.19.2/metview/src/AppMod/MvWsToRequest.cc --- metview-5.17.4/metview/src/AppMod/MvWsToRequest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/AppMod/MvWsToRequest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ // std::cout << "MvWsToRequest: fIn=" << fIn << std::endl; // std::cout << "MvWsToRequest: fOut=" << fOut << std::endl; - marsinit(&argc,argv,0,0,0); + marsinit(&argc, argv, nullptr, 0, nullptr); ConfigLoader::init(); MvRequest r; diff -Nru metview-5.17.4/metview/src/AppMod/SavePoolApp.cc metview-5.19.2/metview/src/AppMod/SavePoolApp.cc --- metview-5.17.4/metview/src/AppMod/SavePoolApp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/AppMod/SavePoolApp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ #include "MvQApplication.h" #include "MvQMethods.h" -#include +#include #include #include @@ -50,7 +50,7 @@ exit(1); } - //Get grib file name + // Get grib file name std::string iconName; if (const char* tmpc = in("ICON_NAME")) { iconName = std::string(tmpc); @@ -60,14 +60,16 @@ exit(1); } - //Find out start directory + // Find out start directory std::string iconDir; - char* mvDir = getenv("METVIEW_USER_DIRECTORY"); + char* mvDir = getenv("METVIEW_USER_DIRECTORY"); const char* buf = mdirname(iconName.c_str()); if (mvDir && buf) { iconDir = std::string(mvDir) + "/" + std::string(buf); - struct stat iconDirStat; + struct stat iconDirStat + { + }; if (!(stat(iconDir.c_str(), &iconDirStat) >= 0 && iconDirStat.st_mode & S_IFDIR)) { iconDir = std::string(); } @@ -76,16 +78,16 @@ iconDir = std::string(mvDir); } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("SavePoolApp"); MvQApplication app(argc, argv, appName.c_str()); MvQSavePool qSavepool(QString::fromStdString(iconDir)); - //Enter the app loop + // Enter the app loop app.exec(); - //Now we have left the qt event loop + // Now we have left the qt event loop QString fName = qSavepool.selectedFile(); MvRequest out("SELECTION"); diff -Nru metview-5.17.4/metview/src/AppMod/savepool.cc metview-5.19.2/metview/src/AppMod/savepool.cc --- metview-5.17.4/metview/src/AppMod/savepool.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/AppMod/savepool.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ #include "MvRequest.h" #include "MvTmpFile.h" -#include +#include #include #include @@ -28,10 +28,10 @@ static char** gav; static svc* gs = nullptr; -static svcid* s_id = nullptr; -static const char* path = nullptr; +static svcid* s_id = nullptr; +static const char* path = nullptr; static const char* iconName = nullptr; -static char* cptr = nullptr; +static char* cptr = nullptr; void cleanup(const char* file); void save(svcid* id, request* r, void*); @@ -64,8 +64,8 @@ send_reply(s_id, nullptr); - s_id = nullptr; - path = nullptr; + s_id = nullptr; + path = nullptr; iconName = nullptr; } } @@ -86,7 +86,7 @@ printf("verb=%s\n", verb); - char* pathStr; + char* pathStr = nullptr; if (strcmp(verb, "ODB_GEO_POINTS") == 0 || strcmp(verb, "ODB_GEO_VECTORS") == 0 || strcmp(verb, "ODB_XY_POINTS") == 0 || strcmp(verb, "ODB_XY_VECTORS") == 0 || @@ -96,11 +96,11 @@ else { pathStr = (char*)get_value(r, "PATH", 0); /*iconName = get_value( r, "_NAME", 0 ); - cptr = r->name;*/ + cptr = r->name;*/ } iconName = get_value(r, "_NAME", 0); - cptr = r->name; + cptr = r->name; printf("icon_name=%s\n", iconName); @@ -120,7 +120,7 @@ cptr = (char*)get_value(r, "IMPORT_FILE_TYPE", 0); } - //const char* senderAppl = (char*)get_value(r, "_APPL", 0); + // const char* senderAppl = (char*)get_value(r, "_APPL", 0); // ----------------------------------------------- // get the target file name from SavePoolApp @@ -154,7 +154,7 @@ targetFile = std::string(ch); } - //The real save operation + // The real save operation cleanup(targetFile.empty() ? nullptr : targetFile.c_str()); exit(0); diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrCompDataWidget.cc metview-5.19.2/metview/src/BufrExaminer/BufrCompDataWidget.cc --- metview-5.17.4/metview/src/BufrExaminer/BufrCompDataWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrCompDataWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,11 +29,11 @@ if (source_parent.isValid()) return true; - if (source_row == 0) //the subset index is always visible + if (source_row == 0) // the subset index is always visible return true; QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); - QString s = sourceModel()->data(idx).toString(); + QString s = sourceModel()->data(idx).toString(); if (!s.isEmpty()) { foreach (QString str, filterStr_) { if (s.contains(str, Qt::CaseInsensitive)) @@ -52,8 +52,7 @@ BufrDataKeyModel::BufrDataKeyModel(QObject* parent) : - QAbstractItemModel(parent), - prof_(0) + QAbstractItemModel(parent) { } @@ -69,7 +68,7 @@ if (prof_) delete prof_; - prof_ = 0; + prof_ = nullptr; endResetModel(); } @@ -103,7 +102,7 @@ QVariant BufrDataKeyModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || !prof_ || index.row() >= static_cast(prof_->size())) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { return QString::fromStdString(prof_->at(index.row())->name()); @@ -112,7 +111,7 @@ return (prof_->at(index.row())->metaData("f") == "1") ? QVariant(Qt::Checked) : QVariant(Qt::Unchecked); } - return QVariant(); + return {}; } bool BufrDataKeyModel::setData(const QModelIndex& idx, const QVariant& value, int role) @@ -142,12 +141,12 @@ QModelIndex BufrDataKeyModel::index(int row, int column, const QModelIndex& /*parent*/) const { - return createIndex(row, column, static_cast(0)); + return createIndex(row, column, static_cast(nullptr)); } QModelIndex BufrDataKeyModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } Qt::ItemFlags BufrDataKeyModel::flags(const QModelIndex& index) const @@ -219,8 +218,7 @@ } BufrCompDataWidget::BufrCompDataWidget(QWidget* parent) : - QWidget(parent), - data_(0) + QWidget(parent) { setupUi(this); @@ -228,9 +226,9 @@ columnLe_->setClearButtonEnabled(true); #endif - //header - //header_->setProperty("panelStyle", "2"); - //filterPanelTb_->setProperty("panelStyle", "2"); + // header + // header_->setProperty("panelStyle", "2"); + // filterPanelTb_->setProperty("panelStyle", "2"); model_ = new MvQKeyProfileModel(this); model_->setShadeFirstColumn(true); @@ -245,12 +243,12 @@ tree_->setModels(model_, sortModel_); tree_->setUniformRowHeights(true); tree_->setAlternatingRowColors(true); - //tree_->setAlternatingRowColors(false); + // tree_->setAlternatingRowColors(false); filterPanel_->setProperty("panelStyle", "2"); filterLabel_->setProperty("panelStyle", "2"); - colModel_ = new BufrDataKeyModel(this); + colModel_ = new BufrDataKeyModel(this); colFilterModel_ = new BufrDataKeyFilterModel(this); colFilterModel_->setSourceModel(colModel_); colList_->setModel(colFilterModel_); @@ -265,7 +263,7 @@ void BufrCompDataWidget::init(BufrMetaData* data) { - Q_ASSERT(data_ == 0); + Q_ASSERT(data_ == nullptr); data_ = data; Q_ASSERT(data_); } @@ -283,10 +281,10 @@ auto* prof = new MvKeyProfile("comp"); data_->readCompressedData(prof, msgNum, subsetNum); - //The model will take ownership of the profile + // The model will take ownership of the profile model_->setKeyProfile(prof); - //This model will take ownership of its profile + // This model will take ownership of its profile colModel_->setKeyProfile(prof->clone()); colModel_->selectAll(QString()); } diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrCompDataWidget.h metview-5.19.2/metview/src/BufrExaminer/BufrCompDataWidget.h --- metview-5.17.4/metview/src/BufrExaminer/BufrCompDataWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrCompDataWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,11 +24,11 @@ class BufrDataKeyFilterModel : public QSortFilterProxyModel { public: - BufrDataKeyFilterModel(QObject* parent = 0); + BufrDataKeyFilterModel(QObject* parent = nullptr); void setFilter(QStringList); -protected: - bool filterAcceptsRow(int source_column, const QModelIndex& source_parent) const; +private: + bool filterAcceptsRow(int source_column, const QModelIndex& source_parent) const override; QStringList filterStr_; }; @@ -37,20 +37,20 @@ { Q_OBJECT public: - explicit BufrDataKeyModel(QObject* parent = 0); - ~BufrDataKeyModel(); + explicit BufrDataKeyModel(QObject* parent = nullptr); + ~BufrDataKeyModel() override; void setKeyProfile(MvKeyProfile*); MvKeyProfile* profile() const { return prof_; } - int rowCount(const QModelIndex& parent = QModelIndex()) const; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - QVariant data(const QModelIndex& index, int role) const; - bool setData(const QModelIndex& idx, const QVariant& value, int role); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex& index) const; - Qt::ItemFlags flags(const QModelIndex& index) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex& index, int role) const override; + bool setData(const QModelIndex& idx, const QVariant& value, int role) override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex& index) const override; + Qt::ItemFlags flags(const QModelIndex& index) const override; void clear(); void selectAll(QString); @@ -60,8 +60,8 @@ signals: void filterChanged(); -protected: - MvKeyProfile* prof_; +private: + MvKeyProfile* prof_{nullptr}; }; @@ -70,8 +70,8 @@ Q_OBJECT public: - explicit BufrCompDataWidget(QWidget* parent = 0); - virtual ~BufrCompDataWidget() {} + explicit BufrCompDataWidget(QWidget* parent = nullptr); + ~BufrCompDataWidget() override = default; void init(BufrMetaData* data); void clearData(); @@ -87,10 +87,10 @@ void on_filterPanelTb__toggled(bool); void slotFilterChanged(); -protected: - BufrMetaData* data_; - MvQKeyProfileModel* model_; - MvQKeyProfileSortFilterModel* sortModel_; - BufrDataKeyModel* colModel_; - BufrDataKeyFilterModel* colFilterModel_; +private: + BufrMetaData* data_{nullptr}; + MvQKeyProfileModel* model_{nullptr}; + MvQKeyProfileSortFilterModel* sortModel_{nullptr}; + BufrDataKeyModel* colModel_{nullptr}; + BufrDataKeyFilterModel* colFilterModel_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrExaminer.cc metview-5.19.2/metview/src/BufrExaminer/BufrExaminer.cc --- metview-5.17.4/metview/src/BufrExaminer/BufrExaminer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrExaminer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -89,14 +89,14 @@ MvQBufrMainPanel::MvQBufrMainPanel(bool /*filtered*/, QWidget* parent) : QWidget(parent), - data_(0), + data_(nullptr), inProfileLoad_(false) { Q_ASSERT(parent); messagePanel_ = new MvQMessagePanel(this); - dumpPanel_ = new MvQBufrDumpPanel(this); - gotoPanel_ = new MessageControlPanel(true, true, this); + dumpPanel_ = new MvQBufrDumpPanel(this); + gotoPanel_ = new MessageControlPanel(true, true, this); auto* dataLayout = new QVBoxLayout(this); dataLayout->setContentsMargins(0, 0, 0, 0); @@ -141,23 +141,23 @@ connect(dumpPanel_, SIGNAL(messageSelectedInMap(int)), this, SLOT(messageSelectedInMap(int))); - //Extra actions for the control panel + // Extra actions for the control panel - //Debug + // Debug actionDebug_ = new QAction(this); actionDebug_->setObjectName(QString::fromUtf8("actionDebug")); actionDebug_->setText(tr("Enable message debug")); actionDebug_->setCheckable(true); actionDebug_->setChecked(false); actionDebug_->setToolTip(tr("Enable message debug")); - //actionDebug_->setIcon(QPixmap(QString::fromUtf8(":/examiner/debug.svg"))); + // actionDebug_->setIcon(QPixmap(QString::fromUtf8(":/examiner/debug.svg"))); connect(actionDebug_, SIGNAL(toggled(bool)), dumpPanel_, SLOT(setEnableDebug(bool))); gotoPanel_->addOptionsAction(actionDebug_); - //Navigate uncompressed + // Navigate uncompressed actionNavigateUncompressed_ = new QAction(this); actionNavigateUncompressed_->setText("Step through uncompressed subsets"); actionNavigateUncompressed_->setCheckable(true); @@ -230,7 +230,7 @@ void MvQBufrMainPanel::subsetChangedInGoto(int value) { - //Override cursor + // Override cursor QApplication::setOverrideCursor(QCursor(Qt::BusyCursor)); dumpPanel_->loadDumpsForSubset(value); QApplication::restoreOverrideCursor(); @@ -251,20 +251,20 @@ QApplication::restoreOverrideCursor(); } -//msgCnt: starts at 0 +// msgCnt: starts at 0 void MvQBufrMainPanel::messageSelected(int msgCnt) { - //Notify the log panel about the selection. + // Notify the log panel about the selection. if (inProfileLoad_ == false) emit newMessageSelected(msgCnt); - //The message counter might not have been initialised. But at this point - //we must know the correct message num so we can set the counter. + // The message counter might not have been initialised. But at this point + // we must know the correct message num so we can set the counter. if (gotoPanel_->messageValue() == 0) { gotoPanel_->resetMessageNum(data_->messageNum(), false); } - //Set the message counter + // Set the message counter gotoPanel_->setMessageValue(msgCnt + 1, false); MvEccBufrMessage* msg = data_->message(msgCnt); @@ -279,9 +279,7 @@ if (msg->isCompressed() == false && doNavigateUncompressed() == false) { subsetText = tr("subsets: ") + QString::number(msg->subsetNum()) + ""; if (msg->subsetNum() > 1) { - subsetText += " ("; - subsetText += (msg->isCompressed() ? "compressed" : "uncompressed"); - subsetText += ")"; + subsetText += " (uncompressed)"; } } else { @@ -353,7 +351,7 @@ void MvQBufrMainPanel::messageFilterChanged(const BufrFilterDef& /*def*/) { - //gotoPanel_->setFilterText(QString::fromStdString(def.messageFilterLabel())); + // gotoPanel_->setFilterText(QString::fromStdString(def.messageFilterLabel())); } void MvQBufrMainPanel::writeSettings(QSettings& settings) @@ -446,7 +444,7 @@ searchTb_->setAutoRaise(true); searchTb_->setIcon(QPixmap(":/examiner/panel_search.svg")); searchTb_->setToolTip(tr("Search in dump tree")); - //searchTb_->setProperty("panelStyle", "2"); + // searchTb_->setProperty("panelStyle", "2"); searchTb_->setShortcut(QKeySequence(tr("Ctrl+F"))); dataControlLayout->addWidget(searchTb_); @@ -455,7 +453,7 @@ keyInfoTb_->setIcon(QPixmap(":/examiner/panel_info.svg")); keyInfoTb_->setCheckable(true); keyInfoTb_->setToolTip(tr("Show key information sidebar")); - //keyInfoTb_->setProperty("panelStyle", "2"); + // keyInfoTb_->setProperty("panelStyle", "2"); keyInfoTb_->setChecked(true); dataControlLayout->addWidget(keyInfoTb_); @@ -464,7 +462,7 @@ splitter_ = new QSplitter(this); vb->addWidget(splitter_, 1); - tree_ = new MvQTreeView(this, true); + tree_ = new MvQTreeView(this, true); model_ = new MvQBufrDataModel(this); tree_->setModel(model_); tree_->setObjectName("dataDumpTree"); @@ -475,7 +473,7 @@ tree_->setContextMenuPolicy(Qt::ActionsContextMenu); - //Add actions to dump tree + // Add actions to dump tree auto* acCopyDumpKey = new QAction(this); acCopyDumpKey->setText(tr("&Copy item")); acCopyDumpKey->setShortcut(QKeySequence(tr("Ctrl+C"))); @@ -488,11 +486,11 @@ splitter_->addWidget(keyWidget_); splitter_->setCollapsible(1, false); - //Initial ratio of widths in the splitter + // Initial ratio of widths in the splitter splitter_->setStretchFactor(0, 6); splitter_->setStretchFactor(1, 1); - //Search widget + // Search widget searchLine_ = new TreeViewSearchLine(this); searchLine_->setView(tree_); searchLine_->setColumns({0}); @@ -514,7 +512,7 @@ connect(keyWidget_, SIGNAL(subsetSelected(int)), this, SIGNAL(subsetSelectedInKeyWidget(int))); - //Adjust ns tree columns + // Adjust ns tree columns QFont f; QFontMetrics fm(f); tree_->setColumnWidth(0, MvQ::textWidth(fm, "Dat pressureReducedToMeanSealevel ")); @@ -532,7 +530,7 @@ { searchLine_->setVisible(true); searchLine_->setFocus(); - //dataDumpSearch_->selectAll(); + // dataDumpSearch_->selectAll(); } void BufrJsonDumpWidget::saveExpandState() @@ -540,15 +538,15 @@ if (expand_) delete expand_; - //Save expand state in the tree + // Save expand state in the tree expand_ = new MvQTreeExpandState(tree_); - //If the dumpData has already been loaded + // If the dumpData has already been loaded if (model_->hasData()) { expand_->save(); } else { - //By default we expand the "Data" toplevel node + // By default we expand the "Data" toplevel node QStringList topLev; topLev << "Data"; expand_->init(topLev); @@ -676,8 +674,8 @@ vb->addWidget(messageLabel_); messageLabel_->hide(); - //auto* w1 = new MvQPanel(this); - auto* w1 = new QWidget(this); + // auto* w1 = new MvQPanel(this); + auto* w1 = new QWidget(this); auto* dataControlLayout = new QHBoxLayout(w1); dataControlLayout->setContentsMargins(0, 0, 0, 0); vb->addWidget(w1); @@ -688,13 +686,13 @@ searchTb_->setAutoRaise(true); searchTb_->setIcon(QPixmap(":/examiner/panel_search.svg")); searchTb_->setToolTip(tr("Search in dump tree")); - //searchTb_->setProperty("panelStyle", "2"); + // searchTb_->setProperty("panelStyle", "2"); searchTb_->setShortcut(QKeySequence(tr("Ctrl+F"))); dataControlLayout->addWidget(searchTb_); dataControlLayout->addSpacing(4); - tree_ = new MvQTreeView(this); + tree_ = new MvQTreeView(this); model_ = new BufrExpandDataModel(this); tree_->setModel(model_); @@ -706,7 +704,7 @@ tree_->setContextMenuPolicy(Qt::ActionsContextMenu); - //Add actions to dump tree + // Add actions to dump tree auto* acCopyDumpKey = new QAction(this); acCopyDumpKey->setText(tr("&Copy item")); acCopyDumpKey->setShortcut(QKeySequence(tr("Ctrl+C"))); @@ -715,7 +713,7 @@ connect(acCopyDumpKey, SIGNAL(triggered()), this, SLOT(slotCopyKey())); - //Search widget + // Search widget searchLine_ = new TreeViewSearchLine(this); searchLine_->setView(tree_); searchLine_->setColumns({0, 1}); @@ -725,7 +723,7 @@ connect(searchTb_, SIGNAL(clicked()), this, SLOT(slotSearch())); - //Adjust ns tree columns + // Adjust ns tree columns QFont f; QFontMetrics fm(f); tree_->setColumnWidth(0, MvQ::textWidth(fm, "0000009 ")); @@ -797,25 +795,15 @@ //=========================================================== MvQBufrDumpPanel::MvQBufrDumpPanel(QWidget* parent) : - QWidget(parent), - currentMsg_(-1), - currentSubset_(-1), - data_(0), - locationContent_(LocationContent), - messageCanBeDecoded_(true), - expandDumpLoaded_(false), - debugDumpLoaded_(false), - navigateUncompressed_(false), - compDumpLoaded_(false), - locationLoaded_(false) + QWidget(parent) { - QWidget* w; - QVBoxLayout* vb; + QWidget* w = nullptr; + QVBoxLayout* vb = nullptr; auto* dumpLayout = new QVBoxLayout(this); dumpLayout->setContentsMargins(0, 0, 0, 0); - //Tab + // Tab dumpTab_ = new QTabWidget(this); dumpLayout->addWidget(dumpTab_); @@ -901,7 +889,7 @@ // Table dump //-------------------------------- - w = new QWidget; + w = new QWidget; vb = new QVBoxLayout(w); vb->setContentsMargins(0, 0, 0, 0); vb->setSpacing(0); @@ -911,7 +899,7 @@ vb->addWidget(tableTe_); - //dataDumpTree_->setDragDropMode(QAbstractItemView::DragOnly); + // dataDumpTree_->setDragDropMode(QAbstractItemView::DragOnly); dumpTab_->addTab(w, tr("Tables")); Q_ASSERT(static_cast(TableTabIndex) == dumpTab_->count() - 1); @@ -922,10 +910,10 @@ // Debug dump //-------------------------------- - w = new QWidget; + w = new QWidget; vb = new QVBoxLayout(w); - //debugTe_=new QPlainTextEdit(this); + // debugTe_=new QPlainTextEdit(this); debugTe_ = new PlainTextWidget(this); debugTe_->editor()->setShowLineNumbers(false); vb->setContentsMargins(0, 0, 0, 0); @@ -940,7 +928,7 @@ // Locations //-------------------------------- - w = new QWidget; + w = new QWidget; vb = new QVBoxLayout(w); vb->setContentsMargins(0, 0, 0, 0); vb->setSpacing(0); @@ -953,7 +941,7 @@ locationW_ = new LocationWidget(this); vb->addWidget(locationW_); - //dataDumpTree_->setDragDropMode(QAbstractItemView::DragOnly); + // dataDumpTree_->setDragDropMode(QAbstractItemView::DragOnly); dumpTab_->addTab(w, tr("Locations")); Q_ASSERT(static_cast(LocationTabIndex) == dumpTab_->count() - 1); @@ -968,15 +956,12 @@ // Init //---------------------------------------- - QFont f; - QFontMetrics fm(f); - connect(dumpTab_, SIGNAL(currentChanged(int)), this, SLOT(currentDumpChanged(int))); - dumpTab_->setCurrentIndex(0); //Default is data dump + dumpTab_->setCurrentIndex(0); // Default is data dump - //The debug tab is disabled by default + // The debug tab is disabled by default setEnableDebug(false); } @@ -992,12 +977,12 @@ Q_ASSERT(currentMsg_ == -1); Q_ASSERT(currentSubset_ == -1); - currentMsg_ = -1; - currentSubset_ = -1; + currentMsg_ = -1; + currentSubset_ = -1; messageCanBeDecoded_ = false; - expandDumpLoaded_ = false; - debugDumpLoaded_ = false; - compDumpLoaded_ = false; + expandDumpLoaded_ = false; + debugDumpLoaded_ = false; + compDumpLoaded_ = false; loadJsonDump(); loadExpandDump(); @@ -1018,8 +1003,8 @@ void MvQBufrDumpPanel::dataFileChanged() { - //The locations are connected to the whole BUFR file. - //We only need to clear them if the BUFR file changes. + // The locations are connected to the whole BUFR file. + // We only need to clear them if the BUFR file changes. clearLocations(); } @@ -1045,28 +1030,28 @@ navigateUncompressed_ = b; } -//msgCnt: starts at 0, subsetCnt: starts at 1 +// msgCnt: starts at 0, subsetCnt: starts at 1 void MvQBufrDumpPanel::loadDumps(int msgCnt, int subsetCnt) { Q_ASSERT(data_); StatusMsgHandler::instance()->show("Message: " + QString::number(msgCnt + 1), true); - currentMsg_ = msgCnt; + currentMsg_ = msgCnt; currentSubset_ = subsetCnt; - //Save expand state in the tree + // Save expand state in the tree jsonDumpWidget_->saveExpandState(); - //Clear all the dumps except the locations. Locations are - //attached to the whole file not to a message. + // Clear all the dumps except the locations. Locations are + // attached to the whole file not to a message. clearDumps(); - //Check if we could completely decode the header!! + // Check if we could completely decode the header!! if (currentMsg_ >= 0 && data_->totalMessageNum() > 0) { MvEccBufrMessage* msg = data_->message(currentMsg_); Q_ASSERT(msg); - //Header decoding is not complete. We display an error message in the Data tab. + // Header decoding is not complete. We display an error message in the Data tab. if (!msg->isHeaderValid()) { MvQ::showTabLabel(dumpTab_, JsonTabIndex, IconProvider::failedPixmap()); QString errMsg("Failed to properly decode header! "); @@ -1078,13 +1063,13 @@ StatusMsgHandler::instance()->task("Generating json dump"); StatusMsgHandler::instance()->failed(); - //We do not continue with all of the dumps!!! + // We do not continue with all of the dumps!!! loadTableDump(); return; } } - //Check for other serious problems + // Check for other serious problems if (currentMsg_ < 0 || currentSubset_ < 1 || data_->totalMessageNum() == 0) { MvQ::showTabLabel(dumpTab_, JsonTabIndex, IconProvider::failedPixmap()); QString errMsg; @@ -1101,9 +1086,9 @@ Q_ASSERT(currentMsg_ >= 0); messageCanBeDecoded_ = true; - expandDumpLoaded_ = false; - debugDumpLoaded_ = false; - compDumpLoaded_ = false; + expandDumpLoaded_ = false; + debugDumpLoaded_ = false; + compDumpLoaded_ = false; loadJsonDump(); loadExpandDump(); @@ -1112,14 +1097,14 @@ loadCompDump(); loadLocations(); - //Restore data tree expand state + // Restore data tree expand state jsonDumpWidget_->restoreExpandState(); } void MvQBufrDumpPanel::loadDumpsForSubset(int subsetCnt) { - //Override cursor - //QApplication::setOverrideCursor(QCursor(Qt::BusyCursor)); + // Override cursor + // QApplication::setOverrideCursor(QCursor(Qt::BusyCursor)); int msgCnt = currentMsg_; Q_ASSERT(currentMsg_ >= 0); @@ -1135,7 +1120,7 @@ " subset: " + QString::number(subsetCnt), true); - //Save expand state in th tree + // Save expand state in th tree jsonDumpWidget_->saveExpandState(); loadJsonDump(); @@ -1143,25 +1128,25 @@ debugDumpLoaded_ = false; loadDebugDump(); - //Restore data tree expand state + // Restore data tree expand state jsonDumpWidget_->restoreExpandState(); } else { jsonDumpWidget_->setSubsetNumber(subsetCnt - 1); } - //Update the key info widget + // Update the key info widget jsonDumpWidget_->updateKeyInfo(); - //QApplication::restoreOverrideCursor(); + // QApplication::restoreOverrideCursor(); } void MvQBufrDumpPanel::clear() { clearDumps(); clearLocations(); - currentMsg_ = -1, - currentSubset_ = -1, + currentMsg_ = -1, + currentSubset_ = -1, messageCanBeDecoded_ = true; } @@ -1186,8 +1171,8 @@ debugDumpLoaded_ = false; } -//The locations are connected to the whole BUFR file. -//We only need to clear them if the BUFR file changes. +// The locations are connected to the whole BUFR file. +// We only need to clear them if the BUFR file changes. void MvQBufrDumpPanel::clearLocations() { if (locationLoaded_) { @@ -1214,7 +1199,7 @@ auto* dump = new BufrDataDump; - int subsetNum = msg->subsetNum(); + int subsetNum = msg->subsetNum(); bool compressed = msg->isCompressed(); std::string strErr; @@ -1226,7 +1211,7 @@ msg->offset(), strErr); if (ret) { QString s = QString::fromStdString(dump->text()); - //qDebug() << s; + // qDebug() << s; if (s.startsWith(",")) s.remove(0, 1); @@ -1259,8 +1244,8 @@ else { } - //Just for development - //data_->readMessageData(currentMsg_,currentSubset_); + // Just for development + // data_->readMessageData(currentMsg_,currentSubset_); } void MvQBufrDumpPanel::loadExpandDump() @@ -1273,7 +1258,7 @@ MvEccBufrMessage* msg = data_->message(currentMsg_); Q_ASSERT(msg); - //It can be expensve to run so we check if it is really needed + // It can be expensve to run so we check if it is really needed if (dumpTab_->currentIndex() != ExpandTabIndex || expandDumpLoaded_) return; @@ -1313,11 +1298,11 @@ expandDumpLoaded_ = true; - //Just for development - //data_->readMessageData(currentMsg_,currentSubset_); + // Just for development + // data_->readMessageData(currentMsg_,currentSubset_); } -//Load data for compressed messages +// Load data for compressed messages void MvQBufrDumpPanel::loadCompDump() { if (currentMsg_ == -1 && currentSubset_ == -1) { @@ -1338,7 +1323,7 @@ } - //It can be expensve to run so we check if it is really needed + // It can be expensve to run so we check if it is really needed if (dumpTab_->currentIndex() != CompTabIndex || compDumpLoaded_) return; @@ -1347,17 +1332,17 @@ if (messageCanBeDecoded_) { StatusMsgHandler::instance()->task("Generating compressed value dump"); - //BufrDataDump* dump = new BufrDataDump; + // BufrDataDump* dump = new BufrDataDump; int subsetNum = msg->subsetNum(); - //bool compressed=msg->isCompressed(); + // bool compressed=msg->isCompressed(); std::string err; - //bool readAsCompressed=compressed; - //if(compressed == false && navigateUncompressed_ == false) - // readAsCompressed=true; + // bool readAsCompressed=compressed; + // if(compressed == false && navigateUncompressed_ == false) + // readAsCompressed=true; - //data_->messageData(msg->prof(),currentMsg_); + // data_->messageData(msg->prof(),currentMsg_); compDumpWidget_->loadData(currentMsg_, subsetNum); @@ -1388,7 +1373,7 @@ s += "ecCodes used the following tables to decode the current message:
"; s += "

WMO tables

"; s += "
  Paths:
    "; - for (auto p : masterDir) { + for (const auto& p : masterDir) { s += "
  • " + QString::fromStdString(p) + "
  • "; } s += "
"; @@ -1398,7 +1383,7 @@ if (msg->localTablesVersionNumber() != 0) { s += "

Local tables

"; s += "
  Paths:
    "; - for (auto p : localDir) { + for (const auto& p : localDir) { s += "
  • " + QString::fromStdString(p) + "
  • "; } s += "
"; @@ -1408,8 +1393,8 @@ tableTe_->setHtml(s); } -//It can be costly. We delay loading it until it becomes first visible with -//the new contents +// It can be costly. We delay loading it until it becomes first visible with +// the new contents void MvQBufrDumpPanel::loadDebugDump() { if (currentMsg_ == -1 && currentSubset_ == -1) { @@ -1424,7 +1409,7 @@ MvEccBufrMessage* msg = data_->message(currentMsg_); Q_ASSERT(msg); - //It can be expensve to run so we check if it is really needed + // It can be expensve to run so we check if it is really needed if (dumpTab_->currentIndex() != DebugTabIndex || debugDumpLoaded_) return; @@ -1437,14 +1422,14 @@ #endif StatusMsgHandler::instance()->task("Generating debug dump"); - int subsetNum = msg->subsetNum(); - bool compressed = msg->isCompressed(); + int subsetNum = msg->subsetNum(); + bool compressed = msg->isCompressed(); bool readAsCompressed = compressed; if (compressed == false && navigateUncompressed_ == false) readAsCompressed = true; std::string err; - bool ret = dump->debug(data_->fileName(), currentMsg_ + 1, currentSubset_, subsetNum, + bool ret = dump->debug(data_->fileName(), currentMsg_ + 1, currentSubset_, subsetNum, readAsCompressed, msg->offset(), err); QString s = QString::fromStdString(dump->debug()); debugTe_->editor()->setPlainText(s); @@ -1482,7 +1467,7 @@ dumpTab_->setCurrentIndex(LocationTabIndex); } -//Sets what the location tab should contain +// Sets what the location tab should contain void MvQBufrDumpPanel::setHasFilterResult(bool b) { setLocationContent((b) ? FilterResultContent : LocationContent); @@ -1508,29 +1493,29 @@ } } -//Load locations for the whole BUFR file!!! -//It can be costly. We delay loading it until it becomes first visible with -//the new contents. +// Load locations for the whole BUFR file!!! +// It can be costly. We delay loading it until it becomes first visible with +// the new contents. void MvQBufrDumpPanel::loadLocations() { if (currentMsg_ == -1 && currentSubset_ == -1) { return; } - //It can be expensve to run so we check if it is really needed + // It can be expensve to run so we check if it is really needed if (dumpTab_->currentIndex() != LocationTabIndex) { return; } - //The current tab is the location tab and it is already loaded: - //we just adjust the message in the location widget + // The current tab is the location tab and it is already loaded: + // we just adjust the message in the location widget else if (locationLoaded_) { - //currentMsg_ starts at 0 + // currentMsg_ starts at 0 locationW_->updateMessage(currentMsg_ + 1); return; } - //The rest of this functions is dealing with the locations + // The rest of this functions is dealing with the locations if (locationContent_ == FilterResultContent) return; @@ -1538,11 +1523,11 @@ Q_ASSERT(data_); std::string err; - //Start status message + // Start status message StatusMsgHandler::instance()->task("Scanning locations"); - //Create progress bar - int num = data_->totalMessageNum(); + // Create progress bar + int num = data_->totalMessageNum(); int minDuration = 1000.; if (num > 1000) { minDuration = 0; @@ -1555,10 +1540,10 @@ connect(this, SIGNAL(locationScanProgess(int)), &progress, SLOT(setValue(int))); - //Create a collector + // Create a collector BufrLocationCollector* collector = locationW_->makeCollector(); - //get the locations, will start and update the progress bar + // get the locations, will start and update the progress bar bool ret = data_->readLocations(collector, err); locationW_->update(collector); @@ -1626,17 +1611,10 @@ BufrExaminer::BufrExaminer(QWidget* parent) : #ifdef ECCODES_UI - MvQAbstractMessageExaminer("codes_ui", MvQAbstractMessageExaminer::BufrType, parent), + MvQAbstractMessageExaminer("codes_ui", MvQAbstractMessageExaminer::BufrType, parent) #else - MvQAbstractMessageExaminer("BufrExaminer", MvQAbstractMessageExaminer::BufrType, parent), + MvQAbstractMessageExaminer("BufrExaminer", MvQAbstractMessageExaminer::BufrType, parent) #endif - filteredPanel_(0), - filteredData_(0), - messageCanBeDecoded_(false), - actionFilterEdit_(0), - actionFilterRemove_(0), - actionSave_(0), - filterDialog_(0) { setAttribute(Qt::WA_DeleteOnClose); @@ -1649,13 +1627,13 @@ #endif setWindowTitle(winTitleBase_); - //Initial size + // Initial size setInitialSize(1100, 800); - //Init + // Init messageType_ = "BUFR"; - //The main tab - holding the original and filtered bufr file + // The main tab - holding the original and filtered bufr file mainTab_ = new QTabWidget(this); #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) mainTab_->setTabBarAutoHide(true); @@ -1664,14 +1642,14 @@ // mainTab_->setProperty("filter", "1"); // mainTab_->tabBar()->setProperty("filter", "1"); - //The main panel - holding the original bufr file + // The main panel - holding the original bufr file mainPanel_ = new MvQBufrMainPanel(false, this); - //The main panel is displayed in the tab. The filtered panel - //will be created and added to the tab on demand. + // The main panel is displayed in the tab. The filtered panel + // will be created and added to the tab on demand. mainTab_->addTab(mainPanel_, tr("Original data")); - //The main tab is on the right hand side of the central splitter + // The main tab is on the right hand side of the central splitter centralSplitter_->addWidget(mainTab_); connect(mainPanel_, SIGNAL(keyProfileChanged()), @@ -1737,7 +1715,7 @@ void BufrExaminer::setupFilterMenu() { - //Filters + // Filters actionFilterEdit_ = new QAction(this); actionFilterEdit_->setText("Edit filter"); actionFilterEdit_->setIcon(QPixmap(":/examiner/filter_blue.svg")); @@ -1748,7 +1726,7 @@ actionFilterRemove_ = new QAction(this); actionFilterRemove_->setText("Remove filtered data"); actionFilterRemove_->setIcon(QPixmap(":/examiner/filter_blue_clear.svg")); - actionFilterRemove_->setEnabled(false); //no filter by default + actionFilterRemove_->setEnabled(false); // no filter by default connect(actionFilterRemove_, SIGNAL(triggered()), this, SLOT(slotFilterRevert())); @@ -1761,18 +1739,18 @@ void BufrExaminer::initMain(MvMessageMetaData* data) { Q_ASSERT(mainPanel_); - auto* bufr = static_cast(data); + auto* bufr = dynamic_cast(data); mainPanel_->init(bufr); } void BufrExaminer::initDumps() { - //dataDumpTree_->setFocus(Qt::OtherFocusReason); + // dataDumpTree_->setFocus(Qt::OtherFocusReason); } void BufrExaminer::initAllKeys() { - //Get all keys + // Get all keys auto* prof = new MvKeyProfile("Metview keys"); prof->addKey(new MvKey("MV_Index", "Message", "Message index")); allKeys_ << prof; @@ -1787,7 +1765,7 @@ #endif } -//A new bufr file is loaded +// A new bufr file is loaded void BufrExaminer::slotLoadFile(QString f) { if (data_->fileName() == f.toStdString()) @@ -1797,7 +1775,7 @@ loadFile(f); - //We need to clean the filter panel + // We need to clean the filter panel slotFilterRevert(); } @@ -1805,7 +1783,7 @@ { Q_ASSERT(filteredPanel_); - if (mainTab_->tabBar()->tabButton(FilteredTabIndex, QTabBar::RightSide) == 0) { + if (mainTab_->tabBar()->tabButton(FilteredTabIndex, QTabBar::RightSide) == nullptr) { auto* closeTb = new QToolButton(filteredPanel_); closeTb->setProperty("filterClose", "1"); closeTb->setAutoRaise(true); @@ -1819,7 +1797,7 @@ mainTab_->tabBar()->setTabButton(FilteredTabIndex, QTabBar::RightSide, closeTb); } - if (mainTab_->tabBar()->tabButton(FilteredTabIndex, QTabBar::LeftSide) == 0) { + if (mainTab_->tabBar()->tabButton(FilteredTabIndex, QTabBar::LeftSide) == nullptr) { Q_ASSERT(actionSave_); auto* hello = new QToolButton(filteredPanel_); hello->setProperty("filterClose", "1"); @@ -1832,7 +1810,7 @@ void BufrExaminer::createFilteredPanel() { if (filteredPanel_) { - //Add the existing panel to the tab and make it visible + // Add the existing panel to the tab and make it visible if (mainTab_->count() - 1 < FilteredTabIndex) { mainTab_->addTab(filteredPanel_, tr("Filtered data")); addCloseButtonFilteredTab(); @@ -1842,13 +1820,13 @@ return; } - //The main panel - holding the original bufr file + // The main panel - holding the original bufr file filteredPanel_ = new MvQBufrMainPanel(true, this); - //The filtered panel is displayed in the tab. + // The filtered panel is displayed in the tab. mainTab_->addTab(filteredPanel_, tr("Filtered data")); - //Add close button to tab + // Add close button to tab addCloseButtonFilteredTab(); connect(filteredPanel_, SIGNAL(keyProfileChanged()), @@ -1866,7 +1844,7 @@ Q_ASSERT(filteredData_); filteredPanel_->init(filteredData_); - //Set the profile on the panel + // Set the profile on the panel MvKeyProfile* profDef = mainPanel_->keyProfile(); Q_ASSERT(profDef); filteredPanel_->loadKeyProfile(profDef); @@ -1874,7 +1852,7 @@ actionFilterRemove_->setEnabled(true); } -//Load a new bufr file in the main panel +// Load a new bufr file in the main panel void BufrExaminer::loadFile(QString f) { #ifdef ECCODES_UI @@ -1883,23 +1861,23 @@ clearLog(); mainPanel_->clear(); - //Set the new file name + // Set the new file name data_->setFileName(f.toStdString()); currentMessageNo_ = -1; - //Reload + // Reload mainPanel_->reloadData(false); - //if(sourceFileName_ == f) - // sourceMessageNum_=data_->totalMessageNum(); + // if(sourceFileName_ == f) + // sourceMessageNum_=data_->totalMessageNum(); updateFileInfoLabel(); - //Notify the the filter dialogue + // Notify the the filter dialogue if (filterDialog_) { filterDialog_->newFileLoaded(f.toStdString()); - //helpers will be initailised later when - //there is data already scanned available!!! + // helpers will be initailised later when + // there is data already scanned available!!! } #ifdef ECCODES_UI @@ -1907,7 +1885,7 @@ #endif } -//Load an empty file in the main panel +// Load an empty file in the main panel void BufrExaminer::loadEmptyFile(QString f) { #ifdef ECCODES_UI @@ -1916,18 +1894,18 @@ clearLog(); mainPanel_->clear(); - //Set the new file name + // Set the new file name data_->setFileName(f.toStdString()); currentMessageNo_ = -1; - //Notify main panel thet a new file will be loaded - //mainPanel_->dataFileChanged(); + // Notify main panel thet a new file will be loaded + // mainPanel_->dataFileChanged(); - //Reload - //mainPanel_->reloadData(); + // Reload + // mainPanel_->reloadData(); - //if(sourceFileName_ == f) - // sourceMessageNum_=data_->totalMessageNum(); + // if(sourceFileName_ == f) + // sourceMessageNum_=data_->totalMessageNum(); updateFileInfoLabel(); #ifdef ECCODES_UI @@ -1935,13 +1913,13 @@ #endif } -//Load a new bufr file in the filtered panel +// Load a new bufr file in the filtered panel void BufrExaminer::loadFilteredFile(QString f, MvKeyProfile* extractedProf) { #ifdef ECCODES_UI filePanel_->setEnabled(false); #endif - //clearLog(); + // clearLog(); Q_ASSERT(filteredPanel_); Q_ASSERT(filteredData_); @@ -1949,41 +1927,41 @@ filteredPanel_->clear(); - //Set the new file name + // Set the new file name filteredData_->setFileName(f.toStdString()); - //currentMessageNo_=-1; + // currentMessageNo_=-1; - //Reload - filteredPanel_->reloadData(extractedProf != 0); + // Reload + filteredPanel_->reloadData(extractedProf != nullptr); - //if(sourceFileName_ == f) - // sourceMessageNum_=data_->totalMessageNum(); + // if(sourceFileName_ == f) + // sourceMessageNum_=data_->totalMessageNum(); - //Add the extracted results to the filtered panel. - //it will take ownership of it. + // Add the extracted results to the filtered panel. + // it will take ownership of it. if (extractedProf) { filteredPanel_->loadFilterResult(extractedProf); } - //Set save action + // Set save action actionSave_->setEnabled(filteredData_->totalMessageNum() > 0); - //set control panel + // set control panel filteredPanel_->setFilterInfo(true, data_->totalMessageNum(), filteredData_->totalMessageNum()); - //updateFileInfoLabel(); + // updateFileInfoLabel(); #ifdef ECCODES_UI filePanel_->setEnabled(true); #endif } -//Load an empty file in the main panel +// Load an empty file in the main panel void BufrExaminer::loadFilteredEmptyFile(QString f) { #ifdef ECCODES_UI filePanel_->setEnabled(false); #endif - //clearLog(); + // clearLog(); Q_ASSERT(filteredPanel_); Q_ASSERT(filteredData_); @@ -1991,16 +1969,16 @@ filteredPanel_->clear(); - //Set the new file name + // Set the new file name filteredData_->setFileName(f.toStdString()); - //Reload + // Reload filteredPanel_->reloadData(false); - //Set save action + // Set save action actionSave_->setEnabled(false); - //set control panel + // set control panel filteredPanel_->setFilterInfo(true, data_->totalMessageNum(), 0); #ifdef ECCODES_UI @@ -2023,13 +2001,13 @@ void BufrExaminer::slotUncompressedMode(bool) { Q_ASSERT(mainPanel_); - //mainPanel_->setNavigateUncompressed(actionUncompressedMode_->isChecked()); + // mainPanel_->setNavigateUncompressed(actionUncompressedMode_->isChecked()); } void BufrExaminer::newMessageLoaded(int msg) { if (filterDialog_) { - auto* panel = static_cast(sender()); + auto* panel = dynamic_cast(sender()); if (panel != nullptr) { filterDialog_->updateHelpers(panel->data(), msg); } @@ -2042,7 +2020,7 @@ filterDialog_ = new BufrFilterDialog(this); filterDialog_->setModal(false); - //Init helpers + // Init helpers filterDialog_->initHelpers(mainPanel_->data(), mainPanel_->currentMessage()); @@ -2064,13 +2042,13 @@ actionFilterRemove_->setEnabled(false); actionSave_->setEnabled(false); - //these are created on demand so we need to check their existence + // these are created on demand so we need to check their existence if (filteredPanel_ && filteredData_) { Q_ASSERT(filteredPanel_); Q_ASSERT(filteredData_); filteredPanel_->clear(); if (mainTab_->count() - 1 >= FilteredTabIndex) { - //Q_ASSERT(mainTab_->count()-1 >= FilteredTabIndex); + // Q_ASSERT(mainTab_->count()-1 >= FilteredTabIndex); mainTab_->setTabEnabled(FilteredTabIndex, false); mainTab_->removeTab(FilteredTabIndex); filteredPanel_->hide(); @@ -2082,18 +2060,18 @@ { Q_ASSERT(data_); - //if the message filter is empty we revert to the - //source file + // if the message filter is empty we revert to the + // source file std::string err; - //Start status message + // Start status message StatusMsgHandler::instance()->task("Running BUFR filter"); MvTmpFile resFile(false); BufrFilterEngine filter(sourceFileName_.toStdString(), BufrFilterEngine::GuiMode, this); - //Create progress bar - int num = data_->totalMessageNum(); + // Create progress bar + int num = data_->totalMessageNum(); int minDuration = 1000.; if (num > 1000) { minDuration = 0; @@ -2106,12 +2084,12 @@ connect(this, SIGNAL(filterProgess(int)), &progress, SLOT(setValue(int))); - //The object to store the extracted values + // The object to store the extracted values auto* extractedProf = new MvKeyProfile("result"); try { - auto* bmd = static_cast(data_); + auto* bmd = dynamic_cast(data_); Q_ASSERT(bmd); filter.run(def, resFile.path(), extractedProf, num, bmd->messages()); @@ -2122,24 +2100,24 @@ Q_ASSERT(mainTab_->count() - 1 >= FilteredTabIndex); mainTab_->setTabEnabled(FilteredTabIndex, true); - //Check if data values were extracted + // Check if data values were extracted if (!filter.isExtractedDefined()) { delete extractedProf; extractedProf = nullptr; } - //Load the filtered bufr file (in the filter panel) + // Load the filtered bufr file (in the filter panel) QFileInfo f(QString::fromStdString(resFile.path())); if (f.exists()) { - //The extracted results (if exist) will be added to the filtered panel. - //The panel will take ownership of it. + // The extracted results (if exist) will be added to the filtered panel. + // The panel will take ownership of it. loadFilteredFile(QString::fromStdString(resFile.path()), extractedProf); } else { loadFilteredEmptyFile(QString::fromStdString(resFile.path())); } - //Set the main tab index to the filtered panel + // Set the main tab index to the filtered panel Q_ASSERT(mainTab_->count() - 1 >= FilteredTabIndex); mainTab_->setCurrentIndex(FilteredTabIndex); filteredPanel_->selectFilterResultTab(); @@ -2153,7 +2131,7 @@ "Filter failed
Error message: " + QString::fromStdString(e.what())); - //We need to delete prof + // We need to delete prof delete extractedProf; } } @@ -2182,7 +2160,7 @@ QStringList lst = dialog.selectedFiles(); if (lst.count() > 0) { QString fTarget = lst[0]; - QString fSrc = filteredPanel_->fileName(); + QString fSrc = filteredPanel_->fileName(); QString err; if (!MvQFileUtil::copy(fSrc, fTarget, err)) { @@ -2224,11 +2202,11 @@ void BufrExaminer::updateFileInfoLabel() { - //file info panel + // file info panel fileInfoLabel_->setBufrTextLabel(sourceFileName_, data_->totalMessageNum(), false, data_->totalMessageNum(), false); - //window title - //updateWinTitle(sourceFileName_ + ((filtered_)?" [filtered]":"")); + // window title + // updateWinTitle(sourceFileName_ + ((filtered_)?" [filtered]":"")); updateWinTitle(sourceFileName_); } diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrExaminer.h metview-5.19.2/metview/src/BufrExaminer/BufrExaminer.h --- metview-5.17.4/metview/src/BufrExaminer/BufrExaminer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrExaminer.h 2023-07-15 08:28:47.000000000 +0000 @@ -53,7 +53,7 @@ Q_OBJECT public: BufrJsonDumpWidget(MvQBufrDumpPanel* context, QWidget* parent = nullptr); - ~BufrJsonDumpWidget(); + ~BufrJsonDumpWidget() override; void showError(QString errMsg); void saveExpandState(); @@ -75,19 +75,19 @@ signals: void subsetSelectedInKeyWidget(int subsetNumber); -protected: +private: void updateKeyInfo(const QModelIndex& idx); - MvQBufrDumpPanel* context_; - QSplitter* splitter_; - QTreeView* tree_; - MvQBufrDataModel* model_; - MessageLabel* messageLabel_; - QToolButton* searchTb_; - QToolButton* keyInfoTb_; - TreeViewSearchLine* searchLine_; - BufrKeyWidget* keyWidget_; - MvQTreeExpandState* expand_; + MvQBufrDumpPanel* context_{nullptr}; + QSplitter* splitter_{nullptr}; + QTreeView* tree_{nullptr}; + MvQBufrDataModel* model_{nullptr}; + MessageLabel* messageLabel_{nullptr}; + QToolButton* searchTb_{nullptr}; + QToolButton* keyInfoTb_{nullptr}; + TreeViewSearchLine* searchLine_{nullptr}; + BufrKeyWidget* keyWidget_{nullptr}; + MvQTreeExpandState* expand_{nullptr}; }; class BufrExpandDumpWidget : public QWidget @@ -95,7 +95,7 @@ Q_OBJECT public: BufrExpandDumpWidget(QWidget* parent = nullptr); - ~BufrExpandDumpWidget(); + ~BufrExpandDumpWidget() override; void showError(QString errMsg); bool loadData(const std::string& dump, QString& err); @@ -108,19 +108,19 @@ void slotSearch(); void slotCopyKey(); -protected: - QTreeView* tree_; - BufrExpandDataModel* model_; - MessageLabel* messageLabel_; - QToolButton* searchTb_; - TreeViewSearchLine* searchLine_; +private: + QTreeView* tree_{nullptr}; + BufrExpandDataModel* model_{nullptr}; + MessageLabel* messageLabel_{nullptr}; + QToolButton* searchTb_{nullptr}; + TreeViewSearchLine* searchLine_{nullptr}; }; class MvQBufrDumpPanel : public QWidget, public MvMessageMetaDataObserver { Q_OBJECT public: - MvQBufrDumpPanel(QWidget* parent = 0); + MvQBufrDumpPanel(QWidget* parent = nullptr); void init(BufrMetaData* data); void loadEmpty(); @@ -152,7 +152,7 @@ void subsetSelected(int); protected: - void locationScanStepChanged(int); + void locationScanStepChanged(int) override; private: enum LocationTabContent @@ -162,11 +162,11 @@ }; enum DumpTabIndex { - JsonTabIndex = 0, - ExpandTabIndex = 1, - CompTabIndex = 2, - TableTabIndex = 3, - DebugTabIndex = 4, + JsonTabIndex = 0, + ExpandTabIndex = 1, + CompTabIndex = 2, + TableTabIndex = 3, + DebugTabIndex = 4, LocationTabIndex = 5 }; @@ -184,35 +184,35 @@ bool isDebugEnabled() const; void setLocationContent(LocationTabContent locCont); - int currentMsg_; //starts at 0 - int currentSubset_; //starts at 1 - BufrMetaData* data_; - QTabWidget* dumpTab_; - - BufrJsonDumpWidget* jsonDumpWidget_; - BufrExpandDumpWidget* expandDumpWidget_; - - QTextEdit* tableTe_; - PlainTextWidget* debugTe_; - - BufrCompDataWidget* compDumpWidget_; - MvQKeyProfileTree* compDumpTree_; - MvQKeyProfileModel* compDumpModel_; - MvQKeyProfileSortFilterModel* compDumpSortModel_; - - MessageLabel* locationMessageLabel_; - LocationWidget* locationW_; - LocationTabContent locationContent_; - - QAction* actionDebug_; - QAction* actionNavigateUncompressed_; - - bool messageCanBeDecoded_; - bool expandDumpLoaded_; - bool debugDumpLoaded_; - bool navigateUncompressed_; - bool compDumpLoaded_; - bool locationLoaded_; + int currentMsg_{-1}; // starts at 0 + int currentSubset_{-1}; // starts at 1 + BufrMetaData* data_{nullptr}; + QTabWidget* dumpTab_{nullptr}; + + BufrJsonDumpWidget* jsonDumpWidget_{nullptr}; + BufrExpandDumpWidget* expandDumpWidget_{nullptr}; + + QTextEdit* tableTe_{nullptr}; + PlainTextWidget* debugTe_{nullptr}; + + BufrCompDataWidget* compDumpWidget_{nullptr}; + MvQKeyProfileTree* compDumpTree_{nullptr}; + MvQKeyProfileModel* compDumpModel_{nullptr}; + MvQKeyProfileSortFilterModel* compDumpSortModel_{nullptr}; + + MessageLabel* locationMessageLabel_{nullptr}; + LocationWidget* locationW_{nullptr}; + LocationTabContent locationContent_{LocationContent}; + + QAction* actionDebug_{nullptr}; + QAction* actionNavigateUncompressed_{nullptr}; + + bool messageCanBeDecoded_{true}; + bool expandDumpLoaded_{false}; + bool debugDumpLoaded_{false}; + bool navigateUncompressed_{false}; + bool compDumpLoaded_{false}; + bool locationLoaded_{false}; }; class MvQBufrMainPanel : public QWidget @@ -254,15 +254,15 @@ void messageNumDetermined(); private: - BufrMetaData* data_; - MvQMessagePanel* messagePanel_; - MvQBufrDumpPanel* dumpPanel_; - MessageControlPanel* gotoPanel_; - QSplitter* dataSplitter_; + BufrMetaData* data_{nullptr}; + MvQMessagePanel* messagePanel_{nullptr}; + MvQBufrDumpPanel* dumpPanel_{nullptr}; + MessageControlPanel* gotoPanel_{nullptr}; + QSplitter* dataSplitter_{nullptr}; bool navigateUncompressed_; bool inProfileLoad_; - QAction* actionDebug_; - QAction* actionNavigateUncompressed_; + QAction* actionDebug_{nullptr}; + QAction* actionNavigateUncompressed_{nullptr}; }; class BufrExaminer : public MvQAbstractMessageExaminer, public BufrFilterEngineObserver @@ -270,46 +270,46 @@ Q_OBJECT public: - BufrExaminer(QWidget* parent = 0); - ~BufrExaminer(); + BufrExaminer(QWidget* parent = nullptr); + ~BufrExaminer() override; - void notifyBufrFilterProgress(int n); + void notifyBufrFilterProgress(int n) override; protected slots: - void slotShowAboutBox(); + void slotShowAboutBox() override; void slotStatusMessage(QString); - void slotLoadFile(QString); + void slotLoadFile(QString) override; void slotUncompressedMode(bool); void slotFilterEdit(); void slotFilterRevert(); void slotRunFilter(const BufrFilterDef&); void slotSaveFilteredFile(bool); void newMessageLoaded(int msg); - void updateFileInfoLabel(); + void updateFileInfoLabel() override; void initFilterEditorHelpers(); signals: void filterProgess(int); protected: - MvKeyProfile* loadedKeyProfile() const; + MvKeyProfile* loadedKeyProfile() const override; private: enum MainTabIndex { OriiginalTabIndex = 0, - FilteredTabIndex = 1 + FilteredTabIndex = 1 }; - void setupFileMenu(); + void setupFileMenu() override; void setupFilterMenu(); - void initMain(MvMessageMetaData* data); - void initDumps(); - void initAllKeys(); + void initMain(MvMessageMetaData* data) override; + void initDumps() override; + void initAllKeys() override; void addCloseButtonFilteredTab(); void createFilteredPanel(); - void loadKeyProfile(MvKeyProfile*); + void loadKeyProfile(MvKeyProfile*) override; void loadFile(QString); void loadEmptyFile(QString f); void loadFilteredFile(QString, MvKeyProfile*); @@ -318,13 +318,13 @@ void writeSettings(); void readSettings(); - QTabWidget* mainTab_; - MvQBufrMainPanel* mainPanel_; - MvQBufrMainPanel* filteredPanel_; - BufrMetaData* filteredData_; - bool messageCanBeDecoded_; - QAction* actionFilterEdit_; - QAction* actionFilterRemove_; - QAction* actionSave_; - BufrFilterDialog* filterDialog_; + QTabWidget* mainTab_{nullptr}; + MvQBufrMainPanel* mainPanel_{nullptr}; + MvQBufrMainPanel* filteredPanel_{nullptr}; + BufrMetaData* filteredData_{nullptr}; + bool messageCanBeDecoded_{false}; + QAction* actionFilterEdit_{nullptr}; + QAction* actionFilterRemove_{nullptr}; + QAction* actionSave_{nullptr}; + BufrFilterDialog* filterDialog_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrExpandDataModel.cc metview-5.19.2/metview/src/BufrExaminer/BufrExpandDataModel.cc --- metview-5.17.4/metview/src/BufrExaminer/BufrExpandDataModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrExpandDataModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,17 +10,16 @@ #include #include -#include +#include #include "BufrExpandDataModel.h" #include "MvKeyProfile.h" BufrExpandDataModel::BufrExpandDataModel(QObject* parent) : - QAbstractItemModel(parent), - prof_(nullptr) + QAbstractItemModel(parent) { templateProf_ = new MvKeyProfile("bufrExpandDump"); - auto* dKey = new MvKey("Descriptor", "Descriptor"); + auto* dKey = new MvKey("Descriptor", "Descriptor"); templateProf_->addKey(dKey); auto* kKey = new MvKey("Key", "Key"); templateProf_->addKey(kKey); @@ -50,16 +49,16 @@ bool BufrExpandDataModel::loadDumpData(const std::string& dump, QString& /*err*/) { MvKeyProfile* prof = templateProf_->clone(); - MvKey* dKey = prof->at(0); - MvKey* kKey = prof->at(1); - MvKey* nKey = prof->at(2); - MvKey* uKey = prof->at(3); + MvKey* dKey = prof->at(0); + MvKey* kKey = prof->at(1); + MvKey* nKey = prof->at(2); + MvKey* uKey = prof->at(3); // parse text - //the format is: - //descriptor key long_name [units] - //where bot long_name and units can contain spaces + // the format is: + // descriptor key long_name [units] + // where bot long_name and units can contain spaces std::istringstream f(dump); std::string line; @@ -77,9 +76,9 @@ kKey->addValue(svec[1]); // units - size_t uPosEnd = svec.size() - 1; + size_t uPosEnd = svec.size() - 1; size_t uPosStart = uPosEnd + 1; - std::string u = svec[uPosEnd]; + std::string u = svec[uPosEnd]; if (u.size() > 1 && u[u.size() - 1] == ']') { for (size_t i = uPosEnd; i >= 3; i--) { u = svec[i]; @@ -149,11 +148,11 @@ QVariant BufrExpandDataModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { - return QVariant(); + return {}; } if (role == Qt::DisplayRole) { - int row = index.row(); + int row = index.row(); int column = index.column(); if (!prof_ || row < 0 || row >= prof_->valueNum() || @@ -191,7 +190,7 @@ return {}; } - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrExpandDataModel.h metview-5.19.2/metview/src/BufrExaminer/BufrExpandDataModel.h --- metview-5.17.4/metview/src/BufrExaminer/BufrExpandDataModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrExpandDataModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,18 +17,18 @@ { public: BufrExpandDataModel(QObject* parent); - ~BufrExpandDataModel(); + ~BufrExpandDataModel() override; bool loadDumpData(const std::string&, QString& err); void clear(); - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& index) const; - QVariant data(const QModelIndex& index, int role) const; - QVariant headerData(const int section, const Qt::Orientation orient, const int role) const; - QModelIndex index(int row, int column, const QModelIndex& parent) const; - QModelIndex parent(const QModelIndex& index) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& index) const override; + QVariant data(const QModelIndex& index, int role) const override; + QVariant headerData(const int section, const Qt::Orientation orient, const int role) const override; + QModelIndex index(int row, int column, const QModelIndex& parent) const override; + QModelIndex parent(const QModelIndex& index) const override; -protected: - MvKeyProfile* templateProf_; - MvKeyProfile* prof_; +private: + MvKeyProfile* templateProf_{nullptr}; + MvKeyProfile* prof_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrFilterDialog.cc metview-5.19.2/metview/src/BufrExaminer/BufrFilterDialog.cc --- metview-5.17.4/metview/src/BufrExaminer/BufrFilterDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrFilterDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,10 +26,10 @@ QString winTitle; #ifdef ECCODES_UI - winTitle = "BUFR filter (codes_ui)"; + winTitle = "BUFR filter (codes_ui)"; settingsName_ = "codesui-bufr-msgFilterDialog"; #else - winTitle = "BUFR filter (Metview)"; + winTitle = "BUFR filter (Metview)"; settingsName_ = "mv-BufrExaminer-msgFilterDialog"; #endif @@ -46,7 +46,7 @@ groupLabel_->setFont(groupf); groupLabel_->setProperty("type", "sub"); - //Find button + // Find button QPalette pal = filterPb_->palette(); pal.setColor(QPalette::Button, MvQTheme::colour("dialog", "default_button")); filterPb_->setPalette(pal); @@ -62,7 +62,7 @@ void BufrFilterDialog::closeEvent(QCloseEvent* event) { event->accept(); - //writeSettings(); + // writeSettings(); } void BufrFilterDialog::accept() @@ -74,9 +74,7 @@ void BufrFilterDialog::newFileLoaded(const std::string& fname) { - if (lastFileLoaded_ != fname) { - lastFileLoaded_ = fname; - } + lastFileLoaded_ = fname; } void BufrFilterDialog::initHelpers(BufrMetaData* decoder, int msgIdx) @@ -125,7 +123,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, settingsName_); - //We have to clear it so that should not remember all the previous values + // We have to clear it so that should not remember all the previous values settings.clear(); settings.beginGroup("main"); diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrFilterDialog.h metview-5.19.2/metview/src/BufrExaminer/BufrFilterDialog.h --- metview-5.17.4/metview/src/BufrExaminer/BufrFilterDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrFilterDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,14 +22,14 @@ Q_OBJECT public: - explicit BufrFilterDialog(QWidget* parent = 0); - virtual ~BufrFilterDialog(); + explicit BufrFilterDialog(QWidget* parent = nullptr); + ~BufrFilterDialog() override; void newFileLoaded(const std::string& fname); void initHelpers(BufrMetaData*, int msgIdx = 0); void updateHelpers(BufrMetaData*, int msgIdx = 0); public Q_SLOTS: - void accept(); + void accept() override; protected Q_SLOTS: void on_filterPb__clicked(bool); @@ -43,7 +43,9 @@ void edited(const BufrFilterDef&); protected: - void closeEvent(QCloseEvent* event); + void closeEvent(QCloseEvent* event) override; + +private: void writeSettings(); void readSettings(); diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrFilterEditor.cc metview-5.19.2/metview/src/BufrExaminer/BufrFilterEditor.cc --- metview-5.17.4/metview/src/BufrExaminer/BufrFilterEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrFilterEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ { loadInit(); - linePen_ = QPen(MvQTheme::colour("iconeditor", "line_item_pen")); + linePen_ = QPen(MvQTheme::colour("iconeditor", "line_item_pen")); framePen_ = QPen(MvQTheme::colour("iconeditor", "frame_pen")); auto* vb = new QVBoxLayout(this); @@ -52,16 +52,15 @@ vb->setContentsMargins(1, 1, 0, 2); vb->addStretch(1); - EditLineHeader* hdr = 0; EditLineFactory elf(grid_, this); Q_FOREACH (MvQProperty* gr, groups_) { - //Create header for the group - hdr = new EditLineHeader(gr->param("title"), grid_, this); + // Create header for the group + auto hdr = new EditLineHeader(gr->param("title"), grid_, this); hdr->setGroupProp(gr); headers_[gr->name()] = hdr; - //Add line editors to the header + // Add line editors to the header Q_FOREACH (MvQProperty* prop, gr->children()) { if (prop->param("hidden") != "1") { lines_[prop->name()] = elf.make(prop, hdr); @@ -74,11 +73,11 @@ // Set up option dependecies //----------------------------------- - //Output + // Output EditLine* line = lines_["EXTRACT"]; Q_ASSERT(line); - //this also calls slotParamCountLeChanged() + // this also calls slotParamCountLeChanged() slotOutputLeChanged(line, line->value()); connect(line, SIGNAL(valueChanged(EditLine*, QString)), @@ -90,14 +89,14 @@ connect(line, SIGNAL(valueChanged(EditLine*, QString)), this, SLOT(slotParamCountLeChanged(EditLine*, QString))); - //Coordinate condition + // Coordinate condition line = lines_["COORDINATE_COUNT"]; Q_ASSERT(line); connect(line, SIGNAL(valueChanged(EditLine*, QString)), this, SLOT(slotCoordKeyCountLeChanged(EditLine*, QString))); - //Date + // Date line = lines_["DATEMODE"]; Q_ASSERT(line); slotDateModeChanged(line, line->value()); @@ -105,7 +104,7 @@ connect(line, SIGNAL(valueChanged(EditLine*, QString)), this, SLOT(slotDateModeChanged(EditLine*, QString))); - //Custom key + // Custom key line = lines_["CUSTOM_COUNT"]; Q_ASSERT(line); slotCustomKeyCountLeChanged(line, line->value()); @@ -149,7 +148,7 @@ } } -//We init the helpers when a new file is selected +// We init the helpers when a new file is selected void BufrFilterEditor::initHelpers(BufrMetaData* decoder, int msgIdx) { helperTypes_.clear(); @@ -196,7 +195,7 @@ EditLine* cntLe = lines_.value("PARAMETER_COUNT", 0); Q_ASSERT(cntLe); - int cnt = cntLe->value().toInt(); //the number of visible param lines + int cnt = cntLe->value().toInt(); // the number of visible param lines int firstHiddenPar = -1; EditLine* collectLe = lines_.value("EXTRACT_MODE", 0); @@ -271,7 +270,7 @@ EditLine* coordCntLe = lines_.value("COORDINATE_COUNT", 0); Q_ASSERT(coordCntLe); - int cnt = coordCntLe->value().toInt(); + int cnt = coordCntLe->value().toInt(); int firstHiddenKey = -1; if (outLe->value() != "OFF") { @@ -322,12 +321,12 @@ { EditLine* customCntLe = lines_.value("CUSTOM_COUNT", 0); Q_ASSERT(customCntLe); - int cnt = customCntLe->value().toInt(); + int cnt = customCntLe->value().toInt(); int firstHiddenKey = -1; customCntLe->setHiddenByRule(false); if (customCntLe->value() == "0") { - firstHiddenKey = 0; //we hide them all + firstHiddenKey = 0; // we hide them all } else { firstHiddenKey = cnt; @@ -446,7 +445,7 @@ def_.clear(); - //Output + // Output addToDef("EXTRACT"); addToDef("MISSING_DATA"); @@ -461,7 +460,7 @@ addToDef("PARAMETER_VALUE_" + QString::number(i + 1)); } - //Coord + // Coord addToDef("COORDINATE_COUNT"); p = findProperty("COORDINATE_COUNT"); Q_ASSERT(p); @@ -473,33 +472,33 @@ addToDef("COORDINATE_VALUE_" + QString::number(i + 1)); } - //collect + // collect addToDef("EXTRACT_MODE"); addToDef("EXTRACT_COORDINATE"); addToDef("EXTRACT_DATE"); - //Index + // Index addToDef("MESSAGE_INDEX"); - //Edition + // Edition addToDef("EDITION"); addToDef("CENTRE"); addToDef("SUBCENTRE"); addToDef("MASTERTABLE"); addToDef("LOCALTABLE"); - //Type + // Type addToDef("DATA_TYPE"); addToDef("DATA_SUBTYPE"); - //Rdb type + // Rdb type addToDef("RDB_TYPE"); - //Identification + // Identification addToDef("IDENT_KEY"); addToDef("IDENT_VALUE"); - //Date, time + // Date, time addToDef("DATEMODE"); addToDef("DATE"); addToDef("TIME"); @@ -509,10 +508,10 @@ addToDef("DATE_2"); addToDef("TIME_2"); - //Area + // Area addToDef("AREA"); - //Custom + // Custom addToDef("CUSTOM_COUNT"); p = findProperty("CUSTOM_COUNT"); Q_ASSERT(p); @@ -529,12 +528,12 @@ MvQProperty* BufrFilterEditor::findProperty(QString id) const { - Q_FOREACH (MvQProperty* p, props_) { + for (auto p : props_) { if (p->name() == id) { return p; } } - return 0; + return nullptr; } void BufrFilterEditor::addToDef(QString id) @@ -543,7 +542,7 @@ Q_ASSERT(p); if (p) { std::string v = p->valueAsString(); - //if(!v.empty()) + // if(!v.empty()) def_.add(id.toStdString(), v); } } @@ -555,37 +554,37 @@ if (EditLine* e = lines_.value(id, 0)) { return e->value(); } - return QString(); + return {}; } void BufrFilterEditor::paintEvent(QPaintEvent* /*event*/) { QPainter painter(this); - //paint bg + // paint bg QPalette pal = palette(); painter.fillRect(0, 0, this->width(), this->height(), pal.color(QPalette::Window)); Q_ASSERT(grid_); painter.setPen(linePen_); - int spacingV = grid_->verticalSpacing(); - int spacingH = grid_->horizontalSpacing(); - int lastY = 0; + int spacingV = grid_->verticalSpacing(); + int spacingH = grid_->horizontalSpacing(); + int lastY = 0; bool currentIsHeader = false; - bool prevIsHeader = true; + bool prevIsHeader = true; #if 0 int currentBlock=0; #endif - //Detect the vertical line pos + // Detect the vertical line pos int vLinePos = 0; for (int i = 0; i < grid_->rowCount(); i++) { QLayoutItem* item = grid_->itemAtPosition(i, 3); if (item) { QWidget* w = item->widget(); if (w->property("lineEditHeader").toString() != "1" && w->isVisible()) { - QRect r = item->geometry(); + QRect r = item->geometry(); vLinePos = r.x() - spacingH / 2; break; } @@ -595,37 +594,38 @@ for (int i = 0; i < grid_->rowCount(); i++) { QLayoutItem* item = grid_->itemAtPosition(i, 3); if (item) { - QWidget* w = item->widget(); - currentIsHeader = (w->property("lineEditHeader").toString() == "1"); + if (QWidget* w = item->widget()) { + currentIsHeader = (w->property("lineEditHeader").toString() == "1"); - if (w && w->isVisible() && !currentIsHeader) { - QRect r = item->geometry(); + if (w->isVisible() && !currentIsHeader) { + QRect r = item->geometry(); - vLinePos = r.x() - spacingH / 2; - int h = r.height() + spacingV; - int y = r.y() - spacingV / 2; - - //horizontal line at the top of the row - MvQ::safeDrawLine(QPoint(0, y), QPoint(this->width(), y), &painter); - lastY = y + h; + vLinePos = r.x() - spacingH / 2; + int h = r.height() + spacingV; + int y = r.y() - spacingV / 2; + + // horizontal line at the top of the row + MvQ::safeDrawLine(QPoint(0, y), QPoint(this->width(), y), &painter); + lastY = y + h; + } } } prevIsHeader = currentIsHeader; } - //The last Horizontal line + // The last Horizontal line if (!prevIsHeader) { MvQ::safeDrawLine(QPoint(0, lastY - 1), QPoint(this->width(), lastY - 1), &painter); } - //Vertical lines + // Vertical lines if (grid_->rowCount() > 1) { if (vLinePos > 0) { MvQ::safeDrawLine(QPoint(vLinePos, 0), QPoint(vLinePos, lastY), &painter); } } - //Frame + // Frame painter.setPen(framePen_); painter.drawRect(0, 0, this->width(), this->height()); } @@ -642,24 +642,24 @@ return; } - QByteArray json = fIn.readAll(); + QByteArray json = fIn.readAll(); QJsonDocument doc = QJsonDocument::fromJson(json); - //This document is an array of groups + // This document is an array of groups Q_ASSERT(doc.isArray()); for (int i = 0; i < doc.array().count(); i++) { - //We process one group + // We process one group QJsonObject grObj = doc.array()[i].toObject(); Q_ASSERT(!grObj.isEmpty()); QString groupName = grObj.value("name").toString(); - auto* grProp = new MvQProperty(groupName.toStdString()); + auto* grProp = new MvQProperty(groupName.toStdString()); groups_ << grProp; - //Iterat through th ojects in a group - for (QJsonObject::const_iterator it = grObj.constBegin(); it != grObj.constEnd(); it++) { + // Iterat through th ojects in a group + for (QJsonObject::const_iterator it = grObj.constBegin(); it != grObj.constEnd(); ++it) { QString name = it.key(); - //The "options" object contains the array of the options + // The "options" object contains the array of the options if (name == "options") { Q_ASSERT(it.value().isArray()); QJsonArray chArr = it.value().toArray(); @@ -667,14 +667,14 @@ QJsonObject chObj = chArr[j].toObject(); Q_ASSERT(!chObj.isEmpty()); QString chName = chObj.value("name").toString(); - auto* chProp = new MvQProperty(chName.toStdString()); + auto* chProp = new MvQProperty(chName.toStdString()); grProp->addChild(chProp); loadProperty(chArr[j], chProp); chProp->adjustAfterLoad(); props_ << chProp; } } - //Other properties - they must be strings + // Other properties - they must be strings else if (name != "name" && it.value().isString()) { grProp->setParam(name, it.value().toString()); } @@ -687,10 +687,10 @@ if (pt.isObject()) { QJsonObject ob = pt.toObject(); for (QJsonObject::const_iterator it = ob.constBegin(); - it != ob.constEnd(); it++) { + it != ob.constEnd(); ++it) { QString name = it.key(); if (it.value().isString()) { - //Default value + // Default value if (name == "default") { prop->setDefaultValue(it.value().toString().toStdString()); } diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrFilterEditor.h metview-5.19.2/metview/src/BufrExaminer/BufrFilterEditor.h --- metview-5.17.4/metview/src/BufrExaminer/BufrFilterEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrFilterEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,8 +33,8 @@ Q_OBJECT public: - explicit BufrFilterEditor(QWidget* parent = 0); - virtual ~BufrFilterEditor() {} + explicit BufrFilterEditor(QWidget* parent = nullptr); + ~BufrFilterEditor() override = default; const BufrFilterDef& filterDef(); void expandAllGroups(); @@ -59,7 +59,7 @@ void slotCustomKeyCountLeChanged(EditLine*, QString mode); protected: - void paintEvent(QPaintEvent* event); + void paintEvent(QPaintEvent* event) override; void addToDef(QString id); MvQProperty* findProperty(QString id) const; QString lineValue(QString id); @@ -71,7 +71,8 @@ void setParGroupVisibility(QString parPattern, int firstHiddenKey); void updateHelpers(int); - QGridLayout* grid_; +private: + QGridLayout* grid_{nullptr}; QMap headers_; QMap lines_; BufrFilterDef def_; diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrKeyWidget.cc metview-5.19.2/metview/src/BufrExaminer/BufrKeyWidget.cc --- metview-5.17.4/metview/src/BufrExaminer/BufrKeyWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrKeyWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -57,7 +57,7 @@ tree_->hide(); } -//Subset is indexed from 0 here!!!! +// Subset is indexed from 0 here!!!! void BufrKeyWidget::setData(MvQBufrDataItem* item, int subset, MvEccBufrMessage* ecc) { te_->clear(); @@ -69,25 +69,25 @@ return; QString tp; - QString key = item->key(); - QString value = item->rawValue(subset); - QString units = item->data("units"); + QString key = item->key(); + QString value = item->rawValue(subset); + QString units = item->data("units"); QString element = item->data("code"); - QString index = item->data("index"); - int bitWidth = item->data("width").toInt(); + QString index = item->data("index"); + int bitWidth = item->data("width").toInt(); if (key.isEmpty()) return; tp = ""; - //Key block + // Key block tp += formatRow("Key", key); if (!index.isEmpty()) tp += formatRow("Index", index); - //Value block - tp += ""; + // Value block + tp += R"()"; tp += formatRow("Value", value); if (!units.isEmpty()) { tp += formatRow("Units", units); @@ -115,18 +115,18 @@ } - //Element block + // Element block if (!element.isEmpty()) { - tp += ""; + tp += R"()"; tp += formatElementBlock(element); - //Scale etc - tp += ""; + // Scale etc + tp += R"()"; tp += formatRow("Scale", item->data("scale")); tp += formatRow("Reference", item->data("reference")); tp += formatRow("Width", item->data("width")); - QString eccType = "double"; + QString eccType = "double"; QString unitsUpper = units.toUpper(); if (unitsUpper.startsWith("CCITT") || unitsUpper.startsWith("CHARACTER")) @@ -139,11 +139,11 @@ eccType = "long"; if (eccType == "long" || eccType == "double") { - float scale = item->data("scale").toFloat(); - float ref = item->data("reference").toFloat(); - float width = item->data("width").toFloat(); - float minv = ref / std::pow(10., scale); - float maxv = (std::pow(2., width) - 2 + ref) / pow(10, scale); + float scale = item->data("scale").toFloat(); + float ref = item->data("reference").toFloat(); + float width = item->data("width").toFloat(); + float minv = ref / std::pow(10., scale); + float maxv = (std::pow(2., width) - 2 + ref) / pow(10, scale); float precision = pow(10., -scale); tp += formatRow("Min", QString::number(minv)); tp += formatRow("Max", QString::number(maxv)); @@ -156,15 +156,15 @@ tp += "
Value
Value
Element
Element
Representation
Representation
"; te_->insertHtml(tp); - //Display array values in tree + // Display array values in tree if (item->valueIsArray() || (key == "unexpandedDescriptors" && item->valueArray().count() > 1)) { int n = item->valueArray().count(); if (n > 0) { - auto* prof = new MvKeyProfile("tmp"); - std::string firstName = (key == "unexpandedDescriptors") ? "pos" : "subset"; + auto* prof = new MvKeyProfile("tmp"); + std::string firstName = (key == "unexpandedDescriptors") ? "pos" : "subset"; std::string secondName = (key == "unexpandedDescriptors") ? "descriptor" : "value"; - auto* firstKey = new MvKey(firstName, firstName); + auto* firstKey = new MvKey(firstName, firstName); firstKey->setValueType(MvKey::IntType); firstKey->setIntRange(1, n); prof->addKey(firstKey); @@ -181,7 +181,7 @@ tree_->show(); tree_->resizeColumnToContents(0); - //subset is indexed from 0 here + // subset is indexed from 0 here if (key != "unexpandedDescriptors" && subset >= 0 && subset < n) { tree_->setCurrentIndex(sortModel_->mapFromSource(model_->index(subset, 0))); } @@ -214,7 +214,7 @@ QString key("Element"); if (val.length() == 6) { QString type = val.mid(0, 1); - QString cat = val.mid(1, 2); + QString cat = val.mid(1, 2); QString code = val.mid(3, 3); QString defType = "???"; @@ -229,9 +229,9 @@ break; } - QString typeStr = MvQ::formatText(type, MvQTheme::colour("bufrelement", "type")); //"" + type + ""; - QString catStr = MvQ::formatText(cat, MvQTheme::colour("bufrelement", "category")); //"" + cat + ""; - QString codeStr = MvQ::formatText(code, MvQTheme::colour("bufrelement", "code")); //"" + code + ""; + QString typeStr = MvQ::formatText(type, MvQTheme::colour("bufrelement", "type")); //"" + type + ""; + QString catStr = MvQ::formatText(cat, MvQTheme::colour("bufrelement", "category")); //"" + cat + ""; + QString codeStr = MvQ::formatText(code, MvQTheme::colour("bufrelement", "code")); //"" + code + ""; s += formatRow(key, typeStr + catStr + codeStr); s += formatRow("Category", catStr); diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrKeyWidget.h metview-5.19.2/metview/src/BufrExaminer/BufrKeyWidget.h --- metview-5.17.4/metview/src/BufrExaminer/BufrKeyWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrKeyWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ Q_OBJECT public: - explicit BufrKeyWidget(QWidget* parent = 0); + explicit BufrKeyWidget(QWidget* parent = nullptr); void setData(MvQBufrDataItem*, int, MvEccBufrMessage*); void clear(); @@ -33,12 +33,12 @@ signals: void subsetSelected(int); -protected: +private: QString formatKey(QString); QString formatRow(QString key, QString val); QString formatElementBlock(QString val); - MvQKeyProfileModel* model_; - MvQKeyProfileSortFilterModel* sortModel_; + MvQKeyProfileModel* model_{nullptr}; + MvQKeyProfileSortFilterModel* sortModel_{nullptr}; bool broadcast_{true}; }; diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrValueModel.cc metview-5.19.2/metview/src/BufrExaminer/BufrValueModel.cc --- metview-5.17.4/metview/src/BufrExaminer/BufrValueModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrValueModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -227,7 +227,7 @@ QModelIndex BufrValueModel::index(int row, int column, const QModelIndex& parent) const { if (MvQBufrDataItem* parentItem = indexToItem(parent)) { - //qDebug() << "parentItem" << parentItem->key(); + // qDebug() << "parentItem" << parentItem->key(); if (MvQBufrDataItem* item = parentItem->childAt(row)) { return createIndex(row, column, item); diff -Nru metview-5.17.4/metview/src/BufrExaminer/BufrValueModel.h metview-5.19.2/metview/src/BufrExaminer/BufrValueModel.h --- metview-5.17.4/metview/src/BufrExaminer/BufrValueModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/BufrValueModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,11 +28,11 @@ QModelIndex parent(const QModelIndex& index) const; private: - //MvQBufrDataItem* indexToItem(const QModelIndex& idx) const; + // MvQBufrDataItem* indexToItem(const QModelIndex& idx) const; MvQBufrDataItem* root_; QStringList keys_; - //bool compressed_; - //int subsetNumber_; - //QPixmap arrayPix_; + // bool compressed_; + // int subsetNumber_; + // QPixmap arrayPix_; }; diff -Nru metview-5.17.4/metview/src/BufrExaminer/MvBufrFilter.cc metview-5.19.2/metview/src/BufrExaminer/MvBufrFilter.cc --- metview-5.17.4/metview/src/BufrExaminer/MvBufrFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/MvBufrFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -79,7 +79,7 @@ delete cond_[i]; } -//Takes ownership of the condition +// Takes ownership of the condition void BufrFilterConditionGroup::addCondition(BufrFilterCondition* cond) { assert(cond); @@ -164,9 +164,7 @@ return true; } -MvBufrFilter::MvBufrFilter() : - extract_(0), - result_(0) +MvBufrFilter::MvBufrFilter() { std::vector pars; pars.push_back(new DoubleBufrParam("airTemperature")); @@ -177,7 +175,7 @@ BufrFilterCondition* cond = new BufrFilterValueCondition("pressure", vals); coordCondition_.addCondition(cond); - result_ = new MvKeyProfile("bufr"); + result_ = new MvKeyProfile("bufr"); MvKey* mvk = new MvKey("index", "index"); mvk->setValueType(MvKey::IntType); result_->addKey(mvk); @@ -193,35 +191,17 @@ void MvBufrFilter::filter(MvObs& obs) { - //-- coordinate interval start index in the msg - int startIndex = 0; - //-- (implicitly) force descriptors to be expanded obs.setFirstDescriptor(); - //std::size_t keyNum=obs.keyNum(); - while (obs.setNextDescriptor()) { - //obs.setNextDescriptor(); + // obs.setNextDescriptor(); - //The keyname is + // The keyname is std::string keyName = MvObs::keyWithoutOccurrenceTag(obs.currentKey()); - double keyValue = obs.currentValue(); + double keyValue = obs.currentValue(); - //Check conditions - //dateOption_.add(keyName,keyValue); - //identOption_.add(keyName,keyValue); - //locationOption_.add(keyName,keyValue); - //latitudeValue coordCondition_.add(keyName, keyValue); - - //customOption_.add(keyName,keyValue); - - //extractValues_.add(keyName,keyValue); - - //All conditions match - //if(dateOption_.matches() && identOption_.matches() && locationOption_.matches() && - // coordOption_.matches() && customOption_.matches()) if (coordCondition_.match()) { if (extract_->isComplete()) { addToResult(); @@ -232,8 +212,6 @@ if (!extract_->isEmpty()) addToResult(); } - - //cont = obs.setNextDescriptor(); } } diff -Nru metview-5.17.4/metview/src/BufrExaminer/MvBufrFilter.h metview-5.19.2/metview/src/BufrExaminer/MvBufrFilter.h --- metview-5.17.4/metview/src/BufrExaminer/MvBufrFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/MvBufrFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -237,13 +237,14 @@ { public: MvBufrFilter(); + MvBufrFilter(const MvBufrFilter&) = delete; + MvBufrFilter& operator=(const MvBufrFilter&) = delete; void filter(MvObs& anObs); - protected: void addToResult(); BufrFilterConditionGroup coordCondition_; - BufrFilterExtract* extract_; - MvKeyProfile* result_; + BufrFilterExtract* extract_{nullptr}; + MvKeyProfile* result_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/BufrExaminer/MvMain.cc metview-5.19.2/metview/src/BufrExaminer/MvMain.cc --- metview-5.17.4/metview/src/BufrExaminer/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ exit(1); } - //Get grib file name + // Get grib file name std::string fbufr; if (const char* tmpc = in("PATH")) { fbufr = std::string(tmpc); @@ -45,25 +45,25 @@ exit(1); } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("BufrExaminer"); MvQApplication app(argc, argv, appName.c_str(), QStringList{"examiner", "keyDialog", "window", "find"}); - //Create the bufr key manager and initialize it + // Create the bufr key manager and initialize it auto* manager = new MvQKeyManager(MvQKeyManager::BufrType); manager->loadProfiles(); - //Create the bufr metadata object and initialize it + // Create the bufr metadata object and initialize it auto* bufr = new BufrMetaData; bufr->setFileName(fbufr); - //Create the bufr browser and initialize it + // Create the bufr browser and initialize it auto* browser = new BufrExaminer; browser->setAppIcon("BUFR"); - browser->init(bufr, manager, 0); + browser->init(bufr, manager, nullptr); browser->show(); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/BufrExaminer/MvQBufrDataItem.cc metview-5.19.2/metview/src/BufrExaminer/MvQBufrDataItem.cc --- metview-5.17.4/metview/src/BufrExaminer/MvQBufrDataItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/MvQBufrDataItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -94,17 +94,17 @@ return rootItem; } - //Header - auto* headerItem = new MvQBufrDataGroupItem(rootItem); + // Header + auto* headerItem = new MvQBufrDataGroupItem(rootItem); headerItem->title_ = "Header"; - bool inHeader = true; + bool inHeader = true; - //Data - auto* dataItem = new MvQBufrDataGroupItem(rootItem); + // Data + auto* dataItem = new MvQBufrDataGroupItem(rootItem); dataItem->title_ = "Data"; for (auto v : data) { - //It is a header item + // It is a header item if (!v.isArray()) { QJsonObject o = v.toObject(); if (inHeader) @@ -113,14 +113,14 @@ if (o.value("key").toString() == "unexpandedDescriptors") inHeader = false; } - //Data items + // Data items else { inHeader = false; MvQBufrDataItem::loadDump(v, dataItem); } } - //loadDump(data,rootItem); + // loadDump(data,rootItem); } return rootItem; @@ -129,7 +129,7 @@ void MvQBufrDataItem::loadDump(const QJsonValue& value, MvQBufrDataItem* parent) { int arrayCnt = 0; - int keyCnt = 0; + int keyCnt = 0; for (auto v : value.toArray()) { if (v.isArray()) @@ -139,23 +139,23 @@ } for (auto v : value.toArray()) { - //Normal object + // Normal object if (!v.isArray()) { QJsonObject o = v.toObject(); addItem(o, parent); } - //Array + // Array else { - //Each will be a group + // Each will be a group if (arrayCnt > 1) { auto* item = new MvQBufrDataGroupItem(parent); loadDump(v, item); if (item->childCount() > 0) { - item->data_ = item->childAt(0)->data_; + item->data_ = item->childAt(0)->data_; item->valueArray_ = item->childAt(0)->valueArray_; - item->title_ = item->key() + ": "; - //item->title_=item->key() + ": " +item->value(); + item->title_ = item->key() + ": "; + // item->title_=item->key() + ": " +item->value(); } } else { @@ -207,7 +207,7 @@ static QHash beautifiers; if (beautifiers.isEmpty()) { beautifiers["null"] = "missing"; - beautifiers[""] = "missing"; + beautifiers[""] = "missing"; } if (beautifiers.contains(val)) { @@ -258,7 +258,7 @@ QString MvQBufrDataItem::extra() { if (isGroup() || childCount() == 0) - return QString(); + return {}; QString s; for (int i = 0; i < children_.count(); i++) { diff -Nru metview-5.17.4/metview/src/BufrExaminer/MvQBufrDataItem.h metview-5.19.2/metview/src/BufrExaminer/MvQBufrDataItem.h --- metview-5.17.4/metview/src/BufrExaminer/MvQBufrDataItem.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/MvQBufrDataItem.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ class MvQBufrDataItem { public: - MvQBufrDataItem(MvQBufrDataItem* parent = 0); + MvQBufrDataItem(MvQBufrDataItem* parent = nullptr); virtual ~MvQBufrDataItem(); MvQBufrDataItem* childAt(int row); @@ -26,7 +26,7 @@ int childCount() const; int indexInParent() const; - virtual QString title(int) const { return QString(); } + virtual QString title(int) const { return {}; } QString data(QString key) const; QString key() const; QString value(int subset = -1) const { return getValue(subset, true); } @@ -39,7 +39,7 @@ virtual bool isGroup() const { return false; } static MvQBufrDataItem* loadDump(QJsonDocument doc, QString& err); - static void loadDump(const QJsonValue& value, MvQBufrDataItem* parent = 0); + static void loadDump(const QJsonValue& value, MvQBufrDataItem* parent = nullptr); static void addItem(QJsonObject o, MvQBufrDataItem* parent); protected: @@ -62,11 +62,11 @@ friend class MvQBufrDataItem; public: - MvQBufrDataGroupItem(MvQBufrDataItem* parent = 0) : + MvQBufrDataGroupItem(MvQBufrDataItem* parent = nullptr) : MvQBufrDataItem(parent) {} - bool isGroup() const { return true; } - QString title(int subset = -1) const; + bool isGroup() const override { return true; } + QString title(int subset = -1) const override; protected: QString title_; diff -Nru metview-5.17.4/metview/src/BufrExaminer/MvQBufrDataModel.cc metview-5.19.2/metview/src/BufrExaminer/MvQBufrDataModel.cc --- metview-5.17.4/metview/src/BufrExaminer/MvQBufrDataModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/MvQBufrDataModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ void MvQBufrDataModel::clear() { beginResetModel(); - compressed_ = false; + compressed_ = false; subsetNumber_ = -1; if (root_) { delete root_; @@ -114,7 +114,7 @@ QVariant MvQBufrDataModel::data(const QModelIndex& index, int role) const { if (!root_ || !index.isValid()) - return QVariant(); + return {}; MvQBufrDataItem* item = indexToItem(index); Q_ASSERT(item); @@ -142,17 +142,17 @@ else if (index.column() == 1) { if (!item->isGroup()) return item->value(subsetNumber_); - return QVariant(); + return {}; } else if (index.column() == 2) { if (!item->isGroup()) return item->data("units"); - return QVariant(); + return {}; } else if (index.column() == 3) { if (!item->isGroup()) return item->extra(); - return QVariant(); + return {}; } } else if (role == Qt::ToolTipRole) { @@ -183,16 +183,16 @@ f.setBold(true); return f; }*/ - return QVariant(); + return {}; } - return QVariant(); + return {}; } QVariant MvQBufrDataModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) - return QVariant(); + return {}; if (orientation == Qt::Horizontal) { switch (section) { @@ -205,44 +205,44 @@ case 3: return tr("Extra"); default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } QModelIndex MvQBufrDataModel::index(int row, int column, const QModelIndex& parent) const { if (MvQBufrDataItem* parentItem = indexToItem(parent)) { - //qDebug() << "parentItem" << parentItem->key(); + // qDebug() << "parentItem" << parentItem->key(); if (MvQBufrDataItem* item = parentItem->childAt(row)) { return createIndex(row, column, item); } else { - return QModelIndex(); + return {}; } } - return QModelIndex(); + return {}; } QModelIndex MvQBufrDataModel::parent(const QModelIndex& index) const { if (!index.isValid()) - return QModelIndex(); + return {}; if (MvQBufrDataItem* ch = indexToItem(index)) { MvQBufrDataItem* p = ch->parent(); if (p == root_) { - return QModelIndex(); + return {}; } return createIndex(p->indexInParent(), 0, p); } - return QModelIndex(); + return {}; } diff -Nru metview-5.17.4/metview/src/BufrExaminer/MvQBufrDataModel.h metview-5.19.2/metview/src/BufrExaminer/MvQBufrDataModel.h --- metview-5.17.4/metview/src/BufrExaminer/MvQBufrDataModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/MvQBufrDataModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,15 @@ class MvQBufrDataModel : public QAbstractItemModel { public: - explicit MvQBufrDataModel(QObject* parent = 0); - ~MvQBufrDataModel(); + explicit MvQBufrDataModel(QObject* parent = nullptr); + ~MvQBufrDataModel() override; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - QVariant data(const QModelIndex& index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex& index) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex& index, int role) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex& index) const override; bool loadJson(const QByteArray& json, bool compressed, QString& err); bool hasData() const; diff -Nru metview-5.17.4/metview/src/BufrExaminer/MvQBufrDumpModel.cc metview-5.19.2/metview/src/BufrExaminer/MvQBufrDumpModel.cc --- metview-5.17.4/metview/src/BufrExaminer/MvQBufrDumpModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/BufrExaminer/MvQBufrDumpModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,10 +17,10 @@ bool MvQBufrDumpSortFilterModel::lessThan(const QModelIndex& left, const QModelIndex& right) const { - QString leftData = sourceModel()->data(left).toString(); + QString leftData = sourceModel()->data(left).toString(); QString rightData = sourceModel()->data(right).toString(); - //Sort as int + // Sort as int if (QString::number(leftData.toInt()) == leftData) { return leftData.toInt() < rightData.toInt(); } @@ -44,7 +44,7 @@ { data_ = dump; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -63,7 +63,7 @@ if (!data_) return 0; - //Non-root + // Non-root if (parent.isValid()) { int id = parent.internalId(); if (idToLevel(id) == 0) { @@ -73,7 +73,7 @@ return 0; } } - //Root + // Root else { return data_->sectionNum(); } @@ -104,8 +104,8 @@ return label(item, index.column()); } else if (idToLevel(id) == 1) { - int parentRow = idToParentRow(id); - BufrSection* sec = data_->section().at(parentRow); + int parentRow = idToParentRow(id); + BufrSection* sec = data_->section().at(parentRow); BufrSectionItem* item = sec->item().at(index.row()); return label(item, index.column()); } @@ -147,7 +147,7 @@ { switch (column) { case 0: { - //return QString(item->pos().c_str()); + // return QString(item->pos().c_str()); return QString(); } case 1: { @@ -168,12 +168,12 @@ return QModelIndex(); } - //Parent is non-root -> level-1 items: id is the (parent row number +1)*1000 + // Parent is non-root -> level-1 items: id is the (parent row number +1)*1000 if (parent.isValid()) { int id = (parent.row() + 1) * 1000; return createIndex(row, column, id); } - //Parent is root -> level-0 items: id is the row number + // Parent is root -> level-0 items: id is the row number else { return createIndex(row, column, row); } @@ -236,8 +236,8 @@ int id = index.internalId(); if (idToLevel(id) == 1 && index.isValid() && procRows.indexOf(index.row()) == -1) { - int parentRow = idToParentRow(id); - BufrSection* sec = data_->section().at(parentRow); + int parentRow = idToParentRow(id); + BufrSection* sec = data_->section().at(parentRow); BufrSectionItem* item = sec->item().at(index.row()); std::string dumpId = item->name(); @@ -289,7 +289,7 @@ { data_ = dump; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -304,11 +304,11 @@ if (!data_) return 0; - //Non-root + // Non-root if (parent.isValid()) { return 0; } - //Root + // Root else { return data_->itemNum(); } @@ -404,7 +404,7 @@ { data_ = dump; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -422,11 +422,11 @@ if (!data_) return 0; - //Non-root + // Non-root if (parent.isValid()) { return 0; } - //Root + // Root else { return data_->itemNum(); } diff -Nru metview-5.17.4/metview/src/CMakeLists.txt metview-5.19.2/metview/src/CMakeLists.txt --- metview-5.17.4/metview/src/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -100,7 +100,7 @@ # still to do: # ensure that contents of images directory are put into tarball -# will not do: libMars-ecregrid Obstat ObstatCurveTool ObstatScatterTool +# will not do: libMars-ecregrid # propagate ModuleObjectSpecFiles to the parent scope so we can use it again set(ModuleObjectSpecFiles ${ModuleObjectSpecFiles} PARENT_SCOPE) diff -Nru metview-5.17.4/metview/src/codes_ui/BufrExaminerMain.cc metview-5.19.2/metview/src/codes_ui/BufrExaminerMain.cc --- metview-5.17.4/metview/src/codes_ui/BufrExaminerMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/codes_ui/BufrExaminerMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,17 +32,17 @@ ac = argc; av = argv; - //Get input files + // Get input files QStringList inFiles; for (int i = 1; i < argc; i++) { inFiles << argv[i]; } - //Create the filelist + // Create the filelist auto* fileLst = new MvQFileList(inFiles, MvQFileList::BufrFile); Q_ASSERT(fileLst); - //Create the qt application + // Create the qt application MvQSimpleApplication app(ac, av, "BufrExaminer", {"examiner", "keyDialog", "window", "find", "codes_ui"}); @@ -75,16 +75,16 @@ // MvQTheme::init(&app, {"examiner","keyDialog","window","find","codes_ui"}); - //Create the bufr key manager and initialize it + // Create the bufr key manager and initialize it auto* manager = new MvQKeyManager(MvQKeyManager::BufrType); manager->loadProfiles(); - //Create the grib metadata object and initialize it with the first file + // Create the grib metadata object and initialize it with the first file auto* bufr = new BufrMetaData; if (fileLst->count() > 0) bufr->setFileName(fileLst->path(0).toStdString()); - //Create the bufr browser and initialize it + // Create the bufr browser and initialize it auto* browser = new BufrExaminer(); browser->init(bufr, manager, fileLst); browser->show(); @@ -94,6 +94,6 @@ "No BUFR files were found in the specified input. The BUFR files used last time were loaded instead.", QMessageBox::Ok); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/codes_ui/CMakeLists.txt metview-5.19.2/metview/src/codes_ui/CMakeLists.txt --- metview-5.17.4/metview/src/codes_ui/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/codes_ui/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ find_package( ecbuild 3.4 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/../../../ecbuild) -project( codes_ui LANGUAGES C CXX VERSION 1.7.2 ) +project( codes_ui LANGUAGES C CXX VERSION 1.7.4 ) set(BUILD_WITHIN_METVIEW ${ENABLE_CODES_UI}) @@ -505,6 +505,7 @@ LocationView.h LocationWidget.h MessageControlPanel.h + MessageLabel.h PlainTextEdit.h PlainTextWidget.h PropertyLineEditor.h diff -Nru metview-5.17.4/metview/src/codes_ui/CodesDirHandler.cc metview-5.19.2/metview/src/codes_ui/CodesDirHandler.cc --- metview-5.17.4/metview/src/codes_ui/CodesDirHandler.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/codes_ui/CodesDirHandler.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ if (char* shareDirCh = getenv("CODES_UI_DIR_SHARE")) { QDir d(shareDirCh); - shareDir_ = d.path().toStdString(); + shareDir_ = d.path().toStdString(); qtResourceDir_ = d.filePath("images").toStdString(); } // this is for developments diff -Nru metview-5.17.4/metview/src/codes_ui/CodesExaminerMain.cc metview-5.19.2/metview/src/codes_ui/CodesExaminerMain.cc --- metview-5.17.4/metview/src/codes_ui/CodesExaminerMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/codes_ui/CodesExaminerMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ ac = argc; av = argv; - //first arg is the mode + // first arg is the mode std::string fMode(argv[1]); if (fMode != "no" && fMode != "bufr" && fMode != "grib") { @@ -87,15 +87,15 @@ Q_ASSERT(fileLst); - //Create the qt application + // Create the qt application QApplication app(ac, av); - //Init the style + // Init the style QStringList styleLst = QStyleFactory::keys(); - //qDebug() << styleLst; + // qDebug() << styleLst; - //Set the style + // Set the style QString style = "Plastique"; if (styleLst.contains(style)) { app.setStyle(style); @@ -108,7 +108,7 @@ } - //Initialise resorces from a static library (libMvQtGui) + // Initialise resorces from a static library (libMvQtGui) Q_INIT_RESOURCE(examiner); Q_INIT_RESOURCE(keyDialog); Q_INIT_RESOURCE(window); @@ -121,38 +121,38 @@ MvQTheme::init(&app); if (fMode == "bufr" || fileLst->type() == MvQFileList::BufrFile) { - //Create the bufr key manager and initialize it + // Create the bufr key manager and initialize it MvQKeyManager* manager = new MvQKeyManager(MvQKeyManager::BufrType); manager->loadProfiles(); - //Create the grib metadata object and initialize it with the first file + // Create the grib metadata object and initialize it with the first file BufrMetaData* bufr = new BufrMetaData; if (fileLst->count() > 0) bufr->setFileName(fileLst->path(0).toStdString()); - //Create the bufr browser and initialize it + // Create the bufr browser and initialize it BufrExaminer* browser = new BufrExaminer(); browser->init(bufr, manager, fileLst); browser->show(); } else if (fMode == "grib" || fileLst->type() == MvQFileList::GribFile) { - //Create the grib key manager and initialize it + // Create the grib key manager and initialize it MvQKeyManager* manager = new MvQKeyManager(MvQKeyManager::GribType); manager->loadProfiles(); - //Create the grib metadata object and initialize it + // Create the grib metadata object and initialize it GribMetaData* grib = new GribMetaData; if (fileLst->count() > 0) grib->setFileName(fileLst->path(0).toStdString()); - //Create the grib browser and initialize it - //Set tmpfile name - std::string ftmp = "/tmp/grib1234.tmp"; + // Create the grib browser and initialize it + // Set tmpfile name + std::string ftmp = "/tmp/grib1234.tmp"; GribExaminer* browser = new GribExaminer(ftmp); browser->init(grib, manager, fileLst); browser->show(); } - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/codes_ui/GribExaminerMain.cc metview-5.19.2/metview/src/codes_ui/GribExaminerMain.cc --- metview-5.17.4/metview/src/codes_ui/GribExaminerMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/codes_ui/GribExaminerMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,17 +33,17 @@ ac = argc; av = argv; - //Get input files + // Get input files QStringList inFiles; for (int i = 1; i < argc; i++) { inFiles << argv[i]; } - //Create the filelist + // Create the filelist auto* fileLst = new MvQFileList(inFiles, MvQFileList::GribFile); Q_ASSERT(fileLst); - //Create the qt application + // Create the qt application MvQSimpleApplication app(ac, av, "GribExaminer", {"examiner", "keyDialog", "window", "find", "codes_ui"}); @@ -78,17 +78,17 @@ DocHighlighter::init(); - //Create the bufr key manager and initialize it + // Create the bufr key manager and initialize it auto* manager = new MvQKeyManager(MvQKeyManager::GribType); manager->loadProfiles(); - //Create the grib metadata object and initialize it with the first file + // Create the grib metadata object and initialize it with the first file auto* grib = new GribMetaData; if (fileLst->count() > 0) grib->setFileName(fileLst->path(0).toStdString()); - //Create the grib browser and initialize it - //Set tmpfile name + // Create the grib browser and initialize it + // Set tmpfile name auto* browser = new GribExaminer(); browser->init(grib, manager, fileLst); browser->show(); @@ -99,6 +99,6 @@ QMessageBox::Ok); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/CptecAccess/CptecAccess.cc metview-5.19.2/metview/src/CptecAccess/CptecAccess.cc --- metview-5.17.4/metview/src/CptecAccess/CptecAccess.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/CptecAccess/CptecAccess.cc 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,12 @@ #include "CptecAccess.h" -//#include +#include +#include +#include +#include + +#include "MvMiscellaneous.h" void CptecAccess::serve(MvRequest& in, MvRequest& out) { @@ -18,105 +23,27 @@ int i; - // Build the path - std::string spath; - if (!buildPath(in, spath)) + // Get some input arguments + if (!get_common_input_info(in)) return; - // Build the filename(s) - std::vector vfiles; - if (!buildFilenames(in, vfiles)) + // Build path + if (!build_path(in)) return; - // Handling Observation data - const char* type = in("TYPE"); - if (strcmp(type, "OBSERVATION") == 0) { - // Check if file exists - std::string ffile = spath + vfiles[0]; - FILE* f = fopen(ffile.c_str(), "r"); - if (!f) { - std::string error = "CptecAccess-> FILE NOT FOUND: "; - error += ffile.c_str(); - setError(1, error.c_str()); - return; - } - - // Create output request - out.setVerb("BUFR"); - out("PATH") = ffile.c_str(); - out.print(); + // Build filename(s) (full path) + std::vector vfiles; + if (!build_filenames(in, vfiles)) { + std::string error = "Cptec Access-> FILE(S) NOT FOUND: "; + if (!vfiles.empty()) + error += vfiles[0].c_str(); + setError(1, error.c_str()); return; } - // Handling model data - // Get the requested PARAMs - const char* caux; - int nparams = in.iterInit("PARAMETER"); - std::map params; - std::string param; - for (i = 0; i < nparams; ++i) { - in.iterGetNextValue(caux); - param = caux; - params[param] = 1; - } - - // Get the requested LEVELs - int nlevels = in.iterInit("LEVEL_LIST"); - std::map levels; - double dlevel; - for (i = 0; i < nlevels; ++i) { - in.iterGetNextValue(dlevel); - levels[(long)dlevel] = 1; - } - - // Build the requested fieldset - // For each input file filter the requested fields by PARAM/LEVEL - // and add them to the output GRIB file - - // Auxilliary variables for GribApi - char shortName[20]; - size_t len; - int error = 0; - grib_handle* h = nullptr; - grib_context* c = grib_context_get_default(); - - // Create the output file name - std::string outname(marstmp()); - for (i = 0; i < (signed)vfiles.size(); ++i) { - // Full filename - std::string ffile = spath + vfiles[i]; - - // Open the input file - FILE* f = fopen(ffile.c_str(), "r"); - if (!f) { - std::string error = "CptecAccess-> FILE NOT FOUND: "; - error += ffile.c_str(); - setError(1, error.c_str()); - return; - } - - // Loop on all GRIB messages in file - long level; - while ((h = grib_handle_new_from_file(c, f, &error)) != nullptr) { - len = 20; - grib_get_string(h, "shortName", shortName, &len); - param = std::string(shortName); - grib_get_long(h, "level", &level); - if (params.find(param) != params.end()) { - if (levels.find(level) != levels.end()) { - grib_write_message(h, outname.c_str(), "a"); - } - } - - grib_handle_delete(h); - } - - // Create output request - out.setVerb("GRIB"); - out("PATH") = outname.c_str(); - - fclose(f); - } + // Build output file + if (!build_output_file(in, vfiles, out)) + return; std::cout << "CPTEC Access::serve out..." << std::endl; out.print(); @@ -124,7 +51,33 @@ return; } -bool CptecAccess::buildPath(MvRequest& in, string& spath) +bool CptecAccess::get_common_input_info(const MvRequest& in) +{ + // Get all values related to parameter DATE + if (!in.getValue("DATE", sdates_, false)) + return false; + + // Get all values related to parameter TIME + // OBS: this version only allowed one time value, but + // the algorithm below accepts many values + int ntimes = in.countValues("TIME"); + itimes_.clear(); + itimes_.reserve(ntimes); + for (int i = 0; i < ntimes; ++i) + itimes_.push_back((int)in("TIME", i) / 100); // hhmm + + // Get grid resolution + // if (strcmp((const char*)in("GRID"), "OFF") == 0) + // resX_ = resY_ = 0.; + // else { + // resX_ = (double)in("GRID", 0); + // resY_ = (double)in("GRID", 1); + // } + + return true; +} + +bool CptecAccess::build_path(MvRequest& in) { // Build the path // 1. Date/time related string @@ -135,73 +88,91 @@ std::string hh(time, 2); std::string sdate = yyyymm + '/' + dd + hh; - //eta 20 - // /rede/eva01/modoper/tempo/regional/etap_20km/grbctl/2012/Jan/11 - // /rede/tupa_tempo/Eta/ams_15km/temp/201202/1700/grib + // eta 20 + // /rede/eva01/modoper/tempo/regional/etap_20km/grbctl/2012/Jan/11 + // /rede/tupa_tempo/Eta/ams_15km/temp/201202/1700/grib - //eta 15 - 1h - // /rede/contg02/stornext/oper/tempo/Eta/ams_15km/temp/201201/1100/grib + // eta 15 - 1h + // /rede/contg02/stornext/oper/tempo/Eta/ams_15km/temp/201201/1100/grib // 2. Fixed part of the path. Try to get it from the // environment variable: METVIEW_CPTEC_ACCESS_PATH. // If not defined, use a default value. const char* fpath = getenv("METVIEW_CPTEC_ACCESS_PATH"); - spath = fpath ? fpath : "/rede/tupa_tempo/"; - // spath = fpath ? fpath : "/mnt/"; + spath_ = fpath ? fpath : "/data"; // 3. Part of the path related to the model - const char* model = in("MODEL"); - const char* observation = in("OBSERVATION"); - const char* type = in("TYPE"); - - if (strcmp(type, "MODEL") == 0) { - if (strcmp(model, "ETA151") == 0) - spath += "Eta/ams_15km/temp/" + sdate + "/grib/"; - // spath += "eta15/stornext/oper/tempo/Eta/ams_15km/temp/" + sdate + "/grib/"; + std::string stype, smodel, sobs; + if (!in.getValue("TYPE", stype, false)) + return false; + + smodel.empty(); + sobs.empty(); + in.getValue("MODEL", smodel, true); + in.getValue("OBSERVATION", sobs, true); + + if (stype == "MODEL") { + if (smodel == "BAM") { + model_res_ = "TQ0666L064"; + spath_ += "/BAM/" + model_res_ + "/"; + } + else if (smodel == "BAM_HIBRIDO") { + model_res_ = "TQ0666L064"; + spath_ += "/BAM_hibrido/" + model_res_ + "/"; + } + } +#if 0 + else if (strcmp(model, "ETA151") == 0) + spath_ += "/Eta/ams_15km/temp/" + sdate + "/grib/"; else if (strcmp(model, "ETANOR") == 0) - spath += "Eta/nor_10km/" + sdate + "/grbctl/"; + spath_ += "/Eta/nor_10km/" + sdate + "/grbctl/"; else if (strcmp(model, "ETAVALE") == 0) - spath += "Eta/smar_5km/" + sdate + "/grbctl/"; + spath_ += "/Eta/smar_5km/" + sdate + "/grbctl/"; else if (strcmp(model, "GLOBAL299") == 0) - spath += "MCGA/TQ0299L064/" + sdate + "/pos/"; + spath_ += "/MCGA/TQ0299L064/" + sdate + "/pos/"; else if (strcmp(model, "GLOBAL213") == 0) - spath += "MCGA/TQ0213L042/" + sdate + "/pos/"; + spath_ += "/MCGA/TQ0213L042/" + sdate + "/pos/"; else if (strcmp(model, "BRAMS05") == 0) - spath += "BRAMS/ams_05km/" + sdate + "/grads/"; + spath_ += "/BRAMS/ams_05km/" + sdate + "/grads/"; else if (strcmp(model, "MCGA3DVAR") == 0) - spath += "G3DVAR/" + sdate + "/mcga/pos/dataout/"; + spath_ += "/G3DVAR/" + sdate + "/mcga/pos/dataout/"; } - else if (strcmp(type, "OBSERVATION") == 0) { - if (strcmp(observation, "PREPBUFR") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; +#endif + else if (stype == "OBSERVATION") { + spath_ += "/BUFR/"; +#if 0 + if (strcmp(observation, "SYNOP") == 0) + spath_ = "/rede/dds_trabalho/GEMPAK_BUFR/"; + else if (strcmp(observation, "PREPBUFR") == 0) + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; else if (strcmp(observation, "EMA_INMET") == 0) - spath = "/rede/dds_trabalho/HDS/BUFR/"; - else if (strcmp(observation, "SYNOP") == 0) - spath = "/rede/dds_trabalho/GEMPAK_BUFR/"; + spath_ = "/rede/dds_trabalho/HDS/BUFR/"; else if (strcmp(observation, "SYNOP") == 0) - spath = "/rede/dds_trabalho/GEMPAK_BUFR/"; + spath_ = "/rede/dds_trabalho/GEMPAK_BUFR/"; else if (strcmp(observation, "SHIP") == 0) - spath = "/rede/dds_trabalho/GEMPAK_BUFR/"; + spath_ = "/rede/dds_trabalho/GEMPAK_BUFR/"; else if (strcmp(observation, "UPPERAIR") == 0) - spath = "/rede/dds_trabalho/GEMPAK_BUFR/"; + spath_ = "/rede/dds_trabalho/GEMPAK_BUFR/"; else if (strcmp(observation, "AIRCRAFT") == 0) - spath = "/rede/dds_trabalho/GEMPAK_BUFR/"; + spath_ = "/rede/dds_trabalho/GEMPAK_BUFR/"; else if (strcmp(observation, "1bamua") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; else if (strcmp(observation, "1bamub") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; else if (strcmp(observation, "1bhrs3") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; else if (strcmp(observation, "airsev") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; else if (strcmp(observation, "gpsro") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; else if (strcmp(observation, "mtiasi") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; else if (strcmp(observation, "satwnd") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; else if (strcmp(observation, "SAnl") == 0) - spath = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + spath_ = "/rede/tupa_tempo/externos/Download/NCEP/" + sdate + "/"; + } +#endif } else { std::string error = "CptecAccess-> ERROR: MODEL not recognized "; @@ -212,51 +183,73 @@ return true; } -bool CptecAccess::buildFilenames(MvRequest& in, std::vector& vfn) +bool CptecAccess::build_filenames(MvRequest& in, std::vector& vfn) { - int i, j, k; - // Part of the filename related to the model - const char* model = in("MODEL"); - const char* type = in("TYPE"); - const char* observation = in("OBSERVATION"); - - // Get all values related to parameters DATE/TIME/STEP - double xx; - int ndates = in.iterInit("DATE"); - std::vector dates; - dates.reserve(ndates); - for (i = 0; i < ndates; ++i) { - in.iterGetNextValue(xx); - dates.push_back(xx); - } - - int ntimes = in.iterInit("TIME"); - std::vector times; - times.reserve(ntimes); - for (i = 0; i < ntimes; ++i) { - in.iterGetNextValue(xx); - times.push_back(xx / 100.); //hhmm - } - - int nsteps = in.iterInit("STEP"); - std::vector steps; - steps.reserve(nsteps); - for (i = 0; i < nsteps; ++i) { - in.iterGetNextValue(xx); - steps.push_back(xx); + std::string stype = (const char*)in("TYPE"); + if (stype == "MODEL") { + if (!build_model_filenames(in, vfn)) + return false; + } + else if (stype == "OBSERVATION") { + if (!build_observation_filenames(in, vfn)) + return false; } + else { + std::string error = "CptecAccess-> ERROR: TYPE not recognized "; + setError(1, error.c_str()); + return false; + } + + for (auto it : vfn) + std::cout << "FILENAMES: " << it << std::endl; + + return true; +} + +bool CptecAccess::build_model_filenames(MvRequest& in, std::vector& vfn) +{ + std::string smodel = (const char*)in("MODEL"); - char buf[12]; - char buf2[12]; + // Get STEP values (hours) + // If STEP is not given or its single value is ALL then variable + // isteps_ is empty + isteps_.clear(); + if ((const char*)in("STEP")) { + int n = in.countValues("STEP"); + if (n == 1 && strcmp((const char*)in("STEP", 0), "ALL") == 0) { + // input value is ALL -> continue + } + else { + isteps_.reserve(n); + for (int i = 0; i < n; ++i) + isteps_.push_back((int)in("STEP", i)); + } + } - if (strcmp(type, "MODEL") == 0) { - if (strcmp(model, "ETA151") == 0) { + // Build filenames + if (smodel == "BAM") { + if (!build_bam_filenames(vfn)) + return false; + } + else if (smodel == "BAM_HIBRIDO") { + if (!build_bam_filenames(vfn)) + return false; + } + else { + std::string error = "Cptec_Access-> ERROR: MODEL " + smodel + " not implemented yet"; + setError(1, error.c_str()); + return false; + } +#if 0 + int i, j; + + if (model == "ETA151") { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { // Analise time stamp string - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmddHH", buf); std::string cs = "eta_15km_"; cs = cs + buf + '+'; @@ -271,12 +264,12 @@ } } } - else if (strcmp(model, "ETANOR") == 0) { + else if (model == "ETANOR") { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { // Analise time stamp string - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmddHH", buf); std::string cs = "eta_10km_"; cs = cs + buf + '+'; @@ -293,10 +286,10 @@ } else if (strcmp(model, "ETAVALE") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { // Analise time stamp string - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmddHH", buf); std::string cs = "eta_05km_"; cs = cs + buf + '+'; @@ -313,10 +306,10 @@ } else if (strcmp(model, "GLOBAL299") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { // Analise time stamp string - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmddHH", buf); std::string cs = "GPOSNMC"; cs = cs + buf; @@ -333,10 +326,10 @@ } else if (strcmp(model, "GLOBAL213") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { // Analise time stamp string - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmddHH", buf); std::string cs = "GPOSNMC"; cs = cs + buf; @@ -353,10 +346,10 @@ } else if (strcmp(model, "MCGA3DVAR") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { // Analise time stamp string - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmddHH", buf); std::string cs = "GPOSCPT"; cs = cs + buf; @@ -373,10 +366,10 @@ } else if (strcmp(model, "BRAMS05") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { // Analise time stamp string - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmddHH", buf); std::string cs = "JULES_BRAMS05km_"; cs = cs + buf + "_"; @@ -391,13 +384,38 @@ } } } +#endif + return true; +} + + +bool CptecAccess::build_observation_filenames(MvRequest& in, + std::vector& vfn) +{ + // Get observation type + std::string sobs = (const char*)in("OBSERVATION"); + metview::toLower(sobs); + + // Build filenames + std::string sdate_dir, fname; + std::string fn_suffix = ".bufr"; + std::stringstream ss; + for (auto it_date : sdates_) { + sdate_dir = it_date.substr(0, 6) + "/" + it_date.substr(6, it_date.length()) + "/"; + for (auto it_time : itimes_) { + ss.str(""); + ss << std::setw(2) << std::setfill('0') << it_time; + fname = it_date + ss.str() + "_" + sobs + fn_suffix; + vfn.push_back(spath_ + sdate_dir + fname); + } } - else if (strcmp(type, "OBSERVATION") == 0) { + +#if 0 if (strcmp(observation, "PREPBUFR") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -409,9 +427,9 @@ } else if (strcmp(observation, "1bamua") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -423,9 +441,9 @@ } else if (strcmp(observation, "1bamub") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -437,9 +455,9 @@ } else if (strcmp(observation, "1bhrs3") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -451,9 +469,9 @@ } else if (strcmp(observation, "airsev") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -465,9 +483,9 @@ } else if (strcmp(observation, "gpsro") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -479,9 +497,9 @@ } else if (strcmp(observation, "mtiasi") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -493,9 +511,9 @@ } else if (strcmp(observation, "satwnd") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -507,9 +525,9 @@ } else if (strcmp(observation, "SAnl") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -521,9 +539,9 @@ } else if (strcmp(observation, "EMA_INMET") == 0) { for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmdd", buf); danal.Format("HH", buf2); std::string rodada = buf2; @@ -539,26 +557,294 @@ // Build all filenames // char buf[12]; for (i = 0; i < ndates; i++) { - MvDate dd(dates[i]); + MvDate dd(sdates_[i]); for (j = 0; j < ntimes; j++) { // Analise time stamp string - MvDate danal = dd + times[j] / 24.; + MvDate danal = dd + itimes_[j] / 24.; danal.Format("yyyymmddHH", buf); std::string cs = buf; vfn.push_back(cs + "_" + tobs + ".bufr"); } } } +#endif + return true; +} + +bool CptecAccess::build_bam_filenames(std::vector& vfn) +{ + // // Level list is ALL + // std::vector vlevels = vlev; + // if (sltype != "sfc" && vlevels.empty()) + // vlevels = {"1000", "850", "500", "250"}; + + // // Convert all parameter names to uppercase; so users can provide input + // // parameter names in lower or uppercase + // std::vector vparams = sparams_; + // for (std::string& s : vparams) + // metview::toUpper(s); + + // Build filenames + std::string sdate_dir, sdate_hr_dir, fname_p, fname_f; + std::string fn_prefix = "GPOSNMC"; + std::string fn_suffix = "P.fct." + model_res_ + ".grb"; + std::stringstream ss; + for (auto it_date : sdates_) { + sdate_dir = it_date.substr(0, 6) + "/" + it_date.substr(6, it_date.length()); + for (auto it_time : itimes_) { + ss << std::setw(2) << std::setfill('0') << it_time; + sdate_hr_dir = sdate_dir + ss.str() + "/"; + fname_p = fn_prefix + it_date + ss.str(); + MvDate danalise(stoi(it_date)); + for (auto it_step : isteps_) { + MvDate dverify = danalise + (float)(it_step / 24.); + char buf[11]; + dverify.Format("yyyymmddHH", buf); + fname_f = fname_p + buf + fn_suffix; + vfn.push_back(spath_ + sdate_hr_dir + fname_f); + } + } } - else { - std::string error = "CptecAccess-> ERROR: MODEL not recognized "; + + return vfn.empty() ? false : true; +} + +bool CptecAccess::build_output_file(MvRequest& in, std::vector& vfn, MvRequest& out) +{ + std::string stype = (const char*)in("TYPE"); + std::string outfname; + std::string verb; + + // Handling model data + if (stype == "MODEL") { + if (!build_model_output_file(in, vfn, outfname)) + return false; + + verb = "GRIB"; + } + + // Handling observation data + else if (stype == "OBSERVATION") { + if (!build_observation_output_file(in, vfn, outfname)) + return false; + + verb = "BUFR"; + } + + // Check output file + if (outfname.empty()) { + std::string error = "CptecAccess-> ERROR: Output file empty"; setError(1, error.c_str()); return false; } + // Create output request + out.setVerb(verb.c_str()); + out("PATH") = outfname.c_str(); + return true; } +bool CptecAccess::build_model_output_file(MvRequest& in, std::vector& vfn, std::string& outfname) +{ + // Get LEVEL_TYPE value + slevel_type_ = (const char*)in("LEVEL_TYPE"); + // std::string sltype; + // if (slevel_type_ == "10_METER") + // sltype = "sfc"; + // else + // sltype = slevel_type_; + + // Get LEVEL_LIST values: int and string formats + // If LEVEL_LIST is not given or its single value is ALL then variable + // ilevels_ is empty + ilevels_.clear(); + if ((const char*)in("LEVEL_LIST")) { + int n = in.countValues("LEVEL_LIST"); + if (n == 1 && strcmp((const char*)in("LEVEL_LIST", 0), "ALL") == 0) { + // input value is ALL -> continue + } + else { + ilevels_.reserve(n); + for (int i = 0; i < n; ++i) + ilevels_.push_back((int)in("LEVEL_LIST", i)); + } + } + // std::vector slevels; + // left_pad_string(ilevels_, 0, slevels); + + // Get PARAMETER values + if (!in.getValue("PARAMETER", sparams_, false)) + return false; + + std::string smodel = (const char*)in("MODEL"); + if (smodel == "BAM") { + outfname = build_bam_output_file(vfn); + } + else if (smodel == "BAM_HIBRIDO") { + outfname = build_bam_output_file(vfn); + } + +#if 0 + // Get the requested PARAMs + const char* caux; + int nparams = in.iterInit("PARAMETER"); + std::map params; + std::string param; + for (i = 0; i < nparams; ++i) { + in.iterGetNextValue(caux); + param = caux; + params[param] = 1; + } + + // Get the requested LEVELs + int nlevels = in.iterInit("LEVEL_LIST"); + std::map levels; + double dlevel; + for (i = 0; i < nlevels; ++i) { + in.iterGetNextValue(dlevel); + levels[(long)dlevel] = 1; + } + + // Build the requested fieldset + // For each input file filter the requested fields by PARAM/LEVEL + // and add them to the output GRIB file + + // Auxilliary variables for GribApi + char shortName[20]; + size_t len; + int error = 0; + grib_handle* h = nullptr; + grib_context* c = grib_context_get_default(); + + // Create the output file name + std::string outname(marstmp()); + for (i = 0; i < (signed)vfiles.size(); ++i) { + // Full filename + std::string ffile = spath_ + vfiles[i]; + + // Open the input file + FILE* f = fopen(ffile.c_str(), "r"); + if (!f) { + std::string error = "CptecAccess-> FILE NOT FOUND: "; + error += ffile.c_str(); + setError(1, error.c_str()); + return; + } + + // Loop on all GRIB messages in file + long level; + while ((h = grib_handle_new_from_file(c, f, &error)) != nullptr) { + len = 20; + grib_get_string(h, "shortName", shortName, &len); + param = std::string(shortName); + grib_get_long(h, "level", &level); + if (params.find(param) != params.end()) { + if (levels.find(level) != levels.end()) { + grib_write_message(h, outname.c_str(), "a"); + } + } + + grib_handle_delete(h); + } + + // Create output request + out.setVerb("GRIB"); + out("PATH") = outname.c_str(); + + fclose(f); + } +#endif + return true; +} + +bool CptecAccess::build_observation_output_file(MvRequest& in, std::vector& vfn, std::string& outfname) +{ + // Open output file + outfname = marstmp(); + std::ofstream dst(outfname.c_str(), std::ios::binary); + + // Build the requested bufr + // Add requested bufr files to a single output file + for (auto fname : vfn) { + std::ifstream src(fname.c_str(), std::ios::binary); + dst << src.rdbuf(); + src.close(); + } + dst.close(); + + return true; +} + +std::string CptecAccess::build_bam_output_file(std::vector& vfn) +{ + // Convert all parameter names to uppercase; so users can provide input + // parameter names in lower or uppercase + for (auto& s : sparams_) + metview::toUpper(s); + + // Build the requested fieldset + // Add requested messages to the output file + // For each input file filter the requested fields by TYPE/PARAM/LEVEL + // and add them to the output GRIB file + int count = 0; + std::string outname(marstmp()); + for (auto fname : vfn) { + // Auxilliary variables for GribApi + char caux[40]; + size_t len; + int ierror = 0; + grib_handle* h = nullptr; + grib_context* c = grib_context_get_default(); + + // Open input grib file + FILE* f = fopen(fname.c_str(), "r"); + if (!f) { + std::string error = "CptecAccess-> FILE NOT FOUND: "; + error += fname.c_str(); + setError(1, error.c_str()); + return std::string(); + } + + // Search and save requested messages + long ilevel; + std::string sparam, levelType; + while ((h = grib_handle_new_from_file(c, f, &ierror)) != nullptr) { + len = 40; + grib_get_string(h, "shortName", caux, &len); + sparam = std::string(caux); + metview::toUpper(sparam); + + len = 40; + grib_get_string(h, "mars.levtype", caux, &len); + levelType = std::string(caux); + + grib_get_long(h, "level", &ilevel); + if (std::find(sparams_.begin(), sparams_.end(), sparam) != sparams_.end()) + if (levelType == slevel_type_) + if (ilevels_.empty() || + (std::find(ilevels_.begin(), ilevels_.end(), ilevel) != + ilevels_.end())) { + grib_write_message(h, outname.c_str(), "a"); + count++; + } + + grib_handle_delete(h); + } + + fclose(f); + } + + // Consistency check + if (count == 0) { + std::string error = "CptecAccess-> Empty output file: no fields found"; + setError(1, error.c_str()); + return std::string(); + } + + return outname; +} + int main(int argc, char** argv) { MvApplication theApp(argc, argv); diff -Nru metview-5.17.4/metview/src/CptecAccess/CptecAccessDef metview-5.19.2/metview/src/CptecAccess/CptecAccessDef --- metview-5.17.4/metview/src/CptecAccess/CptecAccessDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/CptecAccess/CptecAccessDef 2023-07-15 08:28:47.000000000 +0000 @@ -12,6 +12,14 @@ OBSERVATION { SYNOP ; SYNOP + ACARS ; ACARS + AIREP ; AIREP + AMDAR ; AMDAR + AWS ; AWS + BUOY ; BUOY + METAR ; METAR + SHIP ; SHIP + TEMP ; TEMP SHIP ; SHIP UPPERAIR ; UPPERAIR AIRCRAFT ; AIRCRAFT @@ -29,7 +37,8 @@ MODEL { - + BAM ; BAM + BAM_HIBRIDO ; BAM_HIBRIDO Eta_15Km_1h ; ETA151 BRAMS 05 ; BRAMS05 MCGA - 3Dvar ; MCGA3DVAR @@ -38,17 +47,15 @@ Eta Nordeste ; ETANOR Eta Vale ; ETAVALE - } = Eta_15Km_1h - - + } = BAM LEVEL_TYPE { - SURFACE ; 01 + SURFACE ; sfc # 01 10_METER ; 105 - PRESSURE_LEVEL ; 100 - MODEL_LEVEL ; 107 - } = 100 + PRESSURE_LEVEL ; pl #100 + MODEL_LEVEL ; ml #107 + } = pl LEVEL_LIST { diff -Nru metview-5.17.4/metview/src/CptecAccess/CptecAccess.h metview-5.19.2/metview/src/CptecAccess/CptecAccess.h --- metview-5.17.4/metview/src/CptecAccess/CptecAccess.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/CptecAccess/CptecAccess.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,19 +15,42 @@ Access GRIB/BUFR data from CPTEC's storage directories ************************************************************/ #include -//#include -//#include class CptecAccess : public MvService { public: - CptecAccess(char* name) : + CptecAccess(const char* name) : MvService(name){}; + void serve(MvRequest&, MvRequest&); - // Build the path - bool buildPath(MvRequest&, std::string&); + // Get some input arguments + bool get_common_input_info(const MvRequest&); + + // Build path + bool build_path(MvRequest&); + + // Build filenames + bool build_filenames(MvRequest&, std::vector&); + bool build_model_filenames(MvRequest&, std::vector&); + bool build_observation_filenames(MvRequest&, std::vector&); + bool build_bam_filenames(std::vector&); + + // Build output file + bool build_output_file(MvRequest&, std::vector&, MvRequest&); + bool build_model_output_file(MvRequest&, std::vector&, std::string&); + bool build_observation_output_file(MvRequest&, std::vector&, std::string&); + std::string build_bam_output_file(std::vector&); - // Build the filenames - bool buildFilenames(MvRequest&, std::vector&); +private: + std::vector sdates_; + std::vector sparams_; + std::vector ilevels_; + std::vector itimes_; + std::vector isteps_; + std::string spath_; + std::string slevel_type_; + std::string model_res_; + // float resX_{0.}; + // float resY_{0.}; }; diff -Nru metview-5.17.4/metview/src/CptecAccess/CptecAccessRules metview-5.19.2/metview/src/CptecAccess/CptecAccessRules --- metview-5.17.4/metview/src/CptecAccess/CptecAccessRules 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/CptecAccess/CptecAccessRules 2023-07-15 08:28:47.000000000 +0000 @@ -6,6 +6,7 @@ %unset LEVEL_TYPE %unset LEVEL_LIST %unset PARAMETER - %unset STEP - + %unset STEP +%if LEVEL_TYPE = sfc %then + %unset LEVEL_LIST diff -Nru metview-5.17.4/metview/src/Datacoverage/Datacoverage.cc metview-5.19.2/metview/src/Datacoverage/Datacoverage.cc --- metview-5.17.4/metview/src/Datacoverage/Datacoverage.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Datacoverage/Datacoverage.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,7 +42,7 @@ check_time(), in_time() { - //empty + // empty } void CoverageService::serve(MvRequest& in, MvRequest& out) @@ -62,7 +62,7 @@ // Reset members to defaults descriptors.erase(descriptors.begin(), descriptors.end()); subtype_nrs_.erase(subtype_nrs_.begin(), subtype_nrs_.end()); - plot_ss_ = 1; + plot_ss_ = 1; nr_total_ = cutoff = late_check = 0; @@ -78,10 +78,10 @@ in_req.getValue(data_req, "DATA"); // Get the symbol values. - symb = in_req.getSubrequest("SYMBOL"); + symb = in_req.getSubrequest("SYMBOL"); const char* verb = symb.getVerb(); if (!verb) { - symb = MvRequest("PSYMB"); + symb = MvRequest("PSYMB"); symb("SYMBOL_TYPE") = "MARKER"; } @@ -89,15 +89,15 @@ // Check if reference date, time and and cutoff for plotting late obs. is given. const char *chour, *cymd; chour = in_req("CHECKING_TIME"); - cymd = in_req("CHECKING_DATE"); + cymd = in_req("CHECKING_DATE"); if (chour && cymd) { - hour = atol(chour); - ymd = atol(cymd); + hour = atol(chour); + ymd = atol(cymd); late_check = 1; TDynamicTime tmp_time(ymd, hour); in_time = tmp_time; - cutoff = (int)in("CUTOFF_TIME_IN_MINUTES"); + cutoff = (int)in("CUTOFF_TIME_IN_MINUTES"); if (cutoff > 0) { check_time = in_time; check_time.ChangeByMinutes(cutoff); @@ -129,8 +129,8 @@ // If write_values is OK, complete the out request. if (write_values(fname, *in_set)) { MvRequest geo("GEOPOINTS"); - geo("TEMPORARY") = 1; - geo("PATH") = fname; + geo("TEMPORARY") = 1; + geo("PATH") = fname; geo("ORIGINAL_BUFR_FILE") = data_req("PATH"); generate_info_str(geo, "TITLE"); @@ -143,13 +143,13 @@ // Add some text to output request. MvRequest text("PTEXT"); text("TEXT_AUTOMATIC") = Cached("NO"); - text("TEXT_USER") = Cached("YES"); - text("TEXT_COLOUR") = "BLACK"; + text("TEXT_USER") = Cached("YES"); + text("TEXT_COLOUR") = "BLACK"; generate_info_str(text, "TEXT_LINE_1"); text("LEGEND_TEXT_MAXIMUM_HEIGHT") = 0.2; - text("LEGEND_TEXT_QUALITY") = "MEDIUM"; + text("LEGEND_TEXT_QUALITY") = "MEDIUM"; int columnCount = in_req("LEGEND_COLUMN_COUNT"); if (columnCount > 0) @@ -235,10 +235,10 @@ { char buf[150], lg_txt_buf[30]; - s("LEGEND") = "ON"; - s("LEGEND_TITLE") = "OFF"; - s("LEGEND_TEXT_COLOUR") = "BLACK"; - s("LEGEND_TEXT_QUALITY") = "HIGH"; + s("LEGEND") = "ON"; + s("LEGEND_TITLE") = "OFF"; + s("LEGEND_TEXT_COLOUR") = "BLACK"; + s("LEGEND_TEXT_QUALITY") = "HIGH"; s("LEGEND_TEXT_COMPOSITION") = "USER_TEXT_ONLY"; @@ -255,8 +255,8 @@ // Check the subtype values to see if all is well. - auto ii = subtype_nrs_.begin(); - int stype = (*ii).first; + auto ii = subtype_nrs_.begin(); + int stype = (*ii).first; int found_sat = 0, found_conv = 0; for (; ii != subtype_nrs_.end(); ii++) { @@ -454,16 +454,16 @@ long skip, extract, ierr; // Initialize variables - //e itype = obs.messageType(); + // e itype = obs.messageType(); isbtype_ = obs.messageSubtype(); - //const long satid_desc = 1007; //"satelliteIdentifier" + // const long satid_desc = 1007; //"satelliteIdentifier" const std::string satid_key = "satelliteIdentifier"; - ident_ = 0; - sec2_conf_ = -1; - late_ = 0; + ident_ = 0; + sec2_conf_ = -1; + late_ = 0; if (obs.hasSection2()) { -#if 0 //FAMI20171024 commented out to compile Metview +#if 0 // FAMI20171024 commented out to compile Metview #ifdef MV_BUFRDC_TEST long *sec2 = (long *)obs.section2Ptr(); #endif @@ -541,11 +541,11 @@ iflag = UNKNOWN; else if (qc >= 70) iflag = 2; - else if (qc < 70 && qc >= 50) + else if (qc >= 50) iflag = 3; - else if (qc < 50 && qc >= 30) + else if (qc >= 30) iflag = 4; - else if (qc < 30 && qc >= 0) + else if (qc >= 0) iflag = 5; } @@ -557,7 +557,7 @@ int ObsValues::get_conf_value(MvObs& obs) { int lowest = 101; - int tmp_val; + int tmp_val = 0; if (!plot_ss_ && sec2_conf_ >= 0) lowest = sec2_conf_; @@ -572,7 +572,7 @@ tmp_val = obs.confidence(); if (tmp_val < lowest && tmp_val >= 0) { - found = 1; + found = 1; lowest = tmp_val; } } @@ -621,7 +621,7 @@ skip += extract; if (skip > bword) { - kw = skip / bword; + kw = skip / bword; skip = skip - (kw * bword); wordnr += kw; } diff -Nru metview-5.17.4/metview/src/Datacoverage/Datacoverage.h metview-5.19.2/metview/src/Datacoverage/Datacoverage.h --- metview-5.17.4/metview/src/Datacoverage/Datacoverage.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Datacoverage/Datacoverage.h 2023-07-15 08:28:47.000000000 +0000 @@ -52,7 +52,7 @@ enum { - LATE = 1, + LATE = 1, UNKNOWN = 7 }; @@ -104,9 +104,9 @@ {82, 88, 100, 199, 3, "HIMAWARI"}, {82, 88, 200, 299, 4, "GOES"}, {82, 88, 400, 499, 5, "INSAT"}, - //Sylvie Lamy-Thepaut : add setting for MODIS... - // Increase the value of the unknown ... Change the default symbol - // to add an entry... + // Sylvie Lamy-Thepaut : add setting for MODIS... + // Increase the value of the unknown ... Change the default symbol + // to add an entry... {87, 87, 783, 784, 6, "MODIS"}, {121, 124, 2, 2, 2, "ERS-2"}, diff -Nru metview-5.17.4/metview/src/DebugTools/MvMainMonitor.cc metview-5.19.2/metview/src/DebugTools/MvMainMonitor.cc --- metview-5.17.4/metview/src/DebugTools/MvMainMonitor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/DebugTools/MvMainMonitor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -51,7 +51,7 @@ mon = new ProcMonitor(s); - //start + // start monitor(); mon->show(); diff -Nru metview-5.17.4/metview/src/DebugTools/MvProcNode.cc metview-5.19.2/metview/src/DebugTools/MvProcNode.cc --- metview-5.17.4/metview/src/DebugTools/MvProcNode.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/DebugTools/MvProcNode.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,18 +13,18 @@ #include #include -#include +#include #include -#include +#include unsigned long MvProcStat::uptime_ = 0; -long MvProcStat::pageSize_ = 0; +long MvProcStat::pageSize_ = 0; std::vector MvProcNode::items_; std::vector MvProcNode::procRequests_; -MvProcNode* MvProcNode::root_ = 0; -MvProcNodeObserver* MvProcNode::observer_ = 0; -bool MvProcNode::hasProcFs_ = false; +MvProcNode* MvProcNode::root_ = nullptr; +MvProcNodeObserver* MvProcNode::observer_ = nullptr; +bool MvProcNode::hasProcFs_ = false; //============================================= // @@ -40,7 +40,7 @@ if (MvProcNode::hasProcFs()) { procPath_ = "/proc/" + ss.str() + "/stat"; - sysPath_ = "/proc/stat"; + sysPath_ = "/proc/stat"; if (pageSize_ == 0) pageSize_ = sysconf(_SC_PAGESIZE); @@ -57,16 +57,16 @@ if (!MvProcNode::hasProcFs()) return; - //Get the system uptime - //We need to read it only once - FILE* fp; + // Get the system uptime + // We need to read it only once + FILE* fp = nullptr; - //File uptime tells the secons since the system boot. - //Variable uptime_ contains the POSIX time of the boot! + // File uptime tells the secons since the system boot. + // Variable uptime_ contains the POSIX time of the boot! if ((fp = fopen("/proc/uptime", "r"))) { float fv; if (fscanf(fp, "%f", &fv) != EOF) { - uptime_ = time(0) - static_cast(fv); + uptime_ = time(nullptr) - static_cast(fv); std::cout << "uptime " << uptime_ << std::endl; } @@ -82,7 +82,7 @@ if (!hasUptime()) return; - FILE* fp; + FILE* fp = nullptr; if ((fp = fopen(procPath_.c_str(), "r")) != nullptr) { for (int i = 0; i < 21; i++) { @@ -91,10 +91,10 @@ return; } } - long lv; + long lv = 0; if (fscanf(fp, "%ld", &lv) != EOF) { startTime_ = uptime_ + lv / sysconf(_SC_CLK_TCK); - std::cout << "start time " << startTime_ << " " << time(0) << " " << uptime_ << " " << lv << " " << lv / sysconf(_SC_CLK_TCK) << std::endl; + std::cout << "start time " << startTime_ << " " << time(nullptr) << " " << uptime_ << " " << lv << " " << lv / sysconf(_SC_CLK_TCK) << std::endl; } } @@ -106,8 +106,8 @@ if (!MvProcNode::hasProcFs()) return false; - int cpuOri = cpu_; - std::string vmRssOri = vmRss_; + int cpuOri = cpu_; + std::string vmRssOri = vmRss_; std::string vmSharedOri = vmShared_; if (updateStats()) @@ -128,7 +128,7 @@ if (!MvProcNode::hasProcFs()) return -1; - FILE *fpP, *fpS; + FILE *fpP = nullptr, *fpS = nullptr; CpuTime actCpuTime; if ((fpP = fopen(procPath_.c_str(), "r")) == nullptr) { @@ -140,9 +140,9 @@ return -1; } - long int rss; + long int rss = 0; - //Read process cpu time from /proc/pid/stat + // Read process cpu time from /proc/pid/stat if (fscanf(fpP, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %lu" "%lu %ld %ld %*d %*d %*d %*d %*u %*u %ld", @@ -155,10 +155,10 @@ fclose(fpP); - //Get rss memory + // Get rss memory vmRss_ = byteToMbyte(rss * pageSize_); - //Read system cpu time from proc/stat + // Read system cpu time from proc/stat long unsigned int cpuSys[10]; memset(cpuSys, 0, sizeof(cpuSys)); if (fscanf(fpS, "%*s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", @@ -170,14 +170,14 @@ } fclose(fpS); - //Sum up the numbers to get the total cpu time + // Sum up the numbers to get the total cpu time long unsigned int v = 0; for (unsigned long cpuSy : cpuSys) v += cpuSy; actCpuTime.total_ = v; - //Cpu usage + // Cpu usage if (!prevCpuTime_.isEmpty()) { cpu_ = getCpuUsage(&actCpuTime, &prevCpuTime_); } @@ -191,10 +191,10 @@ if (!MvProcNode::hasProcFs()) return "-1"; - time_t t = time(0) - startTime_; - int d = t / 86400; - int h = (t - d * 86400) / 3600; - int m = (t - d * 86400 - h * 3600) / 60; + time_t t = time(nullptr) - startTime_; + int d = t / 86400; + int h = (t - d * 86400) / 3600; + int m = (t - d * 86400 - h * 3600) / 60; char c[15]; if (d == 0) { @@ -207,14 +207,14 @@ sprintf(c, "%dd:%02dh:%02dm", d, h, m); - //std::stringstream ss; - //ss << h << "h:" << m << "m"; - //lastElapsedTime_=ss.str(); + // std::stringstream ss; + // ss << h << "h:" << m << "m"; + // lastElapsedTime_=ss.str(); lastElapsedTime_ = std::string(c); return lastElapsedTime_; } -//Calculates the elapsed CPU usage between 2 measuring points. in percent +// Calculates the elapsed CPU usage between 2 measuring points. in percent int MvProcStat::getCpuUsage(CpuTime* current, CpuTime* prev) { if (!MvProcNode::hasProcFs()) @@ -222,7 +222,7 @@ long unsigned int tdiff = current->total_ - prev->total_; - //std::cout << "cpu " << tdiff << " " << current->uTime_ << " " << prev->uTime_ << std::endl; + // std::cout << "cpu " << tdiff << " " << current->uTime_ << " " << prev->uTime_ << std::endl; return static_cast(100. * ((current->uTime_ + current->cuTime_) - (prev->uTime_ + prev->cuTime_)) / static_cast(tdiff)); @@ -251,10 +251,10 @@ MvProcNode::MvProcNode(long ref, request* r) : ref_(ref), pid_(-50), - stats_(0), + stats_(nullptr), killLevel_(0), - procRequest_(0), - parent_(0) + procRequest_(nullptr), + parent_(nullptr) { if (r) { if (const char* v = get_value(r, "NAME", 0)) @@ -265,7 +265,7 @@ user_ = std::string(v); if (const char* v = get_value(r, "PID", 0)) { pidStr_ = std::string(v); - pid_ = atol(pidStr_.c_str()); + pid_ = atol(pidStr_.c_str()); if (pid_ > 0) { stats_ = new MvProcStat(host_, pid_); updateStats(); @@ -290,7 +290,7 @@ if (stats_) delete stats_; - //Delete children + // Delete children for (auto& it : children_) { delete it; } @@ -322,7 +322,7 @@ MvProcNode* MvProcNode::root() { if (!root_) { - root_ = new MvProcNode(-1, 0); + root_ = new MvProcNode(-1, nullptr); } return root_; @@ -330,7 +330,7 @@ MvProcNode* MvProcNode::childAt(int i) const { - return (i >= 0 && i < static_cast(children_.size())) ? children_.at(i) : 0; + return (i >= 0 && i < static_cast(children_.size())) ? children_.at(i) : nullptr; } int MvProcNode::indexOfChild(MvProcNode* item) const @@ -346,17 +346,17 @@ { auto* proc = new MvProcNode(ref, r); - for (auto it = items_.begin(); it != items_.end(); it++) { - if (*it != root_ && proc != *it && - proc->name().find((*it)->name()) == 0 && proc->name().find("@") != std::string::npos) { - proc->setParent(*it); + for (auto& item : items_) { + if (item != root_ && proc != item && + proc->name().find(item->name()) == 0 && proc->name().find("@") != std::string::npos) { + proc->setParent(item); return; } } proc->setParent(root_); - //Reparent existing items if needed + // Reparent existing items if needed if (!(proc->name().find("@") != std::string::npos)) { for (auto& item : items_) { if (item != root_ && proc != item && item->name().find("@") != std::string::npos) { @@ -387,7 +387,7 @@ { if (procRequest_) { delete procRequest_; - procRequest_ = 0; + procRequest_ = nullptr; } procRequest_ = req; @@ -441,12 +441,12 @@ if (item->ref() == r && item->name() == name) return item; } - return 0; + return nullptr; } void MvProcNode::killProc() { - int sig; + int sig = 0; switch (killLevel_++) { case 0: sig = 15; @@ -488,9 +488,9 @@ //=========================================== MvProcRequest::MvProcRequest(request* r) : - req_(0) + req_(nullptr) { - reqId_ = atol(get_value(r, "REQ_ID", 0)); + reqId_ = atol(get_value(r, "REQ_ID", 0)); sourceRef_ = atol(get_value(r, "SOURCE_REF", 0)); if (const char* ch = get_value(r, "TARGET", 0)) @@ -500,7 +500,7 @@ source_ = std::string(ch); const char* x = get_value(r, "WAITMODE", 0); - int sync = x ? atoi(x) : 0; + int sync = x ? atoi(x) : 0; if (r->next) { req_ = clone_all_requests(r->next); @@ -513,7 +513,7 @@ } if (const char* ch = get_value(req_, "_NAME", 0)) { - name_ = std::string(ch); //mbasename( + name_ = std::string(ch); // mbasename( } else { name_ = std::string(req_->name); @@ -538,23 +538,23 @@ MvServiceInfo::MvServiceInfo(long ref, request* r) : MvProcNode(ref, r) { - //name = strcache(get_value(r,"NAME",0)); + // name = strcache(get_value(r,"NAME",0)); // Look for @ - //int at = 0; - //const char *p = name; - //while(*p) { if(*p == '@') at++; p++; } - - //host = strcache(get_value(r,"HOST",0)); - //user = strcache(get_value(r,"USER",0)); - //pid = atol(get_value(r,"PID",0)); - - //const char *refp = get_value(r,"REF",0); - //if( refp ) ref = atol( refp ); - //else ref = 0; + // int at = 0; + // const char *p = name; + // while(*p) { if(*p == '@') at++; p++; } + + // host = strcache(get_value(r,"HOST",0)); + // user = strcache(get_value(r,"USER",0)); + // pid = atol(get_value(r,"PID",0)); + + // const char *refp = get_value(r,"REF",0); + // if( refp ) ref = atol( refp ); + // else ref = 0; - //name = strcache(nice_name(name)); - //if(!at) icon = DragAddIcon(drag_service,"SERVICE",name,this,0,0); + // name = strcache(nice_name(name)); + // if(!at) icon = DragAddIcon(drag_service,"SERVICE",name,this,0,0); killLevel_ = 0; } @@ -562,25 +562,25 @@ void MvServiceInfo::debug() { - //kill(pid_,SIGUSR2); + // kill(pid_,SIGUSR2); } /*void MvServiceInfo::kill() { - int sig; - switch(killLevel_++) - { - case 0: sig = 15; break; - default: sig = 9; break; - } - //kill(pid_,sig); + int sig; + switch(killLevel_++) + { + case 0: sig = 15; break; + default: sig = 9; break; + } + //kill(pid_,sig); }*/ void MvServiceInfo::open() { - //Info::Open(); - //char buf[1024]; - //sprintf(buf,"Host: %s\nUser: %s\nPID : %d", + // Info::Open(); + // char buf[1024]; + // sprintf(buf,"Host: %s\nUser: %s\nPID : %d", // host,user,pid); // XmTextSetString(request_text,buf); } @@ -590,7 +590,7 @@ MvProcNode(ref, s), to_(t) { - req_ = clone_all_requests(s); + req_ = clone_all_requests(s); const char* n = mbasename(get_value(req_, "_NAME", 0)); if (!n || !*n) @@ -604,7 +604,7 @@ else name_ = std::string(strcache(n)); - //icon = DragAddIcon(drag_request,c,name,this,0,0); + // icon = DragAddIcon(drag_request,c,name,this,0,0); } MvRequestInfo::~MvRequestInfo() diff -Nru metview-5.17.4/metview/src/DebugTools/MvProcNode.h metview-5.19.2/metview/src/DebugTools/MvProcNode.h --- metview-5.17.4/metview/src/DebugTools/MvProcNode.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/DebugTools/MvProcNode.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,11 +23,11 @@ CpuTime() { clear(); } void clear() { - uTime_ = 0; - sTime_ = 0; + uTime_ = 0; + sTime_ = 0; cuTime_ = 0; csTime_ = 0; - total_ = 0; + total_ = 0; } bool isEmpty() const { return total_ == 0; } @@ -82,6 +82,9 @@ class MvProcNode { public: + MvProcNode(const MvProcNode&) = delete; + MvProcNode& operator=(const MvProcNode&) = delete; + std::string name() { return name_; } std::string niceName() { return niceName_; } long pid() { return pid_; } @@ -180,19 +183,19 @@ private: int killLevel_; /*std::string host_; - std::string user_; - long pid_; - long ref_; - int killLevel_; - - long memTotal_; - long memFree_; - long maxrss_; + std::string user_; + long pid_; + long ref_; + int killLevel_; + + long memTotal_; + long memFree_; + long maxrss_; - std::string vmSize_; - std::string vmRss_;*/ + std::string vmSize_; + std::string vmRss_;*/ - //void kill(); + // void kill(); void debug(); void open(); }; @@ -207,9 +210,9 @@ private: request* req_; long to_; - //void kill(); - //void debug(); - //void update(request*); + // void kill(); + // void debug(); + // void update(request*); void update(long t) { to_ = t; } void open() {} }; @@ -217,14 +220,14 @@ /*class MvQWaitInfo : public MvProcNode { public: - MvQWaitInfo(long,long,const char*,request*); - ~MvQWaitInfo(); + MvQWaitInfo(long,long,const char*,request*); + ~MvQWaitInfo(); private: - request *req_; - //long from_; - //char *to_; - void kill() { } - void debug() { } - void open() {}; + request *req_; + //long from_; + //char *to_; + void kill() { } + void debug() { } + void open() {}; };*/ diff -Nru metview-5.17.4/metview/src/DebugTools/MvQProcModel.cc metview-5.19.2/metview/src/DebugTools/MvQProcModel.cc --- metview-5.17.4/metview/src/DebugTools/MvQProcModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/DebugTools/MvQProcModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,14 +17,14 @@ MvQProcModel::MvQProcModel(QObject* parent) : QAbstractItemModel(parent), - rootItem_(0) + rootItem_(nullptr) { pm_ = new MvQPixmapCache(QPixmap()); cpuYellow_ = QColor(255, 255, 0); cpuOrange_ = QColor(255, 188, 46); - cpuRed_ = QColor(255, 102, 102); - textGrey_ = QColor(100, 100, 100); + cpuRed_ = QColor(255, 102, 102); + textGrey_ = QColor(100, 100, 100); } void MvQProcModel::dataIsAboutToChange() @@ -44,7 +44,7 @@ void MvQProcModel::updateData() { - //beginResetModel(); + // beginResetModel(); endResetModel(); } @@ -68,16 +68,16 @@ if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::BackgroundRole && role != Qt::DecorationRole && role != Qt::TextAlignmentRole && role != Qt::ForegroundRole)) { - return QVariant(); + return {}; } MvProcNode* item = itemForIndex(index); if (!item) - return QVariant(); + return {}; MvProcStat* st = item->stats(); if (!st && index.column() > 0) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { switch (index.column()) { @@ -100,7 +100,7 @@ return pm_->pixmap(QString::fromStdString(req->className())); } else - return QVariant(); + return {}; } else if (role == Qt::BackgroundRole && index.column() == 1) { int cpu = st->cpu(); @@ -111,11 +111,11 @@ else if (cpu > 25) return cpuYellow_; else - return QVariant(); + return {}; } else if (role == Qt::TextAlignmentRole) { if (index.column() == 0 || index.column() == 4) - return QVariant(); + return {}; else return Qt::AlignRight; } @@ -123,7 +123,7 @@ if ((index.column() == 1 && st->cpu() < 1) || index.column() == 4) return textGrey_; } - return QVariant(); + return {}; } @@ -145,7 +145,7 @@ case 4: return QObject::tr("PID"); default: - return QVariant(); + return {}; } } else if (role == Qt::ToolTipRole) { @@ -161,12 +161,12 @@ case 4: return QObject::tr("The unique process ID"); default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } MvProcNode* MvQProcModel::itemForIndex(const QModelIndex& index) const @@ -183,7 +183,7 @@ QModelIndex MvQProcModel::indexForItem(MvProcNode* proc, int column) { if (!proc->parent()) - return QModelIndex(); + return {}; else { int row = proc->parent()->indexOfChild(proc); @@ -194,7 +194,7 @@ QModelIndex MvQProcModel::index(int row, int column, const QModelIndex& parent) const { if (!rootItem_ || row < 0 || column < 0) - return QModelIndex(); + return {}; MvProcNode* parentItem = itemForIndex(parent); if (MvProcNode* item = parentItem->childAt(row)) { @@ -202,18 +202,18 @@ return index; } - return QModelIndex(); + return {}; } QModelIndex MvQProcModel::parent(const QModelIndex& index) const { if (!index.isValid()) - return QModelIndex(); + return {}; if (MvProcNode* childItem = itemForIndex(index)) { if (MvProcNode* parentItem = childItem->parent()) { if (parentItem == rootItem_) { - return QModelIndex(); + return {}; } else if (MvProcNode* grandParentItem = parentItem->parent()) { int row = grandParentItem->indexOfChild(parentItem); @@ -222,7 +222,7 @@ } } - return QModelIndex(); + return {}; } void MvQProcModel::infoChanged(MvProcNode* proc) @@ -250,7 +250,7 @@ { QVariant leftData, rightData; if (left.column() == 2) { - leftData = sourceModel()->data(left, Qt::UserRole); + leftData = sourceModel()->data(left, Qt::UserRole); rightData = sourceModel()->data(right, Qt::UserRole); return leftData.toLongLong() < rightData.toLongLong(); } diff -Nru metview-5.17.4/metview/src/DebugTools/MvQProcModel.h metview-5.19.2/metview/src/DebugTools/MvQProcModel.h --- metview-5.17.4/metview/src/DebugTools/MvQProcModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/DebugTools/MvQProcModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,24 +21,24 @@ class MvQProcFilterModel : public QSortFilterProxyModel { public: - MvQProcFilterModel(QObject* parent = 0); + MvQProcFilterModel(QObject* parent = nullptr); bool lessThan(const QModelIndex& left, - const QModelIndex& right) const; + const QModelIndex& right) const override; }; class MvQProcModel : public QAbstractItemModel, public MvProcNodeObserver { public: - MvQProcModel(QObject* parent = 0); + MvQProcModel(QObject* parent = nullptr); - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void dataIsAboutToChange(); void changeData(MvProcNode*); @@ -46,8 +46,8 @@ MvProcNode* itemForIndex(const QModelIndex&) const; MvQPixmapCache* pixmapCache() { return pm_; } - //Observer method - void infoChanged(MvProcNode*); + // Observer method + void infoChanged(MvProcNode*) override; protected: QModelIndex indexForItem(MvProcNode*, int); diff -Nru metview-5.17.4/metview/src/DebugTools/ProcMonitor.cc metview-5.19.2/metview/src/DebugTools/ProcMonitor.cc --- metview-5.17.4/metview/src/DebugTools/ProcMonitor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/DebugTools/ProcMonitor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,6 +28,7 @@ #include "ProcMonitor.h" +#include #include #include "MvQPixmapCache.h" @@ -54,7 +55,7 @@ setWindowTitle("Process Monitor - Metview"); QApplication::setWindowIcon(QPixmap(":/debug/monitor.svg")); - //Initial size + // Initial size setInitialSize(460, 400); QDir procFs("/proc"); @@ -83,8 +84,8 @@ // File info label //------------------ - //Add to layout - //mainLayout->addWidget(examinerBase_->fileInfoLabel()); + // Add to layout + // mainLayout->addWidget(examinerBase_->fileInfoLabel()); //--------------------------- // Process tree to the left @@ -99,11 +100,11 @@ /*messageSortModel_= new MvQBufrDumpSortFilterModel; messageSortModel_->setSourceModel(messageModel_); - messageSortModel_->setDynamicSortFilter(true); - messageSortModel_->setFilterRole(Qt::UserRole); - //messageSortModel_->setFilterRegExp(QRegExp("[1]")); - messageSortModel_->setFilterFixedString("1"); - messageSortModel_->setFilterKeyColumn(0);*/ + messageSortModel_->setDynamicSortFilter(true); + messageSortModel_->setFilterRole(Qt::UserRole); + //messageSortModel_->setFilterRegExp(QRegExp("[1]")); + messageSortModel_->setFilterFixedString("1"); + messageSortModel_->setFilterKeyColumn(0);*/ procTree_ = new MvQTreeView(this); procTree_->setSortingEnabled(true); @@ -112,10 +113,10 @@ procTree_->setAllColumnsShowFocus(true); procTree_->setModel(filterModel_); procTree_->setActvatedByKeyNavigation(true); - //procTree_->setUniformRowHeights(true); + // procTree_->setUniformRowHeights(true); procTree_->setItemsExpandable(false); procTree_->setRootIsDecorated(false); - //procTree_->setIconSize(QSize(40,40)); + // procTree_->setIconSize(QSize(40,40)); auto* delegate = new ProcViewDelegate; procTree_->setItemDelegate(delegate); @@ -129,24 +130,24 @@ mainSplitter_->addWidget(procTree_); - //Add context menu + // Add context menu procTree_->setContextMenuPolicy(Qt::CustomContextMenu); - //Context menu + // Context menu connect(procTree_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotContextMenu(const QPoint&))); connect(procTree_, SIGNAL(clicked(const QModelIndex&)), this, SLOT(slotProcInfo(const QModelIndex&))); - //Init model + // Init model procModel_->changeData(MvProcNode::root()); //--------------------------------- // Process info at the bottom //--------------------------------- - //Read css for the text formatting + // Read css for the text formatting QString cssDoc; QFile f(":/debug/procInfo.css"); QTextStream in(&f); @@ -158,14 +159,14 @@ infoTab_ = new QTabWidget(this); mainSplitter_->addWidget(infoTab_); - //Info + // Info procInfo_ = new QTextEdit(this); procInfo_->setReadOnly(true); procInfo_->setLineWrapMode(QTextEdit::NoWrap); procInfo_->document()->setDefaultStyleSheet(cssDoc); infoTab_->addTab(procInfo_, tr(" Information")); - //Request + // Request procReq_ = new QTextEdit(this); procReq_->setReadOnly(true); procReq_->setLineWrapMode(QTextEdit::NoWrap); @@ -183,15 +184,15 @@ infoTab_->setCornerWidget(tbCloseInfo); infoTab_->hide(); - //procInfo_=new QTextEdit(this); - //procInfo_->setReadOnly(true); - //procInfo_->document()->setDefaultStyleSheet(cssDoc); - //procInfo_->setLineWrapMode(QTextEdit::NoWrap); + // procInfo_=new QTextEdit(this); + // procInfo_->setReadOnly(true); + // procInfo_->document()->setDefaultStyleSheet(cssDoc); + // procInfo_->setLineWrapMode(QTextEdit::NoWrap); - //procInfo_->setWordWrapMode(QTextOption::WordWrap); + // procInfo_->setWordWrapMode(QTextOption::WordWrap); - //mainSplitter_->addWidget(procInfo_); + // mainSplitter_->addWidget(procInfo_); //-------------------------------------- // Buttons @@ -206,12 +207,12 @@ mainLayout->addWidget(buttonBox_); - //Starts stats update + // Starts stats update if (MvProcNode::hasProcFs()) { startService(); } - //Read settings + // Read settings readSettings(); } @@ -230,18 +231,18 @@ if (buttonBox_->standardButton(button) == QDialogButtonBox::Close) { writeSettings(); close(); - //accept(); + // accept(); } } void ProcMonitor::input(svcid* id, request* r) { - //ref is not always present in tQModelIndex index=indexAt(position); he request, so we get it from the id + // ref is not always present in tQModelIndex index=indexAt(position); he request, so we get it from the id long ref = atol(get_value(id->r, "REF", 0)); QString name(get_value(id->r, "NAME", 0)); QString mode(get_value(id->r, "MODE", 0)); - //std::cout << ref << " " << name << " " << mode << std::endl; + // std::cout << ref << " " << name << " " << mode << std::endl; #if 0 std::cout << "id->r ------------------------>" << std::endl; @@ -254,17 +255,17 @@ #endif if (mode == "REPLY") { - //long reqid = atol(get_value(r, "REQ_ID", 0)); - //qDebug() << "reply" << name << reqid; + // long reqid = atol(get_value(r, "REQ_ID", 0)); + // qDebug() << "reply" << name << reqid; } else if (mode == "WAIT") { // long reqid = atol(get_value(r, "REQ_ID", 0)); // long from = atol(get_value(r, "SOURCE_REF", 0)); // const char* to = get_value(r, "TARGET", 0); - //qDebug() << "wait" << name << reqid << from << to; + // qDebug() << "wait" << name << reqid << from << to; } else if (mode == "REGISTER") { - //qDebug() << "register" << name << ref; + // qDebug() << "register" << name << ref; procModel_->dataIsAboutToChange(); MvProcNode::add(ref, r); procModel_->updateData(); @@ -272,24 +273,25 @@ adjustView(); } else if (mode == "BUSY") { - //r = r->next; - //slong reqid = atol(get_value(r, "REQ_ID", 0)); - //qDebug() << "busy" << name << reqid; + // r = r->next; + // slong reqid = atol(get_value(r, "REQ_ID", 0)); + // qDebug() << "busy" << name << reqid; } else if (mode == "SERVICE") { - long reqid = atol(get_value(r, "REQ_ID", 0)); + auto v = get_value(r, "REQ_ID", 0); + long reqid = (v != nullptr)?std::atol(v):0; MvProcNode::addProcRequest(reqid, ref, name.toStdString(), r); // long reqId = atol(get_value(r, "REQ_ID", 0)); // long from = atol(get_value(r, "SOURCE_REF", 0)); // const char* x = get_value(r, "WAITMODE", 0); - //int sync = x ? atoi(x) : 0; - //qDebug() << "service" << name << ref << reqid << from << sync; + // int sync = x ? atoi(x) : 0; + // qDebug() << "service" << name << ref << reqid << from << sync; if (r->next) print_all_requests(r->next); } else if (mode == "EXIT") { - //qDebug() << "exit" << name << ref; + // qDebug() << "exit" << name << ref; procModel_->dataIsAboutToChange(); MvProcNode::remove(ref, name.toStdString()); procModel_->updateData(); @@ -297,8 +299,8 @@ adjustView(); } else if (mode == "PROGRESS") { - //long reqid = atol(get_value(r, "REQ_ID", 0)); - //qDebug() << "progress" << name << reqid; + // long reqid = atol(get_value(r, "REQ_ID", 0)); + // qDebug() << "progress" << name << reqid; } else if (mode == "FOLLOWUP") { long reqid = atol(get_value(r, "REQ_ID", 0)); @@ -318,7 +320,7 @@ if (firstUpdate_) { MvProcNode::updateInfo(); - //Adjust treeview column size to contents + // Adjust treeview column size to contents for (int i = 0; i < procModel_->columnCount() - 1; i++) procTree_->resizeColumnToContents(i); @@ -423,10 +425,10 @@ QString txt; txt += ""; - //Request + // Request MvProcRequest* r = proc->procRequest(); if (r) { - //addTitleInfoRow(tr("Request"),txt,2); + // addTitleInfoRow(tr("Request"),txt,2); addInfoRow("Class", r->className(), txt); addInfoRow("Name", r->name(), txt); @@ -448,7 +450,7 @@ void ProcMonitor::addTitleInfoRow(QString label, QString& info, int colSpan) { - info += ""; + info += R"("; } void ProcMonitor::loadIcons(MvQPixmapCache* pm) @@ -472,7 +474,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-MvMonitor"); - //We have to clear it not to remember all the previous windows + // We have to clear it not to remember all the previous windows settings.clear(); settings.beginGroup("main"); diff -Nru metview-5.17.4/metview/src/DebugTools/XServ.cc metview-5.19.2/metview/src/DebugTools/XServ.cc --- metview-5.17.4/metview/src/DebugTools/XServ.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/DebugTools/XServ.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,11 +31,11 @@ // populate the bar with buttons - one for each available service request* r = mars.setup; - int n = 0; + int n = 0; while (r) { if (strcmp(r->name, "service") == 0) { const char* y = no_quotes(get_value(r, "name", 0)); - auto* button = new QPushButton(QString(y), this); + auto* button = new QPushButton(QString(y), this); buttonLayout_.addWidget(button, n % 25, n / 25); connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked())); n++; @@ -56,9 +56,9 @@ QPoint tl = rect.topLeft(); QPoint qp = scrollAreaInternalWidget_->mapTo(this, tl); - //QScrollBar *sb = scrollArea_.verticalScrollBar(); - //wsize = qp.x() + rect.right() + sb->width(); - int wsize = qp.x() + 22; //sb->width(); + // QScrollBar *sb = scrollArea_.verticalScrollBar(); + // wsize = qp.x() + rect.right() + sb->width(); + int wsize = qp.x() + 22; // sb->width(); resize(wsize, 400); } @@ -67,7 +67,7 @@ { auto* button = (QPushButton*)sender(); QString name(button->text()); - //printf("CLICKED: %s\n", name.toUtf8().constData()); + // printf("CLICKED: %s\n", name.toUtf8().constData()); request* r = empty_request("START"); set_value(r, "NAME", "%s", name.toUtf8().constData()); @@ -80,10 +80,10 @@ { QApplication qapp(argc, argv); // TODO: use MvQTheme here! - //QApplication::setWindowIcon(QIcon(MvQTheme::logo())); + // QApplication::setWindowIcon(QIcon(MvQTheme::logo())); - //Get qt style + // Get qt style char* styleCh = getenv("METVIEW_QT_STYLE"); if (styleCh) { QString style(styleCh); @@ -94,7 +94,7 @@ } } - marsinit(&argc, argv, 0, 0, 0); + marsinit(&argc, argv, nullptr, 0, nullptr); svc* s = create_service(mbasename(argv[0])); if (s) diff -Nru metview-5.17.4/metview/src/DebugTools/XServ.h metview-5.19.2/metview/src/DebugTools/XServ.h --- metview-5.17.4/metview/src/DebugTools/XServ.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/DebugTools/XServ.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ public: XServBar(svc* s); - ~XServBar() = default; + ~XServBar() override = default; public slots: diff -Nru metview-5.17.4/metview/src/Desktop/ActionCommand.cc metview-5.19.2/metview/src/Desktop/ActionCommand.cc --- metview-5.17.4/metview/src/Desktop/ActionCommand.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ActionCommand.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ void ActionCommand::execute(IconObject* o) { - o->action(name_); + o->action(name()); } @@ -31,6 +31,7 @@ static ActionCommand executeCmd("execute"); static ActionCommand analyseCmd("analyse"); static ActionCommand extractCmd("extract"); +static ActionCommand extractSubfolderCmd("extract_subfolder"); static ActionCommand exportMacroCmd("export_macro"); static ActionCommand exportPythonCmd("export_python"); static ActionCommand metzoomCmd("metzoom"); diff -Nru metview-5.17.4/metview/src/Desktop/ActionCommand.h metview-5.19.2/metview/src/Desktop/ActionCommand.h --- metview-5.17.4/metview/src/Desktop/ActionCommand.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ActionCommand.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,13 +15,10 @@ { public: ActionCommand(const std::string& name); - virtual ~ActionCommand(); + ~ActionCommand() override; + ActionCommand(const ActionCommand&) = delete; + ActionCommand& operator=(const ActionCommand&) = delete; - virtual void execute(IconObject*); + void execute(IconObject*) override; static void execute(const std::string&, IconObject*); - -private: - // No copy allowed - ActionCommand(const ActionCommand&); - ActionCommand& operator=(const ActionCommand&); }; diff -Nru metview-5.17.4/metview/src/Desktop/CMakeLists.txt metview-5.19.2/metview/src/Desktop/CMakeLists.txt --- metview-5.17.4/metview/src/Desktop/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -1,4 +1,5 @@ -set(desktop_qt_wrap_files +set(desktop_qt_wrap_files + FilePropertyDialog.h MvQAdvancedSearch.h MvQBookmarks.h MvQEditor.h @@ -68,6 +69,7 @@ set(desktop_ui_srcs + FilePropertyDialog.ui PreviewPanel.ui ) @@ -138,6 +140,7 @@ MvQIconObjectModel.cc MvQIconProvider.cc MvQIconStripView.cc + MvQLineStyleLine.cc MvQListHelp.cc MvQListFolderViewBase.cc MvQLogDialog.cc @@ -180,6 +183,7 @@ FamilyObject.cc FamilyScanner.cc FileObject.cc + FilePropertyDialog.cc Folder.cc FolderDatabase.cc FolderInfo.cc diff -Nru metview-5.17.4/metview/src/Desktop/Command.cc metview-5.19.2/metview/src/Desktop/Command.cc --- metview-5.17.4/metview/src/Desktop/Command.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Command.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ { auto j = actions->find(name); if (j == actions->end()) - //Log::error(p) << name << ": action not found" << std::endl; + // Log::error(p) << name << ": action not found" << std::endl; std::cout << name << ": action not found" << std::endl; else (*j).second->execute(p); diff -Nru metview-5.17.4/metview/src/Desktop/Command.h metview-5.19.2/metview/src/Desktop/Command.h --- metview-5.17.4/metview/src/Desktop/Command.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Command.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,16 +18,14 @@ public: Command(const std::string& name); virtual ~Command(); + Command(const Command&) = delete; + Command& operator=(const Command&) = delete; + const std::string& name() const { return name_; } virtual void execute(IconObject*) = 0; static void execute(const std::string&, IconObject*); static bool isValid(const std::string&); -protected: - std::string name_; - private: - // No copy allowed - Command(const Command&); - Command& operator=(const Command&); + std::string name_; }; diff -Nru metview-5.17.4/metview/src/Desktop/ComputeEditor.cc metview-5.19.2/metview/src/Desktop/ComputeEditor.cc --- metview-5.17.4/metview/src/Desktop/ComputeEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ComputeEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,10 +28,10 @@ centralLayout_->addWidget(te_, 0); centralLayout_->addStretch(1); - //std::vector classes; - //classes.push_back(kind.name()); + // std::vector classes; + // classes.push_back(kind.name()); - //connect(w,SIGNAL(iconDropped(IconObject*)), + // connect(w,SIGNAL(iconDropped(IconObject*)), // this,SLOT(slotIconDropped(IconObject*))); connect(te_, SIGNAL(textChanged()), @@ -49,7 +49,7 @@ void ComputeEditor::reset() { - Request r = current_->request(); + Request r = current_->request(); const char* f = r("FORMULA"); QString str; @@ -58,7 +58,7 @@ te_->setText(str); - //modified_ = false; + // modified_ = false; } void ComputeEditor::close() @@ -70,26 +70,26 @@ { /*XMText text(text_); - string s = current_->relativeName(o); - bool quote = false; + string s = current_->relativeName(o); + bool quote = false; - //for(string::iterator i = s.begin(); i != s.end(); ++i) - for(int it=0; it dead_; - virtual void run(); + void run() override; }; void CountedGC::push(Counted* c) @@ -47,12 +47,6 @@ } } - -Counted::Counted() : - count_(0) -{ -} - Counted::~Counted() = default; void Counted::attach() diff -Nru metview-5.17.4/metview/src/Desktop/Counted.h metview-5.19.2/metview/src/Desktop/Counted.h --- metview-5.17.4/metview/src/Desktop/Counted.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Counted.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,21 +15,19 @@ class Counted { public: - Counted(); - + Counted() = default; + virtual ~Counted(); // Change to virtual if base class + Counted(const Counted&) = delete; + Counted& operator=(const Counted&) = delete; void attach(); void detach(); int count() { return count_; } protected: - virtual ~Counted(); // Change to virtual if base class virtual void print(std::ostream&) const; // Change to virtual if base class private: - Counted(const Counted&); - Counted& operator=(const Counted&); - - int count_; + int count_{0}; friend std::ostream& operator<<(std::ostream& s, const Counted& p) { @@ -44,10 +42,10 @@ template class Handle { - T* ptr_; + T* ptr_{nullptr}; public: - Handle(T* ptr = 0) : + Handle(T* ptr = nullptr) : ptr_(ptr) { if (ptr_) @@ -69,7 +67,7 @@ Handle& operator=(const Handle& other) { - if (ptr_ != other.ptr_) { + if (this != &other && ptr_ != other.ptr_) { if (ptr_) ptr_->detach(); ptr_ = other.ptr_; diff -Nru metview-5.17.4/metview/src/Desktop/Dependancy.h metview-5.19.2/metview/src/Desktop/Dependancy.h --- metview-5.17.4/metview/src/Desktop/Dependancy.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Dependancy.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,9 @@ { public: Dependancy(); - virtual ~Dependancy(); + ~Dependancy() override; - virtual Task* action(const Action&) = 0; + virtual Task* action(const Action&) = 0; virtual void success(const Request&) = 0; virtual void failure(const Request&) = 0; }; @@ -30,6 +30,6 @@ class DependancyH : public Handle { public: - DependancyH(Dependancy* o = 0) : + DependancyH(Dependancy* o = nullptr) : Handle(o) {} }; diff -Nru metview-5.17.4/metview/src/Desktop/Drop.cc metview-5.19.2/metview/src/Desktop/Drop.cc --- metview-5.17.4/metview/src/Desktop/Drop.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Drop.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,8 @@ { for (auto icon : icons) { IconObjectH o = icon; - requests_[o] = o->request(); - Task* t = o->action(Action("prepare", "*")); + requests_[o] = o->request(); + Task* t = o->action(Action("prepare", "*")); if (t) { tasks_[t] = o; @@ -48,7 +48,7 @@ void Drop::success(Task* t, const Request& r) { IconObjectH o = tasks_[t]; - requests_[o] = r; + requests_[o] = r; waiting_--; check(); } @@ -56,7 +56,7 @@ void Drop::failure(Task* t, const Request& r) { IconObjectH o = tasks_[t]; - requests_[o] = r; + requests_[o] = r; error_ = true; waiting_--; @@ -70,11 +70,11 @@ if (!error_) { // Request should be sorted - const char* null = 0; + const char* null = nullptr; std::map > m; for (auto& request : requests_) { - Request r = request.second; + Request r = request.second; IconObject* o = request.first; if (r && r.getVerb()) { int priority = IconClass::find(r.getVerb()).priority(); @@ -95,16 +95,16 @@ req = r; } - request_ = request_ + req; + request_ = request_ + req; request_("_MODE") = mode_; - MvApplication::callService(service_.c_str(), request_, 0); + MvApplication::callService(service_.c_str(), request_, nullptr); } else { - auto it = requests_.begin(); + auto it = requests_.begin(); request_ = (*it).second; - MvApplication::callService(service_.c_str(), request_, 0); + MvApplication::callService(service_.c_str(), request_, nullptr); } this->deleteLater(); diff -Nru metview-5.17.4/metview/src/Desktop/Drop.h metview-5.19.2/metview/src/Desktop/Drop.h --- metview-5.17.4/metview/src/Desktop/Drop.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Drop.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,8 @@ class Drop : public QObject, public TaskObserver { public: - Drop(const std::set&, const Request&, const std::string&, const Request&, QObject* obj = 0); - virtual ~Drop(); + Drop(const std::set&, const Request&, const std::string&, const Request&, QObject* obj = nullptr); + ~Drop() override; void start(); @@ -35,8 +35,8 @@ Drop& operator=(const Drop&); void check(); - virtual void success(Task*, const Request&); - virtual void failure(Task*, const Request&); + void success(Task*, const Request&) override; + void failure(Task*, const Request&) override; Request request_; std::string service_; diff -Nru metview-5.17.4/metview/src/Desktop/Editor.cc metview-5.19.2/metview/src/Desktop/Editor.cc --- metview-5.17.4/metview/src/Desktop/Editor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Editor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -37,7 +37,7 @@ if (e) { e->edit(icon); - //add to the open editor's list menu + // add to the open editor's list menu MvQEditorListMenu::add(e); } } @@ -56,7 +56,7 @@ { if (icon != current_) { temporary_ = false; - current_ = icon; + current_ = icon; if (current_) { current_->editor(this); edit(); @@ -80,7 +80,7 @@ current_ = nullptr; temporary_ = false; - //remove from the open editor's list menu + // remove from the open editor's list menu MvQEditorListMenu::remove(this); } diff -Nru metview-5.17.4/metview/src/Desktop/EditorDrawerFactory.h metview-5.19.2/metview/src/Desktop/EditorDrawerFactory.h --- metview-5.17.4/metview/src/Desktop/EditorDrawerFactory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/EditorDrawerFactory.h 2023-07-15 08:28:47.000000000 +0000 @@ -12,7 +12,7 @@ #include #include -//UKMO/HP/aCC: +// UKMO/HP/aCC: #ifdef hp #include #endif @@ -38,7 +38,7 @@ template class EditorDrawerMaker : public EditorDrawerFactory { - EditorDrawer* make(MvQEditor* e) + EditorDrawer* make(MvQEditor* e) override { E* a = dynamic_cast(e); return a ? new T(a) : 0; diff -Nru metview-5.17.4/metview/src/Desktop/EditorDrawer.h metview-5.19.2/metview/src/Desktop/EditorDrawer.h --- metview-5.17.4/metview/src/Desktop/EditorDrawer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/EditorDrawer.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ EditorDrawer(MvQEditor* editor) : editor_(editor) {} - virtual QString name() = 0; + virtual QString name() = 0; virtual QWidget* widget() = 0; protected: diff -Nru metview-5.17.4/metview/src/Desktop/EditorFactory.cc metview-5.19.2/metview/src/Desktop/EditorFactory.cc --- metview-5.17.4/metview/src/Desktop/EditorFactory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/EditorFactory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,12 +15,12 @@ using Map = std::multimap, Editor*>; static Map editors; -static std::map* makers = 0; +static std::map* makers = nullptr; EditorFactory::EditorFactory(const std::string& name) : name_(name) { - if (makers == 0) + if (makers == nullptr) makers = new std::map; (*makers)[name] = this; @@ -35,38 +35,38 @@ Editor* EditorFactory::find(const IconClass& c, const std::string& type) { - //Cleaning + // Cleaning /*for(Map::iterator it = editors.begin(); it != editors.end(); ) - { - if(it->second->current() == 0) - { - std::cout << "Editor deleted: " << it->first.first << " " << it->first.second << std::endl; - - delete it->second; - editors.erase(it++); - } - else - { - ++it; - } - }*/ + { + if(it->second->current() == 0) + { + std::cout << "Editor deleted: " << it->first.first << " " << it->first.second << std::endl; - //Find or create + delete it->second; + editors.erase(it++); + } + else + { + ++it; + } + }*/ + + // Find or create std::pair name(c.name(), type); - Editor* e = 0; + Editor* e = nullptr; std::pair p = editors.equal_range(name); for (auto j = p.first; j != p.second; ++j) { Editor* editor = (*j).second; std::pair n(editor->iconClass().name(), editor->kind()); - if (name == n && editor->current() == 0) { + if (name == n && editor->current() == nullptr) { e = editor; break; } } - if (e == 0) { + if (e == nullptr) { auto j = makers->find(type); if (j == makers->end()) { e = new NoEditor(c, "NoEditor"); diff -Nru metview-5.17.4/metview/src/Desktop/EditorFactory.h metview-5.19.2/metview/src/Desktop/EditorFactory.h --- metview-5.17.4/metview/src/Desktop/EditorFactory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/EditorFactory.h 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ template class EditorMaker : public EditorFactory { - Editor* make(const IconClass& n) { return new T(n, name_); } + Editor* make(const IconClass& n) override { return new T(n, name_); } public: EditorMaker(const std::string& name) : diff -Nru metview-5.17.4/metview/src/Desktop/Editor.h metview-5.19.2/metview/src/Desktop/Editor.h --- metview-5.17.4/metview/src/Desktop/Editor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Editor.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ class Editor : public IconObserver { public: - virtual ~Editor(); + ~Editor() override; const IconClass& iconClass(); const std::string& kind(); @@ -56,7 +56,7 @@ IconObjectH current_; bool temporary_; - virtual void edit() = 0; + virtual void edit() = 0; virtual void showIt() = 0; private: diff -Nru metview-5.17.4/metview/src/Desktop/EditorObserver.h metview-5.19.2/metview/src/Desktop/EditorObserver.h --- metview-5.17.4/metview/src/Desktop/EditorObserver.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/EditorObserver.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,6 +14,7 @@ class EditorObserver { public: + virtual ~EditorObserver() = default; virtual void apply(IconObject*) = 0; virtual void close(IconObject*) = 0; }; diff -Nru metview-5.17.4/metview/src/Desktop/EditTransaction.cc metview-5.19.2/metview/src/Desktop/EditTransaction.cc --- metview-5.17.4/metview/src/Desktop/EditTransaction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/EditTransaction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,7 @@ ***************************** LICENSE END *************************************/ -#include +#include #include "Metview.h" #include "EditTransaction.h" @@ -31,11 +31,6 @@ { } -EditTransaction::~EditTransaction() -{ - //delete subClass_; -} - EditTransaction::EditTransaction(MvTransaction* t) : Transaction(t) { @@ -71,7 +66,7 @@ void EditTransaction::callback(MvRequest& r) { - current_ = 0; + current_ = nullptr; std::cout << "CALLBACK" << std::endl; r.print(); @@ -84,7 +79,7 @@ if (name) { if ((const char*)def("_DEFAULT")) { const IconClass& kind = IconClass::find(def.getVerb()); - current_ = kind.defaultObject(); + current_ = kind.defaultObject(); } else { current_ = IconObject::search(name); @@ -98,7 +93,7 @@ f->scan(); if (IconObject* o = f->find(uplotDir)) { assert(o->isFolder()); - auto* uf = static_cast(o); + auto* uf = dynamic_cast(o); assert(uf); uf->scan(); current_ = IconObject::search(name); diff -Nru metview-5.17.4/metview/src/Desktop/EditTransaction.h metview-5.19.2/metview/src/Desktop/EditTransaction.h --- metview-5.17.4/metview/src/Desktop/EditTransaction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/EditTransaction.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,32 +18,28 @@ public EditorObserver, public TaskObserver { - IconObjectH current_; - - virtual MvTransaction* cloneSelf(); - virtual void callback(MvRequest&); - virtual void apply(IconObject*); - virtual void close(IconObject*); - public: EditTransaction(); EditTransaction(MvTransaction* t); - ~EditTransaction(); + ~EditTransaction() override = default; + EditTransaction(const EditTransaction&) = delete; + EditTransaction& operator=(const EditTransaction&) = delete; private: - // No copy allowed - EditTransaction(const EditTransaction&); - EditTransaction& operator=(const EditTransaction&); + MvTransaction* cloneSelf() override; + void callback(MvRequest&) override; + void apply(IconObject*) override; + void close(IconObject*) override; + void success(Task*, const Request&) override; + void failure(Task*, const Request&) override; + IconObjectH current_; IconClass* subClass_{nullptr}; - - virtual void success(Task*, const Request&); - virtual void failure(Task*, const Request&); }; inline void destroy(EditTransaction**) {} // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(EditTransaction); +// OS_MARK_SCHEMA_TYPE(EditTransaction); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/FamilyEditor.cc metview-5.19.2/metview/src/Desktop/FamilyEditor.cc --- metview-5.17.4/metview/src/Desktop/FamilyEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FamilyEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -48,22 +48,20 @@ hb->addLayout(comboLayout_); hb->addStretch(1); - //pages + // pages page_ = new QStackedWidget(this); centralLayout_->addWidget(page_); Request r(name.name().c_str()); makePages(0, r); - //Now we have all the combos defined we cand add signals-slots. + // Now we have all the combos defined we cand add signals-slots. foreach (QComboBox* cb, combos_) { connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChangePage(int))); } } -FamilyEditor::~FamilyEditor() = default; - void FamilyEditor::setStartPage() { if (!current_) @@ -101,8 +99,8 @@ r(paramName.c_str()) = v[i].c_str(); if (combos_.count() < n + 1) { - int row = combos_.count(); - auto* lab = new QLabel("" + QString::fromStdString(paramName) + ": ", this); + int row = combos_.count(); + auto* lab = new QLabel("" + QString::fromStdString(paramName) + ": ", this); auto* combo = new QComboBox(this); comboLayout_->addWidget(lab, row, 0); comboLayout_->addWidget(combo, row, 1, Qt::AlignLeft); @@ -116,17 +114,17 @@ combo->addItem(name, QString::fromStdString(v[i])); } - //Last keyword --> we create a panel + // Last keyword --> we create a panel if (n == static_cast(p.size()) - 1) { - Request s = class_.language().expand(r); + Request s = class_.language().expand(r); const char* type = s(scanner_.keyword().c_str()); if (type) { - //Create panel + // Create panel std::vector classes; classes.push_back(class_.name()); - auto* w = new MvQRequestPanelWidget(classes, this); + auto* w = new MvQRequestPanelWidget(classes, this); auto* panel = new RequestPanel(IconClass::find(type), w, this, false, type); panels_.push_back(panel); @@ -147,11 +145,11 @@ IconObject* FamilyEditor::copy(const std::string& /*name*/) { - //IconObject* o = IconFactory::create(name, class_); - //panel_.apply(); - //o->request(panel_.request()); - //return o; - return 0; + // IconObject* o = IconFactory::create(name, class_); + // panel_.apply(); + // o->request(panel_.request()); + // return o; + return nullptr; } @@ -164,16 +162,16 @@ std::map keyVals; keyValues(keyVals); - for (auto it = keyVals.begin(); it != keyVals.end(); it++) { - r(it->first.c_str()) = it->second.c_str(); + for (auto& keyVal : keyVals) { + r(keyVal.first.c_str()) = keyVal.second.c_str(); } int i = page_->currentIndex(); if (i >= 0 && i < static_cast(panels_.size())) { panels_.at(i)->apply(); Request pr = panels_.at(i)->request(); - r = r + panels_.at(i)->request(); - //r.print(); + r = r + panels_.at(i)->request(); + // r.print(); objects_.at(i)->setRequest(pr); } @@ -190,7 +188,7 @@ for (auto& panel : panels_) { const IconClass& kind = panel->iconClass(); - //Create icon object + // Create icon object Request panelReq = current_->requestForVerb(kind.name()); if (!panelReq) @@ -222,26 +220,26 @@ objects_.clear(); } -//Request FamilyEditor::currentRequest(long custom_expand) +// Request FamilyEditor::currentRequest(long custom_expand) //{ -//panel_.apply(); -//return custom_expand ? panel_.request(custom_expand) : panel_.request(); -//} +// panel_.apply(); +// return custom_expand ? panel_.request(custom_expand) : panel_.request(); +// } void FamilyEditor::replace(IconObjectH /*o*/) { - //panel_.replace(o); + // panel_.replace(o); } void FamilyEditor::merge(IconObjectH /*o*/) { - //panel_.merge(o); + // panel_.merge(o); } void FamilyEditor::slotChangePage(int) { - //Works only for two keywords (this is the maximum currently)!!!! + // Works only for two keywords (this is the maximum currently)!!!! int index = 0; if (combos_.count() == 1) { @@ -263,7 +261,7 @@ const std::vector& p = scanner_.params(); for (unsigned int i = 0; i < p.size(); i++) { std::string keyVal = p[i]; - int index = combos_.at(i)->currentIndex(); + int index = combos_.at(i)->currentIndex(); if (index > -1) { keyValues[keyVal] = combos_.at(i)->itemData(index, Qt::UserRole).toString().toStdString(); } diff -Nru metview-5.17.4/metview/src/Desktop/FamilyEditor.h metview-5.19.2/metview/src/Desktop/FamilyEditor.h --- metview-5.17.4/metview/src/Desktop/FamilyEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FamilyEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,45 +31,42 @@ Q_OBJECT public: FamilyEditor(const IconClass&, const std::string&); - virtual ~FamilyEditor(); + ~FamilyEditor() override = default; + FamilyEditor(const FamilyEditor&) = delete; + FamilyEditor& operator=(const FamilyEditor&) = delete; - //Request currentRequest(long custom_expand=0); - - virtual void replace(IconObjectH); - virtual void merge(IconObjectH); + void replace(IconObjectH) override; + void merge(IconObjectH) override; public slots: void slotChangePage(int); void slotIconDropped(IconObject*); protected slots: - void slotFilterItems(QString) {} - void slotShowDisabled(bool) {} + void slotFilterItems(QString) override {} + void slotShowDisabled(bool) override {} protected: - void readSettings(QSettings&) {} - void writeSettings(QSettings&) {} + void readSettings(QSettings&) override {} + void writeSettings(QSettings&) override {} private: - FamilyEditor(const FamilyEditor&); - FamilyEditor& operator=(const FamilyEditor&); - void setStartPage(); void makePages(int, Request& r); void keyValues(std::map&); - virtual void apply(); - virtual void reset(); - virtual void close(); - virtual void edit(); + void apply() override; + void reset() override; + void close() override; + void edit() override; virtual IconObject* copy(const std::string&); FamilyScanner& scanner_; QList combos_; - QGridLayout* comboLayout_; + QGridLayout* comboLayout_{nullptr}; - QStackedWidget* page_; + QStackedWidget* page_{nullptr}; std::vector panels_; std::vector objects_; }; @@ -78,5 +75,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(FamilyEditor); +// OS_MARK_SCHEMA_TYPE(FamilyEditor); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/FamilyObject.cc metview-5.19.2/metview/src/Desktop/FamilyObject.cc --- metview-5.17.4/metview/src/Desktop/FamilyObject.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FamilyObject.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ StandardObject(parent, kind, name, info), scanner_(FamilyScanner::find(kind)) { - //MvLog().info() << MV_FN_INFO << "name=" << name << " kind=" << kind.name() << " class=" << class_->name(); + // MvLog().info() << MV_FN_INFO << "name=" << name << " kind=" << kind.name() << " class=" << class_->name(); } FamilyObject::~FamilyObject() = default; @@ -29,8 +29,8 @@ Request FamilyObject::request() const { - //return language().expand(selected()); - //return first(); + // return language().expand(selected()); + // return first(); return iconClass().language().expand(second()); } @@ -39,7 +39,7 @@ Request r = actRec; Request f; - //If actRec only contains the panel request + // If actRec only contains the panel request if (r.getVerb() != class_->name()) { f = first(); } @@ -50,8 +50,8 @@ f = f + IconClass::find(r.getVerb()).language().expand(r, EXPAND_NO_DEFAULT | EXPAND_2ND_NAME); -// MvLog().info() << MV_FN_INFO << "req="; -// f.print(); + // MvLog().info() << MV_FN_INFO << "req="; + // f.print(); f.save(path()); } @@ -66,7 +66,7 @@ { Request r(path()); if (scanner_.validate(r)) { - //r.print(); + // r.print(); r.save(path()); } r.advance(); @@ -84,7 +84,7 @@ return f; } - return Request(); + return {}; } const IconClass& FamilyObject::editorClass() const @@ -104,7 +104,7 @@ if (!p.exists()) { Request r; if (scanner_.validate(r)) { - //r.print(); + // r.print(); r.save(path()); } } diff -Nru metview-5.17.4/metview/src/Desktop/FamilyObject.h metview-5.19.2/metview/src/Desktop/FamilyObject.h --- metview-5.17.4/metview/src/Desktop/FamilyObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FamilyObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ public: FamilyObject(Folder* parent, const IconClass& kind, const std::string& name, IconInfo* info); - virtual ~FamilyObject(); + ~FamilyObject() override; private: // No copy allowed diff -Nru metview-5.17.4/metview/src/Desktop/FamilyScanner.cc metview-5.19.2/metview/src/Desktop/FamilyScanner.cc --- metview-5.17.4/metview/src/Desktop/FamilyScanner.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FamilyScanner.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,7 +27,7 @@ FamilyScanner::FamilyScanner(const IconClass& kind) : class_(kind) { - //std::cout << "FamilyScanner " << kind.name() << std::endl; + // std::cout << "FamilyScanner " << kind.name() << std::endl; kind.language().scan(*this); keyword_ = kind.language().getInfo(); @@ -41,13 +41,13 @@ void FamilyScanner::next(const MvIconParameter& param) { - params_.push_back(param.name()); + params_.emplace_back(param.name()); param.scan(*this); } const std::vector& FamilyScanner::params() const { - //std::cout << "FamilyScanner parans " << params_.size() << std::endl; + // std::cout << "FamilyScanner parans " << params_.size() << std::endl; return params_; } @@ -87,7 +87,7 @@ EXPAND_2ND_NAME); const char* p = f(keyword_.c_str()); - r = f + Request(p); + r = f + Request(p); return true; } #if 0 diff -Nru metview-5.17.4/metview/src/Desktop/FamilyScanner.h metview-5.19.2/metview/src/Desktop/FamilyScanner.h --- metview-5.17.4/metview/src/Desktop/FamilyScanner.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FamilyScanner.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,14 +19,14 @@ const std::string& keyword() const; bool validate(Request&) const; const std::vector& params() const; - const std::vector& values(const std::string&); //const; - const std::vector& beau(const std::string&); //const; + const std::vector& values(const std::string&); // const; + const std::vector& beau(const std::string&); // const; static FamilyScanner& find(const IconClass&); protected: FamilyScanner(const IconClass&); - virtual ~FamilyScanner(); + ~FamilyScanner() override; private: FamilyScanner(const FamilyScanner&); @@ -40,15 +40,15 @@ std::map > beau_; // From LanguageScanner - virtual void next(const MvIconParameter&); + void next(const MvIconParameter&) override; // From ParameterScanner - virtual void next(const MvIconParameter&, const char*, const char*); + void next(const MvIconParameter&, const char*, const char*) override; }; inline void destroy(FamilyScanner**) {} // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(FamilyScanner); +// OS_MARK_SCHEMA_TYPE(FamilyScanner); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/FileObject.cc metview-5.19.2/metview/src/Desktop/FileObject.cc --- metview-5.17.4/metview/src/Desktop/FileObject.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FileObject.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,6 +7,8 @@ ***************************** LICENSE END *************************************/ +#include + #include "FileObject.h" #include "IconClass.h" #include "IconFactory.h" @@ -20,8 +22,6 @@ { } -FileObject::~FileObject() = default; - void FileObject::doubleClick() { edit(); @@ -29,11 +29,18 @@ std::set FileObject::can() { + static std::set compressedNames = {"TAR_GZ", "TAR_BZ2", "ZIP", "GZ", "BZ2", "Z"}; + if (className() == "NOTE" || className() == "BINARY") { std::set s = IconObject::can(); s.insert("recheck_type"); return s; } + else if (std::find(compressedNames.begin(), compressedNames.end(), className()) != compressedNames.end()) { + std::set s = IconObject::can(); + s.erase("compress"); + return s; + } return IconObject::can(); } @@ -56,59 +63,59 @@ void FileObject::setRequest(const Request& /*r*/) { - //IconObject::request(r); + // IconObject::request(r); } -//Be extremely careful when calling this function!! +// Be extremely careful when calling this function!! bool FileObject::recheckIconClass() { - //Recheck only the NOTE and BINARY icons!!!! The others probably have the correct type!!! + // Recheck only the NOTE and BINARY icons!!!! The others probably have the correct type!!! if (class_->name() == "NOTE" || class_->name() == "BINARY") { - std::string oriClassName = class_->name(); + std::string oriClassName = class_->name(); const IconClass& actClass = IconClass::guess(path().str()); - //We can only change the iconclass if the new class is still a File or Macro so - //we can keep the current FileObject (MacroObject is inherited from FileObject!!) + // We can only change the iconclass if the new class is still a File or Macro so + // we can keep the current FileObject (MacroObject is inherited from FileObject!!) if (actClass.name() != oriClassName && (actClass.type() == "File" || actClass.type() == "Macro")) { class_ = const_cast(&actClass); - //TODO: can info be NULL at all? + // TODO: can info be NULL at all? if (info_) { info_->changeIconClass(class_->name()); } - //we need to check everything that depends on the iconclass or - //stores the current object (and its iconclass!!!) + // we need to check everything that depends on the iconclass or + // stores the current object (and its iconclass!!!) - //Editable file types: - // a) NOTE, MACRO, PYTHON, GEOPOINTS, SQL, KML - // can only be edited in a macroEditor - which is a separate process - // and we cannot communicate to it (at the moment) - // b) SVG - // can be edited in inkscape - external editor as well + // Editable file types: + // a) NOTE, MACRO, PYTHON, GEOPOINTS, SQL, KML + // can only be edited in a macroEditor - which is a separate process + // and we cannot communicate to it (at the moment) + // b) SVG + // can be edited in inkscape - external editor as well if (editor_) { editor_->closeIt(); } - //there cannot be a queue for a NOTE + // there cannot be a queue for a NOTE if (queue_) { } - //there cannot be a log for a NOTE + // there cannot be a log for a NOTE if (log_) { } - //there cannot be a logwindow for a NOTE + // there cannot be a logwindow for a NOTE if (logWindow_) { } - //TODO: check observers + // TODO: check observers if (!observers_.empty()) { } - //No dependancy for a file!!! - //dependancies_ + // No dependancy for a file!!! + // dependancies_ return true; } diff -Nru metview-5.17.4/metview/src/Desktop/FileObject.h metview-5.19.2/metview/src/Desktop/FileObject.h --- metview-5.17.4/metview/src/Desktop/FileObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FileObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,20 +21,19 @@ FileObject(Folder* parent, const IconClass& kind, const std::string& name, IconInfo* info); + FileObject(const FileObject&) = delete; + FileObject& operator=(const FileObject&) = delete; - virtual ~FileObject(); + ~FileObject() override = default; protected: bool recheckIconClass() override; private: - FileObject(const FileObject&); - FileObject& operator=(const FileObject&); - void doubleClick() override; - virtual std::set can() override; + std::set can() override; - virtual void createFiles() override; + void createFiles() override; Request request() const override; void setRequest(const Request&) override; }; @@ -43,5 +42,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(FileObject); +// OS_MARK_SCHEMA_TYPE(FileObject); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/FilePropertyDialog.cc metview-5.19.2/metview/src/Desktop/FilePropertyDialog.cc --- metview-5.17.4/metview/src/Desktop/FilePropertyDialog.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FilePropertyDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,98 @@ +/***************************** LICENSE START *********************************** + + Copyright 2022 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + +#include "FilePropertyDialog.h" + +#include +#include + +#include "IconDescription.h" +#include "IconObject.h" +#include "MvQIconProvider.h" +#include "MvQMethods.h" +#include "MvQTheme.h" +#include "MvQStreamOper.h" +#include "MvLog.h" +#include "Path.h" + +#include "ui_FilePropertyDialog.h" + + +FilePropertyDialog::FilePropertyDialog(QWidget* parent) : + QDialog(parent), + ui_(new Ui::FilePropertyDialog) +{ + ui_->setupUi(this); + readSettings(); +} + +FilePropertyDialog::~FilePropertyDialog() +{ + writeSettings(); +} + +void FilePropertyDialog::setItem(IconObject* item) +{ + path_.clear(); + linkPath_.clear(); + if (item) { + ui_->iconLabel->setPixmap(MvQIconProvider::pixmap(item, 32)); + path_ = item->path().str(); + auto txt = IconDescription::Instance()->table(item, true); + if (item->isLink()) { + linkPath_ = item->path().symlinkTarget(); + ui_->linkEdit->setText(QString::fromStdString(linkPath_)); + txt += "
"; + } + else { + ui_->linkLabel->hide(); + ui_->linkEdit->hide(); + } + ui_->infoLabel->setText(txt); + } +} + +void FilePropertyDialog::accept() +{ + if (!linkPath_.empty()) { + Path p(path_); + p.changeSymlink(Path(ui_->linkEdit->text().toStdString())); + if (auto obj = IconObject::search(path_)) { + obj->updateStateInfo(); + } + } + QDialog::accept(); +} + +void FilePropertyDialog::writeSettings() +{ + QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "Desktop-FilePropertyDialog"); + + // We have to clear it not to remember all the previous windows + settings.clear(); + + settings.beginGroup("main"); + settings.setValue("size", size()); + settings.endGroup(); +} + +void FilePropertyDialog::readSettings() +{ + QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "Desktop-FilePropertyDialog"); + + settings.beginGroup("main"); + if (settings.contains("size")) { + resize(settings.value("size").toSize()); + } + else { + resize(QSize(400, 380)); + } + + settings.endGroup(); +} diff -Nru metview-5.17.4/metview/src/Desktop/FilePropertyDialog.h metview-5.19.2/metview/src/Desktop/FilePropertyDialog.h --- metview-5.17.4/metview/src/Desktop/FilePropertyDialog.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FilePropertyDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,39 @@ +/***************************** LICENSE START *********************************** + + Copyright 2022 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + +#pragma once + +#include + +class IconObject; + +namespace Ui +{ +class FilePropertyDialog; +} + +class FilePropertyDialog : public QDialog +{ + Q_OBJECT +public: + FilePropertyDialog(QWidget* parent = nullptr); + ~FilePropertyDialog() override; + void setItem(IconObject* item); + +public slots: + void accept() override; + +private: + void writeSettings(); + void readSettings(); + + Ui::FilePropertyDialog* ui_{nullptr}; + std::string path_; + std::string linkPath_; +}; diff -Nru metview-5.17.4/metview/src/Desktop/FilePropertyDialog.ui metview-5.19.2/metview/src/Desktop/FilePropertyDialog.ui --- metview-5.17.4/metview/src/Desktop/FilePropertyDialog.ui 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FilePropertyDialog.ui 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,108 @@ + + + FilePropertyDialog + + + + 0 + 0 + 482 + 292 + + + + Properties + + + + + + TextLabel + + + + + + + TextLabel + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + Symlink: + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + FilePropertyDialog + accept() + + + 240 + 271 + + + 240 + 145 + + + + + buttonBox + rejected() + FilePropertyDialog + reject() + + + 240 + 271 + + + 240 + 145 + + + + + diff -Nru metview-5.17.4/metview/src/Desktop/Folder.cc metview-5.19.2/metview/src/Desktop/Folder.cc --- metview-5.17.4/metview/src/Desktop/Folder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Folder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,16 +26,16 @@ std::vector Folder::folders_; const unsigned int Folder::maxNokidsNum_ = 100; -//Path stores the full path aka fullName -//Name stores the directory name +// Path stores the full path aka fullName +// Name stores the directory name Folder::Folder(Folder* p, const IconClass& kind, const std::string& name, IconInfo* info) : IconObject(p, kind, name, info), ready_(false), scanIsOn_(false), - folderInfo_(0), - settings_(0) + folderInfo_(nullptr), + settings_(nullptr) { } @@ -86,9 +86,9 @@ if (o) { if (!observers_.insert(o).second) return; - //if(!ready_) + // if(!ready_) // scan(); - //else + // else // for(KidMap::iterator j = kids_.begin(); j != kids_.end(); ++j) // o->arrived((*j).second); } @@ -102,10 +102,10 @@ IconObject* Folder::create(const std::string& name) { IconObject* obj = find(name); - if (obj == 0) { + if (obj == nullptr) { if (noKids_.find(name) == noKids_.end()) { obj = IconFactory::create(this, name); - if (obj == 0) { + if (obj == nullptr) { noKids_.insert(name); } } @@ -131,7 +131,7 @@ std::vector rest(names.begin() + 1, names.end()); IconObject* s = find(names[0]); - return s ? s->findMulti(rest) : 0; + return s ? s->findMulti(rest) : nullptr; } IconObject* Folder::find(const std::string& name) @@ -141,7 +141,7 @@ auto j = kids_.find(name); if (j == kids_.end()) - return 0; + return nullptr; else return (*j).second; } @@ -168,34 +168,34 @@ /*string Folder::fullName() const { - return path_.str(); -} + return path_.str(); +} Path Folder::path() const { - return path_; + return path_; }*/ void Folder::scan() { - ready_ = true; + ready_ = true; scanIsOn_ = true; - //cout << "Scan for: " << fullName() << std::endl; + // cout << "Scan for: " << fullName() << std::endl; std::set files = path().files(); - //Create and iconObject for each file/dir with the exception of the - //dirs ending with a # character. + // Create and iconObject for each file/dir with the exception of the + // dirs ending with a # character. for (const auto& file : files) { - //if((*i).rfind("#") != (*i).size()-1) + // if((*i).rfind("#") != (*i).size()-1) //{ create(file); //} } - //Remove non-existing icons + // Remove non-existing icons std::vector erase; @@ -209,7 +209,7 @@ saveFolderInfo(); scanIsOn_ = false; - //Clear nokids if they overgrew + // Clear nokids if they overgrew if (noKids_.size() > maxNokidsNum_) noKids_.clear(); } @@ -217,11 +217,11 @@ void Folder::scanForNewFile(const std::string& name, int x, int y) { - ready_ = true; + ready_ = true; scanIsOn_ = true; IconObject* obj = find(name); - if (obj == 0) { + if (obj == nullptr) { IconFactory::create(this, name, x, y); } @@ -330,7 +330,7 @@ bool Folder::adopt(IconObject* o) { - if (find(o->name()) != 0) { + if (find(o->name()) != nullptr) { // Log::error(o) << "Icon already exists" << std::endl; return false; } @@ -362,7 +362,7 @@ if (!scanIsOn_) saveFolderInfo(); - //If we have not scanned the folder yet we nned to do it now! + // If we have not scanned the folder yet we nned to do it now! if (!ready_) { scan(); } @@ -372,7 +372,7 @@ bool Folder::release(IconObject* o) { - if (find(o->name()) == 0) { + if (find(o->name()) == nullptr) { // Error("icon does not exist exists"); return false; } @@ -426,7 +426,7 @@ std::string fSuffix; p.nameAndSuffix(fName, fSuffix); - //For macro we want to keep the suffix + // For macro we want to keep the suffix if (fSuffix == "mv") { do { sprintf(buf, "%s_%d.%s", fName.c_str(), ++i, fSuffix.c_str()); @@ -697,16 +697,26 @@ std::set c = IconObject::can(); c.erase("edit"); c.erase("log"); - c.insert("open"); - c.insert("openInTab"); - c.insert("openInWin"); - c.insert("bookmark"); + c.erase("compress"); + if (!isBrokenLink()) { + c.insert("open"); + c.insert("openInTab"); + c.insert("openInWin"); + c.insert("bookmark"); + } + else { + c.erase("open"); + c.erase("openInTab"); + c.erase("openInWin"); + c.erase("bookmark"); + } + return c; } Request Folder::request() const { - return Request(""); + return {""}; } //======================================================== @@ -724,103 +734,103 @@ Folder* Folder::folder(const std::string& name, bool create) { - Folder* f; + Folder* f = nullptr; if (name == "/") return top(); switch (name[0]) { case 0: - return 0; - //return top(); - //break; + return nullptr; + // return top(); + // break; case '/': f = dynamic_cast(IconObject::search(name)); - if (f == 0 && create) + if (f == nullptr && create) f = dynamic_cast(IconFactory::create(name, IconClass::find("FOLDER"))); return f; - //break; + // break; default: return dynamic_cast(Items::find(name)); - //break; + // break; } } -/* -Folder* Folder::folder(const std::string&path,bool create) +/* +Folder* Folder::folder(const std::string&path,bool create) { if(path.empty()) return 0; - - if(path.find("/") !=std::string::npos) - { - for(vector::iterator it=Folder::folders_.begin(); it != Folder::folders_.end(); it++) - { - if((*it)->path().str() == path) - { - return *it; - } - } - - if(create) - { - IconObject* obj = IconFactory::create(0,path,IconClass::find("FOLDER")); - if(obj) - { - return static_cast(obj); - } - } - } - else - { - return static_cast(Items::find(path)); - } - - return 0; + + if(path.find("/") !=std::string::npos) + { + for(vector::iterator it=Folder::folders_.begin(); it != Folder::folders_.end(); it++) + { + if((*it)->path().str() == path) + { + return *it; + } + } + + if(create) + { + IconObject* obj = IconFactory::create(0,path,IconClass::find("FOLDER")); + if(obj) + { + return static_cast(obj); + } + } + } + else + { + return static_cast(Items::find(path)); + } + + return 0; }*/ Folder* Folder::folder(const std::string& name1, const string& name2, bool create) { Folder* f = folder(name1, create); - return f ? folder(f->fullName() + "/" + name2, create) : 0; + return f ? folder(f->fullName() + "/" + name2, create) : nullptr; } Folder* Folder::folder(const std::string& name1, const string& name2, const std::string& name3, bool /*create*/) { Folder* f = folder(name1, name2); - return f ? folder(f->fullName() + "/" + name3) : 0; + return f ? folder(f->fullName() + "/" + name3) : nullptr; } IconObject* Folder::icon(const std::string& /*fullName*/) { /*Path p(fullName); - Folder *f=Folder::folder(p.directory().str()); - - IconObject *obj=0; - - if(f) - { - obj=f->find(p.name()); - if(!obj) - { - f->scan(); - obj=f->find(p.name()); - } - } - - else - { - obj=IconFactory::create(p.directory().str(),IconClass::find("FOLDER")); - if(obj) - { - f=static_cast(obj); - obj=f->find(p.name()); - } - } - - return obj;*/ - return 0; + Folder *f=Folder::folder(p.directory().str()); + + IconObject *obj=0; + + if(f) + { + obj=f->find(p.name()); + if(!obj) + { + f->scan(); + obj=f->find(p.name()); + } + } + + else + { + obj=IconFactory::create(p.directory().str(),IconClass::find("FOLDER")); + if(obj) + { + f=static_cast(obj); + obj=f->find(p.name()); + } + } + + return obj;*/ + return nullptr; } static IconMaker maker1("FOLDER"); diff -Nru metview-5.17.4/metview/src/Desktop/FolderDatabase.cc metview-5.19.2/metview/src/Desktop/FolderDatabase.cc --- metview-5.17.4/metview/src/Desktop/FolderDatabase.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderDatabase.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ FolderDatabase::FolderDatabase() { - //Home + // Home char* mvhome = getenv("METVIEW_USER_DIRECTORY"); if (!mvhome) { return; @@ -37,7 +37,7 @@ exit(1); } - //homePath_=Folder::path(Folder::HomeFolder); + // homePath_=Folder::path(Folder::HomeFolder); homePath_ = std::string(mvhome); rootPath_ = homePath_ + "/System/.icon_database"; @@ -54,7 +54,7 @@ return; std::string line; - //getline(in,line); + // getline(in,line); Tokenizer parse(","); std::vector n; @@ -99,8 +99,7 @@ return p; } } - - return std::string(); + return {}; } std::string FolderDatabase::find(const std::string& name) @@ -109,8 +108,7 @@ if (it != folders_.end()) { return dbPath_ + "/" + it->second; } - - return std::string(); + return {}; } @@ -128,15 +126,13 @@ std::cout << " db error"; } - return std::string(); + return {}; } std::string FolderDatabase::uniquePath() { int id = 0; - std::map::const_iterator it; - while (id < 100000) { std::stringstream sst; sst << id; @@ -157,7 +153,7 @@ id++; } - return std::string(); + return {}; } //=========================================== @@ -169,26 +165,26 @@ InternalFolderDatabase::InternalFolderDatabase() { - dbPath_ = rootPath_ + "/internal"; - dbFile_ = dbPath_ + "/folders"; + setDbPath(rootPath() + "/internal"); + setDbFile(dbPath() + "/folders"); read(); } bool InternalFolderDatabase::isOwner(const std::string& name) { - return (name.find(homePath_) == 0) ? true : false; + return (name.find(homePath()) == 0) ? true : false; } ExternalFolderDatabase::ExternalFolderDatabase() { - dbPath_ = rootPath_ + "/external"; - dbFile_ = dbPath_ + "/folders"; + setDbPath(rootPath() + "/external"); + setDbFile(dbPath() + "/folders"); read(); } bool ExternalFolderDatabase::isOwner(const std::string& name) { - return (name.find(homePath_) != 0) ? true : false; + return (name.find(homePath()) != 0) ? true : false; } diff -Nru metview-5.17.4/metview/src/Desktop/FolderDatabase.h metview-5.19.2/metview/src/Desktop/FolderDatabase.h --- metview-5.17.4/metview/src/Desktop/FolderDatabase.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderDatabase.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,6 +17,7 @@ class FolderDatabase { public: + virtual ~FolderDatabase() = default; static std::string path(const std::string&); protected: @@ -28,7 +29,13 @@ std::string add(const std::string&); std::string uniquePath(); virtual bool isOwner(const std::string&) = 0; + const std::string& homePath() const { return homePath_; } + const std::string& rootPath() const { return rootPath_; } + const std::string& dbPath() const { return dbPath_; } + void setDbPath(const std::string& p) { dbPath_ = p; } + void setDbFile(const std::string& f) { dbFile_ = f; } +private: std::string homePath_; std::string rootPath_; std::string dbPath_; @@ -42,12 +49,12 @@ { public: InternalFolderDatabase(); - bool isOwner(const std::string&); + bool isOwner(const std::string&) override; }; class ExternalFolderDatabase : public FolderDatabase { public: ExternalFolderDatabase(); - bool isOwner(const std::string&); + bool isOwner(const std::string&) override; }; diff -Nru metview-5.17.4/metview/src/Desktop/Folder.h metview-5.19.2/metview/src/Desktop/Folder.h --- metview-5.17.4/metview/src/Desktop/Folder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Folder.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ Folder(Folder*, const IconClass& kind, const std::string& name, IconInfo* info); - virtual ~Folder(); + ~Folder() override; IconObject* findMulti(const std::vector&) override; IconObject* find(const std::string&) override; @@ -37,7 +37,7 @@ virtual bool adopt(IconObject*); virtual bool release(IconObject*); - //virtual void visit(FolderVisitor&); + // virtual void visit(FolderVisitor&); void addObserver(FolderObserver*); void removeObserver(FolderObserver*); @@ -47,26 +47,26 @@ void position(IconObject*, int x, int y); void renamed(IconObject*, const std::string&, const std::string&); - //virtual void empty(); + // virtual void empty(); void destroy() override; void scan(); void scanForNewFile(const std::string&, int x = 0, int y = 0); void recheckKidsIconClass(); void recheckKidIconClass(IconObject*); - //void copyContent(Folder*); - //virtual void drop(IconObject*); + // void copyContent(Folder*); + // virtual void drop(IconObject*); - typedef void (FolderObserver::*TellObserverProc)(IconObject*); + using TellObserverProc = void (FolderObserver::*)(IconObject*); void tellObservers(TellObserverProc, IconObject*); - //void open(); - //void close(); + // void open(); + // void close(); virtual bool ancestor(IconObject*); virtual bool descendant(Folder*); - //virtual bool sameAs(IconObject*); - //virtual void notifyChanged(); + // virtual bool sameAs(IconObject*); + // virtual void notifyChanged(); int numOfIconKids(); const std::map& kids() const { return kids_; } @@ -89,7 +89,7 @@ protected: std::set can() override; - typedef std::map KidMap; + using KidMap = std::map; KidMap kids_; std::set noKids_; @@ -113,7 +113,7 @@ // -- Overridden methods // From IconObject - //virtual void edit(); + // virtual void edit(); }; class FolderH : public Handle diff -Nru metview-5.17.4/metview/src/Desktop/FolderInfo.cc metview-5.19.2/metview/src/Desktop/FolderInfo.cc --- metview-5.17.4/metview/src/Desktop/FolderInfo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderInfo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ void FolderInfo::read() { - info_.clear(); //need to delete the objects!!! + info_.clear(); // need to delete the objects!!! std::string path = folder_->path().add(fileName_).str(); std::ifstream in(path.c_str()); @@ -47,12 +47,12 @@ Tokenizer parse(","); std::vector n; int cnt = 0; - std::size_t pos; + std::size_t pos = 0; while (getline(in, line)) { parse(line, n); if (n.size() >= 4) { - int x, y; + int x = 0, y = 0; std::istringstream issX(n[0]); issX >> x; std::istringstream issY(n[1]); @@ -61,7 +61,7 @@ auto icName = n[2]; adjustIcName(icName); - pos = line.find("," + n[3]); + pos = line.find("," + n[3]); std::string name = line.substr(pos + 1); info_[name] = new IconInfo(icName, x, y); @@ -77,7 +77,7 @@ void FolderInfo::write() { - //Remove non-existing icons from info + // Remove non-existing icons from info check(); std::string path = folder_->path().add(fileName_).str(); @@ -96,7 +96,7 @@ void FolderInfo::check() { - //For performance reason we do it only once! + // For performance reason we do it only once! if (checkWasDone_) return; @@ -126,7 +126,7 @@ IconInfo* info = find(name); if (!info) { - info = new IconInfo(type); + info = new IconInfo(type); info_[name] = info; } @@ -177,12 +177,12 @@ std::string line; Tokenizer parse(","); std::vector n; - std::size_t pos; + std::size_t pos = 0; while (getline(in, line)) { parse(line, n); if (n.size() >= 4) { - pos = line.find("," + n[3]); + pos = line.find("," + n[3]); auto icName = n[2]; adjustIcName(icName); icons[line.substr(pos + 1)] = icName; @@ -200,34 +200,33 @@ void FolderInfo::adjustIcName(std::string& icName) { static std::unordered_map cls = { - {"LINE_HOVM","MHOVMOELLERDATA_FAMILY"}, - {"AREA_HOVM","MHOVMOELLERDATA_FAMILY"}, - {"EXPAND_HOVM","MHOVMOELLERDATA_FAMILY"}, - {"VERTICAL_HOVM","MHOVMOELLERDATA_FAMILY"}, - {"POTT_M", "POTT_FAMILY"}, - {"POTT_P", "POTT_FAMILY"}, - {"EQPOTT_M", "POTT_FAMILY"}, - {"EQPOTT_P", "POTT_FAMILY"}, - {"SEQPOTT_M", "POTT_FAMILY"}, - {"SEQPOTT_M", "POTT_FAMILY"}, - {"GRIB_THERMO","THERMODATA_FAMILY"}, - {"BUFR_THERMO","THERMODATA_FAMILY"}, - {"ROTWIND","DIVROT_FAMILY"}, - {"DIVWIND","DIVROT_FAMILY"}, - {"UVWIND","DIVROT_FAMILY"}, - {"VELPOT","VELSTR_FAMILY"}, - {"STREAMFN","VELSTR_FAMILY"}, - {"SAMPLE_FORMULA_DOD", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_DON", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_NOD", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_NON", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_FD", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_FN", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_FDD", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_FDN", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_FND", "SIMPLE_FORMULA_FAMILY"}, - {"SAMPLE_FORMULA_FNN,", "SIMPLE_FORMULA_FAMILY"} - }; + {"LINE_HOVM", "MHOVMOELLERDATA_FAMILY"}, + {"AREA_HOVM", "MHOVMOELLERDATA_FAMILY"}, + {"EXPAND_HOVM", "MHOVMOELLERDATA_FAMILY"}, + {"VERTICAL_HOVM", "MHOVMOELLERDATA_FAMILY"}, + {"POTT_M", "POTT_FAMILY"}, + {"POTT_P", "POTT_FAMILY"}, + {"EQPOTT_M", "POTT_FAMILY"}, + {"EQPOTT_P", "POTT_FAMILY"}, + {"SEQPOTT_M", "POTT_FAMILY"}, + {"SEQPOTT_M", "POTT_FAMILY"}, + {"GRIB_THERMO", "THERMODATA_FAMILY"}, + {"BUFR_THERMO", "THERMODATA_FAMILY"}, + {"ROTWIND", "DIVROT_FAMILY"}, + {"DIVWIND", "DIVROT_FAMILY"}, + {"UVWIND", "DIVROT_FAMILY"}, + {"VELPOT", "VELSTR_FAMILY"}, + {"STREAMFN", "VELSTR_FAMILY"}, + {"SAMPLE_FORMULA_DOD", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_DON", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_NOD", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_NON", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_FD", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_FN", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_FDD", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_FDN", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_FND", "SIMPLE_FORMULA_FAMILY"}, + {"SAMPLE_FORMULA_FNN,", "SIMPLE_FORMULA_FAMILY"}}; auto it = cls.find(icName); if (it != cls.end()) { diff -Nru metview-5.17.4/metview/src/Desktop/FolderInfo.h metview-5.19.2/metview/src/Desktop/FolderInfo.h --- metview-5.17.4/metview/src/Desktop/FolderInfo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderInfo.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,7 +34,7 @@ static bool read(const Path& folderPath, std::map& icons); -protected: +private: void read(); void check(); static void adjustIcName(std::string& icName); diff -Nru metview-5.17.4/metview/src/Desktop/FolderObserver.h metview-5.19.2/metview/src/Desktop/FolderObserver.h --- metview-5.17.4/metview/src/Desktop/FolderObserver.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderObserver.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,9 @@ class FolderObserver { public: - virtual void arrived(IconObject*) = 0; - virtual void gone(IconObject*) = 0; - virtual void position(IconObject*, int, int) = 0; + virtual void arrived(IconObject*) = 0; + virtual void gone(IconObject*) = 0; + virtual void position(IconObject*, int, int) = 0; virtual void renamed(IconObject*, const std::string&) = 0; diff -Nru metview-5.17.4/metview/src/Desktop/FolderPresenter.h metview-5.19.2/metview/src/Desktop/FolderPresenter.h --- metview-5.17.4/metview/src/Desktop/FolderPresenter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderPresenter.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,8 @@ class FolderPresenter { public: + virtual ~FolderPresenter() = default; virtual Folder* currentFolder() = 0; - virtual bool isDisplayed() = 0; - virtual QObject* realObject() = 0; + virtual bool isDisplayed() = 0; + virtual QObject* realObject() = 0; }; diff -Nru metview-5.17.4/metview/src/Desktop/FolderSearchData.cc metview-5.19.2/metview/src/Desktop/FolderSearchData.cc --- metview-5.17.4/metview/src/Desktop/FolderSearchData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderSearchData.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,13 +12,6 @@ #include #include "IconObject.h" -FolderSearchData::FolderSearchData() : - observer_(0), - owner_(0), - current_(0) -{ -} - void FolderSearchData::setObserver(FolderSearchDataObserver* obs) { observer_ = obs; @@ -85,7 +78,7 @@ IconObject* FolderSearchData::next() { if (matchVec_.size() == 0) - return 0; + return nullptr; current_ += 1; @@ -97,13 +90,13 @@ if (current_ >= 0 && current_ < static_cast(matchVec_.size())) return matchVec_.at(current_); - return 0; + return nullptr; } IconObject* FolderSearchData::prev() { if (matchVec_.size() == 0) - return 0; + return nullptr; current_ -= 1; @@ -115,12 +108,12 @@ if (current_ >= 0 && current_ < static_cast(matchVec_.size())) return matchVec_.at(current_); - return 0; + return nullptr; } IconObject* FolderSearchData::first() { if (matchVec_.size() == 0) - return 0; + return nullptr; return matchVec_.at(0); } diff -Nru metview-5.17.4/metview/src/Desktop/FolderSearchData.h metview-5.19.2/metview/src/Desktop/FolderSearchData.h --- metview-5.17.4/metview/src/Desktop/FolderSearchData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderSearchData.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,8 @@ class FolderSearchDataObserver { public: - FolderSearchDataObserver() = default; + FolderSearchDataObserver() = default; + virtual ~FolderSearchDataObserver() = default; virtual void matchChanged() = 0; }; @@ -25,7 +26,7 @@ class FolderSearchData { public: - FolderSearchData(); + FolderSearchData() = default; void setObserver(FolderSearchDataObserver*); void setSearchTerm(const std::string&, const std::string&); @@ -43,11 +44,11 @@ IconObject* prev(); IconObject* next(); -protected: - FolderSearchDataObserver* observer_; - void* owner_; +private: + FolderSearchDataObserver* observer_{nullptr}; + void* owner_{nullptr}; std::string name_; std::string type_; std::vector matchVec_; - int current_; + int current_{0}; }; diff -Nru metview-5.17.4/metview/src/Desktop/FolderSettings.cc metview-5.19.2/metview/src/Desktop/FolderSettings.cc --- metview-5.17.4/metview/src/Desktop/FolderSettings.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderSettings.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,10 +22,7 @@ FolderSettings::FolderSettings(Folder* folder) : folder_(folder), - fileName_("._mv_viewinfo_"), - viewMode_(Desktop::IconViewMode), - iconSize_(32), - halfSizeImported_(false) + fileName_("._mv_viewinfo_") { read(); } @@ -82,7 +79,7 @@ std::ifstream in(path.c_str()); - //Read the param file + // Read the param file if (in.good()) { std::string line; @@ -92,7 +89,7 @@ if (getline(in, line)) { parse(line, n); if (n.size() >= 2) { - int vm; + int vm = 0; std::istringstream issX(n[0]); issX >> vm; @@ -104,14 +101,14 @@ } } - //If there is no param file we try to read the dot file + // If there is no param file we try to read the dot file else { Folder* parent = folder_->parent(); if (!parent) return; Path parentPath = parent->path(); - Path dot = parentPath.add("." + folder_->name()); + Path dot = parentPath.add("." + folder_->name()); Request dotInfo(dot); if (!dotInfo) { @@ -121,7 +118,7 @@ if (count > 0) { buf[count] = '\0'; Path lnkP(buf); - dot = lnkP.directory().add("." + folder_->name()); + dot = lnkP.directory().add("." + folder_->name()); dotInfo = Request(dot); } } @@ -130,8 +127,8 @@ if (dotInfo) { if (const char* m = dotInfo("SMALL_ICONS")) { if (strcmp(m, "TRUE") == 0) { - viewMode_ = Desktop::SimpleViewMode; - iconSize_ = 16; + viewMode_ = Desktop::SimpleViewMode; + iconSize_ = 16; halfSizeImported_ = true; } } @@ -140,7 +137,7 @@ readDefaults(); } - //Save the settings + // Save the settings write(); } } diff -Nru metview-5.17.4/metview/src/Desktop/FolderSettings.h metview-5.19.2/metview/src/Desktop/FolderSettings.h --- metview-5.17.4/metview/src/Desktop/FolderSettings.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/FolderSettings.h 2023-07-15 08:28:47.000000000 +0000 @@ -36,13 +36,13 @@ static Desktop::FolderViewMode defaultViewMode(); static int defaultIconSize(); -protected: +private: void read(); void write(); - Folder* folder_; + Folder* folder_{nullptr}; std::string fileName_; - Desktop::FolderViewMode viewMode_; - int iconSize_; - bool halfSizeImported_; + Desktop::FolderViewMode viewMode_{Desktop::IconViewMode}; + int iconSize_{32}; + bool halfSizeImported_{false}; }; diff -Nru metview-5.17.4/metview/src/Desktop/HelpFactory.cc metview-5.19.2/metview/src/Desktop/HelpFactory.cc --- metview-5.17.4/metview/src/Desktop/HelpFactory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/HelpFactory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,11 +11,11 @@ #include "Request.h" #include "MvIconParameter.h" -static std::map* makers = 0; +static std::map* makers = nullptr; HelpFactory::HelpFactory(const std::string& name) { - if (makers == 0) + if (makers == nullptr) makers = new std::map; (*makers)[name] = this; diff -Nru metview-5.17.4/metview/src/Desktop/HelpFactory.h metview-5.19.2/metview/src/Desktop/HelpFactory.h --- metview-5.17.4/metview/src/Desktop/HelpFactory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/HelpFactory.h 2023-07-15 08:28:47.000000000 +0000 @@ -36,7 +36,7 @@ template class HelpMaker : public HelpFactory { - MvQRequestPanelHelp* make(RequestPanel& owner, const MvIconParameter& def) { return new T(owner, def); } + MvQRequestPanelHelp* make(RequestPanel& owner, const MvIconParameter& def) override { return new T(owner, def); } public: HelpMaker(const std::string& name) : diff -Nru metview-5.17.4/metview/src/Desktop/IconClass.cc metview-5.19.2/metview/src/Desktop/IconClass.cc --- metview-5.17.4/metview/src/Desktop/IconClass.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconClass.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ static std::map classes; // All icon classed subclass from this one -static IconClass super("*", 0); +static IconClass super("*", nullptr); static std::set allActions; @@ -77,7 +77,7 @@ if (j != classes.end()) return *(*j).second; - return *(new IconClass(name, empty_request(0))); + return *(new IconClass(name, empty_request(nullptr))); } const IconClass& IconClass::find(const std::string& name, const std::string& defaultType, bool caseSensitive) @@ -89,7 +89,7 @@ } else { for (auto& classe : classes) { - //We convert the class name to uppercase for comparison + // We convert the class name to uppercase for comparison std::string str = classe.first; std::transform(str.begin(), str.end(), str.begin(), ::toupper); std::string ucName = name; @@ -116,7 +116,7 @@ std::string strTerm = str; std::transform(strTerm.begin(), strTerm.end(), strTerm.begin(), ::tolower); - //Default name + // Default name s = kind->defaultName(); std::transform(s.begin(), s.end(), s.begin(), ::tolower); if (s.find(strTerm) != std::string::npos) { @@ -124,7 +124,7 @@ continue; } - //Name + // Name s = kind->name(); std::transform(s.begin(), s.end(), s.begin(), ::tolower); if (s.find(strTerm) != std::string::npos) { @@ -132,7 +132,7 @@ continue; } - //Type + // Type s = kind->type(); std::transform(s.begin(), s.end(), s.begin(), ::tolower); if (s.find(strTerm) != std::string::npos) { @@ -140,7 +140,7 @@ continue; } - //icon box + // icon box s = kind->iconBox(); std::transform(s.begin(), s.end(), s.begin(), ::tolower); if (s.find(strTerm) != std::string::npos) { @@ -181,10 +181,10 @@ return false; } -//The list of supported actions (can_) is now cached! We rely on the fact that when can() is -//called for the first time all the initailisation has been done! We also suppose that there is -//at least one action defined for any of the classes so after the first call of can() can_cannot be -//empty! +// The list of supported actions (can_) is now cached! We rely on the fact that when can() is +// called for the first time all the initailisation has been done! We also suppose that there is +// at least one action defined for any of the classes so after the first call of can() can_cannot be +// empty! std::set IconClass::can() const { if (can_.empty()) @@ -193,21 +193,22 @@ return can_; } -//Generate a list of the supported actions (can_) +// Generate a list of the supported actions (can_) std::set IconClass::generateCan() const { std::set c; - //First check if all the actions are allowed for the class + // First check if all the actions are allowed for the class static Action all("*", "*"); if (services_.find(all) != services_.end()) { c = allActions; - //Now we need to remove some actions if they are not defined explicitly for this - //class or its output classes in ObjectList + // Now we need to remove some actions if they are not defined explicitly for this + // class or its output classes in ObjectList static std::set nonAllActions; if (nonAllActions.empty()) { nonAllActions.insert("extract"); + nonAllActions.insert("extract_subfolder"); nonAllActions.insert("analyse"); nonAllActions.insert("save"); nonAllActions.insert("clear"); @@ -216,21 +217,21 @@ nonAllActions.insert("export"); } - //Loop for the actions to be checked + // Loop for the actions to be checked for (const auto& nonAllAction : nonAllActions) { bool need = false; - //Flag the action if it is not present in the services! + // Flag the action if it is not present in the services! Action nonAllAc(nonAllAction, "*"); auto itS = services_.find(nonAllAc); if (itS != services_.end()) { continue; } - //Flag the action if it is not present in the otput classes + // Flag the action if it is not present in the otput classes for (auto output : outputs_) { // std::cout << name_ << " can, adding " << (*k)->name_ << std::endl; - auto oc = output->can(); + auto oc = output->can(); auto itIcs = oc.find(nonAllAction); if (itIcs != oc.end()) { need = true; @@ -238,13 +239,13 @@ } } - //If the action is flagged we remove it + // If the action is flagged we remove it if (!need) c.erase(nonAllAction); } } - //Otherwise compiles a set of action from services and outpusts etc. + // Otherwise compiles a set of action from services and outpusts etc. else { if (super_) { c = super_->can(); @@ -262,7 +263,7 @@ } } - //Check editor + // Check editor if (editor() == "NoEditor") c.erase("edit"); else @@ -282,21 +283,21 @@ allActions.insert(action.name()); - //cout << name_ << " can " << action << " "; - //if(output) std::cout << " output " << output->name_; - //cout << " with " << *s << std::endl; + // cout << name_ << " can " << action << " "; + // if(output) std::cout << " output " << output->name_; + // cout << " with " << *s << std::endl; self->services_[action] = s; } Service* IconClass::service(const Action& action) const { - //cout << "IconClass::service class " << name_ << std::endl; - //cout << "IconClass::service for " << action << std::endl; + // cout << "IconClass::service class " << name_ << std::endl; + // cout << "IconClass::service for " << action << std::endl; auto j = services_.find(action); if (j == services_.end()) { - Service* s = super_ ? super_->service(action) : 0; - if (s == 0 && !(action.name() == "*")) + Service* s = super_ ? super_->service(action) : nullptr; + if (s == nullptr && !(action.name() == "*")) return service(Action("*", action.mode())); else return s; @@ -319,7 +320,7 @@ std::ifstream in(file); int maxLines = 5; - int actLine = 0; + int actLine = 0; std::string typeStr; if (in.good()) { @@ -338,7 +339,7 @@ typeStr = typeStr.substr(0, typeStr.size() - 1); } - //We convert the std::string to uppercase for comparison + // We convert the std::string to uppercase for comparison std::transform(typeStr.begin(), typeStr.end(), typeStr.begin(), ::toupper); break; } @@ -347,12 +348,12 @@ } } - //Close the file + // Close the file in.close(); if (!typeStr.empty()) { for (auto& classe : classes) { - //We convert the class name to uppercase for comparison + // We convert the class name to uppercase for comparison std::string str = classe.first; std::transform(str.begin(), str.end(), str.begin(), ::toupper); if (str == typeStr) { @@ -376,7 +377,7 @@ return ScanFileType(file); case S_IFREG: - //return scan_file(file); + // return scan_file(file); { std::string ft = ScanFileType(file); if (ft != "NOTE") @@ -405,20 +406,20 @@ return find(kind); } -//We need to ensure that this call does not create a new iconClass. So it could be called from another thread. -//On top of that we cannot call anything that requires mars parsing because it is not safe! +// We need to ensure that this call does not create a new iconClass. So it could be called from another thread. +// On top of that we cannot call anything that requires mars parsing because it is not safe! void IconClass::guess(const std::string& fullName, std::string& icName, std::string& icType) { if (!icName.empty()) { const IconClass& ic = IconClass::find(icName, "NOTE", true); - icType = ic.type(); + icType = ic.type(); } else { - //try dot file + // try dot file Path icp(fullName); Path dot = icp.dot(); - //We need to parse the dot file by ourselves because requests cannot be used here (they are not thread safe). + // We need to parse the dot file by ourselves because requests cannot be used here (they are not thread safe). if (dot.exists()) { std::ifstream in(dot.str().c_str()); std::string str; @@ -434,20 +435,20 @@ } const IconClass& ic = IconClass::find(type, "NOTE", false); - icName = ic.name(); - icType = ic.type(); + icName = ic.name(); + icType = ic.type(); } break; } } in.close(); } - //If there is no dotfile we guess the file type + // If there is no dotfile we guess the file type else { //::guesss() does not create a new iconclass! const IconClass& ic = IconClass::guess(fullName); - icName = ic.name(); - icType = ic.type(); + icName = ic.name(); + icType = ic.type(); } } } @@ -463,7 +464,7 @@ if (obj) return obj->clone(f, x, y, false); - return 0; + return nullptr; } IconObject* IconClass::createOneFromRequest(Folder* f) const @@ -479,7 +480,7 @@ IconObject* IconClass::defaultObject() const { - Folder* f = Folder::folder("defaults"); + Folder* f = Folder::folder("defaults"); std::string name = defaultName(); IconObject* obj = f->find(name); @@ -487,9 +488,9 @@ return obj; else return IconFactory::create(f, name, *this); - //return createOneFromRequest(f); + // return createOneFromRequest(f); - return 0; + return nullptr; } #if 0 diff -Nru metview-5.17.4/metview/src/Desktop/IconClass.h metview-5.19.2/metview/src/Desktop/IconClass.h --- metview-5.17.4/metview/src/Desktop/IconClass.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconClass.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,8 @@ class IconClass : public MvIconClassCore { public: - IconClass(const std::string&, request*, const IconClass* = 0); - virtual ~IconClass(); + IconClass(const std::string&, request*, const IconClass* = nullptr); + ~IconClass() override; virtual Service* service(const Action&) const; virtual void service(const Action&, const IconClass*, Service*) const; @@ -51,7 +51,7 @@ virtual bool isSubClassOf(const IconClass&) const; virtual bool canBecome(const IconClass&) const; - //virtual MvIconLanguage& language() const; + // virtual MvIconLanguage& language() const; virtual int priority() const; @@ -77,20 +77,20 @@ std::set generateCan() const; const IconClass* super_; - //std::string name_; - //request* request_; + // std::string name_; + // request* request_; std::map services_; std::set outputs_; mutable std::set can_; - //friend std::ostream& operator<<(std::ostream& s,const IconClass& p) - // { p.print(s); return s; } + // friend std::ostream& operator<<(std::ostream& s,const IconClass& p) + // { p.print(s); return s; } }; inline void destroy(IconClass**) {} // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(IconClass); +// OS_MARK_SCHEMA_TYPE(IconClass); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/IconDescription.cc metview-5.19.2/metview/src/Desktop/IconDescription.cc --- metview-5.17.4/metview/src/Desktop/IconDescription.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconDescription.cc 2023-07-15 08:28:47.000000000 +0000 @@ -76,7 +76,7 @@ auto item = new IconDescriptionCacheItem(); data_.push_back(item); item->path_ = path; - item->pix_ = pix; + item->pix_ = pix; item->text_ = text; #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) item->creationTime_ = QDateTime::currentDateTime().toSecsSinceEpoch(); @@ -104,7 +104,7 @@ } else { auto obj = *it; - it = data_.erase(it); + it = data_.erase(it); delete obj; #ifdef DEBUG_ICONDESCRIPTION__ std::cout << " found cached item with older timestamp [-->delete]" << std::endl; @@ -166,9 +166,11 @@ QString IconDescription::info(IconObject* obj) { if (obj) { - //Icon name + // Icon name QString txt = ""; + bool brokenLink = obj->isBrokenLink(); + if (obj->isLink()) { txt += ""; } @@ -179,43 +181,57 @@ txt += ""; } - //icon class + // icon class auto subCol = MvQTheme::subText(); txt += " " + MvQ::formatText(QString::fromStdString(obj->iconClass().name()), subCol); - //file size + // file size if (!obj->isFolder()) { auto accCol = MvQTheme::accentText(); txt += " " + MvQ::formatText(MvQFileInfo::formatSize(obj->path().sizeInBytes()), accCol); } - //date and time - txt += " " + formatFileDate(obj->path().lastModified()); + // date and time + txt += " " + formatFileDate(obj->path().lastModified(brokenLink)); - //symlink target + // symlink target if (obj->isLink()) { - txt += MvQ::formatText(" link: ", subCol); - txt += "" + MvQ::formatText(QString::fromStdString(obj->path().symlinkTarget()), subCol) + ""; + txt += MvQ::formatText(" symlink: ", subCol) + " "; + auto target = QString::fromStdString(obj->path().symlinkTarget()); + if (!obj->isBrokenLink()) { + txt += target; + } + else { + txt += MvQ::formatText(target + " (broken)", + MvQTheme::colour("folderview", "broken_link")); + } + txt += " "; } + // if (obj->isLink()) { + // txt += MvQ::formatText(" link: ", subCol); + // txt += "" + MvQ::formatText(QString::fromStdString(obj->path().symlinkTarget()), subCol) + ""; + // } return txt; } - return QString(); + return {}; } -QString IconDescription::table(IconObject* obj) +QString IconDescription::table(IconObject* obj, bool addFullPath) { if (obj) { QString txt; auto subCol = MvQTheme::subText(); - //Icon name + // Icon name if (obj->isLink()) { txt += ""; } txt += QString::fromStdString("" + obj->name() + ""); + bool brokenLink = obj->isBrokenLink(); + if (obj->isLink()) { txt += ""; } @@ -223,38 +239,50 @@ txt += "
"; txt += "
" + label + "
" + label + "
"; - //icon class + // icon class txt += "" + MvQ::formatTableTdText("Type:", subCol) + " "; - //file size + // file size if (!obj->isFolder()) { txt += "" + MvQ::formatTableTdText("Size:", subCol) + ""; } - //date and time + // date and time + auto modTime = obj->path().lastModified(brokenLink); txt += "" + MvQ::formatTableTdText("Modified:", subCol) + ""; + ((modTime != 0) ? formatFileDate(modTime) : "???") + ""; txt += "" + MvQ::formatTableTdText("Owner:", subCol) + ""; + QString::fromStdString(obj->path().owner(brokenLink)) + ""; txt += "" + MvQ::formatTableTdText("Permissions:", subCol) + ""; + QString::fromStdString(obj->path().permissions(brokenLink)) + ""; + + if (addFullPath) { + txt += "" + MvQ::formatTableTdText("Path:", subCol) + ""; + } - //symlink target + // symlink target if (obj->isLink()) { - txt += "" + MvQ::formatTableTdText("Link:", subCol) + ""; + txt += "" + MvQ::formatTableTdText("Symlink:", subCol) + ""; } txt += "
" + QString::fromStdString(obj->editorClass().name()) + "
" + MvQFileInfo::formatSize(obj->path().sizeInBytes()) + "
" + - formatFileDate(obj->path().lastModified()) + "
" + - QString::fromStdString(obj->path().owner()) + "
" + - QString::fromStdString(obj->path().permissions()) + "
" + + QString::fromStdString(obj->path().str()) + "
" + - QString::fromStdString(obj->path().symlinkTarget()) + "
"; + auto target = QString::fromStdString(obj->path().symlinkTarget()); + if (!obj->isBrokenLink()) { + txt += target; + } + else { + txt += MvQ::formatText(target + " (broken)", + MvQTheme::colour("folderview", "broken_link")); + } + txt += "
"; - return txt; } - - return QString(); + return {}; } QString IconDescription::formatFileDate(time_t t) const @@ -263,7 +291,7 @@ QDateTime dt; dt.setSecsSinceEpoch(t); #else - QDateTime dt = QDateTime::fromTime_t(t); + QDateTime dt = QDateTime::fromTime_t(t); #endif return dt.toString("yyyy-MM-dd hh:mm"); } diff -Nru metview-5.17.4/metview/src/Desktop/IconDescription.h metview-5.19.2/metview/src/Desktop/IconDescription.h --- metview-5.17.4/metview/src/Desktop/IconDescription.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconDescription.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,12 +27,12 @@ { public: IconDescriptionMakerObserver(IconObject*, IconDescriptionPresenter*); - virtual ~IconDescriptionMakerObserver() {} + ~IconDescriptionMakerObserver() override = default; virtual void start(); - virtual void reply(const Request&, int); - virtual void progress(const Request&) {} - virtual void message(const std::string&) {} + void reply(const Request&, int) override; + void progress(const Request&) override {} + void message(const std::string&) override {} private: // No copy allowed @@ -79,7 +79,7 @@ public: static IconDescription* Instance(); QString info(IconObject*); - QString table(IconObject*); + QString table(IconObject*, bool addFullPath = false); void getContents(IconObject* item, IconDescriptionPresenter* caller); void notifyReply(const Request&, int, const std::string&, const std::string&, IconDescriptionPresenter*); diff -Nru metview-5.17.4/metview/src/Desktop/IconFactory.cc metview-5.19.2/metview/src/Desktop/IconFactory.cc --- metview-5.17.4/metview/src/Desktop/IconFactory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconFactory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,13 +19,13 @@ #include "TemporaryObject.h" #include "MvLog.h" -#include +#include -static std::map* makers = 0; +static std::map* makers = nullptr; IconFactory::IconFactory(const std::string& name) { - if (makers == 0) + if (makers == nullptr) makers = new std::map; (*makers)[name] = this; @@ -33,10 +33,10 @@ IconFactory::~IconFactory() = default; -//For folders name should contain the full path!!! +// For folders name should contain the full path!!! IconObject* IconFactory::create(Folder* parent, const std::string& name, const IconClass& kind, IconInfo* info) { - IconObject* o = 0; + IconObject* o = nullptr; // Try class, then type auto j = makers->find(kind.name()); @@ -45,14 +45,15 @@ if (j == makers->end()) { marslog(LOG_WARN, "Unknown icon type=%s [file=%s]", kind.type().c_str(), name.c_str()); // o = new Unknown(parent,kind,name,info); - o = 0; + o = nullptr; } else o = (*j).second->make(parent, kind, name, info); - if (o != 0) { + if (o != nullptr) { parent->adopt(o); o->createFiles(); + o->initStateInfo(); } return o; @@ -65,7 +66,7 @@ IconObject* IconFactory::create(Folder* parent, const std::string& name, const IconClass& kind) { - return create(parent, name, kind, 0); + return create(parent, name, kind, nullptr); } IconObject* IconFactory::create(Folder* parent, const std::string& name, const IconClass& kind, int x, int y) @@ -82,31 +83,31 @@ IconObject* IconFactory::create(Folder* parent, const std::string& name, int x, int y) { FolderInfo* folderInfo = nullptr; - IconInfo* info = nullptr; + IconInfo* info = nullptr; std::string dirName, fileName; - Path path = parent->path(); - dirName = path.str(); - fileName = path.add(name).str(); + Path path = parent->path(); + dirName = path.str(); + fileName = path.add(name).str(); folderInfo = parent->folderInfo(); - info = folderInfo->find(name); + info = folderInfo->find(name); if (info) { const IconClass& ic = IconClass::find(info->type()); return create(parent, name, ic, info); } - //If there is no folderinfo available we see if there is a - //dotfile to get the type and the positions + // If there is no folderinfo available we see if there is a + // dotfile to get the type and the positions else { Path actPath(dirName); Path dot = actPath.add(std::string(".") + name); Request dotInfo(dot); - //If there is no dotfile we guess the file type + // If there is no dotfile we guess the file type if (!dotInfo) { - dotInfo = Request("USER_INTERFACE"); - const IconClass& ic = IconClass::guess(fileName); + dotInfo = Request("USER_INTERFACE"); + const IconClass& ic = IconClass::guess(fileName); dotInfo("ICON_CLASS") = ic.name().c_str(); info = new IconInfo(dotInfo); @@ -116,7 +117,7 @@ return create(parent, name, ic, info); } else { - const char* type = dotInfo("ICON_CLASS"); + const char* type = dotInfo("ICON_CLASS"); const IconClass& ic = IconClass::find(type); info = new IconInfo(dotInfo); @@ -135,20 +136,20 @@ if (o) return o; - //cout << "IconFactory::create " << name << std::endl; - std::string dir = mdirname(name.c_str()); + // cout << "IconFactory::create " << name << std::endl; + std::string dir = mdirname(name.c_str()); std::string base = mbasename(name.c_str()); Folder* f = dynamic_cast(create(dir, IconClass::find("FOLDER"))); - return f ? create(f, base, kind) : 0; + return f ? create(f, base, kind) : nullptr; } IconObject* IconFactory::create(IconObject* /*o*/, const Request& /*r*/, const IconClass* /*c*/) { assert(0); - return 0; - //return new Temporary(o,r,c); + return nullptr; + // return new Temporary(o,r,c); } IconObject* IconFactory::create(Folder* parent, const Request& r, int x, int y) @@ -156,7 +157,7 @@ const char* kind = r.getVerb(); const char* name = r("_NAME"); - std::string kind1(kind); //it is needed on alpha + std::string kind1(kind); // it is needed on alpha const IconClass& c = IconClass::find(kind1); // The command below was causing memory problems on alpha. diff -Nru metview-5.17.4/metview/src/Desktop/IconFactory.h metview-5.19.2/metview/src/Desktop/IconFactory.h --- metview-5.17.4/metview/src/Desktop/IconFactory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconFactory.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,15 +27,15 @@ const std::string& name, IconInfo* info) = 0; static IconObject* create(Folder* parent, const std::string& name, const IconClass&, IconInfo*); - static IconObject* createTemporary(IconObject*, const Request&, const IconClass* = 0); + static IconObject* createTemporary(IconObject*, const Request&, const IconClass* = nullptr); static IconObject* create(Folder* parent, const std::string& name, const IconClass&); static IconObject* create(Folder* parent, const std::string& name, const IconClass& kind, int x, int y); static IconObject* create(Folder* parent, const std::string& name, int x, int y); static IconObject* create(Folder* parent, const std::string& name); static IconObject* create(const std::string& name, const IconClass&); - //We should never call this - static IconObject* create(IconObject*, const Request&, const IconClass* = 0); + // We should never call this + static IconObject* create(IconObject*, const Request&, const IconClass* = nullptr); static IconObject* create(Folder*, const Request&, int x, int y); @@ -49,9 +49,11 @@ class IconMaker : public IconFactory { IconObject* make(Folder* parent, const IconClass& kind, - const std::string& name, IconInfo* info) + const std::string& name, IconInfo* info) override { - return new T(parent, kind, name, info); + T* t = new T(parent, kind, name, info); + return t; + // return new T(parent, kind, name, info); } public: diff -Nru metview-5.17.4/metview/src/Desktop/IconGroupTools.cc metview-5.19.2/metview/src/Desktop/IconGroupTools.cc --- metview-5.17.4/metview/src/Desktop/IconGroupTools.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconGroupTools.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ std::string IconGroupTools::name() { - return std::string(get_value(request_, "name", 0)); + return {get_value(request_, "name", 0)}; } bool IconGroupTools::can(const std::string& name) diff -Nru metview-5.17.4/metview/src/Desktop/IconInfo.cc metview-5.19.2/metview/src/Desktop/IconInfo.cc --- metview-5.17.4/metview/src/Desktop/IconInfo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconInfo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ IconInfo::IconInfo(const std::string& type) : type_(type) { - info_ = Request("USER_INTERFACE"); + info_ = Request("USER_INTERFACE"); info_("ICON_CLASS") = type.c_str(); info_("X") = undefX_; @@ -48,10 +48,10 @@ x_(x), y_(y) { - info_ = Request("USER_INTERFACE"); + info_ = Request("USER_INTERFACE"); info_("ICON_CLASS") = type.c_str(); - info_("X") = x; - info_("Y") = y; + info_("X") = x; + info_("Y") = y; } IconInfo::~IconInfo() = default; @@ -87,14 +87,14 @@ void IconInfo::save(const Path& s) { info_.save(s); - //cout << "Save into " << s.str() << std::endl; - //info_.print(); + // cout << "Save into " << s.str() << std::endl; + // info_.print(); } bool IconInfo::changeIconClass(const std::string& kind) { if (type_ != kind) { - type_ = kind; + type_ = kind; info_("ICON_CLASS") = kind.c_str(); return true; } diff -Nru metview-5.17.4/metview/src/Desktop/IconInfo.h metview-5.19.2/metview/src/Desktop/IconInfo.h --- metview-5.17.4/metview/src/Desktop/IconInfo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconInfo.h 2023-07-15 08:28:47.000000000 +0000 @@ -35,11 +35,11 @@ IconInfo(const IconInfo&); IconInfo& operator=(const IconInfo&); - bool modified_; + bool modified_{false}; Request info_; std::string type_; - int x_; - int y_; + int x_{0}; + int y_{0}; static int undefX_; static int undefY_; }; diff -Nru metview-5.17.4/metview/src/Desktop/IconObject.cc metview-5.19.2/metview/src/Desktop/IconObject.cc --- metview-5.17.4/metview/src/Desktop/IconObject.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconObject.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,11 +29,12 @@ #include "Tokenizer.h" #include "Dependancy.h" #include "MvQLogDialog.h" +#include "MvLog.h" #include #include #include -#include +#include #include "Metview.h" #include "MvLog.h" @@ -49,31 +50,18 @@ parent_(parent), class_(const_cast(&kind)), info_(info), - queue_(0), - log_(0), - editor_(0), - logWindow_(0), + queue_(nullptr), + log_(nullptr), + editor_(nullptr), + logWindow_(nullptr), locked_(false), link_(false), status_(DefaultStatus) { - std::string p; + Path p(""); if (parent_) { parent_->attach(); - p = path().str(); - } - else { - p = name; } - - struct stat s; - if (lstat(p.c_str(), &s) == 0) { - link_ = S_ISLNK(s.st_mode); - locked_ = faccess(p.c_str(), W_OK); - //else locked_ = true; - } - //else locked_ = true; - objects_.push_back(this); } @@ -84,7 +72,6 @@ parent_->detach(); delete info_; - std::vector::iterator it; for (it = objects_.begin(); it != objects_.end(); it++) { if (*it == this) { @@ -107,11 +94,12 @@ IconInfo& IconObject::info() const { if (info_ == nullptr) { - Request info("USER_INTERFACE"); - info("ICON_CLASS") = editorClassName().c_str(); - auto* o = const_cast(this); - o->info_ = new IconInfo(info); + Request infoReq("USER_INTERFACE"); + infoReq("ICON_CLASS") = editorClassName().c_str(); + auto* o = const_cast(this); + o->info_ = new IconInfo(infoReq); o->saveInfo(); + return *(o->info_); } return *info_; @@ -163,7 +151,7 @@ bool IconObject::isEmbedded() { - //Needs to be improved! + // Needs to be improved! return (parent()->path().str().find("#") != std::string::npos); } @@ -206,25 +194,25 @@ Task* IconObject::action(const Action& a) { Service* s = iconClass().service(a); - if (s == 0) + if (s == nullptr) s = Service::find("InternalDesktopService"); - if (s != 0) { + if (s != nullptr) { Task* t = s->task(a, this); - if (t != 0) { - if (queue_ == 0) + if (t != nullptr) { + if (queue_ == nullptr) queue_ = new Queue(this); queue_->push(t); return t; } } - return 0; + return nullptr; } Log& IconObject::log() { - if (log_ == 0) + if (log_ == nullptr) log_ = new Log(this); return *log_; } @@ -236,13 +224,13 @@ /*Request IconObject::request() const { - cout << "Oops, should not be called..." << std::endl; - return Request(""); + cout << "Oops, should not be called..." << std::endl; + return Request(""); } void IconObject::request(const Request&) { - cout << "Oops, should not be called..." << std::endl; + cout << "Oops, should not be called..." << std::endl; }*/ Request IconObject::fullRequest() const @@ -256,7 +244,7 @@ if (r.getVerb() == verb) return r; - return Request(); + return {}; } MvIconLanguage& IconObject::language() const @@ -266,12 +254,12 @@ IconObject* IconObject::search(const std::string& fullName) { - //cout << "search " << fullName << std::endl; + // cout << "search " << fullName << std::endl; - //return Folder::icon(fullName); + // return Folder::icon(fullName); if (fullName[0] != '/') - return 0; + return nullptr; Tokenizer parse("/"); std::vector n; @@ -279,14 +267,14 @@ std::vector names; - for (auto j = n.begin(); j != n.end(); ++j) { - if (*j == "" || *j == ".") + for (auto& j : n) { + if (j == "" || j == ".") continue; - if (*j == "..") + if (j == "..") names.pop_back(); else - names.push_back(*j); + names.push_back(j); } return Folder::top()->findMulti(names); @@ -294,22 +282,22 @@ IconObject* IconObject::search(IconObject& /*o*/, const std::string& /*relativeName*/) { - return 0; + return nullptr; } IconObject* IconObject::findMulti(const std::vector& n) { - return (n.size() == 0) ? this : 0; + return (n.size() == 0) ? this : nullptr; } IconObject* IconObject::find(const std::string& /*name*/) { - return 0; + return nullptr; } void IconObject::saveInfo() { - //info().save(dotPath()); + // info().save(dotPath()); } void IconObject::reparent(Folder* parent) @@ -318,14 +306,14 @@ modified(); Path old_path = path(); - Path old_emb = embeddedPath(); + Path old_emb = embeddedPath(); parent_->detach(); parent_ = parent; parent_->attach(); Path new_path = path(); - Path new_emb = embeddedPath(); + Path new_emb = embeddedPath(); old_path.rename(new_path); if (old_emb.exists()) @@ -366,19 +354,19 @@ modified(); - std::string old_name = name_; + std::string old_name = name_; std::string old_embedded_name = embeddedName(name_); - Path old_path = path(); + Path old_path = path(); Path old_embedded_path = embeddedPath(); - Folder* old_emb = embeddedFolder(false); + Folder* old_emb = embeddedFolder(false); name_ = new_name; Path new_path = path(); old_path.rename(new_path); - //If there is embedded folder + // If there is embedded folder if (old_embedded_path.exists()) { if (old_emb) { old_emb->rename(embeddedName(name())); @@ -431,24 +419,24 @@ } /*Folder *f=parent(); - if(f && f->locked()) - { - c.erase("duplicate"); - c.erase("delete"); - c.erase("cut"); - c.erase("destroy"); - c.erase("compress"); - }*/ + if(f && f->locked()) + { + c.erase("duplicate"); + c.erase("delete"); + c.erase("cut"); + c.erase("destroy"); + c.erase("compress"); + }*/ if (c.find("save") == c.end()) c.erase("clear"); c.insert("remove"); - //c.insert("output"); + // c.insert("output"); c.insert("mergeIcon"); c.insert("replaceIcon"); - //TODO: find a better solution + // TODO: find a better solution if (iconClass().name() != "ECCHARTS") { c.erase("export_macro"); c.erase("export_python"); @@ -461,11 +449,11 @@ void IconObject::toWastebasket() { Folder* f = Folder::folder("wastebasket"); - if (f == 0) { + if (f == nullptr) { Log::error(this) << "Can't find wastebasket!" << std::endl; } else { - //position(0,0); + // position(0,0); f->adopt(this); } } @@ -481,7 +469,7 @@ void IconObject::edit2() { - //Editor::open(this,"ExternalTextEditor"); + // Editor::open(this,"ExternalTextEditor"); } void IconObject::showLog() @@ -494,7 +482,7 @@ void IconObject::duplicate() { clone(parent(), info().x() + 20, info().y() + 20, false); - //parent()->position(c,info().x()+20,info().y()+20); + // parent()->position(c,info().x()+20,info().y()+20); } IconObject* IconObject::clone(Folder* f, bool update) @@ -504,7 +492,7 @@ IconObject* IconObject::clone(Folder* f, int x, int y, bool update) { - //createFiles(); + // createFiles(); std::string new_name; @@ -518,10 +506,10 @@ new_name = f->uniqueName(name()); Path old_path = path(); - Path old_emb = embeddedPath(); + Path old_emb = embeddedPath(); Path new_path = f->path().add(new_name); - Path new_emb = f->path().add(embeddedName(new_name)); + Path new_emb = f->path().add(embeddedName(new_name)); old_path.copy(new_path); if (old_emb.exists()) { @@ -625,12 +613,12 @@ if (log_) { delete log_; - log_ = 0; + log_ = nullptr; } if (queue_) queue_->ownerGone(); - queue_ = 0; + queue_ = nullptr; dependancies_.clear(); } @@ -714,9 +702,9 @@ { IconObjectH save = this; removeFiles(); - parent()->release(this); //this notify the folderobservers!! + parent()->release(this); // this notify the folderobservers!! - //Do we need it? + // Do we need it? notifyDestroyed(); if (editor_) @@ -730,7 +718,7 @@ bool IconObject::renamable() const { - //return !locked() && !parent()->locked() && editor_ == 0; + // return !locked() && !parent()->locked() && editor_ == 0; return !locked() && !parent()->locked(); } @@ -741,7 +729,7 @@ void IconObject::lock() { - locked_ = true; + // locked_ = true; } bool IconObject::temporary() const @@ -753,16 +741,16 @@ std::vector IconObject::subObjects(const std::string& param, const Request& r) { - int i = 0; + int i = 0; bool more = false; std::vector result; do { - MvRequest a = r(param.c_str(), i); + MvRequest a = r(param.c_str(), i); const char* b = r(param.c_str(), i); - more = false; - IconObjectH o = 0; + more = false; + IconObjectH o = nullptr; if (a) { // a.print(); @@ -777,16 +765,16 @@ o = IconFactory::create(this, a); } - if (b && strcmp(b, "#")) { + if (b && strcmp(b, "#") != 0) { more = true; // Real object std::string name = makeFullName(b); - o = search(name); + o = search(name); // if (o == 0) // std::cout << "Cannot find " << name << std::endl; } - if (o != 0) + if (o != nullptr) result.push_back(o); i++; @@ -800,7 +788,7 @@ void IconObject::setSubObjects(const std::string& name, const std::vector& sub, Request& r, bool clean) { - //Delete the unused embedded subObjects + // Delete the unused embedded subObjects if (clean) { std::vector oriSub = subObjects(name, r); for (const auto& j : oriSub) { @@ -855,7 +843,7 @@ while (same) { int c1 = getc(f1); int c2 = getc(f2); - same = (c1 == c2); + same = (c1 == c2); if (c1 == EOF || c2 == EOF) break; } @@ -887,6 +875,32 @@ } } +void IconObject::initStateInfo() +{ + updateStateInfo(false); +} + +void IconObject::updateStateInfo(bool broadcast) +{ + bool changed = false; + + bool linkVal = path().isSymLink(); + if (linkVal != link_) { + changed = true; + } + link_ = linkVal; + + bool lockedVal = (link_ && isBrokenLink()) ? false : path().locked(); + if (lockedVal != locked_) { + changed = true; + } + locked_ = lockedVal; + + if (broadcast && changed) { + notifyChanged(); + } +} + bool IconObject::isInTimer() const { return false; @@ -942,10 +956,10 @@ { Request r = request(); if (r) { - std::string verb = r.getVerb(); + std::string verb = r.getVerb(); std::string icName = iconClass().name(); - //We convert the string to uppercase for comparison + // We convert the string to uppercase for comparison std::transform(verb.begin(), verb.end(), verb.begin(), ::toupper); std::transform(icName.begin(), icName.end(), icName.begin(), ::toupper); diff -Nru metview-5.17.4/metview/src/Desktop/IconObject.h metview-5.19.2/metview/src/Desktop/IconObject.h --- metview-5.17.4/metview/src/Desktop/IconObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,11 +13,11 @@ class IconClass; class IconInfo; -//class FolderObserver; +// class FolderObserver; class Action; class Queue; class Folder; -//class CommandObserver; +// class CommandObserver; class Editor; class Action; class Request; @@ -50,9 +50,9 @@ int x() const { return x_; } int y() const { return y_; } -protected: - int x_; - int y_; +private: + int x_{0}; + int y_{0}; }; @@ -156,7 +156,6 @@ virtual IconObject* findMulti(const std::vector&); virtual IconObject* find(const std::string&); - // Move virtual void reparent(Folder*); @@ -171,14 +170,14 @@ virtual bool isBrokenLink() const; virtual bool isInTimer() const; virtual void lock(); + void initStateInfo(); + void updateStateInfo(bool broadcast = true); // - void addObserver(IconObserver*); void removeObserver(IconObserver*); // - virtual void notifyWaiting(); virtual void notifyError(); virtual void notifyChanged(); @@ -216,10 +215,10 @@ virtual bool checkRequest(); static std::vector objects() { return objects_; } - virtual bool storedAsRequestFile() const {return false;} + virtual bool storedAsRequestFile() const { return false; } protected: - //Use and implement it with extra care!!! + // Use and implement it with extra care!!! virtual bool recheckIconClass() { return false; } virtual void print(std::ostream&) const; diff -Nru metview-5.17.4/metview/src/Desktop/IconObserver.h metview-5.19.2/metview/src/Desktop/IconObserver.h --- metview-5.17.4/metview/src/Desktop/IconObserver.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/IconObserver.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,6 +14,7 @@ class IconObserver { public: + virtual ~IconObserver() = default; virtual void iconChanged(IconObject*) {} virtual void iconDestroyed(IconObject*) {} virtual void iconEdited(IconObject*) {} diff -Nru metview-5.17.4/metview/src/Desktop/Input.cc metview-5.19.2/metview/src/Desktop/Input.cc --- metview-5.17.4/metview/src/Desktop/Input.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Input.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,8 +42,8 @@ int n = fileno(f); if (!notifier_) { - //WARNING!!!! - //It works only on UNIX!!! + // WARNING!!!! + // It works only on UNIX!!! notifier_ = new QSocketNotifier(n, QSocketNotifier::Read); connect(notifier_, SIGNAL(activated(int)), diff -Nru metview-5.17.4/metview/src/Desktop/Input.h metview-5.19.2/metview/src/Desktop/Input.h --- metview-5.17.4/metview/src/Desktop/Input.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Input.h 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ #include -#include +#include class QSocketNotifier; @@ -21,13 +21,13 @@ public: Input(); - virtual ~Input(); + ~Input() override; void start(FILE*); void stop(); virtual void ready(const char*) = 0; - virtual void done(FILE*) = 0; + virtual void done(FILE*) = 0; protected slots: void slotInput(int); diff -Nru metview-5.17.4/metview/src/Desktop/InternalService.h metview-5.19.2/metview/src/Desktop/InternalService.h --- metview-5.17.4/metview/src/Desktop/InternalService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/InternalService.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,14 +15,14 @@ { public: InternalService(); - virtual ~InternalService(); + ~InternalService() override; private: // No copy allowed InternalService(const InternalService&); InternalService& operator=(const InternalService&); - virtual Task* task(const Action&, IconObject*); + Task* task(const Action&, IconObject*) override; }; inline void destroy(InternalService**) {} diff -Nru metview-5.17.4/metview/src/Desktop/InternalTask.cc metview-5.19.2/metview/src/Desktop/InternalTask.cc --- metview-5.17.4/metview/src/Desktop/InternalTask.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/InternalTask.cc 2023-07-15 08:28:47.000000000 +0000 @@ -55,7 +55,7 @@ if (waiting_) return; - MvRequest r = object_->fullRequest(); + MvRequest r = object_->fullRequest(); const char* null = nullptr; if (null == r("_NAME")) diff -Nru metview-5.17.4/metview/src/Desktop/InternalTask.h metview-5.19.2/metview/src/Desktop/InternalTask.h --- metview-5.17.4/metview/src/Desktop/InternalTask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/InternalTask.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,12 +20,12 @@ { public: InternalTask(const Action&, IconObject*); - virtual ~InternalTask(); + ~InternalTask() override; - virtual void addContext(const Request&) {} + void addContext(const Request&) override {} protected: - void print(std::ostream&) const; + void print(std::ostream&) const override; private: // No copy allowed @@ -33,16 +33,16 @@ InternalTask& operator=(const InternalTask&); void check(); - virtual void start(); - virtual void success(Task*, const Request&); - virtual void failure(Task*, const Request&); + void start() override; + void success(Task*, const Request&) override; + void failure(Task*, const Request&) override; Action action_; IconObjectH object_; bool error_; int waiting_; - typedef std::map Map; + using Map = std::map; Map tasks_; }; diff -Nru metview-5.17.4/metview/src/Desktop/Items.cc metview-5.19.2/metview/src/Desktop/Items.cc --- metview-5.17.4/metview/src/Desktop/Items.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Items.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ Items::Items(request* r) : r_(r), - object_(0) + object_(nullptr) { items[get_value(r, "name", 0)] = this; } @@ -60,13 +60,13 @@ IconObject* Items::object() { - if (object_ != 0) + if (object_ != nullptr) return object_; const char* kind = get_value(r_, "class", 0); const char* full = get_value(r_, "full_name", 0); - //const char *x = get_value(r_,"x",0); - //const char *y = get_value(r_,"y",0); + // const char *x = get_value(r_,"x",0); + // const char *y = get_value(r_,"y",0); const char* link = get_value(r_, "linked_to", 0); object_ = IconObject::search(full); @@ -75,21 +75,21 @@ if (link) { Path path = Folder::top()->path(); - path = path.add(full); + path = path.add(full); path.symlink(std::string(link)); } object_ = IconFactory::create(full, IconClass::find(kind)); /*if(object_) { - if(x && y) object_->parent()->position(object_,atol(x),atol(y)); - return object_; - }*/ + if(x && y) object_->parent()->position(object_,atol(x),atol(y)); + return object_; + }*/ return object_; - Log::error(0) << "Cannot create " << full << std::endl; - return 0; + Log::error(nullptr) << "Cannot create " << full << std::endl; + return nullptr; } diff -Nru metview-5.17.4/metview/src/Desktop/Items.h metview-5.19.2/metview/src/Desktop/Items.h --- metview-5.17.4/metview/src/Desktop/Items.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Items.h 2023-07-15 08:28:47.000000000 +0000 @@ -41,5 +41,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(Items); +// OS_MARK_SCHEMA_TYPE(Items); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/LineFactory.cc metview-5.19.2/metview/src/Desktop/LineFactory.cc --- metview-5.17.4/metview/src/Desktop/LineFactory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/LineFactory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,11 +15,11 @@ #include "MvQTextLine.h" -static std::map* makers = 0; +static std::map* makers = nullptr; LineFactory::LineFactory(const std::string& name) { - if (makers == 0) + if (makers == nullptr) makers = new std::map; // Put in reverse order... @@ -31,13 +31,13 @@ MvQRequestPanelLine* LineFactory::create(RequestPanel& e, const MvIconParameter& p) { const char* o = p.interface(); - if (o != 0) { + if (o != nullptr) { auto j = makers->find(o); if (j != makers->end()) return (*j).second->make(e, p); } - //Default + // Default return new MvQTextLine(e, p); - //return new MvQLineEditItem(e,p) ; + // return new MvQLineEditItem(e,p) ; } diff -Nru metview-5.17.4/metview/src/Desktop/LineFactory.h metview-5.19.2/metview/src/Desktop/LineFactory.h --- metview-5.17.4/metview/src/Desktop/LineFactory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/LineFactory.h 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ template class LineMaker : public LineFactory { - MvQRequestPanelLine* make(RequestPanel& e, const MvIconParameter& p) { return new T(e, p); } + MvQRequestPanelLine* make(RequestPanel& e, const MvIconParameter& p) override { return new T(e, p); } public: LineMaker(const std::string& name) : diff -Nru metview-5.17.4/metview/src/Desktop/Log.cc metview-5.19.2/metview/src/Desktop/Log.cc --- metview-5.17.4/metview/src/Desktop/Log.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Log.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,10 +12,10 @@ #include #include "fstream_mars_fix.h" -#include -#include -#include -#include +#include +#include +#include +#include #include "Folder.h" #include "TeeStream.h" @@ -25,10 +25,10 @@ // which platform require this one? // (not SGI, and Linux get compiler errors // because of different types...!) -//extern char *sys_errlist[]; -//extern const int sys_nerr; +// extern char *sys_errlist[]; +// extern const int sys_nerr; -//static std::string logTimeStamp(); +// static std::string logTimeStamp(); Log::Log(IconObject* o) : path_(::marstmp()), @@ -45,10 +45,10 @@ { static std::ostream* g = nullptr; if (g == nullptr) { - g = &std::cout; // Avoid recursion + g = &std::cout; // Avoid recursion std::string p = Folder::top()->logPath().str(); - g = new std::ofstream(p.c_str(), std::ios::app); - //Folder::top()->showLog(); + g = new std::ofstream(p.c_str(), std::ios::app); + // Folder::top()->showLog(); } return *g; } @@ -60,7 +60,7 @@ tee_ = std::unique_ptr(new TeeStream(global(), *out_)); } - //Add time stamp + // Add time stamp //*out_ << logTimeStamp(); global() << "[" << object_->name() << "] "; @@ -93,8 +93,8 @@ { return find(o); - //if(o == 0) o = Folder::top(); - //return o->log() << "A"; + // if(o == 0) o = Folder::top(); + // return o->log() << "A"; } std::ostream& Log::warning(IconObject* o) @@ -125,13 +125,13 @@ } /*std::string logTimeStamp() -{ - time_t t = time(0); - struct tm* now = localtime(&t); - char buf[7]; - strftime(buf, sizeof(buf),"%H:%M",now); - - string str; - str=string(buf); - return str; +{ + time_t t = time(0); + struct tm* now = localtime(&t); + char buf[7]; + strftime(buf, sizeof(buf),"%H:%M",now); + + string str; + str=string(buf); + return str; }*/ diff -Nru metview-5.17.4/metview/src/Desktop/Log.h metview-5.19.2/metview/src/Desktop/Log.h --- metview-5.17.4/metview/src/Desktop/Log.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Log.h 2023-07-15 08:28:47.000000000 +0000 @@ -53,5 +53,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(Log); +// OS_MARK_SCHEMA_TYPE(Log); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/MacroGuiObject.h metview-5.19.2/metview/src/Desktop/MacroGuiObject.h --- metview-5.17.4/metview/src/Desktop/MacroGuiObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MacroGuiObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,16 +18,16 @@ class MacroGuiObject : public IconClass { public: - MacroGuiObject(const Request& lang, const IconClass* = 0); - virtual ~MacroGuiObject(); + MacroGuiObject(const Request& lang, const IconClass* = nullptr); + ~MacroGuiObject() override; private: // No copy allowed MacroGuiObject(const MacroGuiObject&); MacroGuiObject& operator=(const MacroGuiObject&); - virtual MvIconLanguage& language() const; - virtual std::string editor() const; + MvIconLanguage& language() const override; + std::string editor() const override; MvIconLanguage lang_; IconMaker maker_; diff -Nru metview-5.17.4/metview/src/Desktop/MacroObject.h metview-5.19.2/metview/src/Desktop/MacroObject.h --- metview-5.17.4/metview/src/Desktop/MacroObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MacroObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ const IconClass& kind, const std::string& name, IconInfo* info); - virtual ~MacroObject(); + ~MacroObject() override; private: void createFiles() override; diff -Nru metview-5.17.4/metview/src/Desktop/MacroParamEditor.cc metview-5.19.2/metview/src/Desktop/MacroParamEditor.cc --- metview-5.17.4/metview/src/Desktop/MacroParamEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MacroParamEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ layout->setContentsMargins(1, 1, 1, 1); model_ = new MvQIconHolderModel(classes, this); - view_ = new MvQIconHolderView(model_, 0, this); + view_ = new MvQIconHolderView(model_, nullptr, this); QString title(tr("Icons: ")); for (auto it = classes.begin(); it != classes.end(); ++it) { @@ -58,7 +58,7 @@ std::vector lst; lst.push_back(obj); - //This will clear the unwanted iconobjects!! + // This will clear the unwanted iconobjects!! model_->setIcons(lst); } @@ -71,7 +71,7 @@ if (vals.size() > 0) owner_->editMacro(vals[0]); else - owner_->editMacro(0); + owner_->editMacro(nullptr); } //============================== @@ -85,15 +85,15 @@ paramPanelArea_(nullptr), paramPanel_(nullptr) { - //Macro drop panel + // Macro drop panel std::vector mc; - mc.push_back("MACRO"); + mc.emplace_back("MACRO"); macroDropWidget_ = new MvQMacroParamDropWidget(this, mc, this); centralLayout_->addWidget(macroDropWidget_); centralLayout_->addStretch(1); - //Params panel + // Params panel classes_.push_back(kind.name()); } @@ -127,7 +127,7 @@ if (paramPanelArea_) { centralLayout_->removeWidget(paramPanelArea_); delete paramPanelArea_; - paramPanelArea_ = 0; + paramPanelArea_ = nullptr; centralLayout_->setStretch(1, 1); } } @@ -136,7 +136,7 @@ MacroParamObject* MacroParamEditor::macroParamObject() const { IconObject* cur = current_; - return static_cast(cur); + return dynamic_cast(cur); } IconObject* MacroParamEditor::copy(const std::string& /*name*/) @@ -145,7 +145,7 @@ panel_->apply(); o->request(panel_->request()); return o;*/ - return 0; + return nullptr; } void MacroParamEditor::apply() @@ -165,7 +165,7 @@ void MacroParamEditor::reset() { MacroParamObject* obj = macroParamObject(); - state_ = obj->state(); + state_ = obj->state(); editMacro(state_->macro()); } @@ -173,9 +173,9 @@ { if (macro_) macro_->removeObserver(this); - macro_ = 0; + macro_ = nullptr; deleteParamPanel(); - state_ = 0; + state_ = nullptr; } void MacroParamEditor::editMacro(IconObjectH macro) @@ -187,25 +187,25 @@ if (macro) { macroDropWidget_->reset(macro); - //macroArea_.add(macro); + // macroArea_.add(macro); macro_->addObserver(this); } state_->macro(macro); - //Update param panel + // Update param panel createParamPanel(); } void MacroParamEditor::replace(IconObjectH /*obj*/) { - //panel_->replace(obj); + // panel_->replace(obj); } void MacroParamEditor::merge(IconObjectH /*obj*/) { - //panel_->merge(obj); + // panel_->merge(obj); } void MacroParamEditor::slotIconDropped(IconObject* obj) @@ -215,23 +215,23 @@ void MacroParamEditor::iconEdited(IconObject* /*o*/) { - //macroArea_.openIcon(o); + // macroArea_.openIcon(o); } void MacroParamEditor::iconChanged(IconObject* o) { MvQEditor::iconChanged(o); - //editMacro(o); + // editMacro(o); } void MacroParamEditor::iconDestroyed(IconObject* /*o*/) { - //editMacro(0); + // editMacro(0); } void MacroParamEditor::iconClosed(IconObject* /*o*/) { - //macroArea_.closeIcon(o); + // macroArea_.closeIcon(o); } static EditorMaker editorMaker("TwoLevelsEditor"); diff -Nru metview-5.17.4/metview/src/Desktop/MacroParamEditor.h metview-5.19.2/metview/src/Desktop/MacroParamEditor.h --- metview-5.17.4/metview/src/Desktop/MacroParamEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MacroParamEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ Q_OBJECT public: - MvQMacroParamDropWidget(MacroParamEditor*, const std::vector&, QWidget* parent = 0); + MvQMacroParamDropWidget(MacroParamEditor*, const std::vector&, QWidget* parent = nullptr); void reset(IconObjectH); public slots: @@ -50,7 +50,7 @@ public: MacroParamEditor(const IconClass&, const std::string&); - virtual ~MacroParamEditor(); + ~MacroParamEditor() override; void editMacro(IconObjectH); IconObject* macro() const; @@ -59,12 +59,12 @@ void slotIconDropped(IconObject*); protected slots: - void slotFilterItems(QString) {} - void slotShowDisabled(bool) {} + void slotFilterItems(QString) override {} + void slotShowDisabled(bool) override {} protected: - void readSettings(QSettings&) {} - void writeSettings(QSettings&) {} + void readSettings(QSettings&) override {} + void writeSettings(QSettings&) override {} private: // No copy allowed @@ -75,19 +75,19 @@ void createParamPanel(); void deleteParamPanel(); - virtual void apply(); - virtual void reset(); - virtual void close(); - virtual void replace(IconObjectH); - virtual void merge(IconObjectH); + void apply() override; + void reset() override; + void close() override; + void replace(IconObjectH) override; + void merge(IconObjectH) override; virtual IconObject* copy(const std::string&); - //Iconobserver methods - virtual void iconEdited(IconObject*); - virtual void iconClosed(IconObject*); - virtual void iconChanged(IconObject*); - virtual void iconDestroyed(IconObject*); + // Iconobserver methods + void iconEdited(IconObject*) override; + void iconClosed(IconObject*) override; + void iconChanged(IconObject*) override; + void iconDestroyed(IconObject*) override; MvQMacroParamDropWidget* macroDropWidget_; QScrollArea* paramPanelArea_; diff -Nru metview-5.17.4/metview/src/Desktop/MacroParamObject.cc metview-5.19.2/metview/src/Desktop/MacroParamObject.cc --- metview-5.17.4/metview/src/Desktop/MacroParamObject.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MacroParamObject.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,15 +36,15 @@ MacroParamState* MacroParamObject::state() const { auto* self = const_cast(this); - //if(state_ == 0) + // if(state_ == 0) { - IconObject* macro = 0; + IconObject* macro = nullptr; Request r(path()); const char* name = r("MACRO"); if (name) { std::string fullName = makeFullName(name); - macro = IconObject::search(fullName); + macro = IconObject::search(fullName); } self->state_ = new MacroParamState(self, macro, r.advance()); @@ -66,7 +66,7 @@ const char* name = s("MACRO"); if (name) { std::string fullName = makeFullName(name); - IconObject* macro = IconObject::search(fullName); + IconObject* macro = IconObject::search(fullName); if (macro) s("MACRO") = macro->request(); } diff -Nru metview-5.17.4/metview/src/Desktop/MacroParamObject.h metview-5.19.2/metview/src/Desktop/MacroParamObject.h --- metview-5.17.4/metview/src/Desktop/MacroParamObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MacroParamObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ MacroParamObject(Folder* parent, const IconClass& kind, const std::string& name, IconInfo* info); - virtual ~MacroParamObject(); + ~MacroParamObject() override; MacroParamState* state() const; void state(MacroParamState*); diff -Nru metview-5.17.4/metview/src/Desktop/MacroParamState.cc metview-5.19.2/metview/src/Desktop/MacroParamState.cc --- metview-5.17.4/metview/src/Desktop/MacroParamState.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MacroParamState.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ void MacroParamState::request(const Request& r) { request_ = r; - temp_ = nullptr; + temp_ = nullptr; } IconObject* MacroParamState::iconObject() @@ -70,14 +70,14 @@ MvRequest r = requests(); - r("_NAME") = owner_->fullName().c_str(); - r("_CLASS") = owner_->iconClass().name().c_str(); - r("_ACTION") = "edit"; + r("_NAME") = owner_->fullName().c_str(); + r("_CLASS") = owner_->iconClass().name().c_str(); + r("_ACTION") = "edit"; r("_SERVICE") = "macro"; r.print(); - int error; + int error = 0; Request result = MvApplication::waitService("macro", r, error); result.print(); @@ -87,8 +87,8 @@ Request MacroParamState::requests() const { if (!macro_) { - //Log::error(owner_) << "Missing macro icon" << std::endl; - return Request(""); + // Log::error(owner_) << "Missing macro icon" << std::endl; + return {""}; } Request r("MACROPARAM"); @@ -101,7 +101,7 @@ { if (!class_) { Request i = interface(); - class_ = new MacroGuiObject(i, &owner_->iconClass()); + class_ = new MacroGuiObject(i, &owner_->iconClass()); } return *class_; } diff -Nru metview-5.17.4/metview/src/Desktop/MacroParamState.h metview-5.19.2/metview/src/Desktop/MacroParamState.h --- metview-5.17.4/metview/src/Desktop/MacroParamState.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MacroParamState.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ { public: MacroParamState(IconObject*, IconObject*, const Request&); - ~MacroParamState(); + ~MacroParamState() override; const IconClass& iconClass(); IconObject* iconObject(); @@ -45,6 +45,6 @@ class MacroParamStateH : public Handle { public: - MacroParamStateH(MacroParamState* o = 0) : + MacroParamStateH(MacroParamState* o = nullptr) : Handle(o) {} }; diff -Nru metview-5.17.4/metview/src/Desktop/MessageObserver.cc metview-5.19.2/metview/src/Desktop/MessageObserver.cc --- metview-5.17.4/metview/src/Desktop/MessageObserver.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MessageObserver.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ class MessageHandler : public MvMessage { - void callback(MvRequest& r); + void callback(MvRequest& r) override; }; void MessageHandler::callback(MvRequest& in) diff -Nru metview-5.17.4/metview/src/Desktop/MessageObserver.h metview-5.19.2/metview/src/Desktop/MessageObserver.h --- metview-5.17.4/metview/src/Desktop/MessageObserver.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MessageObserver.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ { public: MessageObserver(); - virtual ~MessageObserver(); + ~MessageObserver() override; virtual void message(const Request&) = 0; void observe(); diff -Nru metview-5.17.4/metview/src/Desktop/MethodCommand.cc metview-5.19.2/metview/src/Desktop/MethodCommand.cc --- metview-5.17.4/metview/src/Desktop/MethodCommand.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MethodCommand.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,8 @@ } static MethodCommand editCmd("edit", &IconObject::edit); -//static MethodCommand copyCmd("copy",&IconObject::duplicate); -//static MethodCommand cutCmd("cut",&IconObject::duplicate); +// static MethodCommand copyCmd("copy",&IconObject::duplicate); +// static MethodCommand cutCmd("cut",&IconObject::duplicate); static MethodCommand duplicateCmd("duplicate", &IconObject::duplicate); static MethodCommand deleteCmd("delete", &IconObject::toWastebasket); static MethodCommand infoCmd("log", &IconObject::showLog); diff -Nru metview-5.17.4/metview/src/Desktop/MethodCommand.h metview-5.19.2/metview/src/Desktop/MethodCommand.h --- metview-5.17.4/metview/src/Desktop/MethodCommand.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MethodCommand.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,12 +14,12 @@ class MethodCommand : public Command { public: - typedef void (IconObject::*Proc)(); + using Proc = void (IconObject::*)(); MethodCommand(const std::string&, Proc); - virtual ~MethodCommand(); + ~MethodCommand() override; - virtual void execute(IconObject*); + void execute(IconObject*) override; static void execute(const std::string&, IconObject*); protected: diff -Nru metview-5.17.4/metview/src/Desktop/MetviewService.h metview-5.19.2/metview/src/Desktop/MetviewService.h --- metview-5.17.4/metview/src/Desktop/MetviewService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MetviewService.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,14 +18,14 @@ { public: MetviewService(const std::string&); - virtual ~MetviewService(); + ~MetviewService() override; private: // No copy allowed MetviewService(const MetviewService&); MetviewService& operator=(const MetviewService&); - virtual Task* task(const Action&, IconObject*); + Task* task(const Action&, IconObject*) override; }; inline void destroy(MetviewService**) {} diff -Nru metview-5.17.4/metview/src/Desktop/MetviewTask.cc metview-5.19.2/metview/src/Desktop/MetviewTask.cc --- metview-5.17.4/metview/src/Desktop/MetviewTask.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MetviewTask.cc 2023-07-15 08:28:47.000000000 +0000 @@ -68,7 +68,7 @@ #endif MvRequest r = object_->fullRequest(); - const char* null = 0; + const char* null = nullptr; if (null == r("_NAME")) r("_NAME") = object_->fullName().c_str(); @@ -94,19 +94,19 @@ std::cout << " <--- send " << *this << std::endl; } -//Sends a special progress message back to Desktop to indicate that the -//GUI app started up. Desktop then turns the icon green. Otherwise the icon would stay -//orange and all other actions would be blocked on it until the GUI finishes!! -//Ideally we should send a reply back to Desktop but this CAN ONLY BE SENT when -//the forked process (the GUI) has finished!!! +// Sends a special progress message back to Desktop to indicate that the +// GUI app started up. Desktop then turns the icon green. Otherwise the icon would stay +// orange and all other actions would be blocked on it until the GUI finishes!! +// Ideally we should send a reply back to Desktop but this CAN ONLY BE SENT when +// the forked process (the GUI) has finished!!! void MetviewTask::progress(const Request& r) { if (const char* v = r.getVerb()) { - //When a GUI_STARTED request is received in progress() it means - //the interactive (GUI) app we requested for has been started up and we can - //regard this task as finished and can tun the icon green so that it could - //receive another action. This typically happens when we start up an examiner. + // When a GUI_STARTED request is received in progress() it means + // the interactive (GUI) app we requested for has been started up and we can + // regard this task as finished and can tun the icon green so that it could + // receive another action. This typically happens when we start up an examiner. if (strcmp(v, "GUI_STARTED") == 0) { Task::success(r); } @@ -127,7 +127,7 @@ if (r) { IconObjectH o = IconFactory::createTemporary(object_, r); - TaskH t = o->action(action_); + TaskH t = o->action(action_); } if (err) diff -Nru metview-5.17.4/metview/src/Desktop/MetviewTask.h metview-5.19.2/metview/src/Desktop/MetviewTask.h --- metview-5.17.4/metview/src/Desktop/MetviewTask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MetviewTask.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,12 +22,12 @@ { public: MetviewTask(const std::string&, const Action&, IconObject*); - virtual ~MetviewTask(); + ~MetviewTask() override; - void addContext(const Request& req) { context_ = req; } + void addContext(const Request& req) override { context_ = req; } protected: - void print(std::ostream&) const; + void print(std::ostream&) const override; private: // No copy allowed @@ -43,22 +43,22 @@ int waiting_; Request context_; - typedef std::map Map; + using Map = std::map; Map tasks_; // -- Overridden methods // From Task - virtual void start(); + void start() override; // From ReplyObserver - virtual void reply(const Request&, int); - virtual void progress(const Request&); - virtual void message(const std::string&); + void reply(const Request&, int) override; + void progress(const Request&) override; + void message(const std::string&) override; // From TaskObserver - virtual void success(Task*, const Request&); - virtual void failure(Task*, const Request&); + void success(Task*, const Request&) override; + void failure(Task*, const Request&) override; }; inline void destroy(MetviewTask**) {} diff -Nru metview-5.17.4/metview/src/Desktop/MvMainQtBrowser.cc metview-5.19.2/metview/src/Desktop/MvMainQtBrowser.cc --- metview-5.17.4/metview/src/Desktop/MvMainQtBrowser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvMainQtBrowser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,8 @@ { auto* app = new MvQDesktop(argc, argv, "Desktop"); - //Initialise resorces from a static library (libMvQtGui) - //Q_INIT_RESOURCE(edit); + // Initialise resorces from a static library (libMvQtGui) + // Q_INIT_RESOURCE(edit); QPixmap pixmap(":/desktop/splash_screen.png"); QSplashScreen splash(pixmap); diff -Nru metview-5.17.4/metview/src/Desktop/MvQActionList.h metview-5.19.2/metview/src/Desktop/MvQActionList.h --- metview-5.17.4/metview/src/Desktop/MvQActionList.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQActionList.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ class MvQActionList { public: - MvQActionList() {} + MvQActionList() = default; void add(QAction* ac) { lst_ << ac; } bool trigger(QString); QAction* action(QString); diff -Nru metview-5.17.4/metview/src/Desktop/MvQAdvancedSearch.cc metview-5.19.2/metview/src/Desktop/MvQAdvancedSearch.cc --- metview-5.17.4/metview/src/Desktop/MvQAdvancedSearch.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQAdvancedSearch.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,7 +41,7 @@ #include "MvQMethods.h" #include "Folder.h" -MvQAdvancedSearchDialog* MvQAdvancedSearchDialog::dialog_ = 0; +MvQAdvancedSearchDialog* MvQAdvancedSearchDialog::dialog_ = nullptr; QList MvQAdvancedSearchDialog::iconClasses_; void MvQAdvancedSearchDialog::open(QWidget* callerWidget, Folder* folder) @@ -56,9 +56,9 @@ } MvQAdvancedSearchDialog::MvQAdvancedSearchDialog(QWidget* callerWidget, Folder* folder) : - QDialog(0), + QDialog(nullptr), caller_(callerWidget), - finder_(0) + finder_(nullptr) { QString currentRelPath("/"); @@ -77,7 +77,7 @@ auto* leftVb = new QVBoxLayout; hb->addLayout(leftVb, 1); - //Tabs + // Tabs auto* tab = new QTabWidget(this); leftVb->addWidget(tab); @@ -85,10 +85,10 @@ tab->addTab(buildContentsTab(), tr("&Contents")); tab->addTab(buildPropTab(), tr("&Properties")); - //Some init + // Some init folderLe_->setText(currentRelPath); - //Results view + // Results view resTree_ = new QTreeWidget(this); resTree_->setRootIsDecorated(false); resTree_->setUniformRowHeights(true); @@ -100,7 +100,7 @@ resTree_->setHeaderLabels(headers); leftVb->addWidget(resTree_, 1); - //Context menu + // Context menu resTree_->setContextMenuPolicy(Qt::CustomContextMenu); connect(resTree_, SIGNAL(customContextMenuRequested(const QPoint&)), @@ -130,7 +130,7 @@ buttonVb->addStretch(1); //------------------- - //Buttonbox + // Buttonbox //------------------- auto* buttonBox = new QDialogButtonBox(this); @@ -152,16 +152,16 @@ findProgress_->hide(); statusMessageLabel_ = new QLabel(""); - //statusMessageLabel_->setTextInteractionFlags(Qt::TextSelectableByMouse); + // statusMessageLabel_->setTextInteractionFlags(Qt::TextSelectableByMouse); statusMessageLabel_->setFrameShape(QFrame::NoFrame); - //messageLabel_->setMinimumSize(messageLabel_->sizeHint()); + // messageLabel_->setMinimumSize(messageLabel_->sizeHint()); statusHb->addWidget(statusMessageLabel_, 1); - //Init + // Init findPb_->setEnabled(true); cancelPb_->setEnabled(false); - //Populate type combo + // Populate type combo loadTypeCb(); readSettings(); @@ -169,7 +169,7 @@ MvQAdvancedSearchDialog::~MvQAdvancedSearchDialog() { - dialog_ = 0; + dialog_ = nullptr; } QWidget* MvQAdvancedSearchDialog::buildMainTab() @@ -187,9 +187,9 @@ int colSpan = 2; - //Folder + // Folder auto* label = new QLabel(tr("&Folder:")); - folderLe_ = new MvQLineEdit(this); + folderLe_ = new MvQLineEdit(this); label->setBuddy(folderLe_); gridLayout->addWidget(label, row, 0); gridLayout->addWidget(folderLe_, row, 1, 1, colSpan); @@ -214,16 +214,16 @@ gridLayout->addWidget(caseCheck_, row, 2); row++; - //Name - label = new QLabel(tr("&Name:")); + // Name + label = new QLabel(tr("&Name:")); nameLe_ = new MvQLineEdit(this); label->setBuddy(nameLe_); gridLayout->addWidget(label, row, 0); gridLayout->addWidget(nameLe_, row, 1, 1, colSpan); row++; - //Type - label = new QLabel(tr("&Type:")); + // Type + label = new QLabel(tr("&Type:")); typeTextRb_ = new QRadioButton("Define by &text"); typeListRb_ = new QRadioButton("Select from &list"); label->setBuddy(typeTextRb_); @@ -234,7 +234,7 @@ row++; typeStacked_ = new QStackedLayout(); - typeLe_ = new MvQLineEdit(this); + typeLe_ = new MvQLineEdit(this); typeStacked_->addWidget(typeLe_); typeCb_ = new QComboBox(this); typeStacked_->addWidget(typeCb_); @@ -251,7 +251,7 @@ connect(typeListRb_, SIGNAL(toggled(bool)), this, SLOT(slotTypeRadio(bool))); - //Init + // Init typeTextRb_->toggle(); return w; } @@ -270,9 +270,9 @@ int row = 0; - //Contains + // Contains auto* label = new QLabel(tr("&Containing text:")); - contLe_ = new MvQLineEdit(this); + contLe_ = new MvQLineEdit(this); label->setBuddy(contLe_); gridLayout->addWidget(label, row, 0); gridLayout->addWidget(contLe_, row, 1); @@ -292,14 +292,14 @@ gridLayout->setColumnStretch(2, 1); gridLayout->setColumnStretch(3, 1); gridLayout->setColumnStretch(4, 1); - //gridLayout->setSpacing(); + // gridLayout->setSpacing(); auto* w = new QWidget(this); w->setLayout(gridLayout); int row = 0; - //Date + // Date dateCheck_ = new QCheckBox(tr("&Modified:")); gridLayout->addWidget(dateCheck_, row, 0, 1, 5); dateCheck_->setChecked(true); @@ -308,11 +308,11 @@ connect(dateCheck_, SIGNAL(stateChanged(int)), this, SLOT(slotUpdateDateBox(int))); - //Period - periodRb_ = new QRadioButton("&from"); + // Period + periodRb_ = new QRadioButton("&from"); auto* label = new QLabel(tr("to")); - fromDateE_ = new QDateEdit(QDate::currentDate(), this); - toDateE_ = new QDateEdit(QDate::currentDate(), this); + fromDateE_ = new QDateEdit(QDate::currentDate(), this); + toDateE_ = new QDateEdit(QDate::currentDate(), this); dateBoxTop_ << periodRb_ << label << fromDateE_ << toDateE_; @@ -325,7 +325,7 @@ gridLayout->addWidget(toDateE_, row, 4); row++; - //Duration + // Duration durationRb_ = new QRadioButton("&during the last"); durationSp_ = new QSpinBox(this); durationCb_ = new QComboBox(this); @@ -352,10 +352,10 @@ connect(durationRb_, SIGNAL(toggled(bool)), this, SLOT(slotDateRadio(bool))); - //Size - label = new QLabel(tr("&Size:")); - sizeOperCb_ = new QComboBox(this); - sizeValSp_ = new QSpinBox(this); + // Size + label = new QLabel(tr("&Size:")); + sizeOperCb_ = new QComboBox(this); + sizeValSp_ = new QSpinBox(this); sizeUnitsCb_ = new QComboBox(this); label->setBuddy(sizeOperCb_); @@ -380,15 +380,15 @@ connect(sizeOperCb_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateSizeBox(int))); - //Owner - label = new QLabel(tr("&Owner:")); + // Owner + label = new QLabel(tr("&Owner:")); ownerLe_ = new MvQLineEdit(this); label->setBuddy(ownerLe_); gridLayout->addWidget(label, row, 0, 1, 2); gridLayout->addWidget(ownerLe_, row, 2); - //group - label = new QLabel(tr("&Group:")); + // group + label = new QLabel(tr("&Group:")); groupLe_ = new MvQLineEdit(this); label->setBuddy(groupLe_); gridLayout->addWidget(label, row, 3); @@ -397,7 +397,7 @@ row++; - //Init + // Init periodRb_->toggle(); dateCheck_->setChecked(false); sizeOperCb_->setCurrentIndex(-1); @@ -437,22 +437,22 @@ options.type = typeLe_->text().toLower().toStdString(); } else { - int idxT; + int idxT = 0; if ((idxT = typeCb_->currentIndex()) > 0) { - options.type = typeCb_->itemData(idxT).toString().toStdString(); + options.type = typeCb_->itemData(idxT).toString().toStdString(); options.strictType = true; } } - options.contentText = contLe_->text().toStdString(); + options.contentText = contLe_->text().toStdString(); options.contentCaseSensitive = contentsCaseCheck_->isChecked(); - options.includeSub = subFolderCheck_->isChecked(); - options.followLinks = (linkCheck_->isEnabled()) ? linkCheck_->isChecked() : false; - options.includeSys = (sysCheck_->isEnabled()) ? sysCheck_->isChecked() : false; + options.includeSub = subFolderCheck_->isChecked(); + options.followLinks = (linkCheck_->isEnabled()) ? linkCheck_->isChecked() : false; + options.includeSys = (sysCheck_->isEnabled()) ? sysCheck_->isChecked() : false; options.caseSensitive = caseCheck_->isChecked(); - //Date + // Date if (dateCheck_->isChecked()) { options.useTime = true; if (periodRb_->isChecked()) { @@ -477,32 +477,32 @@ #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) options.toTime = dt.toSecsSinceEpoch(); #else - options.toTime = dt.toTime_t(); + options.toTime = dt.toTime_t(); #endif } else { QDateTime dt = QDateTime::currentDateTime(); - int v = durationSp_->value(); - int idxD; + int v = durationSp_->value(); + int idxD = 0; if ((idxD = durationCb_->currentIndex()) > -1) { int unitSec = durationCb_->itemData(idxD).toInt(); #if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) - options.toTime = dt.toSecsSinceEpoch(); + options.toTime = dt.toSecsSinceEpoch(); options.fromTime = dt.toSecsSinceEpoch() - static_cast(unitSec * v); #else - options.toTime = dt.toTime_t(); + options.toTime = dt.toTime_t(); options.fromTime = dt.toTime_t() - static_cast(unitSec * v); #endif } } } - //Size + // Size int idx = sizeOperCb_->currentIndex(); if (idx > 0) { options.sizeOper = sizeOperCb_->itemData(idx).toInt(); - int idxU; + int idxU = 0; if ((idxU = sizeUnitsCb_->currentIndex()) > -1) { options.size = sizeUnitsCb_->itemData(idxU).toLongLong(); options.size *= sizeValSp_->value(); @@ -580,7 +580,7 @@ foreach (QWidget* w, dateBoxBottom_) w->setEnabled(st); - //Init radio button state + // Init radio button state slotDateRadio(true); } @@ -590,7 +590,7 @@ return; } else { - bool top = true; + bool top = true; bool bottom = true; if (periodRb_->isChecked()) { bottom = false; @@ -673,7 +673,7 @@ if (iconClasses_.count() == 0) { IconClass::scan(*this); - //sort + // sort QMap cmap; foreach (const IconClass* ic, iconClasses_) { cmap[QString::fromStdString(ic->defaultName())] = ic; @@ -723,7 +723,7 @@ else return QString::number(size / (1024 * 1024 * 1024)) + " GB"; - return QString(); + return {}; } QString MvQAdvancedSearchDialog::formatFileDate(time_t t) const @@ -747,7 +747,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-Desktop-AdvancedSearchDialog"); - //We have to clear it so that should not remember all the previous values + // We have to clear it so that should not remember all the previous values settings.clear(); settings.beginGroup("main"); @@ -761,17 +761,17 @@ settings.setValue("caseCheck", caseCheck_->isChecked()); settings.setValue("name", nameLe_->text()); - //Type + // Type int typeMode = typeTextRb_->isChecked() ? 0 : 1; settings.setValue("typeMode", typeMode); settings.setValue("typeText", typeLe_->text()); settings.setValue("typeCb", typeCb_->currentIndex()); - //Contents + // Contents settings.setValue("containing", contLe_->text()); settings.setValue("contentsCaseCheck", contentsCaseCheck_->isChecked()); - //Date + // Date settings.setValue("useDate", dateCheck_->isChecked()); int dateMode = periodRb_->isChecked() ? 0 : 1; settings.setValue("dateMode", dateMode); @@ -780,12 +780,12 @@ settings.setValue("duration", durationSp_->value()); settings.setValue("durationUnits", durationCb_->currentIndex()); - //Size + // Size settings.setValue("sizeOper", sizeOperCb_->currentIndex()); settings.setValue("sizeVal", sizeValSp_->value()); settings.setValue("sizeUnits", sizeUnitsCb_->currentIndex()); - //Owner + // Owner settings.setValue("owner", ownerLe_->text()); settings.setValue("group", groupLe_->text()); @@ -825,7 +825,7 @@ nameLe_->setText(settings.value("name").toString()); - //Type + // Type if (settings.contains("typeMode")) { int typeMode = settings.value("typeMode").toInt(); if (typeMode == 0) { @@ -847,14 +847,14 @@ typeCb_->setCurrentIndex(idx); } - //Contents + // Contents if (settings.contains("containing")) contLe_->setText(settings.value("containing").toString()); if (settings.contains("contentsCaseCheck")) contentsCaseCheck_->setChecked(settings.value("contentsCaseCheck").toBool()); - //Date + // Date if (settings.contains("useDate")) dateCheck_->setChecked(settings.value("useDate").toBool()); @@ -885,7 +885,7 @@ durationCb_->setCurrentIndex(idx); } - //Size + // Size if (settings.contains("sizeOper")) { int idx = settings.value("sizeOper").toInt(); if (idx >= 0 && idx < sizeOperCb_->count()) @@ -901,7 +901,7 @@ sizeUnitsCb_->setCurrentIndex(idx); } - //Owner + // Owner if (settings.contains("owner")) ownerLe_->setText(settings.value("owner").toString()); diff -Nru metview-5.17.4/metview/src/Desktop/MvQAdvancedSearch.h metview-5.19.2/metview/src/Desktop/MvQAdvancedSearch.h --- metview-5.17.4/metview/src/Desktop/MvQAdvancedSearch.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQAdvancedSearch.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,12 +33,12 @@ Q_OBJECT public: - //From ClassScanner - void next(const IconClass&); - static void open(QWidget* parent, Folder* folder = 0); + // From ClassScanner + void next(const IconClass&) override; + static void open(QWidget* parent, Folder* folder = nullptr); public slots: - void reject(); + void reject() override; void slotFind(); void slotCancel(); void itemArrived(QString, QString); @@ -52,10 +52,10 @@ void slotTypeRadio(bool); protected: - MvQAdvancedSearchDialog(QWidget* parent, Folder* folder = 0); - ~MvQAdvancedSearchDialog(); + MvQAdvancedSearchDialog(QWidget* parent, Folder* folder = nullptr); + ~MvQAdvancedSearchDialog() override; - void closeEvent(QCloseEvent* event); + void closeEvent(QCloseEvent* event) override; QString toRelPath(QString path); QString fromRelPath(QString path); QString formatFileSize(qint64 size) const; @@ -63,6 +63,7 @@ void writeSettings(); void readSettings(); +private: QWidget* caller_; MvQLineEdit* folderLe_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQBookmarks.cc metview-5.19.2/metview/src/Desktop/MvQBookmarks.cc --- metview-5.17.4/metview/src/Desktop/MvQBookmarks.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQBookmarks.cc 2023-07-15 08:28:47.000000000 +0000 @@ -44,9 +44,9 @@ #include "MvKeyProfile.h" #include "Path.h" -MvQKeyManager* MvQBookmarks::manager_ = 0; -MvQBookmarksModel* MvQBookmarks::model_ = 0; -MvKeyProfile* MvQBookmarks::prof_ = 0; +MvQKeyManager* MvQBookmarks::manager_ = nullptr; +MvQBookmarksModel* MvQBookmarks::model_ = nullptr; +MvKeyProfile* MvQBookmarks::prof_ = nullptr; //============================================= // @@ -59,7 +59,7 @@ if (!index.isValid() || index.column() != 0 || (role != Qt::DisplayRole && role != Qt::ToolTipRole && role != Qt::DecorationRole && role != Qt::UserRole)) { - return QVariant(); + return {}; } MvKey* key = profile_->at(index.row()); @@ -71,7 +71,7 @@ if (!cntStr.empty()) return "Bookmark for a group of folders"; else { - //Check if path exist + // Check if path exist Path p = Folder::top()->path(); if (p.add(key->name()).exists()) return QString::fromStdString(key->name()); @@ -85,12 +85,12 @@ else if (role == Qt::UserRole) { std::string cntStr = key->metaData("path_count"); if (!cntStr.empty()) - return QVariant(); + return {}; else return QString::fromStdString(key->name()); } - return QVariant(); + return {}; } //================================================ @@ -104,7 +104,7 @@ { } -//Static +// Static void MvQBookmarks::init() { if (manager_) @@ -113,7 +113,7 @@ manager_ = new MvQKeyManager(MvQKeyManager::BookmarkType); manager_->loadProfiles(); - prof_ = 0; + prof_ = nullptr; if (manager_->data().size() > 0) { prof_ = manager_->data().at(0); } @@ -125,14 +125,14 @@ model_ = new MvQBookmarksModel(prof_); } -//Static +// Static MvQContextItemSet* MvQBookmarks::cmSet() { static MvQContextItemSet cm("Bookmarks"); return &cm; } -//Static +// Static void MvQBookmarks::save() { manager_->saveProfiles(); @@ -156,7 +156,7 @@ void MvQBookmarks::defaultCommand(const QModelIndex& index) { MvKeyProfile* prof = model_->profile(); - MvKey* key = 0; + MvKey* key = nullptr; if (prof && index.row() <= static_cast(prof->size() - 1)) { key = prof->at(index.row()); } @@ -179,7 +179,7 @@ return; MvKeyProfile* prof = model_->profile(); - MvKey* key = 0; + MvKey* key = nullptr; if (prof && index.row() <= static_cast(prof->size() - 1)) { key = prof->at(index.row()); } @@ -240,13 +240,13 @@ } } -//Static +// Static bool MvQBookmarks::addItem(MvKey* key) { if (!key) return false; - QDialog* dialog; + QDialog* dialog = nullptr; if (!MvQBookmarks::isFolderGroup(key)) dialog = new MvQBookmarksDialog(key, tr("Add bookmark")); @@ -272,7 +272,7 @@ } -//Static +// Static bool MvQBookmarks::addItem(IconObject* obj) { if (obj && !obj->isFolder()) @@ -287,13 +287,13 @@ return MvQBookmarks::addItem(key); } -//Static +// Static bool MvQBookmarks::addItem(QString path) { if (path.isEmpty()) return false; - Path p = Folder::top()->path(); + Path p = Folder::top()->path(); Path realPath = p.add(path.toStdString()); if (!realPath.exists()) @@ -306,15 +306,15 @@ return MvQBookmarks::addItem(key); } -//Static +// Static bool MvQBookmarks::addItem(QList folderLst) { auto* key = new MvKey; - //Foldergroup bookmarks' name maust be FOLDERGROUP !!! + // Foldergroup bookmarks' name maust be FOLDERGROUP !!! key->setName("FOLDERGROUP"); key->setShortName("Tabs"); - //Set data for the paths + // Set data for the paths key->setMetaData("path_count", QString::number(folderLst.count()).toStdString()); for (int i = 0; i < folderLst.count(); i++) { QString id; @@ -329,10 +329,10 @@ return MvQBookmarks::addItem(key); } -//static +// static bool MvQBookmarks::editItem(QString path) { - bool retVal = false; + bool retVal = false; MvKeyProfile* prof = model_->profile(); if (!prof) return false; @@ -347,7 +347,7 @@ return retVal; } -//static +// static bool MvQBookmarks::editItem(MvKey* key) { if (!key) @@ -368,7 +368,7 @@ } if (accepted) { - //Not too efficient + // Not too efficient model_->profileIsAboutToChange(); model_->setKeyProfile(prof_); } @@ -380,7 +380,7 @@ bool MvQBookmarks::editItem(const QModelIndex& index) { MvKeyProfile* prof = model_->profile(); - MvKey* key = 0; + MvKey* key = nullptr; if (prof && index.isValid() && index.row() <= static_cast(prof->size() - 1)) { key = prof->at(index.row()); } @@ -393,7 +393,7 @@ bool MvQBookmarks::duplicateItem(const QModelIndex& index) { MvKeyProfile* prof = model_->profile(); - MvKey* key = 0; + MvKey* key = nullptr; if (prof && index.isValid() && index.row() <= static_cast(prof->size() - 1)) { key = prof->at(index.row()); } @@ -414,7 +414,7 @@ bool MvQBookmarks::deleteItem(const QModelIndex& index) { MvKeyProfile* prof = model_->profile(); - if (prof == 0 || !index.isValid()) + if (prof == nullptr || !index.isValid()) return false; MvKey* key = prof->at(index.row()); @@ -459,7 +459,7 @@ } } - return 0; + return nullptr; } QString MvQBookmarks::getPath(const QModelIndex& index) @@ -494,7 +494,7 @@ return lst; } -//Static +// Static bool MvQBookmarks::isFolderGroup(MvKey* key) { if (!key) @@ -516,12 +516,12 @@ { actionFolder_ = new QAction(menu_); actionFolder_->setText(tr("Bookmark current &folder")); - //actionFolder_->setShortcut(tr("Ctrl+D")); + // actionFolder_->setShortcut(tr("Ctrl+D")); menu_->addAction(actionFolder_); actionTabs_ = new QAction(menu_); actionTabs_->setText(tr("Bookmark current &tabs")); - //actionTabs_->setShortcut(tr("Ctrl+T")); + // actionTabs_->setShortcut(tr("Ctrl+T")); menu_->addAction(actionTabs_); auto* sep1 = new QAction(this); @@ -530,14 +530,14 @@ actionAdd_ = new QAction(menu_); actionAdd_->setText(tr("New bookmark")); - //addAction->setShortcut(tr("Ctrl+T")); + // addAction->setShortcut(tr("Ctrl+T")); menu_->addAction(actionAdd_); auto* sep = new QAction(this); sep->setSeparator(true); menu_->addAction(sep); - //Populate + // Populate slotUpdate(); connect(model_, SIGNAL(modelReset()), @@ -546,7 +546,7 @@ connect(menu_, SIGNAL(triggered(QAction*)), this, SLOT(slotMenu(QAction*))); - //Context menu + // Context menu menu_->setContextMenuPolicy(Qt::CustomContextMenu); connect(menu_, SIGNAL(customContextMenuRequested(const QPoint&)), @@ -559,7 +559,7 @@ if (!cms) return; - QAction* ac = menu_->actionAt(pos); + QAction* ac = menu_->actionAt(pos); QString path = "path=" + getPath(ac); if (!path.isEmpty()) { @@ -578,7 +578,7 @@ int cnt = model_->rowCount(); for (int i = 0; i < cnt; i++) { - QAction* action; + QAction* action = nullptr; if (lst.count() <= i + 5) { action = new QAction(menu_); menu_->addAction(action); @@ -588,9 +588,9 @@ } QModelIndex index = model_->index(i, 0); - QString name = model_->data(index, Qt::DisplayRole).toString(); - QString tooltip = model_->data(index, Qt::ToolTipRole).toString(); - auto pix = model_->data(index, Qt::DecorationRole).value(); + QString name = model_->data(index, Qt::DisplayRole).toString(); + QString tooltip = model_->data(index, Qt::ToolTipRole).toString(); + auto pix = model_->data(index, Qt::DecorationRole).value(); action->setText(name); action->setToolTip(tooltip); @@ -624,7 +624,7 @@ return MvQBookmarks::getPath(index); } - return QString(); + return {}; } MvKey* MvQBookmarksMenu::getKey(QAction* ac) @@ -634,7 +634,7 @@ return MvQBookmarks::getKey(index); } - return 0; + return nullptr; } QModelIndex MvQBookmarksMenu::getIndex(QAction* ac) @@ -644,7 +644,7 @@ return model_->index(i, 0); } - return QModelIndex(); + return {}; } //================================================ @@ -671,7 +671,7 @@ } auto index = indexAt(MvQ::eventPos(event)); - auto s = model()->data(index, Qt::UserRole).toString(); + auto s = model()->data(index, Qt::UserRole).toString(); if (!s.isEmpty()) { Folder* f = Folder::folder(s.toStdString(), false); @@ -750,8 +750,8 @@ return; } - auto index = indexAt(MvQ::eventPos(event)); - QString s = model()->data(index, Qt::UserRole).toString(); + auto index = indexAt(MvQ::eventPos(event)); + QString s = model()->data(index, Qt::UserRole).toString(); if (!s.isEmpty()) { Folder* f = Folder::folder(s.toStdString(), false); @@ -805,7 +805,7 @@ connect(view_, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(slotDoubleClickItem(const QModelIndex&))); - //Context menu + // Context menu connect(view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotContextMenu(const QPoint&))); } @@ -823,16 +823,16 @@ QModelIndex index = view_->indexAt(pos); - //Desktop action + // Desktop action if (!index.isValid()) { QString selection = MvQContextMenu::instance()->exec(cms->desktop(), view_->mapToGlobal(pos), view_); if (!selection.isEmpty()) command(selection); } - //Icon Actions + // Icon Actions else if (model_->profile() && index.isValid()) { - QString path = "path=" + getPath(index); + QString path = "path=" + getPath(index); QString selection = MvQContextMenu::instance()->exec(cms->icon(), view_->mapToGlobal(pos), view_, "lookupOrOpenInTab", path); @@ -866,7 +866,7 @@ vb->addLayout(grid); auto* label = new QLabel(tr("&Label:")); - labelEdit_ = new QLineEdit; + labelEdit_ = new QLineEdit; label->setBuddy(labelEdit_); if (key_) { labelEdit_->setText(QString::fromStdString(key_->shortName())); @@ -875,7 +875,7 @@ grid->addWidget(label, 0, 0); grid->addWidget(labelEdit_, 0, 1); - label = new QLabel(tr("&Path:")); + label = new QLabel(tr("&Path:")); pathEdit_ = new QLineEdit; label->setBuddy(pathEdit_); if (key_) { @@ -890,7 +890,7 @@ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - //Try to find the optimal dialog width + // Try to find the optimal dialog width QFont font; QFontMetrics fm(font); setMinimumWidth(MvQ::textWidth(fm, tr("Label")) + MvQ::textWidth(fm, pathEdit_->text()) + 100); @@ -900,7 +900,7 @@ void MvQBookmarksDialog::accept() { - QString path = pathEdit_->text(); + QString path = pathEdit_->text(); QString label = labelEdit_->text(); QString errTxt = tr("Failed to create bookmark!"); @@ -941,7 +941,7 @@ vb->addLayout(grid); auto* label = new QLabel(tr("&Label:")); - labelEdit_ = new QLineEdit; + labelEdit_ = new QLineEdit; label->setBuddy(labelEdit_); if (key_) { labelEdit_->setText(QString::fromStdString(key_->shortName())); @@ -950,7 +950,7 @@ grid->addWidget(label, 0, 0); grid->addWidget(labelEdit_, 0, 1); - label = new QLabel(tr("&Paths:")); + label = new QLabel(tr("&Paths:")); pathEdit_ = new QPlainTextEdit; label->setBuddy(pathEdit_); pathEdit_->setPlainText(getPathsFromKey()); @@ -964,11 +964,6 @@ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - //Try to find the optimal dialog width - QFont font; - QFontMetrics fm(font); - //setMinimumWidth(fm.width(tr("Label"))+fm.width(pathEdit_->text())+100); - vb->addWidget(buttonBox); } @@ -1000,7 +995,7 @@ void MvQBookmarksGroupDialog::accept() { - QString path = pathEdit_->toPlainText(); + QString path = pathEdit_->toPlainText(); QString label = labelEdit_->text(); QString errTxt = tr("Failed to create bookmark!"); @@ -1015,13 +1010,13 @@ } if (key_) { - //key_->setName(labelEdit_->text().toStdString()); + // key_->setName(labelEdit_->text().toStdString()); key_->setShortName(label.toStdString()); - //Figure out paths and add it to the key's metadata + // Figure out paths and add it to the key's metadata key_->clearMetaData(); QStringList lst = path.split("\n"); - int cnt = 0; + int cnt = 0; foreach (QString s, lst) { QString p = s.simplified(); if (!p.isEmpty()) { diff -Nru metview-5.17.4/metview/src/Desktop/MvQBookmarks.h metview-5.19.2/metview/src/Desktop/MvQBookmarks.h --- metview-5.17.4/metview/src/Desktop/MvQBookmarks.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQBookmarks.h 2023-07-15 08:28:47.000000000 +0000 @@ -39,8 +39,8 @@ { public: MvQBookmarksModel(MvKeyProfile* prof) : - MvQKeyModel(prof, ShortNameMode, 0) {} - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; + MvQKeyModel(prof, ShortNameMode, nullptr) {} + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; }; @@ -50,7 +50,7 @@ public: MvQBookmarks(QWidget*); - ~MvQBookmarks() {} + ~MvQBookmarks() override = default; static void init(); static void save(); @@ -97,7 +97,7 @@ public: MvQBookmarksMenu(QWidget*, QMenu*); - ~MvQBookmarksMenu() {} + ~MvQBookmarksMenu() override = default; public slots: void slotUpdate(); @@ -119,16 +119,16 @@ class MvQBookmarksView : public QListView { public: - MvQBookmarksView(QWidget* parent = 0); + MvQBookmarksView(QWidget* parent = nullptr); protected: void checkDropTarget(QDropEvent* event); void removeDropTarget(); - void dragEnterEvent(QDragEnterEvent* event); - void dragMoveEvent(QDragMoveEvent* event); - void dragLeaveEvent(QDragLeaveEvent* event); - void dropEvent(QDropEvent* event); + void dragEnterEvent(QDragEnterEvent* event) override; + void dragMoveEvent(QDragMoveEvent* event) override; + void dragLeaveEvent(QDragLeaveEvent* event) override; + void dropEvent(QDropEvent* event) override; }; class MvQBookmarksPanel : public MvQBookmarks @@ -137,7 +137,7 @@ public: MvQBookmarksPanel(QWidget*); - ~MvQBookmarksPanel() {} + ~MvQBookmarksPanel() override = default; QWidget* widget() { return widget_; } @@ -160,11 +160,11 @@ Q_OBJECT public: - MvQBookmarksDialog(MvKey*, QString, QWidget* parent = 0); - ~MvQBookmarksDialog() {} + MvQBookmarksDialog(MvKey*, QString, QWidget* parent = nullptr); + ~MvQBookmarksDialog() override = default; public slots: - void accept(); + void accept() override; protected: MvKey* key_; @@ -177,11 +177,11 @@ Q_OBJECT public: - MvQBookmarksGroupDialog(MvKey*, QString, QWidget* parent = 0); - ~MvQBookmarksGroupDialog() {} + MvQBookmarksGroupDialog(MvKey*, QString, QWidget* parent = nullptr); + ~MvQBookmarksGroupDialog() override = default; public slots: - void accept(); + void accept() override; protected: QString getPathsFromKey(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQBoolLine.cc metview-5.19.2/metview/src/Desktop/MvQBoolLine.cc --- metview-5.17.4/metview/src/Desktop/MvQBoolLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQBoolLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,18 +21,18 @@ MvQRequestPanelLine(owner, param) { radioParent_ = new QWidget(parentWidget_); - layout_ = new QHBoxLayout(); + layout_ = new QHBoxLayout(); layout_->setSpacing(0); layout_->setContentsMargins(1, 1, 1, 1); radioParent_->setLayout(layout_); - owner_.addWidget(radioParent_, row_, 3); + owner_.addWidget(radioParent_, row_, WidgetColumn); - QString strOnVal = "On"; + QString strOnVal = "On"; QString strOffVal = "Off"; - //Radio buttons - radioOn_ = new QRadioButton(strOnVal, radioParent_); + // Radio buttons + radioOn_ = new QRadioButton(strOnVal, radioParent_); radioOff_ = new QRadioButton(strOffVal, radioParent_); layout_->addWidget(radioOn_); layout_->addWidget(radioOff_, 1); @@ -45,8 +45,8 @@ void MvQBoolLine::refresh(const std::vector& values) { - //We need to set both radio buttons because before the event loop - //is started the autoexclusive feature does not work! + // We need to set both radio buttons because before the event loop + // is started the autoexclusive feature does not work! if (values.size() > 0) { char c = values[0][1]; //== ON or on if (c == 'N' || c == 'n') { @@ -61,7 +61,7 @@ } } - //changed_ = false; + // changed_ = false; } void MvQBoolLine::slotStatusChanged(bool) diff -Nru metview-5.17.4/metview/src/Desktop/MvQBoolLine.h metview-5.19.2/metview/src/Desktop/MvQBoolLine.h --- metview-5.17.4/metview/src/Desktop/MvQBoolLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQBoolLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,11 +25,11 @@ public: MvQBoolLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQBoolLine(); + ~MvQBoolLine() override; - QString currentValue() { return QString(); } + QString currentValue() { return {}; } void addValue(QString) {} - void refresh(const std::vector&); + void refresh(const std::vector&) override; public slots: void slotStatusChanged(bool); diff -Nru metview-5.17.4/metview/src/Desktop/MvQColourGradLine.cc metview-5.19.2/metview/src/Desktop/MvQColourGradLine.cc --- metview-5.17.4/metview/src/Desktop/MvQColourGradLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQColourGradLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -49,7 +49,7 @@ painter->setPen(QColor(140, 140, 140)); painter->drawLine(xp + w / 2, yp + h - w, xp - w / 2, yp + h - w); - //Color rect + // Color rect QRect r(xp - w / 2, yp + h - w, w, w); r.adjust(2, 2, -2, -2); painter->setBrush(col); @@ -69,12 +69,12 @@ painter->setRenderHint(QPainter::Antialiasing, true); - //background + // background painter->setPen(Qt::NoPen); painter->setBrush(QColor(242, 243, 255)); painter->drawPolygon(outer.subtracted(inner)); - //outline + // outline painter->setPen(QPen(QColor(20, 20, 20), 1)); painter->setBrush(Qt::NoBrush); painter->drawPolygon(inner); @@ -271,8 +271,8 @@ cells_ << cell; } - bool techChanged = setTechs(techs, false); - bool stepChanged = setSteps(steps, false); + bool techChanged = setTechs(techs, false); + bool stepChanged = setSteps(steps, false); bool wayMethodChanged = setWayMethod(wayMethod, false); bool directionChanged = setDirection(direction, false); @@ -351,7 +351,7 @@ Q_ASSERT(cells_.count() >= 2); for (int i = 0; i < cells_.count(); i++) { - int left = (i > 0) ? ((cells_[i].xp - cells_[i - 1].xp) / 2) : cells_[i].xp + 1; + int left = (i > 0) ? ((cells_[i].xp - cells_[i - 1].xp) / 2) : cells_[i].xp + 1; int right = (i < cells_.count() - 1) ? ((cells_[i + 1].xp - cells_[i].xp) / 2) : width() - cells_[i].xp + 1; Q_ASSERT(left >= 0); Q_ASSERT(right >= 0); @@ -385,16 +385,16 @@ return; } - //check directions + // check directions if (direction_.isEmpty()) setDirection("clockwise", false); - //we will populate it with the new set of colours + // we will populate it with the new set of colours allColours_.clear(); int cellHeight = 16; - int cellGap = 0; - int usedWidth = width(); + int cellGap = 0; + int usedWidth = width(); int usedHeight = height(); pix_ = QPixmap(width(), height()); @@ -414,7 +414,7 @@ } int gradHeight = 0; - gradHeight = usedHeight - cellHeight - 3; + gradHeight = usedHeight - cellHeight - 3; int cellW = 12; if (cells_.count() > 1) { @@ -428,11 +428,11 @@ QRect r(xp, yp, usedWidth, gradHeight); painter.fillRect(r, cells_[0].col); - //if there is only one cell it appears in the middle + // if there is only one cell it appears in the middle cells_[0].xp = width() / 2 - cellW / 2 + 1; cells_[0].yp = yStart + gradHeight + 2; - cells_[0].w = cellW; - cells_[0].h = cellHeight; + cells_[0].w = cellW; + cells_[0].h = cellHeight; cells_[0].render(&painter); return; } @@ -441,7 +441,7 @@ pix_.fill(palette().color(QPalette::Window)); - //Cells + // Cells xp = xStart; yp = yStart + gradHeight + 2; @@ -450,7 +450,7 @@ cells_[i].xp = xp + cellW / 2 + 1; } else if (i == cells_.count() - 1) { - xp = xStart + usedWidth - cellW / 2 - 2; + xp = xStart + usedWidth - cellW / 2 - 2; cells_[i].xp = xp; } else { @@ -458,11 +458,11 @@ } cells_[i].yp = yp; - cells_[i].w = cellW; - cells_[i].h = cellHeight; + cells_[i].w = cellW; + cells_[i].h = cellHeight; cells_[i].render(&painter); - //Gradient + // Gradient if (i > 0) { QColor c1 = cells_[i - 1].col; QColor c2 = cells_[i].col; @@ -508,7 +508,7 @@ } } -//The first block is actBlock=1 !!!! +// The first block is actBlock=1 !!!! void MvQColourGradWidget::renderBlock(QPainter* painter, QColor c1, QColor c2, QString tech, int num, QRect r, int actBlock, int blockNum) { @@ -525,7 +525,7 @@ num = 100; if (wayMethod_ == "both") { - float w = static_cast(r.width()) / (static_cast(num)); + float w = static_cast(r.width()) / (static_cast(num)); float xp = r.x(); for (int i = 0; i < num; i++) { if (i == num - 1) @@ -548,7 +548,7 @@ } else if (wayMethod_ == "ignore") { - float w = static_cast(r.width()) / (static_cast(num)); + float w = static_cast(r.width()) / (static_cast(num)); float xp = r.x(); for (int i = 0; i < num; i++) { if (i == num - 1) @@ -590,7 +590,7 @@ } else if (wayMethod_ == "left") { - float w = static_cast(r.width()) / (static_cast(num)); + float w = static_cast(r.width()) / (static_cast(num)); float xp = r.x(); for (int i = 0; i < num; i++) { if (i == num - 1) @@ -626,7 +626,7 @@ } else if (wayMethod_ == "right") { - float w = static_cast(r.width()) / (static_cast(num)); + float w = static_cast(r.width()) / (static_cast(num)); float xp = r.x(); for (int i = 0; i < num; i++) { if (i == num - 1) @@ -704,7 +704,7 @@ float alpha1 = c1.alphaF(); float alpha2 = c2.alphaF(); - float alpha = alpha1; + float alpha = alpha1; if (c1.alpha() != c2.alpha()) alpha = alpha1 * (1 - p) + alpha2 * p; @@ -737,7 +737,7 @@ float alpha1 = c1.alphaF(); float alpha2 = c2.alphaF(); - float alpha = alpha1; + float alpha = alpha1; if (c1.alpha() != c2.alpha()) alpha = alpha1 * (1 - p) + alpha2 * p; @@ -773,7 +773,7 @@ float alpha1 = c1.alphaF(); float alpha2 = c2.alphaF(); - float alpha = alpha1; + float alpha = alpha1; if (c1.alpha() != c2.alpha()) alpha = alpha1 * (1 - p) + alpha2 * p; @@ -806,7 +806,7 @@ return interpolateHslClockwise(c1, c2, p); } - return QColor(); + return {}; } QColor MvQColourGradWidget::interpolateHslLong(QColor c1, QColor c2, float p) @@ -837,11 +837,11 @@ return interpolateHslAntiClockwise(c1, c2, p); } - return QColor(); + return {}; } -//HCL=Hue,Chroma,Luminence -//Warning: Hue in HCL is naot the same as in HSL +// HCL=Hue,Chroma,Luminence +// Warning: Hue in HCL is naot the same as in HSL QColor MvQColourGradWidget::interpolateHclClockwise(QColor c1, QColor c2, float p) { @@ -865,8 +865,8 @@ } float chroma = chroma1 * (1 - p) + chroma2 * p; - float lumin = lumin1 * (1 - p) + lumin2 * p; - float alpha = alpha1; + float lumin = lumin1 * (1 - p) + lumin2 * p; + float alpha = alpha1; if (c1.alpha() != c2.alpha()) alpha = alpha1 * (1 - p) + alpha2 * p; @@ -874,7 +874,7 @@ QColor res = MvQPalette::fromHclLabF(h, chroma, lumin); res.setAlphaF(alpha); #ifdef DEBUG_MV_MVQCOLOURGRADLINE__ - //qDebug() << "res=" << res; + // qDebug() << "res=" << res; #endif return res; } @@ -903,8 +903,8 @@ } float chroma = chroma1 * (1 - p) + chroma2 * p; - float lumin = lumin1 * (1 - p) + lumin2 * p; - float alpha = alpha1; + float lumin = lumin1 * (1 - p) + lumin2 * p; + float alpha = alpha1; if (c1.alpha() != c2.alpha()) alpha = alpha1 * (1 - p) + alpha2 * p; @@ -968,7 +968,7 @@ return interpolateHclAntiClockwise(c1, c2, p); } - return QColor(); + return {}; } void MvQColourGradWidget::renderCurrentCell(QPainter* painter) @@ -991,7 +991,7 @@ if (currentCell_ >= 0 && currentCell_ < cells_.count()) return cells_[currentCell_].col; - return QColor(); + return {}; } void MvQColourGradWidget::setCurrentColour(QColor col) @@ -1117,7 +1117,7 @@ QColor col2 = cells_[index].col; cells_[index - 1].col = col2; - cells_[index].col = col1; + cells_[index].col = col1; createPixmap(); setCurrentCell(index); @@ -1132,7 +1132,7 @@ QColor col1 = cells_[index].col; QColor col2 = cells_[index + 1].col; - cells_[index].col = col2; + cells_[index].col = col2; cells_[index + 1].col = col1; createPixmap(); @@ -1166,11 +1166,11 @@ bool MvQColourGradWidget::setWayMethod(const std::string& val, bool redraw) { - bool changed = false; + bool changed = false; QString qsVal = QString::fromStdString(val).toLower(); if (wayMethod_ != qsVal) { wayMethod_ = qsVal; - changed = true; + changed = true; } if (changed && redraw) { @@ -1183,11 +1183,11 @@ bool MvQColourGradWidget::setDirection(const std::string& val, bool redraw) { - bool changed = false; + bool changed = false; QString qsVal = QString::fromStdString(val).toLower(); if (direction_ != qsVal) { direction_ = qsVal; - changed = true; + changed = true; } if (changed && redraw) { @@ -1201,7 +1201,7 @@ bool MvQColourGradWidget::setTechs(const std::vector& vals, bool redraw) { bool changed = false; - int valsNum = static_cast(vals.size()); + int valsNum = static_cast(vals.size()); for (int i = 0; i < valsNum; i++) { QString v = QString::fromStdString(vals[i]).toLower(); @@ -1209,7 +1209,7 @@ if (techs_.count() > i) { if (techs_[i] != v) { techs_[i] = v; - changed = true; + changed = true; } } else { @@ -1221,7 +1221,7 @@ if (techs_.count() > i) { if (isTechValid(techs_[i])) { techs_[i] = QString(); - changed = true; + changed = true; } } else { @@ -1250,7 +1250,7 @@ bool MvQColourGradWidget::setSteps(const std::vector& vals, bool redraw) { bool changed = false; - int valsNum = static_cast(vals.size()); + int valsNum = static_cast(vals.size()); for (int i = 0; i < valsNum; i++) { int v = QString::fromStdString(vals[i]).toInt(); @@ -1261,7 +1261,7 @@ if (steps_.count() > i) { if (steps_[i] != v) { steps_[i] = v; - changed = true; + changed = true; } } else { @@ -1273,7 +1273,7 @@ if (steps_.count() > i) { if (steps_[i] >= 2) { steps_[i] = 0; - changed = true; + changed = true; } } else { @@ -1339,7 +1339,7 @@ { MvQRequestPanelLine::buildHelper(); - //Customisation + // Customisation if (helper_) helper_->setExternalActions(widget_->actions()); @@ -1365,11 +1365,10 @@ QList colours; for (const auto& value : values) { - QString name = QString::fromStdString(value); colours << MvQPalette::magics(value); } - Request r = owner_.request(); + Request r = owner_.request(); std::vector ways = r.get(waypointParam_.c_str()); std::string wayMethod; if (ways.size() > 0) @@ -1387,7 +1386,7 @@ widget_->reset(colours, wayMethod, tech, direction, steps); } - //changed_ = false; + // changed_ = false; } void MvQColourGradLine::changed(const char* param, const std::vector& vals) @@ -1406,9 +1405,9 @@ widget_->setDirection(val, true); } else if (param && strcmp(param, techParam_.c_str()) == 0) { - //Set directions. In "rgb" mode there is no direction so - //we need to define it when we switch from "rgb" into "hsl" or "hcl". - Request r = owner_.request(); + // Set directions. In "rgb" mode there is no direction so + // we need to define it when we switch from "rgb" into "hsl" or "hcl". + Request r = owner_.request(); std::vector dirs = r.get(directionParam_.c_str()); std::string direction; if (dirs.size() > 0) @@ -1459,7 +1458,6 @@ if (vals.size() == 0) return; - QString name = QString::fromStdString(vals[0]); widget_->setCurrentColour(MvQPalette::magics(vals[0])); } diff -Nru metview-5.17.4/metview/src/Desktop/MvQColourGradLine.h metview-5.19.2/metview/src/Desktop/MvQColourGradLine.h --- metview-5.17.4/metview/src/Desktop/MvQColourGradLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQColourGradLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,7 @@ struct ColorCell { - ColorCell() {} + ColorCell() = default; ColorCell(QColor c) : col(c) {} QColor col; @@ -42,7 +42,7 @@ Q_OBJECT public: - MvQColourGradWidget(QWidget* parent = 0); + MvQColourGradWidget(QWidget* parent = nullptr); void reset(QList, const std::string&, const std::vector&, const std::string&, const std::vector&); QColor currentColour() const; void setCurrentColour(QColor); @@ -72,10 +72,10 @@ void singleCellClicked(); protected: - void resizeEvent(QResizeEvent*); - void changeEvent(QEvent* event); - void paintEvent(QPaintEvent*); - void mousePressEvent(QMouseEvent*); + void resizeEvent(QResizeEvent*) override; + void changeEvent(QEvent* event) override; + void paintEvent(QPaintEvent*) override; + void mousePressEvent(QMouseEvent*) override; void createPixmap(); void renderBlock(QPainter*, QColor c1, QColor c2, QString tech, int num, QRect r, int, int); void renderCurrentCell(QPainter*); @@ -135,23 +135,23 @@ public: MvQColourGradLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQColourGradLine() {} + ~MvQColourGradLine() override = default; - QString currentValue() { return QString(); } - void refresh(const std::vector&); - void changed(const char* param, const std::vector&); - void changed(const char* param, const std::string&); - bool isDependent() const { return true; } + QString currentValue() { return {}; } + void refresh(const std::vector&) override; + void changed(const char* param, const std::vector&) override; + void changed(const char* param, const std::string&) override; + bool isDependent() const override { return true; } public slots: void slotListChanged(); void slotCurrentChanged(QColor); - void slotHelperEdited(const std::vector&); + void slotHelperEdited(const std::vector&) override; void slotSingleCellClicked(); - void slotHelperOpened(bool); + void slotHelperOpened(bool) override; protected: - void buildHelper(); + void buildHelper() override; void updateHelper(); MvQColourGradWidget* widget_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQColourHelp.cc metview-5.19.2/metview/src/Desktop/MvQColourHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQColourHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQColourHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ #include #include -#include +#include #include "HelpFactory.h" #include "RequestPanel.h" @@ -68,7 +68,7 @@ if (values.size() == 0) return; - oriName_ = QString::fromStdString(values[0]); + oriName_ = QString::fromStdString(values[0]); QColor col = MvQPalette::magics(values[0]); if ((selector_->currentColour() == col || @@ -96,7 +96,7 @@ vb->setContentsMargins(1, 1, 1, 1); vb->setSpacing(1); - //Buttons + // Buttons auto* hb = new QHBoxLayout(w_); vb->addLayout(hb); @@ -128,7 +128,7 @@ this, SLOT(slotReset(bool))); - //Colour selector + // Colour selector selector_ = new MvQColourSelectionWidget(w_, true); vb->addWidget(selector_); @@ -144,7 +144,7 @@ void MvQColourListHelp::setExternalActions(QList lst) { - if (auto* hb = static_cast(w_->layout()->itemAt(0))) { + if (auto* hb = dynamic_cast(w_->layout()->itemAt(0))) { foreach (QAction* ac, lst) { if (!ac->isSeparator() && ac->data().toString() != "ignore") { auto* tb = new QToolButton(w_); @@ -228,7 +228,7 @@ vb->setContentsMargins(1, 1, 1, 1); vb->setSpacing(1); - //Buttons + // Buttons auto* hb = new QHBoxLayout(w_); vb->addLayout(hb); @@ -259,7 +259,7 @@ connect(resetTb_, SIGNAL(clicked(bool)), this, SLOT(slotReset(bool))); - //Colour selector + // Colour selector selector_ = new MvQColourSelectionWidget(w_, true); vb->addWidget(selector_); @@ -275,7 +275,7 @@ void MvQColourGradHelp::setExternalActions(QList lst) { - if (auto* hb = static_cast(w_->layout()->itemAt(0))) { + if (auto* hb = dynamic_cast(w_->layout()->itemAt(0))) { foreach (QAction* ac, lst) { if (!ac->isSeparator() && ac->data().toString() != "ignore") { auto* tb = new QToolButton(w_); diff -Nru metview-5.17.4/metview/src/Desktop/MvQColourHelp.h metview-5.19.2/metview/src/Desktop/MvQColourHelp.h --- metview-5.17.4/metview/src/Desktop/MvQColourHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQColourHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -10,7 +10,7 @@ #pragma once -//include "MvQPalette.h" +// include "MvQPalette.h" #include "MvQRequestPanelHelp.h" #include "MvIconParameter.h" @@ -34,17 +34,17 @@ public: MvQColourHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQColourHelp() {} + ~MvQColourHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget(); + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override; public slots: void slotSelected(QColor); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; private: MvQColourSelectionWidget* selector_; @@ -57,19 +57,19 @@ public: MvQColourListHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQColourListHelp() {} + ~MvQColourListHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget(); - void setExternalActions(QList); + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override; + void setExternalActions(QList) override; public slots: void slotSelected(QColor); void slotReset(bool); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; void setOriColourBox(QColor colour); QToolButton* insertBeforeTb_; @@ -91,19 +91,21 @@ public: MvQColourGradHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQColourGradHelp() {} + ~MvQColourGradHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget(); - void setExternalActions(QList); + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override; + void setExternalActions(QList) override; public slots: void slotSelected(QColor); void slotReset(bool); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; + +private: void setOriColourBox(QColor colour); QToolButton* insertBeforeTb_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQColourLine.cc metview-5.19.2/metview/src/Desktop/MvQColourLine.cc --- metview-5.17.4/metview/src/Desktop/MvQColourLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQColourLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ // The custom colour (if exists) is always the last one customColIndex_ = colCb_->count(); - owner_.addWidget(colCb_, row_, 3); + owner_.addWidget(colCb_, row_, WidgetColumn); connect(colCb_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentChanged(int))); @@ -51,7 +51,7 @@ auto* acCopyCol = new QAction(this); acCopyCol->setText(tr("&Copy colour")); acCopyCol->setShortcut(QKeySequence(tr("Ctrl+C"))); - //acCopyCol->setIcon(QPixmap(":/desktop/editcopy.svg")); + // acCopyCol->setIcon(QPixmap(":/desktop/editcopy.svg")); colCb_->addAction(acCopyCol); connect(acCopyCol, SIGNAL(triggered()), @@ -80,7 +80,7 @@ auto* acPasteCol = new QAction(this); acPasteCol->setText(tr("&Paste colour")); acPasteCol->setShortcut(QKeySequence(tr("Ctrl+V"))); - //acPasteCol->setIcon(QPixmap(":/desktop/editpaste.svg")); + // acPasteCol->setIcon(QPixmap(":/desktop/editpaste.svg")); colCb_->addAction(acPasteCol); connect(acPasteCol, SIGNAL(triggered()), @@ -102,14 +102,14 @@ if (pix_.isNull()) { int w = colCb_->iconSize().width(); int h = colCb_->iconSize().height(); - pix_ = QPixmap(w, h); + pix_ = QPixmap(w, h); pix_.fill(Qt::transparent); } QPainter painter(&pix_); if (col.isValid()) { - //paint the chequered background when alpha is set + // paint the chequered background when alpha is set if (col.alpha() != 255) { MvQPalette::paintAlphaBg(&painter, QRect(0, 0, pix_.width(), pix_.height())); #if 0 @@ -147,7 +147,7 @@ } else { pix_.fill(Qt::transparent); - //painter.setBrush(Qt::white); + // painter.setBrush(Qt::white); painter.setPen(QPen(Qt::gray, 0., Qt::DashLine)); painter.drawRect(1, 1, pix_.width() - 2, pix_.height() - 3); } @@ -234,11 +234,11 @@ } QString name = QString::fromStdString(values[0]); - //This sets the current index as well + // This sets the current index as well setCustomColour(MvQPalette::magics(values[0]), name, name, true); } - //changed_ = false; + // changed_ = false; } void MvQColourLine::slotCurrentChanged(int index) @@ -269,15 +269,15 @@ } QString name = QString::fromStdString(values[0]); - //This sets the current index as well + // This sets the current index as well setCustomColour(MvQPalette::magics(values[0]), name, name, true); - //If the current index did not change the slotCurrentChanged() was - //not called, so here we need to notify the owner about the change!! - //if(colCb_->currentIndex() == currentPrev) + // If the current index did not change the slotCurrentChanged() was + // not called, so here we need to notify the owner about the change!! + // if(colCb_->currentIndex() == currentPrev) //{ // owner_.set(param_.name(),name.toStdString()); - //} + // } } } @@ -307,7 +307,7 @@ int index = colCb_->currentIndex(); if (index != -1) { QString name = colCb_->itemData(index).toString(); - QColor col = MvQPalette::magics(name.toStdString()); + QColor col = MvQPalette::magics(name.toStdString()); MvQ::toClipboard("\"" + QString::fromStdString(MvQPalette::toString(col)) + "\""); } } @@ -317,7 +317,7 @@ int index = colCb_->currentIndex(); if (index != -1) { QString name = colCb_->itemData(index).toString(); - QColor col = MvQPalette::magics(name.toStdString()); + QColor col = MvQPalette::magics(name.toStdString()); MvQ::toClipboard(MvQPalette::toRgbString(col)); } } @@ -327,7 +327,7 @@ int index = colCb_->currentIndex(); if (index != -1) { QString name = colCb_->itemData(index).toString(); - QColor col = MvQPalette::magics(name.toStdString()); + QColor col = MvQPalette::magics(name.toStdString()); MvQ::toClipboard(MvQPalette::toHslString(col)); } } diff -Nru metview-5.17.4/metview/src/Desktop/MvQColourLine.h metview-5.19.2/metview/src/Desktop/MvQColourLine.h --- metview-5.17.4/metview/src/Desktop/MvQColourLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQColourLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,16 +26,16 @@ public: MvQColourLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQColourLine() {} + ~MvQColourLine() override = default; - QString currentValue() { return QString(); } + QString currentValue() { return {}; } void addValue(QString) {} - void refresh(const std::vector&); + void refresh(const std::vector&) override; public slots: - void slotHelperEdited(const std::vector&); - void slotHelperEditConfirmed(); + void slotHelperEdited(const std::vector&) override; + void slotHelperEditConfirmed() override; protected slots: void slotCurrentChanged(int); @@ -45,7 +45,7 @@ void slotPasteColour(); protected: - void next(const MvIconParameter&, const char* first, const char* second); + void next(const MvIconParameter&, const char* first, const char* second) override; void addColour(QColor, QString, QString, bool setCurrent = false); void setCustomColour(QColor, QString, QString, bool setCurrent = false); void updateHelper(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQColourListLine.cc metview-5.19.2/metview/src/Desktop/MvQColourListLine.cc --- metview-5.17.4/metview/src/Desktop/MvQColourListLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQColourListLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -87,7 +87,7 @@ copyColAc_ = new QAction(this); copyColAc_->setText(tr("&Copy colour cell")); copyColAc_->setShortcut(QKeySequence(tr("Ctrl+C"))); - //copyColAc_->setIcon(QPixmap(":/desktop/editcopy.svg")); + // copyColAc_->setIcon(QPixmap(":/desktop/editcopy.svg")); copyColAc_->setData("ignore"); addAction(copyColAc_); @@ -97,7 +97,7 @@ pasteColAc_ = new QAction(this); pasteColAc_->setText(tr("&Paste colour cell")); pasteColAc_->setShortcut(QKeySequence(tr("Ctrl+V"))); - //pasteColAc_->setIcon(QPixmap(":/desktop/editpaste.svg")); + // pasteColAc_->setIcon(QPixmap(":/desktop/editpaste.svg")); pasteColAc_->setData("ignore"); addAction(pasteColAc_); @@ -207,7 +207,7 @@ void MvQColourListWidget::mousePressEvent(QMouseEvent* event) { setCurrentCell(event->pos()); - //if(colours_.count() == 1) + // if(colours_.count() == 1) //{ emit singleCellClicked(); //} @@ -236,9 +236,7 @@ return; } - QFont font; - QFontMetrics fm(font); - int h = height(); //fm.height()+4; + int h = height(); // fm.height()+4; int w = width() / ((colours_.count() > 0) ? colours_.count() : 1); cellWidth_ = w; @@ -326,7 +324,7 @@ if (currentCell_ >= 0 && currentCell_ < colours_.count()) return colours_[currentCell_]; - return QColor(); + return {}; } void MvQColourListWidget::setCurrentColour(QColor col) @@ -453,7 +451,7 @@ void MvQColourListWidget::slotPasteColourList() { - QString txt = MvQ::fromClipboard(); + QString txt = MvQ::fromClipboard(); QList cLst = MvQPalette::toColourList(txt); if (cLst.count() > 0) { colours_ = cLst; @@ -473,10 +471,6 @@ { widget_ = new MvQColourListWidget(parentWidget_); - QFont font; - QFontMetrics fm(font); - //int h=fm.height()+4; - owner_.addWidget(widget_, row_, WidgetColumn); connect(widget_, SIGNAL(currentChanged(QColor)), @@ -494,17 +488,17 @@ { MvQRequestPanelLine::buildHelper(); - //Customisation + // Customisation if (helper_) helper_->setExternalActions(widget_->actions()); /*connect(helper_,SIGNAL(insertBefore()), widget_,SLOT(slotInsertBeforeCell())); - - connect(helper_,SIGNAL(insertAfter()), + + connect(helper_,SIGNAL(insertAfter()), widget_,SLOT(slotInsertAfterCell())); - - connect(helper_,SIGNAL(deleteCell()), + + connect(helper_,SIGNAL(deleteCell()), widget_,SLOT(slotDeleteCell()));*/ } @@ -520,14 +514,13 @@ QList colours; for (const auto& value : values) { - QString name = QString::fromStdString(value); colours << MvQPalette::magics(value); } widget_->setColours(colours); } - //changed_ = false; + // changed_ = false; } @@ -569,7 +562,6 @@ if (vals.size() == 0) return; - QString name = QString::fromStdString(vals[0]); widget_->setCurrentColour(MvQPalette::magics(vals[0])); } diff -Nru metview-5.17.4/metview/src/Desktop/MvQColourListLine.h metview-5.19.2/metview/src/Desktop/MvQColourListLine.h --- metview-5.17.4/metview/src/Desktop/MvQColourListLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQColourListLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,7 +27,7 @@ Q_OBJECT public: - MvQColourListWidget(QWidget* parent = 0); + MvQColourListWidget(QWidget* parent = nullptr); void setColours(QList); QColor currentColour() const; void setCurrentColour(QColor); @@ -53,10 +53,10 @@ void singleCellClicked(); protected: - void resizeEvent(QResizeEvent*); - void changeEvent(QEvent* event); - void paintEvent(QPaintEvent*); - void mousePressEvent(QMouseEvent*); + void resizeEvent(QResizeEvent*) override; + void changeEvent(QEvent* event) override; + void paintEvent(QPaintEvent*) override; + void mousePressEvent(QMouseEvent*) override; void createPixmap(); void renderCurrentCell(QPainter*); void setCurrentCell(QPoint); @@ -88,20 +88,20 @@ public: MvQColourListLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQColourListLine() {} + ~MvQColourListLine() override = default; - QString currentValue() { return QString(); } - void refresh(const std::vector&); + QString currentValue() { return {}; } + void refresh(const std::vector&) override; public slots: void slotListChanged(); void slotCurrentChanged(QColor); - void slotHelperEdited(const std::vector&); + void slotHelperEdited(const std::vector&) override; void slotSingleCellClicked(); - void slotHelperOpened(bool); + void slotHelperOpened(bool) override; protected: - void buildHelper(); + void buildHelper() override; void updateHelper(); MvQColourListWidget* widget_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQComboBoxLine.cc metview-5.19.2/metview/src/Desktop/MvQComboBoxLine.cc --- metview-5.17.4/metview/src/Desktop/MvQComboBoxLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQComboBoxLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -8,6 +8,7 @@ ***************************** LICENSE END *************************************/ #include +#include #include #include "MvQComboBoxLine.h" @@ -61,14 +62,14 @@ { cbEdit_ = new MvQEditorComboBox(parentWidget_); - owner_.addWidget(cbEdit_, row_, 3); + owner_.addWidget(cbEdit_, row_, WidgetColumn); param_.scan(*this); connect(cbEdit_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentChanged(int))); - //combo_->setCurrentIndex(dindex); + // combo_->setCurrentIndex(dindex); } @@ -92,7 +93,7 @@ } } - //changed_ = false; + // changed_ = false; } void MvQComboBoxLine::slotCurrentChanged(int index) @@ -101,6 +102,13 @@ owner_.set(param_.name(), cbEdit_->itemData(index).toString().toStdString()); } +void MvQComboBoxLine::fixedFontAndHeight(QFont& font, int& h) const +{ + font = QFont(); + font.setPointSize(font.pointSize() - 1); + auto fm = QFontMetrics(font); + h = fm.height() + 4; +} static LineMaker maker1("menu"); -static LineMaker maker2("option_menu"); \ No newline at end of file +static LineMaker maker2("option_menu"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQComboBoxLine.h metview-5.19.2/metview/src/Desktop/MvQComboBoxLine.h --- metview-5.17.4/metview/src/Desktop/MvQComboBoxLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQComboBoxLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,12 +21,12 @@ class MvQEditorComboBox : public QComboBox { public: - MvQEditorComboBox(QWidget* parent = 0); + MvQEditorComboBox(QWidget* parent = nullptr); protected: - void wheelEvent(QWheelEvent* event); - void focusInEvent(QFocusEvent* event); - void focusOutEvent(QFocusEvent* event); + void wheelEvent(QWheelEvent* event) override; + void focusInEvent(QFocusEvent* event) override; + void focusOutEvent(QFocusEvent* event) override; }; @@ -37,16 +37,17 @@ public: MvQComboBoxLine(RequestPanel& owner, const MvIconParameter& param); - QString currentValue() { return QString(); } + QString currentValue() { return {}; } void addValue(QString) {} - void refresh(const std::vector&); + void refresh(const std::vector&) override; public slots: void slotCurrentChanged(int); protected: - void next(const MvIconParameter&, const char* first, const char* second); + void next(const MvIconParameter&, const char* first, const char* second) override; + void fixedFontAndHeight(QFont& font, int& h) const; MvQEditorComboBox* cbEdit_; bool reportChange_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQContextMenu.cc metview-5.19.2/metview/src/Desktop/MvQContextMenu.cc --- metview-5.17.4/metview/src/Desktop/MvQContextMenu.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQContextMenu.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,6 +7,7 @@ ***************************** LICENSE END *************************************/ + #include #include @@ -16,10 +17,12 @@ #include "IconClass.h" #include "Folder.h" #include "IconObject.h" +#include "MvLog.h" #include "MvRequest.h" #include "MvQMethods.h" +#include "MvQStreamOper.h" -MvQContextMenu* MvQContextMenu::instance_ = 0; +MvQContextMenu* MvQContextMenu::instance_ = nullptr; //====================================== // @@ -49,24 +52,24 @@ if (!verb) return; - MvQContextItem* item = 0; + MvQContextItem* item = nullptr; if (strcmp(verb, "icon_menu") == 0) { - if ((item = MvQContextItem::build(r, icon_)) != 0) + if ((item = MvQContextItem::build(r, icon_)) != nullptr) icon_ << item; } if (strcmp(verb, "group_menu") == 0) { - if ((item = MvQContextItem::build(r, icon_)) != 0) + if ((item = MvQContextItem::build(r, icon_)) != nullptr) multiIcon_ << item; } else if (strcmp(verb, "desktop_menu") == 0) { - if ((item = MvQContextItem::build(r, desktop_)) != 0) + if ((item = MvQContextItem::build(r, desktop_)) != nullptr) desktop_ << item; } else if (strcmp(verb, "container_menu") == 0) { - if ((item = MvQContextItem::build(r, container_)) != 0) + if ((item = MvQContextItem::build(r, container_)) != nullptr) container_ << item; } } @@ -75,7 +78,7 @@ { foreach (MvQContextItem* item, icon_) { if (item->hasShortCut("Return")) - return 0; + return nullptr; } auto* sc = new QShortcut(Qt::Key_Return, w); @@ -104,10 +107,10 @@ QStringList lst = c.split(operand_); if (lst.count() == 2) { - key_ = lst[0]; + key_ = lst[0]; value_ = lst[1]; - //Need to resolve items paths + // Need to resolve items paths if (key_ == "path" && !value_.startsWith("/")) { IconObject* wbo = Folder::folder(value_.toStdString().c_str(), false); if (wbo) @@ -146,7 +149,8 @@ MvQContextItem* MvQContextItem::build(const MvRequest& r, QList items) { - QMenu* parent = nullptr; + QMenu* parent = nullptr; + MvQContextSubMenu* parentSubMenu = nullptr; MvQContextItem* item = nullptr; const char* verb = r.getVerb(); @@ -162,9 +166,9 @@ if (const char* parent_menu = r("parent_menu")) { foreach (MvQContextItem* c, items) if (c->id() == QString(parent_menu)) { - auto* cs = static_cast(c); - if (cs) - parent = cs; + parentSubMenu = static_cast(c); + if (parentSubMenu) + parent = parentSubMenu; break; } } @@ -181,6 +185,9 @@ else { if (checkEnv(r)) { item = new MvQContextAction(parent, r); + if (parentSubMenu) { + parentSubMenu->addChildCommand(item->command()); + } return (parent) ? nullptr : item; } else { @@ -199,9 +206,9 @@ MvQContextItem::MvQContextItem(const MvRequest& r) : condition_(QString(r("condition"))) { - id_ = QString(r("id")); - command_ = QString(r("cmd")); - service_ = QString(r("service")); + id_ = QString(r("id")); + command_ = QString(r("cmd")); + service_ = QString(r("service")); shortCut_ = QString(r("shortcut")); } @@ -226,7 +233,7 @@ { if (const char* ic = r("icon")) return ":desktop/" + QString(ic) + ".svg"; - return QString(); + return {}; } bool MvQContextItem::hasShortCut(QString s) @@ -234,6 +241,11 @@ return (shortCut_ == s); } +bool MvQContextItem::checkCommand(const std::set& commands) const +{ + return command().isEmpty() || commands.find(command().toStdString()) != commands.end(); +} + //====================================== // // MvQContextSubMenu @@ -241,7 +253,7 @@ //====================================== MvQContextSubMenu::MvQContextSubMenu(QString text, QString iconPath) : - QMenu(0) + QMenu(nullptr) { setTitle(text); if (!iconPath.isEmpty()) { @@ -250,7 +262,7 @@ } MvQContextSubMenu::MvQContextSubMenu(const MvRequest& r) : - QMenu(0), + QMenu(nullptr), MvQContextItem(r) { QString text(r("label")); @@ -262,10 +274,36 @@ } } -void MvQContextSubMenu::addToMenu(QMenu* m) +void MvQContextSubMenu::addToMenu(QMenu* menu) { - if (m) - m->addMenu(this); + if (menu) + menu->addMenu(this); +} + +void MvQContextSubMenu::addChildCommand(QString cmd) +{ + childCommands_ << cmd; + static QStringList specCmds = {"compress", "archive"}; + for (auto s : specCmds) { + if (cmd.startsWith(s + "_")) { + if (!childCommands_.contains(s)) { + childCommands_ << s; + } + } + } +} + +bool MvQContextSubMenu::checkCommand(const std::set& commands) const +{ + if (childCommands_.isEmpty()) { + return true; + } + for (auto cmd : childCommands_) { + if (commands.find(cmd.toStdString()) != commands.end()) { + return true; + } + } + return false; } //====================================== @@ -313,7 +351,7 @@ sc->setProperty("cmd", command_); return sc; } - return 0; + return nullptr; } //====================================== @@ -357,15 +395,13 @@ { auto* menu = new QMenu(parent); QString retVal; - QAction* defaultAction = 0; - QString defaultMethod = QString::fromStdString(obj->iconClass().defaultMethod()).toLower(); - + QAction* defaultAction = nullptr; + QString defaultMethod = QString::fromStdString(obj->iconClass().defaultMethod()).toLower(); std::set iconCommands = obj->can(); - foreach (MvQContextItem* item, lst) { - if (item->command().isEmpty() || iconCommands.find(item->command().toStdString()) != iconCommands.end()) { + for (MvQContextItem* item : lst) { + if (item->checkCommand(iconCommands)) { item->addToMenu(menu); - if (!defaultMethod.isEmpty() && defaultMethod == item->command()) { QFont font; @@ -388,7 +424,7 @@ delete menu; - //Reset font for the default action + // Reset font for the default action if (defaultAction) defaultAction->setFont(QFont()); @@ -404,7 +440,7 @@ bool shared = true; for (auto it : objLst) { std::set iconCommands = it->can(); - if (!item->command().isEmpty() && iconCommands.find(item->command().toStdString()) == iconCommands.end()) { + if (!item->checkCommand(iconCommands)) { shared = false; break; } @@ -415,7 +451,6 @@ if (!menu->isEmpty()) { QAction* ac = menu->exec(pos); - if (!ac || ac->isSeparator()) { retVal = QString(); } @@ -433,7 +468,7 @@ { auto* menu = new QMenu(parent); QString retVal; - QAction* defaultAction = 0; + QAction* defaultAction = nullptr; foreach (MvQContextItem* item, lst) { if (item->checkCondition(condition)) @@ -457,7 +492,7 @@ delete menu; - //Reset font for the default action + // Reset font for the default action if (defaultAction) { defaultAction->setFont(QFont()); } diff -Nru metview-5.17.4/metview/src/Desktop/MvQContextMenu.h metview-5.19.2/metview/src/Desktop/MvQContextMenu.h --- metview-5.17.4/metview/src/Desktop/MvQContextMenu.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQContextMenu.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -74,12 +75,13 @@ QString command() const { return command_; } QString service() const { return service_; } QString shortCut() const { return shortCut_; } - virtual void addToMenu(QMenu*) = 0; + virtual void addToMenu(QMenu*) = 0; virtual QShortcut* makeShortCut(QWidget*) = 0; bool checkCondition(QString); static bool checkEnv(const MvRequest& r); static MvQContextItem* build(const MvRequest& r, QList items); bool hasShortCut(QString); + virtual bool checkCommand(const std::set&) const; protected: QString iconPath(const MvRequest& r); @@ -96,16 +98,21 @@ public: MvQContextSubMenu(QString, QString iconPath = QString()); MvQContextSubMenu(const MvRequest& r); - void addToMenu(QMenu*); - QShortcut* makeShortCut(QWidget*) { return 0; } + void addToMenu(QMenu*) override; + QShortcut* makeShortCut(QWidget*) override { return nullptr; } + void addChildCommand(QString cmd); + bool checkCommand(const std::set&) const override; + +private: + QStringList childCommands_; }; class MvQContextAction : public QAction, public MvQContextItem { public: MvQContextAction(QMenu*, const MvRequest& r); - void addToMenu(QMenu*); - QShortcut* makeShortCut(QWidget*); + void addToMenu(QMenu*) override; + QShortcut* makeShortCut(QWidget*) override; protected: void init(QString, QString, QString, QString); @@ -114,9 +121,9 @@ class MvQContextSeparator : public QAction, public MvQContextItem { public: - MvQContextSeparator(QMenu* menu = 0); - void addToMenu(QMenu*); - QShortcut* makeShortCut(QWidget*) { return 0; } + MvQContextSeparator(QMenu* menu = nullptr); + void addToMenu(QMenu*) override; + QShortcut* makeShortCut(QWidget*) override { return nullptr; } }; class MvQContextMenu diff -Nru metview-5.17.4/metview/src/Desktop/MvQDesktop.cc metview-5.19.2/metview/src/Desktop/MvQDesktop.cc --- metview-5.17.4/metview/src/Desktop/MvQDesktop.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQDesktop.cc 2023-07-15 08:28:47.000000000 +0000 @@ -59,7 +59,7 @@ Protocol::init(); // Register this service - //registerTMvServe(*this,0); + // registerTMvServe(*this,0); //----------------------- // Special folders @@ -98,7 +98,7 @@ WsType::init(WsType::DesktopMode); //------------------------------------------------ - //Add drop callback to handle drops to uPlot + // Add drop callback to handle drops to uPlot //------------------------------------------------ add_drop_callback(MvApplication::getService(), nullptr, drop_request, nullptr); @@ -107,14 +107,14 @@ } -//This request is sent from uPlot when an icon is dropped from Desktop to uPlot. +// This request is sent from uPlot when an icon is dropped from Desktop to uPlot. static void drop_request(svcid* id, request* r, void* /*data*/) { - //print_all_requests(r); + // print_all_requests(r); MvRequest req = get_subrequest(r, "HEADER", 0); - //Service name + // Service name const char* serviceCh = get_svc_source(id); if (!serviceCh) return; @@ -122,22 +122,22 @@ std::string serviceName(serviceCh); req("_SERVICE") = serviceCh; - //Context + // Context req("_CONTEXT") = get_subrequest(r, "_CONTEXT", 0); - //Mode + // Mode MvRequest mode = get_subrequest(r, "MODE", 0); std::set icons; - //Icons + // Icons int cnt = req.iterInit("ICON_NAME"); for (int i = 0; i < cnt; i++) { - //Icon name - const char* iconChName; + // Icon name + const char* iconChName = nullptr; req.iterGetNextValue(iconChName); - //Find the iconobject + // Find the iconobject if (iconChName) { std::string iconName(iconChName); IconObject* obj = IconObject::search(iconName); @@ -146,19 +146,19 @@ } } - //Action type + // Action type int action = atoi(get_value(r, "ACTION", 0)); if (action == 3) { - //Who will delete it???? + // Who will delete it???? new Drop(icons, req, serviceName, mode); } } static void reply_request(svcid*, request* r, void* /*data*/) { - //cout << "reply" << std::endl; - //print_all_requests(r); + // cout << "reply" << std::endl; + // print_all_requests(r); if (r) { bool hasError = (strcmp(r->name, "ERROR") == 0); @@ -170,14 +170,14 @@ if (hasError) { MvRequest req(r); - //MvQMessageBox m(r); + // MvQMessageBox m(r); int cnt = req.iterInit("ICON_NAME"); for (int i = 0; i < cnt; i++) { - //Icon name - const char* iconChName; + // Icon name + const char* iconChName = nullptr; req.iterGetNextValue(iconChName); - //Find the iconobject and notify an error + // Find the iconobject and notify an error if (iconChName) { std::string iconName(iconChName); IconObject* obj = IconObject::search(iconName); @@ -196,13 +196,13 @@ inRequest.print(); // Create a new context, based on the input Request - //PmContext * context = new PmContext ( proto, inRequest ); + // PmContext * context = new PmContext ( proto, inRequest ); // Increment the reference counting - //context->Attach(); + // context->Attach(); // Execute the context - //context->Execute();showBrowsers() + // context->Execute();showBrowsers() // Decrement the reference counting // context->Detach(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQDesktop.h metview-5.19.2/metview/src/Desktop/MvQDesktop.h --- metview-5.17.4/metview/src/Desktop/MvQDesktop.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQDesktop.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ { public: MvQDesktop(int& argc, char** argv, std::string); - ~MvQDesktop(); + ~MvQDesktop() override; void init(); void showBrowsers(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQDesktopSettings.cc metview-5.19.2/metview/src/Desktop/MvQDesktopSettings.cc --- metview-5.17.4/metview/src/Desktop/MvQDesktopSettings.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQDesktopSettings.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,10 +32,10 @@ return Desktop::DragShowDraggedIcon; } -//Writing/reading QLists for QSettings did not work whatever we -//tried with Q_DECLARE_METATYPE and qRegisterMetaType +// Writing/reading QLists for QSettings did not work whatever we +// tried with Q_DECLARE_METATYPE and qRegisterMetaType //(got error: QVariant::load: unable to load type 257). -//So instead we need to use QStringlist here. +// So instead we need to use QStringlist here. void MvQDesktopSettings::writeSettings(QSettings& settings) { diff -Nru metview-5.17.4/metview/src/Desktop/MvQDetailedFolderView.cc metview-5.19.2/metview/src/Desktop/MvQDetailedFolderView.cc --- metview-5.17.4/metview/src/Desktop/MvQDetailedFolderView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQDetailedFolderView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,7 +41,7 @@ QTreeView(parent), MvQFolderViewBase(folderModel, parent), moveActionEnabled_(true), - defaultShortCut_(0), + defaultShortCut_(nullptr), appIconActions_(iconActions), appDesktopActions_(desktopActions) { @@ -54,13 +54,13 @@ setAllColumnsShowFocus(true); setUniformRowHeights(true); - //Drag and drop + // Drag and drop setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(true); setDragDropMode(QAbstractItemView::DragDrop); - //Delegate + // Delegate delegate_ = new MvQDetailedViewDelegate(this); setItemDelegate(delegate_); @@ -71,7 +71,7 @@ setSelectionMode(QAbstractItemView::ExtendedSelection); - //Context menu + // Context menu setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), @@ -83,18 +83,18 @@ connect(this, SIGNAL(entered(const QModelIndex&)), this, SLOT(slotEntered(const QModelIndex&))); - //Selection form the list + // Selection form the list connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(slotSelectItem(const QModelIndex))); - //Set header ContextMenuPolicy + // Set header ContextMenuPolicy header()->setSectionsMovable(false); header()->setContextMenuPolicy(Qt::CustomContextMenu); connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotHeaderContextMenu(const QPoint&))); - //Init header + // Init header updateHeader(); for (int i = 0; i < folderModel_->columnCount(QModelIndex()) - 1; i++) @@ -103,11 +103,11 @@ /*connect(header(),SIGNAL(sectionMoved(int,int,int)), this, SLOT(slotMessageTreeColumnMoved(int,int,int)));*/ - //We set up the shortcuts here!! + // We set up the shortcuts here!! setupShortCut(); - //We attach the model because by default the view is enabled. At this point the model is empty so - //it is a cheap operation!! + // We attach the model because by default the view is enabled. At this point the model is empty so + // it is a cheap operation!! attachModel(); } @@ -116,10 +116,10 @@ views.removeOne(this); } -//Connect the models signal to the view +// Connect the models signal to the view void MvQDetailedFolderView::attachModel() { - //Standard signals from the model + // Standard signals from the model setModel(filterModel_); connect(folderModel_, SIGNAL(iconSizeChanged()), @@ -129,11 +129,11 @@ this, SLOT(slotObjectRenamed(const QModelIndex&, QString))); } -//Disconnect the model from the view +// Disconnect the model from the view void MvQDetailedFolderView::detachModel() { - setModel(0); - disconnect(folderModel_, 0, this, 0); + setModel(nullptr); + disconnect(folderModel_, nullptr, this, nullptr); } void MvQDetailedFolderView::changeEvent(QEvent* event) @@ -143,7 +143,7 @@ attachModel(); blockSignals(false); } - //When the view is diabled we do not want to receive any signals from the model + // When the view is diabled we do not want to receive any signals from the model else { detachModel(); blockSignals(true); @@ -179,11 +179,11 @@ void MvQDetailedFolderView::slotSelectItem(const QModelIndex& /*index*/) { /*if(isFolder(index,FilterModelIndex)) - { - changeFolder(index,FilterModelIndex); - emit currentFolderChanged(currentFolder()); + { + changeFolder(index,FilterModelIndex); + emit currentFolderChanged(currentFolder()); - }*/ + }*/ } void MvQDetailedFolderView::slotDoubleClickItem(const QModelIndex& index) @@ -250,8 +250,8 @@ { auto* sc = static_cast(QObject::sender()); if (sc) { - //QPoint scrollOffset(horizontalScrollBar()->value(),verticalScrollBar()->value()); - //handleContextMenu(index,lst,mapToGlobal(position),position+scrollOffset,this); + // QPoint scrollOffset(horizontalScrollBar()->value(),verticalScrollBar()->value()); + // handleContextMenu(index,lst,mapToGlobal(position),position+scrollOffset,this); handleDesktopShortCut(sc, QPoint(0, 0), this); } @@ -260,7 +260,7 @@ void MvQDetailedFolderView::slotContextMenu(const QPoint& position) { QModelIndexList lst = selectedList(); - //QModelIndex index=indexAt(position); + // QModelIndex index=indexAt(position); QPoint scrollOffset(horizontalScrollBar()->value(), verticalScrollBar()->value()); handleContextMenu(indexAt(position), lst, mapToGlobal(position), position + scrollOffset, this); @@ -399,13 +399,13 @@ void MvQDetailedFolderView::performDrag(Qt::DropAction dropAction, QPoint pos) { QModelIndex viewIndex = indexAt(pos); - QModelIndex index = filterModel_->mapToSource(viewIndex); + QModelIndex index = filterModel_->mapToSource(viewIndex); - //The object that was dragged + // The object that was dragged IconObject* dragObj = folderModel_->objectFromIndex(index); - //List of objects to drag - //We need only one index (the first column) for each row + // List of objects to drag + // We need only one index (the first column) for each row QList objLst; QSet rows; foreach (QModelIndex index, selectedIndexes()) { @@ -416,7 +416,7 @@ } } - //It cannot be a helper! + // It cannot be a helper! bool fromHelper = false; QDrag* drag = buildDrag(dragObj, objLst, fromHelper, this); @@ -431,7 +431,7 @@ void MvQDetailedFolderView::checkDropTarget(QDropEvent* event) { - IconObject* dragObj = 0; + IconObject* dragObj = nullptr; if (event->mimeData()->hasFormat("metview/icon")) { const auto* mimeData = qobject_cast(event->mimeData()); @@ -452,7 +452,7 @@ #else QModelIndex index = indexAt(event->pos()); #endif - IconObject* obj = folderModel_->objectFromIndex(filterModel_->mapToSource(index)); + IconObject* obj = folderModel_->objectFromIndex(filterModel_->mapToSource(index)); if (obj != dragObj && obj && obj->isFolder() && !obj->locked()) { MvQDropTarget::Instance()->reset(QString::fromStdString(obj->name()), (dropAction == Qt::MoveAction)); @@ -477,9 +477,9 @@ void MvQDetailedFolderView::dragEnterEvent(QDragEnterEvent* event) { - //qDebug() << event->mimeData()->formats(); - //qDebug() << event->mimeData()->text(); - //qDebug() << event->proposedAction(); + // qDebug() << event->mimeData()->formats(); + // qDebug() << event->mimeData()->text(); + // qDebug() << event->proposedAction(); if (event->source() && (event->proposedAction() == Qt::CopyAction || @@ -542,11 +542,11 @@ return; } - IconObject* dragObj = mimeData->dragObject(); + IconObject* dragObj = mimeData->dragObject(); MvQFolderModel* model = mimeData->model(); if (dragObj && (model || mimeData->fromEditor())) { - bool fromSameView = false; + bool fromSameView = false; MvQFolderModel* model = mimeData->model(); if (model) { fromSameView = (model == folderModel_ || model->folder() == folderModel_->folder()); @@ -555,7 +555,7 @@ fromSameView = (folderModel_->folder() == dragObj->parent()); } - //We cannot drop icons into a locked folder! + // We cannot drop icons into a locked folder! if (!fromSameView && folderModel_->folder()->locked()) { event->ignore(); return; @@ -599,12 +599,12 @@ QPoint pos, bool fromSameView) { bool toSameFolder = true; - Folder* folder = folderModel_->folder(); + Folder* folder = folderModel_->folder(); IconObject* objAt = folderModel_->objectFromIndex(filterModel_->mapToSource(indexAt(pos))); - //See if we drop the icons onto a folder icons. We do not allow dropping a folder into itself!! + // See if we drop the icons onto a folder icons. We do not allow dropping a folder into itself!! if (objAt && objAt->isFolder() && !data->objects().contains(objAt)) { - folder = static_cast(objAt); + folder = static_cast(objAt); toSameFolder = false; } @@ -612,9 +612,9 @@ if (!isAccepted(obj)) continue; - //We set the object position to zero. This will instuct the icon folder view + // We set the object position to zero. This will instuct the icon folder view //(when the folder is next open in it) to find meaningful positions to the - //icons. + // icons. if (dropAction == Qt::CopyAction || moveActionEnabled_ == false) { obj->clone(folder, false); @@ -677,13 +677,12 @@ if (section < 0 || section >= header()->count()) return; - QList lst; auto* menu = new QMenu(this); - QAction* ac; + QAction* ac = nullptr; for (int i = 0; i < header()->count(); i++) { QString name = header()->model()->headerData(i, Qt::Horizontal).toString(); - ac = new QAction(menu); + ac = new QAction(menu); ac->setText(name); ac->setCheckable(true); ac->setData(i); diff -Nru metview-5.17.4/metview/src/Desktop/MvQDetailedFolderView.h metview-5.19.2/metview/src/Desktop/MvQDetailedFolderView.h --- metview-5.17.4/metview/src/Desktop/MvQDetailedFolderView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQDetailedFolderView.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,12 +27,12 @@ Q_OBJECT public: - MvQDetailedFolderView(MvQFolderModel*, MvQActionList*, MvQActionList*, QWidget* parent = 0); - ~MvQDetailedFolderView(); + MvQDetailedFolderView(MvQFolderModel*, MvQActionList*, MvQActionList*, QWidget* parent = nullptr); + ~MvQDetailedFolderView() override; static void writeGlobalSettings(QSettings&); static void readGlobalSettings(QSettings&); - QWidget* concreteWidget(); - void doReset(); + QWidget* concreteWidget() override; + void doReset() override; public slots: void slotIconShortCut(); @@ -53,44 +53,44 @@ void desktopCommandRequested(QString, QPoint); protected: - void attachModel(); - void detachModel(); + void attachModel() override; + void detachModel() override; - MvQContextItemSet* cmSet(); - void setupShortCut(); + MvQContextItemSet* cmSet() override; + void setupShortCut() override; void setPositions() {} - void blink(const QModelIndex&); - void showIcon(const QModelIndex&); - void rename(IconObject*); - - void changeEvent(QEvent* event); - void leaveEvent(QEvent* event); - void mousePressEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); + void blink(const QModelIndex&) override; + void showIcon(const QModelIndex&) override; + void rename(IconObject*) override; + + void changeEvent(QEvent* event) override; + void leaveEvent(QEvent* event) override; + void mousePressEvent(QMouseEvent*) override; + void mouseMoveEvent(QMouseEvent*) override; void performDrag(Qt::DropAction, QPoint); void checkDropTarget(QDropEvent* event); void removeDropTarget(); - void dragEnterEvent(QDragEnterEvent*); - void dragMoveEvent(QDragMoveEvent*); - void dragLeaveEvent(QDragLeaveEvent*); - void dropEvent(QDropEvent*); + void dragEnterEvent(QDragEnterEvent*) override; + void dragMoveEvent(QDragMoveEvent*) override; + void dragLeaveEvent(QDragLeaveEvent*) override; + void dropEvent(QDropEvent*) override; void performDrop(Qt::DropAction dropAction, const MvQIconMimeData* data, - QPoint cursorScenePos, bool fromSameView); + QPoint cursorScenePos, bool fromSameView) override; - void keyPressEvent(QKeyEvent* event); + void keyPressEvent(QKeyEvent* event) override; QModelIndexList selectedList(); - QRect itemRect(IconObject*); - QRect itemRect(QList); - QRect pixmapRect(QList); - QRect pixmapRect(IconObject*); - - bool ignoreItemPositionForCm() { return true; } - - void folderChanged(); - void iconCommandFromMain(QString name); - virtual void iconCommand(QString, IconObjectH); - virtual void desktopCommand(QString, QPoint); + QRect itemRect(IconObject*) override; + QRect itemRect(QList) override; + QRect pixmapRect(QList) override; + QRect pixmapRect(IconObject*) override; + + bool ignoreItemPositionForCm() override { return true; } + + void folderChanged() override; + void iconCommandFromMain(QString name) override; + void iconCommand(QString, IconObjectH) override; + void desktopCommand(QString, QPoint) override; static void broadcastHeaderChange(); void updateHeader(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQDrawerPanel.cc metview-5.19.2/metview/src/Desktop/MvQDrawerPanel.cc --- metview-5.17.4/metview/src/Desktop/MvQDrawerPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQDrawerPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -68,8 +68,8 @@ bar_ = new MvQDrawerTabBar(this); - //bar_->setDrawBase(false); - //bar_->setDocumentMode(true); + // bar_->setDrawBase(false); + // bar_->setDocumentMode(true); bar_->setExpanding(true); barLayout_->addWidget(bar_); @@ -88,15 +88,15 @@ connect(bar_, SIGNAL(leftClicked(int)), this, SLOT(slotTabClicked(int))); - //Contextmenu + // Contextmenu bar_->setContextMenuPolicy(Qt::CustomContextMenu); connect(bar_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotContextMenu(const QPoint&))); - openIcon_ = QIcon(QPixmap(":/desktop/drawer_open.svg")); + openIcon_ = QIcon(QPixmap(":/desktop/drawer_open.svg")); closeIcon_ = QIcon(QPixmap(":/desktop/drawer_close.svg")); - noIcon_ = QIcon(); + noIcon_ = QIcon(); } MvQDrawerPanel::~MvQDrawerPanel() = default; @@ -113,7 +113,7 @@ bar_->addTab(name); stacked_->addWidget(w); - //Add tool button + // Add tool button auto* tb = new QToolButton(this); tb->setToolButtonStyle(Qt::ToolButtonIconOnly); tb->setAutoRaise(true); @@ -166,18 +166,18 @@ sorted = ori; sorted.sort(); - //qDebug() << oriIdx; - //qDebug() << ori; - //qDebug() << sorted; + // qDebug() << oriIdx; + // qDebug() << ori; + // qDebug() << sorted; for (int i = 0; i < sorted.count(); i++) { - //qDebug() << i << sorted[i] <tabText(i); + // qDebug() << i << sorted[i] <tabText(i); if (sorted[i] != bar_->tabText(i)) { int from = oriIdx[sorted[i]]; - int to = i; + int to = i; - //qDebug() << "--> to from" << to << from; + // qDebug() << "--> to from" << to << from; bar_->moveTab(from, to); @@ -211,7 +211,7 @@ QWidget* MvQDrawerPanel::drawer(int index) { - return (index >= 0 && index < stacked_->count()) ? stacked_->widget(index) : 0; + return (index >= 0 && index < stacked_->count()) ? stacked_->widget(index) : nullptr; } QString MvQDrawerPanel::drawerText(int index) @@ -266,7 +266,7 @@ void MvQDrawerPanel::slotTabButton() { - if (auto* w = static_cast(sender())) { + if (auto* w = dynamic_cast(sender())) { for (int i = 0; i < bar_->count(); i++) if (w == bar_->tabButton(i, QTabBar::RightSide)) { slotTabClicked(i); @@ -278,7 +278,7 @@ void MvQDrawerPanel::setTabButtonStatus(int index, const QIcon& icon, QString txt) { if (QWidget* w = bar_->tabButton(index, QTabBar::RightSide)) - if (auto* tb = static_cast(w)) { + if (auto* tb = dynamic_cast(w)) { tb->setIcon(icon); tb->setToolTip(txt); } diff -Nru metview-5.17.4/metview/src/Desktop/MvQDrawerPanel.h metview-5.19.2/metview/src/Desktop/MvQDrawerPanel.h --- metview-5.17.4/metview/src/Desktop/MvQDrawerPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQDrawerPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,12 +26,12 @@ Q_OBJECT public: - MvQDrawerTabBar(QWidget* parent = 0); + MvQDrawerTabBar(QWidget* parent = nullptr); signals: void leftClicked(int); protected: - void mousePressEvent(QMouseEvent*); + void mousePressEvent(QMouseEvent*) override; }; class MvQDrawerPanel : public QWidget @@ -39,8 +39,8 @@ Q_OBJECT public: - MvQDrawerPanel(QWidget* parent = 0); - ~MvQDrawerPanel(); + MvQDrawerPanel(QWidget* parent = nullptr); + ~MvQDrawerPanel() override; void setSorted(bool b) { sorted_ = b; } int drawerCount(); @@ -63,7 +63,7 @@ void renameDrawer(int, QString); void deleteDrawer(int); void sortDrawers(); - void paintEvent(QPaintEvent*); + void paintEvent(QPaintEvent*) override; private: void setCurrent(QString); diff -Nru metview-5.17.4/metview/src/Desktop/MvQDrawerView.h metview-5.19.2/metview/src/Desktop/MvQDrawerView.h --- metview-5.17.4/metview/src/Desktop/MvQDrawerView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQDrawerView.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,11 +16,11 @@ class MvQDrawerView : public MvQIconStripView { public: - MvQDrawerView(MvQFolderModel*, QWidget* parent = 0); - ~MvQDrawerView(); + MvQDrawerView(MvQFolderModel*, QWidget* parent = nullptr); + ~MvQDrawerView() override; protected: - void attachModel() {} - void detachModel() {} - MvQContextItemSet* cmSet(); + void attachModel() override {} + void detachModel() override {} + MvQContextItemSet* cmSet() override; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcLayerDb.cc metview-5.19.2/metview/src/Desktop/MvQEcLayerDb.cc --- metview-5.17.4/metview/src/Desktop/MvQEcLayerDb.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcLayerDb.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,14 +20,14 @@ #include #include -//for logging +// for logging #include "mars.h" #include "MvQStyleDb.h" #include "MvQTheme.h" #include "MvMiscellaneous.h" -MvQEcLayerDb* MvQEcLayerDb::instance_ = 0; +MvQEcLayerDb* MvQEcLayerDb::instance_ = nullptr; //========================================== // @@ -122,11 +122,11 @@ { QSet ts; for (int i = 0; i < items_.count(); i++) { - foreach (QString s, items_[i]->title().split(" ", + for (auto s : items_[i]->title().split(" ", #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - Qt::SkipEmptyParts)) { + Qt::SkipEmptyParts)) { #else - QString::SkipEmptyParts)) { + QString::SkipEmptyParts)) { #endif s.remove(")").remove("("); if (s.size() >= 2) { @@ -135,7 +135,7 @@ } } #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - return QStringList(ts.begin(), ts.end()); + return {ts.begin(), ts.end()}; #else return QStringList::fromSet(ts); #endif @@ -152,25 +152,28 @@ return; } - QByteArray json = fIn.readAll(); + QByteArray json = fIn.readAll(); QJsonDocument doc = QJsonDocument::fromJson(json); - //This document is an array of groups + // This document is an array of groups Q_ASSERT(doc.isObject()); - //This document is an array of groups - //Q_ASSERT(doc.isArray()); - //QJsonArray docArr=doc.array(); + // This document is an array of groups + // Q_ASSERT(doc.isArray()); + // QJsonArray docArr=doc.array(); - //Iterate through the ojects in a group - //Iterate through the ojects in a group + // Iterate through the ojects in a group + // Iterate through the ojects in a group const QJsonObject& jsonob = doc.object(); for (QJsonObject::const_iterator it = jsonob.constBegin(); it != jsonob.constEnd(); it++) { QString name = it.key(); - //qDebug() << name; + // qDebug() << name; auto* item = new MvQEcLayerDbItem(name); + if (name.count() > maxNameLen_) { + maxNameLen_ = name.count(); + } QStringList styles; QJsonObject ob = it.value().toObject(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcLayerDb.h metview-5.19.2/metview/src/Desktop/MvQEcLayerDb.h --- metview-5.17.4/metview/src/Desktop/MvQEcLayerDb.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcLayerDb.h 2023-07-15 08:28:47.000000000 +0000 @@ -47,7 +47,7 @@ QPixmap makePixmap(QSize pixSize); void paint(QPainter* painter, QRect rect); -protected: +private: void resolveStyles(QStringList lst); QString previewFile() const; @@ -57,7 +57,7 @@ QString group_; QStringList keywords_; QString defaultStyle_; - //QStringList styles_; + // QStringList styles_; QList styleIds_; QStringList steps_; QStringList quantiles_; @@ -72,11 +72,12 @@ QStringList titleWords() const; QStringList groups() const { return groups_; } QStringList keywords() const { return keywords_; } + int maxNameLen() const { return maxNameLen_; } MvQEcLayerDbItem* find(const std::string& name) const; int indexOf(const std::string& name) const; -protected: +private: MvQEcLayerDb(); void load(); void collect(QStringList lst, QStringList& allLst) const; @@ -85,6 +86,7 @@ static MvQEcLayerDb* instance_; QVector items_; + int maxNameLen_{0}; QStringList groups_; QStringList keywords_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcLayerHelp.cc metview-5.19.2/metview/src/Desktop/MvQEcLayerHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQEcLayerHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcLayerHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -46,12 +46,12 @@ int MvQEcLayerModel::columnCount(const QModelIndex& /*parent */) const { - return 1; + return 2; } int MvQEcLayerModel::rowCount(const QModelIndex& parent) const { - //Parent is the root: + // Parent is the root: if (!parent.isValid()) { return MvQEcLayerDb::instance()->items().count(); } @@ -63,21 +63,45 @@ { int row = index.row(); if (row < 0 || row >= MvQEcLayerDb::instance()->items().count()) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { - if (index.column() == 0) - return row; + if (index.column() == 0) { + // return MvQEcLayerDb::instance()->items()[row]->name(); + return QString(); + } + else if (index.column() == 1) { + return MvQEcLayerDb::instance()->items()[row]->title(); + } } else if (role == Qt::UserRole) { + if (index.column() == 0) { + return row; + } + } + // else if (role == NameRole) { + // if (index.column() == 0) { + // return MvQEcLayerDb::instance()->items()[row]->name(); + // } + // } + else if (role == Qt::ForegroundRole) { + if (index.column() == 0) { + return QColor(Qt::transparent); + } + } + else if (role == FilterRole) { return (isFiltered(MvQEcLayerDb::instance()->items()[row]) == true) ? "1" : "0"; } else if (role == SortRole) { - if (index.column() == 0) + if (index.column() == 0) { return MvQEcLayerDb::instance()->items()[row]->name(); + } + else if (index.column() == 1) { + return MvQEcLayerDb::instance()->items()[row]->title(); + } } - return QVariant(); + return {}; } QVariant MvQEcLayerModel::headerData(const int section, const Qt::Orientation orient, const int role) const @@ -85,26 +109,34 @@ if (orient != Qt::Horizontal || (role != Qt::DisplayRole && role != Qt::ToolTipRole)) return QAbstractItemModel::headerData(section, orient, role); - return role == Qt::DisplayRole && section == 0 ? "Matching layers" : QVariant(); + if (role == Qt::DisplayRole) { + if (section == 0) { + return "Name"; + } + else if (section == 1) { + return "Title"; + } + } + return {}; } QModelIndex MvQEcLayerModel::index(int row, int column, const QModelIndex& parent) const { if (row < 0 || column < 0) { - return QModelIndex(); + return {}; } - //When parent is the root this index refers to a node or server + // When parent is the root this index refers to a node or server if (!parent.isValid()) { return createIndex(row, column); } - return QModelIndex(); + return {}; } QModelIndex MvQEcLayerModel::parent(const QModelIndex& /*child*/) const { - return QModelIndex(); + return {}; } void MvQEcLayerModel::setFilter(QString s) @@ -168,23 +200,25 @@ vb->addWidget(nameLe_); - //tree view and model + // tree view and model browser_ = new MvQEcLayerTreeWidget(this); vb->addWidget(browser_, 1); - model_ = new MvQEcLayerModel(this); + model_ = new MvQEcLayerModel(this); sortModel_ = new QSortFilterProxyModel(this); #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) sortModel_->setFilterRegularExpression("1"); #else sortModel_->setFilterRegExp("1"); #endif - sortModel_->setFilterRole(Qt::UserRole); + + sortModel_->setFilterRole(MvQEcLayerModel::FilterRole); sortModel_->setSortRole(MvQEcLayerModel::SortRole); sortModel_->setSourceModel(model_); browser_->tree()->setModel(sortModel_); + browser_->tree()->resizeColumnToContents(0); connect(nameLe_, SIGNAL(textChanged(QString)), this, SLOT(slotNameFilter(QString))); diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcLayerHelp.h metview-5.19.2/metview/src/Desktop/MvQEcLayerHelp.h --- metview-5.17.4/metview/src/Desktop/MvQEcLayerHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcLayerHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -48,26 +48,27 @@ #endif -//Model to dislay/select the suites +// Model to dislay/select the suites class MvQEcLayerModel : public QAbstractItemModel { public: enum CustomItemRole { - SortRole = Qt::UserRole + 1 + SortRole = Qt::UserRole + 1, + FilterRole = Qt::UserRole + 2 }; - explicit MvQEcLayerModel(QObject* parent = 0); - ~MvQEcLayerModel(); + explicit MvQEcLayerModel(QObject* parent = nullptr); + ~MvQEcLayerModel() override; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void setFilter(QString s); void clearFilter(); @@ -82,7 +83,7 @@ { Q_OBJECT public: - MvQEcLayerSelectionWidget(QWidget* parent = 0); + MvQEcLayerSelectionWidget(QWidget* parent = nullptr); void setCurrent(const std::string&); protected slots: @@ -108,17 +109,17 @@ public: MvQEcLayerHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQEcLayerHelp() {} + ~MvQEcLayerHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget() { return selector_; } + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override { return selector_; } public slots: void slotSelected(int); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; private: MvQEcLayerSelectionWidget* selector_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcLayerLine.cc metview-5.19.2/metview/src/Desktop/MvQEcLayerLine.cc --- metview-5.17.4/metview/src/Desktop/MvQEcLayerLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcLayerLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ owner_(owner) {} protected: - void mousePressEvent(QMouseEvent*) + void mousePressEvent(QMouseEvent*) override { owner_->widgetClicked(); } @@ -49,13 +49,13 @@ MvQEcLayerLine::MvQEcLayerLine(RequestPanel& owner, const MvIconParameter& param) : MvQRequestPanelLine(owner, param) { - //MvQEcLayerDb::instance(); + // MvQEcLayerDb::instance(); - auto* w = new MvQEcLayerLineWidget(this, parentWidget_); + auto* w = new MvQEcLayerLineWidget(this, parentWidget_); auto* hb = new QHBoxLayout(w); hb->setContentsMargins(0, 0, 0, 0); - pixLabel_ = new QLabel(w); + pixLabel_ = new QLabel(w); nameLabel_ = new QLabel(w); hb->addWidget(pixLabel_); hb->addWidget(nameLabel_, 1); @@ -64,7 +64,7 @@ QFontMetrics fm(font); pixSize_ = QSize(180, fm.height() + 4); - owner_.addWidget(w, row_, 3); + owner_.addWidget(w, row_, WidgetColumn); #if 0 connect(colCb_,SIGNAL(currentIndexChanged(int)), @@ -98,7 +98,7 @@ pixLabel_->setPixmap(QPixmap()); nameLabel_->clear(); - //changed_ = false; + // changed_ = false; } void MvQEcLayerLine::slotHelperEdited(const std::vector& values) @@ -128,12 +128,12 @@ setCustomColour(MvQPalette::magics(values[0]),name,name,true); #endif - //If the current index did not change the slotCurrentChanged() was - //not called, so here we need to notify the owner about the change!! - //if(colCb_->currentIndex() == currentPrev) + // If the current index did not change the slotCurrentChanged() was + // not called, so here we need to notify the owner about the change!! + // if(colCb_->currentIndex() == currentPrev) //{ // owner_.set(param_.name(),name.toStdString()); - //} + // } } } diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcLayerLine.h metview-5.19.2/metview/src/Desktop/MvQEcLayerLine.h --- metview-5.17.4/metview/src/Desktop/MvQEcLayerLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcLayerLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,16 +28,16 @@ public: MvQEcLayerLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQEcLayerLine() {} + ~MvQEcLayerLine() override = default; - void refresh(const std::vector&); + void refresh(const std::vector&) override; void widgetClicked(); public slots: - void slotHelperEdited(const std::vector&); + void slotHelperEdited(const std::vector&) override; protected: - void next(const MvIconParameter&, const char* first, const char* second); + void next(const MvIconParameter&, const char* first, const char* second) override; void updateHelper(); QPixmap pix_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcLayerTreeWidget.cc metview-5.19.2/metview/src/Desktop/MvQEcLayerTreeWidget.cc --- metview-5.17.4/metview/src/Desktop/MvQEcLayerTreeWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcLayerTreeWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ QFont f; QFontMetrics fm(f); textHeight_ = fm.height(); - pixHeight_ = qMax(textHeight_ + 2, 24); + pixHeight_ = qMax(textHeight_ + 2, 24); } void MvQEcLayerDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, @@ -49,17 +49,20 @@ painter->save(); if (index.column() == 0) { - //Background + // Background QStyleOptionViewItem vopt(option); initStyleOption(&vopt, index); - const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); + const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); const QWidget* widget = vopt.widget; - //We render everything with the default method + // We render everything with the default method, + // this will not draw text just the bg (e.g. for selection) + painter->setPen(Qt::NoPen); style->drawControl(QStyle::CE_ItemViewItem, &vopt, painter, widget); - int row = index.data(Qt::DisplayRole).toInt(); + // now render the main contents + int row = index.data(Qt::UserRole).toInt(); if (row < 0) return; @@ -68,26 +71,26 @@ MvQEcLayerDbItem* item = MvQEcLayerDb::instance()->items()[row]; Q_ASSERT(item); - if (item) + if (item) { item->paint(painter, rect); - - QString name = item->name(); - QRect textRect = rect; - textRect.setX(rect.x() + rect.width()); - textRect.setRight(option.rect.right()); - painter->setPen(MvQTheme::text()); - painter->drawText(textRect, name, Qt::AlignLeft | Qt::AlignVCenter); + QString name = item->name(); + QRect textRect = rect; + textRect.setX(rect.x() + rect.width()); + textRect.setRight(option.rect.right()); + auto textCol = (option.state & QStyle::State_Selected)?MvQTheme::colour("highlightedtext"):MvQTheme::text(); + painter->setPen(textCol); + painter->drawText(textRect, name, Qt::AlignLeft | Qt::AlignVCenter); + } } else { QStyledItemDelegate::paint(painter, option, index); } - //Render the horizontal border for rows. We only render the top border line. - //With this technique we miss the bottom border line of the last row!!! - //QRect fullRect=QRect(0,option.rect.y(),painter->device()->width(),option.rect.height()); + // Render the horizontal border for rows. We only render the top border line. + // With this technique we miss the bottom border line of the last row!!! QRect bgRect = option.rect; painter->setPen(borderCol_); - painter->drawLine(bgRect.topLeft(), bgRect.topRight()); + MvQ::safeDrawLine(bgRect.topLeft(), bgRect.topRight(), painter); painter->restore(); } @@ -95,7 +98,13 @@ QSize MvQEcLayerDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { QSize s = QStyledItemDelegate::sizeHint(option, index); - return QSize(pixHeight_ * 2 + 10 + s.width(), pixHeight_); + QFont f; + QFontMetrics fm(f); + auto w = MvQ::textWidth(fm, QString().fill('A', MvQEcLayerDb::instance()->maxNameLen() + 1)); + if (w > s.width()) { + s.setWidth(w); + } + return {pixHeight_ * 2 + 10 + s.width(), pixHeight_}; } //===================================================== @@ -107,7 +116,7 @@ MvQEcLayerTreeWidget::MvQEcLayerTreeWidget(QWidget* parent) : QWidget(parent) { - //Layout to hold tree and sidebar + // Layout to hold tree and sidebar auto* vb = new QVBoxLayout(this); vb->setContentsMargins(0, 0, 0, 0); @@ -117,10 +126,11 @@ splitter_->setChildrenCollapsible(false); vb->addWidget(splitter_); - //tree view and model + // tree view and model tree_ = new QTreeView(this); tree_->setRootIsDecorated(false); tree_->setUniformRowHeights(true); + tree_->setSelectionBehavior(QAbstractItemView::SelectRows); tree_->setMinimumHeight(268); splitter_->addWidget(tree_); @@ -128,9 +138,9 @@ tree_->setSortingEnabled(true); tree_->sortByColumn(1, Qt::AscendingOrder); - //tree_->setModel(sortModel_); + // tree_->setModel(sortModel_); - //Tree context menu + // Tree context menu tree_->setContextMenuPolicy(Qt::ActionsContextMenu); auto* acCopyName = new QAction(this); @@ -141,7 +151,7 @@ connect(acCopyName, SIGNAL(triggered()), this, SLOT(slotCopyLayerName())); - //Tree sidebar + // Tree sidebar te_ = new QTextEdit(this); splitter_->addWidget(te_); @@ -192,7 +202,7 @@ bool hasMarsInfo = !(item->quantiles().isEmpty() && item->steps().isEmpty()); if (hasMarsInfo) { - txt += "Specific values for MARS retrievals"; + txt += R"(Specific values for MARS retrievals)"; } if (!item->quantiles().isEmpty()) @@ -205,7 +215,7 @@ te_->insertHtml(txt); - //scroll to top + // scroll to top te_->moveCursor(QTextCursor::Start); te_->ensureCursorVisible(); } diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcLayerTreeWidget.h metview-5.19.2/metview/src/Desktop/MvQEcLayerTreeWidget.h --- metview-5.17.4/metview/src/Desktop/MvQEcLayerTreeWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcLayerTreeWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,10 +20,10 @@ class MvQEcLayerDelegate : public QStyledItemDelegate { public: - MvQEcLayerDelegate(QWidget* parent = 0); + MvQEcLayerDelegate(QWidget* parent = nullptr); void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; + const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; protected: QColor borderCol_; @@ -36,7 +36,7 @@ { Q_OBJECT public: - explicit MvQEcLayerTreeWidget(QWidget* parent = 0); + explicit MvQEcLayerTreeWidget(QWidget* parent = nullptr); void setLayer(MvQEcLayerDbItem* item); QTreeView* tree() const { return tree_; } diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcStyleHelp.cc metview-5.19.2/metview/src/Desktop/MvQEcStyleHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQEcStyleHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcStyleHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -49,7 +49,7 @@ int MvQEcStyleModel::rowCount(const QModelIndex& parent) const { - //Parent is the root: + // Parent is the root: if (!parent.isValid()) { return MvQStyleDb::instance()->items().count(); } @@ -61,7 +61,7 @@ { int row = index.row(); if (row < 0 || row >= MvQStyleDb::instance()->items().count()) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { return row; @@ -73,7 +73,7 @@ return MvQStyleDb::instance()->items()[row]->name(); } - return QVariant(); + return {}; } QVariant MvQEcStyleModel::headerData(const int section, const Qt::Orientation orient, const int role) const @@ -87,20 +87,20 @@ QModelIndex MvQEcStyleModel::index(int row, int column, const QModelIndex& parent) const { if (row < 0 || column < 0) { - return QModelIndex(); + return {}; } - //When parent is the root this index refers to a node or server + // When parent is the root this index refers to a node or server if (!parent.isValid()) { return createIndex(row, column); } - return QModelIndex(); + return {}; } QModelIndex MvQEcStyleModel::parent(const QModelIndex& /*child*/) const { - return QModelIndex(); + return {}; } void MvQEcStyleModel::setIndexFilter(QList lst) @@ -131,9 +131,9 @@ MvQEcStyleSelectionWidget::MvQEcStyleSelectionWidget(QWidget* parent) : QWidget(parent) -//ignoreFilterChanged_(false) +// ignoreFilterChanged_(false) { - QVBoxLayout* vb = new QVBoxLayout(this); + auto* vb = new QVBoxLayout(this); browser_ = new MvQStyleTreeWidget(this); vb->addWidget(browser_, 1); @@ -150,14 +150,14 @@ sortModel_->setSortRole(MvQEcStyleModel::SortRole); sortModel_->setSourceModel(model_); - //tree_->setSortingEnabled(true); - //tree_->sortByColumn(1,Qt::AscendingOrder); + // tree_->setSortingEnabled(true); + // tree_->sortByColumn(1,Qt::AscendingOrder); browser_->tree()->setModel(sortModel_); connect(browser_->tree()->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(slotItemSelected(QModelIndex, QModelIndex))); - //Init the button states!! + // Init the button states!! checkButtonState(); } @@ -180,16 +180,16 @@ void MvQEcStyleSelectionWidget::slotClearFilter() { - //ignoreFilterChanged_=true; - //nameLe_->clear(); - //keywordCb_->setCurrentIndex(0); - //colourCb_->setCurrentIndex(0); - //paramCb_->setCurrentIndex(0); - //ignoreFilterChanged_=false; + // ignoreFilterChanged_=true; + // nameLe_->clear(); + // keywordCb_->setCurrentIndex(0); + // colourCb_->setCurrentIndex(0); + // paramCb_->setCurrentIndex(0); + // ignoreFilterChanged_=false; model_->clearFilter(); sortModel_->invalidate(); - //checkButtonState(); + // checkButtonState(); } void MvQEcStyleSelectionWidget::checkButtonState() diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcStyleHelp.h metview-5.19.2/metview/src/Desktop/MvQEcStyleHelp.h --- metview-5.17.4/metview/src/Desktop/MvQEcStyleHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcStyleHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ class RequestPanel; class MvQStyleTreeWidget; -//Model to dislay/select the suites +// Model to dislay/select the suites class MvQEcStyleModel : public QAbstractItemModel { public: @@ -40,17 +40,17 @@ SortRole = Qt::UserRole + 1 }; - explicit MvQEcStyleModel(QObject* parent = 0); - ~MvQEcStyleModel(); + explicit MvQEcStyleModel(QObject* parent = nullptr); + ~MvQEcStyleModel() override; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void setIndexFilter(QList); void clearFilter(); @@ -65,7 +65,7 @@ { Q_OBJECT public: - MvQEcStyleSelectionWidget(QWidget* parent = 0); + MvQEcStyleSelectionWidget(QWidget* parent = nullptr); void setCurrent(const std::string&, const std::string& layerName); protected slots: @@ -91,17 +91,17 @@ public: MvQEcStyleHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQEcStyleHelp() {} + ~MvQEcStyleHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget() { return selector_; } + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override { return selector_; } public slots: void slotSelected(int); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; private: MvQEcStyleSelectionWidget* selector_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcStyleLine.cc metview-5.19.2/metview/src/Desktop/MvQEcStyleLine.cc --- metview-5.17.4/metview/src/Desktop/MvQEcStyleLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcStyleLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ owner_(owner) {} protected: - void mousePressEvent(QMouseEvent*) + void mousePressEvent(QMouseEvent*) override { owner_->widgetClicked(); } @@ -51,11 +51,11 @@ MvQRequestPanelLine(owner, param), layerParam_("LAYER") { - MvQEcStyleLineWidget* w = new MvQEcStyleLineWidget(this, parentWidget_); - QHBoxLayout* hb = new QHBoxLayout(w); + auto* w = new MvQEcStyleLineWidget(this, parentWidget_); + auto* hb = new QHBoxLayout(w); hb->setContentsMargins(0, 0, 0, 0); - stylePixLabel_ = new QLabel(w); + stylePixLabel_ = new QLabel(w); styleNameLabel_ = new QLabel(w); hb->addWidget(stylePixLabel_); hb->addWidget(styleNameLabel_, 1); @@ -64,7 +64,8 @@ QFontMetrics fm(font); pixSize_ = QSize(180, fm.height() + 4); - owner_.addWidget(w, row_, 3); + owner_.addWidget(w, row_, WidgetColumn); + #if 0 connect(colCb_,SIGNAL(currentIndexChanged(int)), @@ -98,7 +99,7 @@ stylePixLabel_->setPixmap(QPixmap()); styleNameLabel_->clear(); - //changed_ = false; + // changed_ = false; } @@ -109,7 +110,7 @@ std::vector vec; vec.push_back(layer->defaultStyle().toStdString()); refresh(vec); - //Here the style has already been selected and stored in styleNameLabel_ + // Here the style has already been selected and stored in styleNameLabel_ owner_.set(param_.name(), styleNameLabel_->text().toStdString()); } } @@ -117,7 +118,7 @@ std::string MvQEcStyleLine::layerName() const { - Request r = owner_.request(); + Request r = owner_.request(); std::vector vec = r.get(layerParam_.c_str()); return (!vec.empty()) ? vec[0] : std::string(); } @@ -150,12 +151,12 @@ setCustomColour(MvQPalette::magics(values[0]),name,name,true); #endif - //If the current index did not change the slotCurrentChanged() was - //not called, so here we need to notify the owner about the change!! - //if(colCb_->currentIndex() == currentPrev) + // If the current index did not change the slotCurrentChanged() was + // not called, so here we need to notify the owner about the change!! + // if(colCb_->currentIndex() == currentPrev) //{ // owner_.set(param_.name(),name.toStdString()); - //} + // } } } diff -Nru metview-5.17.4/metview/src/Desktop/MvQEcStyleLine.h metview-5.19.2/metview/src/Desktop/MvQEcStyleLine.h --- metview-5.17.4/metview/src/Desktop/MvQEcStyleLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEcStyleLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,19 +29,19 @@ public: MvQEcStyleLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQEcStyleLine() {} + ~MvQEcStyleLine() override = default; - void refresh(const std::vector&); + void refresh(const std::vector&) override; void widgetClicked(); - void changed(const char* /*param*/, const std::vector&) {} - void changed(const char* param, const std::string&); - bool isDependent() const { return true; } + void changed(const char* /*param*/, const std::vector&) override {} + void changed(const char* param, const std::string&) override; + bool isDependent() const override { return true; } public slots: - void slotHelperEdited(const std::vector&); + void slotHelperEdited(const std::vector&) override; protected: - void next(const MvIconParameter&, const char* first, const char* second); + void next(const MvIconParameter&, const char* first, const char* second) override; void updateHelper(); std::string layerName() const; diff -Nru metview-5.17.4/metview/src/Desktop/MvQEditor.cc metview-5.19.2/metview/src/Desktop/MvQEditor.cc --- metview-5.17.4/metview/src/Desktop/MvQEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -33,9 +34,12 @@ #include #include + #include "EditorDrawerFactory.h" #include "Folder.h" #include "IconClass.h" +#include "MvLog.h" +#include "MvMiscellaneous.h" #include "MvRequest.h" #include "Path.h" #include "Request.h" @@ -44,13 +48,268 @@ #include "MvQFolderModel.h" #include "MvQTemplateDrawer.h" #include "MvQIconProvider.h" +#include "MvQStreamOper.h" #include "MvQTheme.h" #include "MvQMethods.h" #include "MvQIconMimeData.h" +#include "DocHighlighter.h" #include "MessageLabel.h" //#define DEBUG_MV_MVQEDITOR__ + + +class MvQEditorState : public QObject +{ +public: + MvQEditorState(MvQEditor* owner); + ~MvQEditorState() override = default; + + virtual void handleChangeView(QAction*)=0; + virtual bool handleSave()=0; + virtual void handleOk()=0; + virtual void handleClose(); + virtual void handleReset(){} + +protected: + void concludeOk(); + void concludeSave(); + void concludeReset(); + + MvQEditor* owner_{nullptr}; +}; + + +class MvQEditorGuiState : public MvQEditorState +{ +public: + MvQEditorGuiState(MvQEditor* owner, bool doReset); + void handleChangeView(QAction*) override; + bool handleSave() override; + void handleOk() override; + void handleReset() override; +}; + +class MvQEditorTextState : public MvQEditorState +{ +public: + MvQEditorTextState(MvQEditor* owner); + void handleChangeView(QAction*) override; + bool handleSave() override; + void handleOk() override; + void handleReset() override; +private: + bool saveFailed_{false}; +}; + +class MvQEditorPythonState : public MvQEditorState +{ +public: + MvQEditorPythonState(MvQEditor* owner); + void handleChangeView(QAction*) override; + bool handleSave() override {return true;} + void handleOk() override; + void handleReset() override {} +}; + +//========================================= +// +// MvQEditorState +// +//========================================= + +MvQEditorState::MvQEditorState(MvQEditor* owner): owner_(owner) {} + +void MvQEditorState::handleClose() +{ + owner_->writeSettings(); + owner_->savePb_->setEnabled(false); + owner_->resetPb_->setEnabled(false); + owner_->close(); + owner_->notifyObserverClose(); + owner_->editDone(); + + owner_->concludeReject(); +} + +void MvQEditorState::concludeOk() +{ + owner_->writeSettings(); + owner_->current_->modified(); + owner_->notifyObserverApply(); + + owner_->savePb_->setEnabled(false); + owner_->resetPb_->setEnabled(false); + owner_->close(); + owner_->editDone(); + + owner_->concludeAccept(); +} + +void MvQEditorState::concludeSave() +{ + owner_->current_->modified(); + owner_->notifyObserverApply(); + + owner_->savePb_->setEnabled(false); + owner_->resetPb_->setEnabled(false); + owner_->viewAg_->setEnabled(true); +} + +void MvQEditorState::concludeReset() +{ + owner_->savePb_->setEnabled(false); + owner_->resetPb_->setEnabled(false); + owner_->viewAg_->setEnabled(true); +} + +//========================================= +// +// MvQEditorGuiState +// +//========================================= + +MvQEditorGuiState::MvQEditorGuiState(MvQEditor* owner, bool doReset) : MvQEditorState(owner) +{ + owner_->viewSw_->setCurrentIndex(MvQEditor::LineViewMode); + if (doReset) { + owner_->ignoreChange_ = true; + owner_->reset(); + owner_->ignoreChange_ = false; + } +} + +void MvQEditorGuiState::handleChangeView(QAction* ac) +{ + if (ac == owner_->guiAc_) { + return; + } else { + handleSave(); + if (ac == owner_->textAc_) { + owner_->transitionTo(new MvQEditorTextState(owner_)); + } else if (ac == owner_->pyAc_) { + owner_->transitionTo(new MvQEditorPythonState(owner_)); + } + } +} + +void MvQEditorGuiState::handleOk() +{ + owner_->ignoreChange_ = true; + owner_->apply(); + owner_->ignoreChange_ = false; + concludeOk(); +} + +bool MvQEditorGuiState::handleSave() +{ + owner_->ignoreChange_ = true; + owner_->apply(); + owner_->ignoreChange_ = false; + concludeSave(); + return true; +} + +void MvQEditorGuiState::handleReset() +{ + owner_->ignoreChange_ = true; + owner_->reset(); + owner_->ignoreChange_ = false; + concludeReset(); +} + +//========================================= +// +// MvQEditorTextState +// +//========================================= + +MvQEditorTextState::MvQEditorTextState(MvQEditor* owner) : MvQEditorState(owner) +{ + owner_->viewSw_->setCurrentIndex(MvQEditor::TextViewMode); + owner_->ignoreChange_ = true; + owner_->textPanel_->load(); + owner_->ignoreChange_ = false; +} + +void MvQEditorTextState::handleChangeView(QAction* ac) +{ + if (ac == owner_->textAc_) { + if (saveFailed_ == true) { + owner_->viewAg_->setEnabled(false); + } + return; + } else { + saveFailed_ = !handleSave(); + // save can fail since the text is editable and can contain an ill-formatted request + if (!saveFailed_) { + owner_->viewAg_->setEnabled(true); + if (ac == owner_->guiAc_) { + owner_->transitionTo(new MvQEditorGuiState(owner_, true)); + } else if (ac == owner_->pyAc_) { + owner_->transitionTo(new MvQEditorPythonState(owner_)); + } + } else { + // we are not allowing to change the view mode if the request is + // not properly formatted + owner_->textAc_->setChecked(true); + } + } +} + +void MvQEditorTextState::handleOk() +{ + if (owner_->textPanel_->check()) { + owner_->textPanel_->save(); + } + concludeOk(); +} + +bool MvQEditorTextState::handleSave() +{ + if (owner_->textPanel_->check()) { + owner_->textPanel_->save(); + } else { + return false; + } + concludeSave(); + return true; +} + +void MvQEditorTextState::handleReset() +{ + owner_->textPanel_->load(); + concludeReset(); +} + +//========================================= +// +// MvQEditorPythonState +// +//========================================= + +MvQEditorPythonState::MvQEditorPythonState(MvQEditor* owner) : MvQEditorState(owner) +{ + owner_->viewSw_->setCurrentIndex(MvQEditor::PythonViewMode); + owner_->ignoreChange_ = true; + owner_->pyPanel_->load(); + owner_->ignoreChange_ = false; +} + +void MvQEditorPythonState::handleChangeView(QAction* ac) +{ + if (ac == owner_->guiAc_) { + owner_->transitionTo(new MvQEditorGuiState(owner_, false)); + } else if (ac == owner_->textAc_) { + owner_->transitionTo(new MvQEditorTextState(owner_)); + } +} + +void MvQEditorPythonState::handleOk() +{ + concludeOk(); +} + //=========================== // // MvQEditorDragLabel @@ -109,7 +368,7 @@ canDrag_ = false; if (event->button() == Qt::LeftButton) { startPos_ = event->pos(); - canDrag_ = true; + canDrag_ = true; } QLabel::mousePressEvent(event); @@ -135,7 +394,7 @@ QDrag* drag = buildDrag(obj_, scenePos); if (drag) { emit dragStarted(); - //We always initiate a copy action + // We always initiate a copy action drag->exec(Qt::CopyAction, dropAction); } else { @@ -151,20 +410,20 @@ if (dragObj) { auto* drag = new QDrag(this); - //Hotspot is the bottom right corner of the dragged object's pixmap - //we overwrite it if dragPos is null!! We use normalised coordinates + // Hotspot is the bottom right corner of the dragged object's pixmap + // we overwrite it if dragPos is null!! We use normalised coordinates QPointF hotSpotInPix(1, 1); - //It has to have as many elements as there are in objLst + // It has to have as many elements as there are in objLst QList pixDistanceLst; - //QPointF hotSpotInPix=0.; + // QPointF hotSpotInPix=0.; drag->setPixmap(oriPix_); QList objLst; objLst << dragObj; - //Create and set drag mime data + // Create and set drag mime data auto* mimeData = new MvQIconMimeData(nullptr, dragObj, hotSpotInPix, objLst, pixDistanceLst); @@ -197,20 +456,20 @@ font.setBold(true); QFontMetrics fm(font); int txth = 3 * fm.height() + 2 * fm.leading() + 8; - txth = (txth > 32) ? txth : 32; + txth = (txth > 32) ? txth : 32; - //Pixmap label - can be dragged into a plot window + // Pixmap label - can be dragged into a plot window pixLabel_ = new MvQEditorDragLabel(pix, txth, this); hb->addWidget(pixLabel_); connect(pixLabel_, SIGNAL(dragStarted()), - owner_, SLOT(save())); + owner_, SLOT(pixLabelDragStarted())); stackLayout_ = new QStackedLayout(); hb->addLayout(stackLayout_); - //Info panel - auto* w = new QWidget; + // Info panel + auto* w = new QWidget(this); auto* labelHb = new QHBoxLayout(w); labelHb->setSpacing(0); labelHb->setContentsMargins(2, 1, 2, 1); @@ -230,7 +489,7 @@ renameTb_ = new QToolButton(this); renameTb_->setAutoRaise(true); - //renameTb_->setText(tr("Rename")); + // renameTb_->setText(tr("Rename")); renameTb_->setToolTip(tr("Click to rename icon")); renameTb_->setIcon(QPixmap(QString::fromUtf8(":/desktop/edit.svg"))); labelHb->addWidget(renameTb_); @@ -238,8 +497,8 @@ connect(renameTb_, SIGNAL(clicked(bool)), this, SLOT(slotStartEdit(bool))); - //Editor - w = new QWidget; + // Editor + w = new QWidget(this); auto* editHb = new QHBoxLayout(w); editHb->setSpacing(0); editHb->setContentsMargins(2, 1, 2, 1); @@ -248,7 +507,7 @@ edit_ = new QLineEdit(this); editHb->addWidget(edit_); - //Rename buttonBox_ + // Rename buttonBox_ auto* acceptTb = new QToolButton(this); acceptTb->setAutoRaise(true); @@ -346,36 +605,63 @@ // //================================================ +bool MvQEditorTextPanel::showEditWarning_ = true; + MvQEditorTextPanel::MvQEditorTextPanel(const IconClass& c, Editor* owner, QWidget* parent) : QWidget(parent), class_(c), owner_(owner) { + // needed to initialise editWarning + readSettings(); + auto* vb = new QVBoxLayout; setLayout(vb); vb->setSpacing(0); vb->setContentsMargins(0, 0, 0, 0); - //Warning label - auto* warnLayout = new QHBoxLayout(); - vb->addLayout(warnLayout); + // labels +// auto* labelLayout = new QHBoxLayout(); +// vb->addLayout(labelLayout); + + // Info label + auto* iLayout = new QHBoxLayout(); + vb->addLayout(iLayout); + infoLabel_ = new MessageLabel(this); + infoLabel_->showInfo("This is the contents of the file storing your icon settings."); + iLayout->addWidget(infoLabel_,1); +// vb->addWidget(infoLabel_); + + // Warning label + if (showEditWarning_) { + warnLabel_ = new MessageLabel(this); + warnLabel_->showWarning("Please only edit this text at your own risk!"); + warnLabel_->showCustomButton("Do not show again"); + connect(warnLabel_, SIGNAL(customButtonClicked()), + this, SLOT(doNotShowWarningAgain())); - warnLabel_ = new MessageLabel(this); - warnLabel_->showWarning("This is the contents of the file storing your icon settings. Please only edit it at your own risk!"); - warnLayout->addWidget(warnLabel_, 1); + vb->addWidget(warnLabel_); + } - //Message label + // Message label auto* msgLayout = new QHBoxLayout(); vb->addLayout(msgLayout); msgLabel_ = new MessageLabel(this); msgLayout->addWidget(msgLabel_, 1); - //Text editor + // Text editor te_ = new QPlainTextEdit(this); vb->addWidget(te_, 1); + QFont f = MvQ::findMonospaceFont(); + f.setPointSize(te_->font().pointSize()); + te_->setFont(f); + + // The document becomes the owner of the highlighter + new DocHighlighter(te_->document(), "request"); + connect(te_, SIGNAL(textChanged()), this, SLOT(slotTextChanged())); } @@ -384,18 +670,14 @@ { current_ = obj; - QString str = tr("This is the contents of the file storing your icon settings. "); - if (obj->locked() || !obj->storedAsRequestFile()) { te_->setReadOnly(true); } else { te_->setReadOnly(false); - str += tr("Please only edit it at your own risk!"); } te_->update(); - warnLabel_->showWarning(str); } @@ -406,7 +688,8 @@ if (f.open(QFile::ReadOnly | QFile::Text)) { QTextStream rs(&f); te_->setPlainText(rs.readAll()); - } else { + } + else { te_->clear(); } beingLoaded_ = false; @@ -424,22 +707,28 @@ QString verb; #ifdef DEBUG_MV_MVQEDITOR__ - qDebug() << "TEXT --->"; + MvLog().dbg() << "TEXT --->"; r.print(); - qDebug() << "<--- TEXT"; + MvLog().dbg() << "<--- TEXT"; #endif - if (r) + if (r) { verb = QString(r.getVerb()); + } QString ic = QString::fromStdString(current_->editorClass().name()); - //QString ic=QString::fromStdString(current_->iconClass().name()); + // QString ic=QString::fromStdString(current_->iconClass().name()); QString msg; bool failed = false; - if (verb.compare(ic, Qt::CaseInsensitive) != 0) { - msg = "Request type " + verb + " in text does not match icon type " + ic + "! "; - msg += "Please change the request type to " + ic + " or revert the icon back to system defaults."; + if (verb.simplified().isEmpty()) { + msg = "Ill formatted request!
You can either correct the request text or revert the " + "icon back to the last saved state using Reset."; + failed = true; + } else if (verb.compare(ic, Qt::CaseInsensitive) != 0) { + msg = "Request type=" + verb + " in the text does not match icon type=" + ic + "!
" + "Please change the request type to " + ic + " or revert the icon back to " + "the last saved state using Reset."; failed = true; } @@ -472,12 +761,11 @@ } } - void MvQEditorTextPanel::save() { FILE* f = fopen(current_->path().str().c_str(), "w"); if (f == nullptr) { - //marslog(LOG_EROR|LOG_PERR,"%s",tmp); + // marslog(LOG_EROR|LOG_PERR,"%s",tmp); return; } #ifdef DEBUG_MV_MVQEDITOR__ @@ -493,6 +781,123 @@ check(false); } +void MvQEditorTextPanel::doNotShowWarningAgain() +{ + showEditWarning_ = false; + if (warnLabel_) { + warnLabel_->hide(); + writeSettings(); + } +} + +void MvQEditorTextPanel::readSettings() +{ + static bool alreadyRead = false; + if (!alreadyRead) { + QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MvQEditorTextPanel"); + showEditWarning_ = settings.value("showEditWarning", showEditWarning_).toBool(); + alreadyRead = true; + } +} + +void MvQEditorTextPanel::writeSettings() +{ + QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MvQEditorTextPanel"); + settings.clear(); + settings.setValue("showEditWarning", showEditWarning_); +} + +//================================================ +// +// MvQEditorPythonPanel +// +//================================================ + +MvQEditorPythonPanel::MvQEditorPythonPanel(const IconClass& c, Editor* owner, QWidget* parent) : + QWidget(parent), + class_(c), + owner_(owner) +{ + auto* vb = new QVBoxLayout; + setLayout(vb); + + vb->setSpacing(0); + vb->setContentsMargins(0, 0, 0, 0); + + // Warning label + auto* warnLayout = new QHBoxLayout(); + vb->addLayout(warnLayout); + + warnLabel_ = new MessageLabel(this); + warnLabel_->showInfo("This is the (read-only) preview of the Python code generated from the icon."); + warnLayout->addWidget(warnLabel_, 1); + + // Message label + auto* msgLayout = new QHBoxLayout(); + vb->addLayout(msgLayout); + + msgLabel_ = new MessageLabel(this); + msgLayout->addWidget(msgLabel_, 1); + + // Text editor + te_ = new QPlainTextEdit(this); + te_->setReadOnly(true); + vb->addWidget(te_, 1); + + QFont f = MvQ::findMonospaceFont(); + f.setPointSize(te_->font().pointSize()); + te_->setFont(f); + + // The document becomes the owner of the highlighter + new DocHighlighter(te_->document(), "python"); +} + +void MvQEditorPythonPanel::setObject(IconObject* obj) +{ + current_ = obj; +} + +void MvQEditorPythonPanel::load() +{ + // create a temporary file + Path temp(::marstmp()); + std::string outpath = temp.str(); + + std::string lang = "python"; + std::string numSpaces = "4"; + std::string cmd = "$METVIEW_BIN/mvimportDesktop \"" + current_->fullName() + "\" " + outpath + + " \"" + class_.name() + "\" \"" + numSpaces + "\" " + lang; + + system(cmd.c_str()); + + // qDebug() << st; + + // insert text to the Macro editor + QFile file(temp.str().c_str()); + bool start=true; + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QString t = file.readAll(); + QString r; + for (auto row: t.split('\n')) { + if (!row.startsWith("#")) { + // skip empty rows atop + if (start) { + if (row.simplified().isEmpty()) { + continue; + } else { + start = false; + } + } + r += row + "\n"; + } + } + te_->setPlainText(r); + } + + // delete temporary file + temp.remove(); +} + //================================================ // // MvQEditor @@ -503,7 +908,7 @@ QDialog(parent), Editor(name, kind) { - //Set Window icon + // Set Window icon setWindowIcon(MvQIconProvider::pixmap(name, 24)); auto* vb = new QVBoxLayout; @@ -511,11 +916,10 @@ vb->setContentsMargins(0, 0, 0, 0); setLayout(vb); - //Header + // Header headerPanel_ = new MvQEditorHeader(this, MvQIconProvider::pixmap(name, 32)); vb->addWidget(headerPanel_); - //------------------- // Toolbar //------------------- @@ -524,16 +928,18 @@ toolBarLayout_->setSpacing(0); toolBarLayout_->setContentsMargins(0, 0, 0, 0); - //Widget to provide bg for the toolbars + // Widget to provide bg for the toolbars auto* w = new QWidget(this); w->setProperty("editor", "true"); w->setLayout(toolBarLayout_); vb->addWidget(w); toolbarLeft_ = new QToolBar(this); + toolbarLeft_->setIconSize({16,16}); toolBarLayout_->addWidget(toolbarLeft_); toolbarRight_ = new QToolBar(w); + toolbarRight_->setIconSize({16,16}); toolBarLayout_->addWidget(toolbarRight_); auto* spacer = new QWidget(this); @@ -543,36 +949,53 @@ toolBarLayout_->addWidget(toolbarRight_); toolBarLayout_->addWidget(toolbarRight_); - //Gui edit + auto modeLabel = new QLabel(this); + modeLabel->setText(tr("View mode:")); + toolbarRight_->insertWidget(nullptr, modeLabel); + + // Gui edit guiAc_ = new QAction(this); guiAc_->setIcon(QPixmap(":/desktop/gui_edit.svg")); guiAc_->setCheckable(true); - guiAc_->setToolTip(tr("GUI mode.
To switch between view modes changes have to be saved!")); + guiAc_->setToolTip(tr("GUI view mode")); toolbarRight_->addAction(guiAc_); - //Text edit + // Text edit textAc_ = new QAction(this); textAc_->setIcon(QPixmap(":/desktop/text_edit.svg")); textAc_->setCheckable(true); - textAc_->setToolTip(tr("Text mode.
To switch between view modes changes have to be saved!")); + textAc_->setToolTip(tr("Text view mode")); toolbarRight_->addAction(textAc_); + // Python + pyAc_ = new QAction(this); + pyAc_->setIcon(QPixmap(":/desktop/python.svg")); + pyAc_->setCheckable(true); + pyAc_->setToolTip(tr("Python view mode")); + toolbarRight_->addAction(pyAc_); + viewAg_ = new QActionGroup(this); viewAg_->setExclusive(true); viewAg_->addAction(guiAc_); viewAg_->addAction(textAc_); + viewAg_->addAction(pyAc_); guiAc_->setChecked(true); connect(viewAg_, SIGNAL(triggered(QAction*)), this, SLOT(slotChangeView(QAction*))); - //Search - //QSearchLine - //QLabel - //searchLine_=new QLineEdit(this); - //toolBarLayout_->addStretch(1); + toolbarRight_->addSeparator(); + + // Documentation + webAc_ = new QAction(this); + webAc_->setIcon(QPixmap(":/desktop/web_link.svg")); + webAc_->setToolTip(tr("Documentation")); + toolbarRight_->addAction(webAc_); + + connect(webAc_, SIGNAL(triggered()), + this, SLOT(slotWebDoc())); //--------------------- // Central part @@ -581,18 +1004,21 @@ viewSw_ = new QStackedWidget(this); vb->addWidget(viewSw_, 1); - //Panel layout - w = new QWidget(this); + // Panel layout + w = new QWidget(this); centralLayout_ = new QVBoxLayout; centralLayout_->setSpacing(0); centralLayout_->setContentsMargins(1, 1, 1, 1); w->setLayout(centralLayout_); viewSw_->addWidget(w); - //Text widget + // Text widget textPanel_ = new MvQEditorTextPanel(name, this, this); viewSw_->addWidget(textPanel_); - viewSw_->addWidget(textPanel_); + + // Python widget + pyPanel_ = new MvQEditorPythonPanel(name, this, this); + viewSw_->addWidget(pyPanel_); viewSw_->setCurrentIndex(0); @@ -602,13 +1028,6 @@ drawerPanel_ = new MvQEditorDrawerPanel(this); - /*map drawers=EditorDrawerFactory::create(this); - for(map::iterator j = drawers.begin();j != drawers.end(); ++j) - { - drawerPanel_->addDrawer((*j).second->widget(), - (*j).second->name()); - }*/ - vb->addWidget(drawerPanel_); drawerPanel_->shrink(); @@ -619,20 +1038,20 @@ buttonBox_ = new QDialogButtonBox(this); - savePb_ = buttonBox_->addButton(QDialogButtonBox::Save); - okPb_ = buttonBox_->addButton(QDialogButtonBox::Ok); + savePb_ = buttonBox_->addButton(QDialogButtonBox::Save); + okPb_ = buttonBox_->addButton(QDialogButtonBox::Ok); cancelPb_ = buttonBox_->addButton(QDialogButtonBox::Cancel); - resetPb_ = buttonBox_->addButton(QDialogButtonBox::Reset); + resetPb_ = buttonBox_->addButton(QDialogButtonBox::Reset); savePb_->setDefault(true); savePb_->setEnabled(false); resetPb_->setEnabled(false); /*QCheckBox* stayOpenCb= new QCheckBox(tr("Stay open"),this); - stayOpenCb->setChecked(false); - buttonBox_->addButton(stayOpenCb,QDialogButtonBox::YesRole);*/ + stayOpenCb->setChecked(false); + buttonBox_->addButton(stayOpenCb,QDialogButtonBox::YesRole);*/ - //buttonBox_->addButton(QDialogButtonBox::Close); + // buttonBox_->addButton(QDialogButtonBox::Close); connect(buttonBox_, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotButtonClicked(QAbstractButton*))); @@ -641,6 +1060,9 @@ // to ignore ESC key installEventFilter(this); + + // initialise state + transitionTo(new MvQEditorGuiState(this, false)); } @@ -649,7 +1071,7 @@ bool MvQEditor::eventFilter(QObject* obj, QEvent* event) { - if (static_cast(obj) == this && + if (dynamic_cast(obj) == this && event->type() == QEvent::KeyPress && ((QKeyEvent*)event)->key() == Qt::Key_Escape) { return true; } @@ -659,9 +1081,9 @@ void MvQEditor::setupLineFilter() { - auto label = new QLabel(this); - label->setPixmap(QPixmap(":/desktop/filter_decor.svg")); - toolbarLeft_->insertWidget(nullptr, label); +// auto label = new QLabel(this); +// label->setPixmap(QPixmap(":/desktop/filter_decor.svg")); +// toolbarLeft_->insertWidget(nullptr, label); filterLe_ = new QLineEdit(this); filterLe_->setPlaceholderText("Filter ..."); @@ -725,7 +1147,7 @@ { show(); - //Mimimize the drawer + // Mimimize the drawer drawerPanel_->shrink(); } @@ -734,7 +1156,7 @@ toolbarRight_->insertActions(sepAc_, lst); } -//Iconobserver method +// IconObserver method void MvQEditor::iconChanged(IconObject* obj) { if (obj == current_) { @@ -743,17 +1165,16 @@ } } - void MvQEditor::changed() { if (!temporary_ && !ignoreChange_) { savePb_->setEnabled(true); resetPb_->setEnabled(true); - viewAg_->setEnabled(false); +// viewAg_->setEnabled(false); updateFilterCountLabel(); } - //resetPb_->setEnabled(true); + // resetPb_->setEnabled(true); } void MvQEditor::edit() @@ -761,11 +1182,11 @@ if (!current_) return; - //Set default button status + // Set default button status savePb_->setEnabled(false); resetPb_->setEnabled(false); - //Populate drawers if needed + // Populate drawers if needed if (!drawerFilled_) { std::map drawers = EditorDrawerFactory::create(this); for (auto& drawer : drawers) { @@ -775,31 +1196,33 @@ drawerFilled_ = true; } - //Read the previous size + // Read the previous size readSettings(); - //Header + // Header headerPanel_->updateLabel(current_); - //Title + // Title updateWindowTitle(); - //Text + // Text textPanel_->setObject(current_); + pyPanel_->setObject(current_); - //If request is broken we switch to text mode + // If request is broken we switch to text mode if (!current_->checkRequest()) { textPanel_->load(); viewAg_->setEnabled(false); textAc_->setChecked(true); slotChangeView(textAc_); - //textAc_->toggled(); + // textAc_->toggled(); } - //otherwise we start with gui mode + // otherwise we start with gui mode else { viewAg_->setEnabled(true); guiAc_->setChecked(true); - slotChangeView(guiAc_); // this will call reset + reset(); + slotChangeView(guiAc_); viewAg_->setEnabled(true); } @@ -809,19 +1232,19 @@ okPb_->setEnabled(!current_->locked()); } -bool MvQEditor::isTextMode() const -{ - return (viewSw_->currentIndex() == TextViewMode); -} +//bool MvQEditor::isTextMode() const +//{ +// return (viewSw_->currentIndex() == TextViewMode); +//} void MvQEditor::slotTextChanged() { changed(); } -void MvQEditor::save() +void MvQEditor::pixLabelDragStarted() { - slotButtonClicked(savePb_); + state_->handleSave(); } void MvQEditor::raiseIt() @@ -834,8 +1257,7 @@ void MvQEditor::closeIt() { - close(); - reject(); + state_->handleClose(); } void MvQEditor::rename(QString text) @@ -846,7 +1268,7 @@ if (!text.isEmpty()) { auto n = text.toStdString(); if (n != current_->name()) { - current_->editor(0); + current_->editor(nullptr); current_->rename(n); current_->editor(this); } @@ -855,27 +1277,22 @@ } } -void MvQEditor::slotChangeView(QAction* ac) +void MvQEditor::slotWebDoc() { - if (savePb_->isEnabled()) { - viewAg_->setEnabled(false); - return; + std::string err; + std::string fnName = class_.name(); + metview::toLower(fnName); + std::string url = "https://metview.readthedocs.io/en/latest/gen_files/icon_functions/" + + fnName + ".html#id0"; + if (!metview::openInBrowser(url, err)) { + QMessageBox::warning(this, "Icon editor - Metview", + "Failed to show documentation in web browser!

" + QString::fromStdString(err)); } +} - //From gui to text mode - if (ac == textAc_) { - viewSw_->setCurrentIndex(TextViewMode); - ignoreChange_ = true; - textPanel_->load(); - ignoreChange_ = false; - } - //From text to gui mode - else { - viewSw_->setCurrentIndex(LineViewMode); - ignoreChange_ = true; - reset(); - ignoreChange_ = false; - } +void MvQEditor::slotChangeView(QAction* ac) +{ + state_->handleChangeView(ac); } void MvQEditor::slotButtonClicked(QAbstractButton* button) @@ -884,94 +1301,26 @@ return; if (buttonBox_->standardButton(button) == QDialogButtonBox::Cancel) { - writeSettings(); - - savePb_->setEnabled(false); - resetPb_->setEnabled(false); - - close(); - reject(); + state_->handleClose(); } else if (buttonBox_->standardButton(button) == QDialogButtonBox::Ok) { - writeSettings(); - - //Text mode - if (isTextMode()) { - if (textPanel_->check()) - textPanel_->save(); - else { - viewAg_->setEnabled(false); - return; - } - } - //GUI mode - else { - ignoreChange_ = true; - apply(); - ignoreChange_ = false; - } - - current_->modified(); - notifyObserverApply(); - - savePb_->setEnabled(false); - resetPb_->setEnabled(false); - - close(); - accept(); + state_->handleOk(); } else if (buttonBox_->standardButton(button) == QDialogButtonBox::Save) { - ignoreChange_ = true; - - //Text mode - if (isTextMode()) { - if (textPanel_->check()) - textPanel_->save(); - else { - viewAg_->setEnabled(false); - return; - } - } - //GUI mode - else { - ignoreChange_ = true; - apply(); - ignoreChange_ = false; - } - - current_->modified(); - notifyObserverApply(); - - savePb_->setEnabled(false); - resetPb_->setEnabled(false); - viewAg_->setEnabled(true); + state_->handleSave(); } else if (buttonBox_->standardButton(button) == QDialogButtonBox::Reset) { - //Text mode - if (isTextMode()) - textPanel_->load(); - else { - ignoreChange_ = true; - reset(); - ignoreChange_ = false; - } - - savePb_->setEnabled(false); - resetPb_->setEnabled(false); - viewAg_->setEnabled(true); + state_->handleReset(); } } -void MvQEditor::accept() +void MvQEditor::concludeAccept() { - editDone(); QDialog::accept(); } -void MvQEditor::reject() +void MvQEditor::concludeReject() { - notifyObserverClose(); - editDone(); QDialog::reject(); } @@ -985,9 +1334,7 @@ void MvQEditor::closeEvent(QCloseEvent* event) { - writeSettings(); - close(); - accept(); + state_->handleClose(); event->accept(); } @@ -1005,7 +1352,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-Desktop-Editor-" + QString::fromStdString(class_.name())); - //We have to clear it so that should not remember all the previous values + // We have to clear it so that should not remember all the previous values settings.clear(); settings.beginGroup("main"); @@ -1031,3 +1378,14 @@ readSettings(settings); } + +void MvQEditor::transitionTo(MvQEditorState* state) +{ +#ifdef UI_OUTPUTDIRWIDGET_DEBUG_ + UiLog().dbg() << UI_FN_INFO << "state=" << typeid(*state).name(); +#endif + if (state_ != nullptr) { + state_->deleteLater(); + } + state_ = state; +} diff -Nru metview-5.17.4/metview/src/Desktop/MvQEditor.h metview-5.19.2/metview/src/Desktop/MvQEditor.h --- metview-5.17.4/metview/src/Desktop/MvQEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -37,6 +37,7 @@ class MvQIconTemplateView; class MvQEditor; class MessageLabel; +class MvQEditorState; class MvQEditorDragLabel : public QLabel { @@ -82,7 +83,7 @@ void slotCancelEdit(bool); protected: - void paintEvent(QPaintEvent*); + void paintEvent(QPaintEvent*) override; MvQEditor* owner_{nullptr}; QStackedLayout* stackLayout_{nullptr}; @@ -107,8 +108,41 @@ public slots: void slotTextChanged(); -protected: +protected slots: + void doNotShowWarningAgain(); + +private: void loadRequestFile(); + void readSettings(); + void writeSettings(); + + static bool showEditWarning_; + const IconClass& class_; + Editor* owner_{nullptr}; + IconObject* current_{nullptr}; + QPlainTextEdit* te_{nullptr}; + MessageLabel* infoLabel_{nullptr}; + MessageLabel* warnLabel_{nullptr}; + MessageLabel* msgLabel_{nullptr}; + bool correct_{true}; + bool beingLoaded_{false}; +}; + +class MvQEditorPythonPanel : public QWidget +{ +public: + MvQEditorPythonPanel(const IconClass&, Editor*, QWidget*); + +// bool check(bool fromSave = true); + void setObject(IconObject*); +// void save(); + void load(); + +//public slots: +// void slotTextChanged(); + +protected: +// void loadRequestFile(); const IconClass& class_; Editor* owner_{nullptr}; @@ -120,39 +154,47 @@ bool beingLoaded_{false}; }; + class MvQEditor : public QDialog, public Editor { Q_OBJECT + friend class MvQEditorState; + friend class MvQEditorGuiState; + friend class MvQEditorTextState; + friend class MvQEditorPythonState; + public: - MvQEditor(const IconClass& name, const std::string& kind, QWidget* parent = 0); - virtual ~MvQEditor(); + MvQEditor(const IconClass& name, const std::string& kind, QWidget* parent = nullptr); + ~MvQEditor() override; void changed() override; - virtual void merge(IconObjectH) = 0; + virtual void merge(IconObjectH) = 0; virtual void replace(IconObjectH) = 0; void rename(QString); - //Observer method + // Observer method void iconChanged(IconObject*) override; public slots: void slotChangeView(QAction*); void slotButtonClicked(QAbstractButton*); - void accept() override; - void reject() override; +// void accept() override; +// void reject() override; void slotTextChanged(); protected slots: virtual void slotFilterItems(QString) = 0; - virtual void slotShowDisabled(bool) = 0; - void save(); + virtual void slotShowDisabled(bool) = 0; + void slotWebDoc(); + void pixLabelDragStarted(); protected: enum ViewMode { LineViewMode = 0, - TextViewMode = 1 + TextViewMode = 1, + PythonViewMode = 2 }; bool eventFilter(QObject* obj, QEvent* event) override; @@ -169,15 +211,18 @@ virtual void apply() = 0; virtual void reset() = 0; virtual void close() = 0; - virtual void edit() override; - virtual void temporary() override; + void edit() override; + void temporary() override; + void concludeAccept(); + void concludeReject(); void closeEvent(QCloseEvent*) override; void readSettings(); void writeSettings(); - virtual void readSettings(QSettings&) = 0; + virtual void readSettings(QSettings&) = 0; virtual void writeSettings(QSettings&) = 0; - bool isTextMode() const; +// bool isTextMode() const; + void transitionTo(MvQEditorState* state); QLabel* headerLabel_{nullptr}; QLineEdit* headerEdit_{nullptr}; @@ -188,7 +233,9 @@ QAction* sepAc_{nullptr}; QAction* guiAc_{nullptr}; QAction* textAc_{nullptr}; + QAction* pyAc_{nullptr}; QActionGroup* viewAg_{nullptr}; + QAction* webAc_{nullptr}; QVBoxLayout* centralLayout_{nullptr}; @@ -204,10 +251,12 @@ QToolBar* toolbarLeft_{nullptr}; QToolBar* toolbarRight_{nullptr}; MvQEditorTextPanel* textPanel_{nullptr}; + MvQEditorPythonPanel* pyPanel_{nullptr}; private: void updateWindowTitle(); QHBoxLayout* toolBarLayout_{nullptr}; bool ignoreChange_{false}; + MvQEditorState* state_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQEditorListMenu.cc metview-5.19.2/metview/src/Desktop/MvQEditorListMenu.cc --- metview-5.17.4/metview/src/Desktop/MvQEditorListMenu.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEditorListMenu.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ QObject(menu), menu_(menu) { - //Populate + // Populate updateMenu(); connect(menu_, SIGNAL(triggered(QAction*)), @@ -52,15 +52,15 @@ { Q_ASSERT(e); - //the editor can be already in the list, e.g. when it is open and we - //double click on its icon to raise it + // the editor can be already in the list, e.g. when it is open and we + // double click on its icon to raise it if (editors_.contains(e)) { return; } editors_ << e; sortList(); - //reload the editor list in each window + // reload the editor list in each window foreach (MvQEditorListMenu* item, items_) { item->updateMenu(); } @@ -71,14 +71,14 @@ if (editors_.removeAll(e) > 0) { sortList(); - //reload the editor list in each window + // reload the editor list in each window foreach (MvQEditorListMenu* item, items_) { item->updateMenu(); } } } -//sort editor list by iconclass +// sort editor list by iconclass void MvQEditorListMenu::sortList() { QMap > editorMap; @@ -103,7 +103,7 @@ for (int i = 0; i < editors_.count(); i++) { Editor* e = editors_[i]; - auto* ac = new QAction(menu_); + auto* ac = new QAction(menu_); auto name = QString::fromStdString(e->current()->fullName()); ac->setText(name); ac->setIcon(MvQIconProvider::pixmap(e->iconClass(), 16)); diff -Nru metview-5.17.4/metview/src/Desktop/MvQEditorListMenu.h metview-5.19.2/metview/src/Desktop/MvQEditorListMenu.h --- metview-5.17.4/metview/src/Desktop/MvQEditorListMenu.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQEditorListMenu.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,14 +20,14 @@ public: MvQEditorListMenu(QMenu*); - ~MvQEditorListMenu(); + ~MvQEditorListMenu() override; static void add(Editor*); static void remove(Editor*); static void initDockMenu(); public slots: - //void slotUpdate(); + // void slotUpdate(); void slotMenu(QAction*); protected: @@ -42,7 +42,7 @@ static MvQEditorListMenu* dockMenu_; #endif - //QAction* actionFolder_; - //QAction* actionTabs_; - //QAction* actionAdd_; + // QAction* actionFolder_; + // QAction* actionTabs_; + // QAction* actionAdd_; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQExternalHelp.cc metview-5.19.2/metview/src/Desktop/MvQExternalHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQExternalHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQExternalHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,43 +41,43 @@ void MvQExternalHelp::reply(const Request& reply, int error) { - //cout << "ExternalHelp::reply" << std::endl; + // cout << "ExternalHelp::reply" << std::endl; if (error == 0) reply.print(); } void MvQExternalHelp::progress(const Request& progress) { - //cout << "ExternalHelp::progress" << std::endl; + // cout << "ExternalHelp::progress" << std::endl; progress.print(); request_ = progress; - //owner_.changed(*this); + // owner_.changed(*this); } void MvQExternalHelp::message(const std::string& /*msg*/) { - //cout << "MvQExternalHelp::message" << msg << std::endl; + // cout << "MvQExternalHelp::message" << msg << std::endl; } /*void MvQExternalHelp::message(const Request& msg) { - std::string s = msg.getVerb(); - if (s != "INPUT") return; + std::string s = msg.getVerb(); + if (s != "INPUT") return; request_ = owner_.request(); - request_.merge(msg); - - int cnt = msg.countValues(param_.name()); - std::vector res; - for(int i=0; i res; + for(int i=0; i maker("help_external"); +// static HelpMaker maker("help_external"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQExternalHelp.h metview-5.19.2/metview/src/Desktop/MvQExternalHelp.h --- metview-5.17.4/metview/src/Desktop/MvQExternalHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQExternalHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,20 +22,20 @@ { public: MvQExternalHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQExternalHelp() = default; + ~MvQExternalHelp() override = default; - void start(); - bool dialog() { return true; } - QWidget* widget() { return 0; } + void start() override; + bool dialog() override { return true; } + QWidget* widget() override { return nullptr; } protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; virtual long flags() { return 9; } virtual void set(Request&); - void reply(const Request&, int); - void progress(const Request&); - void message(const std::string&); + void reply(const Request&, int) override; + void progress(const Request&) override; + void message(const std::string&) override; Request request_; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQFileBrowser.cc metview-5.19.2/metview/src/Desktop/MvQFileBrowser.cc --- metview-5.17.4/metview/src/Desktop/MvQFileBrowser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFileBrowser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -58,7 +58,7 @@ #include "Folder.h" #include "Tools.h" -bool MvQFileBrowser::quitStarted_ = false; +bool MvQFileBrowser::quitStarted_ = false; bool MvQFileBrowser::sessionLogoutStarted_ = false; QList MvQFileBrowser::browsers_; @@ -79,7 +79,7 @@ setWindowTitle("Metview - Desktop"); - //Initial size + // Initial size setInitialSize(1100, 800); setMovableToolBars(false); @@ -103,7 +103,7 @@ mainSplitter_ = new QSplitter(this); mainSplitter_->setOpaqueResize(false); - //drawerSplitter_->addWidget(mainSplitter_); + // drawerSplitter_->addWidget(mainSplitter_); mainLayout->addWidget(mainSplitter_, 1); //------------------------------ @@ -115,7 +115,7 @@ mainSplitter_->addWidget(sidebar_); mainSplitter_->setCollapsible(0, false); - //User bookmarks + // User bookmarks bookmarksPanel_ = new MvQBookmarksPanel(this); sidebar_->addWidget(bookmarksPanel_->widget()); @@ -134,7 +134,7 @@ mainSplitter_->addWidget(w); mainSplitter_->setStretchFactor(1, 1); - //Folder panel to store all the widgets + // Folder panel to store all the widgets folderPanel_ = new MvQFolderPanel(this); centralVb->addWidget(folderPanel_); @@ -148,7 +148,7 @@ this, SLOT(slotItemInfo(IconObject*))); - //Search panel below the folders + // Search panel below the folders searchPanel_ = new MvQFolderSearchPanel(this); centralVb->addWidget(searchPanel_); @@ -170,7 +170,7 @@ folderPanel_->setPreviewPanel(previewPanel_); previewPanel_->hide(); - //Init splitters + // Init splitters int spWidth = mainSplitter_->size().width(); if (spWidth > 0) { QList spSize; @@ -220,8 +220,8 @@ connect(searchPanel_, SIGNAL(iconSelected(IconObject*)), folderPanel_, SLOT(slotShowIconInCurrent(IconObject*))); - //Setup - //updateNavigationActionState(); + // Setup + // updateNavigationActionState(); //----------------------------- // Statusbar @@ -241,10 +241,10 @@ MvQFileBrowser::~MvQFileBrowser() = default; -//Show the brower for the first time! +// Show the brower for the first time! void MvQFileBrowser::showIt() { - //We need to reset the size to the expected value. See METV-2271 + // We need to reset the size to the expected value. See METV-2271 QVariant expectedSize = property("expectedSize"); if (expectedSize.isValid() && expectedSize.toSize().isValid()) { resize(expectedSize.toSize()); @@ -254,7 +254,7 @@ show(); - //Minimise the drawer panel! + // Minimise the drawer panel! drawerPanel_->shrink(); } @@ -289,9 +289,9 @@ } -//This slot is called when the window mangager quits to ask the app to -//close in a correct way. We set the sessionLogoutStarted_ flag to indicate that -//this happened. +// This slot is called when the window mangager quits to ask the app to +// close in a correct way. We set the sessionLogoutStarted_ flag to indicate that +// this happened. void MvQFileBrowser::slotCommitDataRequest(QSessionManager&) { sessionLogoutStarted_ = true; @@ -318,18 +318,18 @@ ac = new QAction(this); ac->setToolTip(tr("Open a new window")); ac->setText(tr("New &window")); - //ac->setShortcut(tr("Ctrl+N")); + // ac->setShortcut(tr("Ctrl+N")); QAction* newWinAction = ac; connect(newWinAction, SIGNAL(triggered(bool)), folderPanel_, SLOT(slotNewWindow(bool))); - //Close + // Close QAction* closeAction = createAction(MvQMainWindow::CloseAction, this); connect(closeAction, SIGNAL(triggered()), this, SLOT(close())); - //Quit application + // Quit application QAction* quitAction = createAction(MvQMainWindow::QuitAction, this); connect(quitAction, SIGNAL(triggered()), this, SLOT(slotQuit())); @@ -350,46 +350,46 @@ void MvQFileBrowser::setupEditActions() { /*QAction *actionSearch=MvQMainWindow::createAction(MvQMainWindow::FindAction,this); - connect(actionSearch,SIGNAL(triggered(bool)), - searchPanel_,SLOT(openPanel(bool))); - - QAction *actionSearchNext=MvQMainWindow::createAction(MvQMainWindow::FindNextAction,this); - connect(actionSearchNext,SIGNAL(triggered()), - searchPanel_,SLOT(slotFindNext())); - - QAction *actionSearchPrev=MvQMainWindow::createAction(MvQMainWindow::FindPreviousAction,this); - connect(actionSearchPrev,SIGNAL(triggered()), - searchPanel_,SLOT(slotFindPrev())); - - - //Add actions to menu and toolbar - MvQMainWindow::MenuType menuType=MvQMainWindow::EditMenu; - - menuItems_[menuType].push_back(new MvQMenuItem(actionSearch,MvQMenuItem::MenuTarget)); - menuItems_[menuType].push_back(new MvQMenuItem(actionSearchNext,MvQMenuItem::MenuTarget)); - menuItems_[menuType].push_back(new MvQMenuItem(actionSearchPrev,MvQMenuItem::MenuTarget));*/ + connect(actionSearch,SIGNAL(triggered(bool)), + searchPanel_,SLOT(openPanel(bool))); - //Icon object actions + QAction *actionSearchNext=MvQMainWindow::createAction(MvQMainWindow::FindNextAction,this); + connect(actionSearchNext,SIGNAL(triggered()), + searchPanel_,SLOT(slotFindNext())); + + QAction *actionSearchPrev=MvQMainWindow::createAction(MvQMainWindow::FindPreviousAction,this); + connect(actionSearchPrev,SIGNAL(triggered()), + searchPanel_,SLOT(slotFindPrev())); + + + //Add actions to menu and toolbar + MvQMainWindow::MenuType menuType=MvQMainWindow::EditMenu; + + menuItems_[menuType].push_back(new MvQMenuItem(actionSearch,MvQMenuItem::MenuTarget)); + menuItems_[menuType].push_back(new MvQMenuItem(actionSearchNext,MvQMenuItem::MenuTarget)); + menuItems_[menuType].push_back(new MvQMenuItem(actionSearchPrev,MvQMenuItem::MenuTarget));*/ + + // Icon object actions /*MvQContextItemSet set("DesktopMain"); - QActionGroup *iconObjAg=new QActionGroup(this); - - foreach(MvQContextItem *item,set.icon()) - { - if(QAction *ac=static_cast(item)) - { - iconObjAg->addAction(ac); - folderPanel_->addIconAction(ac); - menuItems_[menuType].push_back(new MvQMenuItem(ac,MvQMenuItem::MenuTarget)); - } - } - - connect(iconObjAg,SIGNAL(triggered(QAction*)), - folderPanel_,SLOT(slotIconCommand(QAction*)));*/ + QActionGroup *iconObjAg=new QActionGroup(this); + + foreach(MvQContextItem *item,set.icon()) + { + if(QAction *ac=static_cast(item)) + { + iconObjAg->addAction(ac); + folderPanel_->addIconAction(ac); + menuItems_[menuType].push_back(new MvQMenuItem(ac,MvQMenuItem::MenuTarget)); + } + } + + connect(iconObjAg,SIGNAL(triggered(QAction*)), + folderPanel_,SLOT(slotIconCommand(QAction*)));*/ } void MvQFileBrowser::setupNavigateActions() { - //Back + // Back actionBack_ = new QAction(this); actionBack_->setIcon(QPixmap(QString::fromUtf8(":/desktop/big_arrow_left.svg"))); actionBack_->setToolTip(tr("Back")); @@ -399,7 +399,7 @@ connect(actionBack_, SIGNAL(triggered()), folderPanel_, SLOT(slotChFolderBack())); - //Forward + // Forward actionForward_ = new QAction(this); actionForward_->setIcon(QPixmap(QString::fromUtf8(":/desktop/big_arrow_right.svg"))); actionForward_->setToolTip(tr("Forward")); @@ -409,7 +409,7 @@ connect(actionForward_, SIGNAL(triggered()), folderPanel_, SLOT(slotChFolderForward())); - //Parent + // Parent actionParent_ = new QAction(this); actionParent_->setIcon(QPixmap(QString::fromUtf8(":/desktop/big_arrow_up.svg"))); actionParent_->setToolTip(tr("Up")); @@ -420,7 +420,7 @@ connect(actionParent_, SIGNAL(triggered()), folderPanel_, SLOT(slotChFolderParent())); - //Home + // Home actionMvHome_ = new QAction(this); actionMvHome_->setIcon(QPixmap(QString::fromUtf8(":/desktop/home.svg"))); actionMvHome_->setToolTip(tr("Metview home")); @@ -431,7 +431,7 @@ connect(actionMvHome_, SIGNAL(triggered()), folderPanel_, SLOT(slotChFolderMvHome())); - //Wastebin + // Wastebin actionWastebasket_ = new QAction(this); actionWastebasket_->setIcon(QPixmap(QString::fromUtf8(":/desktop/wastebasket.svg"))); actionWastebasket_->setToolTip(tr("&Wastebasket")); @@ -442,14 +442,14 @@ connect(actionWastebasket_, SIGNAL(triggered()), folderPanel_, SLOT(slotChFolderWastebasket())); - //Defaults + // Defaults actionDefaults_ = new QAction(this); actionDefaults_->setToolTip(tr("Defaults")); actionDefaults_->setText(tr("&Defaults")); connect(actionDefaults_, SIGNAL(triggered()), folderPanel_, SLOT(slotChFolderDefaults())); - //Breadcrumbs + // Breadcrumbs breadcrumbs_ = new MvQPathWidget(this); connect(breadcrumbs_, SIGNAL(dirChanged(QString)), @@ -471,15 +471,15 @@ menuItems_[menuType].push_back(new MvQMenuItem(actionWastebasket_, MvQMenuItem::MenuTarget)); menuItems_[menuType].push_back(new MvQMenuItem(actionDefaults_, MvQMenuItem::MenuTarget)); menuItems_[menuType].push_back(new MvQMenuItem(breadcrumbs_, MvQMenuItem::ToolBarTarget)); - //menuItems_[menuType].push_back(new MvQMenuItem(locationCombo_,MvQMenuItem::ToolBarTarget)); + // menuItems_[menuType].push_back(new MvQMenuItem(locationCombo_,MvQMenuItem::ToolBarTarget)); breadcrumbs_->setPath("/"); } void MvQFileBrowser::setupBookmarksActions() { - //We need at least one action to create the menu. We will populate it later dinamically - QAction* action = 0; + // We need at least one action to create the menu. We will populate it later dinamically + QAction* action = nullptr; MvQMainWindow::MenuType menuType = MvQMainWindow::BookmarksMenu; menuItems_[menuType].push_back(new MvQMenuItem(action, MvQMenuItem::MenuTarget)); @@ -487,8 +487,8 @@ void MvQFileBrowser::setupHistoryActions() { - //We need at least one action to create the menu. We will populate it later dinamically - QAction* action = 0; + // We need at least one action to create the menu. We will populate it later dinamically + QAction* action = nullptr; MvQMainWindow::MenuType menuType = MvQMainWindow::HistoryMenu; menuItems_[menuType].push_back(new MvQMenuItem(action, MvQMenuItem::MenuTarget)); @@ -496,8 +496,8 @@ void MvQFileBrowser::setupEditorActions() { - //We need at least one action to create the menu. We will populate it later dinamically - QAction* action = 0; + // We need at least one action to create the menu. We will populate it later dinamically + QAction* action = nullptr; MvQMainWindow::MenuType menuType = MvQMainWindow::EditorMenu; menuItems_[menuType].push_back(new MvQMenuItem(action, MvQMenuItem::MenuTarget)); @@ -505,14 +505,12 @@ void MvQFileBrowser::setupViewActions() { - QAction* action; + QAction* action = nullptr; //-------------- // View mode //-------------- - QList viewModeLst; - auto* viewModeMenu = new QMenu(this); viewModeMenu->setObjectName(QString::fromUtf8("viewModeSubMenu")); viewModeMenu->setTitle(tr("&View mode")); @@ -602,8 +600,8 @@ action = new QAction(this); action->setObjectName(QString::fromUtf8("actionShowlast")); action->setText(tr("Show &last icon created")); - //action->setIcon(QPixmap(QString::fromUtf8(":/desktop/reload.svg"))); - //action->setShortcut(tr("F5")); + // action->setIcon(QPixmap(QString::fromUtf8(":/desktop/reload.svg"))); + // action->setShortcut(tr("F5")); action->setData("showLastIcon"); folderPanel_->addDesktopAction(action); QAction* actionLastIcon = action; @@ -611,7 +609,7 @@ connect(actionLastIcon, SIGNAL(triggered(bool)), folderPanel_, SLOT(slotShowLastCreated(bool))); - //Add reload action to the breadcrumbs + // Add reload action to the breadcrumbs breadcrumbs_->setReloadAction(actionReload); //----------------------------------- @@ -621,7 +619,7 @@ sidebarAg_ = new QActionGroup(this); sidebarAg_->setExclusive(false); - //Bookmarks + // Bookmarks action = new QAction(this); action->setObjectName(QString::fromUtf8("actionSidebar")); action->setCheckable(true); @@ -641,7 +639,7 @@ // Preview panel //----------------------------------- - //Preview + // Preview action = new QAction(this); action->setObjectName(QString::fromUtf8("actionPreview")); action->setCheckable(true); @@ -650,7 +648,7 @@ action->setIcon(QPixmap(QString::fromUtf8(":/desktop/preview.svg"))); action->setShortcut(tr("Ctrl+P")); actionPreview_ = action; - //sidebarAg_->addAction(action); + // sidebarAg_->addAction(action); connect(previewPanel_, SIGNAL(closePanel()), this, SLOT(slotClosePreview())); @@ -662,26 +660,26 @@ // Bottom part //------------------------------- - //Drawers + // Drawers actionDrawers_ = new QAction(this); actionDrawers_->setObjectName(QString::fromUtf8("actionDrawers")); actionDrawers_->setCheckable(true); actionDrawers_->setChecked(true); //!!! actionDrawers_->setText(tr("&Drawers")); - //actionDrawers_->setIcon(QPixmap(QString::fromUtf8(":/desktop/drawer.svg"))); - //actionDrawers_->setShortcut(tr("Ctrl+")); + // actionDrawers_->setIcon(QPixmap(QString::fromUtf8(":/desktop/drawer.svg"))); + // actionDrawers_->setShortcut(tr("Ctrl+")); connect(actionDrawers_, SIGNAL(toggled(bool)), drawerPanel_, SLOT(setVisible(bool))); - //Statusbar + // Statusbar actionStatusbar_ = new QAction(this); actionStatusbar_->setObjectName(QString::fromUtf8("actionStatusbar")); actionStatusbar_->setCheckable(true); actionStatusbar_->setChecked(true); //!!! actionStatusbar_->setText(tr("S&tatusbar")); - //actionStatusbar_->setIcon(QPixmap(QString::fromUtf8(":/desktop/statusbar.svg"))); - //actionStatusbar_->setShortcut(tr("Ctrl+")); + // actionStatusbar_->setIcon(QPixmap(QString::fromUtf8(":/desktop/statusbar.svg"))); + // actionStatusbar_->setShortcut(tr("Ctrl+")); connect(actionStatusbar_, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool))); @@ -711,7 +709,7 @@ folderPanel_->addDesktopAction(action); actionIconSizeUp_ = action; - //Folder settings + // Folder settings action = new QAction(this); action->setText(tr("Apply icon size to all open folders")); @@ -743,8 +741,8 @@ connect(actionIconSizeUp_, SIGNAL(triggered()), this, SLOT(slotIconSizeUp())); - //It is important to use triggered because it will not emit a signal if - //setChecked is called! + // It is important to use triggered because it will not emit a signal if + // setChecked is called! connect(actionGlobalIconSize_, SIGNAL(triggered()), this, SLOT(slotGlobalIconSize())); @@ -766,7 +764,7 @@ auto* sep3 = new QAction(this); sep3->setSeparator(true); - //Build menuitems + // Build menuitems MvQMainWindow::MenuType menuType = MvQMainWindow::ViewMenu; @@ -816,7 +814,7 @@ menuItems_[menuType].push_back(new MvQMenuItem(actionDrawers_, MvQMenuItem::MenuTarget)); menuItems_[menuType].push_back(new MvQMenuItem(actionStatusbar_, MvQMenuItem::MenuTarget)); - //Viewmode action group + // Viewmode action group viewModeAg_ = new QActionGroup(this); viewModeAg_->setExclusive(true); @@ -841,7 +839,7 @@ QList lst; Tools::make(lst, this); - //Preferences + // Preferences auto* actionPref = new QAction(this); actionPref->setIcon(QPixmap(":/desktop/cogwheel.svg")); actionPref->setToolTip(tr("Preferences")); @@ -850,7 +848,7 @@ connect(actionPref, SIGNAL(triggered()), this, SLOT(slotPreferences())); - //Icon filter + // Icon filter auto* actionFilter = new QAction(this); actionFilter->setIcon(QPixmap(":/desktop/filter.svg")); actionFilter->setToolTip(tr("Show icon filter bar")); @@ -889,7 +887,7 @@ connect(actionFilter, SIGNAL(toggled(bool)), actionFilterPrev, SLOT(setEnabled(bool))); - //Find + // Find auto* actionFind = new QAction(this); actionFind->setIcon(QPixmap(":/desktop/search.svg")); actionFind->setToolTip(tr("Search icons")); @@ -902,14 +900,14 @@ #ifdef USE_PRODUCT_BROWSER QAction* actionProduct = new QAction(this); actionProduct->setText(tr("Product browser ...")); - //actionProduct->setShortcut(tr("Ctrl+Alt+F")); + // actionProduct->setShortcut(tr("Ctrl+Alt+F")); connect(actionProduct, SIGNAL(triggered()), this, SLOT(slotProductBrowser())); #endif - //Add actions to menus and toolbars + // Add actions to menus and toolbars MvQMainWindow::MenuType menuType = MvQMainWindow::ToolsMenu; menuItems_[menuType].push_back(new MvQMenuItem(actionLog, MvQMenuItem::MenuTarget)); @@ -959,31 +957,31 @@ void MvQFileBrowser::setupIconSizeWidget() { - //Descrease size + // Descrease size auto* tb = new QToolButton(this); tb->setDefaultAction(actionIconSizeDown_); tb->setAutoRaise(true); statusBar()->addPermanentWidget(tb); - //Slider + // Slider iconSizeSlider_ = new MvQSlider(this); iconSizeSlider_->setOrientation(Qt::Horizontal); iconSizeSlider_->setRange(0, iconSizes_.count() - 1); - //int index=iconSizes_.indexOf(currentIconSize_); - //iconSizeSlider_->setValue(index); + // int index=iconSizes_.indexOf(currentIconSize_); + // iconSizeSlider_->setValue(index); iconSizeSlider_->setMaximumWidth(90); statusBar()->addPermanentWidget(iconSizeSlider_); connect(iconSizeSlider_, SIGNAL(valueChanged(int)), this, SLOT(slotSetIconSizeByIndex(int))); - //Increase size + // Increase size tb = new QToolButton(this); tb->setDefaultAction(actionIconSizeUp_); tb->setAutoRaise(true); statusBar()->addPermanentWidget(tb); - //Global size + // Global size tb = new QToolButton(this); tb->setAutoRaise(true); tb->setIcon(QIcon(QPixmap(QString::fromUtf8(":/desktop/cogwheel.svg")))); @@ -1002,7 +1000,7 @@ updateIconSizeActionState(); updateSearchPanel(); - //Update window title + // Update window title updateWindowTitle(); } @@ -1012,9 +1010,9 @@ slotUpdateNavigationActions(folderPanel_->folderNavigation()); updateViewModeStatus(folderPanel_->viewMode()); updateIconSizeActionState(); - //updateSearchPanel(); + // updateSearchPanel(); - //Update window title + // Update window title updateWindowTitle(); } @@ -1044,7 +1042,7 @@ if (!nav) return; - //nav->print(); + // nav->print(); breadcrumbs_->setPath(folderPanel_->currentFolderPath()); updateIconSizeActionState(); @@ -1070,7 +1068,7 @@ actionParent_->setEnabled(true); } - //nav->print(); + // nav->print(); } void MvQFileBrowser::slotChangeViewMode(QAction* action) @@ -1117,7 +1115,7 @@ MvQProductBrowser pb(this); pb.exec(); - //MvQAdvancedSearchDialog::open(this,folderPanel_->currentFolder()); + // MvQAdvancedSearchDialog::open(this,folderPanel_->currentFolder()); #endif } @@ -1321,7 +1319,7 @@ updateIconSizeActionState(); } -//Callback from the slider +// Callback from the slider void MvQFileBrowser::slotSetIconSizeByIndex(int index) { if (ignoreIconSizeSlider_) @@ -1344,9 +1342,9 @@ void MvQFileBrowser::slotGlobalIconSize() { /*if(QMessageBox::warning(this,tr("Use global icon size"),"You are about to enter a mode when all the folders has the same icon size and all changes to the iconsize is automatically broadcast to all the open folders. Do you want to proceed?",QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Cancel) - { - return; - }*/ + { + return; + }*/ int index = iconSizes_.indexOf(folderPanel_->iconSize()); if (index >= 0 && index < iconSizes_.count() - 1) { @@ -1357,7 +1355,7 @@ void MvQFileBrowser::slotSaveViewAsDefault() { /*if(QMessageBox::warning(this,tr("Save view settings as default"),"You are about to save the current view mode and iconsize as defaults. These will be applied for all unvisited folders in the future. Do you want to proceed?",QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Cancel) - return;*/ + return;*/ FolderSettings::setDefaults(folderPanel_->viewMode(), folderPanel_->iconSize()); } @@ -1399,7 +1397,7 @@ //======================================== // -//Init +// Init // //======================================== @@ -1408,7 +1406,7 @@ if (!browser) return; - //actionIconSidebar_->setChecked(browser->actionIconSidebar_->isChecked()); + // actionIconSidebar_->setChecked(browser->actionIconSidebar_->isChecked()); if (QAction* ac = browser->sidebarAg_->checkedAction()) { int index = browser->sidebarAg_->actions().indexOf(ac); sidebarAg_->actions().at(index)->setChecked(true); @@ -1435,7 +1433,7 @@ { settings.setValue("geometry", saveGeometry()); settings.setValue("state", saveState()); - //settings.setValue("drawerSplitter",drawerSplitter_->saveState()); + // settings.setValue("drawerSplitter",drawerSplitter_->saveState()); settings.setValue("mainSplitter", mainSplitter_->saveState()); int sidebarIndex = -1; @@ -1458,25 +1456,25 @@ { restoreGeometry(settings.value("geometry").toByteArray()); - //we need to save the expected size to reset the size later. See METV-2271 + // we need to save the expected size to reset the size later. See METV-2271 setProperty("expectedSize", size()); restoreState(settings.value("state").toByteArray()); mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); - //drawerSplitter_->restoreState(settings.value("drawerSplitter").toByteArray()); + // drawerSplitter_->restoreState(settings.value("drawerSplitter").toByteArray()); /*QString viewMode=settings.value("viewMode").toString(); - if(viewMode == MvQFileBrowserWidget::DetailedViewMode) - actionIconView_->trigger(); - else if(viewMode == MvQFileBrowserWidget::DetailedViewMode) - actionDetailedView_->trigger();*/ + if(viewMode == MvQFileBrowserWidget::DetailedViewMode) + actionIconView_->trigger(); + else if(viewMode == MvQFileBrowserWidget::DetailedViewMode) + actionDetailedView_->trigger();*/ QVariant var = settings.value("iconSize"); if (!var.isNull()) { slotSetIconSizeByIndex(iconSizes_.indexOf(var.toInt())); } - //By default sidebar actions are uncheked + // By default sidebar actions are uncheked if (!settings.value("sidebar").isNull()) { int index = settings.value("sidebar").toInt(); if (index >= 0 && index < sidebarAg_->actions().count()) { @@ -1572,33 +1570,33 @@ qDebug() << "aboutToQuit"; quitStarted_ = true; - //Save bookmarks + // Save bookmarks MvQBookmarks::save(); - //Save most recent icons list + // Save most recent icons list MvQRecentIcons::save(); - //Save browser settings + // Save browser settings MvQFileBrowser::save(topBrowser); qDebug() << " save done!"; qDebug() << " calls app quit"; - //Exit metview + // Exit metview QApplication::quit(); qDebug() << " app quit called!"; } void MvQFileBrowser::init() { - //Read the settings + // Read the settings QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-Desktop"); std::cout << "MvQFileBrowser::init settings path is: " << settings.fileName().toStdString() << std::endl; settings.beginGroup("main"); if (settings.contains("browserCount")) { - int cnt = settings.value("browserCount").toInt(); + int cnt = settings.value("browserCount").toInt(); int topBrowserId = settings.value("topBrowserId").toInt(); MvQFolderHistory::init(settings.value("history").toStringList()); settings.endGroup(); @@ -1623,12 +1621,12 @@ } } - //Try to read the resource file from MetviewUI + // Try to read the resource file from MetviewUI else { loadMetviewUIFolders(); } - //If nothing has been found we open the home folder + // If nothing has been found we open the home folder if (browsers_.count() == 0) { MvQFileBrowser::makeBrowser(QString::fromStdString(Folder::top()->fullName())); } @@ -1636,7 +1634,7 @@ void MvQFileBrowser::loadMetviewUIFolders() { - //Try to read the resource file from MetviewUI + // Try to read the resource file from MetviewUI Path p = Folder::top()->path().add(".MainWindowResources"); MvRequest req(p.loadRequest()); @@ -1644,7 +1642,7 @@ QStringList pathLst; int cnt = req.iterInit("OPEN"); for (int i = 0; i < cnt; ++i) { - const char* c = 0; + const char* c = nullptr; req.iterGetNextValue(c); if (c) { QString str(c); @@ -1663,7 +1661,7 @@ void MvQFileBrowser::save(MvQFileBrowser* topBrowser) { - //Save folder info for all the open browsers + // Save folder info for all the open browsers for (int i = 0; i < browsers_.count(); i++) { browsers_.at(i)->saveFolderInfo(); } @@ -1671,7 +1669,7 @@ QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-Desktop"); std::cout << "MvQFileBrowser::save settings path is: " << settings.fileName().toStdString() << std::endl; - //We have to clear it not to remember all the previous windows + // We have to clear it not to remember all the previous windows settings.clear(); settings.beginGroup("main"); @@ -1700,33 +1698,33 @@ MvQFileBrowser* MvQFileBrowser::findBrowser(QWidget* childW) { if (!childW) - return 0; + return nullptr; foreach (MvQFileBrowser* b, browsers_) { if (static_cast(b) == childW->window()) return b; } - return 0; + return nullptr; } void MvQFileBrowser::locate(QWidget* winPref, QString path, QString name) { - //Find the folder of the icon + // Find the folder of the icon Folder* f = Folder::folder(path.toStdString(), false); if (!f) { return; } - //Get the IconObject + // Get the IconObject IconObject* obj = f->find(name.toStdString()); if (!obj) return; - //The preferred browser to show the icon + // The preferred browser to show the icon MvQFileBrowser* bPref = findBrowser(winPref); - //We try to show the icon the preferred browser + // We try to show the icon the preferred browser if (bPref) { if (bPref->showIcon(obj, false)) { bPref->raise(); @@ -1734,7 +1732,7 @@ } } - //If the preferred browser does not contan the icon icon we try the other browsers + // If the preferred browser does not contan the icon icon we try the other browsers for (int i = 0; i < browsers_.count(); i++) { if (browsers_.at(i) != bPref && browsers_.at(i)->showIcon(obj, false)) { browsers_.at(i)->raise(); @@ -1742,13 +1740,13 @@ } } - //If none of the browsers contain the icon add its folder - //to the preferred browser (as a tab) and locate the icon in it + // If none of the browsers contain the icon add its folder + // to the preferred browser (as a tab) and locate the icon in it if (bPref) { bPref->showIcon(obj, true); bPref->raise(); } - //In case there is no preffered browser + // In case there is no preffered browser else if (browsers_.count() > 0) { browsers_.at(0)->showIcon(obj, true); browsers_.at(0)->raise(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFileBrowser.h metview-5.19.2/metview/src/Desktop/MvQFileBrowser.h --- metview-5.17.4/metview/src/Desktop/MvQFileBrowser.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFileBrowser.h 2023-07-15 08:28:47.000000000 +0000 @@ -59,13 +59,13 @@ Q_OBJECT public: - MvQFileBrowser(QStringList, QWidget* parent = 0); - ~MvQFileBrowser(); + MvQFileBrowser(QStringList, QWidget* parent = nullptr); + ~MvQFileBrowser() override; static void init(); static void showBrowsers(); - static void openBrowser(QString path, QWidget* fromW = 0); - static void openBrowser(QStringList, QWidget* fromW = 0); + static void openBrowser(QString path, QWidget* fromW = nullptr); + static void openBrowser(QStringList, QWidget* fromW = nullptr); static void locate(QWidget*, QString, QString); public slots: @@ -102,7 +102,7 @@ protected: void showIt(); - void closeEvent(QCloseEvent*); + void closeEvent(QCloseEvent*) override; void setupFileActions(); void setupEditActions(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFileWatcher.cc metview-5.19.2/metview/src/Desktop/MvQFileWatcher.cc --- metview-5.17.4/metview/src/Desktop/MvQFileWatcher.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFileWatcher.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,7 @@ ***************************** LICENSE END *************************************/ -#include +#include #include #include "MvQFileWatcher.h" @@ -42,7 +42,7 @@ if (file_ == nullptr && f != nullptr) { file_ = f; - //int n=fileno(f); + // int n=fileno(f); if (!watcher_) { watcher_ = new QFileSystemWatcher(this); @@ -66,6 +66,6 @@ buf[strlen(buf) - 1] = 0; emit ready(buf); } - //else + // else // emit done(file_); } diff -Nru metview-5.17.4/metview/src/Desktop/MvQFileWatcher.h metview-5.19.2/metview/src/Desktop/MvQFileWatcher.h --- metview-5.17.4/metview/src/Desktop/MvQFileWatcher.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFileWatcher.h 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ #include -#include +#include #include @@ -23,7 +23,7 @@ public: MvQFileWatcher(); - virtual ~MvQFileWatcher(); + ~MvQFileWatcher() override; void start(FILE*, const std::string&); void stop(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFind.cc metview-5.19.2/metview/src/Desktop/MvQFind.cc --- metview-5.17.4/metview/src/Desktop/MvQFind.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFind.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ { mutex_.lock(); abort_ = true; - //condition.wakeOne(); + // condition.wakeOne(); mutex_.unlock(); wait(); @@ -37,8 +37,8 @@ void MvQFind::find(const std::string& dir, FindOptions options) { options_ = options; - path_ = dir; - abort_ = false; + path_ = dir; + abort_ = false; start(LowPriority); } @@ -61,7 +61,7 @@ FindOptions options = this->options_; mutex_.unlock(); - //Get classes to be searched for + // Get classes to be searched for std::vector classes; if (options.strictType == false) { @@ -105,20 +105,22 @@ bool doMatch = true; - //Check folders - struct stat buf; + // Check folders + struct stat buf + { + }; std::string fName = dirName + "/" + (name); bool needDir = false; - //Check folders + // Check folders if (stat(fName.c_str(), &buf) >= 0) { if ((buf.st_mode & S_IFMT) == S_IFDIR) { - //Ignore embedded folders - they end with # + // Ignore embedded folders - they end with # if (fName[fName.length() - 1] == '#') { doMatch = false; } - //Ignore links if options.followLinks==false + // Ignore links if options.followLinks==false else if (!options.followLinks && lstat(fName.c_str(), &buf) >= 0) { if (S_ISLNK(buf.st_mode)) @@ -160,12 +162,12 @@ bool MvQFind::match(const FindOptions& options, const std::string& fileDir, const std::string fileName, const std::vector& classes, std::string& icName, std::string& icType) { - bool hasOption = false; + bool hasOption = false; std::string fullName = fileDir + "/" + fileName; - //Check name + // Check name if (!options.name.empty()) { - hasOption = true; + hasOption = true; QString fileNameStr = QString::fromStdString(fileName); if (!fileNameStr.contains(QString::fromStdString(options.name), Qt::CaseInsensitive)) { return false; @@ -174,17 +176,17 @@ Path path(fullName); - //Check timestamp + // Check timestamp if (options.useTime) { - hasOption = true; + hasOption = true; time_t modTime = path.lastModified(); if (modTime < options.fromTime || modTime > options.toTime) return false; } - //Check size + // Check size if (options.size > 0) { - hasOption = true; + hasOption = true; off_t diff = path.sizeInBytes() - options.size; if (diff < 0 && options.sizeOper >= 0) return false; @@ -194,21 +196,21 @@ return false; } - //Check owner + // Check owner if (!options.owner.empty()) { hasOption = true; if (path.owner() != options.owner) return false; } - //Check group + // Check group if (!options.group.empty()) { hasOption = true; if (path.group() != options.group) return false; } - //Check type + // Check type if (!options.type.empty()) { hasOption = true; if (icName.empty()) { @@ -221,7 +223,7 @@ } } - //Check contents + // Check contents if (!options.contentText.empty()) { hasOption = true; if (icType.empty()) { diff -Nru metview-5.17.4/metview/src/Desktop/MvQFind.h metview-5.19.2/metview/src/Desktop/MvQFind.h --- metview-5.17.4/metview/src/Desktop/MvQFind.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFind.h 2023-07-15 08:28:47.000000000 +0000 @@ -53,9 +53,9 @@ Q_OBJECT public: - MvQFind(std::string, QObject* parent = 0); - ~MvQFind(); - //void findOptions(FindOptions options) {options_=options;} + MvQFind(std::string, QObject* parent = nullptr); + ~MvQFind() override; + // void findOptions(FindOptions options) {options_=options;} void find(const std::string&, FindOptions); void abortFind(); @@ -63,10 +63,10 @@ void found(QString, QString); protected: - void run(); + void run() override; void scan(); void scan(const Path& dir, const FindOptions& option, const std::vector& classes); - //void scanFolder(const Path& dir,const FindOptions& option,const std::vector& classes,Folder*); + // void scanFolder(const Path& dir,const FindOptions& option,const std::vector& classes,Folder*); bool match(const FindOptions& options, const std::string& path, const std::string fileName, const std::vector& classes, std::string& icName, std::string& icType); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderDrawerPanel.cc metview-5.19.2/metview/src/Desktop/MvQFolderDrawerPanel.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderDrawerPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderDrawerPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ MvQFolderDrawerPanel::MvQFolderDrawerPanel(QWidget* parent) : MvQDrawerPanel(parent) { - //Init + // Init parentFolder_ = Folder::folder("stationary"); if (parentFolder_) { parentFolder_->scan(); @@ -45,14 +45,14 @@ parentFolder_->addObserver(this); } - //Add cornerbutton + // Add cornerbutton auto* tb = new QToolButton(this); tb->setIcon(QPixmap(QString::fromUtf8(":/desktop/add_drawer.svg"))); tb->setAutoRaise(true); tb->setToolTip(tr("Add new drawer")); addCornerButton(tb); - //Selection + // Selection connect(tb, SIGNAL(clicked(bool)), this, SLOT(slotCreateDrawer(bool))); } @@ -71,11 +71,11 @@ void MvQFolderDrawerPanel::setIconPositions() { /*for(int i=0; i < tab_->count(); i++) - { - MvQDrawerView* view =static_cast(stacked_->widget(i)); - if(view) - view->slotSetPositions(); - }*/ + { + MvQDrawerView* view =static_cast(stacked_->widget(i)); + if(view) + view->slotSetPositions(); + }*/ } //--------------------- @@ -89,7 +89,7 @@ auto* drawer = new MvQDrawerView(model); MvQDrawerPanel::addDrawer(drawer, QString::fromStdString(folder->name())); - //drawer->setHelper(true); + // drawer->setHelper(true); connect(drawer, SIGNAL(itemEntered(IconObject*)), this, SIGNAL(itemEntered(IconObject*))); @@ -110,7 +110,7 @@ std::string offeredName = getUniqueName("Drawer"); bool ok; - QString text = QInputDialog::getText(0, + QString text = QInputDialog::getText(nullptr, tr("Create new drawer"), tr("Drawer name:"), QLineEdit::Normal, QString::fromStdString(offeredName), &ok); @@ -134,13 +134,13 @@ return; bool ok; - QString text = QInputDialog::getText(0, + QString text = QInputDialog::getText(nullptr, tr("Rename drawer"), tr("Drawer name:"), QLineEdit::Normal, drawerText(index), &ok); if (ok && !text.isEmpty()) { - Folder* folder = indexToFolder(index); + Folder* folder = indexToFolder(index); std::string name = getUniqueName(text.toStdString()); if (folder) folder->rename(name); @@ -152,7 +152,7 @@ if (index < 0 || index >= drawerCount()) return; - if (QMessageBox::question(0, tr("Delete drawer"), tr("Do you want to delete drawer") + " " + drawerText(index) + "?", + if (QMessageBox::question(nullptr, tr("Delete drawer"), tr("Do you want to delete drawer") + " " + drawerText(index) + "?", QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Cancel) { return; } @@ -169,7 +169,7 @@ void MvQFolderDrawerPanel::arrived(IconObject* obj) { - auto* folder = static_cast(obj); + auto* folder = dynamic_cast(obj); if (!folder) return; @@ -178,7 +178,7 @@ void MvQFolderDrawerPanel::renamed(IconObject* obj, const std::string&) { - auto* folder = static_cast(obj); + auto* folder = dynamic_cast(obj); if (!folder) return; @@ -187,11 +187,11 @@ void MvQFolderDrawerPanel::gone(IconObject* obj) { - auto* folder = static_cast(obj); + auto* folder = dynamic_cast(obj); if (!folder) return; - int index = folderToIndex(folder); + int index = folderToIndex(folder); MvQFolderModel* model = indexToModel(index); MvQDrawerPanel::deleteDrawer(folderToIndex(folder)); @@ -214,11 +214,11 @@ } } -//Desktop menu signal from one of the views +// Desktop menu signal from one of the views void MvQFolderDrawerPanel::slotCommandFromView(QString name, QPoint /*pos*/) { if (name == "deleteDrawer" || name == "renameDrawer") { - auto* view = static_cast(sender()); + auto* view = dynamic_cast(sender()); if (!view) return; @@ -241,7 +241,7 @@ int MvQFolderDrawerPanel::folderToIndex(Folder* f) { for (int i = 0; i < drawerCount(); i++) { - auto* view = static_cast(drawer(i)); + auto* view = dynamic_cast(drawer(i)); if (view->currentFolder() == f) return i; @@ -252,12 +252,12 @@ Folder* MvQFolderDrawerPanel::indexToFolder(int index) { - auto* view = static_cast(drawer(index)); - return (view) ? view->currentFolder() : 0; + auto* view = dynamic_cast(drawer(index)); + return (view) ? view->currentFolder() : nullptr; } MvQFolderModel* MvQFolderDrawerPanel::indexToModel(int index) { - auto* view = static_cast(drawer(index)); - return (view) ? view->folderModel() : 0; + auto* view = dynamic_cast(drawer(index)); + return (view) ? view->folderModel() : nullptr; } diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderDrawerPanel.h metview-5.19.2/metview/src/Desktop/MvQFolderDrawerPanel.h --- metview-5.17.4/metview/src/Desktop/MvQFolderDrawerPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderDrawerPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,8 @@ Q_OBJECT public: - MvQFolderDrawerPanel(QWidget* parent = 0); - ~MvQFolderDrawerPanel(); + MvQFolderDrawerPanel(QWidget* parent = nullptr); + ~MvQFolderDrawerPanel() override; void setIconPositions(); @@ -39,21 +39,21 @@ void commandRequested(Folder*, QString, QPoint); protected: - void command(QString, int); + void command(QString, int) override; void createDrawer(Folder*); void renameDrawer(int); void deleteDrawer(int); - void arrived(IconObject*); - void renamed(IconObject*, const std::string&); - void gone(IconObject*); - void position(IconObject*, int, int) {} + void arrived(IconObject*) override; + void renamed(IconObject*, const std::string&) override; + void gone(IconObject*) override; + void position(IconObject*, int, int) override {} std::string getUniqueName(const std::string&); int folderToIndex(Folder*); Folder* indexToFolder(int); MvQFolderModel* indexToModel(int); - MvQContextItemSet* cmSet(); + MvQContextItemSet* cmSet() override; Folder* parentFolder_; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderHistory.cc metview-5.19.2/metview/src/Desktop/MvQFolderHistory.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderHistory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderHistory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -111,17 +111,17 @@ QString MvQFolderHistory::path(QAction* action) { if (!action) - return QString(); + return {}; return action->data().toString(); } QAction* MvQFolderHistory::createAction(QString fullName) { - //Home + // Home auto* action = new QAction(menu_); - //action->setText("" + prefix_ +"" + fullName); - //action->setText(prefix_ + fullName); + // action->setText("" + prefix_ +"" + fullName); + // action->setText(prefix_ + fullName); action->setText(fullName); action->setData(fullName); @@ -145,7 +145,7 @@ static MvQContextItemSet cmItems("FolderHistory"); QAction* ac = menu_->actionAt(pos); - QString pt = path(ac); + QString pt = path(ac); if (pt.isEmpty()) return; diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderHistory.h metview-5.19.2/metview/src/Desktop/MvQFolderHistory.h --- metview-5.17.4/metview/src/Desktop/MvQFolderHistory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderHistory.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ public: MvQFolderHistory(QMenu*); - ~MvQFolderHistory(); + ~MvQFolderHistory() override; void add(QString); static QStringList items() { return items_; } diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderItemProperty.cc metview-5.19.2/metview/src/Desktop/MvQFolderItemProperty.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderItemProperty.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderItemProperty.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,17 +22,13 @@ //======================================== MvQAbstractIconItemProperty::MvQAbstractIconItemProperty() : - refIconSize_(32), fm_(QApplication::font()), - refFm_(QApplication::font()), - paddingX_(3), - paddingY_(3) + refFm_(QApplication::font()) { iconSize_ = refIconSize_; - scaling_ = 1.; - font_ = QApplication::font(); - refFont_ = QApplication::font(); - refFm_ = QFontMetrics(font_); + font_ = QApplication::font(); + refFont_ = QApplication::font(); + refFm_ = QFontMetrics(font_); } bool MvQAbstractIconItemProperty::setIconSize(int size) @@ -76,8 +72,8 @@ MvQClassicIconItemProperty::MvQClassicIconItemProperty() { textOffset_ = 5; - height_ = iconSize_ + textOffset_ + textHeight() + 2 * paddingY_; - refHeight_ = height_; + height_ = iconSize_ + textOffset_ + textHeight() + 2 * paddingY_; + refHeight_ = height_; } void MvQClassicIconItemProperty::update() @@ -85,21 +81,21 @@ if (iconSize_ != refIconSize_) { if (iconSize_ > 32) { float dScale = static_cast(iconSize_) / 32.; - int h = refFont_.pointSize(); + int h = refFont_.pointSize(); font_.setPointSize(2 * (static_cast(h * dScale) / 2)); } else { font_ = refFont_; } - fm_ = QFontMetrics(font_); - height_ = iconSize_ + textOffset_ + textHeight() + 2 * paddingY_; + fm_ = QFontMetrics(font_); + height_ = iconSize_ + textOffset_ + textHeight() + 2 * paddingY_; scaling_ = static_cast(height_) / static_cast(refHeight_); } else { - font_ = refFont_; - fm_ = refFm_; - height_ = refHeight_; + font_ = refFont_; + fm_ = refFm_; + height_ = refHeight_; scaling_ = 1.; } } @@ -108,19 +104,19 @@ QPoint MvQClassicIconItemProperty::position(QString name, QPoint refPos) { if (iconSize_ != refIconSize_) { - //Ref centre + // Ref centre int refTextW = refTextWidth(name) + 2 * paddingX_; - int refW = (refTextW < 32) ? 32 : refTextW; - int cx = refPos.x() + refW / 2; - //int cy=refPos.y()+refHeight_/2; + int refW = (refTextW < 32) ? 32 : refTextW; + int cx = refPos.x() + refW / 2; + // int cy=refPos.y()+refHeight_/2; - //Item width + // Item width int textW = textWidth(name) + 2 * paddingX_; - int w = (textW < iconSize_) ? iconSize_ : textW; + int w = (textW < iconSize_) ? iconSize_ : textW; int x = cx * ((iconSize_ > 32) ? (scaling_ + 1) * 0.5 : 1) - w / 2; - int y = refPos.y() * scaling_; //cy*scaling_-height_/2; - return QPoint(x, y); + int y = refPos.y() * scaling_; // cy*scaling_-height_/2; + return {x, y}; } return refPos; @@ -128,42 +124,42 @@ QPoint MvQClassicIconItemProperty::positionFromHotSpot(QString name, QPoint pos, QPointF hotSpotAtPos) { - //hotSpotAtPos is the relative position inside the icon pixmap + // hotSpotAtPos is the relative position inside the icon pixmap QSize s = size(name); QPoint d(iconSize_ * hotSpotAtPos.x(), iconSize_ * hotSpotAtPos.y()); - return QPoint(pos.x() - d.x() - (s.width() - iconSize_) / 2, pos.y() - d.y() - paddingY_); + return {pos.x() - d.x() - (s.width() - iconSize_) / 2, pos.y() - d.y() - paddingY_}; } QSize MvQClassicIconItemProperty::size(QString name) { int textW = textWidth(name) + 2 * paddingX_; - //int textW=fm_.boundingRect(name).width()+2*paddingX_; + // int textW=fm_.boundingRect(name).width()+2*paddingX_; int w = (textW < iconSize_) ? iconSize_ : textW; - return QSize(w, height_); + return {w, height_}; } -//Position of the top-left corner of the item at pos in the scene as if it had iconSize=32 +// Position of the top-left corner of the item at pos in the scene as if it had iconSize=32 QPoint MvQClassicIconItemProperty::referencePosition(QString name, QPoint pos) { if (iconSize_ != refIconSize_) { - //Item width + // Item width int textW = textWidth(name) + 2 * paddingX_; - int w = (textW < iconSize_) ? iconSize_ : textW; + int w = (textW < iconSize_) ? iconSize_ : textW; - //Item centre + // Item centre int cx = (pos.x() + w / 2) / ((iconSize_ > 32) ? (scaling_ + 1) * 0.5 : 1); - //int cy=pos.y()+height_/2; + // int cy=pos.y()+height_/2; - //Ref width + // Ref width int refTextW = refTextWidth(name) + 2 * paddingX_; - int refW = (refTextW < 32) ? 32 : refTextW; + int refW = (refTextW < 32) ? 32 : refTextW; - //Ref + // Ref int refX = cx - refW / 2; - int refY = pos.y() / scaling_; //cy/scaling_-refHeight_/2; + int refY = pos.y() / scaling_; // cy/scaling_-refHeight_/2; - return QPoint(refX, refY); + return {refX, refY}; } return pos; @@ -171,7 +167,7 @@ QPoint MvQClassicIconItemProperty::adjsutReferencePosition(QString name, QString oriName, QPoint pos) { - //Ref width + // Ref width int oriW = refTextWidth(oriName) + 2 * paddingX_; if (oriW < 32) oriW = 32; @@ -185,50 +181,50 @@ QRect MvQClassicIconItemProperty::iconRect(QString name) { QSize s = size(name); - return QRect(s.width() / 2 - iconSize_ / 2, - paddingY_ + 1, - iconSize_, - iconSize_); + return {s.width() / 2 - iconSize_ / 2, + paddingY_ + 1, + iconSize_, + iconSize_}; } QRect MvQClassicIconItemProperty::textRect(QString name) { - return QRect(paddingX_, - paddingY_ + iconSize_ + textOffset_, - textWidth(name), - textHeight()); + return {paddingX_, + paddingY_ + iconSize_ + textOffset_, + textWidth(name), + textHeight()}; } -//The reference position we store in the iconobject is the top-left corner of the item -//without the padding. This is how Desktop was first released and how MetviewUI worked. -//However, the reference position in the view is the top-left corner of the item -//including a (now) non-zero padding! So to get the position we want to store in the iconobject -//we need to add the padding to the reference position of the item in the view. -//We assume that the padding is the same for all the iconsizes. +// The reference position we store in the iconobject is the top-left corner of the item +// without the padding. This is how Desktop was first released and how MetviewUI worked. +// However, the reference position in the view is the top-left corner of the item +// including a (now) non-zero padding! So to get the position we want to store in the iconobject +// we need to add the padding to the reference position of the item in the view. +// We assume that the padding is the same for all the iconsizes. QPoint MvQClassicIconItemProperty::storedPosition(QPoint viewRefPos) { return viewRefPos + QPoint(paddingX_, paddingY_); } -//The reference position we store in the iconobject is the top-left corner of the item -//without the padding at iconSize=32. This is how Desktop was first released and how MetviewUI worked. -//However, the reference position in the view is the top-left corner of the item -//including a (now) non-zero padding! So to get the position of the item in the view -//we need to subtract the padding from reference position stored in the iconobject. -//We assume that the padding is the same for all the iconsizes. +// The reference position we store in the iconobject is the top-left corner of the item +// without the padding at iconSize=32. This is how Desktop was first released and how MetviewUI worked. +// However, the reference position in the view is the top-left corner of the item +// including a (now) non-zero padding! So to get the position of the item in the view +// we need to subtract the padding from reference position stored in the iconobject. +// We assume that the padding is the same for all the iconsizes. QPoint MvQClassicIconItemProperty::referencePosition(IconObject* obj) { - return QPoint(obj->info().x() - paddingX_, - obj->info().y() - paddingY_); + return {obj->info().x() - paddingX_, + obj->info().y() - paddingY_}; } QPoint MvQClassicIconItemProperty::referencePositionFromStored(QPoint storedPos) { - return QPoint(storedPos.x() - paddingX_, - storedPos.y() - paddingY_); + return {storedPos.x() - paddingX_, + storedPos.y() - paddingY_}; } @@ -241,8 +237,8 @@ MvQSimpleIconItemProperty::MvQSimpleIconItemProperty() { textOffset_ = 5; - height_ = iconSize_ + 2 * paddingY_; - refHeight_ = height_; + height_ = iconSize_ + 2 * paddingY_; + refHeight_ = height_; } @@ -251,21 +247,21 @@ if (iconSize_ != refIconSize_) { if (iconSize_ > 32) { float dScale = static_cast(iconSize_) / 32.; - int h = refFont_.pointSize(); + int h = refFont_.pointSize(); font_.setPointSize(2 * (static_cast(h * dScale) / 2)); } else { font_ = refFont_; } - fm_ = QFontMetrics(font_); - height_ = iconSize_ + 2 * paddingY_; + fm_ = QFontMetrics(font_); + height_ = iconSize_ + 2 * paddingY_; scaling_ = static_cast(height_) / static_cast(refHeight_); } else { - font_ = refFont_; - fm_ = refFm_; - height_ = refHeight_; + font_ = refFont_; + fm_ = refFm_; + height_ = refHeight_; scaling_ = 1.; } } @@ -276,7 +272,7 @@ if (iconSize_ != refIconSize_) { int x = refPos.x() * ((iconSize_ > 32) ? (scaling_ + 1) * 0.5 : 1); int y = refPos.y() * scaling_; - return QPoint(x, y); + return {x, y}; } return refPos; @@ -284,26 +280,26 @@ QPoint MvQSimpleIconItemProperty::positionFromHotSpot(QString /*name*/, QPoint pos, QPointF hotSpotAtPos) { - //hotSpotAtPos is the relative position inside the icon pixmap + // hotSpotAtPos is the relative position inside the icon pixmap QPoint d(iconSize_ * hotSpotAtPos.x(), iconSize_ * hotSpotAtPos.y()); - return QPoint(pos.x() - d.x() - paddingX_, pos.y() - d.y() - paddingY_); + return {pos.x() - d.x() - paddingX_, pos.y() - d.y() - paddingY_}; } QSize MvQSimpleIconItemProperty::size(QString name) { int w = iconSize_ + textOffset_ + textWidth(name) + 2 * paddingX_; - return QSize(w, height_); + return {w, height_}; } QPoint MvQSimpleIconItemProperty::referencePosition(QString, QPoint pos) { if (iconSize_ != refIconSize_) { - //Ref + // Ref int refX = pos.x() / ((iconSize_ > 32) ? (scaling_ + 1) * 0.5 : 1); int refY = pos.y() / scaling_; - return QPoint(refX, refY); + return {refX, refY}; } return pos; @@ -311,32 +307,32 @@ QPoint MvQSimpleIconItemProperty::adjsutReferencePosition(QString /*name*/, QString /*oriName*/, QPoint /*pos*/) { - return QPoint(); + return {}; } QRect MvQSimpleIconItemProperty::iconRect(QString /*name*/) { - return QRect(paddingX_, - paddingY_, - iconSize_, - iconSize_); + return {paddingX_, + paddingY_, + iconSize_, + iconSize_}; } QRect MvQSimpleIconItemProperty::textRect(QString name) { QSize s = size(name); - return QRect(paddingX_ + iconSize_ + textOffset_, - (s.height() - textHeight()) / 2, - textWidth(name), - textHeight()); -} -//The reference position we store in the iconobject is the top-left corner of the item -//without the padding. This is how Desktop was first released and how MetviewUI worked. -//However, the reference position in the view is the top-left corner of the item -//including a (now) non-zero padding! So to get the position we want to store in the iconobject -//we need to add the padding to the reference position of the item in the view. -//We assume that the padding is the same for all the iconsizes. + return {paddingX_ + iconSize_ + textOffset_, + (s.height() - textHeight()) / 2, + textWidth(name), + textHeight()}; +} +// The reference position we store in the iconobject is the top-left corner of the item +// without the padding. This is how Desktop was first released and how MetviewUI worked. +// However, the reference position in the view is the top-left corner of the item +// including a (now) non-zero padding! So to get the position we want to store in the iconobject +// we need to add the padding to the reference position of the item in the view. +// We assume that the padding is the same for all the iconsizes. QPoint MvQSimpleIconItemProperty::storedPosition(QPoint viewRefPos) { @@ -344,23 +340,23 @@ QPoint(paddingX_, paddingY_); } -//The reference position we store in the iconobject is the top-left corner of the item -//without the padding. This is how Desktop was first released and how MetviewUI worked. -//However, the reference position in the view is the top-left corner of the item -//including a (now) non-zero padding! So to get the position of the item in the view -//we need to subtract the padding from reference position stored in the iconobject. -//We assume that the padding is the same for all the iconsizes. +// The reference position we store in the iconobject is the top-left corner of the item +// without the padding. This is how Desktop was first released and how MetviewUI worked. +// However, the reference position in the view is the top-left corner of the item +// including a (now) non-zero padding! So to get the position of the item in the view +// we need to subtract the padding from reference position stored in the iconobject. +// We assume that the padding is the same for all the iconsizes. QPoint MvQSimpleIconItemProperty::referencePosition(IconObject* obj) { - return QPoint(obj->info().x() - paddingX_, - obj->info().y() - paddingY_); + return {obj->info().x() - paddingX_, + obj->info().y() - paddingY_}; } QPoint MvQSimpleIconItemProperty::referencePositionFromStored(QPoint storedPos) { - return QPoint(storedPos.x() - paddingX_, - storedPos.y() - paddingY_); + return {storedPos.x() - paddingX_, + storedPos.y() - paddingY_}; } @@ -373,8 +369,8 @@ MvQDetailedIconItemProperty::MvQDetailedIconItemProperty() { textOffset_ = 5; - height_ = iconSize_; - refHeight_ = height_; + height_ = iconSize_; + refHeight_ = height_; } void MvQDetailedIconItemProperty::update() @@ -382,21 +378,21 @@ if (iconSize_ != refIconSize_) { if (iconSize_ > 32) { float dScale = static_cast(iconSize_) / 32.; - int h = refFont_.pointSize(); + int h = refFont_.pointSize(); font_.setPointSize(2 * (static_cast(h * dScale) / 2)); } else { font_ = refFont_; } - fm_ = QFontMetrics(font_); - height_ = iconSize_ + textOffset_ + fm_.height(); + fm_ = QFontMetrics(font_); + height_ = iconSize_ + textOffset_ + fm_.height(); scaling_ = static_cast(height_) / static_cast(refHeight_); } else { - font_ = refFont_; - fm_ = refFm_; - height_ = refHeight_; + font_ = refFont_; + fm_ = refFm_; + height_ = refHeight_; scaling_ = 1.; } } @@ -416,8 +412,8 @@ QSize MvQDetailedIconItemProperty::size(QString name) { int textW = MvQ::textWidth(fm_, name); - int w = iconSize_ + textOffset_ + textW; - return QSize(w, height_); + int w = iconSize_ + textOffset_ + textW; + return {w, height_}; } QPoint MvQDetailedIconItemProperty::referencePosition(QString /*name*/, QPoint pos) @@ -433,20 +429,20 @@ QRect MvQDetailedIconItemProperty::iconRect(QString name) { QSize s = size(name); - return QRect(s.width() / 2 - iconSize_ / 2, - paddingY_, - iconSize_, - iconSize_); + return {s.width() / 2 - iconSize_ / 2, + paddingY_, + iconSize_, + iconSize_}; } QRect MvQDetailedIconItemProperty::textRect(QString name) { QSize s = size(name); - return QRect(0, - paddingY_ + textOffset_, - s.width(), - s.height() - (iconSize_ + textOffset_ + 2 * paddingY_)); + return {0, + paddingY_ + textOffset_, + s.width(), + s.height() - (iconSize_ + textOffset_ + 2 * paddingY_)}; } @@ -477,11 +473,11 @@ current_(nullptr) { - prop_[Desktop::IconViewMode] = new MvQClassicIconItemProperty; - prop_[Desktop::SimpleViewMode] = new MvQSimpleIconItemProperty; + prop_[Desktop::IconViewMode] = new MvQClassicIconItemProperty; + prop_[Desktop::SimpleViewMode] = new MvQSimpleIconItemProperty; prop_[Desktop::DetailedViewMode] = new MvQDetailedIconItemProperty; - current_ = prop_[viewMode_]; - iconSize_ = current_->iconSize(); + current_ = prop_[viewMode_]; + iconSize_ = current_->iconSize(); } MvQFolderItemProperty::~MvQFolderItemProperty() @@ -530,7 +526,7 @@ void MvQFolderItemProperty::setViewMode(Desktop::FolderViewMode mode) { - viewMode_ = mode; + viewMode_ = mode; QMap::iterator it = prop_.find(mode); if (it != prop_.end()) { current_ = it.value(); @@ -540,12 +536,12 @@ /*void MvQFolderItemProperty::setTextPosMode(TextPosMode tp) { - textPosMode_=tp; - QMap::iterator it=prop_.find(tp); - if( it != prop_.end()) - { - current_=it.value(); - } + textPosMode_=tp; + QMap::iterator it=prop_.find(tp); + if( it != prop_.end()) + { + current_=it.value(); + } } */ bool MvQFolderItemProperty::setIconSize(int size) @@ -560,22 +556,22 @@ } /* retVal=it.value()->setIconSize(size); - - QMap::iterator it = prop_.begin(); - while(it != prop_.end()) - { - if(it.value() == current_) - { - retVal=it.value()->setIconSize(size); - } - else - { - it.value()->setIconSize(size); - } - ++it; - } - - return retVal; + + QMap::iterator it = prop_.begin(); + while(it != prop_.end()) + { + if(it.value() == current_) + { + retVal=it.value()->setIconSize(size); + } + else + { + it.value()->setIconSize(size); + } + ++it; + } + + return retVal; } */ QPoint MvQFolderItemProperty::position(QString name, QPoint refPos) diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderItemProperty.h metview-5.19.2/metview/src/Desktop/MvQFolderItemProperty.h --- metview-5.17.4/metview/src/Desktop/MvQFolderItemProperty.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderItemProperty.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ { public: MvQAbstractIconItemProperty(); - virtual ~MvQAbstractIconItemProperty() {} + virtual ~MvQAbstractIconItemProperty() = default; int iconSize() const { return iconSize_; } QFont font() const { return font_; } @@ -32,16 +32,16 @@ int paddingX() const { return paddingX_; } int paddingY() const { return paddingY_; } - virtual QPoint position(QString, QPoint) = 0; + virtual QPoint position(QString, QPoint) = 0; virtual QPoint positionFromHotSpot(QString name, QPoint pos, QPointF hotSpotAtPos) = 0; - virtual QPoint referencePosition(QString, QPoint) = 0; - virtual QPoint adjsutReferencePosition(QString, QString, QPoint) = 0; - virtual QSize size(QString) = 0; - virtual QRect textRect(QString) = 0; - virtual QRect iconRect(QString) = 0; - virtual QPoint storedPosition(QPoint viewRefPos) = 0; - virtual QPoint referencePosition(IconObject*) = 0; - virtual QPoint referencePositionFromStored(QPoint storedPos) = 0; + virtual QPoint referencePosition(QString, QPoint) = 0; + virtual QPoint adjsutReferencePosition(QString, QString, QPoint) = 0; + virtual QSize size(QString) = 0; + virtual QRect textRect(QString) = 0; + virtual QRect iconRect(QString) = 0; + virtual QPoint storedPosition(QPoint viewRefPos) = 0; + virtual QPoint referencePosition(IconObject*) = 0; + virtual QPoint referencePositionFromStored(QPoint storedPos) = 0; protected: virtual void update() = 0; @@ -49,19 +49,19 @@ int refTextWidth(QString); int refTextHeight(); - int iconSize_; - const int refIconSize_; - float scaling_; + int iconSize_{32}; + const int refIconSize_{32}; + float scaling_{1.}; QFont font_; QFont refFont_; QFontMetrics fm_; QFontMetrics refFm_; - int height_; - int refHeight_; - int textOffset_; - int paddingX_; - int paddingY_; + int height_{0}; + int refHeight_{0}; + int textOffset_{0}; + int paddingX_{3}; + int paddingY_{3}; }; class MvQClassicIconItemProperty : public MvQAbstractIconItemProperty @@ -69,19 +69,19 @@ public: MvQClassicIconItemProperty(); - QPoint position(QString, QPoint); - QPoint positionFromHotSpot(QString name, QPoint pos, QPointF hotSpotAtPos); - QPoint referencePosition(QString, QPoint); - QPoint adjsutReferencePosition(QString, QString, QPoint); - QSize size(QString); - QRect textRect(QString); - QRect iconRect(QString); - QPoint storedPosition(QPoint viewRefPos); - QPoint referencePosition(IconObject*); - QPoint referencePositionFromStored(QPoint storedPos); + QPoint position(QString, QPoint) override; + QPoint positionFromHotSpot(QString name, QPoint pos, QPointF hotSpotAtPos) override; + QPoint referencePosition(QString, QPoint) override; + QPoint adjsutReferencePosition(QString, QString, QPoint) override; + QSize size(QString) override; + QRect textRect(QString) override; + QRect iconRect(QString) override; + QPoint storedPosition(QPoint viewRefPos) override; + QPoint referencePosition(IconObject*) override; + QPoint referencePositionFromStored(QPoint storedPos) override; protected: - void update(); + void update() override; }; class MvQSimpleIconItemProperty : public MvQAbstractIconItemProperty @@ -89,19 +89,19 @@ public: MvQSimpleIconItemProperty(); - QPoint position(QString, QPoint); - QPoint positionFromHotSpot(QString name, QPoint pos, QPointF hotSpotAtPos); - QPoint referencePosition(QString, QPoint); - QPoint adjsutReferencePosition(QString, QString, QPoint); - QSize size(QString); - QRect textRect(QString); - QRect iconRect(QString); - QPoint storedPosition(QPoint viewRefPos); - QPoint referencePosition(IconObject*); - QPoint referencePositionFromStored(QPoint storedPos); + QPoint position(QString, QPoint) override; + QPoint positionFromHotSpot(QString name, QPoint pos, QPointF hotSpotAtPos) override; + QPoint referencePosition(QString, QPoint) override; + QPoint adjsutReferencePosition(QString, QString, QPoint) override; + QSize size(QString) override; + QRect textRect(QString) override; + QRect iconRect(QString) override; + QPoint storedPosition(QPoint viewRefPos) override; + QPoint referencePosition(IconObject*) override; + QPoint referencePositionFromStored(QPoint storedPos) override; protected: - void update(); + void update() override; }; class MvQDetailedIconItemProperty : public MvQAbstractIconItemProperty @@ -109,26 +109,26 @@ public: MvQDetailedIconItemProperty(); - QPoint position(QString, QPoint); - QPoint positionFromHotSpot(QString name, QPoint pos, QPointF hotSpotAtPos); - QPoint referencePosition(QString, QPoint); - QPoint adjsutReferencePosition(QString, QString, QPoint); - QSize size(QString); - QRect textRect(QString); - QRect iconRect(QString); - QPoint storedPosition(QPoint viewRefPos); - QPoint referencePosition(IconObject*); - QPoint referencePositionFromStored(QPoint storedPos); + QPoint position(QString, QPoint) override; + QPoint positionFromHotSpot(QString name, QPoint pos, QPointF hotSpotAtPos) override; + QPoint referencePosition(QString, QPoint) override; + QPoint adjsutReferencePosition(QString, QString, QPoint) override; + QSize size(QString) override; + QRect textRect(QString) override; + QRect iconRect(QString) override; + QPoint storedPosition(QPoint viewRefPos) override; + QPoint referencePosition(IconObject*) override; + QPoint referencePositionFromStored(QPoint storedPos) override; protected: - void update(); + void update() override; }; class MvQFolderItemProperty { public: - //enum TextPosMode {TextBelow,TextBeside}; + // enum TextPosMode {TextBelow,TextBeside}; MvQFolderItemProperty(); ~MvQFolderItemProperty(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderModel.cc metview-5.19.2/metview/src/Desktop/MvQFolderModel.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,7 +34,7 @@ #include "MvQTheme.h" #include "MvQFileInfo.h" -#include +#include #include QHash MvQFolderModel::statusColour_; @@ -56,18 +56,17 @@ void MvQFolderModel::init() { - searchData_ = nullptr; - folder_ = nullptr, - initialScanIsOn_ = false, - lastArrived_ = nullptr; + searchData_ = nullptr; + folder_ = nullptr; + lastArrived_ = nullptr; itemProp_ = new MvQFolderItemProperty(); if (statusColour_.empty()) { statusColour_[IconObject::DefaultStatus] = MvQTheme::colour("folderview", "text"); - statusColour_[IconObject::ReadyStatus] = MvQTheme::colour("folderview", "ready_status"); + statusColour_[IconObject::ReadyStatus] = MvQTheme::colour("folderview", "ready_status"); statusColour_[IconObject::WaitingStatus] = MvQTheme::colour("folderview", "waiting_status"); - statusColour_[IconObject::ErrorStatus] = MvQTheme::colour("folderview", "error_status"); + statusColour_[IconObject::ErrorStatus] = MvQTheme::colour("folderview", "error_status"); fadedColour_ = MvQTheme::colour("folderview", "faded_text"); } @@ -86,7 +85,7 @@ bool MvQFolderModel::isDataSet() const { - return (folder_ == 0) ? false : true; + return (folder_ == nullptr) ? false : true; } void MvQFolderModel::folderIsAboutToChange() @@ -105,7 +104,7 @@ beginResetModel(); - //Clear all the items!!! + // Clear all the items!!! items_.clear(); if (folder_) { @@ -113,19 +112,19 @@ ((IconObject*)folder_)->removeObserver((IconObserver*)this); } - folder_ = folder; + folder_ = folder; lastArrived_ = nullptr; if (folder_) { - //We are not an observer at the moment so arrived() will - //not be called! + // We are not an observer at the moment so arrived() will + // not be called! folder_->scan(); - //Load items_ from folder + // Load items_ from folder loadItems(); - //Now we become an observer. Any changes afterwards will end up - //in arrived(), gone() etc. observer methods! + // Now we become an observer. Any changes afterwards will end up + // in arrived(), gone() etc. observer methods! folder_->addObserver(this); ((IconObject*)folder_)->addObserver((IconObserver*)this); @@ -135,7 +134,7 @@ retVal = true; } - //Update the search status + // Update the search status updateSearchData(false); endResetModel(); @@ -204,18 +203,18 @@ role != Qt::ForegroundRole && role != Qt::FontRole && role != ClassFilterRole && role != PositionRole && role != EditorRole && role != Qt::EditRole && role != Qt::UserRole) { - return QVariant(); + return {}; } if (!index.isValid()) { - return QVariant(); + return {}; } IconObject* obj = objectFromIndex(index); if (!obj) return QString(); - //First column: icon + name + // First column: icon + name if (index.column() == 0) { switch (role) { case Qt::DecorationRole: { @@ -250,7 +249,7 @@ return isAccepted(obj); case PositionRole: - //We get the reference position from the object + // We get the reference position from the object return itemProp_->referencePosition(obj); case EditorRole: @@ -303,7 +302,7 @@ return itemProp_->font(); } - return QVariant(); + return {}; } bool MvQFolderModel::setData(const QModelIndex& index, const QVariant& value, int role) @@ -318,16 +317,14 @@ std::string new_name = value.toString().toStdString(); if (obj && obj->name() != new_name) { - QString oriName = QString::fromStdString(obj->name()); - - //This will call the renamed() observer method! + // This will call the renamed() observer method! return obj->rename(new_name); } } else if (role == PositionRole) { QPoint viewRefPos = value.toPoint(); - //Compute the stored reference position from the view reference postion. + // Compute the stored reference position from the view reference postion. QPoint refPos = itemProp_->storedPosition(viewRefPos); obj->info().position(refPos.x(), refPos.y()); return true; @@ -340,7 +337,7 @@ QVariant MvQFolderModel::headerData(const int section, const Qt::Orientation orient, const int role) const { if (orient != Qt::Horizontal || role != Qt::DisplayRole) - return QVariant(); + return {}; if (section == 0) return "Name"; @@ -355,14 +352,14 @@ else if (section == 5) return "Permissions"; - return QVariant(); + return {}; } QModelIndex MvQFolderModel::index(int row, int column, const QModelIndex& /*parent*/) const { if (!isDataSet()) { - return QModelIndex(); + return {}; } return createIndex(row, column, (void*)nullptr); @@ -371,7 +368,7 @@ QModelIndex MvQFolderModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } Qt::ItemFlags MvQFolderModel::flags(const QModelIndex& index) const @@ -404,13 +401,13 @@ QModelIndex MvQFolderModel::indexFromObject(IconObject* obj) { if (!obj) - return QModelIndex(); + return {}; int i = items_.indexOf(obj); return (i >= 0) ? createIndex(i, 0, (void*)nullptr) : QModelIndex(); } -//Should be called between beginResetModel() and endResetModel() !! +// Should be called between beginResetModel() and endResetModel() !! void MvQFolderModel::loadItems() { items_.clear(); @@ -494,7 +491,7 @@ return indexFromObject(lastArrived_); } - return QModelIndex(); + return {}; } //--------------------------------------- @@ -517,8 +514,8 @@ void MvQFolderModel::setPositionHint(const std::string& cn, int x, int y) { posHint_.className = cn; - posHint_.x = x; - posHint_.y = y; + posHint_.x = x; + posHint_.y = y; } //---------------------------------------------- @@ -530,27 +527,27 @@ void MvQFolderModel::arrived(IconObject* obj) { if (obj && isAccepted(obj)) { - //beginInsertRows(), endInsertRows() were just resetting the whole view! - //It is easier just reset the model because our icon view knows what to do with the - //icon positions in this case + // beginInsertRows(), endInsertRows() were just resetting the whole view! + // It is easier just reset the model because our icon view knows what to do with the + // icon positions in this case beginResetModel(); items_ << obj; lastArrived_ = obj; if ((posHint_.className.empty() || posHint_.className == obj->iconClass().name()) && obj->info().x() == 0 && obj->info().y() == 0) { - //positionHint contains the viewRefPos!! + // positionHint contains the viewRefPos!! QPoint refPos = itemProp_->storedPosition(QPoint(posHint_.x, posHint_.y)); obj->info().position(refPos.x(), refPos.y()); } posHint_.clear(); - //Update saerch data + // Update saerch data updateSearchData(false); endResetModel(); - //emit objectArrived(indexFromObject(obj)); + // emit objectArrived(indexFromObject(obj)); } } @@ -560,7 +557,7 @@ beginResetModel(); items_.removeOne(obj); - //Update saerch data + // Update saerch data updateSearchData(false); endResetModel(); @@ -574,10 +571,10 @@ void MvQFolderModel::renamed(IconObject* obj, const std::string& oriName) { if (isAccepted(obj)) { - //Update saerch data + // Update saerch data updateSearchData(false); - //We notify the view about the renaming + // We notify the view about the renaming emit objectRenamed(indexFromObject(obj), QString::fromStdString(oriName)); } } @@ -624,8 +621,8 @@ { } -//This is an iconobserver method. It is called when the folder itself (e.g. name) -//has been changed/ +// This is an iconobserver method. It is called when the folder itself (e.g. name) +// has been changed/ void MvQFolderModel::iconChanged(IconObject* obj) { if (obj == folder_) { @@ -636,7 +633,7 @@ void MvQFolderModel::createNewFolder() { - //This will call in the end the arrived() observer method! + // This will call in the end the arrived() observer method! IconClass::find("FOLDER").createOne(folder_); } @@ -667,7 +664,7 @@ { searchData_ = data; - //Register owner + // Register owner searchData_->setOwner(this); updateSearchData(true); @@ -677,13 +674,13 @@ { if (!hasSearchData()) { if (doReset) - //reset(); NOT in Qt 5 + // reset(); NOT in Qt 5 beginResetModel(); endResetModel(); return; } - //Clear search results + // Clear search results searchData_->clearMatch(); if (searchData_->isSet()) { @@ -693,11 +690,11 @@ } } - //Notify changes + // Notify changes searchData_->matchChanged(); if (doReset) - //reset(); NOT in Qt 5 + // reset(); NOT in Qt 5 beginResetModel(); endResetModel(); } @@ -718,34 +715,34 @@ /* - - bool found=false; - - if(filterName_ == name.toStdString() && filterType_ == type.toStdString()) - return found; - - filterName_=name.toStdString(); - filterType_=type.toStdString(); - - filterMatchLst_.clear(); - - if(!filterName_.empty() || !filterType_.empty()) - { - for(int i=0; i< rowCount(); i++) - { - QModelIndex idx=index(i,0); - if(IconObject *obj=objectFromIndex(idx)) - { - if(obj->match(filterName_,filterType_)) - { - filterMatchLst_ << obj; - } - } - } - } - - reset(); - return found; + + bool found=false; + + if(filterName_ == name.toStdString() && filterType_ == type.toStdString()) + return found; + + filterName_=name.toStdString(); + filterType_=type.toStdString(); + + filterMatchLst_.clear(); + + if(!filterName_.empty() || !filterType_.empty()) + { + for(int i=0; i< rowCount(); i++) + { + QModelIndex idx=index(i,0); + if(IconObject *obj=objectFromIndex(idx)) + { + if(obj->match(filterName_,filterType_)) + { + filterMatchLst_ << obj; + } + } + } + } + + reset(); + return found; }*/ @@ -778,7 +775,7 @@ { QVariant leftData, rightData; if (left.column() == 2) { - leftData = sourceModel()->data(left, Qt::UserRole); + leftData = sourceModel()->data(left, Qt::UserRole); rightData = sourceModel()->data(right, Qt::UserRole); return leftData.toLongLong() < rightData.toLongLong(); } @@ -788,54 +785,54 @@ /*QVariant MvQFolderFilterModel::data(const QModelIndex& index, int role ) const { - if(role == Qt::DecorationRole && matchLst_.count() > 0 ) - { - if(MvQFolderModel *md=static_cast(sourceModel())) - { - if(IconObject *obj=md->objectFromIndex(mapToSource(index))) - { - if(!matchLst_.contains(obj)) - { - return md->data(mapToSource(index),MvQFolderModel::GreyedOutRole); - } - } - } - } - - return sourceModel()->data(mapToSource(index),role); + if(role == Qt::DecorationRole && matchLst_.count() > 0 ) + { + if(MvQFolderModel *md=static_cast(sourceModel())) + { + if(IconObject *obj=md->objectFromIndex(mapToSource(index))) + { + if(!matchLst_.contains(obj)) + { + return md->data(mapToSource(index),MvQFolderModel::GreyedOutRole); + } + } + } + } + + return sourceModel()->data(mapToSource(index),role); } */ -/* +/* bool MvQFolderFilterModel::setFilter(QString name,QString type) { - bool found=false; - - if(name_ == name.toStdString() && type_ == type.toStdString()) - return found; - - name_=name.toStdString(); - type_=type.toStdString(); - - matchLst_.clear(); - - MvQFolderModel *md=static_cast(sourceModel()); - if(!md) - return found; - - if(!name_.empty() || !type_.empty()) - { - for(int i=0; i< rowCount(); i++) - { - QModelIndex idx=index(i,0); - if(IconObject *obj=md->objectFromIndex(mapToSource(idx))) - { - if(obj->match(name_,type_)) - matchLst_ << obj; - } - } - } - - reset(); - - return found; + bool found=false; + + if(name_ == name.toStdString() && type_ == type.toStdString()) + return found; + + name_=name.toStdString(); + type_=type.toStdString(); + + matchLst_.clear(); + + MvQFolderModel *md=static_cast(sourceModel()); + if(!md) + return found; + + if(!name_.empty() || !type_.empty()) + { + for(int i=0; i< rowCount(); i++) + { + QModelIndex idx=index(i,0); + if(IconObject *obj=md->objectFromIndex(mapToSource(idx))) + { + if(obj->match(name_,type_)) + matchLst_ << obj; + } + } + } + + reset(); + + return found; } */ diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderModel.h metview-5.19.2/metview/src/Desktop/MvQFolderModel.h --- metview-5.17.4/metview/src/Desktop/MvQFolderModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -38,8 +38,8 @@ void clear() { className = ""; - x = 0; - y = 0; + x = 0; + y = 0; } std::string className; int x; @@ -51,28 +51,28 @@ Q_OBJECT public: - MvQFolderModel(QObject* parent = 0); - MvQFolderModel(int, QObject* parent = 0); - ~MvQFolderModel(); + MvQFolderModel(QObject* parent = nullptr); + MvQFolderModel(int, QObject* parent = nullptr); + ~MvQFolderModel() override; enum CustomItemRole { ClassFilterRole = Qt::UserRole + 1, - EditorRole = Qt::UserRole + 2, - PositionRole = Qt::UserRole + 3, + EditorRole = Qt::UserRole + 2, + PositionRole = Qt::UserRole + 3, FontMetricsRole = Qt::UserRole + 4 }; - int columnCount(const QModelIndex&) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex&) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex&, const QVariant&, int); - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; - - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; - Qt::ItemFlags flags(const QModelIndex&) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex&, const QVariant&, int) override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; + + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; + Qt::ItemFlags flags(const QModelIndex&) const override; void folderIsAboutToChange(); Folder* folder() { return folder_; } @@ -91,21 +91,21 @@ void createNewFolder(); void saveFolderInfo(); - //Observer methods + // Observer methods - void arrived(IconObject*); - void gone(IconObject*); - void position(IconObject*, int, int); - void renamed(IconObject*, const std::string&); - - void waiting(IconObject*); - void error(IconObject*); - void modified(IconObject*); - void ready(IconObject*); - void opened(IconObject*); - void closed(IconObject*); - void highlight(IconObject*); - void iconChanged(IconObject*); + void arrived(IconObject*) override; + void gone(IconObject*) override; + void position(IconObject*, int, int) override; + void renamed(IconObject*, const std::string&) override; + + void waiting(IconObject*) override; + void error(IconObject*) override; + void modified(IconObject*) override; + void ready(IconObject*) override; + void opened(IconObject*) override; + void closed(IconObject*) override; + void highlight(IconObject*) override; + void iconChanged(IconObject*) override; void setIconSize(int); int iconSize() const; @@ -134,18 +134,17 @@ void updateSearchData(bool doReset); bool hasSearchData() const; - Folder* folder_; + Folder* folder_{nullptr}; QList items_; - bool initialScanIsOn_; std::vector classes_; - IconObject* lastArrived_; + IconObject* lastArrived_{nullptr}; MvQFolderItemProperty* itemProp_; PositionHint posHint_; static QHash statusColour_; static QColor fadedColour_; - mutable FolderSearchData* searchData_; + mutable FolderSearchData* searchData_{nullptr}; private: void init(); @@ -155,17 +154,17 @@ class MvQFolderFilterModel : public QSortFilterProxyModel { public: - MvQFolderFilterModel(QObject* parent = 0); - void setSourceModel(QAbstractItemModel*); - bool filterAcceptsRow(int, const QModelIndex&) const; + MvQFolderFilterModel(QObject* parent = nullptr); + void setSourceModel(QAbstractItemModel*) override; + bool filterAcceptsRow(int, const QModelIndex&) const override; bool lessThan(const QModelIndex& left, - const QModelIndex& right) const; + const QModelIndex& right) const override; - //QVariant data(const QModelIndex& index, int role ) const; - //bool setFilter(QString,QString); + // QVariant data(const QModelIndex& index, int role ) const; + // bool setFilter(QString,QString); protected: - MvQFolderModel* folderModel_; + MvQFolderModel* folderModel_{nullptr}; std::string name_; std::string type_; QList matchLst_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderNavigation.cc metview-5.19.2/metview/src/Desktop/MvQFolderNavigation.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderNavigation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderNavigation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,7 @@ #include "MvQFolderNavigation.h" -#include +#include void MvQFolderNavigation::clear() { diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderNavigation.h metview-5.19.2/metview/src/Desktop/MvQFolderNavigation.h --- metview-5.17.4/metview/src/Desktop/MvQFolderNavigation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderNavigation.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ class MvQFolderNavigation { public: - MvQFolderNavigation() : - pos_(-1), maxSize_(300) {} + MvQFolderNavigation() = default; void clear(); bool isEmpty() const { return folders_.isEmpty(); } @@ -34,6 +33,6 @@ bool isPosCorrect(); QStringList folders_; - int pos_; - int maxSize_; + int pos_{-1}; + int maxSize_{300}; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderPanel.cc metview-5.19.2/metview/src/Desktop/MvQFolderPanel.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -55,7 +55,7 @@ MvQTabWidget::MvQTabWidget(QWidget* parent) : QWidget(parent) { - //Create layout + // Create layout auto* layout = new QVBoxLayout(this); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); @@ -72,7 +72,7 @@ bar_->setMovable(true); bar_->setExpanding(true); - //Add tab button + // Add tab button addTb_ = new QToolButton(this); addTb_->setAutoRaise(true); addTb_->setIcon(QPixmap(":/desktop/add_tab.svg")); @@ -110,7 +110,7 @@ nextTabTb_->setDefaultAction(nextAc_); hb->addWidget(nextTabTb_); - //Tab list menu + // Tab list menu tabListTb_ = new QToolButton(this); tabListTb_->setAutoRaise(true); tabListTb_->setIcon(QPixmap(":/desktop/menu_arrow_down.svg")); @@ -118,11 +118,11 @@ hb->addWidget(tabListTb_); stacked_ = new QStackedWidget(this); - //stacked_->setMinimumHeight(1); - //stacked_->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum); + // stacked_->setMinimumHeight(1); + // stacked_->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum); layout->addWidget(stacked_); - //Context menu + // Context menu bar_->setContextMenuPolicy(Qt::CustomContextMenu); connect(bar_, SIGNAL(customContextMenuRequested(const QPoint&)), @@ -167,7 +167,7 @@ int index = bar_->tabAt(pos); QString selection = MvQContextMenu::instance()->exec(cms->icon(), mapToGlobal(pos), this, - //QString::number(bar_->count())); + // QString::number(bar_->count())); "path=" + folderPath(index)); if (!selection.isEmpty()) tabBarCommand(selection, index); @@ -194,7 +194,7 @@ return stacked_->widget(index); } - return 0; + return nullptr; } QWidget* MvQTabWidget::currentWidget() const @@ -277,14 +277,14 @@ stacked_->removeWidget(w); stacked_->insertWidget(to, w); - //Experience with Qt 4.6.3: Here from and to does not - //incicate the dragged tabs's position!!! - //But at least tab_->currentIndex() shows the dragged tab's new position. + // Experience with Qt 4.6.3: Here from and to does not + // incicate the dragged tabs's position!!! + // But at least tab_->currentIndex() shows the dragged tab's new position. - //qDebug() << "move" << from << to << bar_->currentIndex(); + // qDebug() << "move" << from << to << bar_->currentIndex(); - //We do not emit currentIndexChanged() signal here because - //the "current widget" stayed the same! + // We do not emit currentIndexChanged() signal here because + // the "current widget" stayed the same! if (stacked_->count() == bar_->count()) { stacked_->setCurrentIndex(bar_->currentIndex()); checkTabStatus(); @@ -320,7 +320,7 @@ if (index >= 0 && index < bar_->count()) { return bar_->tabData(index); } - return QVariant(); + return {}; } @@ -329,7 +329,7 @@ if (index >= 0 && index < bar_->count()) { return bar_->tabIcon(index); } - return QIcon(); + return {}; } void MvQTabWidget::setTabText(int index, QString txt) @@ -397,8 +397,8 @@ QString s = bar_->tabText(index); if (!s.isEmpty()) { - //Folder *f=Folder::folder(s.toStdString(),false); - //if(f && !f->locked()) + // Folder *f=Folder::folder(s.toStdString(),false); + // if(f && !f->locked()) //{ Qt::DropAction dropAction = event->proposedAction(); MvQDropTarget::Instance()->reset(s, (dropAction == Qt::MoveAction)); @@ -533,7 +533,7 @@ Folder* MvQFolderPanel::currentFolder() { MvQFolderWidget* w = currentFolderWidget(); - return (w) ? w->currentFolder() : 0; + return (w) ? w->currentFolder() : nullptr; } QList MvQFolderPanel::currentFolders() @@ -554,7 +554,7 @@ if (Folder* f = w->currentFolder()) return QString::fromStdString(f->fullName()); } - return QString(); + return {}; } void MvQFolderPanel::setHistoryMenu(QMenu* m) @@ -579,13 +579,13 @@ MvQFolderWidget* MvQFolderPanel::addWidget(QString path) { - //if(path.isEmpty()) - // return 0; + // if(path.isEmpty()) + // return 0; auto* fw = new MvQFolderWidget(path, folderHistory_, &iconActions_, &desktopActions_, this); QString name = fw->currentFolderName(); - QPixmap pix = MvQIconProvider::pixmap(fw->currentFolder(), 24); + QPixmap pix = MvQIconProvider::pixmap(fw->currentFolder(), 24); addTab(fw, pix, name); @@ -659,13 +659,13 @@ MvQFolderWidget* MvQFolderPanel::folderWidget(int index) { QWidget* w = widget(index); - return (w) ? static_cast(w) : 0; + return (w) ? dynamic_cast(w) : nullptr; } MvQFolderWidget* MvQFolderPanel::currentFolderWidget() { QWidget* w = currentWidget(); - return static_cast(w); + return dynamic_cast(w); } void MvQFolderPanel::slotCurrentWidgetChanged(int /*index*/) @@ -739,9 +739,9 @@ /*void MvQFolderPanel::updateFolderHistory(QString) { - folderNavigation_->removeAfterCurrent(); - folderNavigation_->add(path); - updateNavigationActionState(); + folderNavigation_->removeAfterCurrent(); + folderNavigation_->add(path); + updateNavigationActionState(); }*/ void MvQFolderPanel::slotChFolderBack() @@ -782,7 +782,7 @@ w->chFolderFromBookmarks(mvHomePath_); } else { - //If there is no widget at all we offer this way to create one! + // If there is no widget at all we offer this way to create one! if (count() != 0) addWidget(mvHomePath_); } @@ -797,7 +797,7 @@ w->chFolderFromBookmarks(defaultsPath); } else { - //If there is no widget at all we offer this way to create one! + // If there is no widget at all we offer this way to create one! if (count() != 0) addWidget(defaultsPath); } @@ -805,11 +805,11 @@ /*void MvQFolderPanel::slotFolderChangedInView(QString path) { - folderNavigation_->removeAfterCurrent(); - folderNavigation_->add(path); - updateNavigationActionState(); - folderHistory_->add(path); - pathWidget_->setPath(path); + folderNavigation_->removeAfterCurrent(); + folderNavigation_->add(path); + updateNavigationActionState(); + folderHistory_->add(path); + pathWidget_->setPath(path); }*/ void MvQFolderPanel::slotChFolderFromHistory(QString path) @@ -854,7 +854,7 @@ void MvQFolderPanel::slotPathChanged() { - auto* fw = static_cast(sender()); + auto* fw = dynamic_cast(sender()); if (count() > 0 && fw) { int index = indexOfWidget(fw); @@ -898,13 +898,16 @@ { if (name == "openInTab") { addWidget(path); - } else if (name == "openInWin") { + } + else if (name == "openInWin") { MvQFileBrowser::openBrowser(path, this); - } else if (name == "bookmark") { + } + else if (name == "bookmark") { MvQBookmarks::addItem(path); - } else if (name == "copy_path") { + } + else if (name == "copy_path") { auto pathStr = path.toStdString(); - if (Folder *f = Folder::folder(pathStr, false)) { + if (Folder* f = Folder::folder(pathStr, false)) { MvQ::toClipboard(QString::fromStdString(f->path().str())); } } @@ -1010,7 +1013,7 @@ if (w) return w->folderNavigation(); - return 0; + return nullptr; } //========================================================== @@ -1040,7 +1043,7 @@ } } - //If the icons's parent folder is not displayed + // If the icons's parent folder is not displayed if (addFolder) { if (MvQFolderWidget* fw = addWidget(QString::fromStdString(obj->parent()->fullName()))) { fw->showIcon(obj); @@ -1067,7 +1070,7 @@ qDebug() << "----------------------"; #endif QString prevPath = tabNavigation_->prev(); - int idx = pathLst.indexOf(prevPath); + int idx = pathLst.indexOf(prevPath); if (idx != -1) { inTabNavigation_ = true; setCurrentIndex(idx); @@ -1093,7 +1096,7 @@ } QString nextPath = tabNavigation_->next(); - int idx = pathLst.indexOf(nextPath); + int idx = pathLst.indexOf(nextPath); if (idx != -1) { inTabNavigation_ = true; setCurrentIndex(idx); @@ -1110,7 +1113,7 @@ menu->addAction(prevAc_); menu->addAction(nextAc_); - //Recent tabs + // Recent tabs menu->addSeparator(); QStringList pathLst; @@ -1118,7 +1121,7 @@ pathLst << tabData(i).toString(); } - int cnt = 0; + int cnt = 0; int maxCnt = 10; foreach (QString item, folderHistory_->items()) { int idx = pathLst.indexOf(item); @@ -1166,7 +1169,7 @@ removeDupAc->setData(-1); menu->addAction(removeDupAc); - //All the tabs + // All the tabs menu->addSeparator(); for (int i = 0; i < count(); i++) { @@ -1237,16 +1240,16 @@ { inInitialLoad_ = true; - //Create folder tabs - int cnt = settings.value("folderCount").toInt(); + // Create folder tabs + int cnt = settings.value("folderCount").toInt(); int currentIndex = settings.value("current").toInt(); if (cnt > 0) { for (int i = 0; i < cnt; i++) { settings.beginGroup("folder_" + QString::number(i)); QString relPath = settings.value("path").toString(); - //Path mvPath(path.toStdString()); - //if(mvPath.exists()) + // Path mvPath(path.toStdString()); + // if(mvPath.exists()) //{ MvQFolderWidget* fw = addWidget(relPath); if (fw) @@ -1256,7 +1259,7 @@ settings.endGroup(); } - //Set current tab + // Set current tab if (currentIndex >= 0 && currentIndex < cnt) { setCurrentIndex(currentIndex); } diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderPanel.h metview-5.19.2/metview/src/Desktop/MvQFolderPanel.h --- metview-5.17.4/metview/src/Desktop/MvQFolderPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -41,7 +41,7 @@ Q_OBJECT public: - MvQTabWidget(QWidget* parent = 0); + MvQTabWidget(QWidget* parent = nullptr); int currentIndex() const; int indexOfWidget(QWidget*) const; @@ -63,7 +63,7 @@ void removeTab(int); void removeOtherTabs(int); void setCurrentIndex(int); - virtual void slotTabList() = 0; + virtual void slotTabList() = 0; virtual void slotRecentTabs() = 0; private slots: @@ -79,18 +79,18 @@ void iconDropped(int, QDropEvent*); protected: - virtual MvQContextItemSet* cmSet() = 0; + virtual MvQContextItemSet* cmSet() = 0; virtual void tabBarCommand(QString, int) = 0; - virtual QString folderPath(int) = 0; + virtual QString folderPath(int) = 0; void removeDuplicatedTabs(); void checkDropTarget(QDropEvent* event); void removeDropTarget(); - void dragEnterEvent(QDragEnterEvent* event); - void dragMoveEvent(QDragMoveEvent* event); - void dragLeaveEvent(QDragLeaveEvent* event); - void dropEvent(QDropEvent* event); - void paintEvent(QPaintEvent*); + void dragEnterEvent(QDragEnterEvent* event) override; + void dragMoveEvent(QDragMoveEvent* event) override; + void dragLeaveEvent(QDragLeaveEvent* event) override; + void dropEvent(QDropEvent* event) override; + void paintEvent(QPaintEvent*) override; QToolButton* tabListTb_; QToolButton* recentTb_; @@ -110,8 +110,8 @@ Q_OBJECT public: - MvQFolderPanel(QWidget* parent = 0); - ~MvQFolderPanel(); + MvQFolderPanel(QWidget* parent = nullptr); + ~MvQFolderPanel() override; Folder* currentFolder(); QString currentFolderName(); @@ -167,8 +167,8 @@ protected slots: void slotPrevTab(bool); void slotNextTab(bool); - void slotTabList(); - void slotRecentTabs(); + void slotTabList() override; + void slotRecentTabs() override; signals: void itemInfoChanged(IconObject*); @@ -176,11 +176,11 @@ void currentWidgetChanged(); protected: - MvQContextItemSet* cmSet(); + MvQContextItemSet* cmSet() override; MvQFolderWidget* currentFolderWidget(); MvQFolderWidget* folderWidget(int); - QString folderPath(int); - void tabBarCommand(QString, int); + QString folderPath(int) override; + void tabBarCommand(QString, int) override; QString mvHomePath_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderViewBase.cc metview-5.19.2/metview/src/Desktop/MvQFolderViewBase.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderViewBase.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderViewBase.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,6 +32,7 @@ #include "MvQDesktopSettings.h" #include "MvQFileBrowser.h" #include "MvQFileDialog.h" +#include "FilePropertyDialog.h" #include "MvQFolderItemProperty.h" #include "MvQFolderModel.h" #include "MvQIconMimeData.h" @@ -49,8 +50,7 @@ MvQFolderViewBase::MvQFolderViewBase(MvQFolderModel* folderModel, QWidget* view) : folderModel_(folderModel), - view_(view), - shortCutInit_(false) + view_(view) { filterModel_ = new MvQFolderFilterModel; filterModel_->setSourceModel(folderModel_); @@ -138,8 +138,8 @@ if (!cms) return; - //Icon actions - if (indexClicked.isValid() && indexClicked.column() == 0) //indexLst[0].isValid() && indexLst[0].column() == 0) + // Icon actions + if (indexClicked.isValid() && indexClicked.column() == 0) // indexLst[0].isValid() && indexLst[0].column() == 0) { std::vector objLst; for (int i = 0; i < indexLst.count(); i++) { @@ -151,10 +151,10 @@ if (objLst.size() > 0) { QString selection; if (objLst.size() == 1) - //selection=MvQContextMenu::instance()->exec(cmIconItems_,objLst[0],globalPos,widget); + // selection=MvQContextMenu::instance()->exec(cmIconItems_,objLst[0],globalPos,widget); selection = MvQContextMenu::instance()->exec(cms->icon(), objLst[0], globalPos, widget); else - //selection=MvQContextMenu::instance()->exec(cmMultiIconItems_,objLst,globalPos,widget); + // selection=MvQContextMenu::instance()->exec(cmMultiIconItems_,objLst,globalPos,widget); selection = MvQContextMenu::instance()->exec(cms->multiIcon(), objLst, globalPos, widget); if (!selection.isEmpty()) @@ -162,18 +162,18 @@ } /*IconObject* obj=folderModel_->objectFromIndex(filterModel_->mapToSource(index)); - if(obj) - { - QString selection=MvQContextMenu::instance()->exec(cmIconItems_,obj,globalPos,widget); - - if(!selection.isEmpty()) - handleIconCommand(obj,selection); - }*/ + if(obj) + { + QString selection=MvQContextMenu::instance()->exec(cmIconItems_,obj,globalPos,widget); + + if(!selection.isEmpty()) + handleIconCommand(obj,selection); + }*/ } - //Desktop actions + // Desktop actions else { - //QString selection=MvQContextMenu::instance()->exec(cmDesktopItems_,globalPos,widget); + // QString selection=MvQContextMenu::instance()->exec(cmDesktopItems_,globalPos,widget); QString selection = MvQContextMenu::instance()->exec(cms->desktop(), globalPos, widget); if (!selection.isEmpty()) { handleDesktopCommand(selection, widgetPos, widget); @@ -231,14 +231,16 @@ if (objLstIn.empty()) return; - //Selects the iconobjects for that the command is valid + // Selects the iconobjects for that the command is valid std::vector objLst; for (auto it : objLstIn) { if (it) { std::set cmdSet = it->can(); - QString canCmd = name; + QString canCmd = name; if (name.startsWith("compress_")) canCmd = "compress"; + else if (name.startsWith("archive_")) + canCmd = "archive"; if (cmdSet.find(canCmd.toStdString()) != cmdSet.end()) { objLst.push_back(it); @@ -308,19 +310,19 @@ if (!obj) return; - //Check if the command is valid for the object + // Check if the command is valid for the object std::set cmdSet = obj->can(); if (cmdSet.find(name.toStdString()) == cmdSet.end()) return; - //Delete icon (permanently) + // Delete icon (permanently) if (name == "destroy") { if (confirmDelete(1)) { obj->command(name.toStdString()); } } - //Other actions + // Other actions else if (Command::isValid(name.toStdString())) { if (name == "save") { QPoint refPos = itemProp_->referencePosition(obj); @@ -349,6 +351,11 @@ if (Folder* f = obj->parent()) f->recheckKidIconClass(obj); } + else if (name == "property") { + FilePropertyDialog d; + d.setItem(obj); + d.exec(); + } else { iconCommand(name, obj); } @@ -358,9 +365,9 @@ { Folder* folder = folderModel_->folder(); - //For the detailed view the actual icon position should be ignored for desktop commands, - //e.g. when creating a new icon. In this case we use an "undefined" position!!! - //ignoreItemPositionForCm() tells us when we need to apply it. + // For the detailed view the actual icon position should be ignored for desktop commands, + // e.g. when creating a new icon. In this case we use an "undefined" position!!! + // ignoreItemPositionForCm() tells us when we need to apply it. if (name == "createFolder") { const IconClass& kind = IconClass::find("FOLDER"); @@ -388,12 +395,12 @@ if (dialog.exec() == QDialog::Accepted) { const IconClass& kind = dialog.selected(); - QPoint refPos = itemProp_->referencePosition(QString::fromStdString(kind.name()), pos); + QPoint refPos = itemProp_->referencePosition(QString::fromStdString(kind.name()), pos); if (ignoreItemPositionForCm()) kind.createOne(folder); else kind.createOne(folder, refPos.x(), refPos.y()); - //showLastCreated(); + // showLastCreated(); } } else if (name == "createLinkToFile" || name == "createLinkToFolder") { @@ -412,13 +419,13 @@ if (lst.count() > 0) { Path result(lst[0].toStdString()); std::string name = folder->uniqueName(result.name()); - Path path = folder->path().add(name); + Path path = folder->path().add(name); path.symlink(result); - //The dot file for a link should not be created in the - //link target's folder. By commenting out the line below we can prevent it! - //path.dot().symlink(result.dot()); + // The dot file for a link should not be created in the + // link target's folder. By commenting out the line below we can prevent it! + // path.dot().symlink(result.dot()); if (ignoreItemPositionForCm()) folder->scanForNewFile(name); else @@ -495,7 +502,7 @@ qobject_cast(QApplication::clipboard()->mimeData()); #endif - //If there is data we simulate drop + // If there is data we simulate drop if (mimeData && !mimeData->isEmpty()) { if (mimeData->clipboardAction() == MvQIconMimeData::CopyAction) performDrop(Qt::CopyAction, mimeData, pos, false); @@ -516,7 +523,7 @@ txt2 = QObject::tr("Do you really want to delete these ") + QString::number(count) + QObject::tr(" icons? They will be permanently deleted from disk!"); } - return (QMessageBox::warning(0, txt1, txt2, + return (QMessageBox::warning(nullptr, txt1, txt2, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Yes); } @@ -533,15 +540,15 @@ return QString::number(size/(1024*1024*1024)) + " GB"; #endif - return QString(); + return {}; } QString MvQFolderViewBase::formatFilePermissions(const QFile::Permissions& perm) { - //There is a bug in Qt 4.6.3 (it was the version used for the developments)! - //QFileSystemModel::permissions() gives inversed results for the - //write premissions. So the the code below had to be changed to cope - //with it (the original code is still kept but commented out). + // There is a bug in Qt 4.6.3 (it was the version used for the developments)! + // QFileSystemModel::permissions() gives inversed results for the + // write premissions. So the the code below had to be changed to cope + // with it (the original code is still kept but commented out). return "-" + QString((perm.testFlag(QFile::ReadOwner)) ? "r" : "-") + @@ -599,7 +606,7 @@ QFontMetrics fm(f); QRect textRect(0, 0, MvQ::textWidth(fm, QString::number(cnt)), fm.height()); - int padding = 2; + int padding = 2; int overlapx = 4; int overlapy = 10; @@ -615,14 +622,14 @@ iconPix = QRect(0, pix.height() - getIconSize(), getIconSize(), getIconSize()); - //Item count indicator - QPen pen = MvQTheme::pen("folderview", "drag_count_pen"); + // Item count indicator + QPen pen = MvQTheme::pen("folderview", "drag_count_pen"); QBrush brush = MvQTheme::brush("folderview", "drag_count_brush"); painter.setPen(pen); painter.setBrush(brush); painter.setFont(f); - //painter.setRenderHint(QPainter::Antialiasing,true); + // painter.setRenderHint(QPainter::Antialiasing,true); QRect cntRect(getIconSize() - overlapx + 2, 1, textRect.width() + 2 * padding, textRect.height() + 2 * padding); painter.drawRoundedRect(cntRect, 2, 2); @@ -642,27 +649,27 @@ MvQIconMimeData* MvQFolderViewBase::buildClipboardData(IconObject* dragObj, QList objLst, bool fromHelper, bool copy) { if (dragObj && objLst.contains(dragObj)) { - //Hotspot is the bottom right corner of the dragged object's pixmap + // Hotspot is the bottom right corner of the dragged object's pixmap QPoint hotSpotInPix(1, 1); - //It has to have as many elements as there are in objLst - QList pixDistanceLst; //It has + // It has to have as many elements as there are in objLst + QList pixDistanceLst; // It has - //Multiple items + // Multiple items if (objLst.count() > 1) { - //Pixmap rect of the drag object + // Pixmap rect of the drag object QRect rect = pixmapRect(dragObj); for (int i = 0; i < objLst.count(); i++) { QRect vr = pixmapRect(objLst[i]); - //Normalised distance of the pixmap's bottom right corner from the - //bottom right corner of the dragged object's pixmap + // Normalised distance of the pixmap's bottom right corner from the + // bottom right corner of the dragged object's pixmap pixDistanceLst << (vr.bottomRight() - rect.bottomRight()) / getIconSize(); } } - //Single item + // Single item else { pixDistanceLst << QPoint(0, 0); } @@ -673,7 +680,7 @@ else ca = MvQIconMimeData::CutAction; - //Create and set drag mime data + // Create and set drag mime data auto* mimeData = new MvQIconMimeData(folderModel_, dragObj, hotSpotInPix, objLst, pixDistanceLst, ca); @@ -682,7 +689,7 @@ return mimeData; } - return 0; + return nullptr; } QDrag* MvQFolderViewBase::buildDrag(IconObject* dragObj, QList objLst, bool fromHelper, QWidget* dragParent, QPoint dragPos) @@ -690,23 +697,23 @@ if (dragObj && objLst.contains(dragObj)) { auto* drag = new QDrag(dragParent); - //Hotspot is the bottom right corner of the dragged object's pixmap - //we overwrite it if dragPos is null!! We use normalised coordinates + // Hotspot is the bottom right corner of the dragged object's pixmap + // we overwrite it if dragPos is null!! We use normalised coordinates QPointF hotSpotInPix(1, 1); - //It has to have as many elements as there are in objLst + // It has to have as many elements as there are in objLst QList pixDistanceLst; - //Multiple items + // Multiple items if (objLst.count() > 1) { if (MvQDesktopSettings::dragPolicy() == Desktop::DragShowAllIcons) { - //Pixmap rect of the drag object + // Pixmap rect of the drag object QRect rect = pixmapRect(dragObj); - //Find bounding box for selected pixmap rects + // Find bounding box for selected pixmap rects QRect bbox = pixmapRect(objLst); - //Render the drag pixmap --> will contain all the icons pixmaps! + // Render the drag pixmap --> will contain all the icons pixmaps! QPixmap pix(bbox.size()); pix.fill(Qt::transparent); QPainter painter(&pix); @@ -716,8 +723,8 @@ painter.drawPixmap(vr.topLeft() - bbox.topLeft(), MvQIconProvider::pixmap(objLst.at(i)->iconClass(), getIconSize())); - //Normalised distance of the pixmap's bottom right corner from the - //bottom right corner of the dragged object's pixmap + // Normalised distance of the pixmap's bottom right corner from the + // bottom right corner of the dragged object's pixmap pixDistanceLst << (vr.bottomRight() - rect.bottomRight()) / getIconSize(); } @@ -725,14 +732,14 @@ QPoint hotSpot; - //Hotspot is the bottom right corner of the dragged object's pixmap + // Hotspot is the bottom right corner of the dragged object's pixmap if (dragPos.isNull()) { - hotSpot = rect.bottomRight() - bbox.topLeft(); + hotSpot = rect.bottomRight() - bbox.topLeft(); hotSpotInPix = QPointF(1, 1); } - //We use the real drag position if dragPos in not present + // We use the real drag position if dragPos in not present else { - hotSpot = dragPos - bbox.topLeft(); + hotSpot = dragPos - bbox.topLeft(); hotSpotInPix = QPointF(dragPos.x() - (rect.center().x() - getIconSize() / 2), dragPos.y() - rect.top()); hotSpotInPix /= getIconSize(); @@ -741,14 +748,14 @@ drag->setHotSpot(hotSpot); } else { - //Pixmap rect of the drag object + // Pixmap rect of the drag object QRect rect = pixmapRect(dragObj); for (int i = 0; i < objLst.count(); i++) { QRect vr = pixmapRect(objLst[i]); - //Normalised distance of the pixmap's bottom right corner from the - //bottom right corner of the dragged object's pixmap + // Normalised distance of the pixmap's bottom right corner from the + // bottom right corner of the dragged object's pixmap pixDistanceLst << (vr.bottomRight() - rect.bottomRight()) / getIconSize(); } @@ -756,25 +763,25 @@ QPixmap pix = dragPixmapWithCount(dragObj, objLst.count(), iconPix); drag->setPixmap(pix); - //Hotspot is the bottom right corner of the dragged object's pixmap + // Hotspot is the bottom right corner of the dragged object's pixmap QPoint hotSpot(iconPix.bottomRight()); hotSpotInPix = QPointF(1, 1); drag->setHotSpot(hotSpot); } } - //Single item + // Single item else { drag->setPixmap(MvQIconProvider::pixmap(dragObj->iconClass(), getIconSize())); QPoint hotSpot; if (dragPos.isNull()) { - hotSpot = QPoint(getIconSize(), getIconSize()); + hotSpot = QPoint(getIconSize(), getIconSize()); hotSpotInPix = QPointF(1, 1); } - //We use the real drag position + // We use the real drag position else { - //Pixmap rect of the drag object + // Pixmap rect of the drag object QRect rect = pixmapRect(dragObj); hotSpot = QPoint(dragPos.x() - (rect.center().x() - getIconSize() / 2), @@ -790,7 +797,7 @@ } - //Create and set drag mime data + // Create and set drag mime data auto* mimeData = new MvQIconMimeData(folderModel_, dragObj, hotSpotInPix, objLst, pixDistanceLst); @@ -802,7 +809,7 @@ return drag; } - return 0; + return nullptr; } void MvQFolderViewBase::dropToFolder(Folder* folder, QDropEvent* event) @@ -841,27 +848,27 @@ return; } - //Ignore drops from the same folder - except when it comes from an editor + // Ignore drops from the same folder - except when it comes from an editor if (dragObj->parent() == folder && !mimeData->fromEditor()) { event->ignore(); return; } - //Drop from another view/model or from the clipboard or from an editor --> copy or move + // Drop from another view/model or from the clipboard or from an editor --> copy or move for (int i = 0; i < mimeData->objects().count(); i++) { IconObject* obj = mimeData->objects().at(i); - //We set the object position to zero. This will instuct the icon folder view + // We set the object position to zero. This will instuct the icon folder view //(when the folder is next open in it) to find meaningful positions to the - //icons. + // icons. - //Copy + // Copy if (event->proposedAction() == Qt::CopyAction) { obj->clone(folder, false); } - //Move + // Move else if (event->proposedAction() == Qt::MoveAction) { obj->position(IconInfo::undefX(), IconInfo::undefY()); folder->adopt(obj); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderViewBase.h metview-5.19.2/metview/src/Desktop/MvQFolderViewBase.h --- metview-5.17.4/metview/src/Desktop/MvQFolderViewBase.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderViewBase.h 2023-07-15 08:28:47.000000000 +0000 @@ -49,6 +49,8 @@ MvQFolderViewBase(MvQFolderModel*, QWidget*); virtual ~MvQFolderViewBase(); + MvQFolderViewBase(const MvQFolderViewBase&) = delete; + MvQFolderViewBase& operator=(const MvQFolderViewBase&) = delete; Folder* currentFolder(); bool changeFolderToParent(); @@ -73,8 +75,8 @@ virtual void attachModel() = 0; virtual void detachModel() = 0; bool changeFolder(const QModelIndex&, IndexType indexType = FsModelIndex); - virtual void folderChanged() = 0; - virtual void blink(const QModelIndex&) = 0; + virtual void folderChanged() = 0; + virtual void blink(const QModelIndex&) = 0; virtual void showIcon(const QModelIndex&) = 0; virtual void iconSizeChanged() {} virtual void rename(IconObject*) = 0; @@ -84,7 +86,7 @@ void handleIconShortCut(QShortcut*, QModelIndexList); void handleDesktopShortCut(QShortcut* sc, QPoint pos, QWidget* widget); virtual void iconCommand(QString, IconObjectH) = 0; - virtual void desktopCommand(QString, QPoint) = 0; + virtual void desktopCommand(QString, QPoint) = 0; IconObject* itemInfo(const QModelIndex&, IndexType); QString formatFileSize(qint64); @@ -96,32 +98,31 @@ void handleIconCommand(QModelIndexList indexLst, QString name); virtual MvQContextItemSet* cmSet() = 0; - virtual void setupShortCut() = 0; + virtual void setupShortCut() = 0; virtual bool ignoreItemPositionForCm() = 0; - //Drag and drop - virtual QRect itemRect(IconObject*) = 0; - virtual QRect itemRect(QList) = 0; - virtual QRect pixmapRect(IconObject*) = 0; - virtual QRect pixmapRect(QList) = 0; + // Drag and drop + virtual QRect itemRect(IconObject*) = 0; + virtual QRect itemRect(QList) = 0; + virtual QRect pixmapRect(IconObject*) = 0; + virtual QRect pixmapRect(QList) = 0; virtual void performDrop(Qt::DropAction, const MvQIconMimeData*, QPoint, bool) = 0; QPixmap dragPixmapWithCount(IconObject*, int cnt, QRect&); QDrag* buildDrag(IconObject* dragObj, QList objLst, bool, QWidget*, QPoint dragPos = QPoint()); - //Clipboard + // Clipboard void copyToClipboard(IconObject*, QList); void cutToClipboard(IconObject*, QList); void copyPathToClipboard(IconObject* obj, QList lst); void fromClipboard(QPoint); MvQIconMimeData* buildClipboardData(IconObject* dragObj, QList objLst, bool fromHelper, bool copy); - MvQFolderFilterModel* filterModel_; - MvQFolderModel* folderModel_; - QWidget* view_; - int iconSize_; - MvQFolderItemProperty* itemProp_; - bool shortCutInit_; + MvQFolderFilterModel* filterModel_{nullptr}; + MvQFolderModel* folderModel_{nullptr}; + QWidget* view_{nullptr}; + MvQFolderItemProperty* itemProp_{nullptr}; + bool shortCutInit_{false}; private: void handleIconCommand(const std::vector&, QString); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderViewDelegate.cc metview-5.19.2/metview/src/Desktop/MvQFolderViewDelegate.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderViewDelegate.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderViewDelegate.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ MvQFolderViewDelegate::MvQFolderViewDelegate(QWidget* parent) : QStyledItemDelegate(parent), - timer_(0), + timer_(nullptr), blinkCnt_(-1), blinkNum_(5), enablePaint_(true) @@ -40,12 +40,12 @@ void MvQFolderViewDelegate::setColours() { QString group = "folderview"; - editPen_ = QPen(MvQTheme::colour(group, "edit_pen")); - editBrush_ = MvQTheme::brush(group, "edit_brush"); - hoverPen_ = QPen(MvQTheme::colour(group, "hover_pen")); - hoverBrush_ = MvQTheme::brush(group, "hover_brush"); - selectPen_ = QPen(MvQTheme::colour(group, "select_pen")); - selectBrush_ = MvQTheme::brush(group, "select_brush"); + editPen_ = QPen(MvQTheme::colour(group, "edit_pen")); + editBrush_ = MvQTheme::brush(group, "edit_brush"); + hoverPen_ = QPen(MvQTheme::colour(group, "hover_pen")); + hoverBrush_ = MvQTheme::brush(group, "hover_brush"); + selectPen_ = QPen(MvQTheme::colour(group, "select_pen")); + selectBrush_ = MvQTheme::brush(group, "select_brush"); } void MvQFolderViewDelegate::blink(const QModelIndex& index) @@ -67,7 +67,7 @@ if (blinkCnt_ == 2 * blinkNum_ + 1) { timer_->stop(); blinkIndex_ = QModelIndex(); - blinkCnt_ = -1; + blinkCnt_ = -1; } else blinkCnt_++; @@ -78,9 +78,9 @@ { if (index.column() == 0) { auto* le = new QLineEdit(parent); - //timeEdit->setDisplayFormat("mm:ss"); + // timeEdit->setDisplayFormat("mm:ss"); - //connect(le,SIGNAL(editingFinished()), + // connect(le,SIGNAL(editingFinished()), // this,SLOT(commitAndCloseEditor())); QFont font; QFontMetrics fm(font); @@ -168,20 +168,19 @@ QStyleOptionViewItem vopt(option); initStyleOption(&vopt, index); - const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); + const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); const QWidget* widget = vopt.widget; - QString txt = index.data(Qt::DisplayRole).toString(); auto pixmap = index.data(Qt::DecorationRole).value(); - //Save painter state + // Save painter state painter->save(); - QString text = index.data(Qt::DisplayRole).toString(); + QString text = index.data(Qt::DisplayRole).toString(); QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &vopt, widget); - //Background + // Background if (blink) { QRect fillRect = option.rect.adjusted(0, 1, -1, -1); @@ -194,7 +193,7 @@ painter->drawRect(fillRect); } else if (option.state & QStyle::State_Selected) { - //QRect fillRect=option.rect.adjusted(0,1,-1,-textRect.height()-1); + // QRect fillRect=option.rect.adjusted(0,1,-1,-textRect.height()-1); QRect fillRect = option.rect.adjusted(0, 1, -1, -1); painter->fillRect(fillRect, selectBrush_); painter->setPen(selectPen_); @@ -207,11 +206,11 @@ painter->drawRect(fillRect); } - //Pixmap + // Pixmap QRect iconRect = style->subElementRect(QStyle::SE_ItemViewItemDecoration, &vopt, widget); painter->drawPixmap(iconRect, pixmap); - //Text rect + // Text rect auto font = index.data(Qt::FontRole).value(); painter->setFont(font); @@ -233,7 +232,7 @@ { QSize s = QStyledItemDelegate::sizeHint(option, index); - //qDebug() << "decoration" <style() : QApplication::style(); + const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); const QWidget* widget = vopt.widget; - //Save painter state + // Save painter state painter->save(); - //Get current values from model - QString text = index.data(Qt::DisplayRole).toString(); + // Get current values from model + QString text = index.data(Qt::DisplayRole).toString(); QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &vopt, widget); - //Background + // Background if (index.column() == 0) { QRect fillRect = QRect(option.rect.x(), option.rect.y(), painter->device()->width(), option.rect.height()); @@ -282,14 +281,14 @@ // painter->drawLine(fillRect.bottomLeft(), fillRect.bottomRight()); } else if (option.state & QStyle::State_Selected) { - //QRect fillRect=option.rect.adjusted(0,1,-1,-textRect.height()-1); + // QRect fillRect=option.rect.adjusted(0,1,-1,-textRect.height()-1); painter->fillRect(fillRect, selectBrush_); // painter->setPen(selectPen_); // painter->drawLine(fillRect.topLeft(), fillRect.topRight()); // painter->drawLine(fillRect.bottomLeft(), fillRect.bottomRight()); } else if (option.state & QStyle::State_MouseOver) { - //QRect fillRect=option.rect.adjusted(0,1,-1,-1); + // QRect fillRect=option.rect.adjusted(0,1,-1,-1); painter->fillRect(fillRect, hoverBrush_); // painter->setPen(hoverPen_); // painter->drawLine(fillRect.topLeft(), fillRect.topRight()); @@ -297,16 +296,16 @@ } } - //Pixmap + // Pixmap if (index.column() == 0) { - auto pixmap = index.data(Qt::DecorationRole).value(); + auto pixmap = index.data(Qt::DecorationRole).value(); QRect iconRect = style->subElementRect(QStyle::SE_ItemViewItemDecoration, &vopt, widget); - //iconRect.adjust(2,2,-2,-2); + // iconRect.adjust(2,2,-2,-2); painter->drawPixmap(iconRect, pixmap); } - //Text rect + // Text rect auto font = index.data(Qt::FontRole).value(); painter->setFont(font); if (blink) @@ -316,7 +315,7 @@ painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, text); - //restore painter state + // restore painter state painter->restore(); } else { diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderViewDelegate.h metview-5.19.2/metview/src/Desktop/MvQFolderViewDelegate.h --- metview-5.17.4/metview/src/Desktop/MvQFolderViewDelegate.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderViewDelegate.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,12 +22,12 @@ Q_OBJECT public: - MvQFolderViewDelegate(QWidget* parent = 0); + MvQFolderViewDelegate(QWidget* parent = nullptr); void blink(const QModelIndex&); - QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const; - void setEditorData(QWidget*, const QModelIndex&) const; - void setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&) const; + QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const override; + void setEditorData(QWidget*, const QModelIndex&) const override; + void setModelData(QWidget*, QAbstractItemModel*, const QModelIndex&) const override; void setEnablePaint(bool b) { enablePaint_ = b; } public slots: @@ -57,17 +57,17 @@ class MvQIconDelegate : public MvQFolderViewDelegate { public: - MvQIconDelegate(QWidget* parent = 0); + MvQIconDelegate(QWidget* parent = nullptr); void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; + const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; }; class MvQDetailedViewDelegate : public MvQFolderViewDelegate { public: - MvQDetailedViewDelegate(QWidget* parent = 0); + MvQDetailedViewDelegate(QWidget* parent = nullptr); void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; + const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderViewHandler.cc metview-5.19.2/metview/src/Desktop/MvQFolderViewHandler.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderViewHandler.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderViewHandler.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,7 +26,7 @@ void MvQFolderViewHandler::add(Desktop::FolderViewMode mode, MvQFolderViewBase* b) { - //Check if the same widget/base has been already set for another mode + // Check if the same widget/base has been already set for another mode Desktop::FolderViewMode parentMode = mode; for (auto& base : bases_) if (base.second == b) { @@ -34,8 +34,8 @@ break; } - bases_[mode] = b; - QWidget* w = b->concreteWidget(); + bases_[mode] = b; + QWidget* w = b->concreteWidget(); widgets_[mode] = w; int cnt = stacked_->count(); @@ -43,7 +43,7 @@ stacked_->addWidget(w); indexes_[mode] = cnt; } - //If the widget is already in the stack we just register its layout index + // If the widget is already in the stack we just register its layout index else { indexes_[mode] = indexes_[parentMode]; } @@ -65,63 +65,63 @@ { bool retVal = false; - //Check if currentMode is valid + // Check if currentMode is valid if (bases_.find(currentMode_) == bases_.end()) { - //If the currentMode is invalid we set it to icon view + // If the currentMode is invalid we set it to icon view currentMode_ = Desktop::IconViewMode; - //Check if there is icon view + // Check if there is icon view if (bases_.find(currentMode_) == bases_.end()) { - //If there area any views defined we set current to the first + // If there area any views defined we set current to the first if (bases_.size() > 0) currentMode_ = bases_.begin()->first; - //Otherwise something really bad happened! + // Otherwise something really bad happened! else return false; } } - //Note: when a view is diabled we completely detach it from the model, clear its content and block all - //its signals. So when the view becomes enabled again we need to do exactly the opposite. Out of this + // Note: when a view is diabled we completely detach it from the model, clear its content and block all + // its signals. So when the view becomes enabled again we need to do exactly the opposite. Out of this - //We change the mode + // We change the mode if (mode != currentMode_ && bases_.find(mode) != bases_.end()) { QWidget* wNew = widget(mode); - //Set the mode + // Set the mode currentMode_ = mode; - //Set the folder view rendering properties. We need to do it before enabeling the view. + // Set the folder view rendering properties. We need to do it before enabeling the view. itemProp_->setViewMode(currentMode_); - //Update the view + // Update the view if (wNew) { - //This will NOT call reset in the view!!! + // This will NOT call reset in the view!!! wNew->setEnabled(true); } } - //Disable the other views + // Disable the other views QWidget* currentWidget = widget(currentMode_); for (auto& widget : widgets_) if (widget.first != currentMode_ && widget.second && widget.second != currentWidget) widget.second->setEnabled(false); - //Update the folder in the current view + // Update the folder in the current view if (MvQFolderViewBase* b = base(currentMode_)) { - //If changing the folder is successfull it calls reset and returns true + // If changing the folder is successfull it calls reset and returns true retVal = b->changeFolder(folder, iconSize); - //We need to reset if the - //folder change was not successful (we stayed in the same folder) + // We need to reset if the + // folder change was not successful (we stayed in the same folder) if (!retVal) { b->doReset(); } } - //Set the layout + // Set the layout stacked_->setCurrentIndex(indexes_[currentMode_]); return retVal; diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderWatcher.cc metview-5.19.2/metview/src/Desktop/MvQFolderWatcher.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderWatcher.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderWatcher.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,6 @@ connect(fsWatcher_, SIGNAL(directoryChanged(QString)), this, SLOT(slotFolderChanged(QString))); - Q_ASSERT(presenter_->realObject()); connect(presenter_->realObject(), SIGNAL(pathChanged()), this, SLOT(slotFolderPathChanged())); @@ -71,19 +70,19 @@ } } - //we delay the rescan. With an immediate rescan a new file being written (and thus empty or - //not yet complete ) can be interpreted as NOTE by Desktop! + // we delay the rescan. With an immediate rescan a new file being written (and thus empty or + // not yet complete ) can be interpreted as NOTE by Desktop! timer_->singleShot(timeout_, this, SLOT(slotTimeout())); - //reload(); + // reload(); } void MvQFolderWatcher::slotFolderPathChanged() { - //clear the fswatcher + // clear the fswatcher fsWatcher_->removePaths(fsWatcher_->directories()); if (Folder* f = folder()) { fsWatcher_->addPath(QString::fromStdString(f->path().str())); - //f->scan(); + // f->scan(); } } @@ -97,7 +96,7 @@ if (Folder* f = folder()) { f->scan(); } - //print(); + // print(); } MvQFolderWatcher* MvQFolderWatcher::add(FolderPresenter* fp) @@ -126,7 +125,7 @@ if (item) { item->reload(); } - //safety measure + // safety measure else { item = MvQFolderWatcher::add(fp); item->reload(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderWatcher.h metview-5.19.2/metview/src/Desktop/MvQFolderWatcher.h --- metview-5.17.4/metview/src/Desktop/MvQFolderWatcher.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderWatcher.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ #include #include -#include +#include class Folder; class FolderPresenter; @@ -52,7 +52,7 @@ protected: MvQFolderWatcher(FolderPresenter*); - ~MvQFolderWatcher() {} + ~MvQFolderWatcher() override = default; void reload(); static void cleanLog(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderWidget.cc metview-5.19.2/metview/src/Desktop/MvQFolderWidget.cc --- metview-5.17.4/metview/src/Desktop/MvQFolderWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,13 +38,13 @@ folderHistory_(folderHistory), expectedFolderPath_(expectedFolderPath) { - //Read folder settings - int iconSize = FolderSettings::defaultIconSize(); + // Read folder settings + int iconSize = FolderSettings::defaultIconSize(); Desktop::FolderViewMode viewMode = FolderSettings::defaultViewMode(); if (Folder* f = Folder::folder(expectedFolderPath.toStdString(), false)) { FolderSettings* fi = f->settings(); - viewMode = fi->viewMode(); - iconSize = fi->iconSize(); + viewMode = fi->viewMode(); + iconSize = fi->iconSize(); } //-------------------------------------------- @@ -69,21 +69,21 @@ // Central part //------------------------------ - //View mode stacked widget + // View mode stacked widget centralLayout_ = new QStackedLayout; mainLayout->addLayout(centralLayout_, 1); - //View handler + // View handler views_ = new MvQFolderViewHandler(centralLayout_, folderModel_->itemProp()); - //Icon view + // Icon view auto* iconView = new MvQIconFolderView(folderModel_, iconActions, desktopActions, this); views_->add(Desktop::IconViewMode, iconView); - //Simple view - the same object as icon view!! + // Simple view - the same object as icon view!! views_->add(Desktop::SimpleViewMode, iconView); - //Detailed view + // Detailed view auto* detailedView = new MvQDetailedFolderView(folderModel_, iconActions, desktopActions, this); views_->add(Desktop::DetailedViewMode, detailedView); @@ -101,19 +101,19 @@ this, SIGNAL(itemInfoChanged(IconObject*))); } - //Init view mode + // Init view mode views_->setCurrentMode(viewMode); - //At this point the folder is not set on the model!!! - //So non of the views store any icons!!! + // At this point the folder is not set on the model!!! + // So non of the views store any icons!!! - //Set the folder + // Set the folder folderModel_->setFolder(expectedFolderPath_); folderNavigation_ = new MvQFolderNavigation; if (folderModel_->folder()) { folderNavigation_->add(expectedFolderPath_); - //Add root to history + // Add root to history folderHistory_->add(expectedFolderPath_); } } @@ -135,23 +135,23 @@ return folderModel_->folder(); } -//This is used for the tab title +// This is used for the tab title QString MvQFolderWidget::currentFolderName() { - //If there is a folder. + // If there is a folder. if (folderModel_->folder()) return QString::fromStdString(folderModel_->folder()->name()); - //The folder does not exits. This can be the case during init when the - //stored path exists on the local disk and we start metview from another - //machine where this path is not accessible. In this case we return the expected - //path. + // The folder does not exits. This can be the case during init when the + // stored path exists on the local disk and we start metview from another + // machine where this path is not accessible. In this case we return the expected + // path. else { return QDir(expectedFolderPath_).dirName(); } - return QString(); + return {}; } QString MvQFolderWidget::currentFolderPath() @@ -159,10 +159,10 @@ if (folderModel_->folder()) return QString::fromStdString(folderModel_->folder()->fullName()); - //The folder does not exits. This can be the case during init when the - //stored path exists on the local disk and we start metview from another - //machine where this path is not accessible. In this case we return the expected - //path. + // The folder does not exits. This can be the case during init when the + // stored path exists on the local disk and we start metview from another + // machine where this path is not accessible. In this case we return the expected + // path. else { return expectedFolderPath_; } @@ -173,10 +173,10 @@ if (Folder* folder = folderModel_->folder()) return QString::fromStdString(folder->path().str()); - //The folder does not exits. This can be the case during init when the - //stored path exists on the local disk and we start metview from another - //machine where this path is not accessible. In this case we return the expected - //path. + // The folder does not exits. This can be the case during init when the + // stored path exists on the local disk and we start metview from another + // machine where this path is not accessible. In this case we return the expected + // path. else { return expectedFolderPath_; } @@ -218,7 +218,7 @@ void MvQFolderWidget::chFolderParent() { Folder* folderCurrent = folderModel_->folder(); - Folder* folder = folderCurrent->parent(); + Folder* folder = folderCurrent->parent(); if (folder && views_->changeFolder(folder)) { expectedFolderPath_.clear(); folder = folderModel_->folder(); @@ -311,7 +311,7 @@ } } -//When the folder object itself is changed (e.g. renamed). It is a callback from the model! +// When the folder object itself is changed (e.g. renamed). It is a callback from the model! void MvQFolderWidget::slotFolderChanged(Folder* folder) { expectedFolderPath_.clear(); @@ -364,14 +364,14 @@ { QWidget::showEvent(event); MvQFolderWatcher::add(this); - //qDebug() << "show -->" << currentFolderName(); + // qDebug() << "show -->" << currentFolderName(); } void MvQFolderWidget::hideEvent(QHideEvent* event) { QWidget::hideEvent(event); MvQFolderWatcher::remove(this); - //qDebug() << "hide -->" << currentFolderName(); + // qDebug() << "hide -->" << currentFolderName(); } //------------------------ @@ -444,13 +444,13 @@ void MvQFolderWidget::readSettings(QSettings& settings) { - //Settings must store the same values as FolderSettings!! - //However, we need the code below because for read-only folders we cannot store the folder settings - //in a hidden file in the folder!! So we must read the the settings and overwrite the foldersettings with it if - //they are different. + // Settings must store the same values as FolderSettings!! + // However, we need the code below because for read-only folders we cannot store the folder settings + // in a hidden file in the folder!! So we must read the the settings and overwrite the foldersettings with it if + // they are different. if (settings.contains("viewMode") && settings.contains("iconSize")) { Desktop::FolderViewMode viewMode = FolderSettings::toViewMode(settings.value("viewMode").toInt()); - int iconSize = settings.value("iconSize").toInt(); + int iconSize = settings.value("iconSize").toInt(); if (Folder* f = folderModel_->folder()) { FolderSettings* fi = f->settings(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQFolderWidget.h metview-5.19.2/metview/src/Desktop/MvQFolderWidget.h --- metview-5.17.4/metview/src/Desktop/MvQFolderWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQFolderWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -37,13 +37,13 @@ Q_OBJECT public: - MvQFolderWidget(QString, MvQFolderHistory*, MvQActionList*, MvQActionList*, QWidget* parent = 0); - ~MvQFolderWidget(); + MvQFolderWidget(QString, MvQFolderHistory*, MvQActionList*, MvQActionList*, QWidget* parent = nullptr); + ~MvQFolderWidget() override; - //From FolderPresenter - Folder* currentFolder(); - bool isDisplayed() { return isVisible(); } - QObject* realObject(); + // From FolderPresenter + Folder* currentFolder() override; + bool isDisplayed() override { return isVisible(); } + QObject* realObject() override; QString currentFolderName(); QString currentFolderPath(); @@ -86,8 +86,8 @@ void pathChanged(); protected: - void showEvent(QShowEvent* event); - void hideEvent(QHideEvent* event); + void showEvent(QShowEvent* event) override; + void hideEvent(QHideEvent* event) override; private: QModelIndex changeFolder(const QModelIndex&); @@ -98,7 +98,7 @@ MvQFolderNavigation* folderNavigation_; MvQFolderModel* folderModel_; - //stores the initial path, even if the folder itself - //does not exists + // stores the initial path, even if the folder itself + // does not exists QString expectedFolderPath_; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQGeoHelp.cc metview-5.19.2/metview/src/Desktop/MvQGeoHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQGeoHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQGeoHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,12 +28,12 @@ // The parameter is in lower case because it // will be used to build the icon filename - Cached input = info("input_type"); + Cached input = info("input_type"); request("INPUT_TYPE") = input.toUpper(); request("INPUT_PARAM") = param_.name(); - request("CUSTOM_WIDTH") = 14.8; + request("CUSTOM_WIDTH") = 14.8; request("CUSTOM_HEIGHT") = 10.5; @@ -64,7 +64,7 @@ { progress.print(); request_ = progress; - //owner_.changed(*this); + // owner_.changed(*this); } void MvQGeoHelp::message(const std::string& msg) @@ -84,15 +84,15 @@ int cnt = msg.countValues(param_.name()); std::vector res; for (int i = 0; i < cnt; ++i) { - const char* ch; + const char* ch = nullptr; msg.getValue(ch, param_.name(), i); - res.push_back(std::string(ch)); + res.emplace_back(ch); } owner_.set(param_.name(), res); stop(); // stop observing the helper widget since it could be reused for other params - //owner_.changed(*this); + // owner_.changed(*this); } QIcon MvQGeoHelp::dialogIcon() @@ -109,7 +109,7 @@ t = "map"; return QIcon(QPixmap(":/desktop/help_" + t + ".svg")); } - return QIcon(); + return {}; } diff -Nru metview-5.17.4/metview/src/Desktop/MvQGeoHelp.h metview-5.19.2/metview/src/Desktop/MvQGeoHelp.h --- metview-5.17.4/metview/src/Desktop/MvQGeoHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQGeoHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,23 +25,23 @@ { public: MvQGeoHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQGeoHelp() = default; + ~MvQGeoHelp() override = default; - void start(); - bool dialog() { return true; } - QIcon dialogIcon(); - bool useLargeDialogIcon() { return true; } - QWidget* widget() { return 0; } + void start() override; + bool dialog() override { return true; } + QIcon dialogIcon() override; + bool useLargeDialogIcon() override { return true; } + QWidget* widget() override { return nullptr; } protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; virtual long flags() { return 9; } virtual void set(Request&); - void reply(const Request&, int); - void progress(const Request&); - void message(const std::string&); - void message(const Request&); + void reply(const Request&, int) override; + void progress(const Request&) override; + void message(const std::string&) override; + void message(const Request&) override; Request request_; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQ.h metview-5.19.2/metview/src/Desktop/MvQ.h --- metview-5.17.4/metview/src/Desktop/MvQ.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQ.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,9 @@ namespace MvQ { -//enum FolderViewMode {NoViewMode,IconViewMode,SimpleViewMode,DetailedViewMode}; -//enum GridSortMode {GridSortByName,GridSortBySize,GridSortByType}; -//enum DragPolicy {DragShowAllIcons,DragShowDraggedIcon}; +// enum FolderViewMode {NoViewMode,IconViewMode,SimpleViewMode,DetailedViewMode}; +// enum GridSortMode {GridSortByName,GridSortBySize,GridSortByType}; +// enum DragPolicy {DragShowAllIcons,DragShowDraggedIcon}; void emptyWasteBasket(); } // namespace MvQ diff -Nru metview-5.17.4/metview/src/Desktop/MvQHelpBrowser.cc metview-5.19.2/metview/src/Desktop/MvQHelpBrowser.cc --- metview-5.17.4/metview/src/Desktop/MvQHelpBrowser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQHelpBrowser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -44,40 +44,40 @@ MvQHelpBrowser::MvQHelpBrowser(QWidget* parent) : MvQMainWindow(parent) { - //setAttribute(Qt::WA_DeleteOnClose); + // setAttribute(Qt::WA_DeleteOnClose); setWindowTitle("Metview - Help"); - //Initial size + // Initial size setInitialSize(1100, 800); //-------------------------------------- - //Set the help engine + // Set the help engine //-------------------------------------- - //QFileInfo fileInfo("/tmp/dummy-user/metview_qt_documentation/metview_confluence/metview_collection.qhc"); + // QFileInfo fileInfo("/tmp/dummy-user/metview_qt_documentation/metview_confluence/metview_collection.qhc"); const QString share_dir = QString(getenv("METVIEW_DIR_SHARE")); QFileInfo fileInfo(share_dir + QString("/etc/metview_collection.qhc")); QHelpEngine* engine_ = new QHelpEngine(fileInfo.absoluteFilePath(), this); engine_->setupData(); //-------------------------------------- - //Main Layout - splitter + // Main Layout - splitter //-------------------------------------- - QWidget* w = new QWidget(this); + QWidget* w = new QWidget(this); QVBoxLayout* mainLayout = new QVBoxLayout(w); mainLayout->setSpacing(0); mainLayout->setContentsMargins(1, 1, 1, 1); setCentralWidget(w); - //Splitter + // Splitter splitter_ = new QSplitter(this); mainLayout->addWidget(splitter_); //-------------------------------------- - //Left - tab Content + // Left - tab Content //-------------------------------------- @@ -87,15 +87,15 @@ tab->addTab(engine_->contentWidget(), tr("Content")); //-------------------------------------- - //Left - tab Index + // Left - tab Index //-------------------------------------- lookFor_label_ = new QLabel(tr("Look for:"), this); - lookFor_edit_ = new QLineEdit(this); + lookFor_edit_ = new QLineEdit(this); lookFor_label_->setBuddy(lookFor_edit_); connect(lookFor_edit_, SIGNAL(textChanged(const QString&)), engine_->indexWidget(), SLOT(filterIndices(const QString&))); - QWidget* itab_w = new QWidget(this); + QWidget* itab_w = new QWidget(this); QVBoxLayout* ilayout = new QVBoxLayout(itab_w); ilayout->addWidget(lookFor_label_); ilayout->addWidget(lookFor_edit_); @@ -104,23 +104,23 @@ tab->addTab(itab_w, tr("Index")); //-------------------------------------- - //Right - content view widget + // Right - content view widget //-------------------------------------- - //set web view text encoding + // set web view text encoding webView_ = new QWebView(this); webView_->settings()->setDefaultTextEncoding("utf-8"); - //set the documentation css style - //QUrl myCssFileURL= QUrl("file:///tmp/dummy-user/metview_qt_documentation/metview_confluence/METV/styles/site.css"); + // set the documentation css style + // QUrl myCssFileURL= QUrl("file:///tmp/dummy-user/metview_qt_documentation/metview_confluence/METV/styles/site.css"); - //ini juanjo 03.09.2013 - //QUrl myCssFileURL= QUrl(QString("file://")+share_dir+QString("/etc/help.css")); - //webView_->settings()->setUserStyleSheetUrl(myCssFileURL); - //end juanjo 03.09.2013 + // ini juanjo 03.09.2013 + // QUrl myCssFileURL= QUrl(QString("file://")+share_dir+QString("/etc/help.css")); + // webView_->settings()->setUserStyleSheetUrl(myCssFileURL); + // end juanjo 03.09.2013 - //use a request manager able to handle "qthelp" requests + // use a request manager able to handle "qthelp" requests QNetworkAccessManager* current_manager = webView_->page()->networkAccessManager(); MvHelpNetworkAccessManager* newManager = new MvHelpNetworkAccessManager(engine_, current_manager, this); webView_->page()->setNetworkAccessManager(newManager); @@ -134,10 +134,10 @@ connect(webView_, SIGNAL(linkClicked(const QUrl&)), this, SLOT(setWebSource(const QUrl&))); //-------------------------------------- - //Right - content view layout + // Right - content view layout //-------------------------------------- - QWidget* rw = new QWidget(this); + QWidget* rw = new QWidget(this); QVBoxLayout* rLayout = new QVBoxLayout(rw); rLayout->setSpacing(0); rLayout->addWidget(webView_); @@ -147,7 +147,7 @@ // Right - Find widget //-------------------------- - search_ = new MvQWebViewSearchLine(webView_, tr("&Find:")); + search_ = new MvQWebViewSearchLine(webView_, tr("&Find:")); searchPanel_ = new MvQSearchLinePanel(); searchPanel_->addSearchLine(search_, webView_); searchPanel_->setHidden(true); @@ -184,22 +184,22 @@ void MvQHelpBrowser::closeEvent(QCloseEvent* event) { - //emit aboutToClose(this); + // emit aboutToClose(this); close(); event->accept(); } void MvQHelpBrowser::setupSearchActions() { - //Find + // Find QAction* actionFind_ = MvQMainWindow::createAction(MvQMainWindow::FindAction, this); connect(actionFind_, SIGNAL(triggered(bool)), searchPanel_, SLOT(setHidden(bool))); - //Find Next + // Find Next QAction* actionFindNext_ = MvQMainWindow::createAction(MvQMainWindow::FindNextAction, this); connect(actionFindNext_, SIGNAL(triggered(bool)), searchPanel_, SLOT(slotFindNext(bool))); - //Find Previous + // Find Previous QAction* actionFindPrev_ = MvQMainWindow::createAction(MvQMainWindow::FindPreviousAction, this); connect(actionFindPrev_, SIGNAL(triggered(bool)), searchPanel_, SLOT(slotFindPrev(bool))); @@ -212,7 +212,7 @@ void MvQHelpBrowser::setupNavigateActions() { - //Back + // Back actionBack_ = new QAction(this); actionBack_->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowLeft)); actionBack_->setToolTip(tr("Back")); @@ -221,7 +221,7 @@ connect(actionBack_, SIGNAL(triggered()), webView_, SLOT(back())); - //Forward + // Forward actionForward_ = new QAction(this); actionForward_->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowRight)); actionForward_->setToolTip(tr("Forward")); @@ -230,7 +230,7 @@ connect(actionForward_, SIGNAL(triggered()), webView_, SLOT(forward())); - //Home + // Home actionHome_ = new QAction(this); actionHome_->setIcon(QPixmap(QString::fromUtf8(":/desktop/home.svg"))); actionHome_->setToolTip(tr("Metview Documentation home")); @@ -275,12 +275,12 @@ void MvQHelpBrowser::setWebSource(const QUrl& url) { - //qDebug() << "setWebSource url=" << url.toString(); + // qDebug() << "setWebSource url=" << url.toString(); if (url.scheme() == "qthelp") webView_->load(url); else QDesktopServices::openUrl(url); - //for(int i=0; i < webView_->history()->count(); i++) qDebug() << "item" << i << webView_->history()->itemAt(i).url(); + // for(int i=0; i < webView_->history()->count(); i++) qDebug() << "item" << i << webView_->history()->itemAt(i).url(); } void MvQHelpBrowser::writeSettings() diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconFolderView.cc metview-5.19.2/metview/src/Desktop/MvQIconFolderView.cc --- metview-5.17.4/metview/src/Desktop/MvQIconFolderView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconFolderView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -71,7 +71,7 @@ if (item_) item->setBlinkState(MvQIconItem::NoBlink); item_ = item; - cnt_ = 0; + cnt_ = 0; } void MvQIconItemTimer::blink() @@ -86,7 +86,7 @@ { if (item_ && cnt_ < maxCnt_) { item_->setBlinkState((cnt_ % 2 == 0) ? MvQIconItem::BlinkOn : MvQIconItem::BlinkOff); - //item_->update(); + // item_->update(); cnt_++; } else { @@ -94,7 +94,7 @@ cnt_ = 0; if (item_) item_->setBlinkState(MvQIconItem::NoBlink); - item_ = 0; + item_ = nullptr; } } @@ -109,7 +109,7 @@ item_(item) { QString text = item->text(); - QFont f = item->font(); + QFont f = item->font(); QFontMetrics fm(f); editor_ = new QLineEdit(text); @@ -117,8 +117,8 @@ editor_->setMinimumWidth(MvQ::textWidth(fm, text) + 16); editor_->setMaximumWidth(MvQ::textWidth(fm, text) + MvQ::textWidth(fm, "AAAAAAA")); editor_->selectAll(); - //editor_->setCursorPosition(0); - //editor_->deselect(); + // editor_->setCursorPosition(0); + // editor_->deselect(); setWidget(editor_); } @@ -135,7 +135,7 @@ void MvQEditorProxy::keyPressEvent(QKeyEvent* e) { - //qDebug() << "ketPressEvent" << e->key() << Qt::Key_Return << Qt::Key_Enter; + // qDebug() << "ketPressEvent" << e->key() << Qt::Key_Return << Qt::Key_Enter; QGraphicsProxyWidget::keyPressEvent(e); if ((e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && editor_->selectedText() != editor_->text()) { @@ -159,15 +159,15 @@ dropTarget_(false), blinkState_(NoBlink) { - //Setup colours - static memebers + // Setup colours - static memebers if (editPen_.color() == Qt::yellow) { QString group = "folderview"; - editPen_ = QPen(MvQTheme::colour(group, "edit_pen")); - editBrush_ = MvQTheme::brush(group, "edit_brush"); - hoverPen_ = QPen(MvQTheme::colour(group, "hover_pen")); - hoverBrush_ = MvQTheme::brush(group, "hover_brush"); - selectPen_ = QPen(MvQTheme::colour(group, "select_pen")); - selectBrush_ = MvQTheme::brush(group, "select_brush"); + editPen_ = QPen(MvQTheme::colour(group, "edit_pen")); + editBrush_ = MvQTheme::brush(group, "edit_brush"); + hoverPen_ = QPen(MvQTheme::colour(group, "hover_pen")); + hoverBrush_ = MvQTheme::brush(group, "hover_brush"); + selectPen_ = QPen(MvQTheme::colour(group, "select_pen")); + selectBrush_ = MvQTheme::brush(group, "select_brush"); } setAcceptHoverEvents(true); @@ -188,18 +188,18 @@ { auto pixmap = index_.data(Qt::DecorationRole).value(); - //Save painter state + // Save painter state painter->save(); QString text = index_.data(Qt::DisplayRole).toString(); - //Background + // Background QRectF fillRect = bRect_; if (blinkState_ == BlinkOn) { painter->fillRect(fillRect, Qt::black); } - //If the icon editor is open we render a transparent rect above the item + // If the icon editor is open we render a transparent rect above the item else if (index_.data(MvQFolderModel::EditorRole).toBool()) { painter->setPen(editPen_); painter->setBrush(editBrush_); @@ -223,10 +223,10 @@ painter->setBrush(QBrush()); - //Render icon + // Render icon painter->drawPixmap(iconRect_.toRect(), pixmap); - //Tender text + // Tender text auto font = index_.data(Qt::FontRole).value(); painter->setFont(font); @@ -244,8 +244,8 @@ { prepareGeometryChange(); - QString name = index_.data(Qt::DisplayRole).toString(); - bRect_ = QRectF(QPointF(0, 0), itemProp_->size(name)); + QString name = index_.data(Qt::DisplayRole).toString(); + bRect_ = QRectF(QPointF(0, 0), itemProp_->size(name)); QPoint refPos = index_.data(MvQFolderModel::PositionRole).toPoint(); setPos(itemProp_->position(name, refPos)); @@ -324,13 +324,13 @@ enterFolders_(true), mousePos_(0, 0), canDrag_(false), - editor_(0), - timer_(0), - defaultShortCut_(0), + editor_(nullptr), + timer_(nullptr), + defaultShortCut_(nullptr), appIconActions_(iconActions), appDesktopActions_(desktopActions) { - //setBackgroundBrush(QColor(125,124,123)); + // setBackgroundBrush(QColor(125,124,123)); setAlignment(Qt::AlignLeft | Qt::AlignTop); setDragMode(QGraphicsView::RubberBandDrag); @@ -338,32 +338,32 @@ auto* scene_ = new QGraphicsScene(this); setScene(scene_); - //qDebug() << maximumViewportSize() << items().count(); - //qDebug() << "scenerect" << sceneRect(); + // qDebug() << maximumViewportSize() << items().count(); + // qDebug() << "scenerect" << sceneRect(); setContextMenuPolicy(Qt::CustomContextMenu); - //Context menu + // Context menu connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotContextMenu(const QPoint&))); - //Set the style + // Set the style setProperty("mvStyle", "IconFolderView"); - //We set up the shortcuts here!! + // We set up the shortcuts here!! setupShortCut(); - //We attach the model because by default the view is enabled. At this point the model is empty so - //it is a cheap operation!! + // We attach the model because by default the view is enabled. At this point the model is empty so + // it is a cheap operation!! attachModel(); } MvQIconFolderView::~MvQIconFolderView() = default; -//Connect the models signal to the view +// Connect the models signal to the view void MvQIconFolderView::attachModel() { - //Standard signals from the model + // Standard signals from the model connect(filterModel_, SIGNAL(modelReset()), this, SLOT(reset())); @@ -371,22 +371,22 @@ connect(filterModel_, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(slotDataChanged(const QModelIndex&, const QModelIndex&))); - //Custom signals from the model + // Custom signals from the model connect(folderModel_, SIGNAL(iconSizeChanged()), this, SLOT(slotIconSizeChanged())); connect(folderModel_, SIGNAL(objectRenamed(const QModelIndex&, QString)), this, SLOT(slotObjectRenamed(const QModelIndex&, QString))); - //We need to call it to be sure that the view show the actual state of the model!!! - //doReset(); + // We need to call it to be sure that the view show the actual state of the model!!! + // doReset(); } -//Disconnect the model from the view +// Disconnect the model from the view void MvQIconFolderView::detachModel() { - disconnect(filterModel_, 0, this, 0); - disconnect(folderModel_, 0, this, 0); + disconnect(filterModel_, nullptr, this, nullptr); + disconnect(folderModel_, nullptr, this, nullptr); } void MvQIconFolderView::doReset() @@ -405,7 +405,7 @@ bool MvQIconFolderView::event(QEvent* event) { - //qDebug() << "TYPE" << event->type(); + // qDebug() << "TYPE" << event->type(); return QGraphicsView::event(event); } @@ -414,10 +414,10 @@ if (event->type() == QEvent::EnabledChange) { if (isEnabled()) { attachModel(); - //Reset will be called by the handler!!!! + // Reset will be called by the handler!!!! blockSignals(false); } - //When the view is diabled we do not want to receive any signals from the model + // When the view is diabled we do not want to receive any signals from the model else { detachModel(); clearContents(); @@ -434,20 +434,21 @@ { QGraphicsItem* item = scene()->itemAt(scenePos, QTransform()); if (item) { - auto* icItem = static_cast(item); - return icItem->index(); + if (auto* icItem = dynamic_cast(item)) { + return icItem->index(); + } } - return QModelIndex(); + return {}; } IconObject* MvQIconFolderView::iconObjectAt(QPointF scenePos) { QGraphicsItem* item = scene()->itemAt(scenePos, QTransform()); if (item) { - auto* icItem = static_cast(item); + auto* icItem = dynamic_cast(item); return folderModel_->objectFromIndex(icItem->index()); } - return 0; + return nullptr; } MvQIconItem* MvQIconFolderView::objectToItem(IconObject* obj) @@ -471,7 +472,7 @@ static QPersistentModelIndex emptyPersIndex(emptyIndex); if (item) { - auto* icItem = static_cast(item); + auto* icItem = dynamic_cast(item); return icItem->index(); } return emptyPersIndex; @@ -480,10 +481,10 @@ IconObject* MvQIconFolderView::itemToObject(QGraphicsItem* item) { if (item) { - auto* icItem = static_cast(item); + auto* icItem = dynamic_cast(item); return folderModel_->objectFromIndex(icItem->index()); } - return 0; + return nullptr; } QRect MvQIconFolderView::pixmapRect(QList objLst) @@ -504,7 +505,7 @@ return item->mapToScene(item->pixmapRect()).boundingRect().toRect(); } - return QRect(); + return {}; } @@ -525,7 +526,7 @@ return item->mapToScene(item->boundingRect()).boundingRect().toRect(); } - return QRect(); + return {}; } QRectF MvQIconFolderView::itemRect(QGraphicsItem* item) @@ -534,7 +535,7 @@ return item->mapToScene(item->boundingRect()).boundingRect(); } - return QRectF(); + return {}; } QModelIndexList MvQIconFolderView::selectedIndexes() @@ -582,8 +583,8 @@ void MvQIconFolderView::slotContextMenu(const QPoint& position) { - //QGraphicsItem *item=itemAt(position); - //Relay the context menu event ot the editor! + // QGraphicsItem *item=itemAt(position); + // Relay the context menu event ot the editor! if (editor_) { QPointF scenePos = mapToScene(position); if (editor_->contains(editor_->mapFromScene(scenePos))) { @@ -594,7 +595,7 @@ } QModelIndexList lst = selectedIndexes(); - //qDebug() << "selected" << lst; + // qDebug() << "selected" << lst; auto index = indexAt(mapToScene(position)); @@ -602,25 +603,25 @@ handleContextMenu(index, lst, mapToGlobal(position), position + scrollOffset, this); /*QModelIndexList lst=selectedIndexes(); - QPoint scrollOffset(horizontalScrollBar()->value(),verticalScrollBar()->value()); - handleContextMenu(indexAt(position),lst,mapToGlobal(position),position+scrollOffset,this);*/ + QPoint scrollOffset(horizontalScrollBar()->value(),verticalScrollBar()->value()); + handleContextMenu(indexAt(position),lst,mapToGlobal(position),position+scrollOffset,this);*/ /*if(lst.count() == 1) - { - QModelIndex index=indexAt(position); - QPoint scrollOffset(horizontalScrollBar()->value(),verticalScrollBar()->value()); - - handleContextMenu(index,mapToGlobal(position),position+scrollOffset,this); - } - else if(lst.count() > 1) - { - handleContextMenu(lst,mapToGlobal(position),position+scrollOffset,this); - } */ + { + QModelIndex index=indexAt(position); + QPoint scrollOffset(horizontalScrollBar()->value(),verticalScrollBar()->value()); + + handleContextMenu(index,mapToGlobal(position),position+scrollOffset,this); + } + else if(lst.count() > 1) + { + handleContextMenu(lst,mapToGlobal(position),position+scrollOffset,this); + } */ } void MvQIconFolderView::mouseDoubleClickEvent(QMouseEvent* event) { - QModelIndexList lst = selectedIndexes(); + QModelIndexList lst = selectedIndexes(); const QModelIndex& index = indexAt(mapToScene(event->pos())); if (lst.count() == 1 && lst.at(0) == index) handleDoubleClick(index); @@ -666,15 +667,15 @@ itemProp_->iconSize() == 16) { for (int i = 0; i < filterModel_->rowCount(); i++) { QModelIndex idx = filterModel_->index(i, 0); - QString name = filterModel_->data(idx, Qt::DisplayRole).toString(); + QString name = filterModel_->data(idx, Qt::DisplayRole).toString(); - //Get the original pos taken from MetviewUI (padding addded!). It is valid for 16px icon size! + // Get the original pos taken from MetviewUI (padding addded!). It is valid for 16px icon size! QPoint refPos = filterModel_->data(idx, MvQFolderModel::PositionRole).toPoint(); QPoint storedPos = itemProp_->storedPosition(refPos); - //If the stored position is valid: - //We need to scale it up to the reference position and set it as the real position!! + // If the stored position is valid: + // We need to scale it up to the reference position and set it as the real position!! if (IconInfo::validPos(storedPos.x(), storedPos.y())) { filterModel_->setData(idx, itemProp_->referencePosition(name, refPos), MvQFolderModel::PositionRole); @@ -719,8 +720,8 @@ items_[idxP] = item; } - //Checks if there are icons with (0,0) positions and layout them - //nicely + // Checks if there are icons with (0,0) positions and layout them + // nicely checkPositions(); adjustSceneRect(); @@ -736,7 +737,7 @@ void MvQIconFolderView::slotObjectArrived(const QModelIndex&) { - //showLastCreated(); + // showLastCreated(); } //=============================================== @@ -785,7 +786,7 @@ h = s.height(); } - return QSize(w, h); + return {w, h}; } void MvQIconFolderView::computeGrid(Desktop::GridSortMode sortMode) @@ -795,13 +796,13 @@ QSize itemSize = maxItemSize(); - int dx = itemSize.width() + 2; + int dx = itemSize.width() + 2; int colNum = static_cast(round(static_cast(viewport()->size().width()) / static_cast(dx))); if (colNum == 0) colNum = 1; int dy = itemSize.height() + 3 * itemProp_->scaling(); - //qDebug() << "DELTA" << itemSize.height() << itemProp_->scaling() << dy; + // qDebug() << "DELTA" << itemSize.height() << itemProp_->scaling() << dy; int x = 5; int y = 5; @@ -839,7 +840,7 @@ QPoint pos; if (itemProp_->viewMode() == Desktop::IconViewMode) { int w = item->boundingRect().width(); - pos = QPoint(x + (dx - w) / 2, y); + pos = QPoint(x + (dx - w) / 2, y); } else { pos = QPoint(x, y); @@ -863,19 +864,19 @@ return; QList needPos; - MvQIconItem* bottomItem = 0; + MvQIconItem* bottomItem = nullptr; - int h = 0; + int h = 0; int maxWidth = itemProp_->iconSize(); - int maxX = 0; - int maxY = 0; + int maxX = 0; + int maxY = 0; QMap::const_iterator it = items_.constBegin(); while (it != items_.constEnd()) { - //Reference pos + // Reference pos QPoint refPos = it.key().data(MvQFolderModel::PositionRole).toPoint(); - //stored pos + // stored pos QPoint storedPos = itemProp_->storedPosition(refPos); if (IconInfo::validPos(storedPos.x(), storedPos.y())) { @@ -883,7 +884,7 @@ if (pos.x() > maxX) maxX = pos.x(); if (pos.y() > maxY) { - maxY = pos.y(); + maxY = pos.y(); bottomItem = it.value(); } } @@ -905,15 +906,15 @@ int dx = maxWidth + 2; - //Find out the available widthfor layouting + // Find out the available widthfor layouting int sceneWidth = sceneRect().size().width(); - //The actual viewport can be bigger than the scenerect width. + // The actual viewport can be bigger than the scenerect width. if (viewport()->size().width() > sceneWidth) sceneWidth = viewport()->size().width(); - //If the window is not yet visible the viewport and the scenerect do not have the correct size!!!! - //So we estimate the available size form the window size (it is "almost" correctly set although it is not visible) + // If the window is not yet visible the viewport and the scenerect do not have the correct size!!!! + // So we estimate the available size form the window size (it is "almost" correctly set although it is not visible) if (QWidget* win = window()) { if (!win->isVisible()) sceneWidth = win->size().width() - 20; @@ -921,32 +922,32 @@ int dy = h + 3 * itemProp_->scaling(); - //Find the staring pos of the new items + // Find the staring pos of the new items int x = 5; int y = maxY + ((maxY == 0) ? 10 : dy); - //int sceneWidth = sceneRect().size().width(); + // int sceneWidth = sceneRect().size().width(); if (sceneWidth < 20) { sceneWidth = maxX + maxWidth + 20; } - //Try to find a starting postion in the last "row" of the "old" items + // Try to find a starting postion in the last "row" of the "old" items if (bottomItem) { - //See if other items intersect the bottom item's row + // See if other items intersect the bottom item's row QRectF bottomRect = bottomItem->boundingRect(); bottomRect.moveTo(bottomItem->pos()); - //This is the rect at the right edge of the available area in the bottomItem's row. + // This is the rect at the right edge of the available area in the bottomItem's row. QRectF r(QPointF(sceneWidth - bottomRect.width(), bottomRect.y()), bottomRect.size()); int rectStep = 0; while (r.x() > 0 && r.width() > 0) { - //r.translate(-r.width(), 0); - //See if we have overlapping items with the rect!! + // r.translate(-r.width(), 0); + // See if we have overlapping items with the rect!! QList intersectVector = scene()->items(r, Qt::IntersectsItemShape, Qt::AscendingOrder); if (!intersectVector.isEmpty()) { - //If the first rect overlaps we need to start a new row - //otherwise ... + // If the first rect overlaps we need to start a new row + // otherwise ... if (rectStep > 0) { //.. we need to find the rightmost overlapping rect QRectF endRect = intersectVector.at(0)->boundingRect(); @@ -973,7 +974,7 @@ break; } - //We move the rect to the left + // We move the rect to the left r.translate(-r.width(), 0); rectStep++; @@ -1004,7 +1005,7 @@ filterModel_->setData(item->index(), itemProp_->referencePosition(name, pos), MvQFolderModel::PositionRole); item->adjust(); - //qDebug() << name << pos << w << sceneWidth; + // qDebug() << name << pos << w << sceneWidth; x += dx; } @@ -1023,17 +1024,17 @@ QPointF scenePos = mapToScene(event->pos()); if (editor_) { - //This is the standard behaviour on various systems: when we click - //outside the editor we finish editing and confirm the rename operation. However, - //the editor can have a context menu open so we need to check if we click inside - //the context menu. Unfortunately QWidget::childAt() and Qwidget::childrenRect() does not - //work properly to decide if the position is inside the context menu. So we have to check the - //children one by one. + // This is the standard behaviour on various systems: when we click + // outside the editor we finish editing and confirm the rename operation. However, + // the editor can have a context menu open so we need to check if we click inside + // the context menu. Unfortunately QWidget::childAt() and Qwidget::childrenRect() does not + // work properly to decide if the position is inside the context menu. So we have to check the + // children one by one. if (!editor_->contains(editor_->mapFromScene(scenePos))) { bool outside = true; foreach (QObject* chObj, editor_->editor()->children()) { if (chObj->isWidgetType()) { - if (auto* w = static_cast(chObj)) { + if (auto* w = dynamic_cast(chObj)) { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QPoint posInW = w->mapFromGlobal(event->globalPosition().toPoint()); #else @@ -1048,7 +1049,7 @@ } if (outside) { - //qDebug() << "click outside editor"; + // qDebug() << "click outside editor"; slotRename(); return; } @@ -1058,11 +1059,11 @@ return; } - //At this point the item cannot be the editor!!! + // At this point the item cannot be the editor!!! if (event->button() == Qt::LeftButton || event->button() == Qt::MiddleButton) { - MvQIconItem* item = static_cast(itemAt(event->pos())); + MvQIconItem* item = dynamic_cast(itemAt(event->pos())); if (item) { - //check if editor is needed + // check if editor is needed if (item->textContains(item->mapFromScene(scenePos))) { if (IconObject* obj = itemToObject(item)) { if (obj->renamable()) { @@ -1073,9 +1074,9 @@ return; } - //Set startpos in Viewport coordinates and enable drag + // Set startpos in Viewport coordinates and enable drag startPos_ = event->pos(); - canDrag_ = true; + canDrag_ = true; if (event->button() == Qt::MiddleButton) { selectOnlyOneItem(item); @@ -1122,23 +1123,23 @@ void MvQIconFolderView::performDrag(Qt::DropAction dropAction, QPoint scenePos) { - //The object that was dragged - //IconObject* dragObj=iconObjectAt(mapFromScene(scenePos)); + // The object that was dragged + // IconObject* dragObj=iconObjectAt(mapFromScene(scenePos)); IconObject* dragObj = iconObjectAt(scenePos); - //List of object to drag + // List of object to drag QList objLst; foreach (QGraphicsItem* gt, scene()->selectedItems()) objLst << itemToObject(gt); - //Need a solution!!!!!!!!!!!!!!!!!1 + // Need a solution!!!!!!!!!!!!!!!!!1 bool fromHelper = (!allowMoveAction_); QDrag* drag = buildDrag(dragObj, objLst, fromHelper, this, scenePos); if (drag) { - //We always initiate a copy or move action + // We always initiate a copy or move action drag->exec(Qt::CopyAction | Qt::MoveAction, dropAction); } else { @@ -1152,7 +1153,7 @@ void MvQIconFolderView::checkDropTarget(QDropEvent* event) { - IconObject* dragObj = 0; + IconObject* dragObj = nullptr; if (event->mimeData()->hasFormat("metview/icon")) { const auto* mimeData = qobject_cast(event->mimeData()); @@ -1166,7 +1167,7 @@ return; } - QPointF scenePos = mapToScene(MvQ::eventPos(event)); + QPointF scenePos = mapToScene(MvQ::eventPos(event)); Qt::DropAction dropAction = event->proposedAction(); IconObject* obj = iconObjectAt(scenePos); @@ -1190,9 +1191,9 @@ void MvQIconFolderView::dragEnterEvent(QDragEnterEvent* event) { - //qDebug() << event->mimeData()->formats(); - //qDebug() << event->mimeData()->text(); - //qDebug() << event->proposedAction(); + // qDebug() << event->mimeData()->formats(); + // qDebug() << event->mimeData()->text(); + // qDebug() << event->proposedAction(); if (event->source() && (event->proposedAction() == Qt::CopyAction || @@ -1252,7 +1253,7 @@ return; } - IconObject* dragObj = mimeData->dragObject(); + IconObject* dragObj = mimeData->dragObject(); MvQFolderModel* model = mimeData->model(); if (dragObj && (model || mimeData->fromEditor())) { @@ -1265,7 +1266,7 @@ fromSameView = (folderModel_->folder() == dragObj->parent()); } - //We cannot drop icons into a locked folder! + // We cannot drop icons into a locked folder! if (!fromSameView && folderModel_->folder()->locked()) { event->ignore(); return; @@ -1277,7 +1278,7 @@ } } else if (event->mimeData()->hasFormat("metview/new_icon")) { - //We cannot drop icons into a locked folder! + // We cannot drop icons into a locked folder! if (folderModel_->folder()->locked()) { event->ignore(); return; @@ -1317,28 +1318,32 @@ if (!dragObj) return; - //Find out the itemRect topleft point in scene (scaled) + // Find out the itemRect topleft point in scene (scaled) QPoint scenePos = itemProp_->positionFromHotSpot(QString::fromStdString(dragObj->name()), cursorScenePos, data->hotSpotInVisRect()); - //The object position - ignoring the scaling - QPoint refPos = itemProp_->referencePosition(QString::fromStdString(dragObj->name()), scenePos); + // The object position - ignoring the scaling + QPoint refPos = itemProp_->referencePosition(QString::fromStdString(dragObj->name()), scenePos); QPoint deltaPos = refPos - itemProp_->referencePosition(dragObj); bool toSameFolder = true; - Folder* folder = folderModel_->folder(); + Folder* folder = folderModel_->folder(); IconObject* objAt = iconObjectAt(cursorScenePos); - //See if we drop the icons onto a folder icon. We do not allow dropping a folder into itself!! - if (objAt && objAt->isFolder() && !data->objects().contains(objAt)) { - folder = static_cast(objAt); + // See if we drop the icons onto a folder icon. We do not allow dropping a folder into itself!! + if (objAt != nullptr && objAt->isFolder() && !data->objects().contains(objAt)) { + folder = dynamic_cast(objAt); toSameFolder = false; } + if (folder == nullptr) { + return; + } + bool doAdjustScene = false; - QRectF scRect = scene()->sceneRect(); - float rightEdge = scRect.left(); - float bottomEdge = scRect.bottom(); + QRectF scRect = scene()->sceneRect(); + float rightEdge = scRect.left(); + float bottomEdge = scRect.bottom(); QPoint bottomRight(1, 1); for (int i = 0; i < data->objects().count(); i++) { @@ -1347,14 +1352,14 @@ if (!obj || !isAccepted(obj)) continue; - //If the drop target is a folder icon in the current folder we set the coordinates to - //undef. This will instruct the view to find maningful new positions to the icons, + // If the drop target is a folder icon in the current folder we set the coordinates to + // undef. This will instruct the view to find maningful new positions to the icons, if (toSameFolder == false && folder) { - //Copy + // Copy if (dropAction == Qt::CopyAction) { obj->clone(folder, false); } - //Move + // Move else if (dropAction == Qt::MoveAction) { if (!obj->locked()) { obj->position(IconInfo::undefX(), IconInfo::undefY()); @@ -1362,25 +1367,25 @@ } } } - //Otherwise we compute the possible new positions according to the position of the drag object + // Otherwise we compute the possible new positions according to the position of the drag object else { QPoint newPos; QPoint newRefPos; if (obj == dragObj) { newRefPos = refPos; - newPos = scenePos; + newPos = scenePos; } else { QPoint dp = data->pixDistances().at(i); - newPos = itemProp_->positionFromHotSpot(QString::fromStdString(obj->name()), + newPos = itemProp_->positionFromHotSpot(QString::fromStdString(obj->name()), cursorScenePos + dp * getIconSize(), bottomRight); newRefPos = itemProp_->referencePosition(QString::fromStdString(obj->name()), newPos); - //Icons can be off screen vertically or horizontally so we need to - //adjust their positions + // Icons can be off screen vertically or horizontally so we need to + // adjust their positions if (newRefPos.y() < 0) newRefPos.setY(0); if (newRefPos.x() < 0) @@ -1394,26 +1399,26 @@ doAdjustScene = true; } - //Copy + // Copy if (dropAction == Qt::CopyAction) { obj->clone(folder, newRefPos.x(), newRefPos.y(), false); } - //Move + // Move else if (dropAction == Qt::MoveAction) { - //Drag from the same view/model + // Drag from the same view/model if (fromSameView) { - QString name = QString::fromStdString(obj->name()); + QString name = QString::fromStdString(obj->name()); QPoint oriPos = itemProp_->referencePosition(obj); QPoint newPos = oriPos + deltaPos; - //Icons can be off screen vertically or horizontally so we need to - //adjust their positions + // Icons can be off screen vertically or horizontally so we need to + // adjust their positions if (newPos.y() < 0) newPos.setY(0); if (newPos.x() < 0) newPos.setX(0); - //We need to store the storedPos in the object!!! + // We need to store the storedPos in the object!!! QPoint storedPos = itemProp_->storedPosition(newPos); obj->position(storedPos.x(), storedPos.y()); @@ -1422,10 +1427,10 @@ } } - //Drop from another view/model + // Drop from another view/model else { if (!obj->locked()) { - //We need to store the storedPos in the object!!! + // We need to store the storedPos in the object!!! QPoint storedPos = itemProp_->storedPosition(newRefPos); obj->position(storedPos.x(), storedPos.y()); folder->adopt(obj); @@ -1454,22 +1459,22 @@ void MvQIconFolderView::slotRename() { if (editor_) { - //qDebug() << "slotRename()"; + // qDebug() << "slotRename()"; folderModel_->setData(editor_->item()->index(), editor_->editor()->text(), Qt::EditRole); removeEditor(); } } -//Called from the source model when the item was renamed! +// Called from the source model when the item was renamed! void MvQIconFolderView::slotObjectRenamed(const QModelIndex& sourceIndex, QString oriName) { QModelIndex index = filterModel_->mapFromSource(sourceIndex); MvQIconItem* item = indexToItem(index); if (item) { if (itemProp_->viewMode() == Desktop::IconViewMode) { - QString name = filterModel_->data(index, Qt::DisplayRole).toString(); - QPoint pos = filterModel_->data(index, MvQFolderModel::PositionRole).toPoint(); + QString name = filterModel_->data(index, Qt::DisplayRole).toString(); + QPoint pos = filterModel_->data(index, MvQFolderModel::PositionRole).toPoint(); QPoint newPos = itemProp_->adjsutReferencePosition(name, oriName, pos); filterModel_->setData(index, newPos, MvQFolderModel::PositionRole); } @@ -1481,19 +1486,19 @@ void MvQIconFolderView::edit(QGraphicsItem* item) { if (item && !editor_) { - //qDebug() << "create editor"; + // qDebug() << "create editor"; - auto* ic = static_cast(item); - editor_ = new MvQEditorProxy(ic); + auto* ic = dynamic_cast(item); + editor_ = new MvQEditorProxy(ic); - //Warning: editingFinished is emitted twice !!! It is a known qt bug!! - //So we needed to use returnPressed here. - //connect(editor_->editor(),SIGNAL(returnPressed()), + // Warning: editingFinished is emitted twice !!! It is a known qt bug!! + // So we needed to use returnPressed here. + // connect(editor_->editor(),SIGNAL(returnPressed()), connect(editor_, SIGNAL(finishedEditing()), this, SLOT(slotRename())); scene()->addItem(editor_); - //editor_->setPos(item->pos().x(),item->pos().y()+getIconSize()+5); + // editor_->setPos(item->pos().x(),item->pos().y()+getIconSize()+5); editor_->setPos(ic->textPos()); scene()->setFocusItem(editor_, Qt::MouseFocusReason); editor_->editor()->setFocus(Qt::MouseFocusReason); @@ -1508,7 +1513,7 @@ if (editor_) { scene()->removeItem(editor_); editor_->deleteLater(); - editor_ = 0; + editor_ = nullptr; if (defaultShortCut_) defaultShortCut_->setEnabled(true); @@ -1555,11 +1560,11 @@ void MvQIconFolderView::slotIconShortCut() { - auto* sc = static_cast(QObject::sender()); + auto* sc = dynamic_cast(QObject::sender()); if (sc) { QModelIndexList lst = selectedIndexes(); - //qDebug() << "shortcuts" << sc << lst; + // qDebug() << "shortcuts" << sc << lst; if (lst.count() > 0) handleIconShortCut(sc, lst); } @@ -1570,7 +1575,7 @@ if (defaultShortCut_) { QModelIndexList lst = selectedIndexes(); - //qDebug() << "default shortcut" << lst; + // qDebug() << "default shortcut" << lst; if (lst.count() == 1) handleDoubleClick(lst.at(0)); } @@ -1578,7 +1583,7 @@ void MvQIconFolderView::slotDesktopShortCut() { - auto* sc = static_cast(QObject::sender()); + auto* sc = dynamic_cast(QObject::sender()); if (sc) { QPoint scrollOffset(horizontalScrollBar()->value(), verticalScrollBar()->value()); handleDesktopShortCut(sc, mousePos_ + scrollOffset, this); @@ -1588,19 +1593,19 @@ void MvQIconFolderView::keyPressEvent(QKeyEvent* event) { - QGraphicsItem* current = 0; + QGraphicsItem* current = nullptr; - //qDebug() << "KEY" << event->key(); + // qDebug() << "KEY" << event->key(); if (editor_) { QGraphicsView::keyPressEvent(event); return; } - bool hasCtrl = event->modifiers() & Qt::ControlModifier; + bool hasCtrl = event->modifiers() & Qt::ControlModifier; bool hasShift = event->modifiers() & Qt::ShiftModifier; - //Ctrl+Shift + // Ctrl+Shift if (hasCtrl && hasShift) { event->ignore(); return; @@ -1642,7 +1647,7 @@ break; } - //QGraphicsView::keyPressEvent(event); + // QGraphicsView::keyPressEvent(event); } @@ -1653,9 +1658,9 @@ QGraphicsItem* MvQIconFolderView::findByKey(int key) { if (items().count() == 0) - return 0; + return nullptr; - QGraphicsItem* current = items().at(0); + QGraphicsItem* current = items().at(0); QList sLst = scene()->selectedItems(); if (sLst.size() > 0) current = sLst.at(0); @@ -1773,9 +1778,9 @@ QGraphicsItem* MvQIconFolderView::findByText(QString search) { if (!folderModel_->folder() || items().count() == 0) - return 0; + return nullptr; - //Get current item and index + // Get current item and index QGraphicsItem* currentItem = items().at(0); QList sLst = scene()->selectedItems(); if (sLst.size() > 0) @@ -1794,12 +1799,12 @@ bool sameKey = false; if (keyboardInput_.length() > 1) { - int c = keyboardInput_.count(keyboardInput_.at(keyboardInput_.length() - 1)); + int c = keyboardInput_.count(keyboardInput_.at(keyboardInput_.length() - 1)); sameKey = (c == keyboardInput_.length()); } const QString searchString = sameKey ? QString(keyboardInput_.at(0)) : keyboardInput_; - QModelIndexList match = filterModel_->match(current, Qt::DisplayRole, searchString, -1, + QModelIndexList match = filterModel_->match(current, Qt::DisplayRole, searchString, -1, Qt::MatchStartsWith | Qt::MatchWrap); match.removeOne(current); diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconFolderView.h metview-5.19.2/metview/src/Desktop/MvQIconFolderView.h --- metview-5.17.4/metview/src/Desktop/MvQIconFolderView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconFolderView.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ Q_OBJECT public: - MvQIconItemTimer(MvQIconItem*, QObject* parent = 0); + MvQIconItemTimer(MvQIconItem*, QObject* parent = nullptr); void setItem(MvQIconItem*); void blink(); @@ -51,7 +51,7 @@ { Q_OBJECT public: - MvQEditorProxy(MvQIconItem* item, QGraphicsItem* parent = 0); + MvQEditorProxy(MvQIconItem* item, QGraphicsItem* parent = nullptr); QLineEdit* editor(); MvQIconItem* item(); @@ -59,7 +59,7 @@ void finishedEditing(); protected: - void keyPressEvent(QKeyEvent*); + void keyPressEvent(QKeyEvent*) override; MvQIconItem* item_; QLineEdit* editor_; @@ -68,33 +68,33 @@ /*class MvQDropTargetItem : public QGraphicsItem { public: - MvQDropTargetItem(MvQIconItem*,bool); - QRectF boundingRect() const; - void paint(QPainter*, const QStyleOptionGraphicsItem *,QWidget*); - void setTarget(MvQIconItem*,bool); - -protected: - void adjust(bool); - - MvQIconItem* target_; - QRectF bRect_; - QString text1_; - QString text2_; - int xPadding_; - int yPadding_; - int textOffset_; - QPen bgPen_; - QBrush bgBrush_; - QPixmap pix_; + MvQDropTargetItem(MvQIconItem*,bool); + QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem *,QWidget*); + void setTarget(MvQIconItem*,bool); + +protected: + void adjust(bool); + + MvQIconItem* target_; + QRectF bRect_; + QString text1_; + QString text2_; + int xPadding_; + int yPadding_; + int textOffset_; + QPen bgPen_; + QBrush bgBrush_; + QPixmap pix_; };*/ class MvQIconItem : public QGraphicsItem { public: - MvQIconItem(const QModelIndex& index, MvQFolderItemProperty* itemProp, MvQIconFolderView*, QGraphicsItem* parent = 0); - QRectF boundingRect() const; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + MvQIconItem(const QModelIndex& index, MvQFolderItemProperty* itemProp, MvQIconFolderView*, QGraphicsItem* parent = nullptr); + QRectF boundingRect() const override; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; const QPersistentModelIndex& index() const; QRect pixmapRect(); QString text(); @@ -112,8 +112,8 @@ QPointF textPos(); protected: - void hoverEnterEvent(QGraphicsSceneHoverEvent*); - void hoverLeaveEvent(QGraphicsSceneHoverEvent*); + void hoverEnterEvent(QGraphicsSceneHoverEvent*) override; + void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override; MvQIconFolderView* view_; MvQFolderItemProperty* itemProp_; @@ -125,7 +125,7 @@ bool dropTarget_; BlinkState blinkState_; - //We make these static members because they are the same for all instances + // We make these static members because they are the same for all instances static QPen editPen_; static QBrush editBrush_; static QPen hoverPen_; @@ -143,13 +143,13 @@ Q_OBJECT public: - MvQIconFolderView(MvQFolderModel*, MvQActionList*, MvQActionList*, QWidget* parent = 0); - ~MvQIconFolderView(); + MvQIconFolderView(MvQFolderModel*, MvQActionList*, MvQActionList*, QWidget* parent = nullptr); + ~MvQIconFolderView() override; - void toGrid(Desktop::GridSortMode); + void toGrid(Desktop::GridSortMode) override; static void load(request* r); - QWidget* concreteWidget(); - void doReset(); + QWidget* concreteWidget() override; + void doReset() override; public slots: void slotIconSizeChanged(); @@ -171,8 +171,8 @@ void desktopCommandRequested(QString, QPoint); protected: - void attachModel(); - void detachModel(); + void attachModel() override; + void detachModel() override; void clearContents(); void initImportedHalfSizeItems(); QModelIndex indexAt(QPointF); @@ -182,10 +182,10 @@ const QPersistentModelIndex& itemToIndex(QGraphicsItem*); IconObject* itemToObject(QGraphicsItem*); QRectF itemRect(QGraphicsItem*); - QRect itemRect(QList); - QRect itemRect(IconObject*); - QRect pixmapRect(QList); - QRect pixmapRect(IconObject*); + QRect itemRect(QList) override; + QRect itemRect(IconObject*) override; + QRect pixmapRect(QList) override; + QRect pixmapRect(IconObject*) override; QModelIndexList selectedIndexes(); void selectOnlyOneItem(QGraphicsItem*); @@ -195,46 +195,46 @@ void computeGrid(Desktop::GridSortMode mode = Desktop::GridSortByName); void checkPositions(); - bool ignoreItemPositionForCm() { return false; } + bool ignoreItemPositionForCm() override { return false; } - MvQContextItemSet* cmSet(); - void setupShortCut(); + MvQContextItemSet* cmSet() override; + void setupShortCut() override; - bool event(QEvent* event); - void changeEvent(QEvent* event); + bool event(QEvent* event) override; + void changeEvent(QEvent* event) override; void notifyItemEntered(MvQIconItem* item); void notifyItemLeft(MvQIconItem* item); - void mouseDoubleClickEvent(QMouseEvent*); - void keyPressEvent(QKeyEvent*); - void mousePressEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); + void mouseDoubleClickEvent(QMouseEvent*) override; + void keyPressEvent(QKeyEvent*) override; + void mousePressEvent(QMouseEvent*) override; + void mouseMoveEvent(QMouseEvent*) override; void performDrag(Qt::DropAction, QPoint); - void dragEnterEvent(QDragEnterEvent*); - void dragMoveEvent(QDragMoveEvent*); - void dragLeaveEvent(QDragLeaveEvent*); - void dropEvent(QDropEvent*); - //void performDrop(Qt::DropAction,IconObject*,QList,QPoint,QPoint,bool); + void dragEnterEvent(QDragEnterEvent*) override; + void dragMoveEvent(QDragMoveEvent*) override; + void dragLeaveEvent(QDragLeaveEvent*) override; + void dropEvent(QDropEvent*) override; + // void performDrop(Qt::DropAction,IconObject*,QList,QPoint,QPoint,bool); void performDrop(Qt::DropAction dropAction, const MvQIconMimeData* data, - QPoint cursorScenePos, bool fromSameView); + QPoint cursorScenePos, bool fromSameView) override; void checkDropTarget(QDropEvent*); void removeDropTarget(); - void rename(IconObject*); + void rename(IconObject*) override; void edit(QGraphicsItem*); void removeEditor(); QGraphicsItem* findByKey(int); QGraphicsItem* findByText(QString); - void folderChanged(); - void blink(const QModelIndex&); - void showIcon(const QModelIndex&); - void iconCommandFromMain(QString name); - void iconCommand(QString, IconObjectH); - void desktopCommand(QString, QPoint); + void folderChanged() override; + void blink(const QModelIndex&) override; + void showIcon(const QModelIndex&) override; + void iconCommandFromMain(QString name) override; + void iconCommand(QString, IconObjectH) override; + void desktopCommand(QString, QPoint) override; QPoint prevScrollPos_; bool paintEnabled_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconHelp.cc metview-5.19.2/metview/src/Desktop/MvQIconHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQIconHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,7 +27,7 @@ { multiple_ = param.multiple(); - //Create model + // Create model model_ = new MvQFolderModel(parentWidget_); Folder* f = Folder::folder("templates", @@ -37,20 +37,20 @@ model_->setFolder(f); model_->setAcceptedClasses(param.interfaceRequest().get("class")); - //If the folder is empty try to create an icon from the help_definition + // If the folder is empty try to create an icon from the help_definition fill(param); - //Create view + // Create view view_ = new MvQIconHelpView(model_, parentWidget_); - //view_->setHelper(true); + // view_->setHelper(true); view_->setFixedHeight(80); view_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - //Title + // Title auto* titleLabel = new QLabel(tr("Helper icons for: ") + QString::fromStdString(param.beautifiedName()), parentWidget_); - //Layout + // Layout auto* layout = new QVBoxLayout(parentWidget_); layout->setSpacing(3); layout->setContentsMargins(1, 1, 1, 1); @@ -60,12 +60,12 @@ layout->addWidget(titleLabel); layout->addWidget(view_); - //QFont font; - //QFontMetrics fm(font); - //holderW_->setMinimumHeight(2*(fm.size(Qt::TextExpandTabs,"A").height()+32+10+5+10)); - //holderW_->setMaximumHeight(2*(fm.size(Qt::TextExpandTabs,"A").height()+32+10+5+10)); + // QFont font; + // QFontMetrics fm(font); + // holderW_->setMinimumHeight(2*(fm.size(Qt::TextExpandTabs,"A").height()+32+10+5+10)); + // holderW_->setMaximumHeight(2*(fm.size(Qt::TextExpandTabs,"A").height()+32+10+5+10)); - //view_->toGrid(); + // view_->toGrid(); } QWidget* MvQIconHelp::widget() @@ -85,11 +85,11 @@ return; if (f->numOfIconKids() == 0) { - Request i = param.interfaceRequest(); - MvRequest p = i("help_definition"); + Request i = param.interfaceRequest(); + MvRequest p = i("help_definition"); const char* n = i("help_name"); - //Create a helper icon from the request + // Create a helper icon from the request if (p) { IconObject* o = IconFactory::create(model_->folder(), p, IconInfo::undefX(), IconInfo::undefY()); if (n) diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconHelp.h metview-5.19.2/metview/src/Desktop/MvQIconHelp.h --- metview-5.17.4/metview/src/Desktop/MvQIconHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,16 +26,16 @@ public: MvQIconHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQIconHelp() = default; + ~MvQIconHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget(); + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override; public slots: protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; virtual long flags() { return 9; } virtual void set(Request&) {} void fill(const MvIconParameter&); diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconHelpView.cc metview-5.19.2/metview/src/Desktop/MvQIconHelpView.cc --- metview-5.17.4/metview/src/Desktop/MvQIconHelpView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconHelpView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,13 +20,8 @@ { } -MvQIconHelpView::~MvQIconHelpView() -{ - //delete filterModel_; -} - MvQContextItemSet* MvQIconHelpView::cmSet() { static MvQContextItemSet cmItems("IconHelpView"); return &cmItems; -} \ No newline at end of file +} diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconHelpView.h metview-5.19.2/metview/src/Desktop/MvQIconHelpView.h --- metview-5.17.4/metview/src/Desktop/MvQIconHelpView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconHelpView.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,9 @@ class MvQIconHelpView : public MvQIconStripView { public: - MvQIconHelpView(MvQFolderModel*, QWidget* parent = 0); - ~MvQIconHelpView(); + MvQIconHelpView(MvQFolderModel*, QWidget* parent = nullptr); + ~MvQIconHelpView() override = default; protected: - MvQContextItemSet* cmSet(); + MvQContextItemSet* cmSet() override; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconHolder.cc metview-5.19.2/metview/src/Desktop/MvQIconHolder.cc --- metview-5.17.4/metview/src/Desktop/MvQIconHolder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconHolder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -45,7 +45,7 @@ { beginResetModel(); - //Cleaning + // Cleaning foreach (IconObjectH actObj, icons_) { if (actObj && actObj->isEmbedded() && std::find(objects.begin(), objects.end(), actObj) == objects.end()) { @@ -66,7 +66,7 @@ { beginResetModel(); - //Cleaning + // Cleaning foreach (IconObjectH actObj, icons_) { if (actObj && actObj->isEmbedded() && (std::find(objects.begin(), objects.end(), actObj) == objects.end())) { @@ -99,18 +99,18 @@ { if (role != Qt::DisplayRole && role != Qt::DecorationRole && role != Qt::ForegroundRole && role != Qt::UserRole && role != Qt::FontRole) { - return QVariant(); + return {}; } if (!index.isValid()) - return QVariant(); + return {}; - IconObject* obj = 0; + IconObject* obj = nullptr; if (index.row() >= 0 && index.row() < icons_.count()) obj = icons_[index.row()]; if (!obj) - return QVariant(); + return {}; switch (role) { case Qt::DecorationRole: { @@ -122,23 +122,23 @@ break; } - return QVariant(); + return {}; } QModelIndex MvQIconHolderModel::index(int row, int column, const QModelIndex& /*parent */) const { - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } QModelIndex MvQIconHolderModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } IconObject* MvQIconHolderModel::iconObject(const QModelIndex& index) { - IconObject* obj = 0; + IconObject* obj = nullptr; if (index.row() >= 0 && index.row() < icons_.count()) obj = icons_[index.row()]; @@ -204,13 +204,13 @@ QFontMetrics fm(font); setMaximumHeight(fm.size(Qt::TextExpandTabs, "A").height() + 32 + 10 + 5 + 10); - //Double click + // Double click connect(this, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(slotDoubleClickItem(const QModelIndex))); setContextMenuPolicy(Qt::CustomContextMenu); - //Context menu + // Context menu connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotContextMenu(const QPoint&))); @@ -219,7 +219,7 @@ setDragEnabled(true); setDropIndicatorShown(true); setDragDropMode(QAbstractItemView::DragDrop); - //setDragDropMode(QAbstractItemView::DropOnly); + // setDragDropMode(QAbstractItemView::DropOnly); setModel(model); @@ -264,7 +264,7 @@ QModelIndex index = indexAt(pos); if (index.isValid()) { - IconObjectH obj = model_->iconObject(index); + IconObjectH obj = model_->iconObject(index); QString selected = MvQContextMenu::instance()->exec(cms()->icon(), obj, mapToGlobal(pos), this); if (!selected.isEmpty()) { command(selected, obj); @@ -287,7 +287,7 @@ void MvQIconHolderView::slotIconShortCut() { - if (auto* sc = static_cast(QObject::sender())) { + if (auto* sc = dynamic_cast(QObject::sender())) { QModelIndexList lst = selectedIndexes(); if (lst.count() > 0) { IconObjectH obj = model_->iconObject(lst[0]); @@ -300,7 +300,7 @@ void MvQIconHolderView::command(QString name, IconObjectH obj) { - //Other actions + // Other actions if (Command::isValid(name.toStdString())) { obj->command(name.toStdString()); } @@ -378,10 +378,10 @@ IconObject* obj = dropObj; - //If drop came from a helper + // If drop came from a helper if (dropModel && mimeData->fromHelper()) { std::string param = owner_->parameter().beautifiedName(); - obj = dropObj->clone(owner_->currentObject()->embeddedFolder(param)); + obj = dropObj->clone(owner_->currentObject()->embeddedFolder(param)); } if (obj) { diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconHolder.h metview-5.19.2/metview/src/Desktop/MvQIconHolder.h --- metview-5.17.4/metview/src/Desktop/MvQIconHolder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconHolder.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,13 +27,13 @@ class MvQIconHolderModel : public QAbstractItemModel { public: - MvQIconHolderModel(const std::vector&, QObject* parent = 0); + MvQIconHolderModel(const std::vector&, QObject* parent = nullptr); - int columnCount(const QModelIndex&) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + int columnCount(const QModelIndex&) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void setIcons(const std::vector&); void clearIcons(const std::vector&); @@ -54,8 +54,8 @@ Q_OBJECT public: - MvQIconHolderView(MvQIconHolderModel*, RequestPanelItem*, QWidget* parent = 0); - ~MvQIconHolderView(); + MvQIconHolderView(MvQIconHolderModel*, RequestPanelItem*, QWidget* parent = nullptr); + ~MvQIconHolderView() override; protected slots: void slotDoubleClickItem(const QModelIndex& index); @@ -73,9 +73,9 @@ void remove(IconObjectH); void command(QString, IconObjectH); - void dragEnterEvent(QDragEnterEvent*); - void dragMoveEvent(QDragMoveEvent*); - void dropEvent(QDropEvent*); + void dragEnterEvent(QDragEnterEvent*) override; + void dragMoveEvent(QDragMoveEvent*) override; + void dropEvent(QDropEvent*) override; MvQIconHolderModel* model_; std::vector classes_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconLine.cc metview-5.19.2/metview/src/Desktop/MvQIconLine.cc --- metview-5.17.4/metview/src/Desktop/MvQIconLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,27 +34,27 @@ Request interface = param_.interfaceRequest(); model_ = new MvQIconHolderModel(interface.get("class"), parentWidget_); - view_ = new MvQIconHolderView(model_, this, parentWidget_); + view_ = new MvQIconHolderView(model_, this, parentWidget_); const std::vector& classes = interface.get("class"); /*QString title(tr("Icons: ")); - const std::vector& classes=interface.get("class"); - for(vector::const_iterator it = classes.begin(); it != classes.end(); ++it) - { - if(it != classes.begin()) - { - title+=", "; - } - title+=QString::fromStdString(IconClass::find(*it).defaultName()); - }*/ + const std::vector& classes=interface.get("class"); + for(vector::const_iterator it = classes.begin(); it != classes.end(); ++it) + { + if(it != classes.begin()) + { + title+=", "; + } + title+=QString::fromStdString(IconClass::find(*it).defaultName()); + }*/ - //QLabel *titleLabel=new QLabel(title,parentWidget_); + // QLabel *titleLabel=new QLabel(title,parentWidget_); acceptLayout_ = buildAcceptLayout(classes); - //QLabel *titleLabel=new QLabel(parentWidget_); - //titleLabel->setPixmap(iconClassPixmap(classes)); + // QLabel *titleLabel=new QLabel(parentWidget_); + // titleLabel->setPixmap(iconClassPixmap(classes)); auto* layout = new QVBoxLayout(parentWidget_); layout->setSpacing(3); @@ -66,7 +66,7 @@ layout->addLayout(acceptLayout_); layout->addWidget(view_); - owner_.addWidget(w, row_, 3); + owner_.addWidget(w, row_, WidgetColumn); connect(view_, SIGNAL(edited()), this, SLOT(slotHolderEdited())); @@ -87,12 +87,12 @@ std::vector sub = currentObject_->subObjects(parName, r); grey(); - //This will clear the unwanted iconobjects!! + // This will clear the unwanted iconobjects!! model_->setIcons(sub); mark(model_->rowCount() > 0); - //changed_ = false; + // changed_ = false; } void MvQIconLine::update() @@ -113,19 +113,19 @@ currentObject_->setSubObjects(param_.name(), vals, r, true); } -//Should be called when we close the editor +// Should be called when we close the editor void MvQIconLine::cleanup() { if (!currentObject_) return; - //We read the saved request + // We read the saved request const Request& r = owner_.request(); std::string parName(param_.name()); std::vector sub = currentObject_->subObjects(parName, r); - //This will clear the unwanted iconObjects!! + // This will clear the unwanted iconObjects!! model_->clearIcons(sub); } @@ -145,19 +145,19 @@ int pixSize = 16; for (const auto& classe : classes) { QPixmap pix = MvQIconProvider::pixmap(IconClass::find(classe), pixSize); - lw = new QLabel(parentWidget_); + lw = new QLabel(parentWidget_); lw->setPixmap(pix); lw->setToolTip(QString::fromStdString(IconClass::find(classe).defaultName())); hb->addSpacing(4); hb->addWidget(lw); - //painter.drawPixmap(i*pixSize+i*pixGap,0,pix); + // painter.drawPixmap(i*pixSize+i*pixGap,0,pix); } hb->addStretch(1); return hb; - //return cpix; + // return cpix; } diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconMimeData.cc metview-5.19.2/metview/src/Desktop/MvQIconMimeData.cc --- metview-5.17.4/metview/src/Desktop/MvQIconMimeData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconMimeData.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,7 +42,7 @@ QVariant MvQNewIconMimeData::retrieveData(const QString& /*format*/, QVariant::Type /*type*/) const #endif { - return QVariant(); + return {}; } //================================= @@ -107,7 +107,7 @@ foreach (IconObject* obj, objects_) { stream << QString::fromStdString(obj->fullName()); - //stream << QString::fromStdString(obj->className()); + // stream << QString::fromStdString(obj->className()); stream << QString::fromStdString(obj->editorClass().name()); } @@ -118,7 +118,7 @@ return s; } else if (format == "text/html") { - //return "file://" + path_; + // return "file://" + path_; } else if (format == "image/png") { QString s = "file://" + objPath_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconMimeData.h metview-5.19.2/metview/src/Desktop/MvQIconMimeData.h --- metview-5.17.4/metview/src/Desktop/MvQIconMimeData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconMimeData.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,13 +31,13 @@ MvQNewIconMimeData(QString, IconDefType); - QStringList formats() const; + QStringList formats() const override; QString className() const { return className_; } IconDefType iconDefType() const { return iconDefType_; } protected: #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QVariant retrieveData(const QString& format, QMetaType type) const; + QVariant retrieveData(const QString& format, QMetaType type) const override; #else QVariant retrieveData(const QString& mimeType, QVariant::Type type) const; #endif @@ -61,9 +61,9 @@ }; MvQIconMimeData(MvQFolderModel*, IconObject*, QPointF, QList, QList, ClipboardAction clipboardAction = NoAction); - ~MvQIconMimeData(); + ~MvQIconMimeData() override; - QStringList formats() const; + QStringList formats() const override; MvQFolderModel* model() const { return model_; } IconObject* dragObject() const { return dragObject_; } QPointF hotSpotInVisRect() const { return hotSpotInVisRect_; } @@ -76,11 +76,11 @@ ClipboardAction clipboardAction() const { return clipboardAction_; } bool isEmpty() const; - void iconDestroyed(IconObject*); + void iconDestroyed(IconObject*) override; protected: #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QVariant retrieveData(const QString& format, QMetaType type) const; + QVariant retrieveData(const QString& format, QMetaType type) const override; #else QVariant retrieveData(const QString& mimeType, QVariant::Type type) const; #endif diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconObjectModel.cc metview-5.19.2/metview/src/Desktop/MvQIconObjectModel.cc --- metview-5.17.4/metview/src/Desktop/MvQIconObjectModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconObjectModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -52,18 +52,18 @@ QVariant MvQIconObjectModel::data(const QModelIndex& index, int role) const { if (role != Qt::DisplayRole && role != Qt::DecorationRole) { - return QVariant(); + return {}; } if (!index.isValid()) - return QVariant(); + return {}; IconObjectH obj = nullptr; if (index.row() >= 0 && index.row() < static_cast(IconObject::objects().size())) obj = IconObject::objects().at(index.row()); if (!obj) - return QVariant(); + return {}; if (index.column() == 0) { if (role == Qt::DisplayRole) @@ -83,7 +83,7 @@ return QString::number(obj->count()); } - return QVariant(); + return {}; } QModelIndex MvQIconObjectModel::index(int row, int column, const QModelIndex& /*parent */) const @@ -94,13 +94,13 @@ QModelIndex MvQIconObjectModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } QVariant MvQIconObjectModel::headerData(const int section, const Qt::Orientation orient, const int role) const { if (orient != Qt::Horizontal || role != Qt::DisplayRole) - return QVariant(); + return {}; if (section == 0) return "Name"; @@ -109,5 +109,5 @@ else if (section == 2) return "Count"; - return QVariant(); + return {}; } diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconObjectModel.h metview-5.19.2/metview/src/Desktop/MvQIconObjectModel.h --- metview-5.17.4/metview/src/Desktop/MvQIconObjectModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconObjectModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,13 +16,13 @@ class MvQIconObjectModel : public QAbstractItemModel { public: - MvQIconObjectModel(QObject* parent = 0); + MvQIconObjectModel(QObject* parent = nullptr); - int columnCount(const QModelIndex&) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; - QVariant headerData(const int section, const Qt::Orientation orient, const int role) const; + int columnCount(const QModelIndex&) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; + QVariant headerData(const int section, const Qt::Orientation orient, const int role) const override; void update(); }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconProvider.cc metview-5.19.2/metview/src/Desktop/MvQIconProvider.cc --- metview-5.17.4/metview/src/Desktop/MvQIconProvider.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconProvider.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ #include -//This array defines the avaiable icon sizes +// This array defines the avaiable icon sizes static int sizeArr[] = {12, 16, 24, 32, 48, 64, 96}; static MvQUnknownIcon unknownIcon(":/desktop/unknown.svg"); @@ -60,7 +60,7 @@ if (imgR.canRead()) { imgR.setScaledSize(QSize(size, size)); QImage img = imgR.read(); - pix = QPixmap::fromImage(img); + pix = QPixmap::fromImage(img); } else { pix = unknownIcon.pixmap(size); @@ -69,7 +69,7 @@ pixmaps_[size] = pix; return pix; } - return QPixmap(); + return {}; } QPixmap MvQIcon::pixmap(IconObject* obj, int size, bool checkEmbedded) @@ -134,7 +134,7 @@ QPixmap MvQIcon::greyedOutPixmap(IconObject* obj, int size) { QPixmap pix = pixmap(obj, size, false); - QImage img = pix.toImage(); + QImage img = pix.toImage(); greyOut(img); return QPixmap::fromImage(img); } @@ -143,16 +143,16 @@ { int w = img.width(); int h = img.height(); - QRgb c; - int g; - int gBase = MvQTheme::colour("folderview", "faded_base").red(); + QRgb c = 0; + int g = 0; + int gBase = MvQTheme::colour("folderview", "faded_base").red(); float gFactor = (255. - gBase) / 255.; for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) { c = img.pixel(i, j); if (qAlpha(c) != 0) { - //g=qGray(c); + // g=qGray(c); g = (qRed(c) + qGreen(c) + qBlue(c)) / 3; g = gBase + gFactor * static_cast(g); img.setPixel(i, j, qRgb(g, g, g)); @@ -165,8 +165,8 @@ { } -//We must serve back a valid pixmap all the time!!! The MvQIcon pixmap() method -//calls this a fallback!!! +// We must serve back a valid pixmap all the time!!! The MvQIcon pixmap() method +// calls this a fallback!!! QPixmap MvQUnknownIcon::pixmap(int size) { auto it = pixmaps_.find(size); @@ -185,7 +185,7 @@ painter.setPen(Qt::black); QRect r(0, 0, size, size); QFont f; - float reqFontSize = 4 + 72.0 * 0.75 * static_cast(size) / 96.; //estimate with 96 dpi + float reqFontSize = 4 + 72.0 * 0.75 * static_cast(size) / 96.; // estimate with 96 dpi f.setPointSize(reqFontSize); QFontMetrics fm(f); while (fm.height() > 3 * size / 4 && f.pointSize() > 8) { @@ -200,7 +200,7 @@ } } - return QPixmap(size, size); + return {size, size}; } //=========================================== @@ -217,7 +217,7 @@ if (it != icons_.end()) return it->second; - auto* p = new MvQIcon(MvQTheme::icIconFile(kind.pixmap())); + auto* p = new MvQIcon(MvQTheme::icIconFile(kind.pixmap())); icons_[kind.name()] = p; return p; } @@ -230,8 +230,8 @@ if (IconClass::isValid(kind)) { const IconClass& ic = IconClass::find(kind); - auto* p = new MvQIcon(MvQTheme::icIconFile(ic.pixmap())); - icons_[kind] = p; + auto* p = new MvQIcon(MvQTheme::icIconFile(ic.pixmap())); + icons_[kind] = p; return p; } return &unknownIcon; @@ -272,7 +272,7 @@ } } else { - Folder* folder = Folder::folder(fullName, false); + Folder* folder = Folder::folder(fullName, false); folders_[fullName] = folder; if (folder) return pixmap(folder, size); diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconProvider.h metview-5.19.2/metview/src/Desktop/MvQIconProvider.h --- metview-5.17.4/metview/src/Desktop/MvQIconProvider.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconProvider.h 2023-07-15 08:28:47.000000000 +0000 @@ -41,7 +41,7 @@ { public: MvQUnknownIcon(QString); - QPixmap pixmap(int); + QPixmap pixmap(int) override; }; class MvQIconProvider diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconStripView.cc metview-5.19.2/metview/src/Desktop/MvQIconStripView.cc --- metview-5.17.4/metview/src/Desktop/MvQIconStripView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconStripView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,16 +39,16 @@ setMovement(QListView::Static); setResizeMode(QListView::Fixed); - //Need to set all these again because setting movement - //to static disables the whole drag and drop in the view - //and even in the viewport!!! + // Need to set all these again because setting movement + // to static disables the whole drag and drop in the view + // and even in the viewport!!! setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(true); setDragDropMode(QAbstractItemView::DragDrop); viewport()->setAcceptDrops(true); - //Icons can be moved to/from these folders + // Icons can be moved to/from these folders setAllowMoveAction(false); setEnterFolders(false); @@ -65,7 +65,7 @@ void MvQIconStripView::performDrop(Qt::DropAction, const MvQIconMimeData* data, QPoint, bool fromSameView) { - //Drop from another view/model --> always copy!!! + // Drop from another view/model --> always copy!!! if (!fromSameView) { foreach (IconObject* obj, data->objects()) { #if 0 diff -Nru metview-5.17.4/metview/src/Desktop/MvQIconStripView.h metview-5.19.2/metview/src/Desktop/MvQIconStripView.h --- metview-5.17.4/metview/src/Desktop/MvQIconStripView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQIconStripView.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,9 @@ class MvQIconStripView : public MvQListFolderViewBase { public: - MvQIconStripView(MvQFolderModel*, QWidget* parent = 0); - ~MvQIconStripView(); + MvQIconStripView(MvQFolderModel*, QWidget* parent = nullptr); + ~MvQIconStripView() override; protected: - void performDrop(Qt::DropAction, const MvQIconMimeData*, QPoint, bool); + void performDrop(Qt::DropAction, const MvQIconMimeData*, QPoint, bool) override; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQLineStyleLine.cc metview-5.19.2/metview/src/Desktop/MvQLineStyleLine.cc --- metview-5.17.4/metview/src/Desktop/MvQLineStyleLine.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQLineStyleLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,73 @@ +/***************************** LICENSE START *********************************** + + Copyright 2015 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + +#include "MvQLineStyleLine.h" + +#include + +#include +#include + +#include "LineFactory.h" +#include "MvQTheme.h" + + +//================================================================================= +// +// MvQComboBoxLine +// +//================================================================================= + +MvQLineStyleLine::MvQLineStyleLine(RequestPanel& owner, const MvIconParameter& param) : + MvQComboBoxLine(owner, param) + +{ + QFont f; + int h = 0; + fixedFontAndHeight(f, h); + cbEdit_->setFont(f); + cbEdit_->setIconSize(QSize(100, h - 4)); + loadPixmaps(); +} + +void MvQLineStyleLine::loadPixmaps() +{ + std::map lineStyleDef = { + {"solid", Qt::SolidLine}, + {"dash", Qt::DashLine}, + {"dot", Qt::DotLine}, + {"chain_dot", Qt::DashDotLine}, + {"chain_dash", Qt::DashDotDotLine}, + {"dash_dot", Qt::DashDotLine}, + {"dash_dot_dot", Qt::DashDotDotLine}}; + + for (int i = 0; i < cbEdit_->count(); i++) { + auto style = cbEdit_->itemData(i).toString().toLower(); + auto pix = QPixmap(cbEdit_->iconSize()); + pix.fill(Qt::transparent); + auto it = lineStyleDef.find(style); + if (it != lineStyleDef.end()) { + renderLine(&pix, it->second); + cbEdit_->setItemIcon(i, QIcon(pix)); + } + } +} + + +void MvQLineStyleLine::renderLine(QPixmap* pix, Qt::PenStyle penStyle) +{ + int margin = 4; + auto h = pix->height(); + auto w = pix->width(); + auto painter = QPainter(pix); + painter.setPen(QPen(MvQTheme::colour("uplot", "ribbon_pen"), 2, penStyle)); + painter.drawLine(margin, h / 2, w - margin, h / 2); +} + +static LineMaker maker1("line_style"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQLineStyleLine.h metview-5.19.2/metview/src/Desktop/MvQLineStyleLine.h --- metview-5.17.4/metview/src/Desktop/MvQLineStyleLine.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQLineStyleLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,27 @@ +/***************************** LICENSE START *********************************** + + Copyright 2023 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + +#pragma once + +#include "MvQComboBoxLine.h" + +class QPixmap; +class Request; +class RequestPanel; + +class MvQLineStyleLine : public MvQComboBoxLine +{ +public: + MvQLineStyleLine(RequestPanel& owner, const MvIconParameter& param); + +private: + void loadPixmaps(); + void renderLine(QPixmap* pix, Qt::PenStyle penStyle); + +}; diff -Nru metview-5.17.4/metview/src/Desktop/MvQListFolderViewBase.cc metview-5.19.2/metview/src/Desktop/MvQListFolderViewBase.cc --- metview-5.17.4/metview/src/Desktop/MvQListFolderViewBase.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQListFolderViewBase.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,17 +38,17 @@ allowMoveAction_(true), enterFolders_(true), canDrag_(false), - defaultShortCut_(0) + defaultShortCut_(nullptr) { setContextMenuPolicy(Qt::CustomContextMenu); - //Drag and drop + // Drag and drop setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(true); setDragDropMode(QAbstractItemView::DragDrop); - //Delegate + // Delegate delegate_ = new MvQIconDelegate(this); setItemDelegate(delegate_); @@ -56,7 +56,7 @@ this, SLOT(update(const QModelIndex&))); - //Set the model. This will call reset on the view. + // Set the model. This will call reset on the view. setModel(filterModel_); setMouseTracking(true); @@ -64,18 +64,18 @@ setEditTriggers(QAbstractItemView::NoEditTriggers); setSelectionMode(QAbstractItemView::ExtendedSelection); - //Context menu + // Context menu connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotContextMenu(const QPoint&))); - //Selection in the view + // Selection in the view connect(this, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(slotDoubleClickItem(const QModelIndex))); connect(this, SIGNAL(entered(const QModelIndex&)), this, SLOT(slotEntered(const QModelIndex&))); - //We let the delegate to paint the items + // We let the delegate to paint the items delegate_->setEnablePaint(true); // @@ -85,7 +85,7 @@ MvQListFolderViewBase::~MvQListFolderViewBase() { - //delete filterModel_; + // delete filterModel_; } void MvQListFolderViewBase::doReset() @@ -104,8 +104,8 @@ bool MvQListFolderViewBase::event(QEvent* event) { - //We cannot call shortcut setup in the constructor beacuse it calls a pure virtual function! So we - //call it the first time it is possible. + // We cannot call shortcut setup in the constructor beacuse it calls a pure virtual function! So we + // call it the first time it is possible. if (isVisible()) setupShortCut(); @@ -133,10 +133,10 @@ void MvQListFolderViewBase::slotSelectItem(const QModelIndex& /*index*/) { /*if(changeFolder(index,FilterModelIndex)) - { - changeFolder(index,FilterModelIndex); - emit currentFolderChanged(currentFolder()); - }*/ + { + changeFolder(index,FilterModelIndex); + emit currentFolderChanged(currentFolder()); + }*/ } void MvQListFolderViewBase::slotDoubleClickItem(const QModelIndex& index) @@ -172,7 +172,7 @@ void MvQListFolderViewBase::slotIconShortCut() { - auto* sc = static_cast(QObject::sender()); + auto* sc = dynamic_cast(QObject::sender()); if (sc) { QModelIndexList lst = selectedIndexes(); if (lst.count() > 0) @@ -196,16 +196,16 @@ handleContextMenu(indexAt(position), lst, mapToGlobal(position), position + scrollOffset, this); /*if(lst.count() == 1) - { - QModelIndex index=indexAt(position); - QPoint scrollOffset(horizontalScrollBar()->value(),verticalScrollBar()->value()); - - handleContextMenu(index,mapToGlobal(position),position+scrollOffset,this); - } - else if(lst.count() > 1) - { - handleContextMenu(lst,mapToGlobal(position),position+scrollOffset,this); - } */ + { + QModelIndex index=indexAt(position); + QPoint scrollOffset(horizontalScrollBar()->value(),verticalScrollBar()->value()); + + handleContextMenu(index,mapToGlobal(position),position+scrollOffset,this); + } + else if(lst.count() > 1) + { + handleContextMenu(lst,mapToGlobal(position),position+scrollOffset,this); + } */ } void MvQListFolderViewBase::folderChanged() @@ -271,7 +271,7 @@ QRect MvQListFolderViewBase::pixmapRect(IconObject* obj) { QRect r = visualRect(filterModel_->mapFromSource(folderModel_->indexFromObject(obj))); - return QRect(r.center().x() - getIconSize() / 2, r.y(), getIconSize(), getIconSize()); + return {r.center().x() - getIconSize() / 2, r.y(), getIconSize(), getIconSize()}; } @@ -309,9 +309,9 @@ canDrag_ = true; - //This prevents rubberband selection + // This prevents rubberband selection setState(NoState); - //return; + // return; } } @@ -326,17 +326,13 @@ } if (canDrag_ && event->buttons() & (Qt::LeftButton | Qt::MiddleButton)) { - //qDebug() << "should start drag" << event->pos() << startPos_; + // qDebug() << "should start drag" << event->pos() << startPos_; int distance = (event->pos() - startPos_).manhattanLength(); if (distance >= QApplication::startDragDistance()) { canDrag_ = false; setState(DraggingState); - QModelIndexList lst = selectedIndexes(); - - ///qDebug() << "selected" << lst.count(); - if (allowMoveAction_) { if (event->buttons() & Qt::LeftButton) performDrag(Qt::MoveAction, startPos_); @@ -359,18 +355,18 @@ void MvQListFolderViewBase::performDrag(Qt::DropAction dropAction, QPoint pos) { QModelIndex viewIndex = indexAt(pos); - QModelIndex index = filterModel_->mapToSource(viewIndex); + QModelIndex index = filterModel_->mapToSource(viewIndex); - //The object that was dragged + // The object that was dragged IconObject* dragObj = folderModel_->objectFromIndex(index); - //List of objects to drag + // List of objects to drag QList objLst; foreach (QModelIndex idx, selectedIndexes()) { objLst << folderModel_->objectFromIndex(filterModel_->mapToSource(idx)); } - //Need a solution!!!!!!!!!!!!!!!!!1 + // Need a solution!!!!!!!!!!!!!!!!!1 bool fromHelper = (!allowMoveAction_); QDrag* drag = buildDrag(dragObj, objLst, fromHelper, this); @@ -385,14 +381,14 @@ void MvQListFolderViewBase::dragEnterEvent(QDragEnterEvent* event) { - //qDebug() << event->mimeData()->formats(); - //qDebug() << event->mimeData()->text(); - //qDebug() << event->proposedAction(); + // qDebug() << event->mimeData()->formats(); + // qDebug() << event->mimeData()->text(); + // qDebug() << event->proposedAction(); if (event->source() && (event->proposedAction() == Qt::CopyAction || event->proposedAction() == Qt::MoveAction)) { - //event->setDropAction(Qt::CopyAction); + // event->setDropAction(Qt::CopyAction); event->accept(); } else @@ -412,7 +408,7 @@ void MvQListFolderViewBase::dropEvent(QDropEvent* event) { - //qDebug() << "dropEvent" << folderModel_->fullName(); + // qDebug() << "dropEvent" << folderModel_->fullName(); if (folderModel_->folder()->locked()) { event->ignore(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQListFolderViewBase.h metview-5.19.2/metview/src/Desktop/MvQListFolderViewBase.h --- metview-5.17.4/metview/src/Desktop/MvQListFolderViewBase.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQListFolderViewBase.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,10 +26,10 @@ Q_OBJECT public: - MvQListFolderViewBase(MvQFolderModel*, QWidget* parent = 0); - virtual ~MvQListFolderViewBase(); - QWidget* concreteWidget(); - void doReset(); + MvQListFolderViewBase(MvQFolderModel*, QWidget* parent = nullptr); + ~MvQListFolderViewBase() override; + QWidget* concreteWidget() override; + void doReset() override; public slots: void slotIconShortCut(); @@ -38,7 +38,7 @@ void slotSelectItem(const QModelIndex&); void slotDoubleClickItem(const QModelIndex&); void slotEntered(const QModelIndex&); - void reset(); + void reset() override; signals: void currentFolderChanged(Folder*); @@ -48,39 +48,39 @@ void desktopCommandRequested(QString, QPoint); protected: - void attachModel() {} - void detachModel() {} + void attachModel() override {} + void detachModel() override {} void setAllowMoveAction(bool b) { allowMoveAction_ = b; } void setEnterFolders(bool b) { enterFolders_ = b; } - void setupShortCut(); + void setupShortCut() override; void setPositions() {} - void blink(const QModelIndex&); - void showIcon(const QModelIndex&) {} - void rename(IconObject*); - - void folderChanged(); - void iconCommandFromMain(QString) {} - virtual void iconCommand(QString, IconObjectH); - virtual void desktopCommand(QString, QPoint); - - bool event(QEvent* event); - void leaveEvent(QEvent* event); - void keyPressEvent(QKeyEvent*); - void mousePressEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); + void blink(const QModelIndex&) override; + void showIcon(const QModelIndex&) override {} + void rename(IconObject*) override; + + void folderChanged() override; + void iconCommandFromMain(QString) override {} + void iconCommand(QString, IconObjectH) override; + void desktopCommand(QString, QPoint) override; + + bool event(QEvent* event) override; + void leaveEvent(QEvent* event) override; + void keyPressEvent(QKeyEvent*) override; + void mousePressEvent(QMouseEvent*) override; + void mouseMoveEvent(QMouseEvent*) override; void performDrag(Qt::DropAction, QPoint); - void dragEnterEvent(QDragEnterEvent*); - void dragMoveEvent(QDragMoveEvent*); - void dropEvent(QDropEvent*); - - QRect itemRect(QList); - QRect itemRect(IconObject*); - QRect pixmapRect(QList); - QRect pixmapRect(IconObject*); + void dragEnterEvent(QDragEnterEvent*) override; + void dragMoveEvent(QDragMoveEvent*) override; + void dropEvent(QDropEvent*) override; + + QRect itemRect(QList) override; + QRect itemRect(IconObject*) override; + QRect pixmapRect(QList) override; + QRect pixmapRect(IconObject*) override; - bool ignoreItemPositionForCm() { return false; } + bool ignoreItemPositionForCm() override { return false; } MvQIconDelegate* delegate_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQListHelp.cc metview-5.19.2/metview/src/Desktop/MvQListHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQListHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQListHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,7 +27,7 @@ QVector value_; protected: - void next(const MvIconParameter&, const char* first, const char* second); + void next(const MvIconParameter&, const char* first, const char* second) override; }; ParamHelperList::ParamHelperList(const MvIconParameter& param) @@ -62,7 +62,7 @@ { multiple_ = param.multiple(); - //Create list + // Create list auto paramList = ParamHelperList(param); selector_ = new MvQFilterTreeWidget(paramList.header_, paramList.value_, 0, diff -Nru metview-5.17.4/metview/src/Desktop/MvQListHelp.h metview-5.19.2/metview/src/Desktop/MvQListHelp.h --- metview-5.17.4/metview/src/Desktop/MvQListHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQListHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,17 +25,17 @@ public: MvQListHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQListHelp() {} + ~MvQListHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget(); + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override; public slots: void slotSelectionChanged(QString s, bool); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; virtual long flags() { return 9; } virtual void set(Request&) {} diff -Nru metview-5.17.4/metview/src/Desktop/MvQLogDialog.cc metview-5.19.2/metview/src/Desktop/MvQLogDialog.cc --- metview-5.17.4/metview/src/Desktop/MvQLogDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQLogDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,16 +32,16 @@ static std::set windows; MvQLogDialog::MvQLogDialog() : - current_(0), - file_(0) + current_(nullptr), + file_(nullptr) { - //Window decoration + // Window decoration setWindowIcon(QPixmap(":/desktop/log.svg")); auto* vb = new QVBoxLayout(this); //----------------------- - //Header + // Header //------------------------ auto* hb = new QHBoxLayout; @@ -92,7 +92,7 @@ hb->addStretch(1); //------------------- - //TextEdit + // TextEdit //------------------- textEdit_ = new QPlainTextEdit(this); @@ -102,7 +102,7 @@ vb->addWidget(textEdit_, 1); //------------------- - //Buttonbox + // Buttonbox //------------------- auto* buttonBox = new QDialogButtonBox(this); @@ -113,7 +113,7 @@ this, SLOT(reject())); //------------------- - //Watcher + // Watcher //------------------- watcher_ = new MvQFileWatcher; @@ -136,12 +136,12 @@ void MvQLogDialog::open(IconObject* icon) { MvQLogDialog* e = icon->logWindow(); - if (e == 0) { + if (e == nullptr) { for (auto window : windows) - if (window->current_ == 0) + if (window->current_ == nullptr) e = window; - if (e == 0) + if (e == nullptr) e = new MvQLogDialog(); } Q_ASSERT(e); @@ -156,7 +156,7 @@ if (current_) { current_->logWindow(this); - //Update header and title + // Update header and title if (current_ == Folder::top()) { setWindowTitle(tr("Log window - Metview")); QString str = tr(" Log messages for all the icons"); @@ -176,7 +176,7 @@ headerLabel_->setText(str); } - //Load data + // Load data load(); readSettings(); @@ -192,23 +192,23 @@ if (file_) { fclose(file_); - file_ = 0; + file_ = nullptr; } Path p = current_->logPath(); std::cout << "log: " << p.str() << std::endl; - //Read contents + // Read contents QFile f(QString::fromStdString(p.str())); f.open(QFile::ReadOnly | QFile::Text); QTextStream readStream(&f); textEdit_->appendPlainText(readStream.readAll()); - //textEdit_->appendHtml(formatText(readStream.readAll())); + // textEdit_->appendHtml(formatText(readStream.readAll())); f.close(); - //Set up file watcher + // Set up file watcher file_ = fopen(p.str().c_str(), "r"); if (file_) { fseek(file_, 0, SEEK_END); @@ -222,14 +222,14 @@ if (file_) { fclose(file_); - file_ = 0; + file_ = nullptr; } textEdit_->clear(); if (current_) - current_->logWindow(0); - current_ = 0; + current_->logWindow(nullptr); + current_ = nullptr; writeSettings(); @@ -245,7 +245,7 @@ void MvQLogDialog::slotClear(bool) { - Path p = current_->logPath(); + Path p = current_->logPath(); FILE* f = fopen(p.str().c_str(), "w"); if (f) fclose(f); @@ -264,19 +264,19 @@ void MvQLogDialog::slotDone(FILE*) { watcher_->stop(); - //enable(); + // enable(); std::cout << "done" << std::endl; } void MvQLogDialog::slotReady(const char* buf) { textEdit_->appendPlainText(QString(buf)); - //textEdit_->appendHtml(formatText(QString(buf))); + // textEdit_->appendHtml(formatText(QString(buf))); } QString MvQLogDialog::formatText(QString txt) { - //qDebug() << "add" << txt; + // qDebug() << "add" << txt; QString res; QStringList lst = txt.split("\n"); @@ -284,14 +284,14 @@ res += line + "
"; /*QRegExp rx("\\[(.+)\\]"); - if(rx.indexIn(line) > -1) - { - QString v=rx.cap(1); - res+="" + v + " -"; - res+=line.mid(v.size()+2)+ "
"; - } - else - res+=line + "
";*/ + if(rx.indexIn(line) > -1) + { + QString v=rx.cap(1); + res+="" + v + " -"; + res+=line.mid(v.size()+2)+ "
"; + } + else + res+=line + "
";*/ } return res; @@ -302,7 +302,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-Desktop-LogDialog"); - //We have to clear it so that should not remember all the previous values + // We have to clear it so that should not remember all the previous values settings.clear(); settings.beginGroup("main"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQLogDialog.h metview-5.19.2/metview/src/Desktop/MvQLogDialog.h --- metview-5.17.4/metview/src/Desktop/MvQLogDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQLogDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,16 +24,16 @@ Q_OBJECT public: - virtual ~MvQLogDialog(); + ~MvQLogDialog() override; void close(); static void open(IconObject*); protected: MvQLogDialog(); - void closeEvent(QCloseEvent*); + void closeEvent(QCloseEvent*) override; public slots: - void reject(); + void reject() override; void slotFreeze(bool); void slotClear(bool); void slotReady(const char*); diff -Nru metview-5.17.4/metview/src/Desktop/MvQMessageBox.h metview-5.19.2/metview/src/Desktop/MvQMessageBox.h --- metview-5.17.4/metview/src/Desktop/MvQMessageBox.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQMessageBox.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,5 +16,5 @@ class MvQMessageBox : public QMessageBox { public: - MvQMessageBox(request*, QWidget* parent = 0); + MvQMessageBox(request*, QWidget* parent = nullptr); }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQNewIconWidget.cc metview-5.19.2/metview/src/Desktop/MvQNewIconWidget.cc --- metview-5.17.4/metview/src/Desktop/MvQNewIconWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQNewIconWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -63,10 +63,10 @@ startPos_ = event->pos(); /*QListWidgetItem *item=itemAt(event->pos()); - if(item) - { - startPos_=event->pos(); - }*/ + if(item) + { + startPos_=event->pos(); + }*/ } QListView::mousePressEvent(event); @@ -79,7 +79,7 @@ if (distance >= QApplication::startDragDistance()) { QListWidgetItem* item = itemAt(startPos_); if (item) { - QString cname = item->data(Qt::UserRole).toString(); + QString cname = item->data(Qt::UserRole).toString(); auto* mimeData = new MvQNewIconMimeData(cname, MvQNewIconMimeData::UserDef); auto* drag = new QDrag(this); @@ -115,9 +115,9 @@ QLabel* label; - //In panel mode we need a close button + // In panel mode we need a close button if (selectionMode_ == PanelMode) { - //Top row + // Top row auto* hb = new QHBoxLayout; hb->setSpacing(0); hb->setContentsMargins(0, 0, 0, 0); @@ -138,7 +138,7 @@ this, SIGNAL(closePanel(bool))); } - //Button row + // Button row auto* hbButton = new QHBoxLayout; vb->addLayout(hbButton); hbButton->setSpacing(0); @@ -179,7 +179,7 @@ vb->addSpacing(3); - //Button group for mode selection + // Button group for mode selection modeBg_ = new QButtonGroup(this); modeBg_->setExclusive(true); @@ -214,20 +214,20 @@ // Type widget //--------------------------- - auto* typeW = new QWidget(this); + auto* typeW = new QWidget(this); auto* typeVb = new QVBoxLayout(typeW); - //typeVb->setSpacing(0); + // typeVb->setSpacing(0); typeVb->setContentsMargins(1, 1, 1, 1); - //Type - auto* typeHb = new QHBoxLayout; + // Type + auto* typeHb = new QHBoxLayout; auto* typeLabel = new QLabel(tr("Type: ")); typeHb->addWidget(typeLabel); typeCb_ = new QComboBox(this); typeHb->addWidget(typeCb_, 1); typeVb->addLayout(typeHb); - //Icon + // Icon iconPanel_ = new QStackedWidget(this); typeVb->addWidget(iconPanel_); @@ -242,7 +242,7 @@ connect(iconLists_[key], SIGNAL(iconCreated(QString)), this, SLOT(slotAddToRecentIcons(QString))); - //This is just a selection,. It will not trigger the itemactivated signal. + // This is just a selection,. It will not trigger the itemactivated signal. if (iconLists_[key]->count() > 0) iconLists_[key]->setCurrentRow(0); } @@ -256,14 +256,14 @@ // Search widget //------------------ - auto* searchW = new QWidget(this); + auto* searchW = new QWidget(this); auto* searchVb = new QVBoxLayout(searchW); searchVb->setSpacing(0); searchVb->setContentsMargins(1, 1, 1, 1); auto* searchHb = new QHBoxLayout; - label = new QLabel(tr("Filter:")); - searchLine_ = new QLineEdit(searchW); + label = new QLabel(tr("Filter:")); + searchLine_ = new QLineEdit(searchW); searchHb->addWidget(label); searchHb->addSpacing(2); searchHb->addWidget(searchLine_, 1); @@ -336,7 +336,7 @@ void MvQNewIconPanel::slotTypeChanged(int index) { - QString type = typeCb_->itemData(index).toString(); + QString type = typeCb_->itemData(index).toString(); QMap::iterator it = iconLists_.find(type); if (it != iconLists_.end()) { iconPanel_->setCurrentWidget(it.value()); @@ -379,7 +379,7 @@ searchList_->sortItems(); - //This is just a selection,. It will not trigger the itemactivated signal. + // This is just a selection,. It will not trigger the itemactivated signal. if (searchList_->count() > 0) searchList_->setCurrentRow(0); } @@ -394,7 +394,7 @@ if (index >= 0 && index < modeBg_->buttons().count()) { modeBg_->button(index)->setChecked(true); slotChangeMode(modeBg_->checkedButton()); - //mainPanel_->setCurrentIndex(index); + // mainPanel_->setCurrentIndex(index); } } @@ -425,7 +425,7 @@ recentList_->addItem(item); } - //This is just a selection,. It will not trigger the itemactivated signal. + // This is just a selection,. It will not trigger the itemactivated signal. if (recentList_->count() > 0) recentList_->setCurrentRow(0); } @@ -443,7 +443,7 @@ style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } -//Returns the active mode's current selection +// Returns the active mode's current selection QString MvQNewIconPanel::currentSelection() const { QString s; @@ -455,7 +455,7 @@ } break; case 1: { - QString type = typeCb_->currentText(); + QString type = typeCb_->currentText(); QMap::const_iterator it = iconLists_.find(type); if (it != iconLists_.end()) { if (QListWidgetItem* item = it.value()->currentItem()) { @@ -477,7 +477,7 @@ void MvQNewIconPanel::keyPressEvent(QKeyEvent* event) { - //The search list gets the focus when arrow down or up is pressed + // The search list gets the focus when arrow down or up is pressed if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Up) { if (mainPanel_->currentIndex() == 2) { if (!searchList_->hasFocus()) { @@ -534,7 +534,7 @@ connect(iconWidget_, SIGNAL(iconSelected(QString)), this, SLOT(slotIconSelected(QString))); - //Read settings + // Read settings readSettings(); } @@ -543,8 +543,8 @@ writeSettings(); } -//It is called when return is pressed on the -//dialog. We pick the current selection in the active selection panel. +// It is called when return is pressed on the +// dialog. We pick the current selection in the active selection panel. void MvQNewIconDialog::accept() { selected_ = iconWidget_->currentSelection(); @@ -554,7 +554,7 @@ QDialog::reject(); } -//When an item is clicked or double-clicked in one of the icon lists +// When an item is clicked or double-clicked in one of the icon lists void MvQNewIconDialog::slotIconSelected(QString name) { selected_ = name; @@ -570,7 +570,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-Desktop-NewIconDialog"); - //We have to clear it not to remember all the previous windows + // We have to clear it not to remember all the previous windows settings.clear(); settings.beginGroup("main"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQNewIconWidget.h metview-5.19.2/metview/src/Desktop/MvQNewIconWidget.h --- metview-5.17.4/metview/src/Desktop/MvQNewIconWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQNewIconWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -38,8 +38,8 @@ void iconCreated(QString); protected: - void mousePressEvent(QMouseEvent*); - void mouseMoveEvent(QMouseEvent*); + void mousePressEvent(QMouseEvent*) override; + void mouseMoveEvent(QMouseEvent*) override; QPoint startPos_; }; @@ -56,15 +56,15 @@ }; MvQNewIconPanel(SelectionMode, QWidget* parent = nullptr); - ~MvQNewIconPanel(); + ~MvQNewIconPanel() override; - void next(const IconClass&); + void next(const IconClass&) override; void setCurrentMode(int); int currentMode() const; QString currentSelection() const; - //Observer method - void notifyRecentChanged(); + // Observer method + void notifyRecentChanged() override; void writeSettings(QSettings&); void readSettings(QSettings&); @@ -81,9 +81,9 @@ void closePanel(bool b = true); protected: - void keyPressEvent(QKeyEvent* event); + void keyPressEvent(QKeyEvent* event) override; void updateRecentList(); - void paintEvent(QPaintEvent*); + void paintEvent(QPaintEvent*) override; QStackedWidget* mainPanel_; MvQNewIconListWidget* recentList_; @@ -103,11 +103,11 @@ public: MvQNewIconDialog(QWidget* parent = nullptr); - ~MvQNewIconDialog(); + ~MvQNewIconDialog() override; const IconClass& selected(); public slots: - void accept(); + void accept() override; void slotIconSelected(QString); private: diff -Nru metview-5.17.4/metview/src/Desktop/MvQNoneLine.h metview-5.19.2/metview/src/Desktop/MvQNoneLine.h --- metview-5.17.4/metview/src/Desktop/MvQNoneLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQNoneLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,13 +19,13 @@ { public: MvQNoneLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQNoneLine(); + ~MvQNoneLine() override; - void gray(bool) {} - void mark(bool) {} + void gray(bool) override {} + void mark(bool) override {} - QString currentValue() { return QString(); } + QString currentValue() { return {}; } void addValue(QString) {} - void refresh(const std::vector&) {} + void refresh(const std::vector&) override {} }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQPageView.cc metview-5.19.2/metview/src/Desktop/MvQPageView.cc --- metview-5.17.4/metview/src/Desktop/MvQPageView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQPageView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -44,10 +44,10 @@ setFlag(ItemSendsGeometryChanges); setAcceptHoverEvents(true); - //12x12 pixmaps + // 12x12 pixmaps setupPixmap(); - bRect_ = QRectF(0, 0, 12, 12); + bRect_ = QRectF(0, 0, 12, 12); float delta = 6; switch (type_) { @@ -88,23 +88,23 @@ if (pix_.count() != 0) return; - pix_[TopLeft] = QPixmap(":/desktop/cursor_bdiag.svg"); - pix_[TopMid] = QPixmap(":/desktop/cursor_vert.svg"); - pix_[TopRight] = QPixmap(":/desktop/cursor_fdiag.svg"); - pix_[RightMid] = QPixmap(":/desktop/cursor_horiz.svg"); + pix_[TopLeft] = QPixmap(":/desktop/cursor_bdiag.svg"); + pix_[TopMid] = QPixmap(":/desktop/cursor_vert.svg"); + pix_[TopRight] = QPixmap(":/desktop/cursor_fdiag.svg"); + pix_[RightMid] = QPixmap(":/desktop/cursor_horiz.svg"); pix_[BottomRight] = pix_[TopLeft]; - pix_[BottomMid] = pix_[TopMid]; - pix_[BottomLeft] = pix_[TopRight]; - pix_[LeftMid] = pix_[RightMid]; - - pixHover_[TopLeft] = QPixmap(":/desktop/cursor_bdiag_hover.svg"); - pixHover_[TopMid] = QPixmap(":/desktop/cursor_vert_hover.svg"); - pixHover_[TopRight] = QPixmap(":/desktop/cursor_fdiag_hover.svg"); - pixHover_[RightMid] = QPixmap(":/desktop/cursor_horiz_hover.svg"); + pix_[BottomMid] = pix_[TopMid]; + pix_[BottomLeft] = pix_[TopRight]; + pix_[LeftMid] = pix_[RightMid]; + + pixHover_[TopLeft] = QPixmap(":/desktop/cursor_bdiag_hover.svg"); + pixHover_[TopMid] = QPixmap(":/desktop/cursor_vert_hover.svg"); + pixHover_[TopRight] = QPixmap(":/desktop/cursor_fdiag_hover.svg"); + pixHover_[RightMid] = QPixmap(":/desktop/cursor_horiz_hover.svg"); pixHover_[BottomRight] = pixHover_[TopLeft]; - pixHover_[BottomMid] = pixHover_[TopMid]; - pixHover_[BottomLeft] = pixHover_[TopRight]; - pixHover_[LeftMid] = pixHover_[RightMid]; + pixHover_[BottomMid] = pixHover_[TopMid]; + pixHover_[BottomLeft] = pixHover_[TopRight]; + pixHover_[LeftMid] = pixHover_[RightMid]; } QRectF MvQPageHandlerItem::boundingRect() const @@ -157,17 +157,17 @@ QVariant MvQPageHandlerItem::itemChange(GraphicsItemChange change, const QVariant& value) { /*QRectF r=page_->boundingRect(); - - if(change == ItemPositionHasChanged) - { - switch(type_) - { - case TopMid: r.setTop(pos().y()); break; - default: break; - } - - page_->handlerMoved(r); - }*/ + + if(change == ItemPositionHasChanged) + { + switch(type_) + { + case TopMid: r.setTop(pos().y()); break; + default: break; + } + + page_->handlerMoved(r); + }*/ return QGraphicsItem::itemChange(change, value); } @@ -183,7 +183,7 @@ void MvQPageHandlerItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { - QRectF r = page_->boundingRect(); + QRectF r = page_->boundingRect(); QPointF pp = mapToParent(event->pos()); switch (type_) { @@ -265,7 +265,7 @@ createHandlers(); hide(); - //setAcceptDrops(true); + // setAcceptDrops(true); } QRectF MvQPageSelectionItem::boundingRect() const @@ -275,7 +275,7 @@ void MvQPageSelectionItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { - //painter->fillRect(bRect_,brush_); + // painter->fillRect(bRect_,brush_); painter->setPen(pen_); painter->drawRect(bRect_); @@ -293,9 +293,9 @@ void MvQPageSelectionItem ::createHandlers() { - //Add handlersMvQPageItem:: + // Add handlersMvQPageItem:: if (handlers_.isEmpty()) { - MvQPageHandlerItem* item; + MvQPageHandlerItem* item = nullptr; item = new MvQPageHandlerItem(this, MvQPageHandlerItem::TopLeft); handlers_ << item; @@ -333,7 +333,7 @@ handlerUsed_ = true; } -//Here rect is in item coordiantes +// Here rect is in item coordiantes void MvQPageSelectionItem::handlerMoved(MvQPageHandlerItem* /*handler*/, QRectF rect) { if (!handlerUsed_) @@ -345,7 +345,7 @@ if (superPage_->adjustItemResize(this, rect)) { QPointF dp = rect.topLeft() - bRect_.topLeft(); - bRect_ = QRectF(0, 0, rect.width(), rect.height()); + bRect_ = QRectF(0, 0, rect.width(), rect.height()); setPos(pos() + dp); } @@ -375,7 +375,7 @@ if (handlerUsed_) return; - oriPos_ = pos(); + oriPos_ = pos(); dragPos_ = mapToParent(event->pos()); } @@ -387,7 +387,7 @@ QPointF delta = mapToParent(event->pos()) - dragPos_; QPointF prevPos = pos(); - QPointF pp = pos() + delta; + QPointF pp = pos() + delta; superPage_->adjustItemMove(this, pp); setPos(pp); @@ -429,7 +429,7 @@ foreach (QGraphicsItem* item, superPage_->childItems()) { if (item->isSelected() && item->type() == MvQ::PageItemType) - pages_ << static_cast(item); + pages_ << dynamic_cast(item); } if (pages_.count() == 0) { @@ -439,9 +439,9 @@ QRectF br; QRectF p = pages_.at(0)->boundingRect(); - br = pages_.at(0)->mapToParent(p).boundingRect(); + br = pages_.at(0)->mapToParent(p).boundingRect(); for (int i = 1; i < pages_.count(); i++) { - p = pages_.at(i)->boundingRect(); + p = pages_.at(i)->boundingRect(); br = br.united(pages_.at(i)->mapToParent(p).boundingRect()); } @@ -455,7 +455,7 @@ { if (pages_.count() == 1 && pages_.at(0) == item) { oriPos_ = pos(); - //Event is valid for item!! + // Event is valid for item!! dragPos_ = item->mapToParent(event->pos()); setSelected(true); @@ -504,7 +504,7 @@ view_(view), paperRect_(rect), superPage_(superPage), - viewIcon_(0), + viewIcon_(nullptr), mouseMove_(false) { bRect_ = QRectF(0, 0, @@ -515,16 +515,16 @@ 0.01 * paperRect_.y() * superPage_->boundingRect().height()); setAcceptDrops(true); - //setFlag(ItemIsMovable); + // setFlag(ItemIsMovable); setFlag(QGraphicsItem::ItemIsSelectable); setFlag(QGraphicsItem::ItemIsFocusable); - //setFlag(ItemSendsGeometryChanges); + // setFlag(ItemSendsGeometryChanges); pen_ = QPen(Qt::black); - //pen_=QPen(QColor(8,54,146),1); + // pen_=QPen(QColor(8,54,146),1); pen_.setCosmetic(true); - //brush_=QBrush(QColor(235,235,235,170)); + // brush_=QBrush(QColor(235,235,235,170)); brush_ = QBrush(QColor(222, 230, 240, 160)); selectionPen_ = QPen(Qt::black); @@ -581,9 +581,9 @@ painter->drawPixmap(targetPos, viewPix_); QString name = QString::fromStdString(viewIcon_->name()); - int tw = MvQ::textWidth(fm, name); - float tx = bRect_.center().x() - tw / 2; - float ty = bRect_.center().y() + 0.5 * ph + 3 + fm.height(); + int tw = MvQ::textWidth(fm, name); + float tx = bRect_.center().x() - tw / 2; + float ty = bRect_.center().y() + 0.5 * ph + 3 + fm.height(); painter->setPen(Qt::black); @@ -623,9 +623,9 @@ void MvQPageItem::keyPressEvent(QKeyEvent* event) { - //qDebug() << "key" << event->key(); + // qDebug() << "key" << event->key(); if (event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) { - //qDebug() << "delete item"; + // qDebug() << "delete item"; } } @@ -634,11 +634,11 @@ viewIcon_ = obj; if (viewIcon_) { - viewPix_ = MvQIconProvider::pixmap(viewIcon_, 32); + viewPix_ = MvQIconProvider::pixmap(viewIcon_, 32); viewPixHalf_ = MvQIconProvider::pixmap(viewIcon_, 16); } else { - viewPix_ = QPixmap(); + viewPix_ = QPixmap(); viewPixHalf_ = QPixmap(); } @@ -657,8 +657,8 @@ setPos(0.01 * paperRect_.x() * superPage_->boundingRect().width(), 0.01 * paperRect_.y() * superPage_->boundingRect().height()); - //foreach(MvQPageHandlerItem *h,handlers_) - // h->updatePosition(); + // foreach(MvQPageHandlerItem *h,handlers_) + // h->updatePosition(); } void MvQPageItem::adjustPaperRect() @@ -679,28 +679,28 @@ float hRatio = rectNew.height() / rectOri.height(); float wRatio = rectNew.width() / rectOri.width(); - float top = rectNew.top() + (itemRect.top() - rectOri.top()) * hRatio; + float top = rectNew.top() + (itemRect.top() - rectOri.top()) * hRatio; float bottom = rectNew.bottom() - (rectOri.bottom() - itemRect.bottom()) * hRatio; - float left = rectNew.left() + (itemRect.left() - rectOri.left()) * wRatio; - float right = rectNew.right() - (rectOri.right() - itemRect.right()) * wRatio; + float left = rectNew.left() + (itemRect.left() - rectOri.left()) * wRatio; + float right = rectNew.right() - (rectOri.right() - itemRect.right()) * wRatio; - return QRectF(left, top, right - left, bottom - top); + return {left, top, right - left, bottom - top}; } void MvQPageItem::adjustSizeToSelector(QRectF rectNew, QRectF rectOri) { - /*QRectF itemRect=mapToParent(boundingRect()).boundingRect(); - - float hRatio=rectNew.height()/rectOri.height(); - float wRatio=rectNew.width()/rectOri.width(); - - float top=rectNew.top()+(itemRect.top()-rectOri.top())*hRatio; - float bottom=rectNew.bottom()-(rectOri.bottom()-itemRect.bottom())*hRatio; - float left=rectNew.left()+(itemRect.left()-rectOri.left())*wRatio; - float right=rectNew.right()-(rectOri.right()-itemRect.right())*wRatio; - - itemRect=QRectF(left,top,right-left,bottom-top);*/ + /*QRectF itemRect=mapToParent(boundingRect()).boundingRect(); + + float hRatio=rectNew.height()/rectOri.height(); + float wRatio=rectNew.width()/rectOri.width(); + + float top=rectNew.top()+(itemRect.top()-rectOri.top())*hRatio; + float bottom=rectNew.bottom()-(rectOri.bottom()-itemRect.bottom())*hRatio; + float left=rectNew.left()+(itemRect.left()-rectOri.left())*wRatio; + float right=rectNew.right()-(rectOri.right()-itemRect.right())*wRatio; + + itemRect=QRectF(left,top,right-left,bottom-top);*/ QRectF itemRect = rectToSelector(rectNew, rectOri); @@ -712,21 +712,21 @@ { prepareGeometryChange(); - //QPointF dp=bRect_.topLeft()-rect.topLeft(); + // QPointF dp=bRect_.topLeft()-rect.topLeft(); bRect_ = QRectF(0, 0, rect.width(), rect.height()); setPos(rect.topLeft()); adjustPaperRect(); /*float w=superPage_->boundingRect().width(); - float h=superPage_->boundingRect().height(); - - QRectF oriRect=paperRect_; - - paperRect_=QRectF(100.*pos().x()/w, - 100.*pos().y()/h, - 100.*rect.width()/w, - 100.*rect.height()/h);*/ + float h=superPage_->boundingRect().height(); + + QRectF oriRect=paperRect_; + + paperRect_=QRectF(100.*pos().x()/w, + 100.*pos().y()/h, + 100.*rect.width()/w, + 100.*rect.height()/h);*/ } void MvQPageItem::moveBy(QPointF delta) @@ -750,7 +750,7 @@ if (obj && MvQPageView::matchClass(obj->className())) { setViewIcon(obj); - //view_->pageResized(); + // view_->pageResized(); } } } @@ -763,10 +763,10 @@ void MvQPageItem::paperRect(double& top, double& left, double& bottom, double& right) { - top = paperRect_.y(); - left = paperRect_.x(); + top = paperRect_.y(); + left = paperRect_.x(); bottom = paperRect_.bottomLeft().y(); - right = paperRect_.topRight().x(); + right = paperRect_.topRight().x(); } void MvQPageItem::addSubPaperRect(MvQPageItem* item, QRectF r) @@ -889,7 +889,7 @@ { float wRatio = size.width() / paperRect_.width(); float hRatio = size.height() / paperRect_.height(); - scaling_ = (wRatio < hRatio) ? wRatio : hRatio; + scaling_ = (wRatio < hRatio) ? wRatio : hRatio; prepareGeometryChange(); @@ -908,14 +908,14 @@ QPointF MvQSuperPageItem::itemToPercentage(QPointF pp) { - return QPointF(100. * pp.x() / (paperRect_.width() * scaling_), - 100. * pp.y() / (paperRect_.height() * scaling_)); + return {100. * pp.x() / (paperRect_.width() * scaling_), + 100. * pp.y() / (paperRect_.height() * scaling_)}; } QPointF MvQSuperPageItem::percentageToItem(QPointF pp) { - return QPointF(0.01 * pp.x() * paperRect_.width() * scaling_, - 0.01 * pp.y() * paperRect_.height() * scaling_); + return {0.01 * pp.x() * paperRect_.width() * scaling_, + 0.01 * pp.y() * paperRect_.height() * scaling_}; } @@ -940,7 +940,7 @@ double xn = rint(pp.x() / snapX_); double yn = rint(pp.y() / snapY_); - pp = percentageToItem(QPointF(xn * snapX_, yn * snapY_)); + pp = percentageToItem(QPointF(xn * snapX_, yn * snapY_)); if (pp.x() < 0) pp.setX(0); @@ -977,8 +977,8 @@ pp = r.topLeft(); QPointF delta(r.right() - bRect_.width(), 0); delta = itemToPercentage(delta); - xn = ceil(delta.x() / snapX_); - pp = itemToPercentage(pp); + xn = ceil(delta.x() / snapX_); + pp = itemToPercentage(pp); pp -= QPointF(xn * snapX_, 0); pp = percentageToItem(pp); r.moveLeft(pp.x()); @@ -991,8 +991,8 @@ pp = r.bottomRight(); QPointF delta(0, r.bottom() - bRect_.height()); delta = itemToPercentage(delta); - yn = ceil(delta.y() / snapY_); - pp = itemToPercentage(pp); + yn = ceil(delta.y() / snapY_); + pp = itemToPercentage(pp); pp -= QPointF(0, yn * snapY_); pp = percentageToItem(pp); r.moveBottom(pp.y()); @@ -1002,7 +1002,7 @@ bool MvQSuperPageItem::adjustItemMove(QGraphicsItem* item, QPointF& pp) { - //r is in item coordinates + // r is in item coordinates QRectF r = mapFromItem(item, item->boundingRect()).boundingRect(); r.moveTo(pp); @@ -1028,8 +1028,8 @@ if (snap_) { r.moveTo(pp); - r = snapToGrid(r); - pp = r.topLeft(); + r = snapToGrid(r); + pp = r.topLeft(); adjusted = true; } @@ -1042,7 +1042,7 @@ if (r.width() < 8 || r.height() < 8) return false; - //r is in item coordinates! + // r is in item coordinates! r = mapFromItem(item, r).boundingRect(); r = bRect_.intersected(r); @@ -1070,11 +1070,11 @@ { bool changed = false; if (snapX_ != x) { - snapX_ = x; + snapX_ = x; changed = true; } if (snapY_ != y) { - snapY_ = y; + snapY_ = y; changed = true; } if (snap_ && changed) @@ -1092,7 +1092,7 @@ QList lst; foreach (QGraphicsItem* item, childItems()) { if (item->type() == MvQ::PageItemType) - lst << static_cast(item); + lst << dynamic_cast(item); } return lst; } @@ -1145,7 +1145,7 @@ if (orientation_ == Qt::Horizontal) { for (int x = 0; x <= 100; x += 10) { - float xp = bRect_.width() * x / 100.; + float xp = bRect_.width() * x / 100.; QString str = QString::number(x); QRectF br; @@ -1173,7 +1173,7 @@ } else { for (int y = 0; y <= 100; y += 10) { - float yp = bRect_.height() * y / 100.; + float yp = bRect_.height() * y / 100.; QString str = QString::number(y); QRectF br; @@ -1231,11 +1231,11 @@ MvQPageView::MvQPageView(const std::vector& classes, QUndoStack* undoStack, QWidget* parent) : QGraphicsView(parent), undoStack_(undoStack), - scene_(0), - superPage_(0), - selector_(0), - rulerH_(0), - rulerV_(0) + scene_(nullptr), + superPage_(nullptr), + selector_(nullptr), + rulerH_(nullptr), + rulerV_(nullptr) { classes_ = classes; @@ -1277,15 +1277,15 @@ if (superPage_) { scene()->removeItem(superPage_); delete superPage_; - superPage_ = 0; + superPage_ = nullptr; scene()->removeItem(rulerH_); delete rulerH_; - rulerH_ = 0; + rulerH_ = nullptr; scene()->removeItem(rulerV_); delete rulerV_; - rulerV_ = 0; + rulerV_ = nullptr; - selector_ = 0; + selector_ = nullptr; undoStack_->clear(); } } @@ -1352,10 +1352,10 @@ rulerH_->adjustSize(); rulerV_->adjustSize(); - //Update selector + // Update selector selection(); - //Set the scenerect + // Set the scenerect QRectF br = superPage_->boundingRect(); br.adjust(-dw - 4, -dh - 4, 0, 0); scene_->setSceneRect(br); @@ -1364,7 +1364,7 @@ MvQPageItem* MvQPageView::addPage(double x, double y, double w, double h) { if (!superPage_) - return 0; + return nullptr; auto* cmd = new MvQPageAddCommand(this, x, y, w, h); undoStack_->push(cmd); @@ -1374,7 +1374,7 @@ void MvQPageView::pagesResized(QList pages, QList oriPaperRects) { - auto* cmdParent = new MvQUndoCommand(this, 0); + auto* cmdParent = new MvQUndoCommand(this, nullptr); cmdParent->setText("resize"); for (int i = 0; i < pages.count(); i++) { @@ -1388,7 +1388,7 @@ void MvQPageView::pagesMoved(QList pages, const QPointF& delta) { - auto* cmdParent = new MvQUndoCommand(this, 0); + auto* cmdParent = new MvQUndoCommand(this, nullptr); cmdParent->setText("move"); foreach (MvQPageItem* item, pages) { @@ -1405,7 +1405,7 @@ if (!selector_ || !selector_->hasPages()) return; - auto* cmdParent = new MvQUndoCommand(this, 0); + auto* cmdParent = new MvQUndoCommand(this, nullptr); cmdParent->setText("duplicate"); foreach (MvQPageItem* item, selector_->pages()) { @@ -1420,7 +1420,7 @@ if (!selector_ || !selector_->hasPages()) return; - auto* cmdParent = new MvQUndoCommand(this, 0); + auto* cmdParent = new MvQUndoCommand(this, nullptr); cmdParent->setText("delete"); foreach (MvQPageItem* item, selector_->pages()) { @@ -1444,7 +1444,7 @@ if (!selector_ || !selector_->hasPages()) return; - auto* cmdParent = new MvQUndoCommand(this, 0); + auto* cmdParent = new MvQUndoCommand(this, nullptr); cmdParent->setText("split"); foreach (MvQPageItem* item, selector_->pages()) { @@ -1459,10 +1459,10 @@ if (!selector_ || !selector_->hasPages()) return; - auto* cmdParent = new MvQUndoCommand(this, 0); + auto* cmdParent = new MvQUndoCommand(this, nullptr); cmdParent->setText("expand"); - QRectF selRect = selector_->mapToParent(selector_->boundingRect()).boundingRect(); + QRectF selRect = selector_->mapToParent(selector_->boundingRect()).boundingRect(); QRectF expandRect = superPage_->boundingRect(); foreach (MvQPageItem* item, selector_->pages()) { @@ -1498,7 +1498,7 @@ if (!hasSub) return; - auto* cmdParent = new MvQUndoCommand(this, 0); + auto* cmdParent = new MvQUndoCommand(this, nullptr); cmdParent->setText("disconnect"); foreach (MvQPageItem* item, selector_->pages()) { @@ -1586,7 +1586,7 @@ { oriRect_ = page->paperRect(); - page_ = view_->superPage()->addPage(oriRect_.x(), oriRect_.y(), oriRect_.width(), oriRect_.height()); + page_ = view_->superPage()->addPage(oriRect_.x(), oriRect_.y(), oriRect_.width(), oriRect_.height()); page_->setViewIcon(page->viewIcon()); setText("Add"); } @@ -1684,7 +1684,7 @@ MvQUndoCommand(view, parent), page_(page) { - toPos_ = page_->paperRect().topLeft(); + toPos_ = page_->paperRect().topLeft(); fromPos_ = toPos_ - page_->itemToPaper(delta); setText("Move"); @@ -1709,23 +1709,23 @@ QUndoCommand* parent) : MvQUndoCommand(view, parent), pages_(pages), - parentItem_(0) + parentItem_(nullptr) { if (pages_.count() > 0) { firstOriRect_ = pages_.at(0)->paperRect(); - parentItem_ = pages_.at(0)->parentItem(); + parentItem_ = pages_.at(0)->parentItem(); } setText("Join"); } void MvQPageJoinCommand::redo() { - MvQPageItem* first = 0; + MvQPageItem* first = nullptr; QRectF joinedRect; foreach (MvQPageItem* item, pages_) { if (!first) { - first = item; + first = item; joinedRect = item->paperRect(); } else { @@ -1743,7 +1743,7 @@ void MvQPageJoinCommand::undo() { - MvQPageItem* first = 0; + MvQPageItem* first = nullptr; foreach (MvQPageItem* item, pages_) { if (!first) { @@ -1777,7 +1777,7 @@ return; if (splitPages_.count() == 0) { - QRectF r = page_->paperRect(); + QRectF r = page_->paperRect(); double dx = r.width() / column_; double dy = r.height() / row_; @@ -1825,12 +1825,12 @@ void MvQPageConnectCommand::redo() { - MvQPageItem* first = 0; + MvQPageItem* first = nullptr; QRectF joinedRect; foreach (MvQPageItem* item, pages_) { if (!first) { - first = item; + first = item; joinedRect = item->paperRect(); } else { @@ -1856,7 +1856,7 @@ void MvQPageConnectCommand::undo() { - MvQPageItem* first = 0; + MvQPageItem* first = nullptr; foreach (MvQPageItem* item, pages_) { if (!first) { first = item; @@ -1889,8 +1889,8 @@ pages_.clear(); QRectF pf = page_->paperRect(); - float w = pf.width(); - float h = pf.height(); + float w = pf.width(); + float h = pf.height(); QList subR = page_->subPaperRects(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQPageView.h metview-5.19.2/metview/src/Desktop/MvQPageView.h --- metview-5.17.4/metview/src/Desktop/MvQPageView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQPageView.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,9 +32,9 @@ class MvQUndoCommand : public QUndoCommand { public: - MvQUndoCommand(MvQPageView*, QUndoCommand* parent = 0); - virtual void undo(); - void redo(); + MvQUndoCommand(MvQPageView*, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; protected: MvQPageView* view_; @@ -43,10 +43,10 @@ class MvQPageAddCommand : public MvQUndoCommand { public: - MvQPageAddCommand(MvQPageView*, float, float, float, float, QUndoCommand* parent = 0); - MvQPageAddCommand(MvQPageView*, MvQPageItem*, QUndoCommand* parent = 0); - void undo(); - void redo(); + MvQPageAddCommand(MvQPageView*, float, float, float, float, QUndoCommand* parent = nullptr); + MvQPageAddCommand(MvQPageView*, MvQPageItem*, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; MvQPageItem* page() const { return page_; } protected: @@ -57,9 +57,9 @@ class MvQPageDeleteCommand : public MvQUndoCommand { public: - MvQPageDeleteCommand(MvQPageView*, MvQPageItem*, QUndoCommand* parent = 0); - void undo(); - void redo(); + MvQPageDeleteCommand(MvQPageView*, MvQPageItem*, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; protected: MvQPageItem* page_; @@ -68,9 +68,9 @@ class MvQPageResizeCommand : public MvQUndoCommand { public: - MvQPageResizeCommand(MvQPageView*, MvQPageItem*, const QRectF&, const QRectF&, QUndoCommand* parent = 0); - void undo(); - void redo(); + MvQPageResizeCommand(MvQPageView*, MvQPageItem*, const QRectF&, const QRectF&, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; protected: MvQPageItem* page_; @@ -87,10 +87,10 @@ Id = 1 }; - MvQPageMoveCommand(MvQPageView*, MvQPageItem*, const QPointF&, QUndoCommand* parent = 0); - void undo(); - void redo(); - int id() const { return Id; } + MvQPageMoveCommand(MvQPageView*, MvQPageItem*, const QPointF&, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; + int id() const override { return Id; } protected: MvQPageItem* page_; @@ -102,9 +102,9 @@ class MvQPageExpandCommand : public MvQUndoCommand { public: - MvQPageExpandCommand(MvQPageView*, MvQPageItem*, QRectF, QUndoCommand* parent = 0); - void undo(); - void redo(); + MvQPageExpandCommand(MvQPageView*, MvQPageItem*, QRectF, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; MvQPageItem* page() const { return page_; } protected: @@ -116,9 +116,9 @@ class MvQPageJoinCommand : public MvQUndoCommand { public: - MvQPageJoinCommand(MvQPageView*, QList, QUndoCommand* parent = 0); - void undo(); - void redo(); + MvQPageJoinCommand(MvQPageView*, QList, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; protected: QList pages_; @@ -129,9 +129,9 @@ class MvQPageSplitCommand : public MvQUndoCommand { public: - MvQPageSplitCommand(MvQPageView*, MvQPageItem*, int, int, QUndoCommand* parent = 0); - void undo(); - void redo(); + MvQPageSplitCommand(MvQPageView*, MvQPageItem*, int, int, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; protected: MvQPageItem* page_; @@ -143,9 +143,9 @@ class MvQPageConnectCommand : public MvQUndoCommand { public: - MvQPageConnectCommand(MvQPageView*, QList, QUndoCommand* parent = 0); - void undo(); - void redo(); + MvQPageConnectCommand(MvQPageView*, QList, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; protected: QList pages_; @@ -155,9 +155,9 @@ class MvQPageDisconnectCommand : public MvQUndoCommand { public: - MvQPageDisconnectCommand(MvQPageView*, MvQPageItem*, QUndoCommand* parent = 0); - void undo(); - void redo(); + MvQPageDisconnectCommand(MvQPageView*, MvQPageItem*, QUndoCommand* parent = nullptr); + void undo() override; + void redo() override; protected: MvQPageItem* page_; @@ -170,8 +170,8 @@ { public: MvQPageSelectionItem(MvQPageView*, MvQSuperPageItem*); - QRectF boundingRect() const; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + QRectF boundingRect() const override; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; void createHandlers(); void handlerPressed(MvQPageHandlerItem*); void handlerMoved(MvQPageHandlerItem*, QRectF); @@ -182,10 +182,10 @@ void pagePressed(MvQPageItem*, QGraphicsSceneMouseEvent*); protected: - void dropEvent(QGraphicsSceneDragDropEvent* event); - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseMoveEvent(QGraphicsSceneMouseEvent*); - void mouseReleaseEvent(QGraphicsSceneMouseEvent*); + void dropEvent(QGraphicsSceneDragDropEvent* event) override; + void mousePressEvent(QGraphicsSceneMouseEvent*) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent*) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override; void adjust(QRectF); MvQPageView* view_; @@ -217,18 +217,18 @@ LeftMid }; MvQPageHandlerItem(MvQPageSelectionItem*, HandlerType); - QRectF boundingRect() const; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + QRectF boundingRect() const override; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; void updatePosition(); protected: void setupPixmap(); - QVariant itemChange(GraphicsItemChange, const QVariant&); - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseMoveEvent(QGraphicsSceneMouseEvent*); - void mouseReleaseEvent(QGraphicsSceneMouseEvent*); - void hoverEnterEvent(QGraphicsSceneHoverEvent*); - void hoverLeaveEvent(QGraphicsSceneHoverEvent*); + QVariant itemChange(GraphicsItemChange, const QVariant&) override; + void mousePressEvent(QGraphicsSceneMouseEvent*) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent*) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override; + void hoverEnterEvent(QGraphicsSceneHoverEvent*) override; + void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override; MvQPageSelectionItem* page_; HandlerType type_; @@ -260,8 +260,8 @@ }; MvQPageItem(MvQPageView*, QRectF, MvQSuperPageItem*); - QRectF boundingRect() const; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + QRectF boundingRect() const override; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; IconObjectH viewIcon() const { return viewIcon_; } void setViewIcon(IconObjectH); void adjustSize(); @@ -275,7 +275,7 @@ void addSubPaperRectInPageCoords(double, double, double, double); QList subPaperRects() const; MvQPageItem* subPage(int) const; - int type() const { return Type; } + int type() const override { return Type; } QRectF rectToSelector(QRectF, QRectF); void adjustSizeToSelector(QRectF, QRectF); void resize(QRectF); @@ -285,15 +285,15 @@ QPointF paperToItem(QPointF); protected: - void keyPressEvent(QKeyEvent* event); - void mousePressEvent(QGraphicsSceneMouseEvent*); - void dropEvent(QGraphicsSceneDragDropEvent* event); + void keyPressEvent(QKeyEvent* event) override; + void mousePressEvent(QGraphicsSceneMouseEvent*) override; + void dropEvent(QGraphicsSceneDragDropEvent* event) override; void adjustPaperRect(); - QVariant itemChange(GraphicsItemChange, const QVariant&); + QVariant itemChange(GraphicsItemChange, const QVariant&) override; MvQPageView* view_; QRectF paperRect_; - //QList subPages_; + // QList subPages_; QList > sub_; QRectF bRect_; MvQSuperPageItem* superPage_; @@ -315,8 +315,8 @@ public: MvQSuperPageItem(MvQPageView*, double, double, bool, float, float, bool); - QRectF boundingRect() const; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + QRectF boundingRect() const override; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; QRectF paperRect() const { return paperRect_; } MvQPageItem* addPage(double x, double y, double w, double h); @@ -355,8 +355,8 @@ { public: MvQRulerItem(MvQPageView*, Qt::Orientation); - QRectF boundingRect() const; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + QRectF boundingRect() const override; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; void adjustSize(); protected: @@ -376,7 +376,7 @@ Q_OBJECT public: - MvQPageView(const std::vector&, QUndoStack*, QWidget* parent = 0); + MvQPageView(const std::vector&, QUndoStack*, QWidget* parent = nullptr); void clear(); void clearPages(); @@ -411,7 +411,7 @@ void selectionChanged(int); protected: - void resizeEvent(QResizeEvent*); + void resizeEvent(QResizeEvent*) override; void adjustSize(); QUndoStack* undoStack_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQPaletteHelp.cc metview-5.19.2/metview/src/Desktop/MvQPaletteHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQPaletteHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQPaletteHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -47,7 +47,7 @@ int MvQPaletteModel::rowCount(const QModelIndex& parent) const { - //Parent is the root: + // Parent is the root: if (!parent.isValid()) { return MvQPaletteDb::instance()->items().count(); } @@ -59,7 +59,7 @@ { int row = index.row(); if (row < 0 || row >= MvQPaletteDb::instance()->items().count()) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { if (index.column() == 0) @@ -77,7 +77,7 @@ return MvQPaletteDb::instance()->items()[row]->name(); } - return QVariant(); + return {}; } QVariant MvQPaletteModel::headerData(const int section, const Qt::Orientation orient, const int role) const @@ -92,30 +92,30 @@ case 1: return "Name"; default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } QModelIndex MvQPaletteModel::index(int row, int column, const QModelIndex& parent) const { if (row < 0 || column < 0) { - return QModelIndex(); + return {}; } - //When parent is the root this index refers to a node or server + // When parent is the root this index refers to a node or server if (!parent.isValid()) { return createIndex(row, column); } - return QModelIndex(); + return {}; } QModelIndex MvQPaletteModel::parent(const QModelIndex& /*child*/) const { - return QModelIndex(); + return {}; } void MvQPaletteModel::setOriginFilter(QString s) @@ -196,16 +196,16 @@ painter->save(); if (index.column() == 0) { - //Background + // Background QStyleOptionViewItem vopt(option); initStyleOption(&vopt, index); - const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); + const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); const QWidget* widget = vopt.widget; - //painter->fillRect(option.rect,QColor(238,238,238)); + // painter->fillRect(option.rect,QColor(238,238,238)); - //We render everything with the default method + // We render everything with the default method style->drawControl(QStyle::CE_ItemViewItem, &vopt, painter, widget); int row = index.data(Qt::DisplayRole).toInt(); @@ -223,9 +223,9 @@ QStyledItemDelegate::paint(painter, option, index); } - //Render the horizontal border for rows. We only render the top border line. - //With this technique we miss the bottom border line of the last row!!! - //QRect fullRect=QRect(0,option.rect.y(),painter->device()->width(),option.rect.height()); + // Render the horizontal border for rows. We only render the top border line. + // With this technique we miss the bottom border line of the last row!!! + // QRect fullRect=QRect(0,option.rect.y(),painter->device()->width(),option.rect.height()); QRect bgRect = option.rect; painter->setPen(borderCol_); painter->drawLine(bgRect.topLeft(), bgRect.topRight()); @@ -237,9 +237,9 @@ { QSize s = QStyledItemDelegate::sizeHint(option, index); if (index.column() == 0) - return QSize(180, s.height() + 2); + return {180, s.height() + 2}; - return QSize(s.width(), s.height() + 2); + return {s.width(), s.height() + 2}; } @@ -255,7 +255,7 @@ { auto* vb = new QVBoxLayout(this); - auto *topHb = new QHBoxLayout(this); + auto* topHb = new QHBoxLayout(this); vb->addLayout(topHb); topHb->addStretch(1); @@ -277,29 +277,29 @@ filterGrid_ = new QGridLayout(); vb->addLayout(filterGrid_); - int cbWidth = 42; //number of characters! + int cbWidth = 42; // number of characters! - //name + // name int row = 0; filterGrid_->addWidget(new QLabel(tr("Name:"), this), row, 0); filterGrid_->setContentsMargins(1, 1, 1, 1); filterGrid_->setVerticalSpacing(2); nameLe_ = new QLineEdit(this); - //nameLe_->setPlaceholderText(""); + // nameLe_->setPlaceholderText(""); #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) nameLe_->setClearButtonEnabled(true); #endif - filterGrid_->addWidget(nameLe_, row, 1,1,2); + filterGrid_->addWidget(nameLe_, row, 1, 1, 2); -// nameResetTb_ = new QToolButton(this); -// nameResetTb_->setIcon(QPixmap(":/desktop/undo.svg")); -// nameResetTb_->setAutoRaise(true); -// nameResetTb_->setToolTip(tr("Clear filter")); -// filterGrid_->addWidget(nameResetTb_, row, 2); + // nameResetTb_ = new QToolButton(this); + // nameResetTb_->setIcon(QPixmap(":/desktop/undo.svg")); + // nameResetTb_->setAutoRaise(true); + // nameResetTb_->setToolTip(tr("Clear filter")); + // filterGrid_->addWidget(nameResetTb_, row, 2); row++; - //origin + // origin filterGrid_->addWidget(new QLabel(tr("Origin:"), this), row, 0); filterGrid_->setContentsMargins(1, 1, 1, 1); filterGrid_->setVerticalSpacing(2); @@ -318,7 +318,7 @@ filterGrid_->addWidget(originResetTb_, row, 2); row++; - //colour + // colour filterGrid_->addWidget(new QLabel(tr("Colour:"), this), row, 0); colourCb_ = new QComboBox(this); @@ -335,7 +335,7 @@ filterGrid_->addWidget(colourResetTb_, row, 2); row++; - //Num of colours in palette + // Num of colours in palette filterGrid_->addWidget(new QLabel(tr("Count:"), this), row, 0); numCb_ = new QComboBox(this); @@ -358,7 +358,7 @@ row++; - //params + // params filterGrid_->addWidget(new QLabel(tr("Parameter:"), this), row, 0); paramCb_ = new QComboBox(this); @@ -378,7 +378,7 @@ filterGrid_->setColumnStretch(1, 1); - //tree view and model + // tree view and model tree_ = new QTreeView(this); tree_->setRootIsDecorated(false); @@ -413,8 +413,8 @@ connect(nameLe_, SIGNAL(textChanged(QString)), this, SLOT(slotNameFilter(QString))); -// connect(nameResetTb_, SIGNAL(clicked()), -// nameLe_, SLOT(clear())); + // connect(nameResetTb_, SIGNAL(clicked()), + // nameLe_, SLOT(clear())); connect(originCb_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotOriginFilter(int))); @@ -443,7 +443,7 @@ connect(tree_->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(slotItemSelected(QModelIndex, QModelIndex))); - //Init the button states!! + // Init the button states!! checkButtonState(); // init filters visibility @@ -544,10 +544,10 @@ void MvQPaletteSelectionWidget::showFilters(bool visible) { - for (int i=1; i < filterGrid_->rowCount(); i++) { - for (int j=0; j < 3; j++) { + for (int i = 1; i < filterGrid_->rowCount(); i++) { + for (int j = 0; j < 3; j++) { if (QLayoutItem* item = filterGrid_->itemAtPosition(i, j)) { - if (QWidget *w = item->widget()) { + if (QWidget* w = item->widget()) { w->setVisible(visible); } } @@ -578,7 +578,7 @@ void MvQPaletteSelectionWidget::checkButtonState() { - //nameResetTb_->setEnabled(!nameLe_->text().isEmpty()); + // nameResetTb_->setEnabled(!nameLe_->text().isEmpty()); originResetTb_->setEnabled(originCb_->currentText() != "ANY"); colourResetTb_->setEnabled(colourCb_->currentText() != "ANY"); numResetTb_->setEnabled(numCb_->currentText() != "ANY"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQPaletteHelp.h metview-5.19.2/metview/src/Desktop/MvQPaletteHelp.h --- metview-5.17.4/metview/src/Desktop/MvQPaletteHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQPaletteHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -36,16 +36,16 @@ class MvQPaletteDelegate : public QStyledItemDelegate { public: - MvQPaletteDelegate(QWidget* parent = 0); + MvQPaletteDelegate(QWidget* parent = nullptr); void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; + const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; protected: QColor borderCol_; }; -//Model to dislay/select the suites +// Model to dislay/select the suites class MvQPaletteModel : public QAbstractItemModel { public: @@ -54,17 +54,17 @@ SortRole = Qt::UserRole + 1 }; - explicit MvQPaletteModel(QObject* parent = 0); - ~MvQPaletteModel(); + explicit MvQPaletteModel(QObject* parent = nullptr); + ~MvQPaletteModel() override; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void setOriginFilter(QString s); void setColourFilter(QString s); @@ -87,7 +87,7 @@ { Q_OBJECT public: - MvQPaletteSelectionWidget(QWidget* parent = 0); + MvQPaletteSelectionWidget(QWidget* parent = nullptr); void setCurrent(const std::string&); protected slots: @@ -122,7 +122,7 @@ QComboBox* numCb_; QComboBox* paramCb_; - //QToolButton* nameResetTb_; + // QToolButton* nameResetTb_; QToolButton* originResetTb_; QToolButton* colourResetTb_; QToolButton* numResetTb_; @@ -139,17 +139,17 @@ public: MvQPaletteHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQPaletteHelp() {} + ~MvQPaletteHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget() { return selector_; } + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override { return selector_; } public slots: void slotSelected(int); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; private: MvQPaletteSelectionWidget* selector_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQPaletteLine.cc metview-5.19.2/metview/src/Desktop/MvQPaletteLine.cc --- metview-5.17.4/metview/src/Desktop/MvQPaletteLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQPaletteLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ owner_(owner) {} protected: - void mousePressEvent(QMouseEvent*) + void mousePressEvent(QMouseEvent*) override { owner_->widgetClicked(); } @@ -44,11 +44,11 @@ { MvQPaletteDb::instance(); - auto* w = new MvQPaletteLineWidget(this, parentWidget_); + auto* w = new MvQPaletteLineWidget(this, parentWidget_); auto* hb = new QHBoxLayout(w); hb->setContentsMargins(0, 0, 0, 0); - palPixLabel_ = new QLabel(w); + palPixLabel_ = new QLabel(w); palNameLabel_ = new QLabel(w); hb->addWidget(palPixLabel_); hb->addWidget(palNameLabel_, 1); @@ -91,7 +91,7 @@ palPixLabel_->setPixmap(QPixmap()); palNameLabel_->clear(); - //changed_ = false; + // changed_ = false; } void MvQPaletteLine::slotHelperEdited(const std::vector& values) @@ -122,12 +122,12 @@ setCustomColour(MvQPalette::magics(values[0]),name,name,true); #endif - //If the current index did not change the slotCurrentChanged() was - //not called, so here we need to notify the owner about the change!! - //if(colCb_->currentIndex() == currentPrev) + // If the current index did not change the slotCurrentChanged() was + // not called, so here we need to notify the owner about the change!! + // if(colCb_->currentIndex() == currentPrev) //{ // owner_.set(param_.name(),name.toStdString()); - //} + // } } } diff -Nru metview-5.17.4/metview/src/Desktop/MvQPaletteLine.h metview-5.19.2/metview/src/Desktop/MvQPaletteLine.h --- metview-5.17.4/metview/src/Desktop/MvQPaletteLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQPaletteLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,19 +23,19 @@ public: MvQPaletteLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQPaletteLine() {} + ~MvQPaletteLine() override = default; - //QString currentValue() {return QString();} - //void addValue(QString) {} + // QString currentValue() {return QString();} + // void addValue(QString) {} - void refresh(const std::vector&); + void refresh(const std::vector&) override; void widgetClicked(); public slots: - void slotHelperEdited(const std::vector&); + void slotHelperEdited(const std::vector&) override; protected: - void next(const MvIconParameter&, const char* first, const char* second); + void next(const MvIconParameter&, const char* first, const char* second) override; void updateHelper(); QPixmap pix_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQPathWidget.cc metview-5.19.2/metview/src/Desktop/MvQPathWidget.cc --- metview-5.17.4/metview/src/Desktop/MvQPathWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQPathWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -58,8 +58,8 @@ QString s = text(); if (!s.isEmpty()) { - //Folder *f=Folder::folder(s.toStdString(),false); - //if(f && !f->locked()) + // Folder *f=Folder::folder(s.toStdString(),false); + // if(f && !f->locked()) //{ Qt::DropAction dropAction = event->proposedAction(); MvQDropTarget::Instance()->reset(s, (dropAction == Qt::MoveAction)); @@ -136,11 +136,11 @@ MvQPathWidget::MvQPathWidget(QWidget* parent) : QWidget(parent), - actionReload_(0), - reloadTb_(0), - bookmarkTb_(0), - emptyLabelIcon_(0), - emptyLabel_(0) + actionReload_(nullptr), + reloadTb_(nullptr), + bookmarkTb_(nullptr), + emptyLabelIcon_(nullptr), + emptyLabel_(nullptr) { layout_ = new QHBoxLayout(this); layout_->setSpacing(0); @@ -180,23 +180,23 @@ void MvQPathWidget::clearLayout() { - QLayoutItem* item; - while ((item = layout_->takeAt(0)) != 0) { + QLayoutItem* item = nullptr; + while ((item = layout_->takeAt(0)) != nullptr) { QWidget* w = item->widget(); if (w) { layout_->removeWidget(w); - //delete w; + // delete w; } delete item; } if (emptyLabel_) { delete emptyLabel_; - emptyLabel_ = 0; + emptyLabel_ = nullptr; } if (emptyLabelIcon_) { delete emptyLabelIcon_; - emptyLabelIcon_ = 0; + emptyLabelIcon_ = nullptr; } } @@ -212,21 +212,21 @@ void MvQPathWidget::setPath(Folder* folder, QString path) { - //Clear the layout (widgets are not deleted in this step!) + // Clear the layout (widgets are not deleted in this step!) clearLayout(); path_.clear(); if (!folder) { - Q_ASSERT(emptyLabelIcon_ == 0); + Q_ASSERT(emptyLabelIcon_ == nullptr); emptyLabelIcon_ = new QLabel(this); emptyLabelIcon_->setPixmap(MvQIconProvider::warningPixmap(16)); layout_->addWidget(emptyLabelIcon_); - Q_ASSERT(emptyLabel_ == 0); + Q_ASSERT(emptyLabel_ == nullptr); emptyLabel_ = new QLabel("  Folder " + path + " does not exist!", this); layout_->addWidget(emptyLabel_); - //Delete unused items (if there are any) + // Delete unused items (if there are any) int num = items_.count(); for (int i = 0; i < num; i++) { MvQPathWidgetItem* item = items_.back(); @@ -235,11 +235,11 @@ } if (reloadTb_) { delete reloadTb_; - reloadTb_ = 0; + reloadTb_ = nullptr; } if (bookmarkTb_) { delete bookmarkTb_; - bookmarkTb_ = 0; + bookmarkTb_ = nullptr; } return; } @@ -255,11 +255,11 @@ } //----------------------------------------------------------- - //Try to reuse the current items and delete the unneeded ones + // Try to reuse the current items and delete the unneeded ones //----------------------------------------------------------- - //Find out how many items can be reused. - //firstIndex: the first original item that differs from the current one. + // Find out how many items can be reused. + // firstIndex: the first original item that differs from the current one. int lastIndex = -1; for (int i = 0; i < lst.count() && i < items_.count(); i++) { if (QString::fromStdString(lst.at(i)->fullName()) == items_[i]->fullName_) { @@ -269,7 +269,7 @@ break; } - //Delete unused items (if there are any) + // Delete unused items (if there are any) int num = items_.count(); for (int i = lastIndex + 1; i < num; i++) { MvQPathWidgetItem* item = items_.back(); @@ -284,20 +284,20 @@ QString::fromStdString(f->fullName())); items_ << item; - MvQPathButton* tb; + MvQPathButton* tb = nullptr; //--------------------------------------- // Dir name //--------------------------------------- - tb = new MvQPathButton(item, this); + tb = new MvQPathButton(item, this); item->nameTb_ = tb; if (item->fullName_ == "/") { tb->setToolButtonStyle(Qt::ToolButtonIconOnly); tb->setIconSize(QSize(16, 16)); tb->setIcon(MvQIconProvider::pixmap(f, 16)); - //tb->setIcon(MvQIconProvider::homePixmap(16)); + // tb->setIcon(MvQIconProvider::homePixmap(16)); tb->setObjectName("pathIconTb"); } else { @@ -316,13 +316,13 @@ tb->setStyleSheet("QToolButton {font-style: italic;}"); } - //tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + // tb->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); tb->setAutoRaise(true); connect(tb, SIGNAL(clicked()), smp_, SLOT(map())); - //Context menu + // Context menu tb->setContextMenuPolicy(Qt::CustomContextMenu); connect(tb, SIGNAL(customContextMenuRequested(const QPoint&)), @@ -334,33 +334,33 @@ this, SLOT(slotIconDropped(QDropEvent*))); //--------------------------------------- - //Menu with the folders in the given dir + // Menu with the folders in the given dir //--------------------------------------- - tb = new MvQPathButton(item, this); + tb = new MvQPathButton(item, this); item->menuTb_ = tb; - //tb->setArrowType(Qt::RightArrow); + // tb->setArrowType(Qt::RightArrow); tb->setAutoRaise(true); - //tb->setIconSize(QSize(10,10)); - //tb->setPopupMode(QToolButton::InstantPopup); + // tb->setIconSize(QSize(10,10)); + // tb->setPopupMode(QToolButton::InstantPopup); tb->setObjectName("pathMenuTb"); connect(tb, SIGNAL(clicked()), this, SLOT(slotShowDirMenu())); - //QMenu* mn = createDirMenu(i, f, tb); - //tb->addMenu(mn); - //tb->assignMenu(mn); + // QMenu* mn = createDirMenu(i, f, tb); + // tb->addMenu(mn); + // tb->assignMenu(mn); } - //Add items to layout + // Add items to layout for (int i = 0; i < items_.count(); i++) { layout_->addWidget(items_.at(i)->nameTb_); layout_->addWidget(items_.at(i)->menuTb_); } - //Set the text in the last item bold + // Set the text in the last item bold for (int i = 0; i < items_.count(); i++) { QString st = items_.at(i)->nameTb_->styleSheet(); if (i == items_.count() - 1) @@ -373,11 +373,11 @@ layout_->addStretch(1); - //Bookmarks + // Bookmarks if (!bookmarkTb_) { bookmarkTb_ = new QToolButton(this); bookmarkTb_->setAutoRaise(true); - //bookmarkTb_->setIconSize(QSize(20,20)); + // bookmarkTb_->setIconSize(QSize(20,20)); bookmarkTb_->setObjectName("pathIconTb"); connect(bookmarkTb_, SIGNAL(clicked()), @@ -388,13 +388,13 @@ layout_->addWidget(bookmarkTb_); - //Reload + // Reload if (actionReload_) { if (!reloadTb_) { reloadTb_ = new QToolButton(this); reloadTb_->setDefaultAction(actionReload_); reloadTb_->setAutoRaise(true); - //reloadTb_->setIconSize(QSize(20,20)); + // reloadTb_->setIconSize(QSize(20,20)); reloadTb_->setObjectName("pathIconTb"); } layout_->addWidget(reloadTb_); @@ -403,7 +403,7 @@ void MvQPathWidget::slotShowDirMenu() { - if (auto* tb = static_cast(sender())) { + if (auto* tb = dynamic_cast(sender())) { QString fullName = tb->owner_->fullName_; if (fullName.isEmpty()) @@ -442,11 +442,11 @@ if (index >= 0 && index < items_.count() - 1) { QString path = items_.at(index)->fullName_; - //QString path; - //for(int i=0; i <= index; i++) + // QString path; + // for(int i=0; i <= index; i++) // path+="/"+items_[i].name_; - //setPath(path); + // setPath(path); emit dirChanged(path); setPath(path); @@ -461,7 +461,7 @@ } } - return QString(); + return {}; } void MvQPathWidget::paintEvent(QPaintEvent*) @@ -474,7 +474,7 @@ void MvQPathWidget::slotIconDropped(QDropEvent* event) { - if (auto* tb = static_cast(sender())) { + if (auto* tb = dynamic_cast(sender())) { QString p = getPath(tb); if (Folder* f = Folder::folder(p.toStdString(), false)) { MvQFolderViewBase::dropToFolder(f, event); diff -Nru metview-5.17.4/metview/src/Desktop/MvQPathWidget.h metview-5.19.2/metview/src/Desktop/MvQPathWidget.h --- metview-5.17.4/metview/src/Desktop/MvQPathWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQPathWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ Q_OBJECT public: - MvQPathButton(MvQPathWidgetItem* owner, QWidget* parent = 0); + MvQPathButton(MvQPathWidgetItem* owner, QWidget* parent = nullptr); MvQPathWidgetItem* owner_; signals: @@ -40,10 +40,10 @@ protected: void checkDropTarget(QDropEvent* event); void removeDropTarget(); - void dragEnterEvent(QDragEnterEvent* event); - void dragMoveEvent(QDragMoveEvent* event); - void dragLeaveEvent(QDragLeaveEvent* event); - void dropEvent(QDropEvent*); + void dragEnterEvent(QDragEnterEvent* event) override; + void dragMoveEvent(QDragMoveEvent* event) override; + void dragLeaveEvent(QDragLeaveEvent* event) override; + void dropEvent(QDropEvent*) override; }; @@ -74,8 +74,8 @@ Q_OBJECT public: - MvQPathWidget(QWidget* parent = 0); - ~MvQPathWidget() {} + MvQPathWidget(QWidget* parent = nullptr); + ~MvQPathWidget() override = default; void setPath(QString); void setReloadAction(QAction*); @@ -96,7 +96,7 @@ void setPath(Folder*, QString path); void clearLayout(); QString getPath(QToolButton*); - void paintEvent(QPaintEvent*); + void paintEvent(QPaintEvent*) override; void updateBookmarkStatus(); QHBoxLayout* layout_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQRecentIcons.cc metview-5.19.2/metview/src/Desktop/MvQRecentIcons.cc --- metview-5.17.4/metview/src/Desktop/MvQRecentIcons.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQRecentIcons.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-Desktop-RecentIcons"); - //We have to clear it not to remember all the previous settings + // We have to clear it not to remember all the previous settings settings.clear(); settings.beginGroup("main"); settings.setValue("recentIcons", items_); diff -Nru metview-5.17.4/metview/src/Desktop/MvQRecentIcons.h metview-5.19.2/metview/src/Desktop/MvQRecentIcons.h --- metview-5.17.4/metview/src/Desktop/MvQRecentIcons.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQRecentIcons.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ class RecentIconsObserver { public: - RecentIconsObserver() = default; + RecentIconsObserver() = default; virtual void notifyRecentChanged() = 0; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQRequestPanelHelp.h metview-5.19.2/metview/src/Desktop/MvQRequestPanelHelp.h --- metview-5.17.4/metview/src/Desktop/MvQRequestPanelHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQRequestPanelHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,13 +28,13 @@ public: MvQRequestPanelHelp(RequestPanel&, const MvIconParameter&); - virtual ~MvQRequestPanelHelp() {} + ~MvQRequestPanelHelp() override = default; - virtual void start() = 0; + virtual void start() = 0; virtual bool dialog() = 0; - virtual QIcon dialogIcon() { return QIcon(); } + virtual QIcon dialogIcon() { return {}; } virtual bool useLargeDialogIcon() { return false; } - virtual QWidget* widget() = 0; + virtual QWidget* widget() = 0; virtual void refresh(const std::vector&) = 0; virtual void setExternalActions(QList) {} diff -Nru metview-5.17.4/metview/src/Desktop/MvQRequestPanelLine.cc metview-5.19.2/metview/src/Desktop/MvQRequestPanelLine.cc --- metview-5.17.4/metview/src/Desktop/MvQRequestPanelLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQRequestPanelLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,9 @@ #include "LineFactory.h" #include "MvIconParameter.h" +#include "MvLog.h" #include "RequestPanel.h" +#include "MvQIconProvider.h" #include "MvQMethods.h" #include "MvQTheme.h" @@ -36,22 +38,22 @@ RequestPanel* parentLayout = &owner_; - //Toggle to indicate default/non-default settings + // Toggle to indicate default/non-default settings defaultTb_ = new QToolButton(parentWidget_); defaultTb_->setObjectName(QString::fromUtf8("guiItemDefaultTb")); defaultTb_->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); defaultTb_->setMaximumSize(QSize(20, 20)); defaultTb_->setToolTip(tr("Reset parameter")); - //defaultTb_->setIconSize(QSize(10,10)); + // defaultTb_->setIconSize(QSize(10,10)); defaultTb_->setAutoRaise(true); defaultTb_->setIcon(QPixmap(":/desktop/reset_lineEditor.svg")); - //defaultTb_->setIcon(QPixmap(":/desktop/link.svg")); + // defaultTb_->setIcon(QPixmap(":/desktop/link.svg")); connect(defaultTb_, SIGNAL(clicked(bool)), this, SLOT(slotChangeToDefault(bool))); - //name label - name_ = QString::fromStdString(param.beautifiedName()); + // name label + name_ = QString::fromStdString(param.beautifiedName()); QString nameStr = name_; if (const char* w_text = param.warning_text()) { nameStr += MvQ::formatText(" " + QString(w_text), MvQTheme::colour("iconeditor", "warning_pen")); @@ -60,15 +62,15 @@ nameLabel_ = new QLabel(nameStr, parentWidget_); nameLabel_->setProperty("lineEdit", "1"); const char* help_text = param.help_text(); - if (help_text) + if (help_text) { nameLabel_->setToolTip("" + QString(help_text) + ""); + } row_ = parentLayout->rowCount(); parentLayout->addWidget(defaultTb_, row_, DefaultColumn); parentLayout->addWidget(nameLabel_, row_, NameColumn); defaultTb_->setVisible(false); - //defaultTb_->setEnabled(false); } MvQRequestPanelLine::~MvQRequestPanelLine() @@ -82,7 +84,7 @@ { MvQRequestPanelLine* p = LineFactory::create(owner, param); p->buildHelper(); - //p->init(w); + // p->init(w); return p; } @@ -98,11 +100,11 @@ MvRequest helpReq = param_.interfaceRequest(); - //Toolbuton to show/hide help widget or launch dialog helper + // Toolbuton to show/hide help widget or launch dialog helper helpTb_ = new QToolButton(parentWidget_); - //helpTb_->setObjectName(QString::fromUtf8("guiItemDefaultTb")); + // helpTb_->setObjectName(QString::fromUtf8("guiItemDefaultTb")); - //Set helper icon + // Set helper icon if (helper_->dialog()) { helpTb_->setIcon(helper_->dialogIcon()); if (helper_->useLargeDialogIcon()) @@ -134,7 +136,7 @@ this, SLOT(slotStarHelpDialog(bool))); } else { - parentLayout->addWidget(helper_->widget(), row_ + 1, DefaultColumn, 1, 4); + parentLayout->addWidget(helper_->widget(), row_ + 1, DefaultColumn, 1, 5); helper_->widget()->setVisible(false); // this is not set for the css but for the painter helper_->widget()->setProperty("paintAsHelper", "1"); @@ -166,7 +168,10 @@ if (QWidget* w = item->widget()) { if (w == defaultTb_ && lineVisible_) { w->setVisible(mark_); + } else if (w == warningLabel_){ + w->setVisible(lineVisible_ && warningLabelStatus_); } + else { w->setVisible(lineVisible_); } @@ -244,7 +249,8 @@ { if (!visibleByTemporary_) { setLineVisible(false, forced); - } else if (!visibleByFilter_) { + } + else if (!visibleByFilter_) { setLineVisible(false, forced); } else { @@ -260,7 +266,7 @@ void MvQRequestPanelLine::slotChangeToDefault(bool) { - //This will reset the request and call update on all the items + // This will reset the request and call update on all the items owner_.setToDefault(this); } @@ -274,8 +280,8 @@ { helper_->widget()->setVisible(b); - //We need to immediately repaint the background of the main gridlayout. - //This was the only method to make it work!! + // We need to immediately repaint the background of the main gridlayout. + // This was the only method to make it work!! owner_.updateParentWidget(); qApp->processEvents(); } @@ -287,3 +293,34 @@ return false; } + +void MvQRequestPanelLine::setWarningLabelStatus(bool st, QString msg) +{ + if (st == warningLabelStatus_) { + return; + } + + warningLabelStatus_ = st; + if (st) { + if (warningLabel_ == nullptr) { + RequestPanel* parentLayout = &owner_; + warningLabel_ = new QLabel(parentWidget_); + warningLabel_->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); + warningLabel_->setMaximumSize(QSize(16, 16)); + warningLabel_->setPixmap(MvQIconProvider::warningPixmap(16)); + parentLayout->addWidget(warningLabel_, row_, WarningColumn); + } + + warningLabel_->setToolTip(msg); + warningLabel_->show(); + nameLabel_->setStyleSheet(MvQTheme::styleSheet("iconeditor","name_warn_sh")); + } else { + if (warningLabel_ != nullptr) { + warningLabel_->setToolTip(""); + warningLabel_->hide(); + nameLabel_->setStyleSheet(""); + } + } +} + + diff -Nru metview-5.17.4/metview/src/Desktop/MvQRequestPanelLine.h metview-5.19.2/metview/src/Desktop/MvQRequestPanelLine.h --- metview-5.17.4/metview/src/Desktop/MvQRequestPanelLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQRequestPanelLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,17 @@ Q_OBJECT public: + enum ColumnPos + { + DefaultColumn = 0, + NameColumn = 1, + ExpandColumn = 2, + WarningColumn = 3, + WidgetColumn = 4 + }; + MvQRequestPanelLine(RequestPanel&, const MvIconParameter&, bool buildLine = true); - virtual ~MvQRequestPanelLine(); + ~MvQRequestPanelLine() override; static MvQRequestPanelLine* build(RequestPanel&, const MvIconParameter&); @@ -41,6 +50,8 @@ bool hasDefaultTb() override; bool isGray() const override { return gray_; } bool isVisibleByFilter() const override { return visibleByFilter_; } + void setWarningLabelStatus(bool st, QString msg={}); + bool warningLabelStatus() const {return warningLabelStatus_;} public slots: void slotChangeToDefault(bool); @@ -56,30 +67,24 @@ protected: virtual void buildHelper(); - //void setEnabled(bool); + // void setEnabled(bool); void setLineVisible(bool, bool forced); void setLineEnabled(bool); void adjustState(bool forced = false); - enum ColumnPos - { - DefaultColumn = 0, - NameColumn = 1, - ExpandColumn = 2, - WidgetColumn = 3 - }; - QToolButton* defaultTb_; QLabel* nameLabel_; QToolButton* helpTb_; + QLabel* warningLabel_{nullptr}; + bool warningLabelStatus_{false}; QString name_; QString source_; int row_; bool lineVisible_{true}; bool gray_{false}; - bool mark_{false}; //indicates that a non-default value is set - bool visibleByFilter_{true}; + bool mark_{false}; // indicates that a non-default value is set + bool visibleByFilter_{true}; MvQRequestPanelHelp* helper_; QWidget* parentWidget_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQRequestPanelWidget.cc metview-5.19.2/metview/src/Desktop/MvQRequestPanelWidget.cc --- metview-5.17.4/metview/src/Desktop/MvQRequestPanelWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQRequestPanelWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,6 +20,7 @@ #include "MvQIconMimeData.h" #include "MvQMethods.h" #include "MvQTheme.h" +#include "MvLog.h" #include "IconClass.h" #include "IconObject.h" @@ -36,26 +37,26 @@ delayedRepaintScheduled_(false) { if (helperBrush_.style() == Qt::NoBrush) { - linePen_ = QPen(MvQTheme::colour("iconeditor", "line_item_pen")); - framePen_ = QPen(MvQTheme::colour("iconeditor", "frame_pen")); - bgBrush_ = MvQTheme::brush("iconeditor", "bg_brush"); + linePen_ = QPen(MvQTheme::colour("iconeditor", "line_item_pen")); + framePen_ = QPen(MvQTheme::colour("iconeditor", "frame_pen")); + bgBrush_ = MvQTheme::brush("iconeditor", "bg_brush"); helperBrush_ = MvQTheme::brush("iconeditor", "helper_brush"); } setAcceptDrops(true); } -//We paint the grid lines to the widget holding the gridlayout. The problem is that -//it is not called all the time when the gridlayout changes (items are hidden/shown)! +// We paint the grid lines to the widget holding the gridlayout. The problem is that +// it is not called all the time when the gridlayout changes (items are hidden/shown)! void MvQRequestPanelWidget::paintEvent(QPaintEvent* event) { QPainter painter(this); - //paint bg + // paint bg QPalette pal = palette(); painter.fillRect(0, 0, this->width(), this->height(), bgBrush_); // pal.color(QPalette::Window)); - auto* grid = static_cast(layout()); + auto* grid = dynamic_cast(layout()); if (!grid) { QWidget::paintEvent(event); return; @@ -63,24 +64,39 @@ painter.setPen(linePen_); - //The spacing in the gridlayout + const int widgetPos = 4; + int firstY = 0; + int lastY = 0; + int bgSplitX = 0; + int rowNum = grid->rowCount(); + + // The spacing in the gridlayout int spacingV = grid->verticalSpacing(); - int spacingH = grid->horizontalSpacing(); - int firstY = 0; - int lastY = 0; - int bgSplitX = 0; - int rowNum = grid->rowCount(); + // Find right pos of the widget preceding the main widget + int leftWidgetX =0; + for (int i = 0; i < rowNum; i++) { + for (int j=1; j < widgetPos; j++) { + if (QLayoutItem* item = grid->itemAtPosition(i, j)) { + QWidget* w = item->widget(); + if (w && w->isVisible() && w->property("paintAsHelper") != "1") { + auto r = item->geometry(); + if (r.right() > leftWidgetX) { + leftWidgetX = r.right(); + } + } + } + } + } - //Find the border between the left and right hand side + // Find the border between the left and right hand side for (int i = 0; i < rowNum; i++) { - //At position 3 we have the widget in the row - if (QLayoutItem* item = grid->itemAtPosition(i, 3)) { + if (QLayoutItem* item = grid->itemAtPosition(i, widgetPos)) { QWidget* w = item->widget(); if (w && w->isVisible()) { QRect r = item->geometry(); - int h = r.height() + spacingV; - int y = r.y() - spacingV / 2; + int h = r.height() + spacingV; + int y = r.y() - spacingV / 2; if (firstY == 0) firstY = y; @@ -88,7 +104,7 @@ lastY = y + h; if (bgSplitX == 0) - bgSplitX = r.x() - spacingH / 2; + bgSplitX = (r.x() + leftWidgetX) / 2; } } } @@ -96,37 +112,35 @@ if (firstY == 0 || lastY == 0 || bgSplitX == 0) return; - //Note: using drawLine() does not work properly in this function, - //that is why we use QPolygon instead! See METV-3069. + // Note: using drawLine() does not work properly in this function, + // that is why we use QPolygon instead! See METV-3069. - //The vertical separator line between the left and right hand side + // The vertical separator line between the left and right hand side MvQ::safeDrawLine(QPoint(bgSplitX, firstY), QPoint(bgSplitX, lastY), &painter); - //Draw the horizontal lines + // Draw the horizontal lines for (int i = 0; i < rowNum; i++) { - //At position 3 we have the widget in the row - if (QLayoutItem* item = grid->itemAtPosition(i, 3)) { + if (QLayoutItem* item = grid->itemAtPosition(i, widgetPos)) { QWidget* w = item->widget(); if (w && w->isVisible()) { QRect r = item->geometry(); - int h = r.height() + spacingV; - int y = r.y() - spacingV / 2; + int h = r.height() + spacingV; + int y = r.y() - spacingV / 2; - // At position 1-4 we have the helper if (w->property("paintAsHelper") == "1") { painter.fillRect(0, y, this->width(), h, helperBrush_); } - //Horizontal line + // Horizontal line MvQ::safeDrawLine(QPoint(0, y), QPoint(this->width(), y), &painter); } } } - //The last horizontal line + // The last horizontal line MvQ::safeDrawLine(QPoint(0, lastY), QPoint(this->width(), lastY), &painter); - //Frame + // Frame painter.setPen(framePen_); painter.drawRect(0, 0, this->width(), this->height()); } diff -Nru metview-5.17.4/metview/src/Desktop/MvQRequestPanelWidget.h metview-5.19.2/metview/src/Desktop/MvQRequestPanelWidget.h --- metview-5.17.4/metview/src/Desktop/MvQRequestPanelWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQRequestPanelWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ Q_OBJECT public: - MvQRequestPanelWidget(const std::vector&, QWidget* parent = 0); + MvQRequestPanelWidget(const std::vector&, QWidget* parent = nullptr); void delayedForceRepaint(); signals: @@ -33,10 +33,10 @@ protected: bool isAccepted(const IconClass& kind) const; - void paintEvent(QPaintEvent*); - void dragEnterEvent(QDragEnterEvent*); - void dragMoveEvent(QDragMoveEvent*); - void dropEvent(QDropEvent*); + void paintEvent(QPaintEvent*) override; + void dragEnterEvent(QDragEnterEvent*) override; + void dragMoveEvent(QDragMoveEvent*) override; + void dropEvent(QDropEvent*) override; static QPen linePen_; static QPen framePen_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQScriptHelp.cc metview-5.19.2/metview/src/Desktop/MvQScriptHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQScriptHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQScriptHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -134,7 +134,7 @@ void MvQScriptHelp::slotClosed() { - //the dialog will be automatically deleted + // the dialog will be automatically deleted mb_ = nullptr; delete task_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQScriptHelp.h metview-5.19.2/metview/src/Desktop/MvQScriptHelp.h --- metview-5.17.4/metview/src/Desktop/MvQScriptHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQScriptHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,8 @@ void finished(); protected: - void ready(const char*); - void done(FILE*); + void ready(const char*) override; + void done(FILE*) override; }; class MvQMessageDialog : public QDialog @@ -43,7 +43,7 @@ Q_OBJECT public: - MvQMessageDialog(QWidget* parent = 0); + MvQMessageDialog(QWidget* parent = nullptr); void setHeader(QString); void clear(); @@ -61,19 +61,19 @@ public: MvQScriptHelp(RequestPanel&, const MvIconParameter&); - virtual ~MvQScriptHelp() = default; + ~MvQScriptHelp() override = default; - void start(); - bool dialog() { return true; } - QIcon dialogIcon(); - QWidget* widget() { return 0; } + void start() override; + bool dialog() override { return true; } + QIcon dialogIcon() override; + QWidget* widget() override { return nullptr; } public slots: void slotFinished(); void slotClosed(); protected: - void refresh(const std::vector&) {} + void refresh(const std::vector&) override {} ScriptHelpTask* task_; MvQMessageDialog* mb_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQScrolledTextLine.cc metview-5.19.2/metview/src/Desktop/MvQScrolledTextLine.cc --- metview-5.17.4/metview/src/Desktop/MvQScrolledTextLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQScrolledTextLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,12 +20,12 @@ { textEdit_ = new QPlainTextEdit; - //Try to set the optimal widget height + // Try to set the optimal widget height QFont font; QFontMetrics fm(font); textEdit_->setMaximumHeight(fm.size(Qt::TextExpandTabs, "A\nA\nA\nA\nA\nA\nA\nA\nA\nA\n").height()); - owner_.addWidget(textEdit_, row_, 3); + owner_.addWidget(textEdit_, row_, WidgetColumn); connect(textEdit_, SIGNAL(textChanged()), this, SLOT(slotTextEdited())); @@ -45,7 +45,7 @@ textEdit_->setPlainText(s.c_str()); } - //changed_ = false; + // changed_ = false; } void MvQScrolledTextLine::slotTextEdited() diff -Nru metview-5.17.4/metview/src/Desktop/MvQScrolledTextLine.h metview-5.19.2/metview/src/Desktop/MvQScrolledTextLine.h --- metview-5.17.4/metview/src/Desktop/MvQScrolledTextLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQScrolledTextLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,12 +25,12 @@ public: MvQScrolledTextLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQScrolledTextLine() = default; + ~MvQScrolledTextLine() override = default; - QString currentValue() { return QString(); } + QString currentValue() { return {}; } void addValue(QString) {} - void refresh(const std::vector&); + void refresh(const std::vector&) override; public slots: void slotTextEdited(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQSearchPanel.cc metview-5.19.2/metview/src/Desktop/MvQSearchPanel.cc --- metview-5.17.4/metview/src/Desktop/MvQSearchPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQSearchPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,19 +36,19 @@ hb->setContentsMargins(2, 1, 0, 2); setLayout(hb); - //Name + // Name auto* label = new QLabel(this); label->setText(tr("&Name:")); nameLe_ = new MvQLineEdit(this); nameLe_->setPlaceholderText("Filter name ..."); - //nameLe_->setDecoration(QPixmap(":/desktop/filter_decor.svg")); + // nameLe_->setDecoration(QPixmap(":/desktop/filter_decor.svg")); label->setBuddy(nameLe_); hb->addWidget(label); hb->addWidget(nameLe_, 1); - //Type + // Type label = new QLabel(this); label->setText(tr("&Type:")); typeLe_ = new MvQLineEdit(this); @@ -59,7 +59,7 @@ hb->addWidget(label); hb->addWidget(typeLe_, 1); - //Buttons + // Buttons nextPb_ = new QPushButton(tr("&Next"), this); nextPb_->setIcon(QIcon(QPixmap(QString::fromUtf8(":/desktop/arrow_down.svg")))); diff -Nru metview-5.17.4/metview/src/Desktop/MvQSearchPanel.h metview-5.19.2/metview/src/Desktop/MvQSearchPanel.h --- metview-5.17.4/metview/src/Desktop/MvQSearchPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQSearchPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,12 +28,12 @@ Q_OBJECT public: - MvQFolderSearchPanel(QWidget* parent = 0); - ~MvQFolderSearchPanel(); + MvQFolderSearchPanel(QWidget* parent = nullptr); + ~MvQFolderSearchPanel() override; void targetChanged(); - //Observer method - void matchChanged(); + // Observer method + void matchChanged() override; public slots: void slotFind(QString); diff -Nru metview-5.17.4/metview/src/Desktop/MvQSliderLine.cc metview-5.19.2/metview/src/Desktop/MvQSliderLine.cc --- metview-5.17.4/metview/src/Desktop/MvQSliderLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQSliderLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,11 +23,11 @@ MvQRequestPanelLine(owner, param) { auto* sliderParent = new QWidget(parentWidget_); - auto* layout = new QHBoxLayout(parentWidget_); + auto* layout = new QHBoxLayout(parentWidget_); sliderParent->setLayout(layout); - owner_.addWidget(sliderParent, row_, 3); + owner_.addWidget(sliderParent, row_, WidgetColumn); - //Slider + // Slider slider_ = new MvQSlider(sliderParent); slider_->setOrientation(Qt::Horizontal); slider_->setTickPosition(QSlider::TicksBelow); @@ -55,7 +55,6 @@ const char* direction; r.getValue(direction, "direction", 0); - QString directionVal(direction); slider_->setRange(minVal, maxVal); slider_->setSingleStep(stepVal); @@ -80,7 +79,7 @@ slider_->setInvertedAppearance(true); } - //Label + // Label valueLabel_ = new QLabel(sliderParent); layout->addWidget(valueLabel_); @@ -99,7 +98,7 @@ slider_->setSliderPosition(s.toInt()); } - //changed_ = false; + // changed_ = false; } void MvQSliderLine::slotValueChanged(int value) diff -Nru metview-5.17.4/metview/src/Desktop/MvQSliderLine.h metview-5.19.2/metview/src/Desktop/MvQSliderLine.h --- metview-5.17.4/metview/src/Desktop/MvQSliderLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQSliderLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,11 +25,11 @@ public: MvQSliderLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQSliderLine(); + ~MvQSliderLine() override; - QString currentValue() { return QString(); } + QString currentValue() { return {}; } void addValue(QString) {} - void refresh(const std::vector&); + void refresh(const std::vector&) override; public slots: void slotValueChanged(int); diff -Nru metview-5.17.4/metview/src/Desktop/MvQStationsHelp.cc metview-5.19.2/metview/src/Desktop/MvQStationsHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQStationsHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQStationsHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,7 +27,7 @@ MvQRequestPanelHelp(owner, param), selector_(nullptr) { - Request req = param.interfaceRequest(); + Request req = param.interfaceRequest(); const char* type = req("help_param"); if (!type) @@ -68,13 +68,13 @@ return; /*if(MvQPalette::toString(selector_->currentColour()) == values[0]) - return; - - QColor col=MvQPalette::magics(values[0]); - if(col.isValid()) - { - selector_->setColour(col); - }*/ + return; + + QColor col=MvQPalette::magics(values[0]); + if(col.isValid()) + { + selector_->setColour(col); + }*/ } static HelpMaker maker("help_external"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQStationsHelp.h metview-5.19.2/metview/src/Desktop/MvQStationsHelp.h --- metview-5.17.4/metview/src/Desktop/MvQStationsHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQStationsHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,17 +26,17 @@ public: MvQStationsHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQStationsHelp() = default; + ~MvQStationsHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget(); + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override; public slots: void slotSelected(QString); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; private: MvQStationsWidget* selector_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQStringLine.cc metview-5.19.2/metview/src/Desktop/MvQStringLine.cc --- metview-5.17.4/metview/src/Desktop/MvQStringLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQStringLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ { lineEdit_ = new MvQLineEdit(parentWidget_); - owner_.addWidget(lineEdit_, row_, 3); + owner_.addWidget(lineEdit_, row_, WidgetColumn); connect(lineEdit_, SIGNAL(textEdited(const QString&)), this, SLOT(slotTextEdited(const QString&))); @@ -135,4 +135,4 @@ } } -static LineMaker maker1("string"); \ No newline at end of file +static LineMaker maker1("string"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQStringLine.h metview-5.19.2/metview/src/Desktop/MvQStringLine.h --- metview-5.17.4/metview/src/Desktop/MvQStringLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQStringLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,17 +25,17 @@ public: MvQStringLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQStringLine() = default; + ~MvQStringLine() override = default; - QString currentValue() { return QString(); } + QString currentValue() { return {}; } void addValue(QString) {} - void refresh(const std::vector&); + void refresh(const std::vector&) override; public slots: void slotCleared(); void slotTextEdited(const QString&); - void slotHelperEdited(const std::vector&); + void slotHelperEdited(const std::vector&) override; protected: void dispatchChange(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQStyleHelp.cc metview-5.19.2/metview/src/Desktop/MvQStyleHelp.cc --- metview-5.17.4/metview/src/Desktop/MvQStyleHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQStyleHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -56,7 +56,7 @@ int MvQStyleModel::rowCount(const QModelIndex& parent) const { - //Parent is the root: + // Parent is the root: if (!parent.isValid()) { return MvQStyleDb::instance()->items().count(); } @@ -68,7 +68,7 @@ { int row = index.row(); if (row < 0 || row >= MvQStyleDb::instance()->items().count()) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { if (index.column() == 0) @@ -82,7 +82,7 @@ return MvQStyleDb::instance()->items()[row]->name(); } - return QVariant(); + return {}; } QVariant MvQStyleModel::headerData(const int section, const Qt::Orientation orient, const int role) const @@ -96,20 +96,20 @@ QModelIndex MvQStyleModel::index(int row, int column, const QModelIndex& parent) const { if (row < 0 || column < 0) { - return QModelIndex(); + return {}; } - //When parent is the root this index refers to a node or server + // When parent is the root this index refers to a node or server if (!parent.isValid()) { return createIndex(row, column); } - return QModelIndex(); + return {}; } QModelIndex MvQStyleModel::parent(const QModelIndex& /*child*/) const { - return QModelIndex(); + return {}; } void MvQStyleModel::setFilter(QString s) @@ -173,7 +173,7 @@ vb->addWidget(nameLe_); - //Layout to hold tree and sidebar + // Layout to hold tree and sidebar browser_ = new MvQStyleTreeWidget(this); vb->addWidget(browser_, 1); @@ -192,7 +192,7 @@ browser_->tree()->setModel(sortModel_); - //Signals and slots + // Signals and slots connect(nameLe_, SIGNAL(textChanged(QString)), this, SLOT(slotNameFilter(QString))); diff -Nru metview-5.17.4/metview/src/Desktop/MvQStyleHelp.h metview-5.19.2/metview/src/Desktop/MvQStyleHelp.h --- metview-5.17.4/metview/src/Desktop/MvQStyleHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQStyleHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ class RequestPanel; class MvQStyleTreeWidget; -//Model to dislay/select the suites +// Model to dislay/select the suites class MvQStyleModel : public QAbstractItemModel { public: @@ -42,17 +42,17 @@ SortRole = Qt::UserRole + 1 }; - explicit MvQStyleModel(QObject* parent = 0); - ~MvQStyleModel(); + explicit MvQStyleModel(QObject* parent = nullptr); + ~MvQStyleModel() override; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void setFilter(QString s); void clearFilter(); @@ -67,7 +67,7 @@ { Q_OBJECT public: - MvQStyleSelectionWidget(QWidget* parent = 0); + MvQStyleSelectionWidget(QWidget* parent = nullptr); void setCurrent(const std::string&); protected slots: @@ -93,17 +93,17 @@ public: MvQStyleHelp(RequestPanel& owner, const MvIconParameter& param); - ~MvQStyleHelp() {} + ~MvQStyleHelp() override = default; - void start() {} - bool dialog() { return false; } - QWidget* widget() { return selector_; } + void start() override {} + bool dialog() override { return false; } + QWidget* widget() override { return selector_; } public slots: void slotSelected(int); protected: - virtual void refresh(const std::vector&); + void refresh(const std::vector&) override; private: MvQStyleSelectionWidget* selector_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQStyleLine.cc metview-5.19.2/metview/src/Desktop/MvQStyleLine.cc --- metview-5.17.4/metview/src/Desktop/MvQStyleLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQStyleLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ owner_(owner) {} protected: - void mousePressEvent(QMouseEvent*) + void mousePressEvent(QMouseEvent*) override { owner_->widgetClicked(); } @@ -51,11 +51,11 @@ { MvQStyleDb::instance(); - auto* w = new MvQStyleLineWidget(this, parentWidget_); + auto* w = new MvQStyleLineWidget(this, parentWidget_); auto* hb = new QHBoxLayout(w); hb->setContentsMargins(0, 0, 0, 0); - stylePixLabel_ = new QLabel(w); + stylePixLabel_ = new QLabel(w); styleNameLabel_ = new QLabel(w); hb->addWidget(stylePixLabel_); hb->addWidget(styleNameLabel_, 1); @@ -64,7 +64,7 @@ QFontMetrics fm(font); pixSize_ = QSize(180, fm.height() + 4); - owner_.addWidget(w, row_, 3); + owner_.addWidget(w, row_, WidgetColumn); #if 0 connect(colCb_,SIGNAL(currentIndexChanged(int)), @@ -98,7 +98,7 @@ stylePixLabel_->setPixmap(QPixmap()); styleNameLabel_->clear(); - //changed_ = false; + // changed_ = false; } void MvQStyleLine::slotHelperEdited(const std::vector& values) @@ -129,12 +129,12 @@ setCustomColour(MvQPalette::magics(values[0]),name,name,true); #endif - //If the current index did not change the slotCurrentChanged() was - //not called, so here we need to notify the owner about the change!! - //if(colCb_->currentIndex() == currentPrev) + // If the current index did not change the slotCurrentChanged() was + // not called, so here we need to notify the owner about the change!! + // if(colCb_->currentIndex() == currentPrev) //{ // owner_.set(param_.name(),name.toStdString()); - //} + // } } } diff -Nru metview-5.17.4/metview/src/Desktop/MvQStyleLine.h metview-5.19.2/metview/src/Desktop/MvQStyleLine.h --- metview-5.17.4/metview/src/Desktop/MvQStyleLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQStyleLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,16 +28,16 @@ public: MvQStyleLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQStyleLine() {} + ~MvQStyleLine() override = default; - void refresh(const std::vector&); + void refresh(const std::vector&) override; void widgetClicked(); public slots: - void slotHelperEdited(const std::vector&); + void slotHelperEdited(const std::vector&) override; protected: - void next(const MvIconParameter&, const char* first, const char* second); + void next(const MvIconParameter&, const char* first, const char* second) override; void updateHelper(); QPixmap pix_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQTemplateDrawer.cc metview-5.19.2/metview/src/Desktop/MvQTemplateDrawer.cc --- metview-5.17.4/metview/src/Desktop/MvQTemplateDrawer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQTemplateDrawer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,7 +27,7 @@ model_ = new MvQFolderModel(this); view_ = new MvQTemplateDrawerView(model_); - //view_->setHelper(true); + // view_->setHelper(true); view_->setMinimumHeight(1); view_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); @@ -70,7 +70,7 @@ MvQTemplateDrawerView::~MvQTemplateDrawerView() { - //delete filterModel_; + // delete filterModel_; } MvQContextItemSet* MvQTemplateDrawerView::cmSet() diff -Nru metview-5.17.4/metview/src/Desktop/MvQTemplateDrawer.h metview-5.19.2/metview/src/Desktop/MvQTemplateDrawer.h --- metview-5.17.4/metview/src/Desktop/MvQTemplateDrawer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQTemplateDrawer.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,8 @@ public: MvQTemplateDrawer(MvQEditor*); - QString name(); - QWidget* widget(); + QString name() override; + QWidget* widget() override; public slots: void slotCommand(QString, IconObjectH); @@ -38,9 +38,9 @@ class MvQTemplateDrawerView : public MvQIconStripView { public: - MvQTemplateDrawerView(MvQFolderModel*, QWidget* parent = 0); - ~MvQTemplateDrawerView(); + MvQTemplateDrawerView(MvQFolderModel*, QWidget* parent = nullptr); + ~MvQTemplateDrawerView() override; protected: - MvQContextItemSet* cmSet(); + MvQContextItemSet* cmSet() override; }; diff -Nru metview-5.17.4/metview/src/Desktop/MvQTemporaryEditor.cc metview-5.19.2/metview/src/Desktop/MvQTemporaryEditor.cc --- metview-5.17.4/metview/src/Desktop/MvQTemporaryEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQTemporaryEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ vb->setContentsMargins(1, 1, 1, 1); setLayout(vb); - //Header + // Header auto* hb = new QHBoxLayout; vb->addLayout(hb); @@ -69,8 +69,8 @@ hb->addWidget(headerLabel_, 1); - //Panel layout - auto* w = new QWidget(this); + // Panel layout + auto* w = new QWidget(this); centralLayout_ = new QHBoxLayout; centralLayout_->setSpacing(0); centralLayout_->setContentsMargins(1, 1, 1, 1); @@ -83,9 +83,9 @@ buttonBox_ = new QDialogButtonBox(this); - okPb_ = buttonBox_->addButton(QDialogButtonBox::Ok); + okPb_ = buttonBox_->addButton(QDialogButtonBox::Ok); cancelPb_ = buttonBox_->addButton(QDialogButtonBox::Cancel); - resetPb_ = buttonBox_->addButton(QDialogButtonBox::Reset); + resetPb_ = buttonBox_->addButton(QDialogButtonBox::Reset); resetPb_->setEnabled(false); @@ -119,7 +119,7 @@ if (!current_) return; - auto subCol = MvQTheme::subText(); + auto subCol = MvQTheme::subText(); QString name = "Macro"; if (class_.name().find("python_") == 0) { name = "Python"; @@ -138,7 +138,7 @@ void MvQTemporaryEditor::closeIt() { - //Is this the right thing to do? + // Is this the right thing to do? close(); reject(); editDone(); diff -Nru metview-5.17.4/metview/src/Desktop/MvQTemporaryEditor.h metview-5.19.2/metview/src/Desktop/MvQTemporaryEditor.h --- metview-5.17.4/metview/src/Desktop/MvQTemporaryEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQTemporaryEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,25 +24,25 @@ Q_OBJECT public: - MvQTemporaryEditor(const IconClass& name, const std::string& kind, QWidget* parent = 0); - ~MvQTemporaryEditor(); + MvQTemporaryEditor(const IconClass& name, const std::string& kind, QWidget* parent = nullptr); + ~MvQTemporaryEditor() override; - void changed(); + void changed() override; public slots: void slotButtonClicked(QAbstractButton*); - void accept(); - void reject(); + void accept() override; + void reject() override; protected: - void raiseIt(); - void showIt() { show(); } - void closeIt(); + void raiseIt() override; + void showIt() override { show(); } + void closeIt() override; void updateHeader(); virtual void apply() = 0; virtual void reset() = 0; virtual void close() = 0; - virtual void edit(); + void edit() override; QLabel* headerLabel_; QHBoxLayout* centralLayout_; diff -Nru metview-5.17.4/metview/src/Desktop/MvQTextLine.cc metview-5.19.2/metview/src/Desktop/MvQTextLine.cc --- metview-5.17.4/metview/src/Desktop/MvQTextLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQTextLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,10 @@ #include "LineFactory.h" #include "MvIconParameter.h" +#include "MvQTheme.h" #include "RequestPanel.h" +#include "MvLog.h" +#include "MvMiscellaneous.h" #include @@ -22,7 +25,7 @@ MvQRequestPanelLine(owner, param) { lineEdit_ = new MvQLineEdit(parentWidget_); - owner_.addWidget(lineEdit_, row_, 3); + owner_.addWidget(lineEdit_, row_, WidgetColumn); connect(lineEdit_, SIGNAL(textEdited(const QString&)), this, SLOT(slotTextEdited(const QString&))); @@ -40,23 +43,23 @@ s += value; } - //Now this is the tricky part. Whenever the user types in a new character the - //lineedit emits a changed signal and the request gets updated. And in the end this (refresh()) - //function will be called with the new text. Ideally the new string and the string stored in - //the lineedit should be the same. However, mars tends to change incomplete floating point numbers like - // "7." into integers!! So when the user wants to change e.g. "7.1" to "7.3" when they reach "7." - //during the editing the string changes back to "7". In this case we do not want to set the linedit. - //So we need to carefully compare the new and the previous string and decide what to do. + // Now this is the tricky part. Whenever the user types in a new character the + // lineedit emits a changed signal and the request gets updated. And in the end this (refresh()) + // function will be called with the new text. Ideally the new string and the string stored in + // the lineedit should be the same. However, mars tends to change incomplete floating point numbers like + // "7." into integers!! So when the user wants to change e.g. "7.1" to "7.3" when they reach "7." + // during the editing the string changes back to "7". In this case we do not want to set the linedit. + // So we need to carefully compare the new and the previous string and decide what to do. std::string prevText = lineEdit_->text().toStdString(); if (s.empty() || s != prevText) { - //Single strings + // Single strings if (values.size() <= 1) { - //if the original string was - // "something" + "." or - // "-" - //we do not update the lineedit + // if the original string was + // "something" + "." or + // "-" + // we do not update the lineedit if ((s + "." == prevText) || (prevText == "-" && !s.empty() && s[0] == '-')) { @@ -66,9 +69,9 @@ lineEdit_->setText(s.c_str()); updateHelper(); } - //Lists + // Lists else { - QStringList lst = QString::fromStdString(s).split("/"); + QStringList lst = QString::fromStdString(s).split("/"); QStringList prevLst = QString::fromStdString(prevText).split("/"); if (lst.count() == prevLst.count()) { @@ -93,6 +96,8 @@ } } } + + checkValidity(); } void MvQTextLine::dispatchChange() @@ -104,6 +109,8 @@ } owner_.set(param_.name(), vals); + + checkValidity(); } void MvQTextLine::updateHelper() @@ -134,7 +141,7 @@ void MvQTextLine::slotHelperEdited(QStringList vals, QVector st) { - QString txt = lineEdit_->text(); + QString txt = lineEdit_->text(); QStringList lst = txt.split("/"); for (int i = 0; i < vals.size(); i++) { @@ -179,4 +186,37 @@ } } +void MvQTextLine::checkValidity() +{ + // Check if commma separator is used instead of forward slash + + // Only performs the check if LC_NUMERIC=C to make sure dot is used for decimal + // place in numbers. + if (!metview::is_locale_numeric_set()) { + return; + } + + auto t = lineEdit_->text(); + + // An extremely simple assumption to check if the correct separator is used. + // Will not work for strings containing commas. + bool wrong = t.contains(",") && !t.contains("/"); + + if (wrong) { + if (!warningLabelStatus()) { + static QString warnMsg = "In icon editors a forward slash ('/') must be used as " + "list separator. It seems comma (',') is used instead!"; + setWarningLabelStatus(true, warnMsg); + auto sh = MvQTheme::styleSheet("lineedit", "warning_sh"); + lineEdit_->setStyleSheet(sh); + lineEdit_->setToolTip(warnMsg); + } + } else if (warningLabelStatus()) { + setWarningLabelStatus(false); + lineEdit_->setStyleSheet(""); + lineEdit_->setToolTip(""); + + } +} + static LineMaker maker1("text"); diff -Nru metview-5.17.4/metview/src/Desktop/MvQTextLine.h metview-5.19.2/metview/src/Desktop/MvQTextLine.h --- metview-5.17.4/metview/src/Desktop/MvQTextLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQTextLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,9 @@ Q_OBJECT public: MvQTextLine(RequestPanel& owner, const MvIconParameter& param); - ~MvQTextLine() {} + ~MvQTextLine() override = default; - QString currentValue() { return QString(); } + QString currentValue() { return {}; } void addValue(QString) {} void refresh(const std::vector&) override; @@ -41,6 +41,7 @@ protected: void dispatchChange(); void updateHelper(); + void checkValidity(); MvQLineEdit* lineEdit_; bool doNotUpdateHelper_{false}; diff -Nru metview-5.17.4/metview/src/Desktop/MvQViewDrawer.cc metview-5.19.2/metview/src/Desktop/MvQViewDrawer.cc --- metview-5.17.4/metview/src/Desktop/MvQViewDrawer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQViewDrawer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ model_ = new MvQFolderModel(this); view_ = new MvQViewDrawerView(model_); - //view_->setHelper(true); + // view_->setHelper(true); view_->setMinimumHeight(1); view_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); @@ -71,7 +71,7 @@ MvQViewDrawerView::~MvQViewDrawerView() { - //delete filterModel_; + // delete filterModel_; } MvQContextItemSet* MvQViewDrawerView::cmSet() diff -Nru metview-5.17.4/metview/src/Desktop/MvQViewDrawer.h metview-5.19.2/metview/src/Desktop/MvQViewDrawer.h --- metview-5.17.4/metview/src/Desktop/MvQViewDrawer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/MvQViewDrawer.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,9 @@ public: MvQViewDrawer(MvQEditor*); - QString name(); - QWidget* widget(); - void next(const IconClass&); + QString name() override; + QWidget* widget() override; + void next(const IconClass&) override; public slots: void slotCommand(QString, IconObjectH); @@ -43,9 +43,9 @@ class MvQViewDrawerView : public MvQIconStripView { public: - MvQViewDrawerView(MvQFolderModel*, QWidget* parent = 0); - ~MvQViewDrawerView(); + MvQViewDrawerView(MvQFolderModel*, QWidget* parent = nullptr); + ~MvQViewDrawerView() override; protected: - MvQContextItemSet* cmSet(); + MvQContextItemSet* cmSet() override; }; diff -Nru metview-5.17.4/metview/src/Desktop/NoEditor.h metview-5.19.2/metview/src/Desktop/NoEditor.h --- metview-5.17.4/metview/src/Desktop/NoEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/NoEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,18 +15,18 @@ { public: NoEditor(const IconClass&, const std::string&); - virtual ~NoEditor(); + ~NoEditor() override; - void changed() {} - void raiseIt() {} - void closeIt() {} + void changed() override {} + void raiseIt() override {} + void closeIt() override {} private: NoEditor(const NoEditor&); NoEditor& operator=(const NoEditor&); - void edit() {} - void showIt() {} + void edit() override {} + void showIt() override {} }; inline void destroy(NoEditor**) {} diff -Nru metview-5.17.4/metview/src/Desktop/PreviewPanel.cc metview-5.19.2/metview/src/Desktop/PreviewPanel.cc --- metview-5.17.4/metview/src/Desktop/PreviewPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/PreviewPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -55,10 +55,10 @@ // can be an async call IconDescription::Instance()->getContents(item, this); // this data is generated on the fly - ui_->propLabel->setText(IconDescription::Instance()->table(item)); + ui_->propLabel->setText(IconDescription::Instance()->table(item, true)); } else { - //clear(); + // clear(); } } @@ -72,9 +72,7 @@ void PreviewPanel::setContents(const std::string& path, QString txt) { if (currentPath_ == path) { - if (currentPath_ == path) { - ui_->contentsLabel->setText(cssStyle_ + txt); - } + ui_->contentsLabel->setText(cssStyle_ + txt); } } diff -Nru metview-5.17.4/metview/src/Desktop/PreviewPanel.h metview-5.19.2/metview/src/Desktop/PreviewPanel.h --- metview-5.17.4/metview/src/Desktop/PreviewPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/PreviewPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,8 @@ { Q_OBJECT public: - PreviewPanel(QWidget* parent = 0); - ~PreviewPanel() {} + PreviewPanel(QWidget* parent = nullptr); + ~PreviewPanel() override = default; void setItem(IconObject*); void setContents(const std::string& path, QPixmap) override; diff -Nru metview-5.17.4/metview/src/Desktop/Protocol.h metview-5.19.2/metview/src/Desktop/Protocol.h --- metview-5.17.4/metview/src/Desktop/Protocol.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Protocol.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,7 +13,7 @@ { public: Protocol(); - ~Protocol(); + virtual ~Protocol(); static void init(); @@ -30,13 +30,13 @@ template class ProtocolFactory : public Protocol { - void make() { new T(); } + void make() override { new T(); } public: - ProtocolFactory() {} + ProtocolFactory() = default; }; // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(Protocol); +// OS_MARK_SCHEMA_TYPE(Protocol); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/PythonGuiObject.h metview-5.19.2/metview/src/Desktop/PythonGuiObject.h --- metview-5.17.4/metview/src/Desktop/PythonGuiObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/PythonGuiObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,16 +18,16 @@ class PythonGuiObject : public IconClass { public: - PythonGuiObject(const Request& lang, const IconClass* = 0); - virtual ~PythonGuiObject(); + PythonGuiObject(const Request& lang, const IconClass* = nullptr); + ~PythonGuiObject() override; private: // No copy allowed PythonGuiObject(const PythonGuiObject&); PythonGuiObject& operator=(const PythonGuiObject&); - virtual MvIconLanguage& language() const; - virtual std::string editor() const; + MvIconLanguage& language() const override; + std::string editor() const override; MvIconLanguage lang_; IconMaker maker_; diff -Nru metview-5.17.4/metview/src/Desktop/Queue.cc metview-5.19.2/metview/src/Desktop/Queue.cc --- metview-5.17.4/metview/src/Desktop/Queue.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Queue.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ void Queue::push(Task* t) { t->add(this); - tasks_.push_back(t); + tasks_.emplace_back(t); enable(); } diff -Nru metview-5.17.4/metview/src/Desktop/Queue.h metview-5.19.2/metview/src/Desktop/Queue.h --- metview-5.17.4/metview/src/Desktop/Queue.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Queue.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,16 +24,16 @@ void ownerGone(); private: - ~Queue(); + ~Queue() override; // No copy allowed Queue(const Queue&); Queue& operator=(const Queue&); void done(); - virtual void success(Task*, const Request&); - virtual void failure(Task*, const Request&); - virtual void run(); + void success(Task*, const Request&) override; + void failure(Task*, const Request&) override; + void run() override; IconObjectH owner_; std::list tasks_; diff -Nru metview-5.17.4/metview/src/Desktop/ReplyObserver.cc metview-5.19.2/metview/src/Desktop/ReplyObserver.cc --- metview-5.17.4/metview/src/Desktop/ReplyObserver.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ReplyObserver.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,16 +15,16 @@ //================================================================= class ReplyHandler : public MvReply { - virtual void callback(MvRequest&); + void callback(MvRequest&) override; }; void ReplyHandler::callback(MvRequest& in) { auto* s = (ReplyObserverH*)getReference(); - if (s == 0) + if (s == nullptr) return; - const char* p; + const char* p = nullptr; int i = 0; while ((p = getMessage(i++))) (*s)->message(p); @@ -38,16 +38,16 @@ class ProgressHandler : public MvProgress { - void callback(MvRequest& r); + void callback(MvRequest& r) override; }; void ProgressHandler::callback(MvRequest& in) { auto* s = (ReplyObserverH*)getReference(); - if (s == 0) + if (s == nullptr) return; - const char* p; + const char* p = nullptr; int i = 0; while ((p = getMessage(i++))) (*s)->message(p); diff -Nru metview-5.17.4/metview/src/Desktop/ReplyObserver.h metview-5.19.2/metview/src/Desktop/ReplyObserver.h --- metview-5.17.4/metview/src/Desktop/ReplyObserver.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ReplyObserver.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,10 +17,10 @@ { public: ReplyObserver(); - virtual ~ReplyObserver(); + ~ReplyObserver() override; - virtual void reply(const Request&, int) = 0; - virtual void progress(const Request&) = 0; + virtual void reply(const Request&, int) = 0; + virtual void progress(const Request&) = 0; virtual void message(const std::string&) = 0; protected: diff -Nru metview-5.17.4/metview/src/Desktop/RequestPanel.cc metview-5.19.2/metview/src/Desktop/RequestPanel.cc --- metview-5.17.4/metview/src/Desktop/RequestPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/RequestPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,20 +32,21 @@ Q_ASSERT(panelWidget_); setSizeConstraint(QLayout::SetMinAndMaxSize); - setColumnMinimumWidth(3, 200); - setColumnStretch(3, 1); + setColumnMinimumWidth(MvQRequestPanelLine::WidgetColumn, 200); + setColumnMinimumWidth(MvQRequestPanelLine::WarningColumn, 0); + setColumnStretch(MvQRequestPanelLine::WidgetColumn, 1); - int mleft, mright, mtop, mbottom; + int mleft = 0, mright = 0, mtop = 0, mbottom = 0; getContentsMargins(&mleft, &mtop, &mright, &mbottom); setContentsMargins(4, mtop, mright, mbottom); - //We need to set spacing explicitly to make MvQRequestPanelWidget work! + // We need to set spacing explicitly to make MvQRequestPanelWidget work! setHorizontalSpacing(8); setVerticalSpacing(6); - //create(parent, (char*) name); + // create(parent, (char*) name); scan(); - //Check if there are params depending on others' values (it is idependent of the Rules!!!) + // Check if there are params depending on others' values (it is idependent of the Rules!!!) for (auto& item : items_) { if (item->isDependent()) { dependentItems_.push_back(item); @@ -56,7 +57,7 @@ addWidget(w, count(), 1); setRowStretch(count() - 1, 1); - //Manage(); + // Manage(); } RequestPanel::~RequestPanel() @@ -76,21 +77,21 @@ /*Dimension a,b; - Dimension ma = 0,mb = 0; + Dimension ma = 0,mb = 0; - for(vector::iterator j = items_.begin(); j != items_.end(); ++j) - { - RequestPanelItem* p = (*j); - p->getSizes(a,b); - if(a>ma) ma = a; - if(b>mb) mb = b; - } - - for(vector::iterator j = items_.begin(); j != items_.end(); ++j) - { - RequestPanelItem* p = (*j); - p->setSizes(ma,mb); - }*/ + for(vector::iterator j = items_.begin(); j != items_.end(); ++j) + { + RequestPanelItem* p = (*j); + p->getSizes(a,b); + if(a>ma) ma = a; + if(b>mb) mb = b; + } + + for(vector::iterator j = items_.begin(); j != items_.end(); ++j) + { + RequestPanelItem* p = (*j); + p->setSizes(ma,mb); + }*/ } #if 0 Widget RequestPanel::where() @@ -113,7 +114,7 @@ // only those parameters, plus the ones that are set in the // output request, will be merged. Request r1 = request(); - Request r = class_.language().expand(r1, EXPAND_DEFAULTS, false); + Request r = class_.language().expand(r1, EXPAND_DEFAULTS, false); r.merge(o->request()); @@ -147,8 +148,8 @@ { MvQRequestPanelLine::build(*this, p); - //Who add it to the items??? - //items_.push_back(LineFactory::create(owner,param); + // Who add it to the items??? + // items_.push_back(LineFactory::create(owner,param); } void RequestPanel::call(Method proc) @@ -227,7 +228,7 @@ void RequestPanel::set(const char* p, const std::string& v) { Request r = request(); - r(p) = v.c_str(); + r(p) = v.c_str(); request(r); for (auto& dependentItem : dependentItems_) { @@ -293,7 +294,7 @@ IconObjectH RequestPanel::currentObject() { - return (items_.size() > 0) ? items_.at(0)->currentObject() : 0; + return (items_.size() > 0) ? items_.at(0)->currentObject() : nullptr; } @@ -308,8 +309,8 @@ void RequestPanel::updateParentWidget() { - //if(QWidget *w=parentWidget()) - //w->update(); + // if(QWidget *w=parentWidget()) + // w->update(); panelWidget_->delayedForceRepaint(); } @@ -359,7 +360,7 @@ void RequestPanel::applyTemporaryRules(bool temporary) { if (temporary) { - for(auto item: items_) { + for (auto item : items_) { item->setVisibleByTemporary(temporary); } panelWidget_->delayedForceRepaint(); diff -Nru metview-5.17.4/metview/src/Desktop/RequestPanel.h metview-5.19.2/metview/src/Desktop/RequestPanel.h --- metview-5.17.4/metview/src/Desktop/RequestPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/RequestPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,8 @@ class RequestPanel : public QGridLayout, public MvIconLanguageScanner { public: - RequestPanel(const IconClass&, MvQRequestPanelWidget*, Editor*, bool, const char* = 0); - virtual ~RequestPanel(); + RequestPanel(const IconClass&, MvQRequestPanelWidget*, Editor*, bool, const char* = nullptr); + ~RequestPanel() override; void changed(); void changed(RequestPanelItem&, bool = true); @@ -36,8 +36,8 @@ void registerObserver(RequestPanelItem*); const IconClass& iconClass(); - //Widget where(); - //Widget main(); + // Widget where(); + // Widget main(); void scan(); @@ -69,14 +69,14 @@ const IconClass& class_; bool apply_; - typedef void (RequestPanelItem::*Method)(); + using Method = void (RequestPanelItem::*)(); void call(Method); private: RequestPanel(const RequestPanel&); RequestPanel& operator=(const RequestPanel&); - virtual void next(const MvIconParameter&); + void next(const MvIconParameter&) override; std::map cache_; MvQRequestPanelWidget* panelWidget_; @@ -103,5 +103,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(RequestPanel); +// OS_MARK_SCHEMA_TYPE(RequestPanel); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/RequestPanelItem.cc metview-5.19.2/metview/src/Desktop/RequestPanelItem.cc --- metview-5.17.4/metview/src/Desktop/RequestPanelItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/RequestPanelItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -48,16 +48,16 @@ return EXPAND_2ND_NAME; } -//void RequestPanelItem::refresh(const std::vector&) +// void RequestPanelItem::refresh(const std::vector&) //{ -//} +// } void RequestPanelItem::grey() { - const Request& r = owner_.request(flags()); + const Request& r = owner_.request(flags()); std::vector values = r.get("_UNSET"); - bool g = false; - std::string name = param_.name(); + bool g = false; + std::string name = param_.name(); for (auto& value : values) if (name == value) { g = true; @@ -69,7 +69,7 @@ void RequestPanelItem::reset() { - const Request& r = owner_.request(flags()); + const Request& r = owner_.request(flags()); std::vector values = r.get(param_.name()); bool valChanged = (values != cache_); @@ -101,7 +101,7 @@ void RequestPanelItem::checkDefault() { - const Request& r = owner_.request(flags()); + const Request& r = owner_.request(flags()); std::vector values = r.get(param_.name()); mark(values != cache_); } @@ -113,7 +113,7 @@ void RequestPanelItem::decache() { cache_.clear(); - cache_.push_back("\1\2\3"); // Something imposible + cache_.emplace_back("\1\2\3"); // Something imposible } /*void RequestPanelItem::mark(bool) diff -Nru metview-5.17.4/metview/src/Desktop/RequestPanelItem.h metview-5.19.2/metview/src/Desktop/RequestPanelItem.h --- metview-5.17.4/metview/src/Desktop/RequestPanelItem.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/RequestPanelItem.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,8 @@ RequestPanelItem(RequestPanel&, const MvIconParameter&); virtual ~RequestPanelItem(); - //virtual void getSizes(Dimension&,Dimension&); - //virtual void setSizes(Dimension,Dimension); + // virtual void getSizes(Dimension&,Dimension&); + // virtual void setSizes(Dimension,Dimension); virtual void reset(); virtual void update(); @@ -41,13 +41,13 @@ virtual void setVisibleByFilter(bool) = 0; virtual void setVisibleByTemporary(bool) = 0; - virtual void adjustDisabled() = 0; - virtual void gray(bool) = 0; - virtual void mark(bool) = 0; - virtual bool hasDefaultTb() = 0; + virtual void adjustDisabled() = 0; + virtual void gray(bool) = 0; + virtual void mark(bool) = 0; + virtual bool hasDefaultTb() = 0; virtual bool isDependent() const { return false; } - virtual bool isGray() const = 0; + virtual bool isGray() const = 0; virtual bool isVisibleByFilter() const = 0; virtual void edit(IconObject*); @@ -62,7 +62,7 @@ void decache(); - bool visibleByTemporary_{true}; + bool visibleByTemporary_{true}; private: RequestPanelItem(const RequestPanelItem&); diff -Nru metview-5.17.4/metview/src/Desktop/ResolveTransaction.cc metview-5.19.2/metview/src/Desktop/ResolveTransaction.cc --- metview-5.17.4/metview/src/Desktop/ResolveTransaction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ResolveTransaction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -54,7 +54,7 @@ void ResolveTransaction::callback(MvRequest& r) { const char* name = r("NAME"); - IconObject* o = name ? IconObject::search(name) : nullptr; + IconObject* o = name ? IconObject::search(name) : nullptr; if (o == nullptr) { setError(1, "Cannot find object"); diff -Nru metview-5.17.4/metview/src/Desktop/ResolveTransaction.h metview-5.19.2/metview/src/Desktop/ResolveTransaction.h --- metview-5.17.4/metview/src/Desktop/ResolveTransaction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ResolveTransaction.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ { public: ResolveTransaction(); - ~ResolveTransaction(); + ~ResolveTransaction() override; static void init(); @@ -32,16 +32,16 @@ ResolveTransaction(MvTransaction*); ResolveTransaction& operator=(const ResolveTransaction&); - virtual MvTransaction* cloneSelf(); - virtual void callback(MvRequest&); + MvTransaction* cloneSelf() override; + void callback(MvRequest&) override; - virtual void success(Task*, const Request&); - void failure(Task*, const Request&); + void success(Task*, const Request&) override; + void failure(Task*, const Request&) override; }; inline void destroy(ResolveTransaction**) {} // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(ResolveTransaction); +// OS_MARK_SCHEMA_TYPE(ResolveTransaction); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/RootFolder.cc metview-5.19.2/metview/src/Desktop/RootFolder.cc --- metview-5.17.4/metview/src/Desktop/RootFolder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/RootFolder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,7 @@ { std::string p = "/"; return Path(p); - //return path().add(".MainWindowResources"); + // return path().add(".MainWindowResources"); } std::string RootFolder::fullName() const diff -Nru metview-5.17.4/metview/src/Desktop/RootFolder.h metview-5.19.2/metview/src/Desktop/RootFolder.h --- metview-5.17.4/metview/src/Desktop/RootFolder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/RootFolder.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,7 @@ { public: RootFolder(); - virtual ~RootFolder(); + ~RootFolder() override; private: // No copy allowed diff -Nru metview-5.17.4/metview/src/Desktop/Runnable.cc metview-5.19.2/metview/src/Desktop/Runnable.cc --- metview-5.17.4/metview/src/Desktop/Runnable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Runnable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,7 +13,7 @@ #include #include -#include "assert.h" +#include using Set = std::set; static Set runnables; @@ -24,7 +24,7 @@ { // Copy as Runnable may be removed - Set s = runnables; + Set s = runnables; int active = 0; for (auto j : s) { @@ -35,13 +35,13 @@ } if (active != 0) { - //Find an exisiting runnable and set the timer for it! + // Find an exisiting runnable and set the timer for it! auto j = runnables.begin(); if (j != runnables.end()) { QTimer::singleShot(0, (*j), SLOT(slotWork())); } else { - //This should not happen! + // This should not happen! assert(0); } } diff -Nru metview-5.17.4/metview/src/Desktop/Runnable.h metview-5.19.2/metview/src/Desktop/Runnable.h --- metview-5.17.4/metview/src/Desktop/Runnable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Runnable.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ public: Runnable(); - virtual ~Runnable(); // Change to virtual if base class + ~Runnable() override; // Change to virtual if base class void enable(); void disable(); @@ -34,6 +34,6 @@ bool actived_; - //QT slot??? - //static Boolean workCB(XtPointer); + // QT slot??? + // static Boolean workCB(XtPointer); }; diff -Nru metview-5.17.4/metview/src/Desktop/Service.cc metview-5.19.2/metview/src/Desktop/Service.cc --- metview-5.17.4/metview/src/Desktop/Service.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Service.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,7 +13,7 @@ #include -using Map = std::map; +using Map = std::map; static Map* services = nullptr; Service::Service(const std::string& name) : diff -Nru metview-5.17.4/metview/src/Desktop/ServiceEditor.cc metview-5.19.2/metview/src/Desktop/ServiceEditor.cc --- metview-5.17.4/metview/src/Desktop/ServiceEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ServiceEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ #include "MvMiscellaneous.h" #include "MvTmpFile.h" -#include +#include #include #define SERVICEEDITOR_MV_DEBUG__ @@ -51,7 +51,7 @@ if (replyObserver_) { replyObserver_->editor_ = nullptr; } - //edit again + // edit again edit(); } } @@ -61,7 +61,7 @@ void ServiceEditor::closeIt() { editDone(); - //TODO: what else can we do? + // TODO: what else can we do? } @@ -70,7 +70,7 @@ // Called to start editing a macro. We call the macroedit service to // bring up the Qt macro editor. -void ServiceEditor::edit(void) +void ServiceEditor::edit() { std::string path = current_->path().str(); assert(replyObserver_ == nullptr); @@ -89,7 +89,7 @@ void ServiceEditor::editDone() { replyObserver_ = nullptr; - remotePid_ = -1; + remotePid_ = -1; pidFile_.clear(); Editor::editDone(); } @@ -137,23 +137,23 @@ if (kind == "WMSCLIENT") { r.read(path_.c_str()); - r("_NAME") = path_.c_str(); + r("_NAME") = path_.c_str(); r("_CLASS") = kind.c_str(); } else if (kind == "RTTOV_INPUT_DATA" || kind == "SCM_INPUT_DATA") { - r = MvRequest(kind.c_str()); - r("PATH") = path_.c_str(); - r("_NAME") = path_.c_str(); + r = MvRequest(kind.c_str()); + r("PATH") = path_.c_str(); + r("_NAME") = path_.c_str(); r("_CLASS") = kind.c_str(); } else { - r = ("MACROEDIT"); - r("PATH") = path_.c_str(); // path to macro + r = ("MACROEDIT"); + r("PATH") = path_.c_str(); // path to macro r("LANGUAGE") = editor_->iconClass().name().c_str(); // icon class, e.g. MACRO or MAGML - r("_CLASS") = editor_->iconClass().name().c_str(); // icon class, e.g. MACRO or MAGML + r("_CLASS") = editor_->iconClass().name().c_str(); // icon class, e.g. MACRO or MAGML } - r("_ACTION") = "edit"; + r("_ACTION") = "edit"; r("_PID_FILE") = pidFile.c_str(); r("_WAIT_APP") = "1"; r.print(); diff -Nru metview-5.17.4/metview/src/Desktop/ServiceEditor.h metview-5.19.2/metview/src/Desktop/ServiceEditor.h --- metview-5.17.4/metview/src/Desktop/ServiceEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ServiceEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ public: ServiceEditorObserver(ServiceEditor* editor, std::string& path); - virtual ~ServiceEditorObserver() = default; + ~ServiceEditorObserver() override = default; void start(const std::string& pidFile); @@ -43,7 +43,7 @@ { public: ServiceEditor(const IconClass&, const std::string&); - virtual ~ServiceEditor() = default; + ~ServiceEditor() override = default; void changed() override {} void raiseIt() override; void closeIt() override; @@ -56,7 +56,7 @@ ServiceEditor(const ServiceEditor&); ServiceEditor& operator=(const ServiceEditor&); - void edit(void) override; + void edit() override; void showIt() override {} void getRemotePid(); bool isRemoteRunning() const; diff -Nru metview-5.17.4/metview/src/Desktop/ShellService.h metview-5.19.2/metview/src/Desktop/ShellService.h --- metview-5.17.4/metview/src/Desktop/ShellService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ShellService.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,14 +15,14 @@ { public: ShellService(const std::string&); - virtual ~ShellService(); + ~ShellService() override; private: // No copy allowed ShellService(const ShellService&); ShellService& operator=(const ShellService&); - virtual Task* task(const Action&, IconObject*); + Task* task(const Action&, IconObject*) override; }; inline void destroy(ShellService**) {} diff -Nru metview-5.17.4/metview/src/Desktop/ShellTask.h metview-5.19.2/metview/src/Desktop/ShellTask.h --- metview-5.17.4/metview/src/Desktop/ShellTask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ShellTask.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,18 +18,18 @@ { public: ShellTask(const std::string&, IconObject*); - virtual ~ShellTask(); + ~ShellTask() override; - virtual void addContext(const Request&) {} + void addContext(const Request&) override {} protected: - void print(std::ostream&) const; + void print(std::ostream&) const override; void Object(IconObjectH xx) { object_ = xx; } // From Task - virtual void start(); + void start() override; // From Input - virtual void done(FILE*); + void done(FILE*) override; private: // No copy allowed @@ -41,7 +41,7 @@ std::string cmd_; // From Input - virtual void ready(const char*); + void ready(const char*) override; }; inline void destroy(ShellTask**) {} diff -Nru metview-5.17.4/metview/src/Desktop/SimpleEditor.cc metview-5.19.2/metview/src/Desktop/SimpleEditor.cc --- metview-5.17.4/metview/src/Desktop/SimpleEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/SimpleEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ setupLineFilter(); setupShowDisabledActions(); - //Panel + // Panel panelArea_ = new QScrollArea(this); panelArea_->setWidgetResizable(true); @@ -56,11 +56,11 @@ IconObject* SimpleEditor::copy(const std::string& /*name*/) { - //IconObject* o = IconFactory::create(name, class_); - //panel_.apply(); - //o->request(panel_.request()); - //return o; - return 0; + // IconObject* o = IconFactory::create(name, class_); + // panel_.apply(); + // o->request(panel_.request()); + // return o; + return nullptr; } void SimpleEditor::edit() @@ -93,16 +93,16 @@ void SimpleEditor::close() { panel_->close(); - //Enable again the widget + // Enable again the widget if (QWidget* w = panelArea_->widget()) w->setEnabled(true); } -//Request SimpleEditor::currentRequest(long custom_expand) +// Request SimpleEditor::currentRequest(long custom_expand) //{ -//panel_.apply(); -//return custom_expand ? panel_.request(custom_expand) : panel_.request(); -//} +// panel_.apply(); +// return custom_expand ? panel_.request(custom_expand) : panel_.request(); +// } void SimpleEditor::replace(IconObjectH obj) { diff -Nru metview-5.17.4/metview/src/Desktop/SimpleEditor.h metview-5.19.2/metview/src/Desktop/SimpleEditor.h --- metview-5.17.4/metview/src/Desktop/SimpleEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/SimpleEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,9 @@ Q_OBJECT public: SimpleEditor(const IconClass&, const std::string&); - virtual ~SimpleEditor(); + ~SimpleEditor() override; - //Request currentRequest(long custom_expand=0); + // Request currentRequest(long custom_expand=0); void replace(IconObjectH) override; void merge(IconObjectH) override; @@ -63,5 +63,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(SimpleEditor); +// OS_MARK_SCHEMA_TYPE(SimpleEditor); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/StandardObject.cc metview-5.19.2/metview/src/Desktop/StandardObject.cc --- metview-5.17.4/metview/src/Desktop/StandardObject.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/StandardObject.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ { public: StandardObjectDependancy(IconObject*, const std::string&, int); - ~StandardObjectDependancy(); + ~StandardObjectDependancy() override; int n() { return n_; } const std::string& param() { return param_; } @@ -37,9 +37,9 @@ IconObjectH object() { return object_; } private: - virtual Task* action(const Action&); - virtual void success(const Request&); - virtual void failure(const Request&); + Task* action(const Action&) override; + void success(const Request&) override; + void failure(const Request&) override; IconObjectH object_; std::string param_; @@ -64,13 +64,13 @@ void StandardObjectDependancy::success(const Request& r) { - ok_ = true; + ok_ = true; request_ = r; } void StandardObjectDependancy::failure(const Request& r) { - ok_ = false; + ok_ = false; request_ = r; } @@ -124,7 +124,7 @@ std::vector icons = language().interfaces("icon"); for (auto& icon : icons) { - int i = 0; + int i = 0; std::vector sub = subObjects(icon, r); for (auto& k : sub) @@ -144,7 +144,7 @@ std::vector icons = language().interfaces("icon"); for (auto& icon : icons) { - int i = 0; + int i = 0; std::vector sub = subObjects(icon, r); for (auto& k : sub) @@ -165,9 +165,9 @@ Map2 m; for (const auto& dependancie : dependancies_) { - auto* b = dynamic_cast((Dependancy*)dependancie); + auto* b = dynamic_cast((Dependancy*)dependancie); const auto& p = b->param(); - auto n = b->n(); + auto n = b->n(); const auto& r = b->request(); m[p][n] = r; @@ -175,9 +175,9 @@ for (auto& j : m) { const std::string& param = j.first; - const Map1& reqs = j.second; + const Map1& reqs = j.second; - ::request* empty = 0; + ::request* empty = nullptr; MvRequest s(empty); for (const auto& req : reqs) @@ -236,9 +236,9 @@ //-- i.e. use these lines to set breakpoint in debugger!! std::string s("MvUI/StandardObject::clone()"); - //Log::info(s) << "internal error: nullptr!" << std::endl; + // Log::info(s) << "internal error: nullptr!" << std::endl; - return 0; //-- probably we should not do this... + return nullptr; //-- probably we should not do this... } std::vector icons = language().interfaces("icon"); @@ -276,7 +276,7 @@ if (o) { std::cout << "CLONE: " << k->fullName() << std::endl; - vOther.push_back(o); + vOther.emplace_back(o); std::cout << " IS: " << o->fullName() << std::endl; } } diff -Nru metview-5.17.4/metview/src/Desktop/StandardObject.h metview-5.19.2/metview/src/Desktop/StandardObject.h --- metview-5.17.4/metview/src/Desktop/StandardObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/StandardObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,11 +23,11 @@ const IconClass& kind, const std::string& name, IconInfo* info); - virtual ~StandardObject(); + ~StandardObject() override; void duplicate() override; IconObject* clone(Folder*, bool update = false) override; IconObject* clone(Folder*, int x, int y, bool update = false) override; - bool storedAsRequestFile() const override {return true;} + bool storedAsRequestFile() const override { return true; } protected: Request request() const override; @@ -51,5 +51,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(StandardObject); +// OS_MARK_SCHEMA_TYPE(StandardObject); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/State.cc metview-5.19.2/metview/src/Desktop/State.cc --- metview-5.17.4/metview/src/Desktop/State.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/State.cc 2023-07-15 08:28:47.000000000 +0000 @@ -47,7 +47,7 @@ } for (int ic = 0; ic < nc; ic++) { - const char* c = get_value(r, "class", ic); + const char* c = get_value(r, "class", ic); const IconClass& cc = IconClass::find(c ? c : "*"); for (int ia = 0; ia < na; ia++) { @@ -56,7 +56,7 @@ for (int im = 0; im < nm; im++) { const char* m = get_value(r, "mode", im); for (int io = 0; io < no; io++) { - const char* o = get_value(r, "output_class", io); + const char* o = get_value(r, "output_class", io); const IconClass* oc = o ? &IconClass::find(o) : nullptr; cc.service(Action(a ? a : "*", m ? m : "*"), oc, p); } diff -Nru metview-5.17.4/metview/src/Desktop/SystemFolder.h metview-5.19.2/metview/src/Desktop/SystemFolder.h --- metview-5.17.4/metview/src/Desktop/SystemFolder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/SystemFolder.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ SystemFolder(Folder* parent, const IconClass& kind, const std::string& name, IconInfo* info); - virtual ~SystemFolder(); + ~SystemFolder() override; protected: std::set can() override; @@ -33,5 +33,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(SystemFolder); +// OS_MARK_SCHEMA_TYPE(SystemFolder); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/Task.h metview-5.19.2/metview/src/Desktop/Task.h --- metview-5.17.4/metview/src/Desktop/Task.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Task.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ { public: Task(); - virtual ~Task(); + ~Task() override; virtual void start() = 0; virtual void stop(); @@ -33,8 +33,6 @@ void success(const Request&); void failure(const Request&); - virtual void print(std::ostream&) const = 0; - bool stopped_; private: @@ -52,4 +50,4 @@ friend class Queue; }; -typedef Handle TaskH; +using TaskH = Handle; diff -Nru metview-5.17.4/metview/src/Desktop/TaskObserver.h metview-5.19.2/metview/src/Desktop/TaskObserver.h --- metview-5.17.4/metview/src/Desktop/TaskObserver.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/TaskObserver.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,6 +15,7 @@ class TaskObserver { public: + virtual ~TaskObserver() = default; virtual void success(Task*, const Request&) = 0; virtual void failure(Task*, const Request&) = 0; }; diff -Nru metview-5.17.4/metview/src/Desktop/TeeBuffer.cc metview-5.19.2/metview/src/Desktop/TeeBuffer.cc --- metview-5.17.4/metview/src/Desktop/TeeBuffer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/TeeBuffer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,7 @@ #include "TeeBuffer.h" -#include +#include TeeBuffer::TeeBuffer(std::ostream& one, std::ostream& two) : std::streambuf(), diff -Nru metview-5.17.4/metview/src/Desktop/TeeBuffer.h metview-5.19.2/metview/src/Desktop/TeeBuffer.h --- metview-5.17.4/metview/src/Desktop/TeeBuffer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/TeeBuffer.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,11 +17,11 @@ { public: TeeBuffer(std::ostream&, std::ostream&); - ~TeeBuffer(); + ~TeeBuffer() override; protected: - int overflow(int); - int sync(); + int overflow(int) override; + int sync() override; private: // No copy allowed @@ -32,12 +32,12 @@ std::ostream& one_; std::ostream& two_; - void dumpBuffer(void); + void dumpBuffer(); }; inline void destroy(TeeBuffer**) {} // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(TeeBuffer); +// OS_MARK_SCHEMA_TYPE(TeeBuffer); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/TeeStream.h metview-5.19.2/metview/src/Desktop/TeeStream.h --- metview-5.17.4/metview/src/Desktop/TeeStream.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/TeeStream.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ { public: TeeStream(std::ostream&, std::ostream&); - ~TeeStream(); + ~TeeStream() override; private: // No copy allowed @@ -28,5 +28,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(TeeStream); +// OS_MARK_SCHEMA_TYPE(TeeStream); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/TemporaryEditor.cc metview-5.19.2/metview/src/Desktop/TemporaryEditor.cc --- metview-5.17.4/metview/src/Desktop/TemporaryEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/TemporaryEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,7 +26,7 @@ TemporaryEditor::TemporaryEditor(const IconClass& kind, const std::string& name) : MvQTemporaryEditor(kind, name) { - //Panel + // Panel panelArea_ = new QScrollArea(this); panelArea_->setWidgetResizable(true); @@ -36,7 +36,7 @@ classes.push_back(kind.name()); auto* w = new MvQRequestPanelWidget(classes, this); - panel_ = new RequestPanel(kind, w, this, false); + panel_ = new RequestPanel(kind, w, this, false); panelArea_->setWidget(w); } @@ -49,11 +49,11 @@ IconObject* TemporaryEditor::copy(const std::string& /*name*/) { - //IconObject* o = IconFactory::create(name, class_); - //panel_.apply(); - //o->request(panel_.request()); - //return o; - return 0; + // IconObject* o = IconFactory::create(name, class_); + // panel_.apply(); + // o->request(panel_.request()); + // return o; + return nullptr; } void TemporaryEditor::edit() @@ -81,10 +81,10 @@ panel_->close(); } -//Request TemporaryEditor::currentRequest(long custom_expand) +// Request TemporaryEditor::currentRequest(long custom_expand) //{ -//panel_.apply(); -//return custom_expand ? panel_.request(custom_expand) : panel_.request(); -//} +// panel_.apply(); +// return custom_expand ? panel_.request(custom_expand) : panel_.request(); +// } static EditorMaker editorMaker1("TemporaryEditor"); diff -Nru metview-5.17.4/metview/src/Desktop/TemporaryEditor.h metview-5.19.2/metview/src/Desktop/TemporaryEditor.h --- metview-5.17.4/metview/src/Desktop/TemporaryEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/TemporaryEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,16 +21,16 @@ { public: TemporaryEditor(const IconClass&, const std::string&); - virtual ~TemporaryEditor(); + ~TemporaryEditor() override; private: TemporaryEditor(const TemporaryEditor&); TemporaryEditor& operator=(const TemporaryEditor&); - virtual void apply(); - virtual void reset(); - virtual void close(); - virtual void edit(); + void apply() override; + void reset() override; + void close() override; + void edit() override; virtual IconObject* copy(const std::string&); diff -Nru metview-5.17.4/metview/src/Desktop/TemporaryFolder.h metview-5.19.2/metview/src/Desktop/TemporaryFolder.h --- metview-5.17.4/metview/src/Desktop/TemporaryFolder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/TemporaryFolder.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,14 +17,14 @@ TemporaryFolder(Folder* parent, const IconClass& kind, const std::string& name, IconInfo* info); - virtual ~TemporaryFolder(); // Change to virtual if base class + ~TemporaryFolder() override; // Change to virtual if base class private: // No copy allowed TemporaryFolder(const TemporaryFolder&); TemporaryFolder& operator=(const TemporaryFolder&); - virtual void createFiles(); + void createFiles() override; }; inline void destroy(TemporaryFolder**) {} diff -Nru metview-5.17.4/metview/src/Desktop/TemporaryObject.h metview-5.19.2/metview/src/Desktop/TemporaryObject.h --- metview-5.17.4/metview/src/Desktop/TemporaryObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/TemporaryObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,15 +17,15 @@ class TemporaryObject : public IconObject { public: - TemporaryObject(IconObject*, const Request&, const IconClass* = 0); - virtual ~TemporaryObject(); + TemporaryObject(IconObject*, const Request&, const IconClass* = nullptr); + ~TemporaryObject() override; protected: TemporaryObject(const TemporaryObject&); TemporaryObject& operator=(const TemporaryObject&); void createFiles() override; - //virtual Log& log(); + // virtual Log& log(); Request request() const override; void setRequest(const Request&) override; std::string fullName() const override; @@ -50,7 +50,7 @@ std::string relativeName(IconObject*) const override; std::string makeFullName(const std::string&) const override; - bool storedAsRequestFile() const override {return true;} + bool storedAsRequestFile() const override { return true; } private: IconObjectH ref_; @@ -61,5 +61,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(TemporaryObject); +// OS_MARK_SCHEMA_TYPE(TemporaryObject); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/Tools.cc metview-5.19.2/metview/src/Desktop/Tools.cc --- metview-5.17.4/metview/src/Desktop/Tools.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Tools.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ void Tools::make(QList& lst, QObject* parent) { for (auto& tool : tools) { - auto* ac = new QAction(parent); + auto* ac = new QAction(parent); const char* text = get_value(tool->request_, "label", 0); ac->setText(text); @@ -48,7 +48,7 @@ std::cout << "Tools::start " << get_value(request_, "service", 0) << std::endl; Request r(get_value(request_, "action", 0)); - MvApplication::callService(get_value(request_, "service", 0), r, 0); + MvApplication::callService(get_value(request_, "service", 0), r, nullptr); } diff -Nru metview-5.17.4/metview/src/Desktop/Tools.h metview-5.19.2/metview/src/Desktop/Tools.h --- metview-5.17.4/metview/src/Desktop/Tools.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Tools.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ public: Tools(request*); - ~Tools(); + ~Tools() override; static void make(QList&, QObject*); static void load(request*); diff -Nru metview-5.17.4/metview/src/Desktop/Transaction.h metview-5.19.2/metview/src/Desktop/Transaction.h --- metview-5.17.4/metview/src/Desktop/Transaction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Transaction.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,10 @@ public: Transaction(const char*); Transaction(MvTransaction*); - ~Transaction(); + ~Transaction() override; - virtual MvTransaction* cloneSelf() = 0; - virtual void callback(MvRequest&) = 0; + MvTransaction* cloneSelf() override = 0; + void callback(MvRequest&) override = 0; private: // No copy allowed @@ -31,5 +31,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(Transaction); +// OS_MARK_SCHEMA_TYPE(Transaction); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/ViewEditor.cc metview-5.19.2/metview/src/Desktop/ViewEditor.cc --- metview-5.17.4/metview/src/Desktop/ViewEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ViewEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -56,7 +56,7 @@ MvQEditor(name, kind) { paper_ = new PaperSizeHandler; - snap_ = new GridSnapHandler; + snap_ = new GridSnapHandler; undoStack_ = new QUndoStack(this); @@ -66,17 +66,17 @@ QList tbLst; - //redo + // redo QAction* redoAc = undoStack_->createRedoAction(this, tr("&Redo")); redoAc->setShortcuts(QKeySequence::Redo); redoAc->setIcon(QPixmap(":/desktop/redo.svg")); - //undo + // undo QAction* undoAc = undoStack_->createUndoAction(this, tr("&Undo")); undoAc->setShortcuts(QKeySequence::Undo); undoAc->setIcon(QPixmap(":/desktop/undo.svg")); - //Duplicate + // Duplicate auto* duplicateAc = new QAction(this); duplicateAc->setToolTip(tr("Duplicate selected frames")); duplicateAc->setIcon(QPixmap(":/desktop/duplicate.svg")); @@ -84,7 +84,7 @@ connect(duplicateAc, SIGNAL(triggered(bool)), this, SLOT(slotDuplicateSelection(bool))); - //page setup + // page setup auto* pageAc = new QAction(this); pageAc->setToolTip(tr("Page setup")); pageAc->setIcon(QPixmap(":/desktop/page_setup.svg")); @@ -138,7 +138,7 @@ // Sidebar on the right //----------------------- - //Sidebar on the right + // Sidebar on the right auto* rightVb = new QVBoxLayout; rightVb->setSpacing(0); rightVb->setContentsMargins(1, 1, 1, 1); @@ -193,8 +193,8 @@ connect(expandAc, SIGNAL(triggered(bool)), this, SLOT(slotExpandSelection(bool))); - //connect(connectAc,SIGNAL(triggered(bool)), - //this,SLOT(slotConnectSelection(bool))); + // connect(connectAc,SIGNAL(triggered(bool)), + // this,SLOT(slotConnectSelection(bool))); connect(disconnectAc, SIGNAL(triggered(bool)), this, SLOT(slotDisconnectSelection(bool))); @@ -215,8 +215,8 @@ // View //-------------------- - MvIconLanguage& lang = IconClass::find("PLOT_PAGE").language(); - Request interface = lang.interfaceRequest("VIEW"); + MvIconLanguage& lang = IconClass::find("PLOT_PAGE").language(); + Request interface = lang.interfaceRequest("VIEW"); const std::vector& classes = interface.get("class"); view_ = new MvQPageView(classes, undoStack_, this); @@ -242,8 +242,8 @@ void ViewEditor::reset() { - //cache_.clear(); - //save_.clear(); + // cache_.clear(); + // save_.clear(); request_ = current_->request(); request_.print(); @@ -251,15 +251,15 @@ loadPaperSize(request_); loadPages(current_, request_); - //PaperSetPages(paper_,loadPages(current_,request_)); - //updateDrawers(); - //PaperSelectFirst(paper_); + // PaperSetPages(paper_,loadPages(current_,request_)); + // updateDrawers(); + // PaperSelectFirst(paper_); } void ViewEditor::close() { view_->clear(); - //save_.clear(); + // save_.clear(); } void ViewEditor::merge(IconObjectH /*o*/) @@ -280,50 +280,50 @@ setPaperSize(h, w); - //cout << "h = " << h << " w = " << w << std::endl; + // cout << "h = " << h << " w = " << w << std::endl; - /* + /* std::cout << "paperSize " << std::endl; - r.print(); + r.print(); + + // Set paper size... + double w = r("CUSTOM_HEIGHT"); + double h = r("CUSTOM_WIDTH"); - // Set paper size... - double w = r("CUSTOM_HEIGHT"); - double h = r("CUSTOM_WIDTH"); - - const char* size = r("LAYOUT_SIZE"); - const char* orien = r("LAYOUT_ORIENTATION"); - - if(size && orien) - { - for(int i = 0; i < static_cast(paperSizes_.size()) ; i++) - { + const char* size = r("LAYOUT_SIZE"); + const char* orien = r("LAYOUT_ORIENTATION"); + + if(size && orien) + { + for(int i = 0; i < static_cast(paperSizes_.size()) ; i++) + { if(paperSizes_[i].name() == std::string(size)) - { - if(strcmp(orien,"PORTRAIT") == 0) - { - h = paperSizes_[i].height(); - w = paperSizes_[i].width(); - break; - } - else - { - w = paperSizes_[i].height(); - h = paperSizes_[i].width(); - break; - } - } - } - } - - paperSizeReq_("LAYOUT_SIZE")=size; - paperSizeReq_("LAYOUT_SIZE")=orien; - paperSizeReq_("CUSTOM_HEIGHT")=h; - paperSizeReq_("CUSTOM_WIDTH")=w; - - setPaperSize(h,w); + { + if(strcmp(orien,"PORTRAIT") == 0) + { + h = paperSizes_[i].height(); + w = paperSizes_[i].width(); + break; + } + else + { + w = paperSizes_[i].height(); + h = paperSizes_[i].width(); + break; + } + } + } + } - cout << "h = " << h << " w = " << w << std::endl; - */ + paperSizeReq_("LAYOUT_SIZE")=size; + paperSizeReq_("LAYOUT_SIZE")=orien; + paperSizeReq_("CUSTOM_HEIGHT")=h; + paperSizeReq_("CUSTOM_WIDTH")=w; + + setPaperSize(h,w); + + cout << "h = " << h << " w = " << w << std::endl; + */ } void ViewEditor::savePaperSize(Request& r) @@ -343,7 +343,7 @@ void ViewEditor::loadPages(IconObject* o, const Request& r) { - //Clear the view + // Clear the view std::vector sub = o->subObjects("PAGES", r); @@ -352,10 +352,10 @@ pageReq.print(); - double top = pageReq("TOP"); - double left = pageReq("LEFT"); - double right = pageReq("RIGHT"); - double bottom = pageReq("BOTTOM"); + double top = pageReq("TOP"); + double left = pageReq("LEFT"); + double right = pageReq("RIGHT"); + double bottom = pageReq("BOTTOM"); MvQPageItem* pageItem = view_->addPage(left, top, right - left, bottom - top); std::vector viewVec = itPage->subObjects("VIEW", pageReq); @@ -372,34 +372,34 @@ // Old style /*int rows = r("ROWS"); - int cols = r("COLUMNS"); + int cols = r("COLUMNS"); - if(rows * cols > 1) - { - double height = 1.0 / rows;pageItem - double width = 1.0 / cols; - double x = 0; - - for(int i = 0; i < cols; i++) - { - double y = 0; - for(int j = 0; j < rows; j++) - { - PaperRectangle* s = PaperNewPage( - paper_, - y, - x, - (j == rows - 1) ? 1.0 : y + height, - (i == cols - 1) ? 1.0 : x + width - ); - - s->next = pages; - pages = s; - y += height; - } - x += width; - } - }*/ + if(rows * cols > 1) + { + double height = 1.0 / rows;pageItem + double width = 1.0 / cols; + double x = 0; + + for(int i = 0; i < cols; i++) + { + double y = 0; + for(int j = 0; j < rows; j++) + { + PaperRectangle* s = PaperNewPage( + paper_, + y, + x, + (j == rows - 1) ? 1.0 : y + height, + (i == cols - 1) ? 1.0 : x + width + ); + + s->next = pages; + pages = s; + y += height; + } + x += width; + } + }*/ // New Style std::vector sub = o->subObjects("SUB_PAGES", r); @@ -408,9 +408,9 @@ subR.print(); - double top = subR("TOP"); - double left = subR("LEFT"); - double right = subR("RIGHT"); + double top = subR("TOP"); + double left = subR("LEFT"); + double right = subR("RIGHT"); double bottom = subR("BOTTOM"); p->addSubPaperRectInPageCoords(left, top, right - left, bottom - top); @@ -437,7 +437,7 @@ pageReq.print(); - IconObjectH page = IconFactory::create(pageFolder, pageReq, 0, 0); + IconObjectH page = IconFactory::create(pageFolder, pageReq, 0, 0); FolderH subPageFolder = page->embeddedFolder("Sub Pages", true); pages.push_back(page); @@ -447,7 +447,7 @@ Request subReq("PLOT_SUBPAGE"); saveRectToRequest(subRect, subReq); subReq.print(); - subpages.push_back(IconFactory::create(subPageFolder, subReq, 0, 0)); + subpages.emplace_back(IconFactory::create(subPageFolder, subReq, 0, 0)); } page->setSubObjects("SUB_PAGES", subpages, pageReq); @@ -467,15 +467,15 @@ void ViewEditor::saveRectToRequest(QRectF rect, Request& r) { - double top = rect.y(); - double left = rect.x(); + double top = rect.y(); + double left = rect.x(); double bottom = rect.bottomLeft().y(); - double right = rect.topRight().x(); + double right = rect.topRight().x(); - r("TOP") = top; - r("LEFT") = left; + r("TOP") = top; + r("LEFT") = left; r("BOTTOM") = bottom; - r("RIGHT") = right; + r("RIGHT") = right; } IconObject* ViewEditor::defaultView() @@ -490,24 +490,24 @@ return; /*if(selected ==0) - { - joinAc->setEnabled(false); - splitAc->setEnabled(false); - deleteAc->setEnabled(false); - expandAc->setEnabled(false); - } - - else - { - splitAc->setEnabled(true); - deleteAc->setEnabled(true); - expandAc->setEnabled(true); - - if(selected > 1) - joinAc->setEnabled(true); - else - joinAc->setEnabled(false); - }*/ + { + joinAc->setEnabled(false); + splitAc->setEnabled(false); + deleteAc->setEnabled(false); + expandAc->setEnabled(false); + } + + else + { + splitAc->setEnabled(true); + deleteAc->setEnabled(true); + expandAc->setEnabled(true); + + if(selected > 1) + joinAc->setEnabled(true); + else + joinAc->setEnabled(false); + }*/ } @@ -611,7 +611,7 @@ if (!v.isNull()) gridAc_->setChecked(v.toBool()); - v = settings.value("grid_x"); + v = settings.value("grid_x"); QVariant v1 = settings.value("grid_y"); if (!v.isNull() && !v1.isNull()) { @@ -650,7 +650,7 @@ PaperSizeHandler::PaperSizeHandler() : orientation_("Landscape"), - current_(0) + current_(nullptr) { if (std_.size() == 0) { std_.push_back(new PaperSize("A4", 21, 29.7, "PORTRAIT")); @@ -670,7 +670,7 @@ double h = r("CUSTOM_HEIGHT"); double w = r("CUSTOM_WIDTH"); - const char* size = r("LAYOUT_SIZE"); + const char* size = r("LAYOUT_SIZE"); const char* orien = r("LAYOUT_ORIENTATION"); std::string sizeStr = "A4"; @@ -685,7 +685,7 @@ for (auto& i : std_) { if (i->name() == sizeStr && i->orientation() == orientation_) { current_ = i; - found = true; + found = true; break; } } @@ -705,7 +705,7 @@ for (auto& i : std_) { if (i->name() == sizeStr && i->orientation() == orien) { current_ = i; - found = true; + found = true; break; } } @@ -719,8 +719,8 @@ void PaperSizeHandler::save(Request& r) { - r("LAYOUT_SIZE") = current_->name().c_str(); - r("CUSTOM_WIDTH") = current_->width(); + r("LAYOUT_SIZE") = current_->name().c_str(); + r("CUSTOM_WIDTH") = current_->width(); r("CUSTOM_HEIGHT") = current_->height(); if (current_ != custom_) { @@ -757,7 +757,7 @@ float v[] = {1, 2, 4, 5, 10, 12, 5, 20, 25, 50}; vals_.assign(v, v + sizeof(v) / sizeof(v[0])); - //vals_ << 1 << 2 << 4 << 5 << 10 << 12.5 << 20 << 25 << 50; + // vals_ << 1 << 2 << 4 << 5 << 10 << 12.5 << 20 << 25 << 50; xIndex_ = 3; yIndex_ = 3; } @@ -811,14 +811,14 @@ int row = 0; - //Size - label = new QLabel(tr("&Size:")); + // Size + label = new QLabel(tr("&Size:")); sizeCb_ = new QComboBox; label->setBuddy(sizeCb_); std::set nameSet; for (auto it : paper_->stdSizes()) { - //We do not allow duplicated names + // We do not allow duplicated names if (nameSet.find(it->name()) == nameSet.end()) { sizeCb_->addItem(QString::fromStdString(it->name())); sizeCb_->setItemData(sizeCb_->count() - 1, QString::fromStdString(it->name())); @@ -833,9 +833,9 @@ grid->addWidget(sizeCb_, row, 1); row++; - //orientation + // orientation oriLabel_ = new QLabel(tr("&Orientation:")); - oriCb_ = new QComboBox; + oriCb_ = new QComboBox; oriLabel_->setBuddy(oriCb_); oriCb_->addItem(tr("Portrait")); @@ -848,18 +848,18 @@ grid->addWidget(oriCb_, row, 1); row++; - //width + // width widthLabel_ = new QLabel(tr("&Width:")); - widthEdit_ = new QLineEdit; + widthEdit_ = new QLineEdit; widthLabel_->setBuddy(widthEdit_); grid->addWidget(widthLabel_, row, 0); grid->addWidget(widthEdit_, row, 1); row++; - //height + // height heightLabel_ = new QLabel(tr("&Height:")); - heightEdit_ = new QLineEdit; + heightEdit_ = new QLineEdit; heightLabel_->setBuddy(heightEdit_); grid->addWidget(heightLabel_, row, 0); @@ -870,7 +870,7 @@ // Init //---------------------------------- - //Size + // Size if (paper_->isCustom()) { sizeCb_->setCurrentIndex(sizeCb_->count() - 1); } @@ -883,20 +883,20 @@ } } - //Orientation + // Orientation if (paper_->orientation() == "PORTRAIT") oriCb_->setCurrentIndex(0); else oriCb_->setCurrentIndex(1); - //Width and height + // Width and height widthEdit_->setText(QString::number(paper_->width())); heightEdit_->setText(QString::number(paper_->height())); - //State + // State updateState(); - //Combo box signals + // Combo box signals connect(sizeCb_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSize(int))); } @@ -905,7 +905,7 @@ { int index = sizeCb_->currentIndex(); - //A4, A3, ... + // A4, A3, ... if (sizeCb_->itemData(index).toString() != "CUSTOM") { oriLabel_->setEnabled(true); oriCb_->setEnabled(true); @@ -932,7 +932,7 @@ void MvQPaperSizeWidget::accept() { int sizeIndex = sizeCb_->currentIndex(); - int oriIndex = oriCb_->currentIndex(); + int oriIndex = oriCb_->currentIndex(); if (sizeIndex >= 0 && sizeIndex < sizeCb_->count() && oriIndex >= 0 && oriIndex < oriCb_->count()) { @@ -962,17 +962,17 @@ int row = 0; - //x + // x label = new QLabel(tr("&X grid step:"), this); - xCb_ = new QComboBox(this); + xCb_ = new QComboBox(this); label->setBuddy(xCb_); grid->addWidget(label, row, 0); grid->addWidget(xCb_, row, 1); row++; - //y + // y label = new QLabel(tr("&Y grid step:"), this); - yCb_ = new QComboBox(this); + yCb_ = new QComboBox(this); label->setBuddy(yCb_); grid->addWidget(label, row, 0); grid->addWidget(yCb_, row, 1); @@ -1033,10 +1033,10 @@ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - //Try to find the optimal dialog width + // Try to find the optimal dialog width QFont font; QFontMetrics fm(font); - //setMinimumWidth(fm.width(tr("Orientation: landscape"))+100); + // setMinimumWidth(fm.width(tr("Orientation: landscape"))+100); vb->addWidget(buttonBox); } @@ -1071,7 +1071,7 @@ auto* vb = new QVBoxLayout; setLayout(vb); - //Mode selector + // Mode selector auto* modeFrame = new QFrame(this); modeFrame->setFrameShape(QFrame::StyledPanel); @@ -1081,7 +1081,7 @@ vb->addSpacing(4); auto* label = new QLabel(tr("Selection mode:")); - modeCb_ = new QComboBox(this); + modeCb_ = new QComboBox(this); modeCb_->addItem(tr("Manual")); modeCb_->addItem(tr("Graphical")); hb->addWidget(label); @@ -1095,21 +1095,21 @@ // Manual mode //--------------------------- - auto* w = new QWidget(this); + auto* w = new QWidget(this); auto* mLayout = new QVBoxLayout(); w->setLayout(mLayout); auto* mgLayout = new QGridLayout(); mLayout->addLayout(mgLayout); mLayout->addStretch(1); - //rows + // rows label = new QLabel(tr("Number of rows:"), this); mgLayout->addWidget(label, 0, 0); rowSpin_ = new QSpinBox(this); rowSpin_->setRange(1, maxRow_); mgLayout->addWidget(rowSpin_, 0, 1); - //columns + // columns label = new QLabel(tr("Number of columns:"), this); mgLayout->addWidget(label, 1, 0); colSpin_ = new QSpinBox(this); @@ -1122,7 +1122,7 @@ // Graphical mode //--------------------------- - w = new QWidget(this); + w = new QWidget(this); auto* gLayout = new QVBoxLayout; w->setLayout(gLayout); @@ -1135,15 +1135,15 @@ stacked_->addWidget(w); - //Initialise combo and stacked - //The default is the graphical mode + // Initialise combo and stacked + // The default is the graphical mode modeCb_->setCurrentIndex(1); stacked_->setCurrentIndex(1); updateLabel(); - //Signals and slots + // Signals and slots - //Connect the combobox and the stacked widget to change the mode + // Connect the combobox and the stacked widget to change the mode connect(modeCb_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChangeMode(int))); @@ -1162,17 +1162,17 @@ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - //Try to find the optimal dialog width + // Try to find the optimal dialog width QFont font; QFontMetrics fm(font); setMinimumWidth(MvQ::textWidth(fm, tr("Columns")) + 100); vb->addWidget(buttonBox); - //Read in the settings + // Read in the settings readSettings(); - //This will properly initialise everything + // This will properly initialise everything slotChangeMode(modeCb_->currentIndex()); } @@ -1220,10 +1220,10 @@ column_ = column - 1; } -//From the grid selector +// From the grid selector void MvQSplitDialog::slotSelectionChanged(int row, int column) { - row_ = row; + row_ = row; column_ = column; updateLabel(); } @@ -1237,7 +1237,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS "MV4-Desktop-SplitDialog"); - //We have to clear it so that should not remember all the previous values + // We have to clear it so that should not remember all the previous values settings.clear(); settings.beginGroup("main"); @@ -1301,8 +1301,8 @@ dy_(5) { selectedColour_ = QColor(151, 193, 219); - rectColour_ = QColor(210, 210, 210); - frameColour_ = rectColour_.darker(120); + rectColour_ = QColor(210, 210, 210); + frameColour_ = rectColour_.darker(120); setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); setMinimumSize(QSize(128, 128)); @@ -1312,16 +1312,16 @@ void MvQGridSelector::setGridSize(int row, int col) { - rowNum_ = row; + rowNum_ = row; columnNum_ = col; - row_ = 0; - column_ = 0; + row_ = 0; + column_ = 0; update(); } void MvQGridSelector::setSelection(int row, int col) { - row_ = row; + row_ = row; column_ = col; if (row_ >= rowNum_) { @@ -1340,8 +1340,8 @@ { int w = width(); int h = height(); - //gridSize_=(w= 0 && row < rowNum_ && col >= 0 && col < columnNum_ && (row != row_ || col != column_)) { - row_ = row; + row_ = row; column_ = col; emit changed(row_, column_); return true; diff -Nru metview-5.17.4/metview/src/Desktop/ViewEditor.h metview-5.19.2/metview/src/Desktop/ViewEditor.h --- metview-5.17.4/metview/src/Desktop/ViewEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/ViewEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -100,8 +100,8 @@ Q_OBJECT public: - MvQPaperSizeWidget(PaperSizeHandler*, QWidget* parent = 0); - ~MvQPaperSizeWidget() = default; + MvQPaperSizeWidget(PaperSizeHandler*, QWidget* parent = nullptr); + ~MvQPaperSizeWidget() override = default; void accept(); public slots: @@ -124,8 +124,8 @@ class MvQGridSnapWidget : public QWidget { public: - MvQGridSnapWidget(GridSnapHandler*, QWidget* parent = 0); - ~MvQGridSnapWidget() = default; + MvQGridSnapWidget(GridSnapHandler*, QWidget* parent = nullptr); + ~MvQGridSnapWidget() override = default; void accept(); protected: @@ -140,11 +140,11 @@ Q_OBJECT public: - MvQPageSetupDialog(PaperSizeHandler*, GridSnapHandler*, QWidget* parent = 0); - ~MvQPageSetupDialog() = default; + MvQPageSetupDialog(PaperSizeHandler*, GridSnapHandler*, QWidget* parent = nullptr); + ~MvQPageSetupDialog() override = default; public slots: - void accept(); + void accept() override; protected: MvQPaperSizeWidget* paper_; @@ -158,8 +158,8 @@ Q_OBJECT public: - MvQSplitDialog(QWidget* parent = 0); - ~MvQSplitDialog() = default; + MvQSplitDialog(QWidget* parent = nullptr); + ~MvQSplitDialog() override = default; int row() const { return row_; } int column() const { return column_; } @@ -168,11 +168,11 @@ void slotRowChanged(int); void slotColumnChanged(int); void slotSelectionChanged(int, int); - void accept(); - void reject(); + void accept() override; + void reject() override; protected: - void closeEvent(QCloseEvent* event); + void closeEvent(QCloseEvent* event) override; void updateLabel(); void readSettings(); void writeSettings(); @@ -197,8 +197,8 @@ Q_OBJECT public: - MvQGridSelector(int, int, int, int, QWidget* parent = 0); - ~MvQGridSelector() = default; + MvQGridSelector(int, int, int, int, QWidget* parent = nullptr); + ~MvQGridSelector() override = default; int row() const { return row_; } int column() const { return column_; } void setGridSize(int, int); @@ -208,11 +208,11 @@ void changed(int, int); protected: - void paintEvent(QPaintEvent* event); - void resizeEvent(QResizeEvent* event); - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); + void paintEvent(QPaintEvent* event) override; + void resizeEvent(QResizeEvent* event) override; + void mousePressEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent* event) override; + void mouseReleaseEvent(QMouseEvent* event) override; bool select(QPoint); int row_; @@ -234,7 +234,7 @@ public: ViewEditor(const IconClass&, const std::string&); - virtual ~ViewEditor(); + ~ViewEditor() override; void setPaperSize(double, double); void getPaperSize(double&, double&); @@ -258,12 +258,12 @@ void slotViewChanged(); protected slots: - void slotFilterItems(QString) {} - void slotShowDisabled(bool) {} + void slotFilterItems(QString) override {} + void slotShowDisabled(bool) override {} protected: - void readSettings(QSettings&); - void writeSettings(QSettings&); + void readSettings(QSettings&) override; + void writeSettings(QSettings&) override; private: // No copy allowed @@ -277,17 +277,17 @@ void savePages(IconObject*, Request&); void saveRectToRequest(QRectF, Request&); - virtual void apply(); - virtual void reset(); - virtual void close(); - virtual void merge(IconObjectH); - virtual void replace(IconObjectH); - virtual std::string alternateEditor(); + void apply() override; + void reset() override; + void close() override; + void merge(IconObjectH) override; + void replace(IconObjectH) override; + std::string alternateEditor() override; Request request_; std::vector save_; - //std::map cache_; + // std::map cache_; QAction* snapAc_; QAction* gridAc_; diff -Nru metview-5.17.4/metview/src/Desktop/Wastebasket.cc metview-5.19.2/metview/src/Desktop/Wastebasket.cc --- metview-5.17.4/metview/src/Desktop/Wastebasket.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Wastebasket.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ if (x != nullptr) { x->destroy(); - //Log::warning(this) << "Object " << o->name() + // Log::warning(this) << "Object " << o->name() // << " already in wastebasket" << std::endl; } @@ -41,17 +41,17 @@ KidMap kids = kids_; for (auto& kid : kids) { IconObject* o = kid.second; - //Log::info(this) << "Remove " << *o << std::endl; + // Log::info(this) << "Remove " << *o << std::endl; o->destroy(); } } std::set Wastebasket::can() { - //scan(); + // scan(); std::set c = SystemFolder::can(); c.insert("empty"); - //if(kids_.size()) c.insert("empty"); + // if(kids_.size()) c.insert("empty"); return c; } diff -Nru metview-5.17.4/metview/src/Desktop/Wastebasket.h metview-5.19.2/metview/src/Desktop/Wastebasket.h --- metview-5.17.4/metview/src/Desktop/Wastebasket.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/Wastebasket.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,7 @@ { public: Wastebasket(Folder* parent, const IconClass& kind, const std::string& name, IconInfo* info); - virtual ~Wastebasket(); + ~Wastebasket() override; void empty() override; @@ -31,5 +31,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(Wastebasket); +// OS_MARK_SCHEMA_TYPE(Wastebasket); //#endif diff -Nru metview-5.17.4/metview/src/Desktop/WsCollectionObject.h metview-5.19.2/metview/src/Desktop/WsCollectionObject.h --- metview-5.17.4/metview/src/Desktop/WsCollectionObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/WsCollectionObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ WsCollectionObject(const WsCollectionObject&) = delete; WsCollectionObject& operator=(const WsCollectionObject&) = delete; - ~WsCollectionObject() = default; + ~WsCollectionObject() override = default; Request request() const override; void setRequest(const Request&) override; }; diff -Nru metview-5.17.4/metview/src/Desktop/WsObject.cc metview-5.19.2/metview/src/Desktop/WsObject.cc --- metview-5.17.4/metview/src/Desktop/WsObject.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/WsObject.cc 2023-07-15 08:28:47.000000000 +0000 @@ -47,14 +47,14 @@ bool WsObject::readFromJson(MvRequest& r) const { WsDecoder::toRequest(path().str(), r); -// MvLog().dbg() << MV_FN_INFO << " r="; -// r.print(); + // MvLog().dbg() << MV_FN_INFO << " r="; + // r.print(); if (r) { if (r.getVerb() && strcmp(r.getVerb(), className().c_str()) == 0) { fileType_ = JsonFileType; return true; } - } + } r = MvRequest(); return false; } @@ -73,15 +73,15 @@ void WsObject::setRequest(const Request& r) { -// MvLog().dbg() << MV_FN_INFO << fileType_ << "r="; -// r.print(); + // MvLog().dbg() << MV_FN_INFO << fileType_ << "r="; + // r.print(); if (fileType_ != RequestFileType) { fileType_ = JsonFileType; QJsonDocument doc; WsDecoder::toJson(r, doc); -// MvLog().dbg() << "WRITE=" << path().str(); -// r.print(); -// MvLog().dbg() << "JSON=" << QString(doc.toJson()); + // MvLog().dbg() << "WRITE=" << path().str(); + // r.print(); + // MvLog().dbg() << "JSON=" << QString(doc.toJson()); QFile f(QString::fromStdString(path().str())); if (f.open(QIODevice::WriteOnly | QIODevice::Text)) { f.write(doc.toJson()); @@ -97,7 +97,7 @@ void WsObject::createFiles() { -// MvLog().dbg() << MV_FN_INFO; + // MvLog().dbg() << MV_FN_INFO; Path p = path(); if (!p.exists()) { Request r(className().c_str()); diff -Nru metview-5.17.4/metview/src/Desktop/WsObject.h metview-5.19.2/metview/src/Desktop/WsObject.h --- metview-5.17.4/metview/src/Desktop/WsObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Desktop/WsObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ WsObject(const WsObject&) = delete; WsObject& operator=(const WsObject&) = delete; - ~WsObject() = default; + ~WsObject() override = default; Request request() const override; void setRequest(const Request&) override; bool checkRequest() override; diff -Nru metview-5.17.4/metview/src/Divrot/Divrot.cc metview-5.19.2/metview/src/Divrot/Divrot.cc --- metview-5.17.4/metview/src/Divrot/Divrot.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Divrot/Divrot.cc 2023-07-15 08:28:47.000000000 +0000 @@ -95,7 +95,7 @@ if (Dsmoothing[0] == 'Y') //-- is smoothing requested? smooth_BPPSMTH(gh); - size_t buflen = 0; //-- get the GRIB msg into 'buffer' + size_t buflen = 0; //-- get the GRIB msg into 'buffer' const void* buffer = nullptr; if ((ret = grib_get_message(gh, &buffer, &buflen))) { setError(1, "Error on GRIB decoding: grib_get_message returned %d in Divrot::appendWindComponent", ret); @@ -110,6 +110,7 @@ //-- append 'buffer' to output file if (fwrite(buffer, 1, buflen, gribFile) != buflen) { setError(1, "fwrite(%s) failed", DfileOut.c_str()); + fclose(gribFile); return false; } //-- close and double check @@ -221,7 +222,7 @@ int main(int argc, char** argv) { // From the environment, check whether we're in 'standard' or 'MIR' mode - char* marsmode = getenv("MV_MARS_MODE"); + char* marsmode = getenv("MV_MARS_MODE"); const char* servicename = "Divrot"; if (marsmode && strcmp(marsmode, "MIR") == 0) { diff -Nru metview-5.17.4/metview/src/Divrot/divrot-exFortran.cc metview-5.19.2/metview/src/Divrot/divrot-exFortran.cc --- metview-5.17.4/metview/src/Divrot/divrot-exFortran.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Divrot/divrot-exFortran.cc 2023-07-15 08:28:47.000000000 +0000 @@ -102,11 +102,11 @@ err metview_makeuv_mir(char* vo, char* d, long inlen, char* u, char* v, long* outlen, int truncation) { - //eckit::AutoLock lock(mutex_); + // eckit::AutoLock lock(mutex_); - err e = NOERR; + err e = NOERR; int out = *outlen; - int in = inlen; + int in = inlen; if (!job) { job = std::make_shared(); @@ -122,21 +122,21 @@ // if(!ppdata.quiet) { marslog(LOG_INFO, "Deriving U and V from vorticity and divergence"); - //ppdata.quiet = 1; + // ppdata.quiet = 1; } marslog(LOG_DBUG, "-> INTUV%s in=%d out=%d", mars.use_intuvp ? "P" : "S", *outlen, out); ASSERT(mars.use_intuvp); - //timer_start(pptimer); + // timer_start(pptimer); if (mars.use_intuvp) { e = intuvp2(vo, d, in, u, v, out); - //if(in != out) - //ppdata.inter_cnt+=2; + // if(in != out) + // ppdata.inter_cnt+=2; marslog(LOG_DBUG, "MARS_USE_INTUVP set and parameters are U/V. Avoid calling intf2"); - //ppdata.derive_uv += 2; + // ppdata.derive_uv += 2; } - //timer_stop(pptimer,0); + // timer_stop(pptimer,0); marslog(LOG_DBUG, "<- INTUV%s in=%d out=%d", mars.use_intuvp ? "P" : "S", *outlen, out); @@ -164,41 +164,41 @@ for (int f = 0; f < Dnfield; ++f) //-- loop over input fields { - char* bufferVorticity = nullptr; + char* bufferVorticity = nullptr; char* bufferDivergence = nullptr; - size_t sizeVorticity = 0; - size_t sizeDivergence = 0; + size_t sizeVorticity = 0; + size_t sizeDivergence = 0; int ret; err marsRet; - MvField myField = Dfieldset[f]; //-- get grib handle for this field - grib_handle* ghVorticity = nullptr; + MvField myField = Dfieldset[f]; //-- get grib handle for this field + grib_handle* ghVorticity = nullptr; grib_handle* ghDivergence = nullptr; - grib_handle* ghZero = nullptr; - size_t voValuesLength = 0; //-- data values count - size_t divValuesLength = 0; // ... + grib_handle* ghZero = nullptr; + size_t voValuesLength = 0; //-- data values count + size_t divValuesLength = 0; // ... // note: vorticity->rotwind, divergence->divwind, both->uvwind switch (DresultParam) { case eRotational: { - ghVorticity = myField.getGribHandle(); + ghVorticity = myField.getGribHandle(); ghDivergence = grib_handle_clone(ghVorticity); // create an all-zero valued GRIB for divergence - ghZero = ghDivergence; // this is the one we will zero + ghZero = ghDivergence; // this is the one we will zero break; } case eDivergent: { ghDivergence = myField.getGribHandle(); - ghVorticity = grib_handle_clone(ghDivergence); // create an all-zero valued GRIB for vorticity - ghZero = ghVorticity; // this is the one we will zero + ghVorticity = grib_handle_clone(ghDivergence); // create an all-zero valued GRIB for vorticity + ghZero = ghVorticity; // this is the one we will zero break; } case eUV: { MvField myField2 = Dfieldset2[f]; //-- get grib handle for 'the other' field - ghVorticity = myField.getGribHandle(); - ghDivergence = myField2.getGribHandle(); + ghVorticity = myField.getGribHandle(); + ghDivergence = myField2.getGribHandle(); break; } @@ -242,7 +242,7 @@ // set the 'zero' GRIB values to zero if (ghZero != nullptr) { - auto *zero = new double[voValuesLength]; + auto* zero = new double[voValuesLength]; memset(zero, 0, sizeof(double) * voValuesLength); if ((ret = grib_set_double_array(ghZero, "values", zero, voValuesLength))) { @@ -267,8 +267,8 @@ // compute the size of the output buffers DoutputValsLen = voValuesLength * 3 + 4096; //(DtruncOut+1)*(DtruncOut+2) + 4096; - char* u = new char[DoutputValsLen * sizeof(double)]; - char* v = new char[DoutputValsLen * sizeof(double)]; + char* u = new char[DoutputValsLen * sizeof(double)]; + char* v = new char[DoutputValsLen * sizeof(double)]; #ifdef HAVE_PPROC_MIR // perform conversion with MIR @@ -403,16 +403,16 @@ long itinp1 = DtruncOut; //-- NPREL4 auto* dummy = new double[itinp1]; //-- compute final smoothing coefficients - dummy[0] = 1.0; + dummy[0] = 1.0; for (int n = 1; n < itinp1; ++n) { dummy[n] = exp(fltcons * pow((double)(n * (n + 1)), Dmfltexp)); } - int i = 0; //-- do the smoothing + int i = 0; //-- do the smoothing int ii = 0; for (int m = 0; m < itinp1; ++m) for (int n = m; n < itinp1; ++n) { - data[ii] = dummy[n] * data[i]; + data[ii] = dummy[n] * data[i]; data[ii + 1] = dummy[n] * data[i + 1]; i += 2; ii += 2; diff -Nru metview-5.17.4/metview/src/Download/Download.cc metview-5.19.2/metview/src/Download/Download.cc --- metview-5.17.4/metview/src/Download/Download.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Download/Download.cc 2023-07-15 08:28:47.000000000 +0000 @@ -56,7 +56,7 @@ bool replace_all(std::string& subject, const std::string& search, const std::string& replace) { bool replaced = false; - size_t pos = 0; + size_t pos = 0; while ((pos = subject.find(search, pos)) != std::string::npos) { subject.replace(pos, search.length(), replace); pos += replace.length(); @@ -119,7 +119,7 @@ std::string outname(marstmp()); auto* net = new MvNetwork(); - bool ok = net->get(urlStr, outname, "", errText); + bool ok = net->get(urlStr, outname, "", errText); if (!ok) { setError(1, "Download-> Failed to download data: %s", errText.c_str()); @@ -127,10 +127,10 @@ } - std::string h = net->header(); + std::string h = net->header(); long responseCode = net->responseCode(); // XXX comment out for now - need to trim to 1024 chars for mars logging - //sendProgress("Download-> header %s response code: %ld", h.c_str(), responseCode); + // sendProgress("Download-> header %s response code: %ld", h.c_str(), responseCode); char responseCodeString[32]; sprintf(responseCodeString, "%ld", responseCode); @@ -172,7 +172,7 @@ // Create output request std::string iconType = ScanFileType(outname.c_str()); // dynamically find the type out.setVerb(iconType.c_str()); - out("PATH") = outname.c_str(); + out("PATH") = outname.c_str(); out("_RESPONSE_CODE") = responseCodeString; std::cout << "Exit Download::serve..." << std::endl; diff -Nru metview-5.17.4/metview/src/Eccharts/Eccharts.cc metview-5.19.2/metview/src/Eccharts/Eccharts.cc --- metview-5.17.4/metview/src/Eccharts/Eccharts.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Eccharts/Eccharts.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ protected: void registerCallbacks(); - virtual void reply(const MvRequest&) = 0; + virtual void reply(const MvRequest&) = 0; virtual void progress(const MvRequest&) = 0; }; @@ -45,7 +45,7 @@ void MvMacroCallerService::registerCallbacks() { - //marslog(LOG_INFO, "Eccharts-> registerCallbacks"); + // marslog(LOG_INFO, "Eccharts-> registerCallbacks"); add_progress_callback(MvApplication::getService(), 0, progressCb, (void*)this); @@ -56,7 +56,7 @@ void MvMacroCallerService::progressCb(svcid* /*id*/, request* r, void* obj) { - //marslog(LOG_INFO, "Eccharts-> PROG callback:"); + // marslog(LOG_INFO, "Eccharts-> PROG callback:"); MvRequest in(r); if (const char* chv = in.getVerb()) if (strcmp(chv, "REGISTER_MACRO_PID") == 0) @@ -68,8 +68,8 @@ void MvMacroCallerService::replyCb(svcid* /*id*/, request* r, void* obj) { - //marslog(LOG_INFO, "Eccharts-> replyCb"); - //print_all_requests(r); + // marslog(LOG_INFO, "Eccharts-> replyCb"); + // print_all_requests(r); MvRequest in(r); if (auto* b = static_cast(obj)) b->reply(in); @@ -100,8 +100,8 @@ id_(req), hasReply_(false) { - yesNoIds_["YES"] = "1"; - yesNoIds_["NO"] = "0"; + yesNoIds_["YES"] = "1"; + yesNoIds_["NO"] = "0"; titleIds_["DEFAULT"] = "0"; titleIds_["STYLE_1"] = "1"; } @@ -136,12 +136,12 @@ prepPy = std::string(mvbin) + "/mv_eccharts.py"; } - //Get the verb. We accept two verbs: - // -ECCHARTS: it is sent when we call the action on a non-cached icon - // -GRIB: it sent when the result (basically a GRIB) is cached and we call the - // "export" action on the icon! In this case to correctly perform the action we need - // the original ECCHARTS request and we store int the "_ECHHARTS" parameter of the - // cached GRIB request!! + // Get the verb. We accept two verbs: + // -ECCHARTS: it is sent when we call the action on a non-cached icon + // -GRIB: it sent when the result (basically a GRIB) is cached and we call the + // "export" action on the icon! In this case to correctly perform the action we need + // the original ECCHARTS request and we store int the "_ECHHARTS" parameter of the + // cached GRIB request!! std::string verb; if (const char* chverb = inReq.getVerb()) verb = std::string(chverb); @@ -150,15 +150,15 @@ return; } - //We will work with a local copy oif the incoming request! + // We will work with a local copy oif the incoming request! MvRequest in = inReq; - //Determine the user action + // Determine the user action const char* actionC = (const char*)in("_ACTION"); - std::string action = (actionC) ? std::string(actionC) : "execute"; + std::string action = (actionC) ? std::string(actionC) : "execute"; - //When the incoming request is GRIB we need to recover the original - //request from the _ECCHARTS parameter + // When the incoming request is GRIB we need to recover the original + // request from the _ECCHARTS parameter if (verb == "GRIB") { if (action != "export_macro" && action != "export_python") return; @@ -166,10 +166,10 @@ in = inReq("_ECCHARTS"); } - //Get params + // Get params std::vector param; - //Mode + // Mode std::string mode = "data"; if (action == "export_macro") { mode = "macro"; @@ -180,27 +180,27 @@ assert(mode == "data" || mode == "macro" || mode == "python"); param.push_back(mode); - //Layer definition json file + // Layer definition json file std::string layersFile = metview::ecchartsDirFile("layers.json"); param.push_back(layersFile); - //mars definition json file + // mars definition json file std::string marsFile = metview::ecchartsDirFile("layers_mars.json"); param.push_back(marsFile); - //layer name + // layer name std::string layer; ECCHARTS_CHK(in.getValue("LAYER", layer)); if (mode == "data") { - //Macro file to be generated + // Macro file to be generated char* macroPathCh = marstmp(); - macroPath = std::string(macroPathCh); + macroPath = std::string(macroPathCh); param.push_back(macroPath); - //Request file to be generated + // Request file to be generated char* reqPathCh = marstmp(); - reqPath = std::string(reqPathCh); + reqPath = std::string(reqPathCh); in.print(); param.push_back(reqPath); } @@ -223,66 +223,66 @@ param.push_back("_dummy_path_"); } - //add layer name to params + // add layer name to params param.push_back(layer); - //layer style - for contouring + // layer style - for contouring std::string style; ECCHARTS_CHK(in.getValue("STYLE", style, true)); param.push_back(style); - //need custom title + // need custom title std::string needTitle; ECCHARTS_CHK(in.getValueId("TITLE", needTitle, titleIds_)); param.push_back(needTitle); // MARS params follow from here - //date + // date std::string dateStr; ECCHARTS_CHK(in.getValue("DATE", dateStr)); param.push_back("date=" + dateStr); - //time + // time std::string timeStr; ECCHARTS_CHK(in.getValue("TIME", timeStr)); param.push_back("time=" + timeStr); - //grid + // grid std::vector grid; ECCHARTS_CHK(in.getValue("GRID", grid)); param.push_back("grid=" + metview::toMacroList(grid)); - //quantile + // quantile std::vector quantile; ECCHARTS_CHK(in.getValue("QUANTILE", quantile, true)); if (!quantile.empty()) { param.push_back("quantile=" + quantile[0]); } - //quantile + // quantile std::string interval; ECCHARTS_CHK(in.getValue("INTERVAL", interval, true)); if (!interval.empty()) { param.push_back("interval=" + interval); } - //step + // step std::vector step; ECCHARTS_CHK(in.getValue("STEP", step)); param.push_back("step=" + metview::stepToMacro(step)); - //expver + // expver std::string expver; ECCHARTS_CHK(in.getValue("EXPVER", expver)); param.push_back("expver=" + expver); - //fail on error + // fail on error std::string str; ECCHARTS_CHK(in.getValueId("FAIL_ON_DATA_ERROR", str, yesNoIds_)); bool failOnError = (str == "1") ? true : false; - //Run python script to generate the macro and requests + // Run python script to generate the macro and requests std::string cmd = "python3 -u " + prepPy; for (auto& i : param) { cmd += " \"" + i + "\""; @@ -295,10 +295,10 @@ sendProgress("Eccharts-> Execute command: %s", cmd.c_str()); int ret = system(cmd.c_str()); - //metview::writeFileToLogErr(pyLog); + // metview::writeFileToLogErr(pyLog); - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { setError(1, "Eccharts-> Command (%s) to generate macro failed. Exit code: %d", cmd.c_str(), WEXITSTATUS(ret)); metview::writeFileToLogErr(pyLog); @@ -320,7 +320,7 @@ // Read requests needed to built the plot //========================================= - //Read the requests + // Read the requests MvRequest vReq; vReq.read(reqPath.c_str()); @@ -328,29 +328,29 @@ // Retrieve and process data //========================================= - //Build request to be sent to Macro + // Build request to be sent to Macro MvRequest req("MACRO"); std::string processName = MakeProcessName("Eccharts"); - //MvRequest macroReq("MACRO"); - req("PATH") = macroPath.c_str(); - req("_CLASS") = "MACRO"; - req("_ACTION") = "execute"; - req("_REPLY") = processName.c_str(); + // MvRequest macroReq("MACRO"); + req("PATH") = macroPath.c_str(); + req("_CLASS") = "MACRO"; + req("_ACTION") = "execute"; + req("_REPLY") = processName.c_str(); req("_EXTENDMESSAGE") = "1"; std::vector param; - //The resulting grib file + // The resulting grib file char* dataPath = marstmp(); param.push_back(std::string(dataPath)); - //Define argument list for the macro! + // Define argument list for the macro! for (auto& it : param) { req.addValue("_ARGUMENTS", it.c_str()); } - //Run macro + // Run macro sendProgress("Eccharts-> Execute macro: %s", macroPath.c_str()); svc* mysvc = MvApplication::getService(); @@ -406,14 +406,14 @@ return; } - out = MvRequest("GRIB"); + out = MvRequest("GRIB"); out("TEMPORARY") = 1; - out("PATH") = dataPath; + out("PATH") = dataPath; out = out + vReq; - //Add the original request as a hidden parameter. We need it to export - //to macro under certain circumstances. + // Add the original request as a hidden parameter. We need it to export + // to macro under certain circumstances. out("_ECCHARTS") = in; return; diff -Nru metview-5.17.4/metview/src/Ecfile/Ecfs.cc metview-5.19.2/metview/src/Ecfile/Ecfs.cc --- metview-5.17.4/metview/src/Ecfile/Ecfs.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Ecfile/Ecfs.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,9 @@ void Ecfs::serve(MvRequest& in, MvRequest& out) { - const char* path = in("FILE_NAME"); + const char* path = in("FILE_NAME"); const char* domain = in("ECFS_DOMAIN"); - char buf[1024]; + char buf[1096]; char ecfs_cmd[1024]; char* tmp = marstmp(); @@ -34,8 +34,8 @@ sprintf(ecfs_cmd, "ecp -o %s%s %s", domain, path, tmp); - //sprintf(buf,"csh -exec \'Ecp ec:%s %s 2>&1\'",path,tmp); - //sprintf(buf,"csh -exec \'Ecp -o ec:%s %s\'",path,tmp); + // sprintf(buf,"csh -exec \'Ecp ec:%s %s 2>&1\'",path,tmp); + // sprintf(buf,"csh -exec \'Ecp -o ec:%s %s\'",path,tmp); sprintf(buf, "ksh -c \' . $HOME/.kshrc ; set -e ; %s\'", ecfs_cmd); sendProgress("Ecfs-> command: %s", buf); @@ -58,10 +58,10 @@ return; } - MvRequest grib = guess_class(tmp); - grib("PATH") = tmp; + MvRequest grib = guess_class(tmp); + grib("PATH") = tmp; grib("TEMPORARY") = 1; - out = grib; + out = grib; } //______________________________________________________ diff -Nru metview-5.17.4/metview/src/Event/Event.cc metview-5.19.2/metview/src/Event/Event.cc --- metview-5.17.4/metview/src/Event/Event.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Event/Event.cc 2023-07-15 08:28:47.000000000 +0000 @@ -203,7 +203,6 @@ else if (!strncmp(gOpt.startup, "$METVIEW_STARTUP", 16)) // does it start with $METVIEW_STARTUP? { - startup = getenv("METVIEW_STARTUP"); sprintf(startupBuffer, "%s%s", getenv("METVIEW_STARTUP"), &gOpt.startup[16]); // replace with value startup = startupBuffer; } @@ -284,7 +283,7 @@ fprintf(f, "[Info]\n"); fprintf(f, "EVENT_PID=%d\n", getpid()); WriteEnvVarIfNotNull(f, "METVIEW_LIB"); - //fprintf(f, "MV_SCRIPT_PID=%s\n", getenv("MV_SCRIPT_PID")); + // fprintf(f, "MV_SCRIPT_PID=%s\n", getenv("MV_SCRIPT_PID")); fprintf(f, "[Environment]\n"); WriteEnvVarIfNotNull(f, "METVIEW_BIN"); WriteEnvVarIfNotNull(f, "METVIEW_USER_DIRECTORY"); diff -Nru metview-5.17.4/metview/src/Event/Queue.cc metview-5.19.2/metview/src/Event/Queue.cc --- metview-5.17.4/metview/src/Event/Queue.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Event/Queue.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ return nullptr; QElem* q = q_; - q_ = q_->next_; + q_ = q_->next_; return q; } @@ -75,7 +75,7 @@ void Queue::Insert(QElem* q) { q->next_ = head_; - head_ = q; + head_ = q; if (!tail_) tail_ = q; } diff -Nru metview-5.17.4/metview/src/Event/Service.cc metview-5.19.2/metview/src/Event/Service.cc --- metview-5.17.4/metview/src/Event/Service.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Event/Service.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ #include "Event.h" -Service* Service::gHead = nullptr; +Service* Service::gHead = nullptr; Service* Service::gMonitor = nullptr; //============================================================================== @@ -34,7 +34,7 @@ using mxdrparam = void*; #endif -#if !defined(__linux__) || defined(__INTEL_COMPILER) +#if !defined(__linux__) || defined(__INTEL_COMPILER) || defined(__clang__) typedef int (*mxdrproc)(void*, void*, int); #else typedef int (*mxdrproc)(char*, char*, int); @@ -61,25 +61,25 @@ // xdrrec_create(&x_, 0,0,(void*)&soc_,(mxdrproc)readtcp,(mxdrproc)writetcp); //#endif - name_ = nullptr; - host_ = nullptr; - user_ = nullptr; - ref_ = -1; - timeout_ = 0; - alive_ = 0; - outstanding_ = 0; + name_ = nullptr; + host_ = nullptr; + user_ = nullptr; + ref_ = -1; + timeout_ = 0; + alive_ = 0; + outstanding_ = 0; want_progress_ = 0; - want_message_ = 0; - valid_ = 0; - maximum_ = 1; + want_message_ = 0; + valid_ = 0; + maximum_ = 1; #ifdef USE_THREADS pthread_mutex_init(&mutex_, 0); pthread_cond_init(&cond_, 0); - stop_ = 0; - running_ = 0; + stop_ = 0; + running_ = 0; threaded_ = 0; @@ -165,20 +165,20 @@ void Service::HandleRegister(request* r) { static char* service = strcache("service"); - const char* name = get_value(r, "NAME", 0); + const char* name = get_value(r, "NAME", 0); if (Find(name)) { marslog(LOG_WARN, "Service %s is already registered", name); return; } - ref_ = Event::UniqueID(); - name_ = strcache(get_value(r, "NAME", 0)); - user_ = strcache(get_value(r, "USER", 0)); - host_ = strcache(get_value(r, "HOST", 0)); - pid_ = atol(get_value(r, "PID", 0)); + ref_ = Event::UniqueID(); + name_ = strcache(get_value(r, "NAME", 0)); + user_ = strcache(get_value(r, "USER", 0)); + host_ = strcache(get_value(r, "HOST", 0)); + pid_ = atol(get_value(r, "PID", 0)); lastcall_ = time(nullptr); - valid_ = 1; + valid_ = 1; marslog(LOG_INFO, "Register: %s %s %s %d as ref %d", name_, @@ -194,7 +194,7 @@ if (u->name == service) { const char* nme = get_value(u, "name", 0); if (nme && (name == nme)) { - const char* alive = get_value(u, "alive", 0); + const char* alive = get_value(u, "alive", 0); const char* timeout = get_value(u, "timeout", 0); const char* maximum = get_value(u, "maximum", 0); @@ -457,7 +457,7 @@ void Service::SendRequest(request* r) { - static char* MESSAGE = strcache("MESSAGE"); + static char* MESSAGE = strcache("MESSAGE"); static char* PROGRESS = strcache("PROGRESS"); /* check if the module is interested ... */ @@ -483,7 +483,7 @@ void Service::HandleReply(request* r) { const char* x = get_value(r, "SOURCE_REF", 0); - long ref = x ? atol(x) : -1; + long ref = x ? atol(x) : -1; NotifyMonitor("REPLY", r); @@ -505,7 +505,7 @@ void Service::HandleTimeout(request* r) { const char* t = get_value(r, "TIMEOUT", 0); - timeout_ = (t ? atol(t) : 0) * 60; + timeout_ = (t ? atol(t) : 0) * 60; marslog(LOG_INFO, "Timeout for %s : %d seconds", name_, timeout_); } @@ -514,7 +514,7 @@ void Service::HandleAlive(request* r) { const char* t = get_value(r, "ALIVE", 0); - alive_ = t ? atoi(t) : 0; + alive_ = t ? atoi(t) : 0; marslog(LOG_INFO, "Alive value for %s : %s ", name_, alive_ ? "on" : "off"); } @@ -523,7 +523,7 @@ void Service::HandleStop(request* r) { const char* t = get_value(r, "STOP", 0); - int stop = t ? atoi(t) : 0; + int stop = t ? atoi(t) : 0; marslog(LOG_INFO, "Stop %d requested by service %s", stop, name_); marslog(LOG_INFO, "%s", get_value(r, "INFO", 0)); marsexit(stop); @@ -586,9 +586,9 @@ void Service::HandleWant(request* r) { - static char* MESSAGE = strcache("MESSAGE"); + static char* MESSAGE = strcache("MESSAGE"); static char* PROGRESS = strcache("PROGRESS"); - const char* kind = get_value(r, "TYPE", 0); + const char* kind = get_value(r, "TYPE", 0); if (kind == MESSAGE) want_message_++; @@ -601,7 +601,7 @@ void Service::HandleProgress(request* r) { const char* x = get_value(r, "SOURCE_REF", 0); - long ref = x ? atol(x) : -1; + long ref = x ? atol(x) : -1; #if 0 marslog(LOG_INFO, "progress %ld", ref); print_all_requests(r); @@ -704,7 +704,7 @@ void Service::ReplyFail(const char* fmt, const char* name, request* r) { const char* x = get_value(r, "SOURCE_REF", 0); - long ref = x ? atol(x) : -1; + long ref = x ? atol(x) : -1; Service* a = Service::Find(ref); @@ -728,7 +728,7 @@ void Service::HandleStart(request* r) { const char* name = get_value(r, "NAME", 0); - const char* cmd = get_value(r, "CMD", 0); + const char* cmd = get_value(r, "CMD", 0); if (cmd) { char buf[1024]; marslog(LOG_INFO, "Starting command: %s", cmd); @@ -790,7 +790,7 @@ void Service::HandleMaximum(request* r) { const char* t = get_value(r, "MAXIMUM", 0); - maximum_ = t ? atoi(t) : 0; + maximum_ = t ? atoi(t) : 0; marslog(LOG_INFO, "Maximum value for %s : %d ", name_, maximum_); } @@ -799,7 +799,7 @@ int Service::CheckTimeout() { time_t now = time(nullptr); - int alive = 0; + int alive = 0; Service* s = gHead; while (s) { @@ -931,7 +931,7 @@ void Service::ProcessIncoming() { - request* r = nullptr; + request* r = nullptr; static int first = 1; // marslog(LOG_INFO, "Service incoming: %s", name_); diff -Nru metview-5.17.4/metview/src/Event/WaitingQueue.cc metview-5.19.2/metview/src/Event/WaitingQueue.cc --- metview-5.17.4/metview/src/Event/WaitingQueue.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Event/WaitingQueue.cc 2023-07-15 08:28:47.000000000 +0000 @@ -140,8 +140,8 @@ Rewind(); while ((q = Next()) != 0) { const char* x = get_value(q->Request(), "SOURCE_REF", 0); - long ref = x ? atol(x) : -1; - Service* s = Service::Find(ref); + long ref = x ? atol(x) : -1; + Service* s = Service::Find(ref); if (s) s->NotifyMonitor("WAIT", q->Request()); } @@ -152,7 +152,7 @@ int WaitingQueue::StartModule(const char* name) { static char* service = strcache("service"); - request* r = mars.setup; + request* r = mars.setup; while (r) { if (r->name == service) { diff -Nru metview-5.17.4/metview/src/ExamineManager/MvExamineManager.cc metview-5.19.2/metview/src/ExamineManager/MvExamineManager.cc --- metview-5.17.4/metview/src/ExamineManager/MvExamineManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/ExamineManager/MvExamineManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -61,7 +61,7 @@ exit(0); } -//TODO: do we need it: run is blocking call!!! +// TODO: do we need it: run is blocking call!!! void MvExamineManager::progress(const char* p) { marslog(LOG_INFO, "Got progress: %s", p); @@ -71,7 +71,7 @@ { MvRequest mvReq(dataType.c_str()); mvReq.setValue("PATH", fileName.c_str()); - mvReq("_ACTION") = "examine"; + mvReq("_ACTION") = "examine"; mvReq("_WAIT_APP") = "1"; mvReq.print(); MvTask* task = new MvServiceTask(this, "UiAppManager", mvReq); diff -Nru metview-5.17.4/metview/src/Flextra/flexpartField.cc metview-5.19.2/metview/src/Flextra/flexpartField.cc --- metview-5.17.4/metview/src/Flextra/flexpartField.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Flextra/flexpartField.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,9 +11,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include "grib_api.h" @@ -24,7 +24,7 @@ //#define _GNU_SOURCE //#include -//int feenableexcept(int excepts); +// int feenableexcept(int excepts); class MvFlexpartGrid @@ -33,7 +33,7 @@ MvFlexpartGrid(const std::string&, const std::string&, const std::string&, const std::string&, bool forward, int species); ~MvFlexpartGrid() = default; -protected: +private: void convert(); void convertFlux(); void readField(MvBinaryReader*, double**, size_t, bool, double); @@ -48,8 +48,8 @@ std::string gridFile_; std::string gridType_; std::string outPattern_; - bool forward_; - int species_; //the species index, starts from 0, only used for conc! + bool forward_{true}; + int species_{0}; // the species index, starts from 0, only used for conc! std::string speciesName_; }; @@ -65,18 +65,14 @@ species_(species) { - //feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT); + // feenableexcept(FE_ALL_EXCEPT & ~FE_INEXACT); std::cout << "Converting flexpart output file=" << gridFile << " to grib" << std::endl; std::cout << "species=" << species_ << std::endl; header_.print(); - if (gridType_ == "conc") - convert(); - else if (gridType_ == "pptv") - convert(); - else if (gridType_ == "time") + if (gridType_ == "conc" || gridType_ == "pptv" || gridType_ == "time") convert(); else if (gridType_ == "flux") convertFlux(); @@ -91,28 +87,28 @@ exit(1); } - int paramId; + int paramId = 0.; double scaleFactor = pow(10., -12); - double* data = nullptr; + double* data = nullptr; std::string levType; int spec = species_; r.skipRecMarker(); - int step = r.read(); //forecast time in seconds - //std::cout << "TIME " << itime << std::endl; + int step = r.read(); // forecast time in seconds + // std::cout << "TIME " << itime << std::endl; r.skipRecMarker(); - //bool splitByRelease = (static_cast(header_.release.size()) == header_.specPointNum); + // bool splitByRelease = (static_cast(header_.release.size()) == header_.specPointNum); - //Loop for number of releaspoints for which a different output shall be created + // Loop for number of releaspoints for which a different output shall be created for (int specPoint = 0; specPoint < header_.specPointNum; specPoint++) { - //Loop for age classes + // Loop for age classes for (size_t ac = 0; ac < header_.ageClass.size(); ac++) { size_t dataSize = 0; - //Wet/dry deposition + // Wet/dry deposition if (forward_) { - //Wet deposition + // Wet deposition levType = "sfc"; paramId = 20198; @@ -121,7 +117,7 @@ readField(&r, &data, dataSize, false, scaleFactor); writeField(data, outPattern_ + "wet.grib", paramId, levType, 0., step, specPoint, spec, ac); - //Dry deposition + // Dry deposition levType = "sfc"; paramId = 20197; @@ -130,7 +126,7 @@ readField(&r, &data, dataSize, false, scaleFactor); writeField(data, outPattern_ + "dry.grib", paramId, levType, 0., step, specPoint, spec, ac); } - //No depsotion for backward simulations + // No depsotion for backward simulations else { initData(&data, dataSize); readField(&r, &data, dataSize, false, scaleFactor); @@ -140,18 +136,18 @@ levType = "heightAboveGround"; - //Height level data + // Height level data if (forward_) { - //Concentration + // Concentration if (gridType_ == "conc") { - //Concentration + // Concentration if (header_.indReceptor == 1) paramId = 20000; - //Mass mixing ratio + // Mass mixing ratio else paramId = 20002; } - //Volume mixing ratio + // Volume mixing ratio else if (gridType_ == "pptv") { paramId = 20052; } @@ -160,18 +156,18 @@ } } else { - //Response + // Response if (gridType_ == "time") { - //Particle resident time + // Particle resident time if (header_.indSource == 1 && header_.indReceptor == 1) paramId = 20194; - //Response for mass concentration + // Response for mass concentration else if (header_.indSource == 1 && header_.indReceptor == 2) paramId = 20195; - //Response for mass mixing ratio + // Response for mass mixing ratio else if (header_.indSource == 2 && header_.indReceptor == 1) paramId = 20196; - //Particle resident time + // Particle resident time else if (header_.indSource == 2 && header_.indReceptor == 1) paramId = 20194; else { @@ -179,7 +175,7 @@ exit(1); } } - //Volume mixing ratio + // Volume mixing ratio else if (gridType_ == "pptv") { paramId = 20000; } @@ -214,7 +210,7 @@ if (!r.isValid()) return; - double* data = nullptr; + double* data = nullptr; std::string levType = "heightAboveGround"; r.skipRecMarker(); @@ -224,26 +220,26 @@ size_t dataSize = fieldSize_ * header_.levels.size(); std::vector paramIds; - paramIds.push_back(20199); //east - paramIds.push_back(20200); //west - paramIds.push_back(20201); //south - paramIds.push_back(20202); //north - paramIds.push_back(20203); //up - paramIds.push_back(20204); //down + paramIds.push_back(20199); // east + paramIds.push_back(20200); // west + paramIds.push_back(20201); // south + paramIds.push_back(20202); // north + paramIds.push_back(20203); // up + paramIds.push_back(20204); // down - //Loop for species + // Loop for species for (int spec = 0; spec < header_.specNum; spec++) { - //Loop for number of releaspoints for which a different output shall be created. - //If OUTPUT_FOR_EACH_RELEASE is off.There will be just one field created merging all the - //releases + // Loop for number of releaspoints for which a different output shall be created. + // If OUTPUT_FOR_EACH_RELEASE is off.There will be just one field created merging all the + // releases for (int specPoint = 0; specPoint < header_.specPointNum; specPoint++) { - //Loop for age classes + // Loop for age classes for (size_t ac = 0; ac < header_.ageClass.size(); ac++) { - //Flux types + // Flux types for (size_t iFlux = 0; iFlux < paramIds.size(); iFlux++) { initData(&data, dataSize); - //read data for all the levels + // read data for all the levels readFluxField(&r, &data, dataSize); double* dLev = data; @@ -281,8 +277,8 @@ void MvFlexpartGrid::readField(MvBinaryReader* r, double** data, size_t dataSize, bool doAbs, double scaleFactor) { int factor = 1; - int cnt = 0; - size_t n = 0; + int cnt = 0; + size_t n = 0; r->skipRecMarker(); int spCnt_i = r->read(); @@ -302,18 +298,18 @@ r->read(spCnt_r, spDump_r); r->skipRecMarker(); - //std::cout << "spDump_i" << std::endl; - //for(size_t i=0; i < spDump_i.size(); i++) - // std::cout << " " << spDump_i[i] << std::endl; - - //std::cout << "spDump_r" << std::endl; - //for(size_t i=0; i < spDump_r.size(); i++) - // std::cout << " " << spDump_r[i] << std::endl; + // std::cout << "spDump_i" << std::endl; + // for(size_t i=0; i < spDump_i.size(); i++) + // std::cout << " " << spDump_i[i] << std::endl; + + // std::cout << "spDump_r" << std::endl; + // for(size_t i=0; i < spDump_r.size(); i++) + // std::cout << " " << spDump_r[i] << std::endl; assert(spCnt_r == static_cast(spDump_r.size())); - double dVal; + double dVal = 0.; for (int i = 0; i < spCnt_r; i++) { if (spDump_r[i] * factor > 0.) { @@ -325,14 +321,14 @@ n++; } - //int yPos=n/header.nx; - //int xPos=n-header.nx*yPos; + // int yPos=n/header.nx; + // int xPos=n-header.nx*yPos; int np = n; if (n >= fieldSize_) { np -= fieldSize_; } - //std::cout << "np " << np << " " << i << " " << n << " " << fieldSize_ << std::endl; + // std::cout << "np " << np << " " << i << " " << n << " " << fieldSize_ << std::endl; assert(np < static_cast(dataSize)); if (*data && np < static_cast(dataSize)) { if (doAbs) @@ -349,7 +345,7 @@ (*data)[np] = dVal; } - //std::cout << n << " " << data[n] << std::endl; + // std::cout << n << " " << data[n] << std::endl; } } @@ -362,13 +358,13 @@ r->skipRecMarker(); if (type == 1) { - int ival = 0; + int ival = 0; float fval = 999.; while (ival != -999) { r->skipRecMarker(); ival = r->read(); fval = r->read(); - //std::cout << "ival=" << ival << " fval=" << fval << std::endl; + // std::cout << "ival=" << ival << " fval=" << fval << std::endl; if (ival != -999) { ival -= fieldSize_; assert(ival >= 0); @@ -407,7 +403,7 @@ grib_handle* gh = nullptr; size_t size = header_.nx * header_.ny; - size_t len = 0; + size_t len = 0; std::string sampleName("flexpart_1_grib2"); if ((gh = grib_handle_new_from_samples(nullptr, sampleName.c_str())) == nullptr) { @@ -416,19 +412,19 @@ return; } - //Pouplate Section 2 + // Pouplate Section 2 GRIB_CHECK(grib_set_long(gh, "flexpartVersion", 902), nullptr); GRIB_CHECK(grib_set_long(gh, "speciesId", spec + 1), nullptr); - //Species + // Species assert(spec >= 0 && spec < header_.specNum); std::string speciesName = header_.specNames[spec]; - len = speciesName.size(); + len = speciesName.size(); GRIB_CHECK(grib_set_string(gh, "speciesName", speciesName.c_str(), &len), nullptr); - //Releases + // Releases - //One field per release + // One field per release if (static_cast(header_.release.size()) == header_.specPointNum) { int release = specPoint; assert(release >= 0 && release < static_cast(header_.release.size())); @@ -436,21 +432,21 @@ GRIB_CHECK(grib_set_long(gh, "releaseNumber", release + 1), nullptr); std::string releaseName = header_.release[release].name; - len = releaseName.size(); + len = releaseName.size(); GRIB_CHECK(grib_set_string(gh, "releaseName", releaseName.c_str(), &len), nullptr); } - //releases are merged into a field + // releases are merged into a field else { GRIB_CHECK(grib_set_long(gh, "numberOfReleases", header_.release.size()), nullptr); GRIB_CHECK(grib_set_long(gh, "releaseNumber", 0), nullptr); } - //Ageclasses + // Ageclasses GRIB_CHECK(grib_set_long(gh, "numberOfAgeClasses", header_.ageClass.size()), nullptr); GRIB_CHECK(grib_set_long(gh, "ageClass", ageClass + 1), nullptr); long ageClassBegin = 0; - long ageClassEnd = header_.ageClass[ageClass]; + long ageClassEnd = header_.ageClass[ageClass]; if (ageClass > 0) { ageClassBegin = header_.ageClass[ageClass - 1]; @@ -459,7 +455,7 @@ GRIB_CHECK(grib_set_long(gh, "ageClassEnd", ageClassBegin), nullptr); GRIB_CHECK(grib_set_long(gh, "ageClassEnd", ageClassEnd), nullptr); - //Grid + // Grid GRIB_CHECK(grib_set_double(gh, "longitudeOfFirstGridPointInDegrees", header_.west), nullptr); GRIB_CHECK(grib_set_double(gh, "longitudeOfLastGridPointInDegrees", header_.east), nullptr); GRIB_CHECK(grib_set_double(gh, "latitudeOfFirstGridPointInDegrees", header_.south), nullptr); @@ -470,15 +466,15 @@ GRIB_CHECK(grib_set_double(gh, "jDirectionIncrementInDegrees", header_.dy), nullptr); GRIB_CHECK(grib_set_long(gh, "jScansPositively", 1), nullptr); - //Level + // Level len = levType.size(); GRIB_CHECK(grib_set_string(gh, "typeOfLevel", levType.c_str(), &len), nullptr); GRIB_CHECK(grib_set_double(gh, "level", levVal), nullptr); - //Param + // Param GRIB_CHECK(grib_set_long(gh, "paramId", paramId), nullptr); - //Date + // Date GRIB_CHECK(grib_set_long(gh, "dataDate", header_.runDate), nullptr); GRIB_CHECK(grib_set_long(gh, "dataTime", header_.runTime / 100), nullptr); @@ -499,11 +495,11 @@ GRIB_CHECK(grib_set_long(gh, "bitsPerValue", 24), nullptr); - //for(int i=0; i < size; i++) + // for(int i=0; i < size; i++) //{ - // std::cout << i << " " << data[i] << std::endl; - //data[i]=0.; - //} + // std::cout << i << " " << data[i] << std::endl; + // data[i]=0.; + // } GRIB_CHECK(grib_set_double_array(gh, "values", data, size), nullptr); @@ -530,7 +526,7 @@ std::string speciesStr(argv[6]); bool forward = (forwardStr == "1") ? true : false; - int species = metview::fromString(speciesStr) - 1; + int species = metview::fromString(speciesStr) - 1; MvFlexpartGrid grid(headerFile, gridFile, gridType, pattern, forward, species); return 0; diff -Nru metview-5.17.4/metview/src/Flextra/flexpartReceptor.cc metview-5.19.2/metview/src/Flextra/flexpartReceptor.cc --- metview-5.17.4/metview/src/Flextra/flexpartReceptor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Flextra/flexpartReceptor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,8 @@ struct FxpReceptor { std::string name; - double lat; - double lon; + double lat{0.}; + double lon{0.}; std::vector data; }; @@ -51,7 +51,7 @@ MvFlexpartHeader header(headerFile); MvFlexpartDates dates(datesFile); - //dates.print(); + // dates.print(); MvBinaryReader r(recFile); @@ -67,7 +67,7 @@ FxpReceptor rec; r.read(16, rec.name); recVec.push_back(rec); - //std::cout << "name: " << rec.name << std::endl; + // std::cout << "name: " << rec.name << std::endl; } r.skipRecMarker(); @@ -75,11 +75,11 @@ for (int i = 0; i < recNum; i++) { recVec[i].lon = r.read(); recVec[i].lat = r.read(); - //std::cout << "lat: " << recVec[i].lat << std::endl; + // std::cout << "lat: " << recVec[i].lat << std::endl; } r.skipRecMarker(); - //Create a map to hold receptor data for each species + // Create a map to hold receptor data for each species std::map > recMap; for (int spec = 0; spec < header.specNum; spec++) { recMap[spec] = recVec; @@ -89,7 +89,7 @@ for (int i = 0; i < stepNum; i++) { r.skipRecMarker(); - int step = r.read(); //forecast time in seconds + int step = r.read(); // forecast time in seconds r.skipRecMarker(); for (int spec = 0; spec < header.specNum; spec++) { @@ -99,12 +99,12 @@ r.skipRecMarker(); for (size_t rec = 0; rec < recMap[spec].size(); rec++) { - recMap[spec][rec].data.push_back(FxpReceptorData(step, vals[rec])); + recMap[spec][rec].data.emplace_back(step, vals[rec]); } } } - //Write one file per species + // Write one file per species for (int spec = 0; spec < header.specNum; spec++) { write(recMap[spec], std::to_string(spec + 1), recType, outPattern); } @@ -127,7 +127,7 @@ return false; } - //metadata + // metadata out << "species=" << species << " type=" << recType << " receptorNum=" << rec.size(); for (size_t i = 0; i < rec.size(); i++) { @@ -136,7 +136,7 @@ out << std::endl; - //header + // header out << "time"; for (size_t i = 0; i < rec.size(); i++) { out << ",value_" << i + 1; @@ -146,15 +146,15 @@ if (rec.size() == 0) return false; - //Each receptor series must have the same number of times + // Each receptor series must have the same number of times for (size_t i = 1; i < rec.size(); i++) { assert(rec[0].data.size() == rec[i].data.size()); - //Receptors series must have the same times + // Receptors series must have the same times for (size_t j = 0; j < rec[i].data.size(); j++) assert(rec[0].data[j].time == rec[i].data[j].time); } - //data + // data for (size_t j = 0; j < rec[0].data.size(); j++) { out << rec[0].data[j].time; diff -Nru metview-5.17.4/metview/src/Flextra/FlexpartRun.cc metview-5.19.2/metview/src/Flextra/FlexpartRun.cc --- metview-5.17.4/metview/src/Flextra/FlexpartRun.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Flextra/FlexpartRun.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,8 @@ #include #include #include -#include -#include +#include +#include //#define FLEXPART_CHK(str) if(!(str)) return false #define FLEXPART_CHK(str) ({if(!(str)) {setError(13); return false;} }) @@ -43,12 +43,10 @@ { public: FlexpartRun() : - Base("FLEXPART_RUN"), - forward_(true), - receptorNum_(0) { initIds(); } - void serve(MvRequest&, MvRequest&); + Base("FLEXPART_RUN") { initIds(); } + void serve(MvRequest&, MvRequest&) override; -protected: +private: void initIds(); std::string getReleaseDate(const std::string&, const std::string&); bool generatePathnamesFile(const std::string&, MvRequest&, const std::string&, const std::string&); @@ -68,13 +66,13 @@ std::map relLevelUnitsIds_; std::map domainFillIds_; std::string runDate_; - bool forward_; - int receptorNum_; + bool forward_{true}; + int receptorNum_{0}; }; void FlexpartRun::initIds() { - directionIds_["FORWARD"] = "1"; + directionIds_["FORWARD"] = "1"; directionIds_["BACKWARD"] = "-1"; #if 0 @@ -85,11 +83,11 @@ outputIds_["CONCENTRATION AND PLUME"]="5"; #endif - particleDumpIds_["NO"] = "0"; + particleDumpIds_["NO"] = "0"; particleDumpIds_["AT_OUTPUT"] = "1"; - particleDumpIds_["AT_END"] = "2"; + particleDumpIds_["AT_END"] = "2"; - onOffIds_["ON"] = "1"; + onOffIds_["ON"] = "1"; onOffIds_["OFF"] = "0"; sourceUnitsIds_["MASS"] = "1"; @@ -98,7 +96,7 @@ receptorUnitsIds_["MASS"] = "1"; receptorUnitsIds_["MIXR"] = "2"; - writeInitIds_["NO"] = "0"; + writeInitIds_["NO"] = "0"; writeInitIds_["MASS"] = "1"; writeInitIds_["MIXR"] = "2"; @@ -106,8 +104,8 @@ relLevelUnitsIds_["ASL"] = "2"; relLevelUnitsIds_["HPA"] = "3"; - domainFillIds_["NO"] = "0"; - domainFillIds_["FULL"] = "1"; + domainFillIds_["NO"] = "0"; + domainFillIds_["FULL"] = "1"; domainFillIds_["O3_TRACER"] = "2"; } @@ -132,9 +130,9 @@ MvRequest dataR = in("INPUT_DATA"); - //No icon is specified + // No icon is specified if (!dataR) { - //These can be relative paths + // These can be relative paths FLEXPART_CHK(in.getPath("INPUT_PATH", inPath, false)); FLEXPART_CHK(in.getValue("AVAILABLE_FILE_PATH", fAvailable, true)); @@ -153,12 +151,12 @@ return false; } - //These must be absolute paths + // These must be absolute paths FLEXPART_CHK(dataR.getValue("INPUT_DATA_PATH", inPath)); FLEXPART_CHK(dataR.getValue("AVAILABLE_FILE_PATH", fAvailable)); } - //Pathnames file + // Pathnames file std::ofstream out(fPathnames.c_str()); out << optionsPath << "/" << std::endl; out << outPath << "/" << std::endl; @@ -249,7 +247,7 @@ parName = "OUTPUT_TRAJECTORY"; FLEXPART_CHK(in.getValueId(parName, str, onOffIds_, true)); - //Forward run + // Forward run if (!bwd) { if (outFieldType == "RTIME") { marslog(LOG_EROR, "OUTPUT_FIELD_TYPE cannot be set to %s for forward simulations!", outFieldType.c_str()); @@ -257,7 +255,7 @@ return false; } - //no trajecory + // no trajecory if (str == "0" || str.empty()) { if (outFieldType == "CONC") outFieldId = "1"; @@ -272,7 +270,7 @@ } } - //has trajectory + // has trajectory else if (str == "1") { if (outFieldType == "NONE") outFieldId = "4"; @@ -286,7 +284,7 @@ } } - //backward + // backward else { if (outFieldType != "RTIME" && outFieldType != "NONE") { marslog(LOG_EROR, "OUTPUT_FIELD_TYPE cannot be set to %s for backward simulations!", outFieldType.c_str()); @@ -294,7 +292,7 @@ return false; } - //no trajecory + // no trajecory if (str == "0" || str.empty()) { if (outFieldType == "RTIME") outFieldId = "1"; @@ -305,7 +303,7 @@ } } - //has trajectory + // has trajectory else if (str == "1") { if (outFieldType == "NONE") outFieldId = "4"; @@ -345,11 +343,11 @@ else out << "1" << std::endl; - //parName="AGE_SPECTRA"; - //FLEXPART_CHK(in.getValueId(parName,str,onOffIds_)); - //out << str << std::endl; + // parName="AGE_SPECTRA"; + // FLEXPART_CHK(in.getValueId(parName,str,onOffIds_)); + // out << str << std::endl; - //Cont simulation with dumped particle data + // Cont simulation with dumped particle data out << "0" << std::endl; parName = "OUTPUT_FOR_EACH_RELEASE"; @@ -382,8 +380,8 @@ out << str << std::endl; parName = "NESTED_OUTPUT"; - //FLEXPART_CHK(metview::getParamValueId(str,in,"FLEXPART_NESTED_OUTPUT",onOffIds_)); - //out << str << std::endl; + // FLEXPART_CHK(metview::getParamValueId(str,in,"FLEXPART_NESTED_OUTPUT",onOffIds_)); + // out << str << std::endl; out << "0" << std::endl; parName = "SENSITIVITY"; @@ -413,7 +411,7 @@ *** HEADER ***\n\ *** HEADER ***\n"; - //Species + // Species std::vector sp; FLEXPART_CHK(in.getValue("RELEASE_SPECIES", sp)); @@ -423,17 +421,17 @@ } out << "===================================================================" << std::endl; - //Loop through the releases + // Loop through the releases MvRequest rel = in("RELEASES"); do { - MvRequest rs = rel.justOneRequest(); + MvRequest rs = rel.justOneRequest(); const char* iconType = rs.getVerb(); std::string iconName; if (const char* icnam = rs("_NAME")) iconName = std::string(icnam); - //If no icon is specified + // If no icon is specified if (!iconType || strcmp(iconType, "FLEXPART_RELEASE") != 0) { marslog(LOG_EROR, "No FLEXPART_RELEASE icon is specified!"); setError(13); @@ -536,7 +534,7 @@ *** HEADER ***\n\ *** HEADER ***\n\n"; - //std::string west,south,name,nx,ny,dx,dy,dz; + // std::string west,south,name,nx,ny,dx,dy,dz; parName = "OUTPUT_AREA"; std::vector area; @@ -586,15 +584,15 @@ return false; } - double dval; - std::vector levL; //we need to set a limit! + double dval = 0.; + std::vector levL; // we need to set a limit! for (int i = 0; i < cnt && i < 200; i++) { in.getValue(dval, "OUTPUT_LEVELS", i); levL.push_back(dval); } - float fVal; - int iVal; + float fVal = 0.; + int iVal = 0; out << std::fixed; @@ -701,11 +699,11 @@ std::map > vals; std::vector parLst; - parLst.push_back("RECEPTOR_NAMES"); - parLst.push_back("RECEPTOR_LATITUDES"); - parLst.push_back("RECEPTOR_LONGITUDES"); + parLst.emplace_back("RECEPTOR_NAMES"); + parLst.emplace_back("RECEPTOR_LATITUDES"); + parLst.emplace_back("RECEPTOR_LONGITUDES"); - for (auto s : parLst) { + for (const auto& s : parLst) { FLEXPART_CHK(in.getValue(s, vals[s])); } @@ -764,22 +762,22 @@ std::cout << "--------------FlexpartRun::serve()--------------" << std::endl; in.print(); - //Find out flexpart script paths + // Find out flexpart script paths std::string flexpartScript; std::string ppScript; char* mvbin = getenv("METVIEW_BIN"); - if (mvbin == 0) { + if (mvbin == nullptr) { marslog(LOG_EROR, "No METVIEW_BIN env variable is defined. Cannot locate script mv_flexpart_run!"); setError(13); return; } else { flexpartScript = std::string(mvbin) + "/mv_flexpart_run"; - ppScript = std::string(mvbin) + "/mv_flexpart_pp"; + ppScript = std::string(mvbin) + "/mv_flexpart_pp"; } - //Result path + // Result path std::string resPath; std::string errTxt; if (!in.getPath("OUTPUT_PATH", resPath, false)) { @@ -787,7 +785,7 @@ return; } - //Create tmp dir for the flexpart run + // Create tmp dir for the flexpart run std::string tmpPath; if (!metview::createWorkDir("flexpart", tmpPath, errTxt)) { marslog(LOG_EROR, "%s", errTxt.c_str()); @@ -795,59 +793,59 @@ return; } - //Genarate pathnames file - std::string fPathnames = tmpPath + "/pathnames"; + // Genarate pathnames file + std::string fPathnames = tmpPath + "/pathnames"; std::string optionsPath = tmpPath; - std::string outPath = tmpPath; + std::string outPath = tmpPath; if (!generatePathnamesFile(fPathnames, in, optionsPath, outPath)) { return; } - //Generate COMMAND file + // Generate COMMAND file std::string fCmd = tmpPath + "/COMMAND"; if (!generateCommandFile(fCmd, in)) { return; } - //Generate OUTGRID file + // Generate OUTGRID file std::string fGrid = tmpPath + "/OUTGRID"; if (!generateOutGridFile(fGrid, in)) { return; } - //Generate RELEASES file + // Generate RELEASES file std::string fRelease = tmpPath + "/RELEASES"; if (!generateReleasesFile(fRelease, in)) { return; } - //Generate AGECLASSES file + // Generate AGECLASSES file std::string fAge = tmpPath + "/AGECLASSES"; if (!generateAgeClassesFile(fAge, in)) { return; } - //Generate RECEPTORS file + // Generate RECEPTORS file std::string fReceptors = tmpPath + "/RECEPTORS"; if (!generateReceptorsFile(fReceptors, in)) { return; } - //Flexpart exe + // Flexpart exe std::string exe; if (!in.getPathAndReplace("USER_EXE_PATH", exe, "USE_MV_FLEXPART_EXE", "_UNDEF_")) { setError(13); return; } - //The resources directory + // The resources directory std::string resourcePath; if (!in.getPathAndReplace("USER_RESOURCES_PATH", resourcePath, "USE_MV_FLEXPART_RESOURCES", "_UNDEF_")) { setError(13); return; } - //The species directory + // The species directory std::string speciesPath; if (!in.getPathAndReplace("USER_SPECIES_PATH", speciesPath, "USE_MV_FLEXPART_SPECIES", "_UNDEF_")) { setError(13); @@ -860,26 +858,26 @@ std::string flexpartLogFileName = "log.txt"; - //Run the flexpart script + // Run the flexpart script std::string cmd = flexpartScript + " \"" + tmpPath + "\" \"" + flexpartLogFileName + "\" \"" + exe + "\" \"" + resourcePath + "\" \"" + speciesPath + "\""; - //marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); + // marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); std::cout << "Execute command: " << cmd << std::endl; - //Flexpart ouput goes into the stdout and into this file + // Flexpart ouput goes into the stdout and into this file std::string flexpartLogFile = tmpPath + "/" + flexpartLogFileName; - //The maximum number of lines we dump from the end of the log + // The maximum number of lines we dump from the end of the log int maxLogLineNum = 1000; - //Run the shell script + // Run the shell script int ret = system(cmd.c_str()); - //Log messages + // Log messages - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { if (WEXITSTATUS(ret) == 255) { marslog(LOG_WARN, "Warnings generated during FLEXPART run!"); @@ -913,17 +911,17 @@ if (!forward_) forwardStr = "0"; - //Run the posproc script + // Run the posproc script cmd = ppScript + " \"" + tmpPath + "\" \"" + flexpartLogFileName + "\" \"" + ppLogFileName + "\" \"" + resPath + "\" \"" + forwardStr + +"\" \"" + std::to_string(receptorNum_) + "\""; - //marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); + // marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); std::cout << "Execute command: " << cmd << std::endl; ret = system(cmd.c_str()); - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { std::string ppLogFile = tmpPath + "/" + ppLogFileName; diff -Nru metview-5.17.4/metview/src/Flextra/flexpartToGrib.cc metview-5.19.2/metview/src/Flextra/flexpartToGrib.cc --- metview-5.17.4/metview/src/Flextra/flexpartToGrib.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Flextra/flexpartToGrib.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,9 +11,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include "grib_api.h" @@ -22,16 +22,16 @@ class MvFlexpartRelease { public: - int num; - int start; - int end; + int num{0}; + int start{0}; + int end{0}; std::string type; - float west; - float east; - float north; - float south; - float top; - float bottom; + float west{0.}; + float east{0.}; + float north{0.}; + float south{0.}; + float top{0.}; + float bottom{0.}; std::vector massForSpec; }; @@ -41,28 +41,28 @@ public: MvFlexpartHeader(const std::string&); - int runDate; - int runTime; - int interval; - int averagingInterval; - int samplingInterval; - float west; - float south; - float north; - float east; - int nx; - int ny; - float dx; - float dy; + int runDate{0}; + int runTime{0}; + int interval{0}; + int averagingInterval{0}; + int samplingInterval{0}; + float west{0.}; + float south{0.}; + float north{0.}; + float east{0.}; + int nx{0}; + int ny{0}; + float dx{0.}; + float dy{0.}; std::vector levels; - int specNum; - int specPointNum; + int specNum{0}; + int specPointNum{0}; std::vector release; - int method; - bool hasSubGrid; - bool hasConvection; - int indSource; - int indReceptor; + int method{0}; + bool hasSubGrid{false}; + bool hasConvection{false}; + int indSource{0}; + int indReceptor{0}; std::vector ageClass; }; @@ -70,7 +70,7 @@ { public: MvFlexpartGrid(const std::string&, const std::string&, const std::string&); - ~MvFlexpartGrid() {} + ~MvFlexpartGrid() = default; protected: void convert(); @@ -80,7 +80,7 @@ std::string dir_; MvFlexpartHeader header_; - size_t fieldSize_; + size_t fieldSize_{0}; std::string gridFile_; std::string outPattern_; }; @@ -100,20 +100,20 @@ r.skipRecMarker(); r.skipRecMarker(); - interval = r.read(); + interval = r.read(); averagingInterval = r.read(); - samplingInterval = r.read(); + samplingInterval = r.read(); r.skipRecMarker(); r.skipRecMarker(); - west = r.read(); + west = r.read(); south = r.read(); - nx = r.read(); - ny = r.read(); - dx = r.read(); - dy = r.read(); - north = south + ny * dy; - east = west + nx * dx; + nx = r.read(); + ny = r.read(); + dx = r.read(); + dy = r.read(); + north = south + static_cast(ny) * dy; + east = west + static_cast(nx) * dx; r.skipRecMarker(); r.skipRecMarker(); @@ -126,25 +126,25 @@ r.skipRecMarker(); r.skipRecMarker(); - specNum = r.read() / 3; + specNum = r.read() / 3; specPointNum = r.read(); r.skipRecMarker(); - //Species + // Species for (int i = 0; i < specNum; i++) { std::string wd, dd, sp; r.skipRecMarker(); - r.skip(4); //1 + r.skip(4); // 1 r.read(10, wd); r.skipRecMarker(); r.skipRecMarker(); - r.skip(4); //1 + r.skip(4); // 1 r.read(10, dd); r.skipRecMarker(); r.skipRecMarker(); - int z = r.read(); + r.read(); // z r.read(10, sp); r.skipRecMarker(); @@ -152,7 +152,7 @@ << " " << i << " " << wd << " " << dd << " " << sp << std::endl; } - //Release points + // Release points r.skipRecMarker(); int releaseNum = r.read(); @@ -163,26 +163,26 @@ r.skipRecMarker(); rel.start = r.read(); - rel.end = r.read(); + rel.end = r.read(); r.read(2, rel.type); r.skipRecMarker(); r.skipRecMarker(); - rel.west = r.read(); - rel.south = r.read(); - rel.east = r.read(); - rel.north = r.read(); + rel.west = r.read(); + rel.south = r.read(); + rel.east = r.read(); + rel.north = r.read(); rel.bottom = r.read(); - rel.top = r.read(); + rel.top = r.read(); r.skipRecMarker(); r.skipRecMarker(); rel.num = r.read(); - r.skip(4); //1 + r.skip(4); // 1 r.skipRecMarker(); r.skipRecMarker(); - r.skip(45); //compoint + r.skip(45); // compoint r.skipRecMarker(); for (int j = 0; j < specNum; j++) { @@ -203,19 +203,19 @@ } r.skipRecMarker(); - method = r.read(); - hasSubGrid = r.read(); - hasConvection = r.read(); - indSource = r.read(); - indReceptor = r.read(); + method = r.read(); + hasSubGrid = (r.read() != 0); + hasConvection = (r.read() != 0); + indSource = r.read(); + indReceptor = r.read(); r.skipRecMarker(); r.skipRecMarker(); int acNum = r.read(); r.read(acNum, ageClass); - //r.skipRecMarker(); + // r.skipRecMarker(); - //delete [] d; + // delete [] d; std::cout << runDate << std::endl; std::cout << runTime << std::endl; @@ -230,8 +230,8 @@ std::cout << dy << std::endl; std::cout << num << std::endl; - for (size_t i = 0; i < levels.size(); i++) - std::cout << " " << levels[i] << std::endl; + for (float level : levels) + std::cout << " " << level << std::endl; std::cout << specNum << std::endl; std::cout << specPointNum << std::endl; @@ -250,32 +250,33 @@ { MvBinaryReader r(gridFile_); - if (!r.isValid()) + if (!r.isValid()) { return; + } - double* data = 0; + double* data = nullptr; r.skipRecMarker(); - int itime = r.read(); + r.read(); // itime r.skipRecMarker(); - //Loop for age classes + // Loop for age classes for (size_t ac = 0; ac < header_.ageClass.size(); ac++) { size_t dataSize = 0; - //Wet deposition + // Wet deposition dataSize = fieldSize_; initData(&data, dataSize); readField(&r, &data, dataSize, false); writeField(data, outPattern_ + "wet.grib"); - //Dry deposition + // Dry deposition dataSize = fieldSize_; initData(&data, dataSize); readField(&r, &data, dataSize, false); writeField(data, outPattern_ + "dry.grib"); - //Concentrations + // Concentrations dataSize = fieldSize_ * header_.levels.size(); initData(&data, dataSize); readField(&r, &data, dataSize, true); @@ -296,12 +297,12 @@ void MvFlexpartGrid::readField(MvBinaryReader* r, double** data, size_t dataSize, bool doAbs) { - int pos = 0; + int pos = 0; int factor = 1; - int cnt = 0; - size_t n = 0; + int cnt = 0; + size_t n = 0; - //Wet deposition + // Wet deposition r->skipRecMarker(); int spCnt_i = r->read(); @@ -333,8 +334,8 @@ n++; } - //int yPos=n/header.nx; - //int xPos=n-header.nx*yPos; + // int yPos=n/header.nx; + // int xPos=n-header.nx*yPos; int np = n; if (n >= fieldSize_) { np -= fieldSize_; @@ -347,42 +348,42 @@ else (*data)[np] = spDump_r[i]; - //std::cout << n << " " << data[n] << std::endl; + // std::cout << n << " " << data[n] << std::endl; } } void MvFlexpartGrid::writeField(double* data, const std::string& outFile) { - grib_handle* gh = 0; + grib_handle* gh = nullptr; size_t size = header_.nx * header_.ny; - int err = 0; + int err = 0; std::cout << "data: " << data << std::endl; - if ((gh = grib_handle_new_from_samples(0, "regular_ll_sfc_grib2")) == 0) { - //perror("ERROR: could not clone field"); + if ((gh = grib_handle_new_from_samples(nullptr, "regular_ll_sfc_grib2")) == nullptr) { + // perror("ERROR: could not clone field"); return; } - GRIB_CHECK(grib_set_double(gh, "longitudeOfFirstGridPointInDegrees", header_.west), 0); - GRIB_CHECK(grib_set_double(gh, "longitudeOfLastGridPointInDegrees", header_.east), 0); - GRIB_CHECK(grib_set_double(gh, "latitudeOfFirstGridPointInDegrees", header_.south), 0); - GRIB_CHECK(grib_set_double(gh, "latitudeOfLastGridPointInDegrees", header_.north), 0); - GRIB_CHECK(grib_set_long(gh, "Ni", header_.nx), 0); - GRIB_CHECK(grib_set_long(gh, "Nj", header_.ny), 0); - GRIB_CHECK(grib_set_double(gh, "iDirectionIncrementInDegrees", header_.dx), 0); - GRIB_CHECK(grib_set_double(gh, "jDirectionIncrementInDegrees", header_.dy), 0); - GRIB_CHECK(grib_set_long(gh, "jScansPositively", 1), 0); + GRIB_CHECK(grib_set_double(gh, "longitudeOfFirstGridPointInDegrees", header_.west), nullptr); + GRIB_CHECK(grib_set_double(gh, "longitudeOfLastGridPointInDegrees", header_.east), nullptr); + GRIB_CHECK(grib_set_double(gh, "latitudeOfFirstGridPointInDegrees", header_.south), nullptr); + GRIB_CHECK(grib_set_double(gh, "latitudeOfLastGridPointInDegrees", header_.north), nullptr); + GRIB_CHECK(grib_set_long(gh, "Ni", header_.nx), nullptr); + GRIB_CHECK(grib_set_long(gh, "Nj", header_.ny), nullptr); + GRIB_CHECK(grib_set_double(gh, "iDirectionIncrementInDegrees", header_.dx), nullptr); + GRIB_CHECK(grib_set_double(gh, "jDirectionIncrementInDegrees", header_.dy), nullptr); + GRIB_CHECK(grib_set_long(gh, "jScansPositively", 1), nullptr); - GRIB_CHECK(grib_set_long(gh, "bitsPerValue", 24), 0); + GRIB_CHECK(grib_set_long(gh, "bitsPerValue", 24), nullptr); - //for(int i=130; i < 140; i++) - // std::cout << i << " " << data[i] << std::endl; + // for(int i=130; i < 140; i++) + // std::cout << i << " " << data[i] << std::endl; - GRIB_CHECK(grib_set_double_array(gh, "values", data, size), 0); + GRIB_CHECK(grib_set_double_array(gh, "values", data, size), nullptr); - GRIB_CHECK(grib_write_message(gh, outFile.c_str(), "w"), 0); + GRIB_CHECK(grib_write_message(gh, outFile.c_str(), "w"), nullptr); grib_handle_delete(gh); } diff -Nru metview-5.17.4/metview/src/Flextra/flexpartTrajectory.cc metview-5.19.2/metview/src/Flextra/flexpartTrajectory.cc --- metview-5.17.4/metview/src/Flextra/flexpartTrajectory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Flextra/flexpartTrajectory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -56,7 +56,7 @@ std::string line; - //run date and time + // run date and time getline(in, line); std::string runDate, runTime; { @@ -64,10 +64,10 @@ sst >> runDate >> runTime; } - //options + // options getline(in, line); - //release + // release int relNum = 0; getline(in, line); @@ -90,17 +90,17 @@ } getline(in, line); { - //Todo - //r["name"]=line; + // Todo + // r["name"]=line; } relVec.push_back(r); } - //Trajectory waypoints + // Trajectory waypoints std::map > trMap; std::array fieldWidthArr = {5, 8, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6}; - std::array clWidthArr = {8, 8, 7, 6, 8}; + std::array clWidthArr = {8, 8, 7, 6, 8}; while (getline(in, line)) { FxpTraj t; @@ -148,8 +148,8 @@ trMap[actId].push_back(t); } - for (auto it = trMap.begin(); it != trMap.end(); ++it) { - if (!write(it->second, it->first, outPattern, runDate, runTime, relVec)) + for (auto& it : trMap) { + if (!write(it.second, it.first, outPattern, runDate, runTime, relVec)) return false; } @@ -163,7 +163,7 @@ int relId = metview::fromString(id); assert(relId > 0); - //Build output file name + // Build output file name int digits = static_cast(log10(relId)) + 1; if (digits <= 3) digits = 3; @@ -172,7 +172,7 @@ ss << std::setw(digits) << std::setfill('0') << relId; std::string outFile = outPattern + ss.str() + ".csv"; - //Open output file + // Open output file out.open(outFile.c_str()); if (!out.is_open()) { std::cerr << "Cannot open output file: " << outFile << std::endl; @@ -184,12 +184,12 @@ return false; } - //metadata + // metadata out << "runDate=" << runDate << " " << "runTime=" << runTime; const FxpTraj& tFirst = tr[0]; - int clNum = tFirst.clVec.size(); + int clNum = tFirst.clVec.size(); out << " clNum=" << clNum; @@ -205,7 +205,7 @@ out << std::endl; - //write header + // write header out << "time,meanLon,meanLat,meanZ,meanTopo,meanPBL,meanTropo,meanPv,rmsHBefore," << "rmsHAfter,rmsVBefore,rmsVAfter,pblFract,pv2Fract,tropoFract"; @@ -215,7 +215,7 @@ out << std::endl; - //write data + // write data for (const auto& t : tr) { assert(t.data.size() == 16); diff -Nru metview-5.17.4/metview/src/Flextra/FlextraPrepare.cc metview-5.19.2/metview/src/Flextra/FlextraPrepare.cc --- metview-5.17.4/metview/src/Flextra/FlextraPrepare.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Flextra/FlextraPrepare.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ protected: void registerCallbacks(); - virtual void reply(const MvRequest&) = 0; + virtual void reply(const MvRequest&) = 0; virtual void progress(const MvRequest&) = 0; }; @@ -43,16 +43,16 @@ void MvMacroCallerService::registerCallbacks() { - add_progress_callback(MvApplication::getService(), 0, + add_progress_callback(MvApplication::getService(), nullptr, progressCb, (void*)this); - add_reply_callback(MvApplication::getService(), 0, + add_reply_callback(MvApplication::getService(), nullptr, replyCb, (void*)this); } void MvMacroCallerService::progressCb(svcid* /*id*/, request* r, void* obj) { - //std::cout << "PROG callback: " << s << std::endl; + // std::cout << "PROG callback: " << s << std::endl; MvRequest in(r); if (auto* b = static_cast(obj)) b->progress(in); @@ -60,17 +60,17 @@ void MvMacroCallerService::replyCb(svcid* /*id*/, request* r, void* obj) { - //std::cout << "REPLY: " << std::endl; - //print_all_requests(r); + // std::cout << "REPLY: " << std::endl; + // print_all_requests(r); MvRequest in(r); - //in.print(); + // in.print(); if (auto* b = static_cast(obj)) b->reply(in); } class Base : public MvMacroCallerService { - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; protected: Base(const char* a, const std::string& id, const std::string& paramPrefix, @@ -81,8 +81,8 @@ return paramPrefix_ + p; } - void reply(const MvRequest&); - void progress(const MvRequest&); + void reply(const MvRequest&) override; + void progress(const MvRequest&) override; std::string id_; std::string paramPrefix_; @@ -118,16 +118,16 @@ hasReply_(false) { modeIds_["FORECAST"] = "fc"; - modeIds_["PERIOD"] = "period"; + modeIds_["PERIOD"] = "period"; - onOffIds_["ON"] = "1"; + onOffIds_["ON"] = "1"; onOffIds_["OFF"] = "0"; dataSourceIds_["MARS"] = "mars"; dataSourceIds_["FILE"] = "file"; areaSelectIds_["INTERPOLATE"] = "1"; - areaSelectIds_["NATIVE"] = "0"; + areaSelectIds_["NATIVE"] = "0"; } void Base::progress(const MvRequest& in) @@ -148,12 +148,12 @@ std::cout << "--------------FlextraPrepare::serve()--------------" << std::endl; in.print(); - //Etadot is not stored in MARS for dates earlier than this + // Etadot is not stored in MARS for dates earlier than this MvDate etaDotDate("20080604"); std::string flextraMacro; char* mvbin = getenv("METVIEW_BIN"); - if (mvbin == 0) { + if (mvbin == nullptr) { marslog(LOG_EROR, "No METVIEW_BIN env variable is defined. Cannot locate mv_flextra_prep.mv macro!"); setError(13); return; @@ -165,22 +165,22 @@ std::vector param; std::string str; - //The first param indicates that we are not in test mode - param.push_back("0"); + // The first param indicates that we are not in test mode + param.emplace_back("0"); - //The second param is the model type id + // The second param is the model type id param.push_back(id_); - //Add perparation mode + // Add perparation mode std::string prepMode; FLEXTRA_CHK(in.getValueId(paramName("PREPARE_MODE"), prepMode, modeIds_)); param.push_back(prepMode); - //Add reuse(check) input status + // Add reuse(check) input status FLEXTRA_CHK(in.getValueId(paramName("REUSE_INPUT"), str, onOffIds_)); param.push_back(str); - //Data source + // Data source std::string dataSource; FLEXTRA_CHK(in.getValueId(paramName("INPUT_SOURCE"), dataSource, dataSourceIds_)); param.push_back(dataSource); @@ -192,12 +192,12 @@ return; } - //Add outpath + // Add outpath std::string outPath; FLEXTRA_CHK(in.getPath(paramName("OUTPUT_PATH"), outPath, false)); param.push_back(outPath); - //Add Available file + // Add Available file std::string fAvailable = outPath + "/AVAILABLE"; param.push_back(fAvailable); @@ -211,21 +211,21 @@ std::vector area; std::vector grid; if (interpolate == "1") { - //Add area + // Add area FLEXTRA_CHK(in.getValue(paramName("AREA"), area)); param.push_back(metview::merge(area, "/")); - //Add grid resolution + // Add grid resolution FLEXTRA_CHK(in.getValue(paramName("GRID"), grid)); param.push_back(metview::merge(grid, "/")); } else { - param.push_back("0"); - param.push_back("0"); + param.emplace_back("0"); + param.emplace_back("0"); } - //Add top level + // Add top level std::string topL; FLEXTRA_CHK(in.getValue(paramName("TOP_LEVEL"), topL)); param.push_back(topL); @@ -244,13 +244,13 @@ } if (prepMode == "fc") { - //Add mars expver + // Add mars expver std::string marsExpver; FLEXTRA_CHK(in.getValue(paramName("FC_MARS_EXPVER"), marsExpver)); param.push_back(marsExpver); FLEXTRA_CHK(in.getValue(paramName("DATE"), str)); - //std::cout << "date=" << str << std::endl; + // std::cout << "date=" << str << std::endl; param.push_back(str); MvDate md(str.c_str()); @@ -269,24 +269,24 @@ param.push_back(metview::merge(steps, "/")); } else { - //Add mars class + // Add mars class std::string marsClass; FLEXTRA_CHK(in.getValue(paramName("FC_MARS_CLASS"), marsClass)); metview::toLower(marsClass); param.push_back(marsClass); - //Add mars class + // Add mars class std::string marsAnClass; FLEXTRA_CHK(in.getValue(paramName("AN_MARS_CLASS"), marsAnClass)); metview::toLower(marsAnClass); param.push_back(marsAnClass); - //Add mars expver + // Add mars expver std::string marsExpver; FLEXTRA_CHK(in.getValue(paramName("FC_MARS_EXPVER"), marsExpver)); param.push_back(marsExpver); - //Add mars expver + // Add mars expver std::string marsAnExpver; FLEXTRA_CHK(in.getValue(paramName("AN_MARS_EXPVER"), marsAnExpver)); param.push_back(marsAnExpver); @@ -328,7 +328,7 @@ } } - //Input files + // Input files if (dataSource == "file") { std::string inputFiles; FLEXTRA_CHK(in.getValue(paramName("INPUT_FILE"), inputFiles)); @@ -336,26 +336,26 @@ } - //Build request to be sent to Macro + // Build request to be sent to Macro MvRequest req("MACRO"); std::string processName = MakeProcessName("FlextraPrepare"); MvRequest macroReq("MACRO"); - req("PATH") = flextraMacro.c_str(); - req("_CLASS") = "MACRO"; - req("_ACTION") = "execute"; - req("_REPLY") = processName.c_str(); + req("PATH") = flextraMacro.c_str(); + req("_CLASS") = "MACRO"; + req("_ACTION") = "execute"; + req("_REPLY") = processName.c_str(); req("_EXTENDMESSAGE") = "1"; - //Define argument list for the macro! + // Define argument list for the macro! for (auto& it : param) { req.addValue("_ARGUMENTS", it.c_str()); } - //const char *cdir=getenv("PWD"); - //marslog(LOG_INFO,"PWD=%s",cdir); + // const char *cdir=getenv("PWD"); + // marslog(LOG_INFO,"PWD=%s",cdir); - //Run macro + // Run macro marslog(LOG_INFO, "Execute macro: %s", flextraMacro.c_str()); svc* mysvc = MvApplication::getService(); @@ -410,10 +410,10 @@ return; } #endif - //reply.print(); + // reply.print(); - out = MvRequest(outReqType_.c_str()); - out("INPUT_DATA_PATH") = outPath.c_str(); + out = MvRequest(outReqType_.c_str()); + out("INPUT_DATA_PATH") = outPath.c_str(); out("AVAILABLE_FILE_PATH") = fAvailable.c_str(); out.print(); diff -Nru metview-5.17.4/metview/src/Flextra/FlextraRun.cc metview-5.19.2/metview/src/Flextra/FlextraRun.cc --- metview-5.17.4/metview/src/Flextra/FlextraRun.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Flextra/FlextraRun.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,7 @@ #include #include #include -#include +#include //#define FLEXTRA_CHK(str) if(!(str)) return false @@ -43,7 +43,7 @@ public: FlextraRun() : Base("FLEXTRA_RUN") { initIds(); } - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; protected: void initIds(); @@ -70,34 +70,34 @@ void FlextraRun::initIds() { - directionIds_["FORWARD"] = "1"; + directionIds_["FORWARD"] = "1"; directionIds_["BACKWARD"] = "-1"; modeIds_["NORMAL"] = "1"; - modeIds_["CET"] = "2"; + modeIds_["CET"] = "2"; modeIds_["FLIGHT"] = "3"; intervalIds_["ORIGINAL"] = "0"; intervalIds_["INTERVAL"] = "1"; - intervalIds_["BOTH"] = "2"; + intervalIds_["BOTH"] = "2"; - cetTypeIds_["3D"] = "1"; + cetTypeIds_["3D"] = "1"; cetTypeIds_["MODEL LEVEL"] = "2"; - cetTypeIds_["ISOBARIC"] = "4"; - cetTypeIds_["ISENTROPIC"] = "5"; + cetTypeIds_["ISOBARIC"] = "4"; + cetTypeIds_["ISENTROPIC"] = "5"; cetLevelUnitsIds_["METRES ASL"] = "1"; cetLevelUnitsIds_["METRES AGL"] = "2"; - cetLevelUnitsIds_["HPA"] = "3"; + cetLevelUnitsIds_["HPA"] = "3"; - flightTypeIds_["3D"] = "1"; + flightTypeIds_["3D"] = "1"; flightTypeIds_["MODEL LEVEL"] = "2"; - flightTypeIds_["ISOBARIC"] = "4"; - flightTypeIds_["ISENTROPIC"] = "5"; + flightTypeIds_["ISOBARIC"] = "4"; + flightTypeIds_["ISENTROPIC"] = "5"; flightLevelUnitsIds_["METRES ASL"] = "1"; flightLevelUnitsIds_["METRES AGL"] = "2"; - flightLevelUnitsIds_["HPA"] = "3"; + flightLevelUnitsIds_["HPA"] = "3"; } bool FlextraRun::getMvDate(const std::string& dd, const std::string& tt, MvDate& res) @@ -128,21 +128,21 @@ } if (strcmp(input_mode, "ICON") == 0) { - MvRequest dataR = in("FLEXTRA_INPUT_DATA"); + MvRequest dataR = in("FLEXTRA_INPUT_DATA"); const char* iconType = dataR.getVerb(); - //If no icon is specified + // If no icon is specified if (!iconType || strcmp(iconType, "FLEXTRA_INPUT") != 0) { marslog(LOG_EROR, "No FLEXTRA_INPUT icon is specified!"); setError(13); return false; } - //These must be absolute paths + // These must be absolute paths FLEXTRA_CHK(dataR.getValue("INPUT_DATA_PATH", inPath)); FLEXTRA_CHK(dataR.getValue("AVAILABLE_FILE_PATH", fAvailable)); } else if (strcmp(input_mode, "PATH") == 0) { - //These can be relative paths + // These can be relative paths FLEXTRA_CHK(in.getPath("FLEXTRA_INPUT_PATH", inPath, false)); FLEXTRA_CHK(in.getValue("FLEXTRA_AVAILABLE_FILE_PATH", fAvailable)); @@ -191,7 +191,7 @@ return false; } - //Pathnames file + // Pathnames file std::ofstream out(fPathnames.c_str()); out << optionsPath << "/" << std::endl; out << outPath << "/" << std::endl; @@ -210,7 +210,7 @@ std::string str, str2, trMode; - //Find outrun mode. It is needed for the starting dates + // Find outrun mode. It is needed for the starting dates FLEXTRA_CHK(in.getValueId("FLEXTRA_RUN_MODE", trMode, modeIds_)); out << "**********************************************\n\ @@ -225,7 +225,7 @@ FLEXTRA_CHK(in.getValueId("FLEXTRA_TRAJECTORY_DIRECTION", str, directionIds_)); out << str << std::endl; - //format is: hhhmmss + // format is: hhhmmss FLEXTRA_CHK(in.getValue("FLEXTRA_TRAJECTORY_LENGTH", str)); if (MvDate::timeToLenAsHHHMMSS(str, str2) == false) { marslog(LOG_EROR, "Invalid value red for FLEXTRA_TRAJECTORY_LENGTH=%s. Expected format is: HHH[:MM[:SS]]", str.c_str()); @@ -247,21 +247,21 @@ FLEXTRA_CHK(in.getTime("FLEXTRA_LAST_STARTING_TIME", str)); out << str << std::endl; - //format is: hhhmmss + // format is: hhhmmss FLEXTRA_CHK(in.getValue("FLEXTRA_STARTING_TIME_INTERVAL", str)); if (MvDate::timeToLenAsHHHMMSS(str, str2) == false) { marslog(LOG_EROR, "Invalid value red for FLEXTRA_STARTING_TIME_INTERVAL=%s. Expected format is: HHH[:MM[:SS]]", str.c_str()); setError(13); return false; } - //FLEXTRA_CHK(in.getTimeLenInSec("FLEXTRA_STARTING_TIME_INTERVAL",str)); + // FLEXTRA_CHK(in.getTimeLenInSec("FLEXTRA_STARTING_TIME_INTERVAL",str)); out << str2 << std::endl; } - //In FLIGHT mode the starting date,time and interval are disabled in the - //user interface beause FLEXTRA does not use them for the trajectory - //computations. However FLEXTRA does need a proper date here, otherwise it crashes. - //So we use the first date and time from the FLIGHT starting points here. + // In FLIGHT mode the starting date,time and interval are disabled in the + // user interface beause FLEXTRA does not use them for the trajectory + // computations. However FLEXTRA does need a proper date here, otherwise it crashes. + // So we use the first date and time from the FLIGHT starting points here. else { std::vector startDate, startTime; FLEXTRA_CHK(in.getValue("FLEXTRA_FLIGHT_STARTING_DATES", startDate)); @@ -299,7 +299,7 @@ #endif out << str << std::endl; - //It might be disabled in the inteface (for CET and FLIGHT modes) + // It might be disabled in the inteface (for CET and FLIGHT modes) in.getValue("FLEXTRA_UNCERTAINTY_TRAJECTORIES", str, true); if (str == "ON") { FLEXTRA_CHK(in.getValue("FLEXTRA_UNCERTAINTY_TRAJECTORY_NUMBER", str)); @@ -329,7 +329,7 @@ FLEXTRA_CHK(in.getValue("FLEXTRA_CFL_TEMPORAL", str)); out << str << std::endl; - //FLEXTRA_CHK(getParamValueId(str,in,"FLEXTRA_RUN_MODE",modeIds_)); + // FLEXTRA_CHK(getParamValueId(str,in,"FLEXTRA_RUN_MODE",modeIds_)); out << trMode << std::endl; out.close(); @@ -473,7 +473,7 @@ return false; } - double dval; + double dval = 0.; std::vector areaL; for (int i = 0; i < cnt; i++) { in.getValue(dval, "FLEXTRA_CET_AREA", i); @@ -599,10 +599,10 @@ bool FlextraRun::getDateRange(MvDate& rangeStart, MvDate& rangeEnd, MvRequest& in) { std::string str, dStr, tStr, trMode; - int lenSec; + int lenSec = 0; MvDate startDate1, startDate2; - //Find outrun mode. It is needed for the starting dates + // Find outrun mode. It is needed for the starting dates FLEXTRA_CHK(in.getValueId("FLEXTRA_RUN_MODE", trMode, modeIds_)); FLEXTRA_CHK(in.getTimeLenInSec("FLEXTRA_TRAJECTORY_LENGTH", tStr)); @@ -623,10 +623,10 @@ return false; } - //In FLIGHT mode the starting date,time and interval are disabled in the - //user interface beause FLEXTRA does not use them for the trajectory - //computations. However FLEXTRA does need a proper date here, otherwise it crashes. - //So we use the first date and time from the FLIGHT starting points here. + // In FLIGHT mode the starting date,time and interval are disabled in the + // user interface beause FLEXTRA does not use them for the trajectory + // computations. However FLEXTRA does need a proper date here, otherwise it crashes. + // So we use the first date and time from the FLIGHT starting points here. else { std::vector startDate, startTime; FLEXTRA_CHK(in.getValue("FLEXTRA_FLIGHT_STARTING_DATES", startDate)); @@ -650,15 +650,15 @@ rangeStart = startDate1; - rangeEnd = startDate2 + static_cast(lenSec) / 86400.; + rangeEnd = startDate2 + static_cast(lenSec) / 86400.; return true; } bool FlextraRun::getPredefInputPath(const std::string& rootPath, const MvDate& startDate, const MvDate& /*endDate*/, std::string& resDir) { - //Scan rootpath for FLEXTRA input directories - DIR* dp; + // Scan rootpath for FLEXTRA input directories + DIR* dp = nullptr; struct dirent* dirp; if ((dp = opendir(rootPath.c_str())) == nullptr) { marslog(LOG_EROR, "Failed to open directory: %s", rootPath.c_str()); @@ -668,18 +668,17 @@ std::vector dateVec; std::vector pathVec; - std::string::size_type pos; while ((dirp = readdir(dp)) != nullptr) { std::string name(dirp->d_name); - if (name.size() == 13 && (pos = name.find("_")) != std::string::npos) { + if (name.size() == 13 && name.find("_") != std::string::npos) { std::string s; std::string sDate = name.substr(0, 8); std::string sTime = name.substr(9, 4); - s = sDate; + s = sDate; sDate = s.substr(0, 4) + "-" + s.substr(4, 2) + "-" + s.substr(6, 2); - s = sTime; + s = sTime; sTime = s.substr(0, 2) + ":" + s.substr(2, 4) + ":00"; s = sDate + " " + sTime; @@ -711,7 +710,7 @@ std::string errTxt; - //Find out flextra script path + // Find out flextra script path std::string flextraScript; char* mvbin = getenv("METVIEW_BIN"); if (mvbin == nullptr) { @@ -724,7 +723,7 @@ } - //Create tmp dir for the flextra run + // Create tmp dir for the flextra run std::string tmpPath; if (!metview::createWorkDir("flextra", tmpPath, errTxt)) { marslog(LOG_EROR, "%s", errTxt.c_str()); @@ -732,28 +731,28 @@ return; } - //Flextra exe + // Flextra exe std::string exe; if (!in.getPathAndReplace("FLEXTRA_EXE_PATH", exe, "USE_MV_FLEXTRA_EXE", "_UNDEF_")) { setError(13); return; } - //Genarate pathnames file - std::string fPathnames = tmpPath + "/pathnames"; + // Genarate pathnames file + std::string fPathnames = tmpPath + "/pathnames"; std::string optionsPath = tmpPath; - std::string outPath = tmpPath; + std::string outPath = tmpPath; if (!generatePathnamesFile(fPathnames, in, optionsPath, outPath)) { return; } - //Generate COMMAND file + // Generate COMMAND file std::string fCmd = tmpPath + "/COMMAND"; if (!generateCommandFile(fCmd, in)) { return; } - //Get FLEXTRA RUN MODE + // Get FLEXTRA RUN MODE std::string trMode; in.getValueId("FLEXTRA_RUN_MODE", trMode, modeIds_); @@ -787,16 +786,16 @@ std::string resFileName = "res.txt"; std::string logFileName = "log.txt"; - //Run the flextra script + // Run the flextra script std::string cmd = flextraScript + " \"" + tmpPath + "\" \"" + exe + "\" \"" + trModeName + "\" \"" + resFileName + "\" \"" + logFileName + "\""; - //marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); + // marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); std::cout << "Execute command: " << cmd << std::endl; int ret = system(cmd.c_str()); - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { std::string logFile = tmpPath + "/" + logFileName; std::ifstream in(logFile.c_str()); @@ -808,7 +807,7 @@ marslog(LOG_WARN, "%s", line.c_str()); } in.close(); - //setError(13); + // setError(13); } else if (WEXITSTATUS(ret) == 1) { marslog(LOG_EROR, "Failed to perform FLEXTRA run!"); @@ -832,7 +831,7 @@ std::string resFile = tmpPath + "/" + resFileName; - out = MvRequest("FLEXTRA_FILE"); + out = MvRequest("FLEXTRA_FILE"); out("PATH") = resFile.c_str(); out.print(); diff -Nru metview-5.17.4/metview/src/Flextra/FlextraVisualiser.cc metview-5.19.2/metview/src/Flextra/FlextraVisualiser.cc --- metview-5.17.4/metview/src/Flextra/FlextraVisualiser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Flextra/FlextraVisualiser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ public: FlextraVisualiser(const char* a) : Base(a) {} - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; void FlextraVisualiser::serve(MvRequest& in, MvRequest& out) @@ -44,12 +44,12 @@ // Find out the input filename //------------------------------------------ - MvRequest dataR = inR("FLEXTRA_DATA"); + MvRequest dataR = inR("FLEXTRA_DATA"); const char* iconType = dataR.getVerb(); - //If no icon is specified + // If no icon is specified if (!iconType) { - //If no path is there either + // If no path is there either const char* path = inR("FLEXTRA_FILENAME"); if (!path || strcmp(path, "OFF") == 0) { marslog(LOG_EROR, "No data icon or path is specified!"); @@ -105,7 +105,7 @@ // Select block //---------------------------------- - MvFlextraBlock* data = nullptr; + MvFlextraBlock* data = nullptr; const char* blockIdChar = inR("FLEXTRA_GROUP_INDEX"); if (blockIdChar) { int blockId = atoi(blockIdChar) - 1; @@ -142,25 +142,25 @@ std::string outFilePoints(marstmp()); int metaDataCntPoints = 0; - //data->writeAll(outFilePoints,metaDataCntPoints); + // data->writeAll(outFilePoints,metaDataCntPoints); - //Requests + // Requests if (strcmp(plot_type, "GEO_POINTS") == 0) { if (strcmp(plot_mode, "TRAJECTORY") == 0) { data->writeAll(outFilePoints, metaDataCntPoints); MvRequest req("TABLE_GEO_POINTS"); - req("TABLE_PLOT_TYPE") = "GEO_POINTS"; - req("TABLE_FILENAME") = outFilePoints.c_str(); + req("TABLE_PLOT_TYPE") = "GEO_POINTS"; + req("TABLE_FILENAME") = outFilePoints.c_str(); req("TABLE_VARIABLE_IDENTIFIER_TYPE") = "INDEX"; - req("TABLE_LONGITUDE_VARIABLE") = 4; - req("TABLE_LATITUDE_VARIABLE") = 5; - req("TABLE_VALUE_VARIABLE") = 1; - req("TABLE_DELIMITER") = ","; - req("TABLE_COMBINE_DELIMITERS") = "OFF"; - req("TABLE_HEADER_ROW") = 0; - req("TABLE_DATA_ROW_OFFSET") = metaDataCntPoints + 1; //3; + req("TABLE_LONGITUDE_VARIABLE") = 4; + req("TABLE_LATITUDE_VARIABLE") = 5; + req("TABLE_VALUE_VARIABLE") = 1; + req("TABLE_DELIMITER") = ","; + req("TABLE_COMBINE_DELIMITERS") = "OFF"; + req("TABLE_HEADER_ROW") = 0; + req("TABLE_DATA_ROW_OFFSET") = metaDataCntPoints + 1; // 3; for (int i = 0; i < metaDataCntPoints; i++) { req.addValue("TABLE_META_DATA_ROWS", i + 1); @@ -169,24 +169,24 @@ out = req; MvRequest vdef("MSYMB"); - vdef("LEGEND") = "ON"; - vdef("SYMBOL_TYPE") = "MARKER"; - vdef("SYMBOL_TABLE_MODE") = "ADVANCED"; + vdef("LEGEND") = "ON"; + vdef("SYMBOL_TYPE") = "MARKER"; + vdef("SYMBOL_TABLE_MODE") = "ADVANCED"; vdef("SYMBOL_ADVANCED_TABLE_SELECTION_TYPE") = "INTERVAL"; - vdef("SYMBOL_ADVANCED_TABLE_MIN_VALUE") = 1; - vdef("SYMBOL_ADVANCED_TABLE_MAX_VALUE") = trNum + 1; //!! - vdef("SYMBOL_ADVANCED_TABLE_INTERVAL") = 1; + vdef("SYMBOL_ADVANCED_TABLE_MIN_VALUE") = 1; + vdef("SYMBOL_ADVANCED_TABLE_MAX_VALUE") = trNum + 1; //!! + vdef("SYMBOL_ADVANCED_TABLE_INTERVAL") = 1; for (int i = 0; i < 9; i++) { vdef.addValue("SYMBOL_ADVANCED_TABLE_MARKER_LIST", i); } - vdef("SYMBOL_ADVANCED_TABLE_HEIGHT_LIST") = 0.3; - vdef("SYMBOL_CONNECT_LINE") = "ON"; - vdef("SYMBOL_CONNECT_AUTOMATIC_LINE_COLOUR") = "ON"; + vdef("SYMBOL_ADVANCED_TABLE_HEIGHT_LIST") = 0.3; + vdef("SYMBOL_CONNECT_LINE") = "ON"; + vdef("SYMBOL_CONNECT_AUTOMATIC_LINE_COLOUR") = "ON"; vdef("SYMBOL_ADVANCED_TABLE_COLOUR_DIRECTION") = "CLOCKWISE"; - vdef("_CLASS") = "MSYMB"; - vdef("_NAME") = "MSYMB0"; + vdef("_CLASS") = "MSYMB"; + vdef("_NAME") = "MSYMB0"; out = out + vdef; } @@ -195,16 +195,16 @@ data->writeLabels(outFilePoints, metaDataCntPoints, "6h", labels); MvRequest req("TABLE_GEO_POINTS"); - req("TABLE_PLOT_TYPE") = "GEO_POINTS"; - req("TABLE_FILENAME") = outFilePoints.c_str(); + req("TABLE_PLOT_TYPE") = "GEO_POINTS"; + req("TABLE_FILENAME") = outFilePoints.c_str(); req("TABLE_VARIABLE_IDENTIFIER_TYPE") = "INDEX"; - req("TABLE_LONGITUDE_VARIABLE") = 3; - req("TABLE_LATITUDE_VARIABLE") = 4; - req("TABLE_VALUE_VARIABLE") = ""; - req("TABLE_DELIMITER") = ","; - req("TABLE_COMBINE_DELIMITERS") = "OFF"; - req("TABLE_HEADER_ROW") = 0; - req("TABLE_DATA_ROW_OFFSET") = metaDataCntPoints + 1; //3; + req("TABLE_LONGITUDE_VARIABLE") = 3; + req("TABLE_LATITUDE_VARIABLE") = 4; + req("TABLE_VALUE_VARIABLE") = ""; + req("TABLE_DELIMITER") = ","; + req("TABLE_COMBINE_DELIMITERS") = "OFF"; + req("TABLE_HEADER_ROW") = 0; + req("TABLE_DATA_ROW_OFFSET") = metaDataCntPoints + 1; // 3; for (int i = 0; i < metaDataCntPoints; i++) { req.addValue("TABLE_META_DATA_ROWS", i + 1); @@ -214,17 +214,17 @@ MvRequest vdef("MSYMB"); vdef("LEGEND") = "OFF"; - //vdef("SYMBOL_TYPE") = "NUMBER"; - //vdef("FORMAT") = "(F4.2)"; - //vdef("_CLASS")="MSYMB"; - //vdef("_NAME")="MSYMB0"; + // vdef("SYMBOL_TYPE") = "NUMBER"; + // vdef("FORMAT") = "(F4.2)"; + // vdef("_CLASS")="MSYMB"; + // vdef("_NAME")="MSYMB0"; - vdef("SYMBOL_TYPE") = "TEXT"; + vdef("SYMBOL_TYPE") = "TEXT"; vdef("SYMBOL_TABLE_MODE") = "ADVANCED"; /*vdef("SYMBOL_ADVANCED_TABLE_SELECTION_TYPE") = "INTERVAL"; - vdef("SYMBOL_ADVANCED_TABLE_MIN_VALUE") = 1; - vdef("SYMBOL_ADVANCED_TABLE_MAX_VALUE") = trNum+1; //!! - vdef("SYMBOL_ADVANCED_TABLE_INTERVAL") = 1;*/ + vdef("SYMBOL_ADVANCED_TABLE_MIN_VALUE") = 1; + vdef("SYMBOL_ADVANCED_TABLE_MAX_VALUE") = trNum+1; //!! + vdef("SYMBOL_ADVANCED_TABLE_INTERVAL") = 1;*/ for (auto& label : labels) { vdef.addValue("SYMBOL_ADVANCED_TABLE_TEXT_LIST", label.c_str()); @@ -234,42 +234,42 @@ vdef("SYMBOL_ADVANCED_TABLE_TEXT_HEIGHT") = 0.3; vdef("SYMBOL_ADVANCED_TABLE_COLOUR_DIRECTION") = "CLOCKWISE"; - vdef("_CLASS") = "MSYMB"; - vdef("_NAME") = "MSYMB0"; + vdef("_CLASS") = "MSYMB"; + vdef("_NAME") = "MSYMB0"; out = out + vdef; /*const char *period=inR("FLEXTRA_LABEL_PERIOD"); - std::string periodStr(period); - - std::string outFileLabels(marstmp()); - int metaDataCnt=0; - - data->writeLabels(outFileLabels,metaDataCnt,period); - - - MvRequest req("TABLE_GEO_POINTS"); - req("TABLE_PLOT_TYPE")="GEO_POINTS"; - req("TABLE_FILENAME")=outFileLabels.c_str(); - req("TABLE_VARIABLE_IDENTIFIER_TYPE")="INDEX"; - req("TABLE_LONGITUDE_VARIABLE")=3; - req("TABLE_LATITUDE_VARIABLE")=4; - req("TABLE_VALUE_VARIABLE")=1; - req("TABLE_DELIMITER")=","; - req("TABLE_COMBINE_DELIMITERS")="OFF"; - req("TABLE_HEADER_ROW") = 0; - req("TABLE_DATA_ROW_OFFSET") = metaDataCnt+1;//3; - - out=req; - - - - - MvRequest vdef("MSYMB"); - vdef("LEGEND") = "OFF"; - vdef("SYMBOL_TYPE") = "NUMBER"; - - out=out+vdef;*/ + std::string periodStr(period); + + std::string outFileLabels(marstmp()); + int metaDataCnt=0; + + data->writeLabels(outFileLabels,metaDataCnt,period); + + + MvRequest req("TABLE_GEO_POINTS"); + req("TABLE_PLOT_TYPE")="GEO_POINTS"; + req("TABLE_FILENAME")=outFileLabels.c_str(); + req("TABLE_VARIABLE_IDENTIFIER_TYPE")="INDEX"; + req("TABLE_LONGITUDE_VARIABLE")=3; + req("TABLE_LATITUDE_VARIABLE")=4; + req("TABLE_VALUE_VARIABLE")=1; + req("TABLE_DELIMITER")=","; + req("TABLE_COMBINE_DELIMITERS")="OFF"; + req("TABLE_HEADER_ROW") = 0; + req("TABLE_DATA_ROW_OFFSET") = metaDataCnt+1;//3; + + out=req; + + + + + MvRequest vdef("MSYMB"); + vdef("LEGEND") = "OFF"; + vdef("SYMBOL_TYPE") = "NUMBER"; + + out=out+vdef;*/ } out("_VERB") = "TABLE_GEO_POINTS"; @@ -289,18 +289,18 @@ data->writeAll(outFilePoints, metaDataCntPoints); std::map parId; - parId["DATE"] = 2; - parId["LATITUDE"] = 4; - parId["LONGITUDE"] = 5; - parId["ETA"] = 6; - parId["PRESSURE"] = 7; - parId["HEIGHT"] = 8; + parId["DATE"] = 2; + parId["LATITUDE"] = 4; + parId["LONGITUDE"] = 5; + parId["ETA"] = 6; + parId["PRESSURE"] = 7; + parId["HEIGHT"] = 8; parId["HEIGHT_AGL"] = 9; - parId["PV"] = 10; + parId["PV"] = 10; MvRequest req("TABLE_XY_POINTS"); - req("TABLE_PLOT_TYPE") = "XY_POINTS"; - req("TABLE_FILENAME") = outFilePoints.c_str(); + req("TABLE_PLOT_TYPE") = "XY_POINTS"; + req("TABLE_FILENAME") = outFilePoints.c_str(); req("TABLE_VARIABLE_IDENTIFIER_TYPE") = "INDEX"; if (strcmp(x_var, "DATE") == 0) { @@ -313,11 +313,11 @@ } req("TABLE_Y_VARIABLE") = parId[std::string(y_var)]; - req("TABLE_VALUE_VARIABLE") = "1"; - req("TABLE_DELIMITER") = ","; + req("TABLE_VALUE_VARIABLE") = "1"; + req("TABLE_DELIMITER") = ","; req("TABLE_COMBINE_DELIMITERS") = "OFF"; - req("TABLE_HEADER_ROW") = 0; - req("TABLE_DATA_ROW_OFFSET") = metaDataCntPoints + 1; + req("TABLE_HEADER_ROW") = 0; + req("TABLE_DATA_ROW_OFFSET") = metaDataCntPoints + 1; for (int i = 0; i < metaDataCntPoints; i++) { req.addValue("TABLE_META_DATA_ROWS", i + 1); } @@ -325,31 +325,31 @@ out = req; MvRequest vdef("MSYMB"); - vdef("LEGEND") = "ON"; - vdef("SYMBOL_TYPE") = "MARKER"; - vdef("SYMBOL_TABLE_MODE") = "ADVANCED"; + vdef("LEGEND") = "ON"; + vdef("SYMBOL_TYPE") = "MARKER"; + vdef("SYMBOL_TABLE_MODE") = "ADVANCED"; vdef("SYMBOL_ADVANCED_TABLE_SELECTION_TYPE") = "INTERVAL"; - vdef("SYMBOL_ADVANCED_TABLE_MIN_VALUE") = 1; - vdef("SYMBOL_ADVANCED_TABLE_MAX_VALUE") = trNum + 1; //!! - vdef("SYMBOL_ADVANCED_TABLE_INTERVAL") = 1; + vdef("SYMBOL_ADVANCED_TABLE_MIN_VALUE") = 1; + vdef("SYMBOL_ADVANCED_TABLE_MAX_VALUE") = trNum + 1; //!! + vdef("SYMBOL_ADVANCED_TABLE_INTERVAL") = 1; for (int i = 0; i < 9; i++) { vdef.addValue("SYMBOL_ADVANCED_TABLE_MARKER_LIST", i); } - vdef("SYMBOL_ADVANCED_TABLE_HEIGHT_LIST") = 0.3; - vdef("SYMBOL_CONNECT_LINE") = "ON"; - vdef("SYMBOL_CONNECT_AUTOMATIC_LINE_COLOUR") = "ON"; + vdef("SYMBOL_ADVANCED_TABLE_HEIGHT_LIST") = 0.3; + vdef("SYMBOL_CONNECT_LINE") = "ON"; + vdef("SYMBOL_CONNECT_AUTOMATIC_LINE_COLOUR") = "ON"; vdef("SYMBOL_ADVANCED_TABLE_COLOUR_DIRECTION") = "CLOCKWISE"; - vdef("_CLASS") = "MSYMB"; - vdef("_NAME") = "MSYMB0"; + vdef("_CLASS") = "MSYMB"; + vdef("_NAME") = "MSYMB0"; out = out + vdef; /*MvRequest vdef("MGRAPH"); - vdef("LEGEND") = "ON"; - vdef("GRAPH_LINE") = "ON"; - out=out+vdef;*/ + vdef("LEGEND") = "ON"; + vdef("GRAPH_LINE") = "ON"; + out=out+vdef;*/ } out("_VERB") = "TABLE_XY_POINTS"; @@ -360,57 +360,57 @@ //---------------------------------- /*const char *highlight=in("FLEXTRA_SYMBOL_HIGHLIGHT"); - - if(highlight && strcmp(highlight,"ON") == 0) - { - const char *period=inR("FLEXTRA_SYMBOL_HIGHLIGHT_PERIOD"); - std::string periodStr(period); - - std::string outFileHighlight(marstmp()); - int metaDataCnt=0; - - data->writeHighlightPoints(outFileHighlight,metaDataCnt,periodStr); - - //Requests - - if(strcmp(plot_type,"GEO_POINTS") == 0) - { - MvRequest req("TABLE_GEO_POINTS"); - req("TABLE_PLOT_TYPE")="GEO_POINTS"; - req("TABLE_FILENAME")=outFileHighlight.c_str(); - req("TABLE_VARIABLE_IDENTIFIER_TYPE")="INDEX"; - req("TABLE_LONGITUDE_VARIABLE")=3; - req("TABLE_LATITUDE_VARIABLE")=4; - req("TABLE_VALUE_VARIABLE")=1; - req("TABLE_DELIMITER")=","; - req("TABLE_COMBINE_DELIMITERS")="OFF"; - req("TABLE_HEADER_ROW") = 0; - req("TABLE_DATA_ROW_OFFSET") = metaDataCnt+1;//3; - - - MvRequest vdef("MSYMB"); - //vdef("LEGEND") = "ON"; - vdef("SYMBOL_TYPE") = "MARKER"; - vdef("SYMBOL_TABLE_MODE") = "ADVANCED"; - //vdef("SYMBOL_OUTLINE") = "ON"; - vdef("SYMBOL_ADVANCED_TABLE_SELECTION_TYPE") = "INTERVAL"; - vdef("SYMBOL_ADVANCED_TABLE_MIN_VALUE") = 1; - vdef("SYMBOL_ADVANCED_TABLE_MAX_VALUE") = trNum+1; - vdef("SYMBOL_ADVANCED_TABLE_INTERVAL") = 1; - for(int i=0; i < 9; i++) - { - vdef.addValue("SYMBOL_ADVANCED_TABLE_MARKER_LIST",i); - } - - //vdef("SYMBOL_ADVANCED_TABLE_MARKER_LIST") = 15; - vdef("SYMBOL_ADVANCED_TABLE_HEIGHT_LIST") = 0.6; - vdef("SYMBOL_ADVANCED_TABLE_COLOUR_DIRECTION") = "CLOCKWISE"; - - out=out+req; - out=out+vdef; - } - } - */ + + if(highlight && strcmp(highlight,"ON") == 0) + { + const char *period=inR("FLEXTRA_SYMBOL_HIGHLIGHT_PERIOD"); + std::string periodStr(period); + + std::string outFileHighlight(marstmp()); + int metaDataCnt=0; + + data->writeHighlightPoints(outFileHighlight,metaDataCnt,periodStr); + + //Requests + + if(strcmp(plot_type,"GEO_POINTS") == 0) + { + MvRequest req("TABLE_GEO_POINTS"); + req("TABLE_PLOT_TYPE")="GEO_POINTS"; + req("TABLE_FILENAME")=outFileHighlight.c_str(); + req("TABLE_VARIABLE_IDENTIFIER_TYPE")="INDEX"; + req("TABLE_LONGITUDE_VARIABLE")=3; + req("TABLE_LATITUDE_VARIABLE")=4; + req("TABLE_VALUE_VARIABLE")=1; + req("TABLE_DELIMITER")=","; + req("TABLE_COMBINE_DELIMITERS")="OFF"; + req("TABLE_HEADER_ROW") = 0; + req("TABLE_DATA_ROW_OFFSET") = metaDataCnt+1;//3; + + + MvRequest vdef("MSYMB"); + //vdef("LEGEND") = "ON"; + vdef("SYMBOL_TYPE") = "MARKER"; + vdef("SYMBOL_TABLE_MODE") = "ADVANCED"; + //vdef("SYMBOL_OUTLINE") = "ON"; + vdef("SYMBOL_ADVANCED_TABLE_SELECTION_TYPE") = "INTERVAL"; + vdef("SYMBOL_ADVANCED_TABLE_MIN_VALUE") = 1; + vdef("SYMBOL_ADVANCED_TABLE_MAX_VALUE") = trNum+1; + vdef("SYMBOL_ADVANCED_TABLE_INTERVAL") = 1; + for(int i=0; i < 9; i++) + { + vdef.addValue("SYMBOL_ADVANCED_TABLE_MARKER_LIST",i); + } + + //vdef("SYMBOL_ADVANCED_TABLE_MARKER_LIST") = 15; + vdef("SYMBOL_ADVANCED_TABLE_HEIGHT_LIST") = 0.6; + vdef("SYMBOL_ADVANCED_TABLE_COLOUR_DIRECTION") = "CLOCKWISE"; + + out=out+req; + out=out+vdef; + } + } + */ MvRequest legReq("MLEGEND"); legReq("LEGEND_DISPLAY_TYPE") = "DISJOINT"; @@ -420,7 +420,7 @@ out.print(); - //system(cmd.c_str()); + // system(cmd.c_str()); } diff -Nru metview-5.17.4/metview/src/FlextraExaminer/FlextraExaminer.cc metview-5.19.2/metview/src/FlextraExaminer/FlextraExaminer.cc --- metview-5.17.4/metview/src/FlextraExaminer/FlextraExaminer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/FlextraExaminer/FlextraExaminer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -37,15 +37,15 @@ FlextraExaminer::FlextraExaminer(QWidget* parent) : MvQMainWindow(parent), - data_(0), - actionFileInfo_(0), - actionLog_(0) + data_(nullptr), + actionFileInfo_(nullptr), + actionLog_(nullptr) { // Initializations setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("Metview - FLEXTRA Examiner")); - //Initial size + // Initial size setInitialSize(1100, 800); setupBlockPanel(); @@ -84,7 +84,7 @@ splitterSize << 200 << 900; centralSplitter_->setSizes(splitterSize); - //Log + // Log logPanel_ = new MvQLogPanel(this); mainSplitter_->addWidget(logPanel_); @@ -163,7 +163,7 @@ void FlextraExaminer::setupDumpPanel() { // Build a layout - dumpPanel_ = new QWidget(this); + dumpPanel_ = new QWidget(this); auto* dumpLayout = new QVBoxLayout(dumpPanel_); dumpLayout->setContentsMargins(0, 0, 0, 0); @@ -202,7 +202,7 @@ blockLayout->addWidget(blockTree_); - //connect(blockTree_,SIGNAL(itemActivated(QTreeWidgetItem*,int)), + // connect(blockTree_,SIGNAL(itemActivated(QTreeWidgetItem*,int)), // this,SLOT(slotBlockSelected(QTreeWidgetItem*,int))); connect(blockTree_, SIGNAL(customContextMenuRequested(const QPoint&)), @@ -217,7 +217,7 @@ // Clean data if already exists if (data_) { delete data_; - data_ = 0; + data_ = nullptr; } // Write initial message in the log area @@ -231,7 +231,7 @@ if (data_->blockNum() == 0) { delete data_; - data_ = 0; + data_ = nullptr; GuiLog().error() << "Could not open FLEXTRA file"; StatusMsgHandler::instance()->failed(); return false; @@ -251,13 +251,13 @@ blockPanel_->hide(); } else { - QTreeWidgetItem* firstItem = 0; + QTreeWidgetItem* firstItem = nullptr; for (int i = 0; i < data_->blockNum(); i++) { - auto* item = new QTreeWidgetItem(blockTree_); + auto* item = new QTreeWidgetItem(blockTree_); QString comment = QString::fromStdString(data_->blocks().at(i)->comment()); - QString step = (data_->blocks().at(i)->constantStep()) ? tr("Constant") : tr("Flexible"); - QString utr = (data_->blocks().at(i)->uncertaintyTr()) ? tr("y") : tr("n"); + QString step = (data_->blocks().at(i)->constantStep()) ? tr("Constant") : tr("Flexible"); + QString utr = (data_->blocks().at(i)->uncertaintyTr()) ? tr("y") : tr("n"); item->setData(0, Qt::DisplayRole, QString::number(i + 1)); item->setData(1, Qt::DisplayRole, comment); @@ -326,14 +326,14 @@ void FlextraExaminer::slotContextMenu(const QPoint& position) { QTreeWidgetItem* item = blockTree_->itemAt(position); - int row = item->data(0, Qt::DisplayRole).toString().toInt(); + int row = item->data(0, Qt::DisplayRole).toString().toInt(); row--; if (row < 0 || row >= data_->blockNum()) return; QList actions; - //Inser new key + // Inser new key auto* actionSave = new QAction(this); actionSave->setObjectName(QString::fromUtf8("actionSave")); actionSave->setText(tr("Save")); @@ -367,7 +367,6 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-FlextraExaminer"); - QVariant value; settings.beginGroup("mainWindow"); restoreGeometry(settings.value("geometry").toByteArray()); centralSplitter_->restoreState(settings.value("centralSplitter").toByteArray()); diff -Nru metview-5.17.4/metview/src/FlextraExaminer/FlextraExaminer.h metview-5.19.2/metview/src/FlextraExaminer/FlextraExaminer.h --- metview-5.17.4/metview/src/FlextraExaminer/FlextraExaminer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/FlextraExaminer/FlextraExaminer.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,8 @@ Q_OBJECT public: - FlextraExaminer(QWidget* parent = 0); - ~FlextraExaminer(); + FlextraExaminer(QWidget* parent = nullptr); + ~FlextraExaminer() override; bool initData(const std::string&, const std::string&); void updateFileInfoLabel(); diff -Nru metview-5.17.4/metview/src/FlextraExaminer/MvMain.cc metview-5.19.2/metview/src/FlextraExaminer/MvMain.cc --- metview-5.17.4/metview/src/FlextraExaminer/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/FlextraExaminer/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ exit(1); } - //Get flextra file name + // Get flextra file name std::string fPath; if (const char* tmpc = in("PATH")) { fPath = std::string(tmpc); @@ -56,16 +56,16 @@ // } // } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("FlextraExaminer"); MvQApplication app(argc, argv, appName.c_str(), QStringList{"examiner", "window", "find"}); - //Create the flextra browser, initialize it and show it + // Create the flextra browser, initialize it and show it auto* browser = new FlextraExaminer; browser->setAppIcon("FLEXTRA_FILE"); browser->initData(fPath, iconPath); browser->show(); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/FlextraExaminer/MvQHighlighter.cc metview-5.19.2/metview/src/FlextraExaminer/MvQHighlighter.cc --- metview-5.17.4/metview/src/FlextraExaminer/MvQHighlighter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/FlextraExaminer/MvQHighlighter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ { HighlightingRule rule; - //Keywords + // Keywords QTextCharFormat keywordFormat; keywordFormat.setForeground(Qt::darkBlue); @@ -42,11 +42,11 @@ highlightingRules.append(rule); } - //Data keywords + // Data keywords QTextCharFormat dataKeyFormat; dataKeyFormat.setForeground(QColor(224, 138, 33)); - //dataKeyFormat.setForeground(QColor(255,119,119)); + // dataKeyFormat.setForeground(QColor(255,119,119)); dataKeyFormat.setFontWeight(QFont::Bold); QStringList dataKeyPatterns; @@ -62,8 +62,8 @@ << " Q"; foreach (QString pattern, dataKeyPatterns) { - //rule.pattern = QRegExp(pattern,Qt::CaseInsensitive); - //QString s=pattern + "(?==)"; + // rule.pattern = QRegExp(pattern,Qt::CaseInsensitive); + // QString s=pattern + "(?==)"; QString s = pattern; #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) rule.pattern = QRegularExpression(s); @@ -75,7 +75,7 @@ highlightingRules.append(rule); } - //Comments + // Comments QTextCharFormat singleLineCommentFormat; singleLineCommentFormat.setFontItalic(true); @@ -88,7 +88,7 @@ rx.setPatternSyntax(QRegExp::WildcardUnix); #endif rule.pattern = rx; - rule.format = singleLineCommentFormat; + rule.format = singleLineCommentFormat; highlightingRules.append(rule); } diff -Nru metview-5.17.4/metview/src/FlextraExaminer/MvQHighlighter.h metview-5.19.2/metview/src/FlextraExaminer/MvQHighlighter.h --- metview-5.17.4/metview/src/FlextraExaminer/MvQHighlighter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/FlextraExaminer/MvQHighlighter.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,10 +24,10 @@ class MvQHighlighter : public QSyntaxHighlighter { public: - MvQHighlighter(QTextDocument* parent = 0); + MvQHighlighter(QTextDocument* parent = nullptr); protected: - void highlightBlock(const QString& text); + void highlightBlock(const QString& text) override; private: struct HighlightingRule diff -Nru metview-5.17.4/metview/src/Gaia/Gaia.cc metview-5.19.2/metview/src/Gaia/Gaia.cc --- metview-5.17.4/metview/src/Gaia/Gaia.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Gaia/Gaia.cc 2023-07-15 08:28:47.000000000 +0000 @@ -64,7 +64,7 @@ // FAMII20200812: at the moment, returns only one netcdf file // Check if file exists std::string ffile = vfiles[0]; - FILE* f = fopen(ffile.c_str(), "r"); + FILE* f = fopen(ffile.c_str(), "r"); if (!f) { std::string error = "Gaia-> FILE NOT FOUND: "; error += ffile.c_str(); @@ -132,7 +132,7 @@ times_.clear(); times_.reserve(ntimes); for (int i = 0; i < ntimes; ++i) - times_.push_back((int)in("TIME", i) / 100); //hhmm + times_.push_back((int)in("TIME", i) / 100); // hhmm // Get grid resolution if (strcmp((const char*)in("GRID"), "OFF") == 0) @@ -150,21 +150,21 @@ // 1. Fixed part of the path. Try to get it from the environment variable: // METVIEW_GAIA_PATH. If not defined, use a default value. const char* fpath = getenv("METVIEW_GAIA_PATH"); - spath_ = fpath ? fpath : GAIA_PATH_PREFIX_DEFAULT; + spath_ = fpath ? fpath : GAIA_PATH_PREFIX_DEFAULT; // 2. Part of the path related to the TYPE std::string stype = (const char*)in("TYPE"); - spath_ = spath_ + stype + "/"; + spath_ = spath_ + stype + "/"; if (stype == "MODEL") { std::string smodel = (const char*)in("MODEL"); - spath_ = spath_ + smodel + "/"; + spath_ = spath_ + smodel + "/"; } else if (stype == "OBSERVATION") { std::string sobs = (const char*)in("OBSTYPE"); - spath_ = spath_ + sobs + "/"; + spath_ = spath_ + sobs + "/"; } else if (stype == "GEONETCAST") { - //spath = spath + ; + // spath = spath + ; } return true; @@ -292,7 +292,7 @@ } else if (smodel == "WRF") { std::string region = (const char*)in("REGION_WRF"); - std::string resol = (const char*)in("RESOLUTION_WRF"); + std::string resol = (const char*)in("RESOLUTION_WRF"); if (!build_filenames_wrf(region, resol, stimes, ssteps, vfn)) return false; } @@ -316,9 +316,9 @@ std::string ssat = (const char*)in("SATELLITE_TYPE"); metview::toLower(ssat); std::string stype = (const char*)in("OBSTYPE"); - long ltime1 = (int)in("INITIAL_TIME"); - long ltime2 = (int)in("FINAL_TIME"); - double dres = (double)in("RESOLUTION_SAT"); + long ltime1 = (int)in("INITIAL_TIME"); + long ltime2 = (int)in("FINAL_TIME"); + double dres = (double)in("RESOLUTION_SAT"); // Build filenames vfn.clear(); @@ -333,7 +333,7 @@ // Build filename with wildcards representing time and orbit for (std::size_t i = 0; i < dates_.size(); i++) { sdate_dir = spath_ + dates_[i] + "/"; - //sfn = fn_prefix + dates_[i] + "_*_" + ssat + "_*_" + fn_suffix; + // sfn = fn_prefix + dates_[i] + "_*_" + ssat + "_*_" + fn_suffix; fn_prefix = sfn + dates_[i]; if (!get_filenames(sdate_dir, fn_prefix, fn_suffix, ssat, ltime1, ltime2, vfn)) { @@ -703,8 +703,8 @@ // Open each input grib file and add them to the output GRIB file // Auxilliary variables for GribApi - int error = 0; - grib_handle* h = nullptr; + int error = 0; + grib_handle* h = nullptr; grib_context* c = grib_context_get_default(); // Create output file name @@ -713,7 +713,7 @@ for (int i = 0; i < (signed)vfiles.size(); ++i) { // Open the input file std::string ffile = vfiles[i]; - FILE* f = fopen(ffile.c_str(), "r"); + FILE* f = fopen(ffile.c_str(), "r"); if (!f) { std::string error = "Gaia-> FILE NOT FOUND: "; error += ffile.c_str(); @@ -774,8 +774,8 @@ // Auxilliary variables for GribApi char caux[40]; size_t len; - int error = 0; - grib_handle* h = nullptr; + int error = 0; + grib_handle* h = nullptr; grib_context* c = grib_context_get_default(); // Open input grib file @@ -828,37 +828,37 @@ bool Gaia::add_messages_tpl(const std::string& ffile, const std::string& outname) { - //FAMI20210607 - // This version does not check parameter level type, only param and level - // What to do with parameter level type? - // File wrf_metarea5_00_20210112033 contains the following values: - // mars.levtype typeOfLevel - // ml hybrid - // sfc entireAtmosphere - // sfc surface - // sfc meanSea - // sfc depthBelowLandLayer - // sfc depthBelowLand - // sfc heightAboveGround - // sfc cloudBase - // sfc cloudTop - // sfc nominalTop - // sfc isothermZero - // pl isobaricInhPa - // 101 isobaricLayer - // 106 heightAboveGroundLayer - // 116 pressureFromGroundLayer - // 204 unknown - // 214 unknown - // 215 unknown - // 224 unknown - // 234 unknown + // FAMI20210607 + // This version does not check parameter level type, only param and level + // What to do with parameter level type? + // File wrf_metarea5_00_20210112033 contains the following values: + // mars.levtype typeOfLevel + // ml hybrid + // sfc entireAtmosphere + // sfc surface + // sfc meanSea + // sfc depthBelowLandLayer + // sfc depthBelowLand + // sfc heightAboveGround + // sfc cloudBase + // sfc cloudTop + // sfc nominalTop + // sfc isothermZero + // pl isobaricInhPa + // 101 isobaricLayer + // 106 heightAboveGroundLayer + // 116 pressureFromGroundLayer + // 204 unknown + // 214 unknown + // 215 unknown + // 224 unknown + // 234 unknown // Auxilliary variables for GribApi char caux[40]; size_t len; - int error = 0; - grib_handle* h = nullptr; + int error = 0; + grib_handle* h = nullptr; grib_context* c = grib_context_get_default(); // Open input grib file diff -Nru metview-5.17.4/metview/src/Gaia/Gaia.h metview-5.19.2/metview/src/Gaia/Gaia.h --- metview-5.17.4/metview/src/Gaia/Gaia.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Gaia/Gaia.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,8 @@ class Gaia : public MvService { public: - Gaia(char* name) : MvService(name) {} + Gaia(char* name) : + MvService(name) {} void serve(MvRequest&, MvRequest&); diff -Nru metview-5.17.4/metview/src/GeopExaminer/GeopExaminer.cc metview-5.19.2/metview/src/GeopExaminer/GeopExaminer.cc --- metview-5.17.4/metview/src/GeopExaminer/GeopExaminer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GeopExaminer/GeopExaminer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,17 +35,13 @@ #endif GeopExaminer::GeopExaminer(QWidget* parent) : - MvQMainWindow(parent), - gpModel_(0), - actionFileInfo_(0), - treeData_(0), - ignoreDataRowSpinChangeSignal_(false) + MvQMainWindow(parent) { // Initializations setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("Metview - Geopoints Examiner")); - //Initial size + // Initial size setInitialSize(1100, 800); setupDataBox(); @@ -79,7 +75,7 @@ // Central area mainLayout->addWidget(dataPanel_, 1); - //Log + // Log logPanel_ = new MvQLogPanel(this); mainSplitter_->addWidget(logPanel_); @@ -267,7 +263,7 @@ // Write initial message in the log area GuiLog().task() << "Loading geopoints file"; - data_ = new MvGeoPoints(); + data_ = new MvGeoPoints(); bool ok = data_->load(filename.c_str()); updateFileInfoLabel(); @@ -287,14 +283,14 @@ // Instantiate the model /*gpModel_ = new MvQGeoPointsDataModel; - // Instantiate the sort model - gpSortModel_= new QSortFilterProxyModel; - gpSortModel_->setSourceModel(gpModel_); - gpSortModel_->setDynamicSortFilter(true); - - // Set the sort model - treeData_->setModel(gpSortModel_); - treeData_->setSortingEnabled(true);*/ + // Instantiate the sort model + gpSortModel_= new QSortFilterProxyModel; + gpSortModel_->setSourceModel(gpModel_); + gpSortModel_->setDynamicSortFilter(true); + + // Set the sort model + treeData_->setModel(gpSortModel_); + treeData_->setSortingEnabled(true);*/ // Load data gpModel_->dataIsAboutToChange(); @@ -304,7 +300,7 @@ treeData_->sortByColumn(0, Qt::AscendingOrder); // Set min/max values - //dataRowSpin_->setRange(1,data_->count()); + // dataRowSpin_->setRange(1,data_->count()); dataRowSpin_->reset(data_->count(), false); #if 0 // rezise according to the column contents @@ -327,9 +323,9 @@ QString t; if (data_) { auto subCol = MvQTheme::subText(); - auto bold = MvQTheme::boldFileInfoTitle(); - auto m = data_->metadataConst(); - for (auto v : m) { + auto bold = MvQTheme::boldFileInfoTitle(); + auto m = data_->metadataConst(); + for (const auto& v : m) { auto key = QString::fromStdString(v.first); auto val = QString::fromStdString(v.second.toString()); t += MvQ::formatText(key + ": ", subCol, bold) + val + " "; @@ -386,7 +382,6 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV4-GeopExaminer"); - QVariant value; settings.beginGroup("mainWindow"); restoreGeometry(settings.value("geometry").toByteArray()); mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); diff -Nru metview-5.17.4/metview/src/GeopExaminer/GeopExaminer.h metview-5.19.2/metview/src/GeopExaminer/GeopExaminer.h --- metview-5.17.4/metview/src/GeopExaminer/GeopExaminer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GeopExaminer/GeopExaminer.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,8 @@ Q_OBJECT public: - GeopExaminer(QWidget* parent = 0); - ~GeopExaminer(); + GeopExaminer(QWidget* parent = nullptr); + ~GeopExaminer() override; bool initMetaData(const std::string&); void updateFileInfoLabel(); @@ -55,19 +55,19 @@ void writeSettings(); MvGeoPoints* data_{nullptr}; - MvQGeoPointsDataModel* gpModel_; - QSortFilterProxyModel* gpSortModel_; + MvQGeoPointsDataModel* gpModel_{nullptr}; + QSortFilterProxyModel* gpSortModel_{nullptr}; MvQMainWindow::MenuItemMap menuItems_; - MvQFileInfoLabel* fileInfoLabel_; - QLabel* metadataLabel_; + MvQFileInfoLabel* fileInfoLabel_{nullptr}; + QLabel* metadataLabel_{nullptr}; - QAction* actionFileInfo_; - QSplitter* mainSplitter_; - MvQTreeView* treeData_; - MvQLogPanel* logPanel_; - QAction* actionLog_; - QLabel* statusMessageLabel_; - bool ignoreDataRowSpinChangeSignal_; - MvQArrowSpinWidget* dataRowSpin_; - QWidget* dataPanel_; + QAction* actionFileInfo_{nullptr}; + QSplitter* mainSplitter_{nullptr}; + MvQTreeView* treeData_{nullptr}; + MvQLogPanel* logPanel_{nullptr}; + QAction* actionLog_{nullptr}; + QLabel* statusMessageLabel_{nullptr}; + bool ignoreDataRowSpinChangeSignal_{false}; + MvQArrowSpinWidget* dataRowSpin_{nullptr}; + QWidget* dataPanel_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/GeopExaminer/MvGeoPointsModel.cc metview-5.19.2/metview/src/GeopExaminer/MvGeoPointsModel.cc --- metview-5.17.4/metview/src/GeopExaminer/MvGeoPointsModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GeopExaminer/MvGeoPointsModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,6 @@ MvQGeoPointsDataModel::MvQGeoPointsDataModel(QObject* parent) : QAbstractItemModel(parent) { - data_ = nullptr; } void MvQGeoPointsDataModel::dataIsAboutToChange() @@ -28,27 +27,27 @@ { data_ = data; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } int MvQGeoPointsDataModel::columnCount(const QModelIndex&) const { if (data_ != nullptr) - return data_->totalcols() + 1; + return static_cast(data_->totalcols() + 1); return 0; } int MvQGeoPointsDataModel::rowCount(const QModelIndex& parent) const { - //Non-root + // Non-root if (parent.isValid()) return 0; - //Root + // Root if (data_ != nullptr) - return data_->count(); + return static_cast(data_->count()); return 0; } @@ -56,10 +55,10 @@ QVariant MvQGeoPointsDataModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::UserRole)) - return QVariant(); + return {}; if (index.column() < 0 || index.column() > (int)(data_->totalcols() + 1)) - return QVariant(); + return {}; if (index.column() == 0) return index.row() + 1; @@ -68,12 +67,12 @@ // Get a specific row and column element if (role == Qt::DisplayRole) { // return a nice string to display - int type; + int type = 0; return QString::fromStdString(data_->value(index.row(), index.column() - 1, type)); } else if (role == Qt::UserRole) { // this role is used for sorting, so return a number (so that [100, 20] is correctly sorted) - int type; + int type = 0; QString val = QString::fromStdString(data_->value(index.row(), index.column() - 1, type)); if (type == eGeoVDouble) return val.toDouble(); @@ -84,7 +83,7 @@ return val; } else - return QVariant(); + return {}; } QVariant MvQGeoPointsDataModel::headerData(const int section, const Qt::Orientation orient, const int role) const @@ -93,7 +92,7 @@ return QAbstractItemModel::headerData(section, orient, role); if (section < 0 || !data_ || (data_ && section >= (int)(data_->totalcols() + 1))) - return QVariant(); + return {}; if (section == 0) return QString(tr("Index")); @@ -105,7 +104,7 @@ QModelIndex MvQGeoPointsDataModel::index(int row, int column, const QModelIndex&) const { if (data_ == nullptr || data_->count() <= 0 || column < 0) - return QModelIndex(); + return {}; return createIndex(row, column, (void*)nullptr); } @@ -113,5 +112,5 @@ QModelIndex MvQGeoPointsDataModel::parent(const QModelIndex&) const { - return QModelIndex(); + return {}; } diff -Nru metview-5.17.4/metview/src/GeopExaminer/MvGeoPointsModel.h metview-5.19.2/metview/src/GeopExaminer/MvGeoPointsModel.h --- metview-5.17.4/metview/src/GeopExaminer/MvGeoPointsModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GeopExaminer/MvGeoPointsModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,18 +18,18 @@ public: MvQGeoPointsDataModel(QObject* parent); - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void dataIsAboutToChange(); void setBaseData(MvGeoPoints*); private: - MvGeoPoints* data_; + MvGeoPoints* data_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/GeopExaminer/MvMain.cc metview-5.19.2/metview/src/GeopExaminer/MvMain.cc --- metview-5.17.4/metview/src/GeopExaminer/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GeopExaminer/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ exit(1); } - //Get geopints file name + // Get geopints file name std::string fgpt; if (const char* tmpc = in("PATH")) { fgpt = std::string(tmpc); @@ -42,16 +42,16 @@ exit(1); } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("GeopointsExaminer"); MvQApplication app(argc, argv, appName.c_str(), {"examiner", "window", "find"}); - //Create the geopoints browser, initialize it and show it + // Create the geopoints browser, initialize it and show it auto* browser = new GeopExaminer; browser->setAppIcon("GEOPOINTS"); browser->initMetaData(fgpt); browser->show(); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/GribExaminer/GribExaminer.cc metview-5.19.2/metview/src/GribExaminer/GribExaminer.cc --- metview-5.17.4/metview/src/GribExaminer/GribExaminer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GribExaminer/GribExaminer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -54,6 +54,7 @@ #include "MvQTreeExpandState.h" #include "MessageControlPanel.h" +#include "MessageLabel.h" #include "PlainTextWidget.h" #include "StatusMsgHandler.h" @@ -65,11 +66,11 @@ MvQGribMainPanel::MvQGribMainPanel(QWidget* parent) : QWidget(parent), - data_(0) + data_(nullptr) { messagePanel_ = new MvQMessagePanel(this); - dumpPanel_ = new MvQGribDumpPanel(this); - gotoPanel_ = new MessageControlPanel(false, false, this); + dumpPanel_ = new MvQGribDumpPanel(this); + gotoPanel_ = new MessageControlPanel(false, false, this); auto* dataLayout = new QVBoxLayout(this); dataLayout->setContentsMargins(0, 0, 0, 0); @@ -81,7 +82,7 @@ dataSplitter_->setOpaqueResize(false); dataLayout->addWidget(dataSplitter_, 1); - //dataSplitter_->addWidget(filterPanel_); + // dataSplitter_->addWidget(filterPanel_); dataSplitter_->addWidget(messagePanel_); dataSplitter_->addWidget(dumpPanel_); @@ -123,10 +124,11 @@ messagePanel_->loadKeyProfile(prof); } - +// called when a new grib file is loaded void MvQGribMainPanel::reloadData() { gotoPanel_->resetMessageNum(0, false); + messagePanel_->clearProfile(); messagePanel_->adjustProfile(true, -1); } @@ -137,17 +139,17 @@ QApplication::restoreOverrideCursor(); } -//msgCnt: starts at 0 +// msgCnt: starts at 0 void MvQGribMainPanel::messageSelected(int msgCnt) { emit newMessageSelected(msgCnt); - //The message counter might not have been initialised. But at this point - //we must know the correct message num so we can set the counter. + // The message counter might not have been initialised. But at this point + // we must know the correct message num so we can set the counter. if (gotoPanel_->messageValue() == 0) gotoPanel_->resetMessageNum(data_->messageNum(), false); - //Set the message counter + // Set the message counter gotoPanel_->setMessageValue(msgCnt + 1, false); QApplication::setOverrideCursor(QCursor(Qt::BusyCursor)); @@ -185,7 +187,7 @@ MvQGribDumpPanel::MvQGribDumpPanel(QWidget* parent) : QWidget(parent), currentMsg_(-1), - data_(0) + data_(nullptr) { gribNameSpace_ << "Default" << "geography" @@ -196,7 +198,7 @@ << "time" << "vertical"; - QWidget* w; + QWidget* w = nullptr; auto* dumpLayout = new QVBoxLayout(this); dumpLayout->setContentsMargins(0, 0, 0, 0); @@ -212,8 +214,8 @@ // Namespace dump //-------------------------------- - //Layout - w = new QWidget(this); + // Layout + w = new QWidget(this); auto* mvDumpLayout = new QVBoxLayout(w); mvDumpLayout->setContentsMargins(0, 2, 0, 0); mvDumpLayout->setSpacing(0); @@ -222,12 +224,12 @@ dumpTab_->tabBar()->setTabData(dumpTab_->count() - 1, "namespace"); // auto wp = new MvQPanel(this); - auto wp = new QWidget(this); + auto wp = new QWidget(this); auto* nsComboLayout = new QHBoxLayout(wp); nsComboLayout->setContentsMargins(2, 2, 0, 2); auto* nsLabel = new QLabel(tr(" ecCodes namespace:"), wp); - //nsLabel->setProperty("panelStyle", "2"); + // nsLabel->setProperty("panelStyle", "2"); nsCombo_ = new QComboBox(this); nsLabel->setBuddy(nsCombo_); @@ -239,9 +241,9 @@ nsCombo_->setCurrentIndex(-1); mvDumpLayout->addWidget(wp); - //filter + // filter mvDumpFilterHolder_ = new QWidget(this); - auto filterHb = new QHBoxLayout(mvDumpFilterHolder_); + auto filterHb = new QHBoxLayout(mvDumpFilterHolder_); filterHb->setContentsMargins(0, 0, 0, 0); filterHb->setSpacing(6); auto filterLabel = new QLabel(this); @@ -261,8 +263,8 @@ mvDumpLayout->addWidget(mvDumpFilterHolder_); mvDumpLayout->addSpacing(3); - //tree - mvDumpModel_ = new MvQGribMvDumpModel(this); + // tree + mvDumpModel_ = new MvQGribMvDumpModel(this); mvDumpSortModel_ = new QSortFilterProxyModel(this); mvDumpSortModel_->setDynamicSortFilter(true); mvDumpSortModel_->setFilterRole(Qt::UserRole); @@ -287,7 +289,7 @@ // Std dump //-------------------------------- - w = new QWidget(this); + w = new QWidget(this); auto* stdDumpLayout = new QVBoxLayout(w); stdDumpLayout->setContentsMargins(0, 2, 0, 0); stdDumpLayout->setSpacing(0); @@ -295,8 +297,8 @@ Q_ASSERT(static_cast(StdTabIndex) == dumpTab_->count() - 1); dumpTab_->tabBar()->setTabData(dumpTab_->count() - 1, "std"); - //wp = new MvQPanel(this); - wp = new QWidget(this); + // wp = new MvQPanel(this); + wp = new QWidget(this); auto* stdControlLayout = new QHBoxLayout(wp); stdControlLayout->setContentsMargins(2, 2, 0, 2); stdDumpLayout->addWidget(wp); @@ -317,11 +319,11 @@ stdControlLayout->addWidget(stdTextTb); stdControlLayout->addStretch(1); - //Stacked + // Stacked stdDumpStacked_ = new QStackedWidget(this); stdDumpLayout->addWidget(stdDumpStacked_); - stdDumpTree_ = new MvQTreeView(this, true); + stdDumpTree_ = new MvQTreeView(this, true); stdDumpModel_ = new MvQGribStdDumpModel(this); stdDumpTree_->setModel(stdDumpModel_); stdDumpTree_->setAlternatingRowColors(true); @@ -333,7 +335,7 @@ stdDumpBrowser_->editor()->setReadOnly(true); stdDumpStacked_->addWidget(stdDumpBrowser_); - //The document becomes the owner of the highlighter + // The document becomes the owner of the highlighter new DocHighlighter(stdDumpBrowser_->editor()->document(), "gribStdDump"); connect(stdGroup_, SIGNAL(buttonClicked(QAbstractButton*)), @@ -345,7 +347,7 @@ // Wmo dump //-------------------------------- - w = new QWidget(this); + w = new QWidget(this); auto* wmoDumpLayout = new QVBoxLayout(w); wmoDumpLayout->setContentsMargins(0, 2, 0, 0); wmoDumpLayout->setSpacing(0); @@ -353,8 +355,8 @@ Q_ASSERT(static_cast(WmoTabIndex) == dumpTab_->count() - 1); dumpTab_->tabBar()->setTabData(dumpTab_->count() - 1, "wmo"); - //wp = new MvQPanel(this); - wp = new QWidget(this); + // wp = new MvQPanel(this); + wp = new QWidget(this); auto* wmoControlLayout = new QHBoxLayout(wp); wmoControlLayout->setContentsMargins(2, 2, 0, 2); wmoDumpLayout->addWidget(wp); @@ -375,11 +377,11 @@ wmoControlLayout->addWidget(wmoTextTb); wmoControlLayout->addStretch(1); - //Stacked + // Stacked wmoDumpStacked_ = new QStackedWidget(this); wmoDumpLayout->addWidget(wmoDumpStacked_); - wmoDumpTree_ = new MvQTreeView(this, true); + wmoDumpTree_ = new MvQTreeView(this, true); wmoDumpModel_ = new MvQGribWmoDumpModel(this); wmoDumpTree_->setModel(wmoDumpModel_); wmoDumpTree_->setObjectName("wmoDumpTree"); @@ -394,7 +396,7 @@ wmoDumpBrowser_->editor()->setReadOnly(true); wmoDumpStacked_->addWidget(wmoDumpBrowser_); - //The document becomes the owner of the highlighter + // The document becomes the owner of the highlighter new DocHighlighter(wmoDumpBrowser_->editor()->document(), "gribWmoDump"); connect(wmoGroup_, SIGNAL(buttonClicked(QAbstractButton*)), @@ -406,7 +408,7 @@ // Table dump //-------------------------------- - w = new QWidget; + w = new QWidget; auto vb = new QVBoxLayout(w); vb->setContentsMargins(0, 0, 0, 0); vb->setSpacing(0); @@ -425,7 +427,7 @@ // Value dump //-------------------------------- - w = new QWidget(this); + w = new QWidget(this); auto* valueDumpLayout = new QVBoxLayout(w); valueDumpLayout->setContentsMargins(0, 2, 0, 0); valueDumpLayout->setSpacing(0); @@ -433,33 +435,38 @@ Q_ASSERT(static_cast(ValueTabIndex) == dumpTab_->count() - 1); dumpTab_->tabBar()->setTabData(dumpTab_->count() - 1, "value"); - //wp = new MvQPanel(this); - wp = new QWidget(this); + // wp = new MvQPanel(this); + wp = new QWidget(this); auto* valueControlLayout = new QHBoxLayout(wp); valueControlLayout->setContentsMargins(2, 2, 0, 2); valueDumpLayout->addWidget(wp); - //Spin box for index selection - auto* spinLabel = new QLabel(tr(" Go to row:"), wp); - //spinLabel->setProperty("panelStyle", "2"); + // Spin box for index selection + valueRowLabel_ = new QLabel(tr(" Go to row:"), wp); + // spinLabel->setProperty("panelStyle", "2"); valueRowSpin_ = new QSpinBox(this); - spinLabel->setBuddy(valueRowSpin_); - //QHBoxLayout* valueSpinLayout = new QHBoxLayout; - valueControlLayout->addWidget(spinLabel); + valueRowLabel_->setBuddy(valueRowSpin_); + // QHBoxLayout* valueSpinLayout = new QHBoxLayout; + valueControlLayout->addWidget(valueRowLabel_); valueControlLayout->addWidget(valueRowSpin_); valueDumpLabel_ = new QLabel(wp); - //valueDumpLabel_->setProperty("panelStyle", "2"); + // valueDumpLabel_->setProperty("panelStyle", "2"); valueControlLayout->addWidget(valueDumpLabel_); valueControlLayout->addStretch(1); - //valueDumpLayout->addLayout(valueSpinLayout); + valueDumpMessageLabel_ = new MessageLabel(this); + valueDumpMessageLabel_->setShowTypeTitle(false); + valueDumpLayout->addWidget(valueDumpMessageLabel_); + valueDumpMessageLabel_->hide(); + + // valueDumpLayout->addLayout(valueSpinLayout); // Signals and slots connect(valueRowSpin_, SIGNAL(valueChanged(int)), this, SLOT(slotValueRowSpinChanged(int))); - valueDumpModel_ = new MvQGribValueDumpModel(this); + valueDumpModel_ = new MvQGribValueDumpModel(this); valueDumpSortModel_ = new QSortFilterProxyModel; valueDumpSortModel_->setSourceModel(valueDumpModel_); valueDumpSortModel_->setDynamicSortFilter(true); @@ -476,7 +483,7 @@ valueDumpTree_->setUniformRowHeights(true); valueDumpTree_->setActvatedByKeyNavigation(true); - valueDumpLayout->addWidget(valueDumpTree_); + valueDumpLayout->addWidget(valueDumpTree_, 1); connect(valueDumpTree_, SIGNAL(clicked(QModelIndex)), this, SLOT(slotSelectValueRow(QModelIndex))); @@ -484,7 +491,7 @@ connect(valueDumpTree_, SIGNAL(activated(const QModelIndex&)), this, SLOT(slotSelectValueRow(const QModelIndex&))); - //dumpStacked_->addWidget(w); + // dumpStacked_->addWidget(w); //---------------------------------------- @@ -497,33 +504,33 @@ connect(dumpTab_, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentDumpChanged(int))); - dumpTab_->setCurrentIndex(0); //Default is namespace dump + dumpTab_->setCurrentIndex(0); // Default is namespace dump - //Init ns combo + // Init ns combo nsCombo_->setCurrentIndex(0); connect(nsCombo_, SIGNAL(currentTextChanged(const QString&)), this, SLOT(slotSetGribNameSpace(const QString&))); - nsCombo_->setCurrentIndex(2); //Default is namesapce "ls" + nsCombo_->setCurrentIndex(2); // Default is namesapce "ls" - //Adjust ns tree columns + // Adjust ns tree columns mvDumpTree_->setColumnWidth(0, MvQ::textWidth(fm, "geography.latitudeOfFirstGridPoint")); mvDumpTree_->setColumnWidth(1, MvQ::textWidth(fm, "Key type ")); stdGroup_->button(0)->setChecked(true); - //Adjust std tree columns + // Adjust std tree columns stdDumpTree_->setColumnWidth(0, MvQ::textWidth(fm, "latitudeOfFirstGridPointIndegrees")); stdDumpTree_->setColumnWidth(1, MvQ::textWidth(fm, "-180.0000000")); wmoGroup_->button(0)->setChecked(true); - //Adjust wmo tree columns + // Adjust wmo tree columns wmoDumpTree_->setColumnWidth(0, MvQ::textWidth(fm, "Section 5 23-23 ")); wmoDumpTree_->setColumnWidth(1, MvQ::textWidth(fm, "latitudeOfFirstGridPointIndegrees")); - //Adjust value tree columns + // Adjust value tree columns valueDumpTree_->setColumnWidth(0, MvQ::textWidth(fm, "10000000 ")); valueDumpTree_->setColumnWidth(1, MvQ::textWidth(fm, "Latitude ")); valueDumpTree_->setColumnWidth(1, MvQ::textWidth(fm, "Longitude ")); @@ -546,21 +553,21 @@ StatusMsgHandler::instance()->show("Message: " + QString::number(msgCnt + 1), true); - //StatusMsgHandler::instance()->show("Load message: " + QString::number(msgCnt+1)); + // StatusMsgHandler::instance()->show("Load message: " + QString::number(msgCnt+1)); currentMsg_ = msgCnt; - //At this point the first message scan has finished so we know the real message - //number. It is not known at the beginning because for multi message fields - //grib_count_in_file that we use to estimate the message number does not - //count the sub messages. So we need to updeate the file info label now. + // At this point the first message scan has finished so we know the real message + // number. It is not known at the beginning because for multi message fields + // grib_count_in_file that we use to estimate the message number does not + // count the sub messages. So we need to updeate the file info label now. if (fileInfoLabelNeedsUpdating_) { - //updateFileInfoLabel(); + // updateFileInfoLabel(); fileInfoLabelNeedsUpdating_ = false; } - //Save expand states in the trees + // Save expand states in the trees if (wmoDumpModel_->hasData()) wmoExpand_->save(); @@ -578,13 +585,13 @@ messageCanBeDecoded_ = true; - mvDumpLoaded_ = false; - wmoDumpLoaded_ = false; - stdDumpLoaded_ = false; + mvDumpLoaded_ = false; + wmoDumpLoaded_ = false; + stdDumpLoaded_ = false; tableDumpLoaded_ = false; valueDumpLoaded_ = false; - //Generate and read grib dumps + // Generate and read grib dumps switch (dumpTab_->currentIndex()) { case NamespaceTabIndex: loadMvDump(); @@ -626,7 +633,7 @@ auto* dump = new GribMvDump(); if (dump->read(data_->fileName(), data_->unfilteredMessageCnt(currentMsg_))) { - //the model takes ownership of the dump + // the model takes ownership of the dump mvDumpModel_->setDumpData(dump); StatusMsgHandler::instance()->done(); } @@ -743,7 +750,7 @@ s += "ecCodes used the following tables to decode the current message:
"; s += "

WMO tables

"; s += "
  Paths:
    "; - for (auto p : masterDir) { + for (const auto& p : masterDir) { s += "
  • " + QString::fromStdString(p) + "
  • "; } s += "
"; @@ -753,7 +760,7 @@ if (!localDir.empty()) { s += "

Local tables

"; s += "
  Paths:
    "; - for (auto p : localDir) { + for (const auto& p : localDir) { s += "
  • " + QString::fromStdString(p) + "
  • "; } s += "
"; @@ -787,35 +794,43 @@ StatusMsgHandler::instance()->task("Loading value dump"); - //Generate and read grib dump - int num = 0; + // Generate and read grib dump auto* dump = new GribValueDump(); - if (dump->read(data_->fileName(), data_->unfilteredMessageCnt(currentMsg_))) { + std::string errMsg, warnMsg; + if (dump->read(data_->fileName(), data_->unfilteredMessageCnt(currentMsg_), errMsg, warnMsg)) { + valueDumpMessageLabel_->hide(); valueDumpModel_->setDumpData(dump); - num = dump->num(); + int num = dump->num(); StatusMsgHandler::instance()->done(); + valueRowSpin_->setEnabled(true); + if (num > 0) { + valueRowSpin_->setRange(1, num); + } + else { + valueRowSpin_->setRange(0, 0); + } + QString info = " (Number of points: " + QString::number(num) + ")"; + valueDumpLabel_->setText(info); + valueRowLabel_->show(); + valueRowSpin_->show(); + valueDumpLabel_->show(); } else { delete dump; valueDumpModel_->clear(); StatusMsgHandler::instance()->failed(); + valueRowLabel_->hide(); + valueRowSpin_->hide(); + valueDumpLabel_->hide(); + if (!warnMsg.empty()) { + valueDumpMessageLabel_->showWarning(QString::fromStdString(warnMsg)); + } + else { + valueDumpMessageLabel_->showError(QString::fromStdString(errMsg)); + } } - // Set min/max values for spinbox - if (num > 0) - valueRowSpin_->setRange(1, num); - else - valueRowSpin_->setRange(0, 0); - - //Update info - QString info = " (Number of points: " + QString::number(num) + ")"; - //info+=" Average: " + QString::number(dump->average()); - //info+=" Stdev: " + QString::number(dump->stdev()); - //info+=" Skewness: " + QString::number(dump->skewness()); - //info+=" Kurtosis: " + QString::number(dump->kurtosis()); - - valueDumpLabel_->setText(info); - + // Update info valueDumpLoaded_ = true; } @@ -827,6 +842,11 @@ valueDumpModel_->clear(); valueDumpLabel_->clear(); valueDumpLoaded_ = false; + valueRowLabel_->show(); + valueRowSpin_->show(); + valueDumpLabel_->show(); + valueDumpMessageLabel_->clear(); + valueDumpMessageLabel_->hide(); } void MvQGribDumpPanel::slotStdGroupClicked(QAbstractButton*) @@ -848,7 +868,7 @@ if (!data_) return; - //Generate and read grib dumps + // Generate and read grib dumps switch (dumpTab_->currentIndex()) { case NamespaceTabIndex: loadMvDump(); @@ -984,18 +1004,18 @@ #endif setWindowTitle(winTitleBase_); - //Initial size + // Initial size setInitialSize(1100, 800); - //Init + // Init messageType_ = "GRIB"; - //gribNameSpace_ << "Default" << "geography" << "ls" << "mars" + // gribNameSpace_ << "Default" << "geography" << "ls" << "mars" // << "parameter" << "statistics" << "time" << "vertical"; fileInfoLabelNeedsUpdating_ = true; - //ignoreValueRowSpinChangeSignal_=false; + // ignoreValueRowSpinChangeSignal_=false; mainPanel_ = new MvQGribMainPanel(this); centralSplitter_->addWidget(mainPanel_); @@ -1009,9 +1029,9 @@ connect(mainPanel_, SIGNAL(messageNumDetermined()), this, SLOT(updateFileInfoLabel())); - //Set up panel - //setupGotoPanel(); - //setupDumpPanel(); + // Set up panel + // setupGotoPanel(); + // setupDumpPanel(); //---------------------------- // Setup menus and toolbars @@ -1035,7 +1055,7 @@ void GribExaminer::initMain(MvMessageMetaData* data) { Q_ASSERT(mainPanel_); - auto* grib = static_cast(data); + auto* grib = dynamic_cast(data); mainPanel_->init(grib); } @@ -1045,12 +1065,12 @@ void GribExaminer::initAllKeys() { - //Get all keys + // Get all keys auto* prof = new MvKeyProfile("Metview keys"); prof->addKey(new MvKey("MV_Index", "Index", "Message index")); allKeys_ << prof; - //GribMetaData *grib=static_cast(data_); + // GribMetaData *grib=static_cast(data_); QStringList gribNameSpace; gribNameSpace << "Default" @@ -1063,12 +1083,12 @@ << "vertical"; Q_ASSERT(data_); - auto* gd = static_cast(data_); + auto* gd = dynamic_cast(data_); Q_ASSERT(gd); foreach (QString ns, gribNameSpace) { QString pname = "Namespace: " + ns; - auto* prof = new MvKeyProfile(pname.toStdString()); + auto* prof = new MvKeyProfile(pname.toStdString()); gd->getKeyList(1, ns.toStdString().c_str(), prof); allKeys_ << prof; } @@ -1082,7 +1102,8 @@ data_->setFileName(f.toStdString()); currentMessageNo_ = -1; - //Reload + // Reload + mainPanel_->clear(); mainPanel_->reloadData(); updateFileInfoLabel(); @@ -1114,7 +1135,7 @@ void GribExaminer::updateFileInfoLabel() { - auto* grib = static_cast(data_); + auto* grib = dynamic_cast(data_); fileInfoLabel_->setGribTextLabel(QString(data_->fileName().c_str()), data_->totalMessageNum(), data_->isFilterEnabled(), data_->messageNum(), grib->hasMultiMessage()); diff -Nru metview-5.17.4/metview/src/GribExaminer/GribExaminer.h metview-5.19.2/metview/src/GribExaminer/GribExaminer.h --- metview-5.17.4/metview/src/GribExaminer/GribExaminer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GribExaminer/GribExaminer.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,14 +34,15 @@ class MvQTreeView; class MvQTreeViewSearchLine; class GribMetaData; +class MessageLabel; class PlainTextWidget; class MvQGribDumpPanel : public QWidget { Q_OBJECT public: - MvQGribDumpPanel(QWidget* parent = 0); - ~MvQGribDumpPanel(); + MvQGribDumpPanel(QWidget* parent = nullptr); + ~MvQGribDumpPanel() override; void init(GribMetaData* data); void loadDumps(int msgCnt); @@ -75,13 +76,13 @@ enum DumpTabIndex { NamespaceTabIndex = 0, - StdTabIndex = 1, - WmoTabIndex = 2, - TableTabIndex = 3, + StdTabIndex = 1, + WmoTabIndex = 2, + TableTabIndex = 3, ValueTabIndex }; - int currentMsg_; //starts at 0 + int currentMsg_; // starts at 0 GribMetaData* data_; bool messageCanBeDecoded_{true}; @@ -117,8 +118,10 @@ QTextEdit* tableTe_; bool tableDumpLoaded_{false}; + QLabel* valueRowLabel_; QSpinBox* valueRowSpin_; QLabel* valueDumpLabel_; + MessageLabel* valueDumpMessageLabel_; MvQTreeView* valueDumpTree_; MvQGribValueDumpModel* valueDumpModel_; QSortFilterProxyModel* valueDumpSortModel_; @@ -164,23 +167,23 @@ Q_OBJECT public: - GribExaminer(QWidget* parent = 0); - ~GribExaminer(); + GribExaminer(QWidget* parent = nullptr); + ~GribExaminer() override; protected slots: - void slotShowAboutBox(); - void slotLoadFile(QString); - void updateFileInfoLabel(); + void slotShowAboutBox() override; + void slotLoadFile(QString) override; + void updateFileInfoLabel() override; protected: - MvKeyProfile* loadedKeyProfile() const; + MvKeyProfile* loadedKeyProfile() const override; private: - void initMain(MvMessageMetaData* data); - void initDumps(); - void initAllKeys(); + void initMain(MvMessageMetaData* data) override; + void initDumps() override; + void initAllKeys() override; - void loadKeyProfile(MvKeyProfile*); + void loadKeyProfile(MvKeyProfile*) override; void settatusMessage(QString); diff -Nru metview-5.17.4/metview/src/GribExaminer/MvMain.cc metview-5.19.2/metview/src/GribExaminer/MvMain.cc --- metview-5.17.4/metview/src/GribExaminer/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GribExaminer/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ exit(1); } - //Get grib file name + // Get grib file name std::string fgrib; if (const char* tmpc = in("PATH")) { fgrib = std::string(tmpc); @@ -49,16 +49,16 @@ exit(1); } - //Filter + // Filter const char* temporary = (const char*)in("TEMPORARY"); - //const char *offset=in("TEMPORARY"); + // const char *offset=in("TEMPORARY"); - //Reading the offset values following the techique - // used in function "_request_to_fieldset" in field.c in MARS + // Reading the offset values following the techique + // used in function "_request_to_fieldset" in field.c in MARS int cnt = in.countValues("OFFSET"); std::vector offset; for (int i = 0; i < cnt; i++) { - const char* cval; + const char* cval = nullptr; in.getValue(cval, "OFFSET", i); #ifdef LARGE_FILES_SUPPORT offset.push_back(atoll(cval)); @@ -70,22 +70,22 @@ cnt = in.countValues("LENGTH"); std::vector len; for (int i = 0; i < cnt; i++) { - int ival; + int ival = 0; in.getValue(ival, "LENGTH", i); len.push_back(ival); } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("GribExaminer"); MvQApplication app(argc, argv, appName.c_str(), {"examiner", "keyDialog", "window", "find"}); DocHighlighter::init(); - //Create the grib key manager and initialize it + // Create the grib key manager and initialize it auto* manager = new MvQKeyManager(MvQKeyManager::GribType); manager->loadProfiles(); - //Create the grib metadata object and initialize it + // Create the grib metadata object and initialize it auto* grib = new GribMetaData; grib->setFileName(fgrib); @@ -94,12 +94,12 @@ grib->setFilter(offset, len); } - //Create the grib browser and initialize it + // Create the grib browser and initialize it auto* browser = new GribExaminer(); browser->setAppIcon("GRIB"); - browser->init(grib, manager, 0); + browser->init(grib, manager, nullptr); browser->show(); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/GribExaminer/MvQGribDumpModel.cc metview-5.19.2/metview/src/GribExaminer/MvQGribDumpModel.cc --- metview-5.17.4/metview/src/GribExaminer/MvQGribDumpModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GribExaminer/MvQGribDumpModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ //===================================== // -//MvQGribMvDumpModel +// MvQGribMvDumpModel // //===================================== @@ -48,7 +48,7 @@ data_ = dump; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -58,7 +58,7 @@ gribNameSpace_ = ns; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -68,7 +68,7 @@ filter_ = txt; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -82,7 +82,7 @@ if (!data_) return 0; - //Non-root + // Non-root if (!parent.isValid()) { return data_->itemNum(); } @@ -93,15 +93,15 @@ { if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::UserRole)) { - return QVariant(); + return {}; } if (role == Qt::UserRole) { if (index.column() != 0) - return QVariant(); + return {}; GribItem* item = data_->item().at(index.row()); - QString name = QString::fromStdString(item->name()); + QString name = QString::fromStdString(item->name()); if (gribNameSpace_ == "Default") { if (!filter_.isEmpty() && !name.contains(filter_, Qt::CaseInsensitive)) return QString::number(0); @@ -145,7 +145,7 @@ case StrValueColumn: return "String value"; default: - return QVariant(); + return {}; } } else if (role == Qt::ToolTipRole) { @@ -159,11 +159,11 @@ case StrValueColumn: return "Value accessed as string"; default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } @@ -180,7 +180,8 @@ auto v = item->value(); if (v.type() == MvVariant::LongType) { return QString::number(v.toLong()); - } else if (v.type() == MvVariant::DoubleType) { + } + else if (v.type() == MvVariant::DoubleType) { return QString::number(v.toDouble()); } return QString::fromStdString(v.toString()); @@ -189,18 +190,18 @@ return QString::fromStdString(item->strValue()); } default: - return QString(); + return {}; } } QModelIndex MvQGribMvDumpModel::index(int row, int column, const QModelIndex& /*parent*/) const { - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } QModelIndex MvQGribMvDumpModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } Qt::ItemFlags MvQGribMvDumpModel::flags(const QModelIndex& /*index*/) const @@ -234,7 +235,7 @@ if (index.isValid() && procRows.indexOf(index.row()) == -1) { GribItem* item = data_->item().at(index.row()); - auto* key = new MvKey(item->name(), item->name()); + auto* key = new MvKey(item->name(), item->name()); mimeData->addKey(key, index.row()); procRows << index.row(); } @@ -280,7 +281,7 @@ data_ = dump; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -294,7 +295,7 @@ if (!hasData()) return 0; - //Non-root + // Non-root if (parent.isValid()) { int id = parent.internalId(); if (idToLevel(id) == 0) { @@ -302,8 +303,8 @@ } if (idToLevel(id) == 1) { int parentRow = idToParentRow(id); - int row = parent.row(); - int num = data_->section().at(parentRow)->item().at(row)->arrayData().size(); + int row = parent.row(); + int num = data_->section().at(parentRow)->item().at(row)->arrayData().size(); return num; } @@ -311,7 +312,7 @@ return 0; } } - //Root + // Root else { return data_->sectionNum(); } @@ -321,7 +322,7 @@ QVariant MvQGribWmoDumpModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::ToolTipRole)) { - return QVariant(); + return {}; } int id = index.internalId(); @@ -333,19 +334,19 @@ return label(section, index.column()); } else if (level == 1) { - int parentRow = idToParentRow(id); + int parentRow = idToParentRow(id); GribSection* section = data_->section().at(parentRow); - GribItem* item = section->item().at(index.row()); + GribItem* item = section->item().at(index.row()); return label(item, index.column()); } else if (level == 2) { - //int parentId=index.parent().internalId(); - //int grandParentRow=idToParentRow(parentId); + // int parentId=index.parent().internalId(); + // int grandParentRow=idToParentRow(parentId); - int grandParentRow = idToGrandParentRow(id); + int grandParentRow = idToGrandParentRow(id); GribSection* section = data_->section().at(grandParentRow); - int parentRow = idToParentRow(id); + int parentRow = idToParentRow(id); GribItem* item = section->item().at(parentRow); QString value(item->arrayData().at(index.row()).c_str()); @@ -353,7 +354,7 @@ return label(value, index.column()); } - return QVariant(); + return {}; } @@ -371,7 +372,7 @@ case ValueColumn: return "Value"; default: - return QVariant(); + return {}; } } else if (role == Qt::ToolTipRole) { @@ -383,11 +384,11 @@ case ValueColumn: return "Key value"; default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } @@ -400,22 +401,23 @@ { switch (column) { case PositionColum: { - return QString(item->pos().c_str()); + return {item->pos().c_str()}; } case KeyColumn: { - return QString(item->name().c_str()); + return {item->name().c_str()}; } case ValueColumn: { auto v = item->value(); if (v.type() == MvVariant::LongType) { return QString::number(v.toLong()); - } else if (v.type() == MvVariant::DoubleType) { + } + else if (v.type() == MvVariant::DoubleType) { return QString::number(v.toDouble()); } return QString::fromStdString(v.toString()); } default: - return QString(); + return {}; } } @@ -427,13 +429,13 @@ QModelIndex MvQGribWmoDumpModel::index(int row, int column, const QModelIndex& parent) const { if (!data_ || row < 0 || column < 0 || parent.column() > 3) { - return QModelIndex(); + return {}; } - //Parent is non-root -> level-1 items: id is the parent row (number+1)*1000 + // Parent is non-root -> level-1 items: id is the parent row (number+1)*1000 if (parent.isValid()) { - int id; - int parentId = parent.internalId(); + int id = 0; + int parentId = parent.internalId(); int parentLevel = idToLevel(parentId); if (parentLevel == 0) { @@ -443,12 +445,12 @@ id = parentId + (parent.row() + 1); } else { - return QModelIndex(); + return {}; } return createIndex(row, column, id); } - //Parent is root -> level-0 items: id is the row number + // Parent is root -> level-0 items: id is the row number else { return createIndex(row, column, row); } @@ -457,24 +459,24 @@ QModelIndex MvQGribWmoDumpModel::parent(const QModelIndex& index) const { if (!index.isValid()) { - return QModelIndex(); + return {}; } int id = index.internalId(); if (idToLevel(id) == 0) { - return QModelIndex(); + return {}; } else if (idToLevel(id) == 1) { int parentRow = idToParentRow(id); return createIndex(parentRow, 0, parentRow); } else if (idToLevel(id) == 2) { - int parentRow = idToParentRow(id); + int parentRow = idToParentRow(id); int grandParentRow = idToGrandParentRow(id); return createIndex(parentRow, 0, (grandParentRow + 1) * 1000); } - return QModelIndex(); + return {}; } int MvQGribWmoDumpModel::idToLevel(int id) const @@ -505,9 +507,7 @@ { int level = idToLevel(id); - if (level == 0) - return -1; - else if (level == 1) + if (level == 0 || level == 1) return -1; else if (level == 2) return id / 1000 - 1; @@ -546,11 +546,11 @@ int id = index.internalId(); if (index.isValid() && idToLevel(id) == 1 && procRows.indexOf(index.row()) == -1) { - //Index to the second column!!! + // Index to the second column!!! QModelIndex col = createIndex(index.row(), 1, id); std::string keyName = data(col).toString().toStdString(); - auto* key = new MvKey(keyName, keyName); + auto* key = new MvKey(keyName, keyName); mimeData->addKey(key, index.row()); procRows << index.row(); } @@ -610,7 +610,7 @@ if (!hasData()) return 0; - //Non-root + // Non-root if (parent.isValid()) { int id = parent.internalId(); if (idToLevel(id) == 0) { @@ -620,7 +620,7 @@ return 0; } } - //Root + // Root else { return data_->itemNum(); } @@ -630,10 +630,10 @@ QVariant MvQGribStdDumpModel::data(const QModelIndex& index, int role) const { if (!hasData()) - return QVariant(); + return {}; if (!index.isValid() || role != Qt::DisplayRole) { - return QVariant(); + return {}; } int id = index.internalId(); @@ -642,13 +642,13 @@ return label(item, index.column()); } else if (idToLevel(id) == 1) { - int parentRow = idToParentRow(id); - GribItem* item = data_->item().at(parentRow); + int parentRow = idToParentRow(id); + GribItem* item = data_->item().at(parentRow); std::string value = item->arrayData().at(index.row()); return label(value, index.column()); } - return QVariant(); + return {}; } @@ -666,7 +666,7 @@ case DescColumn: return "Description"; default: - return QVariant(); + return {}; } } else if (role == Qt::ToolTipRole) { @@ -678,10 +678,10 @@ case DescColumn: return "Key description"; default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } @@ -689,23 +689,24 @@ { switch (column) { case KeyColum: { - return QString(item->name().c_str()); + return {item->name().c_str()}; } case ValueColumn: { auto v = item->value(); if (v.type() == MvVariant::LongType) { return QString::number(v.toLong()); - } else if (v.type() == MvVariant::DoubleType) { + } + else if (v.type() == MvVariant::DoubleType) { return QString::number(v.toDouble()); } return QString::fromStdString(v.toString()); } case DescColumn: { - return QString(item->description().c_str()); + return {item->description().c_str()}; } default: - return QString(); + return {}; } } @@ -717,15 +718,15 @@ QModelIndex MvQGribStdDumpModel::index(int row, int column, const QModelIndex& parent) const { if (!data_ || row < 0 || column < 0 || parent.column() > 3) { - return QModelIndex(); + return {}; } - //Parent is non-root -> level-1 items: id is the (parent row number +1)*1000 + // Parent is non-root -> level-1 items: id is the (parent row number +1)*1000 if (parent.isValid()) { int id = (parent.row() + 1) * 1000; return createIndex(row, column, id); } - //Parent is root -> level-0 items: id is the row number + // Parent is root -> level-0 items: id is the row number else { return createIndex(row, column, row); } @@ -734,19 +735,19 @@ QModelIndex MvQGribStdDumpModel::parent(const QModelIndex& index) const { if (!index.isValid()) { - return QModelIndex(); + return {}; } int id = index.internalId(); if (idToLevel(id) == 0) { - return QModelIndex(); + return {}; } else { int parentRow = idToParentRow(id); return createIndex(parentRow, 0, parentRow); } - return QModelIndex(); + return {}; } int MvQGribStdDumpModel::idToLevel(int id) const @@ -799,7 +800,7 @@ if (index.isValid() && idToLevel(id) == 0 && procRows.indexOf(index.row()) == -1) { std::string keyName = data(index).toString().toStdString(); - auto* key = new MvKey(keyName, keyName); + auto* key = new MvKey(keyName, keyName); mimeData->addKey(key, index.row()); procRows << index.row(); } @@ -817,7 +818,7 @@ //===================================== // -//MvQGribValueDumpModel +// MvQGribValueDumpModel // //===================================== @@ -855,7 +856,7 @@ } } - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -869,7 +870,7 @@ if (!data_) return 0; - //Non-root + // Non-root if (!parent.isValid()) { return data_->num(); } @@ -882,7 +883,7 @@ QVariant MvQGribValueDumpModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::UserRole)) { - return QVariant(); + return {}; } if (role == Qt::DisplayRole) { @@ -902,11 +903,11 @@ } break; default: - return QVariant(); + return {}; } } - //Will be used for sorting + // Will be used for sorting else if (role == Qt::UserRole) { switch (index.column()) { case 0: @@ -918,12 +919,12 @@ case 3: return data_->value()[index.row()]; default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } @@ -943,19 +944,19 @@ case 3: return tr("Value"); default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } QModelIndex MvQGribValueDumpModel::index(int row, int column, const QModelIndex& /*parent*/) const { - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } QModelIndex MvQGribValueDumpModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } diff -Nru metview-5.17.4/metview/src/GribExaminer/MvQGribDumpModel.h metview-5.19.2/metview/src/GribExaminer/MvQGribDumpModel.h --- metview-5.17.4/metview/src/GribExaminer/MvQGribDumpModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GribExaminer/MvQGribDumpModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ { public: using QAbstractItemModel::QAbstractItemModel; - ~MvQGribMvDumpModel(); + ~MvQGribMvDumpModel() override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; @@ -50,7 +50,13 @@ const QModelIndex& parent) override; private: - enum Column {KeyColum=0, TypeColumn=1, ValueColumn=2, StrValueColumn=3}; + enum Column + { + KeyColum = 0, + TypeColumn = 1, + ValueColumn = 2, + StrValueColumn = 3 + }; QString label(GribItem*, const int) const; GribMvDump* data_{nullptr}; QString gribNameSpace_; @@ -61,7 +67,7 @@ { public: using QAbstractItemModel::QAbstractItemModel; - ~MvQGribWmoDumpModel(); + ~MvQGribWmoDumpModel() override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; @@ -92,7 +98,12 @@ int idToLevel(int) const; int idToParentRow(int) const; int idToGrandParentRow(int) const; - enum Column {PositionColum=0, KeyColumn=1, ValueColumn=2}; + enum Column + { + PositionColum = 0, + KeyColumn = 1, + ValueColumn = 2 + }; GribWmoDump* data_{nullptr}; }; @@ -101,7 +112,7 @@ { public: using QAbstractItemModel::QAbstractItemModel; - ~MvQGribStdDumpModel(); + ~MvQGribStdDumpModel() override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; @@ -130,7 +141,12 @@ QString label(std::string, const int) const; int idToLevel(int) const; int idToParentRow(int) const; - enum Column {KeyColum=0, ValueColumn=1, DescColumn=2}; + enum Column + { + KeyColum = 0, + ValueColumn = 1, + DescColumn = 2 + }; GribStdDump* data_{nullptr}; }; @@ -139,7 +155,7 @@ { public: using QAbstractItemModel::QAbstractItemModel; - ~MvQGribValueDumpModel(); + ~MvQGribValueDumpModel() override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; diff -Nru metview-5.17.4/metview/src/GribVectors/Vectors.cc metview-5.19.2/metview/src/GribVectors/Vectors.cc --- metview-5.17.4/metview/src/GribVectors/Vectors.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/GribVectors/Vectors.cc 2023-07-15 08:28:47.000000000 +0000 @@ -63,10 +63,10 @@ // Get the colouring field data, if it exists const char* strDim = nColourFields ? "3" : "2"; - MvField f_t = iter_t(); + MvField f_t = iter_t(); // Main loop - //Concatenate the field requests in triples: u[i]/v[i]/t[i] + // Concatenate the field requests in triples: u[i]/v[i]/t[i] out.setVerb("GRIB_VECTORS"); MvFieldSet fs_out; MvField f_u, f_v; @@ -86,9 +86,9 @@ } out("GRIB_WIND_MODE") = polar ? "SD" : "UV"; - out("GRIB") = fs_out.getRequest(); - out("_CLASS") = "GRIB_VECTORS"; - out("_VERB") = "GRIB_VECTORS"; + out("GRIB") = fs_out.getRequest(); + out("_CLASS") = "GRIB_VECTORS"; + out("_VERB") = "GRIB_VECTORS"; std::cout << "GribVectors::serve out" << std::endl; out.print(); diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovArea.cc metview-5.19.2/metview/src/Hovmoeller/HovArea.cc --- metview-5.17.4/metview/src/Hovmoeller/HovArea.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovArea.cc 2023-07-15 08:28:47.000000000 +0000 @@ -8,14 +8,11 @@ ***************************** LICENSE END *************************************/ #include +#include #include "HovArea.h" #include "MvException.h" - -HovAreaToolkit::HovAreaToolkit() : - geoDir_(HOV_EW) -{ -} +//#include "StatsCompute.h" const char* HovAreaToolkit::GetSecondCoordName() { @@ -27,10 +24,11 @@ bool HovAreaToolkit::ComputeSecondCoord() { - double x, y; - int i; + double x = 0., y = 0.; + int i = 0; + coord1_.clear(); - if (geoDir_ == HOV_EW) //average E->W + if (geoDir_ == HOV_EW) // average E->W { for (i = 0, y = y1_; y >= y2_;) { // do not add within the loop becuase of cumulative errors @@ -39,7 +37,7 @@ y = y1_ - (i * gridNS_); } } - else //average N->S + else // average N->S { for (i = 0, x = x1_; x <= x2_;) { // do not add within the loop becuase of cumulative errors @@ -50,7 +48,7 @@ } // Initialise number of points - this->NPoints(coord1_.size()); + this->NPoints(static_cast(coord1_.size())); return true; } @@ -59,21 +57,24 @@ { MvFieldExpander x(field); - // Average over area - // 1) AverageAlong() does not know array size. If it fails then returned array + // Compute statistics over area + // 1) computeAlong() does not know array size. If it fails then returned array // remains empty. Thus, fill with missing values here. - // 2) AverageAlong() assumes that the AREA definition follows the MARS convention - // N-S/W-E. Therefore, if average direction is EW then the computed values follow - // the order N-S, e.g. xint_[0] = average(N), ..., xint_[nrPoints_] = average(S) + // 2) computeAlong() assumes that the AREA definition follows the MARS convention + // N-S/W-E. Therefore, if the direction is EW then the computed values follow + // the order N-S, e.g. xint_[0] = computed(N), ..., xint_[nrPoints_] = computed(S) // and gcoord1_[0] = N], ..., gcoord1_[nrPoints_] = S. // 3) gridNS_ or gridEW_ have the same value - bool interp = false; //set bilinear interpolation - if (!field.averageAlong(xint_, x1_, y1_, x2_, y2_, geoDir_, nrPoints_, gridNS_, interp)) { - for (int i = 0; i < nrPoints_; i++) - xint_[i] = DBL_MAX; + bool interp = false; // set bilinear interpolation - throw MvException("Hovmoeller-> Failed to compute area average"); + StatsComputePtr comp = makeStatsCompute(); + assert(comp); + if (!field.computeAlong(xint_, x1_, y1_, x2_, y2_, geoDir_, nrPoints_, gridNS_, interp, nullptr, comp)) { + for (int i = 0; i < nrPoints_; i++) { + xint_[i] = DBL_MAX; + } + throw MvException(moduleLabel_ + "Failed to compute statistics for area"); } return true; @@ -95,7 +96,7 @@ (y2_ < 0) ? -y2_ : y2_, (y2_ < 0) ? "S" : "N"); } - return std::string(title); + return {title}; } bool HovAreaToolkit::GetInputInfo(MvRequest& in) @@ -110,14 +111,14 @@ // bool swap = false; if (x1_ > x2_) { double W = x1_; - x1_ = x2_; - x2_ = W; + x1_ = x2_; + x2_ = W; // swap = true; } if (y2_ > y1_) { double W = y1_; - y1_ = y2_; - y2_ = W; + y1_ = y2_; + y2_ = W; // swap = true; } @@ -126,7 +127,12 @@ // setError(0,"Input geographical coordinates do not follow MARS rules (n/w/s/e). Values have been swapped."); // Get direction - geoDir_ = ((const char*)in("AVERAGE_DIRECTION") && strcmp(in("AVERAGE_DIRECTION"), "NORTH_SOUTH") == 0) ? HOV_NS : HOV_EW; + if (const char* ch = (const char*)in("AVERAGE_DIRECTION")) { + geoDir_ = (strcmp(ch, "NORTH_SOUTH") == 0) ? HOV_NS : HOV_EW; + } + else { + throw MvException(moduleLabel_ + "No AVERAGE_DIRECTION parameter specified"); + } // Get swap axes flag swapAxes_ = ((const char*)in("SWAP_AXES") && strcmp(in("SWAP_AXES"), "YES") == 0) ? true : false; @@ -141,6 +147,8 @@ gridNS_ = in("RESOLUTION"); gridEW_ = in("RESOLUTION"); + stats_ = statsType(in); + return true; } @@ -157,9 +165,19 @@ geoDir_ = (strcmp(cp, "NORTH_SOUTH") == 0) ? HOV_NS : HOV_EW; // Retrieve swap axes flag, if exists - cp = (const char*)req("swap_axes"); + cp = (const char*)req("swap_axes"); swapAxes_ = (cp == nullptr) ? false : atoi(cp); + // Retrieve stats value + const char* statCh = (const char*)req("area_statistics"); + if (statCh == nullptr) { + /// can be an old file! + stats_ = MeanStats; + } + else { + stats_ = statsType(statCh); + } + // Get common information from the netCDF file // This command needs the geoDir_ info if (!GetInputCommonInfo(netcdf)) @@ -170,13 +188,16 @@ void HovAreaToolkit::NcWriteGlobalAttributesApp() { - // Add average direction + // Add direction const char* adir = (geoDir_ == HOV_NS) ? "NORTH_SOUTH" : "EAST_WEST"; netcdf_->addAttribute("average_direction", adir); // Add swap axes flag - if (swapAxes_) + if (swapAxes_) { netcdf_->addAttribute("swap_axes", swapAxes_); + } + + netcdf_->addAttribute("area_statistics", statsName(stats_).c_str()); } bool HovAreaToolkit::NcWriteSecondCoord() @@ -193,59 +214,26 @@ } else { ncx->addAttribute("long_name", "latitude"); - ncx->addAttribute("units", "degrees_north"); //or degrees_south? + ncx->addAttribute("units", "degrees_north"); // or degrees_south? } return true; } -bool HovAreaToolkit::consistencyCheck(MvRequest& req1, MvRequest& req2) +bool HovAreaToolkit::consistencyCheck(MvRequest& viewReq, MvRequest& dataReq) { - // Check input TYPE - if ((const char*)req1("TYPE") != (const char*)req2.getVerb()) { - std::ostringstream oss; - oss << "Hovmoeller-> TYPE parameter has two different values: " - << (const char*)req1("TYPE") - << " and " - << (const char*)req2.getVerb(); - throw MvException(oss.str()); - } - - // Check coordinates - if ((double)req1("AREA", 0) != (double)req2("AREA", 0) || - (double)req1("AREA", 1) != (double)req2("AREA", 1) || - (double)req1("AREA", 2) != (double)req2("AREA", 2) || - (double)req1("AREA", 3) != (double)req2("AREA", 3)) - throw MvException("Hovmoeller-> AREA coordinates are not consistent"); - - // Check DIRECTION - if ((const char*)req1("AVERAGE_DIRECTION") != (const char*)req2("AVERAGE_DIRECTION")) { - std::ostringstream oss; - oss << "Hovmoeller-> AVERAGE_DIRECTION parameter is not consistent: " - << (const char*)req1("AVERAGE_DIRECTION") - << " and " - << (const char*)req2("AVERAGE_DIRECTION"); - throw MvException(oss.str()); - } - - // Check SWAP AXES - if ((const char*)req1("SWAP_AXES") != (const char*)req2("SWAP_AXES")) { - std::ostringstream oss; - oss << "Hovmoeller-> SWAP_AXES parameter is not consistent: " - << (const char*)req1("SWAP_AXES") - << " and " - << (const char*)req2("SWAP_AXES"); - throw MvException(oss.str()); - } - - // Check RESOLUTION - if ((const char*)req1("RESOLUTION") != (const char*)req2("RESOLUTION")) { - std::ostringstream oss; - oss << "Hovmoeller-> RESOLUTION parameter is not consistent: " - << (const char*)req1("RESOLUTION") - << " and " - << (const char*)req2("RESOLUTION"); - throw MvException(oss.str()); + std::string msg; + std::string label1 = "view"; + std::string label2 = "data"; + + if (!MvRequest::paramEqualToVerb(viewReq, dataReq, "TYPE", label1, label2, msg)) { + throw MvException(moduleLabel_ + msg); + } + + for (auto name : {"AREA", "AREA_STATISTICS", "AVERAGE_DIRECTION", "SWAP_AXES", "RESOLUTION"}) { + if (!MvRequest::paramsEqual(viewReq, dataReq, name, label1, label2, msg)) { + throw MvException(moduleLabel_ + msg); + } } return true; @@ -267,8 +255,8 @@ if ((const char*)origReq_("RESOLUTION")) viewReq("RESOLUTION") = (const char*)origReq_("RESOLUTION"); - viewReq("_CLASS") = "MHOVMOELLERVIEW"; - viewReq("_DEFAULT") = 1; + viewReq("_CLASS") = "MHOVMOELLERVIEW"; + viewReq("_DEFAULT") = 1; viewReq("_DATAATTACHED") = "YES"; return viewReq; diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovArea.h metview-5.19.2/metview/src/Hovmoeller/HovArea.h --- metview-5.17.4/metview/src/Hovmoeller/HovArea.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovArea.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,35 +15,35 @@ class HovAreaToolkit : public HovToolkit { public: - HovAreaToolkit(); - ~HovAreaToolkit() = default; + using HovToolkit::HovToolkit; + ~HovAreaToolkit() override = default; // Common functions - std::string GetTitle(ParamInfo*); - const char* GetSecondCoordName(); - bool SecondAuxiliaryCoord() { return false; } - const char* ApplicationType() { return "AREA_HOVM"; } - bool NcWriteSecondCoord(); - void NcWriteGlobalAttributesApp(); + std::string GetTitle(ParamInfo*) override; + const char* GetSecondCoordName() override; + bool SecondAuxiliaryCoord() override { return false; } + const char* ApplicationType() override { return "AREA_HOVM"; } + bool NcWriteSecondCoord() override; + void NcWriteGlobalAttributesApp() override; // Calculate diagram values - bool ComputeValues(MvField&, int = 0); + bool ComputeValues(MvField&, int = 0) override; // Compute coordinates - bool ComputeSecondCoord(); + bool ComputeSecondCoord() override; // Initialize variables - bool GetInputInfo(MvRequest&); //from user interface - bool GetInputInfo(MvNetCDF*); //from the netCDF file + bool GetInputInfo(MvRequest&) override; // from user interface + bool GetInputInfo(MvNetCDF*) override; // from the netCDF file // Check if parameters between two requests are consistent - bool consistencyCheck(MvRequest&, MvRequest&); + bool consistencyCheck(MvRequest& vieReq, MvRequest& dataReq) override; private: // Create View request - MvRequest CreateViewRequest(); + MvRequest CreateViewRequest() override; - int geoDir_; // average direction: East-West or North-South + int geoDir_{HOV_EW}; }; //--------------------------------------------------------------------- @@ -56,10 +56,10 @@ AreaHovmoeller(const char* kw) : Hovmoeller(kw) {} - ~AreaHovmoeller() = default; + ~AreaHovmoeller() override = default; // Entry point - void serve(MvRequest& in, MvRequest& out); + void serve(MvRequest& in, MvRequest& out) override; }; static SimpleObjectMaker area("AREA_HOVM"); @@ -71,8 +71,8 @@ public: AreaHovmoellerM3() : AreaHovmoeller("AREA_HOV") {} - ~AreaHovmoellerM3() = default; + ~AreaHovmoellerM3() override = default; // Entry point - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovExpand.cc metview-5.19.2/metview/src/Hovmoeller/HovExpand.cc --- metview-5.17.4/metview/src/Hovmoeller/HovExpand.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovExpand.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,7 +42,7 @@ bool ExpandHovmoeller::GetInputInfo(MvRequest& in, std::string& netfnameIn, MvRequest& dataRequestIn, std::string& hovTypeIn) { // Get netcdf information from UI - if ((const char*)in("NETCDF_PATH") && (strcmp((const char*)in("NETCDF_PATH"), "OFF") && strcmp((const char*)in("NETCDF_PATH"), "off"))) + if ((const char*)in("NETCDF_PATH") != nullptr && strcmp((const char*)in("NETCDF_PATH"), "OFF") != 0 && strcmp((const char*)in("NETCDF_PATH"), "off") != 0) netfnameIn = (const char*)in("NETCDF_PATH"); else { // Get information from the icon @@ -57,7 +57,7 @@ // Get fieldset information from UI std::string str; - if ((const char*)in("DATA_PATH") && (strcmp((const char*)in("DATA_PATH"), "OFF") && strcmp((const char*)in("DATA_PATH"), "off"))) { + if ((const char*)in("DATA_PATH") != nullptr && strcmp((const char*)in("DATA_PATH"), "OFF") != 0 && strcmp((const char*)in("DATA_PATH"), "off") != 0) { str = (const char*)in("DATA_PATH"); dataRequestIn.setVerb("GRIB"); dataRequestIn("PATH") = str.c_str(); diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovExpand.h metview-5.19.2/metview/src/Hovmoeller/HovExpand.h --- metview-5.17.4/metview/src/Hovmoeller/HovExpand.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovExpand.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,10 +17,10 @@ // Constructor/destructor ExpandHovmoeller() : Hovmoeller("EXPAND_HOVM") {} - ~ExpandHovmoeller() = default; + ~ExpandHovmoeller() override = default; // Main function - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; // Initialize variables from user interface bool GetInputInfo(MvRequest&, std::string&, MvRequest&, std::string&); diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovHeight.cc metview-5.19.2/metview/src/Hovmoeller/HovHeight.cc --- metview-5.17.4/metview/src/Hovmoeller/HovHeight.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovHeight.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,16 +16,21 @@ #include "MvException.h" #include "MvLog.h" -#include +#include "StatsCompute.h" +#include #define HOV_SP 1013.25 // stardard pressure std::map HovHeightToolkit::vertAxisTypeNames_ = { {HovHeightToolkit::AsInDataLevelType, "AS_IN_DATA"}, {HovHeightToolkit::PressureLevelType, "PRESSURE"}, - {HovHeightToolkit::ParamLevelType, "USER"} -}; + {HovHeightToolkit::ParamLevelType, "USER"}}; + +std::map HovHeightToolkit::inputModeNames_ = { + {HovHeightToolkit::AreaInputMode, "AREA"}, + {HovHeightToolkit::NearestGrpInputMode, "NEAREST_GRIDPOINT"}, + {HovHeightToolkit::PointInputMode, "POINT"}}; struct VerticalDataMatrix { @@ -38,8 +43,9 @@ class VerticalDataItem { friend class LevelInterpolator; + public: - VerticalDataItem(int levelNum=0); + VerticalDataItem(int levelNum = 0); void addOneLevel(); double interpolate(int level1, int level2, double targetYCoord) const; double extrapolateTop(double targetYCoord, LevelInterpolator* inter) const; @@ -55,33 +61,37 @@ class LevelInterpolator { -public: - enum ExtrapolateMode {ConstantExtrapolation, LinearExtrapolation}; - - int levelNum() const {return static_cast(levels_.size());} - int stepNum() const {return static_cast(steps_.size());} - bool isEmpty() const {return steps_.size() == 0;} - void clear() {levels_.clear(); steps_.clear();} - bool hasKey(const std::string& key) const {return steps_.find(key) != steps_.end();} +public: + enum ExtrapolateMode + { + ConstantExtrapolation, + LinearExtrapolation + }; + + int levelNum() const { return static_cast(levels_.size()); } + int stepNum() const { return static_cast(steps_.size()); } + bool isEmpty() const { return steps_.size() == 0; } + void clear(); + bool hasKey(const std::string& key) const { return steps_.find(key) != steps_.end(); } double lnsp(const std::string& key) const; void setLnsp(const std::string& key, double val); void setVCoord(const std::string& key, int level, double val); void setValue(const std::string& key, int level, double val); void interpolate(VerticalDataMatrix&); - void setTopLevel(double v) {topLevel_ = v;} - void setBottomLevel(double v) {bottomLevel_ = v;} - double bottomLevel() const {return bottomLevel_;} - double topLevel() const {return topLevel_;} - bool extrapolate() const {return extrapolate_;} - void setExtrapolate(double v) {extrapolate_ = v;} - ExtrapolateMode extrapolateMode() const {return extrapolateMode_;} - void setExtrapolateMode(ExtrapolateMode m) {extrapolateMode_ = m;} - bool extrapolateFixedSign() const {return extrapolateFixedSign_;} - void setExtrapolateFixedSign(bool b) {extrapolateFixedSign_=b;} - void setUseFixedLnsp(bool b) {useFixedLnsp_=b;} - bool useFixedLnsp() const {return useFixedLnsp_;} - void setFixedLnsp(float v) {fixedLnsp_ = v;} - float fixedLnsp() const {return fixedLnsp_;} + void setTopLevel(double v) { topLevel_ = v; } + void setBottomLevel(double v) { bottomLevel_ = v; } + double bottomLevel() const { return bottomLevel_; } + double topLevel() const { return topLevel_; } + bool extrapolate() const { return extrapolate_; } + void setExtrapolate(bool v) { extrapolate_ = v; } + ExtrapolateMode extrapolateMode() const { return extrapolateMode_; } + void setExtrapolateMode(ExtrapolateMode m) { extrapolateMode_ = m; } + bool extrapolateFixedSign() const { return extrapolateFixedSign_; } + void setExtrapolateFixedSign(bool b) { extrapolateFixedSign_ = b; } + void setUseFixedLnsp(bool b) { useFixedLnsp_ = b; } + bool useFixedLnsp() const { return useFixedLnsp_; } + void setFixedLnsp(float v) { fixedLnsp_ = v; } + float fixedLnsp() const { return fixedLnsp_; } protected: int indexOfLevel(int level) const; @@ -109,7 +119,7 @@ { if (levelNum >= 1) { yCoord_ = std::vector(levelNum, mars.grib_missing_value); - val_ = std::vector(levelNum, mars.grib_missing_value); + val_ = std::vector(levelNum, mars.grib_missing_value); } } @@ -122,15 +132,15 @@ double VerticalDataItem::interpolate(int level1, int level2, double targetYCoord) const { if (!MISSING_VALUE(val_[level1]) && !MISSING_VALUE(val_[level2])) { - double alpha = (targetYCoord - yCoord_[level1])/(yCoord_[level2] - yCoord_[level1]); - return alpha * val_[level2] + (1.- alpha) * val_[level1]; + double alpha = (targetYCoord - yCoord_[level1]) / (yCoord_[level2] - yCoord_[level1]); + return alpha * val_[level2] + (1. - alpha) * val_[level1]; } return HMISSING_VALUE; } double VerticalDataItem::extrapolateTop(double targetYCoord, LevelInterpolator* inter) const { - return extrapolate(targetYCoord, yCoord_.size()-1, yCoord_.size()-2, inter); + return extrapolate(targetYCoord, yCoord_.size() - 1, yCoord_.size() - 2, inter); #if 0 assert(yCoord_.size() == val_.size()); int level = yCoord_.size()-1; @@ -180,23 +190,24 @@ double VerticalDataItem::extrapolate(double targetYCoord, int level1, int level2, LevelInterpolator* inter) const { - assert(yCoord_.size() == val_.size()); - if (yCoord_.size() >= 2) { - if (inter->extrapolateMode() == LevelInterpolator::ConstantExtrapolation) { - return MISSING_VALUE(val_[level1])?HMISSING_VALUE:val_[level1]; - } else if (!MISSING_VALUE(val_[level1]) && !MISSING_VALUE(val_[level2])) { - double alpha = (targetYCoord - yCoord_[level2])/(yCoord_[level1] - yCoord_[level2]); - double rv = alpha * val_[level1] + (1.- alpha) * val_[level2]; - if (inter->extrapolateFixedSign()) { - assert(inter->extrapolateMode() == LevelInterpolator::LinearExtrapolation); - if (val_[level1]*rv <= 0) { - rv = 0.; - } - } - return rv; - } - } - return MISSING_VALUE(val_[level1])?HMISSING_VALUE:val_[level1]; + assert(yCoord_.size() == val_.size()); + if (yCoord_.size() >= 2) { + if (inter->extrapolateMode() == LevelInterpolator::ConstantExtrapolation) { + return MISSING_VALUE(val_[level1]) ? HMISSING_VALUE : val_[level1]; + } + else if (!MISSING_VALUE(val_[level1]) && !MISSING_VALUE(val_[level2])) { + double alpha = (targetYCoord - yCoord_[level2]) / (yCoord_[level1] - yCoord_[level2]); + double rv = alpha * val_[level1] + (1. - alpha) * val_[level2]; + if (inter->extrapolateFixedSign()) { + assert(inter->extrapolateMode() == LevelInterpolator::LinearExtrapolation); + if (val_[level1] * rv <= 0) { + rv = 0.; + } + } + return rv; + } + } + return MISSING_VALUE(val_[level1]) ? HMISSING_VALUE : val_[level1]; } //=========================================== @@ -205,10 +216,23 @@ // //=========================================== +void LevelInterpolator::clear() +{ + topLevel_ = 0.01; + bottomLevel_ = 1100.; + extrapolate_ = false; + extrapolateMode_ = ConstantExtrapolation; + extrapolateFixedSign_ = true; + levels_.clear(); + steps_.clear(); + useFixedLnsp_ = false; + fixedLnsp_ = 1013.25; +} + int LevelInterpolator::indexOfLevel(int level) const { auto it = std::find(levels_.begin(), levels_.end(), level); - return (it != levels_.end())?(it-levels_.begin()):-1; + return (it != levels_.end()) ? (it - levels_.begin()) : -1; } VerticalDataItem* LevelInterpolator::getStep(const std::string& key, bool addIfMissing) const @@ -216,12 +240,13 @@ auto it = steps_.find(key); if (it == steps_.end()) { if (addIfMissing) { - steps_[key] = VerticalDataItem(levelNum()); + steps_[key] = VerticalDataItem(levelNum()); it = steps_.find(key); if (useFixedLnsp_) { steps_[key].lnsp_ = fixedLnsp_; } - } else { + } + else { return nullptr; } } @@ -231,7 +256,7 @@ double LevelInterpolator::lnsp(const std::string& key) const { auto item = getStep(key, false); - return (item)?item->lnsp_:-1.; + return (item) ? item->lnsp_ : -1.; } void LevelInterpolator::setLnsp(const std::string& key, double val) @@ -245,8 +270,8 @@ auto levIdx = indexOfLevel(level); if (levIdx == -1) { levels_.push_back(level); - levIdx = levelNum()-1; - for (auto &it: steps_) { + levIdx = levelNum() - 1; + for (auto& it : steps_) { it.second.addOneLevel(); } } @@ -262,8 +287,8 @@ auto levIdx = indexOfLevel(level); if (levIdx == -1) { levels_.push_back(level); - levIdx = levelNum()-1; - for (auto &it: steps_) { + levIdx = levelNum() - 1; + for (auto& it : steps_) { it.second.addOneLevel(); } } @@ -274,7 +299,7 @@ step->val_[levIdx] = val; } -void LevelInterpolator::interpolate(VerticalDataMatrix &dm) +void LevelInterpolator::interpolate(VerticalDataMatrix& dm) { if (isEmpty()) return; @@ -284,57 +309,58 @@ // determine target levels by taking the vertical coordinate average on each // input level std::vector> sData; - for (std::size_t idx=0; idx < levels_.size(); idx++) { + for (std::size_t idx = 0; idx < levels_.size(); idx++) { double yAvg = 0.; int validNum = 0; - for (auto it: steps_) { + for (const auto& it : steps_) { auto y = it.second.yCoord_[idx]; if (!MISSING_VALUE(y)) { - yAvg +=y; + yAvg += y; validNum++; } } if (validNum > 0) { yAvg /= validNum; - sData.push_back(std::make_pair(idx, yAvg)); + sData.emplace_back(idx, yAvg); } } // sort target levels from bottom to top std::stable_sort(sData.begin(), sData.end(), - [targetAscending](const auto& v1,const auto& v2) {return (targetAscending)?(v2.second > v1.second):(v1.second > v2.second);}); + [targetAscending](const auto& v1, const auto& v2) { return (targetAscending) ? (v2.second > v1.second) : (v1.second > v2.second); }); std::vector srcLevIdx; - for (auto v: sData) { + for (auto v : sData) { srcLevIdx.push_back(v.first); } // select only target levels in the bottomLevel_/topLevel_ range. The levels right below and above // the range are also added - int startIdx=-1, endIdx=-1; + int startIdx = -1, endIdx = -1; double minLevel = std::min(bottomLevel_, topLevel_); double maxLevel = std::max(bottomLevel_, topLevel_); - for(std::size_t i=0; i < sData.size(); i++) { + for (std::size_t i = 0; i < sData.size(); i++) { if (sData[i].second >= minLevel && sData[i].second <= maxLevel) { if (startIdx == -1) { - startIdx=i; + startIdx = i; } - endIdx = i+1; + endIdx = i + 1; } } if (startIdx >= endIdx) { MvException("No vertical coordinates found within the specified range: [" + - std::to_string(minLevel) +"," + std::to_string(maxLevel) + "]"); - } else { + std::to_string(minLevel) + "," + std::to_string(maxLevel) + "]"); + } + else { assert(startIdx != -1); assert(endIdx != -1); if (startIdx > 0) { startIdx--; } - if (endIdx >= static_cast(sData.size()-1)) { - endIdx = static_cast(sData.size()-1); + if (endIdx >= static_cast(sData.size() - 1)) { + endIdx = static_cast(sData.size() - 1); } - for(int i=startIdx; i <= endIdx; i++) { + for (int i = startIdx; i <= endIdx; i++) { dm.yCoord_.push_back(sData[i].second); } } @@ -348,7 +374,7 @@ dm.yCoord_.insert(dm.yCoord_.begin(), bottomLevel_); extraBottom = 1; } - if ((targetAscending && topLevel_ > dm.yCoord_.back())|| + if ((targetAscending && topLevel_ > dm.yCoord_.back()) || (!targetAscending && topLevel_ < dm.yCoord_.back())) { dm.yCoord_.push_back(topLevel_); extraTop = 1; @@ -357,34 +383,37 @@ // interpolate + extrapolate values int targetLevNum = dm.yCoord_.size(); - for (auto it: steps_) { + for (const auto& it : steps_) { auto key = it.first; - auto *item = &(it.second); + auto* item = &(it.second); dm.val_[key] = std::vector(targetLevNum, HMISSING_VALUE); // interpolation - for (int targetIdx=extraBottom; targetIdx < targetLevNum-extraTop; targetIdx++) { + for (int targetIdx = extraBottom; targetIdx < targetLevNum - extraTop; targetIdx++) { auto targetYCoord = dm.yCoord_[targetIdx]; int lev1 = -1; int lev2 = -1; - for (auto srcIdx: srcLevIdx) { - if (srcIdx >=0 && !MISSING_VALUE(item->val_[srcIdx])) { + for (auto srcIdx : srcLevIdx) { + if (srcIdx >= 0 && !MISSING_VALUE(item->val_[srcIdx])) { if ((targetAscending && item->yCoord_[srcIdx] < targetYCoord) || (!targetAscending && item->yCoord_[srcIdx] > targetYCoord)) { - lev1 = srcIdx; - } else if ((targetAscending && item->yCoord_[srcIdx] >= targetYCoord) || - (!targetAscending &&item->yCoord_[srcIdx] <= targetYCoord)) { - lev2 = srcIdx; - break; + lev1 = srcIdx; + } + else if ((targetAscending && item->yCoord_[srcIdx] >= targetYCoord) || + (!targetAscending && item->yCoord_[srcIdx] <= targetYCoord)) { + lev2 = srcIdx; + break; } } } - if (lev1 >=0 && lev2 >=0 && abs(lev1-lev2) < 4) { + if (lev1 >= 0 && lev2 >= 0 && abs(lev1 - lev2) < 4) { dm.val_[key][targetIdx] = item->interpolate(lev1, lev2, targetYCoord); - } else if(lev1 >= 0 && lev2 == -1) { + } + else if (lev1 >= 0 && lev2 == -1) { dm.val_[key][targetIdx] = item->val_[lev1]; - } else if(lev2 >= 0 && lev1 == -1) { + } + else if (lev2 >= 0 && lev1 == -1) { dm.val_[key][targetIdx] = item->val_[lev2]; } } @@ -395,7 +424,7 @@ dm.val_[key][dmIndex] = item->extrapolateBottom(bottomLevel_, this); } if (extraTop == 1) { - int dmIndex = targetLevNum-1; + int dmIndex = targetLevNum - 1; dm.val_[key][dmIndex] = item->extrapolateTop(topLevel_, this); } } @@ -420,8 +449,8 @@ void HovHeightToolkit::GenerateKey(std::string& str, MvRequest& rq) { // The level value is ignored to build the key - int par = rq("PARAM"); - int level = 0; + int par = rq("PARAM"); + int level = 0; const char* expver = rq("EXPVER"); std::ostringstream oss; @@ -446,54 +475,64 @@ } if (inputLevelType_ == "ml" && outputLevelType_ == "pl") { - if(!levHandler_->useFixedLnsp() && levHandler_->isEmpty()) { + if (!levHandler_->useFixedLnsp() && levHandler_->isEmpty()) { throw MvException(moduleLabel_ + - "No lnsp data was found! Cannot interpolate input model level data for pressure levels!"); + "No lnsp data was found! Cannot interpolate input model level data for pressure levels!"); } - } else if(vertAxisType_ != ParamLevelType && inputLevelType_ != outputLevelType_) { + } + else if (vertAxisType_ != ParamLevelType && inputLevelType_ != outputLevelType_) { throw MvException(moduleLabel_ + "Input (=" + inputLevelType_ + - ") and output (=" + outputLevelType_ + - ") level types must be the same with the current settings!"); + ") and output (=" + outputLevelType_ + + ") level types must be the same with the current settings!"); } } // Conversion from model level to pressure level is needed if (inputLevelType_ == "ml" && outputLevelType_ == "pl") { int ml = static_cast(ilevel); - if(levHandler_->useFixedLnsp()) { + if (levHandler_->useFixedLnsp()) { auto p = field.meanML_to_Pressure_byLNSP(levHandler_->fixedLnsp(), ml) / 100.; - levHandler_->setVCoord(timeKey, ml-1, p); - levHandler_->setValue(timeKey, ml-1, computeValue(field)); - } else { + levHandler_->setVCoord(timeKey, ml - 1, p); + levHandler_->setValue(timeKey, ml - 1, computeValue(field)); + } + else { assert(!levHandler_->isEmpty()); if (levHandler_->hasKey(timeKey)) { auto lnsp = levHandler_->lnsp(timeKey); if (!MISSING_VALUE(lnsp)) { // compute pressue in hPa auto p = field.meanML_to_Pressure_byLNSP(lnsp, ml) / 100.; - levHandler_->setVCoord(timeKey, ml-1, p); - levHandler_->setValue(timeKey, ml-1, computeValue(field)); + levHandler_->setVCoord(timeKey, ml - 1, p); + levHandler_->setValue(timeKey, ml - 1, computeValue(field)); } - } else { - throw MvException(moduleLabel_ + "Invalid date/time in input data!"); + } + else { + std::string msg("Trying to convert from model levels to pressure levels " + "but cannot find lnsp field for time step "); + msg += TimeKeyToUserString(timeKey); + throw MvException(moduleLabel_ + msg); } } - } else if (vertAxisType_ == ParamLevelType) { -// assert(!mlevInter_->isEmpty()); + } + else if (vertAxisType_ == ParamLevelType) { + // assert(!mlevInter_->isEmpty()); int lev = static_cast(ilevel); -// if (mlevInter_->hasKey(timeKey)) { - if (1) { + // if (mlevInter_->hasKey(timeKey)) { + if (true) { auto param = static_cast(field.parameter()); if (param == vertCoordParamId_) { levHandler_->setVCoord(timeKey, lev, computeValue(field)); - } else { + } + else { levHandler_->setValue(timeKey, lev, computeValue(field)); } - } else { + } + else { throw MvException(moduleLabel_ + "Invalid date/time in input data!"); } - // Standard vertical coordinates - } else { + // Standard vertical coordinates + } + else { double level = ilevel; auto iter = std::find(coord1_.begin(), coord1_.end(), level); if (iter == coord1_.end()) @@ -504,10 +543,8 @@ // Called during the very first scan. bool HovHeightToolkit::collectLnsp(MvRequest& data) { - levHandler_->clear(); // model level input with pressure vertical axis if (vertAxisType_ == PressureLevelType) { - if (levHandler_->useFixedLnsp()) { return true; } @@ -529,7 +566,7 @@ hasMlData = field.isModelLevel(); } if (isParamLnsp(static_cast(field.parameter()))) { - MvRequest rq = field.getRequest(); + rq = field.getRequest(); GenerateKey(keystr, rq); GenerateTimeKey(timekey, rq); levHandler_->setLnsp(timekey, computeValue(field)); @@ -539,7 +576,8 @@ if (!hasMlData || levHandler_->stepNum() == 0) { levHandler_->clear(); return false; - } else { + } + else { return true; } } @@ -563,10 +601,14 @@ MvFieldExpander x(field); if (inputMode_ == PointInputMode) { return field.interpolateAt(x1_, y1_); - } else if (inputMode_ == NearestGrpInputMode) { + } + else if (inputMode_ == NearestGrpInputMode) { return field.nearestGridpoint(x1_, y1_, false); - } else if (inputMode_ == AreaInputMode) { - return field.integrate(y1_, x1_, y2_, x2_); + } + else if (inputMode_ == AreaInputMode) { + StatsComputePtr comp = makeStatsCompute(); + assert(comp); + return field.computeInArea(y1_, x1_, y2_, x2_, true, comp); } return mars.grib_missing_value; } @@ -579,12 +621,12 @@ bool HovHeightToolkit::GenerateData(MvRequest& data) { - MvLog().dbg() << MV_FN_INFO; -// for (auto v: lnsp_) { -// MvLog().dbg() << "key=" << v.first << " lnsp=" << v.second; -// MvLog().dbg() << "lnsp=" << v.second; -// } - + // MvLog().dbg() << MV_FN_INFO; + // MvLog().dbg() << "levelNum=" << levHandler_->levelNum() << " stepNum=" << levHandler_->stepNum(); + // for (auto v: lnsp_) { + // MvLog().dbg() << "key=" << v.first << " lnsp=" << v.second; + // MvLog().dbg() << "lnsp=" << v.second; + // } // Compute the vertical data matrix for model level data // interpoltated to a time-pressure grid (i.e. matrix) @@ -600,25 +642,27 @@ return false; // Allocate internal variables - if (xint_) - delete xint_; + if (xint_ != nullptr) { + delete[] xint_; + xint_ = nullptr; + } xint_ = new double[nrPoints_]; // Process the ML data already interpolated to pressure levels if (!levHandler_->isEmpty()) { // we assume there is only one param! - ParamInfo* par = nullptr; + ParamInfo* par = nullptr; std::string paramKey; - for(auto it: params_) { + for (const auto& it : params_) { paramKey = it.first; par = it.second; break; } if (par) { - for (auto it: vData.val_) { + for (auto it : vData.val_) { auto key = it.first; - for (std::size_t i=0; i < it.second.size(); i++) { - xint_[i] = (it.second)[i]; + for (std::size_t i = 0; i < it.second.size(); i++) { + xint_[i] = (it.second)[i]; } par->FillIndex(xint_, key, nrPoints_); @@ -626,11 +670,13 @@ if (!NcWriteData(paramKey)) { return false; } - } else { + } + else { return false; } - // native levels - } else { + // native levels + } + else { // Sort data by level, expver and param MvFieldSet fs(data); MvFieldSetIterator iter(fs); @@ -644,15 +690,14 @@ // Generate data int currentGenerated = 0, lastNrGenerated = -1; - int ind = 0; + int ind = 0; std::string sfirst = "FIRSTFIELD"; std::string timeKey, keystr; std::string lastTimeKey = sfirst; - std::string lastKey = sfirst; + std::string lastKey = sfirst; MvField field, lastField; ParamIterator paramIter; while ((field = iter())) { - // skip lnsp if (!levHandler_->isEmpty() && isParamLnsp(static_cast(field.parameter()))) { continue; @@ -697,10 +742,10 @@ lastNrGenerated = currentGenerated; } - lastKey = keystr; - lastField = field; + lastKey = keystr; + lastField = field; lastTimeKey = sfirst; - ind = 0; + ind = 0; } // Write out the data in the netcdf file @@ -725,50 +770,67 @@ (y2_ < 0) ? -y2_ : y2_, (y2_ < 0) ? "S" : "N", (x2_ < 0) ? -x2_ : x2_, (x2_ < 0) ? "W" : "E"); - return std::string(title); + return {title}; } bool HovHeightToolkit::GetInputInfo(MvRequest& in) -{ +{ + x1_ = 0.; + x2_ = 0.; + y1_ = 0.; + y2_ = 0.; + lnspParamId_ = 152; + vertAxisType_ = NoLevelType; + inputLevelType_.clear(); + outputLevelType_.clear(); + levHandler_->clear(); + // Input mode - if (const char* ch = in("INPUT_MODE")) { - if (strcmp(ch, "AREA") == 0) { - inputMode_ = AreaInputMode; - y1_ = in("AREA", 0); - x1_ = in("AREA", 1); - y2_ = in("AREA", 2); - x2_ = in("AREA", 3); + inputMode_ = NoInputMode; + if (const char* ch = in("INPUT_MODE")) { + auto imName = std::string(ch); + for (const auto& it : inputModeNames_) { + if (it.second == imName) { + inputMode_ = it.first; + break; + } + } + + if (inputMode_ == AreaInputMode) { + y1_ = in("AREA", 0); + x1_ = in("AREA", 1); + y2_ = in("AREA", 2); + x2_ = in("AREA", 3); // Make sure coordinates follow Mars rules (n/w/s/e) - // bool swap = false; if (x1_ > x2_) { std::swap(x1_, x2_); } if (y2_ > y1_) { std::swap(y1_, y2_); } - } else if (strcmp(ch, "POINT") == 0) { - inputMode_ = PointInputMode; - y1_ = in("POINT", 0); - x1_ = in("POINT", 1); - } else if (strcmp(ch, "NEAREST_GRIDPOINT") == 0) { - inputMode_ = NearestGrpInputMode; + stats_ = statsType(in); + } + else if (inputMode_ == PointInputMode || inputMode_ == NearestGrpInputMode) { y1_ = in("POINT", 0); x1_ = in("POINT", 1); - } else { - throw MvException(moduleLabel_ + "Invalid INPUT_MODE=" + std::string(ch)); } - } else { + else { + throw MvException(moduleLabel_ + "Invalid INPUT_MODE=" + imName); + } + } + else { throw MvException(moduleLabel_ + "No INPUT_MODE specified"); } - if ((const char*)in("LNSP_PARAM")) + if ((const char*)in("LNSP_PARAM")) { lnspParamId_ = (int)in("LNSP_PARAM"); + } // Get vertical axis type if (const char* ch = (const char*)in("VERTICAL_LEVEL_TYPE")) { std::string sch(ch); - for (auto it: vertAxisTypeNames_) { + for (const auto& it : vertAxisTypeNames_) { if (it.second == sch) { vertAxisType_ = it.first; break; @@ -781,7 +843,7 @@ } if ((const char*)in("VERTICAL_COORDINATE_PARAM")) { - vertCoordParamId_ = (int) in("VERTICAL_COORDINATE_PARAM"); + vertCoordParamId_ = (int)in("VERTICAL_COORDINATE_PARAM"); } if (vertAxisType_ == ParamLevelType && vertCoordParamId_ <= 0) { @@ -793,13 +855,13 @@ if (const char* ch = in("USE_FIXED_SURFACE_PRESSURE")) { levHandler_->setUseFixedLnsp((strcmp(ch, "ON") == 0)); if (levHandler_->useFixedLnsp()) { - if ((const char*)in("FIXED_SURFACE_PRESSURE")) { - auto sp = (double)in("FIXED_SURFACE_PRESSURE"); - if (sp <= 1E-5) { - throw MvException(moduleLabel_ + "invalid FIXED_SURFACE_PRESSURE specified!"); - } - levHandler_->setFixedLnsp(std::log(sp*100.)); - } + if ((const char*)in("FIXED_SURFACE_PRESSURE")) { + auto sp = (double)in("FIXED_SURFACE_PRESSURE"); + if (sp <= 1E-5) { + throw MvException(moduleLabel_ + "invalid FIXED_SURFACE_PRESSURE specified!"); + } + levHandler_->setFixedLnsp(std::log(sp * 100.)); + } } } @@ -807,7 +869,7 @@ verticalAxis_ = HOV_GEO; // Initialize x/y resolution ??? Do we need this ??? - gridEW_ = gridNS_ = 1; //in("RESOLUTION"); + gridEW_ = gridNS_ = 1; // in("RESOLUTION"); if ((const char*)in("BOTTOM_LEVEL")) { levHandler_->setBottomLevel((double)in("BOTTOM_LEVEL")); @@ -823,10 +885,10 @@ if (levHandler_->extrapolate()) { if (const char* ch = in("VERTICAL_COORDINATE_EXTRAPOLATE_MODE")) { - levHandler_->setExtrapolateMode((strcmp(ch, "CONSTANT") == 0)?LevelInterpolator::ConstantExtrapolation:LevelInterpolator::LinearExtrapolation); + levHandler_->setExtrapolateMode((strcmp(ch, "CONSTANT") == 0) ? LevelInterpolator::ConstantExtrapolation : LevelInterpolator::LinearExtrapolation); } if (const char* ch = in("VERTICAL_COORDINATE_EXTRAPOLATE_FIXED_SIGN")) { - levHandler_->setExtrapolateFixedSign((strcmp(ch, "ON") == 0)?true:false); + levHandler_->setExtrapolateFixedSign((strcmp(ch, "ON") == 0) ? true : false); } } @@ -842,11 +904,46 @@ // Retrieve attributes values MvRequest req = netcdf->getRequest(); + // input mode + if (const char* ch = (const char*)req("input_mode")) { + std::string sch(ch); + inputMode_ = NoInputMode; + for (const auto& it : inputModeNames_) { + if (it.second == sch) { + inputMode_ = it.first; + break; + } + } + + if (inputMode_ == AreaInputMode) { + // Retrieve stats value + const char* statCh = (const char*)req("area_statistics"); + // older files do not contain this attribute + if (statCh == nullptr) { + stats_ = MeanStats; + } + else { + stats_ = statsType(statCh); + } + } + else if (inputMode_ == NoInputMode) { + throw MvException(moduleLabel_ + + "Netcdf input file error: invalid input_mode=" + + std::string(ch) + " found!"); + } + } + else { + // we do not fail because older files do not have this attribute, but + // we use the default values + inputMode_ = AreaInputMode; + stats_ = MeanStats; + } + // Retrieve vertical type axes flag if (const char* ch = (const char*)req("vertical_type")) { std::string sch(ch); vertAxisType_ = NoLevelType; - for (auto it: vertAxisTypeNames_) { + for (const auto& it : vertAxisTypeNames_) { if (it.second == sch) { vertAxisType_ = it.first; break; @@ -857,7 +954,8 @@ "Netcdf input file error: invalid vertical_type=" + std::string(ch) + " found!"); } - } else { + } + else { throw MvException(moduleLabel_ + "Netcdf input file error: vertical_type attribute not found"); } @@ -869,10 +967,24 @@ void HovHeightToolkit::NcWriteGlobalAttributesApp() { + auto itIm = inputModeNames_.find(inputMode_); + if (itIm != inputModeNames_.end()) { + netcdf_->addAttribute("input_mode", itIm->second.c_str()); + } + else { + throw MvException(moduleLabel_ + + "Could not determine the value for input_mode NetCDF attribute!"); + } + + if (inputMode_ == AreaInputMode) { + netcdf_->addAttribute("area_statistics", statsName(stats_).c_str()); + } + auto it = vertAxisTypeNames_.find(vertAxisType_); if (it != vertAxisTypeNames_.end()) { netcdf_->addAttribute("vertical_type", it->second.c_str()); - } else { + } + else { throw MvException(moduleLabel_ + "Could not determine the value for vertical_type NetCDF attribute!"); } @@ -891,26 +1003,39 @@ return true; } -bool HovHeightToolkit::consistencyCheck(MvRequest& req1, MvRequest& req2) +bool HovHeightToolkit::consistencyCheck(MvRequest& viewReq, MvRequest& dataReq) { - // Check input TYPE - if ((const char*)req1("TYPE") != (const char*)req2.getVerb()) { - throw MvException(moduleLabel_ + "TYPE parameter is not consistent: " - + (const char*)req1("TYPE") + " does not equal " + (const char*)req2.getVerb()); + std::string msg; + std::string label1 = "view"; + std::string label2 = "data"; + if (!MvRequest::paramEqualToVerb(viewReq, dataReq, "TYPE", label1, label2, msg)) { + throw MvException(moduleLabel_ + msg); } - // Check coordinates - if ((double)req1("AREA", 0) != (double)req2("AREA", 0) || - (double)req1("AREA", 1) != (double)req2("AREA", 1) || - (double)req1("AREA", 2) != (double)req2("AREA", 2) || - (double)req1("AREA", 3) != (double)req2("AREA", 3)) - throw MvException(moduleLabel_ + "AREA coordinates are not consistent"); - - // Check VERTICAL_LEVEL_TYPE - if ((const char*)req1("VERTICAL_LEVEL_TYPE") != (const char*)req2("VERTICAL_LEVEL_TYPE")) { - throw MvException(moduleLabel_ + "VERTICAL_LEVEL_TYPE parameter is not consistent: " - + (const char*)req1("VERTICAL_LEVEL_TYPE") + " does not equal " + (const char*)req2("VERTICAL_LEVEL_TYPE")); + std::vector params = {"INPUT_MODE", "VERTICAL_LEVEL_TYPE"}; + for (const auto& name : params) { + if (!MvRequest::paramsEqual(viewReq, dataReq, name, label1, label2, msg)) { + throw MvException(moduleLabel_ + msg); + } + } + + params.clear(); + const char* ch = (const char*)viewReq("INPUT_MODE"); + assert(ch); + auto imStr = std::string(ch); + if (imStr == "AREA") { + params.emplace_back("AREA"); + params.emplace_back("AREA_STATISTICS"); + } + else { + params.emplace_back("POINT"); + } + + for (const auto& name : params) { + if (!MvRequest::paramsEqual(viewReq, dataReq, name, label1, label2, msg)) { + throw MvException(moduleLabel_ + msg); + } } return true; @@ -929,7 +1054,8 @@ auto it = vertAxisTypeNames_.find(vertAxisType_); if (it != vertAxisTypeNames_.end()) { viewReq("VERTICAL_LEVEL_TYPE") = it->second.c_str(); - } else { + } + else { throw MvException(moduleLabel_ + "Cannot build view request! Invalid VERTICAL_LEVEL_TYPE was found!"); } @@ -938,8 +1064,8 @@ viewReq("TOP_LEVEL") = levHandler_->topLevel(); viewReq("BOOTOM_LEVEL") = levHandler_->bottomLevel(); - viewReq("_CLASS") = "MHOVMOELLERVIEW"; - viewReq("_DEFAULT") = 1; + viewReq("_CLASS") = "MHOVMOELLERVIEW"; + viewReq("_DEFAULT") = 1; viewReq("_DATAATTACHED") = "YES"; return viewReq; diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovHeight.h metview-5.19.2/metview/src/Hovmoeller/HovHeight.h --- metview-5.17.4/metview/src/Hovmoeller/HovHeight.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovHeight.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ { public: HovHeightToolkit(); - ~HovHeightToolkit(); + ~HovHeightToolkit() override; // Common functions bool GenerateData(MvRequest&) override; @@ -31,7 +31,7 @@ // Functions to handle list of levels void InitializeLevelList() override { coord1_.clear(); } - void collectVerticalData(MvField&, const std::string&, double) override; + void collectVerticalData(MvField&, const std::string&, double) override; bool collectLnsp(MvRequest& data) override; // Calculate diagram values @@ -45,14 +45,20 @@ void GenerateKey(std::string&, MvRequest&) override; // Initialize variables - bool GetInputInfo(MvRequest&) override; //from user interface - bool GetInputInfo(MvNetCDF*) override; //from the netCDF file + bool GetInputInfo(MvRequest&) override; // from user interface + bool GetInputInfo(MvNetCDF*) override; // from the netCDF file // Check if parameters between two requests are consistent - bool consistencyCheck(MvRequest&, MvRequest&) override; + bool consistencyCheck(MvRequest& viewReq, MvRequest& dataReq) override; private: - enum VerticalLevelType {AsInDataLevelType,PressureLevelType,ParamLevelType,NoLevelType}; + enum VerticalLevelType + { + AsInDataLevelType, + PressureLevelType, + ParamLevelType, + NoLevelType + }; // Create View request MvRequest CreateViewRequest() override; @@ -62,8 +68,15 @@ LevelInterpolator* levHandler_{nullptr}; std::string inputLevelType_; std::string outputLevelType_; - enum InputMode {PointInputMode, NearestGrpInputMode, AreaInputMode}; - InputMode inputMode_{AreaInputMode}; + enum InputMode + { + NoInputMode, + PointInputMode, + NearestGrpInputMode, + AreaInputMode + }; + static std::map inputModeNames_; + InputMode inputMode_{NoInputMode}; }; //--------------------------------------------------------------------- @@ -76,10 +89,10 @@ HeightHovmoeller(const char* kw) : Hovmoeller(kw) {} - ~HeightHovmoeller() = default; + ~HeightHovmoeller() override = default; // Entry point - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; static SimpleObjectMaker height("VERTICAL_HOVM"); @@ -91,8 +104,8 @@ public: HeightHovmoellerM3() : HeightHovmoeller("HEIGHT_HOV") {} - ~HeightHovmoellerM3() = default; + ~HeightHovmoellerM3() override = default; // Entry point - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovLine.cc metview-5.19.2/metview/src/Hovmoeller/HovLine.cc --- metview-5.17.4/metview/src/Hovmoeller/HovLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -9,6 +9,7 @@ #include "HovLine.h" +#include #include #include @@ -91,14 +92,14 @@ double dellat = std::fabs(y2_ - y1_); double dellon = std::fabs(x2_ - x1_); - int np = int(sqrt(dellon * dellon + dellat * dellat) / MAX(gridNS_, gridEW_)); + int np = int(sqrt(dellon * dellon + dellat * dellat) / MAX(gridNS_, gridEW_)); if (np <= 0) { throw MvException(moduleLabel_ + "Computed number of points along the hovmoeller line is invalid: " + std::to_string(np) + ". Check the input data grid geometry."); } - nrPoints_ = MAX(np, 64); //64->arbitrary minimum number of points + nrPoints_ = MAX(np, 64); // 64->arbitrary minimum number of points return true; } @@ -134,7 +135,7 @@ // Retrieve swap axes flag, if exists const char* cp = (const char*)req("swap_axes"); - swapAxes_ = (cp == nullptr) ? false : atoi(cp); + swapAxes_ = (cp == nullptr) ? false : atoi(cp); return true; } @@ -158,56 +159,29 @@ // Add latitude coordinate to the netCDF file v_sdim[0] = HOV_VARLAT; - ncx = netcdf_->addVariable(v_sdim[0], ncDouble, v_ndim, v_sdim); + ncx = netcdf_->addVariable(v_sdim[0], ncDouble, v_ndim, v_sdim); ncx->addAttribute("long_name", "latitude"); - ncx->addAttribute("units", "degrees_north"); //or degrees_south? + ncx->addAttribute("units", "degrees_north"); // or degrees_south? ncx->put(coord2_, (long)nrPoints_); return true; } -bool HovLineToolkit::consistencyCheck(MvRequest& req1, MvRequest& req2) +bool HovLineToolkit::consistencyCheck(MvRequest& viewReq, MvRequest& dataReq) { - // Check input TYPE - const char* cType1 = (const char*)req1("TYPE"); - const char* verb2 = (const char*)req2.getVerb(); - if (strcmp(cType1, verb2) != 0) { - std::string msg = moduleLabel_ + "TYPE parameter is not consistent"; - if (cType1 && verb2) { - msg += ": " + std::string(cType1) + " != " + std::string(verb2); - } - throw MvException(msg); - } + std::string msg; + std::string label1 = "view"; + std::string label2 = "data"; - // Check coordinates - if ((double)req1("LINE", 0) != (double)req2("LINE", 0) || - (double)req1("LINE", 1) != (double)req2("LINE", 1) || - (double)req1("LINE", 2) != (double)req2("LINE", 2) || - (double)req1("LINE", 3) != (double)req2("LINE", 3)) - throw MvException(moduleLabel_ + "LINE coordinates are not consistent"); - - // Check SWAP AXES - const char* swapA1 = (const char*)req1("SWAP_AXES"); - const char* swapA2 =(const char*)req2("SWAP_AXES"); - if (strcmp(swapA1, swapA2) != 0) { - std::string msg = moduleLabel_ + "SWAP_AXES parameter is not consistent"; - if (swapA1 && swapA2) { - msg += ": " + std::string(swapA1) + " != " + std::string(swapA2); - } - throw MvException(msg); + if (!MvRequest::paramEqualToVerb(viewReq, dataReq, "TYPE", label1, label2, msg)) { + throw MvException(moduleLabel_ + msg); } - // Check RESOLUTION - const char* res1 = (const char*)req1("RESOLUTION"); - const char* res2 = (const char*)req2("RESOLUTION"); - if (strcmp(res1, res2) != 0) { - std::string msg = moduleLabel_ + "RESOLUTION parameter is not consistent"; - if (res1 && res2) { - msg += ": " + std::string(res1) + " != " + std::string(res2); + for (auto name : {"LINE", "SWAP_AXES", "RESOLUTION"}) { + if (!MvRequest::paramsEqual(viewReq, dataReq, name, label1, label2, msg)) { + throw MvException(moduleLabel_ + msg); } - throw MvException(msg); } - return true; } @@ -224,8 +198,8 @@ if ((const char*)origReq_("RESOLUTION")) viewReq("RESOLUTION") = (const char*)origReq_("RESOLUTION"); - viewReq("_CLASS") = "MHOVMOELLERVIEW"; - viewReq("_DEFAULT") = 1; + viewReq("_CLASS") = "MHOVMOELLERVIEW"; + viewReq("_DEFAULT") = 1; viewReq("_DATAATTACHED") = "YES"; return viewReq; diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovLine.h metview-5.19.2/metview/src/Hovmoeller/HovLine.h --- metview-5.17.4/metview/src/Hovmoeller/HovLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,33 +16,33 @@ { public: // Initialize variables - bool GetInputInfo(MvRequest&); //from user interface - bool GetInputInfo(MvNetCDF*); //from the netCDF file + bool GetInputInfo(MvRequest&) override; // from user interface + bool GetInputInfo(MvNetCDF*) override; // from the netCDF file // Common functions - std::string GetTitle(ParamInfo*); - const char* GetSecondCoordName(); - const char* GetSecondAuxiliaryCoordName(); - bool SecondAuxiliaryCoord() { return true; } - const char* ApplicationType() { return "LINE_HOVM"; } - bool NcWriteSecondCoord(); - void NcWriteGlobalAttributesApp(); + std::string GetTitle(ParamInfo*) override; + const char* GetSecondCoordName() override; + const char* GetSecondAuxiliaryCoordName() override; + bool SecondAuxiliaryCoord() override { return true; } + const char* ApplicationType() override { return "LINE_HOVM"; } + bool NcWriteSecondCoord() override; + void NcWriteGlobalAttributesApp() override; // Calculate diagram values - bool ComputeValues(MvField&, int = 0); + bool ComputeValues(MvField&, int = 0) override; // Compute coordinates - bool ComputeSecondCoord(); + bool ComputeSecondCoord() override; // Check if parameters between two requests are consistent - bool consistencyCheck(MvRequest&, MvRequest&); + bool consistencyCheck(MvRequest& viewReq, MvRequest& dataReq) override; private: // Compute number of points bool EvaluateNPoints(); // Create View request - MvRequest CreateViewRequest(); + MvRequest CreateViewRequest() override; }; //--------------------------------------------------------------------- @@ -55,10 +55,10 @@ LineHovmoeller(const char* kw) : Hovmoeller(kw) {} - ~LineHovmoeller() = default; + ~LineHovmoeller() override = default; // Entry point - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; static SimpleObjectMaker line("LINE_HOVM"); @@ -71,8 +71,8 @@ LineHovmoellerM3() : LineHovmoeller("LINE_HOV") {} - ~LineHovmoellerM3() = default; + ~LineHovmoellerM3() override = default; // Entry point - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; diff -Nru metview-5.17.4/metview/src/Hovmoeller/Hovmoeller.cc metview-5.19.2/metview/src/Hovmoeller/Hovmoeller.cc --- metview-5.17.4/metview/src/Hovmoeller/Hovmoeller.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/Hovmoeller.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,7 +26,7 @@ // The applications don't try to read or write from pool, this // should not be done with the new PlotMod. - //a.addModeService("GRIB", "DATA"); + // a.addModeService("GRIB", "DATA"); lhov.saveToPool(false); ahov.saveToPool(false); ehov.saveToPool(false); diff -Nru metview-5.17.4/metview/src/Hovmoeller/Hovmoeller.h metview-5.19.2/metview/src/Hovmoeller/Hovmoeller.h --- metview-5.17.4/metview/src/Hovmoeller/Hovmoeller.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/Hovmoeller.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,12 +13,12 @@ Application for Hovmoeller (similar to XSection, Average). It takes a GRIB file as input (in addition to the values given by the user), and produces an NetCDF - file as output. There is no metadata on output request, + file as output. There is no metadata on output request, only the path to NetCDF file. First the GRIB while is read, and info about all parameters and level are stored. Then several - flags is set, based on the data and the input + flags is set, based on the data and the input request, to determine how the application should run. @@ -44,7 +44,7 @@ MvService(kw) {} // Destructor - virtual ~Hovmoeller() = default; + ~Hovmoeller() override = default; - virtual void serve(MvRequest&, MvRequest&) {} + void serve(MvRequest&, MvRequest&) override {} }; diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovToolkit.cc metview-5.19.2/metview/src/Hovmoeller/HovToolkit.cc --- metview-5.17.4/metview/src/Hovmoeller/HovToolkit.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovToolkit.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,19 +14,19 @@ #include "MvException.h" #include "MvRequestUtil.hpp" +#include "StatsCompute.h" +#include "MvLog.h" -// Type of input request to be processed -enum -{ - HOV_DATA_DROPPED, - HOV_DATA_MODULE, - HOV_DATA_MODULE_DROPPED -}; +std::string HovToolkit::moduleLabel_ = "Hovmoeller-> "; +std::map HovToolkit::statsMap_ = { + {"MEAN", HovToolkit::MeanStats}, + {"MAXIMUM", HovToolkit::MaxStats}, + {"MINIMUM", HovToolkit::MinStats}, + {"MEDIAN", HovToolkit::MedianStats}, + {"MODE", HovToolkit::ModeStats}, + {"STDEV", HovToolkit::StdevStats}, + {"VARIANCE", HovToolkit::VarianceStats}}; -HovToolkit::HovToolkit() : - procType_(HOV_DATA_MODULE) // default value for option EXPAND -{ -} HovToolkit::~HovToolkit() { @@ -43,7 +43,7 @@ { coord1_.clear(); coord2_.clear(); - if (xint_) { + if (xint_ != nullptr) { delete[] xint_; xint_ = nullptr; } @@ -73,10 +73,10 @@ bool HovToolkit::Compute(std::string& netfnameIn, MvRequest& data, std::string action, MvRequest& out) { // Initialise variables - expand_ = true; - netfnameIn_ = netfnameIn; + expand_ = true; + netfnameIn_ = netfnameIn; nrIndexesIn_ = -1; - actionMode_ = action; + actionMode_ = action; // Open previous netcdf file ExpandOpenNcFile(); @@ -105,7 +105,7 @@ // Main function. It is called from the basic option (Line,Area,Height) bool HovToolkit::Compute(MvRequest& in, MvRequest& out) { - nrIndexesIn_ = 0; //option is not Expand + nrIndexesIn_ = 0; // option is not Expand // Initialize HovToolkit object from the user interface if (!GetInputParameters(in)) @@ -145,18 +145,18 @@ { // Create netCDF data request MvRequest req("NETCDF"); - req("PATH") = ncdfPath_.c_str(); + req("PATH") = ncdfPath_.c_str(); req("TEMPORARY") = 1; // Currently, the netcdf file contains only one parameter. // Update this code for more than one parameter - auto ii = params_.begin(); + auto ii = params_.begin(); ParamInfo* par = (*ii).second; // Create netCDF output request MvRequest out1("NETCDF_XY_MATRIX"); - out1("NETCDF_PLOT_TYPE") = "XY_MATRIX"; - out1("NETCDF_DATA") = req; + out1("NETCDF_PLOT_TYPE") = "XY_MATRIX"; + out1("NETCDF_DATA") = req; const char* secondCoordName = GetSecondCoordName(); if (verticalAxis_ == HOV_TIME) // TIME is vertical axis { @@ -178,9 +178,9 @@ } } - out1("NETCDF_VALUE_VARIABLE") = getNetcdfVarname(par->ParamName()).c_str(); + out1("NETCDF_VALUE_VARIABLE") = getNetcdfVarname(par->ParamName()).c_str(); out1("NETCDF_MISSING_ATTRIBUTE") = "_FillValue"; - out1("_VERB") = "NETCDF_XY_MATRIX"; + out1("_VERB") = "NETCDF_XY_MATRIX"; // Add information to help the Macro Converter to translate // the output request to a Macro code @@ -198,16 +198,16 @@ // AREA and HEIGHT but not for EXPAND. MvDate dd(GetRefTime()); viewReq("DATE_MIN") = dd.magicsDate().c_str(); - dd = dateMaxD_; + dd = dateMaxD_; viewReq("DATE_MAX") = dd.magicsDate().c_str(); // If action is not visualisation related then return the netcdf data. // Also, add the visualisation and original requests as hidden parameters. // These may be used later to help the visualisation of the netcdf data. if (!IsVisualise()) { - req("_VIEW") = "MHOVMOELLERVIEW"; + req("_VIEW") = "MHOVMOELLERVIEW"; req("_VIEW_REQUEST") = viewReq; - req("_VISUALISE") = out1; + req("_VISUALISE") = out1; return req; } @@ -220,8 +220,8 @@ MvRequest HovToolkit::CreateOutputRequest(MvRequest& in) { // Create NetCDF output request - MvRequest data = in.getSubrequest("DATA"); - MvRequest out1 = data.getSubrequest("_VISUALISE"); + MvRequest data = in.getSubrequest("DATA"); + MvRequest out1 = data.getSubrequest("_VISUALISE"); MvRequest viewReq = data.getSubrequest("_VIEW_REQUEST"); data.unsetParam("_VISUALISE"); // to avoid duplication of info data.unsetParam("_VIEW_REQUEST"); // to avoid duplication of info @@ -268,7 +268,7 @@ viewRequest = in("_CONTEXT"); // Check if a HovData module was dropped - const char* verb = (const char*)in("_VERB"); + const char* verb = (const char*)in("_VERB"); bool moduleDropped = this->IsDataModule(verb); // Check the type of input request to be processed @@ -281,10 +281,10 @@ // Get information from the View request if (procType_ == HOV_DATA_DROPPED) { // Retrieve the HovmoellerView request from the CartesianView - MvRequest hovRequest = this->GetAppView(viewRequest); + MvRequest hovViewReq = this->GetAppView(viewRequest); // Retrieve parameters - if (!this->GetInputInfo(hovRequest)) + if (!this->GetInputInfo(hovViewReq)) return false; } // Process a data module @@ -298,20 +298,20 @@ // Get information from the Module and View and check if they are compatible. else if (procType_ == HOV_DATA_MODULE_DROPPED) { // Retrieve the HovmoellerView request from the CartesianView - MvRequest hovRequest = this->GetAppView(viewRequest); + MvRequest hovViewReq = this->GetAppView(viewRequest); // Retrieve 'original' request from the data module - MvRequest modRequest = dataRequest_.getSubrequest("_ORIGINAL_REQUEST"); - if (!modRequest) - modRequest = in; + MvRequest hovDataReq = dataRequest_.getSubrequest("_ORIGINAL_REQUEST"); + if (!hovDataReq) + hovDataReq = in; // Consistency check, only for non-default View request - if (!((const char*)hovRequest("_DEFAULT") && (int)hovRequest("_DEFAULT") == 1)) - if (!this->consistencyCheck(hovRequest, modRequest)) + if (!((const char*)hovViewReq("_DEFAULT") && (int)hovViewReq("_DEFAULT") == 1)) + if (!this->consistencyCheck(hovViewReq, hovDataReq)) return false; // Retrieve parameters - if (!this->GetInputInfo(hovRequest)) + if (!this->GetInputInfo(hovViewReq)) return false; } @@ -321,9 +321,9 @@ bool HovToolkit::GetInputCommonInfo(MvNetCDF* netcdf) { // Retrieve information from the 'time' variable - MvNcVar* var = netcdf->getVariable(HOV_VARTIME); - long* edges = var->edges(); - nrIndexesIn_ = edges[0]; + MvNcVar* var = netcdf->getVariable(HOV_VARTIME); + long* edges = var->edges(); + nrIndexesIn_ = edges[0]; MvNcAtt* tmpatt = var->getAttribute("reference_date"); if (!tmpatt) throw MvException(moduleLabel_ + "Netcdf file: REFERENCE_DATE attribute not found"); @@ -332,22 +332,22 @@ refTime_ = d1.YyyyMmDd_r(); // Retrieve information from the second axis variable - var = netcdf->getVariable(GetSecondCoordName()); - edges = var->edges(); + var = netcdf->getVariable(GetSecondCoordName()); + edges = var->edges(); nrPoints_ = edges[0]; if (nrIndexesIn_ <= 0 || nrPoints_ <= 0) throw MvException(moduleLabel_ + "Netcdf file: invalid dimension for variables TIME and/or GEOGRAPHICAL"); // Retrieve attributes values // Retrieve Grid values - MvRequest req = netcdf->getRequest(); + MvRequest req = netcdf->getRequest(); const char* cp = (const char*)req("grid"); if (cp == nullptr) throw MvException(moduleLabel_ + "Netcdf file: GRID attribute not found"); std::string str = cp; - gridEW_ = atof(strtok((char*)str.c_str(), "/")); - gridNS_ = atof(strtok(nullptr, "/")); + gridEW_ = atof(strtok((char*)str.c_str(), "/")); + gridNS_ = atof(strtok(nullptr, "/")); // Retrieve Coordinates values cp = (const char*)req("coordinates"); @@ -361,7 +361,7 @@ x2_ = atof(strtok(nullptr, "/")); // Retrieve vertical axis flag - cp = (const char*)req("vertical_axis"); + cp = (const char*)req("vertical_axis"); verticalAxis_ = (cp == nullptr) ? HOV_TIME : atoi(cp); return true; @@ -385,9 +385,9 @@ dateMinD_ = 99999999.; dateMaxD_ = 0.; std::string keystr, timekey; - int iparam; - double level; - const char* expver = 0; + int iparam = 0; + double level = 0.; + const char* expver = nullptr; iter.rewind(); iter.sort("LEVELIST", '>'); // iter.sort("STEP"); @@ -399,9 +399,9 @@ while ((field = iter())) { // MvFieldExpander x(field); MvRequest rq = field.getRequest(); - iparam = rq("PARAM"); - level = rq("LEVELIST", 0); - expver = rq("EXPVER"); + iparam = rq("PARAM"); + level = rq("LEVELIST", 0); + expver = rq("EXPVER"); std::string ev = expver ? expver : "_"; // Save basic information @@ -421,17 +421,17 @@ if (dateMaxD_ < d1) dateMaxD_ = d1; - //TODO: This seems to be a memory leak + // TODO: This seems to be a memory leak auto* par = new ParamInfo(iparam, d1, level, ev, field.getGribKeyValueString("shortName"), field.getGribKeyValueString("name"), field.getGribKeyValueString("units")); ParamInsertPair inserted = params_.insert(ParamPair(keystr, par)); - ParamInfo* pp = (*(inserted.first)).second; + ParamInfo* pp = (*(inserted.first)).second; pp->AddIndex(timekey); } - } + } } // Check if basic information was retrieved @@ -440,9 +440,7 @@ // Maybe this restriction should be removed in the future if (params_.size() > 1) { - throw MvException(moduleLabel_ + "Creation of Hovmoeller diagrams from multiple parameters or vertical levels is not yet supported. This data has " - + std::to_string(params_.size()) + " parameters or levels"); - + throw MvException(moduleLabel_ + "Creation of Hovmoeller diagrams from multiple parameters or vertical levels is not yet supported. This data has " + std::to_string(params_.size()) + " parameters or levels"); } return true; @@ -450,7 +448,7 @@ void HovToolkit::GenerateKey(std::string& str, MvRequest& rq) { - int par = rq("PARAM"); + int par = rq("PARAM"); int level = rq("LEVELIST", 0); std::ostringstream oss; @@ -483,13 +481,14 @@ return; } -double HovToolkit::GetDateDif(std::string& timekey) +// step as double to help prepare for sub-hourly steps +void HovToolkit::GetComponentsFromTimeKeyf(const std::string& timekey, MvDate& date, double& step) { // Extract date information - double ddate = atof(timekey.substr(0, 8).c_str()); - double dhour = atof(timekey.substr(8, 2).c_str()); - double dmin = atof(timekey.substr(10, 2).c_str()); - double dstep; + int ddate = atoi(timekey.substr(0, 8).c_str()); + int dhour = atoi(timekey.substr(8, 2).c_str()); + int dmin = atoi(timekey.substr(10, 2).c_str()); + double dstep = 0.; std::string strStep = timekey.substr(12, HOV_STEPSIZE); @@ -505,25 +504,57 @@ else { dstep = 0; // nothing but zeros } - - // Compute hour+min+step in fraction of days - double frac = dhour * 3600. / 86400. + dmin * 60. / 86400. + dstep * 3600. / 86400.; + step = dstep; // export to calling function // If it is a monthly mean parameter, add 1 to original date if (fmod(ddate, 100) == 0.) ddate++; + // Compute hour+min+step in fraction of days + double frac = dhour * 3600. / 86400. + dmin * 60. / 86400.; + // Compute new date MvDate ndate(ddate); ndate += frac; + date = ndate; // export to calling function +} + +double HovToolkit::GetDateDif(const std::string& timekey) +{ + // Extract date information + MvDate ddate; + double dstep; + GetComponentsFromTimeKeyf(timekey, ddate, dstep); + + // Compute step in fraction of days + double stepfrac = dstep * 3600. / 86400.; + + // Compute new date + ddate += stepfrac; // Compute the difference from the reference date MvDate ref(GetRefTime()); - double dif = ref.time_interval_hours(ndate); + double dif = ref.time_interval_hours(ddate); return dif; } +// used for generating error messages +std::string HovToolkit::TimeKeyToUserString(const std::string& timekey) +{ + // Extract date information + MvDate ddate; + double dstep; + GetComponentsFromTimeKeyf(timekey, ddate, dstep); + + char dateCStr[1024]; + ddate.Format("yyyy-mm-dd HH:MM", dateCStr); + std::string dateStr(dateCStr); + dateStr += " step " + std::to_string(int(dstep)) + "h"; // XX ASSUMES hours + + return std::string(dateStr); +} + MvDate HovToolkit::GetDate(MvField& field) { // Compute initial date @@ -556,13 +587,13 @@ void HovToolkit::GetTimeInfoFromParam() { // Get time series from the first variable - double dd; + double dd = 0.; std::string timekey; - ParamInfo* par = (*params_.begin()).second; + ParamInfo* par = (*params_.begin()).second; IndexesMap lmap = par->Indexes(); for (auto& ii : lmap) { timekey = ii.first; - dd = this->GetDateDif(timekey); + dd = this->GetDateDif(timekey); vtime_.push_back(dd); } @@ -576,8 +607,10 @@ return false; // Allocate internal variables - if (xint_) - delete xint_; + if (xint_ != nullptr) { + delete[] xint_; + xint_ = nullptr; + } xint_ = new double[nrPoints_]; // Sort data by level, expver and param @@ -620,7 +653,7 @@ lastNrGenerated = currentGenerated; } - lastKey = keystr; + lastKey = keystr; lastField = field; } @@ -634,6 +667,71 @@ return true; } +std::string HovToolkit::statsName(Statistics s) +{ + for (auto it : statsMap_) { + if (it.second == s) { + return it.first; + } + } + return {}; +} + +HovToolkit::Statistics HovToolkit::statsType(MvRequest& in) +{ + Statistics s = NoStats; + if (const char* ch = (const char*)in("AREA_STATISTICS")) { + return statsType(ch); + } + return s; +} + +HovToolkit::Statistics HovToolkit::statsType(const char* name) +{ + Statistics s = NoStats; + if (name) { + std::string stStr(name); + auto it = statsMap_.find(name); + if (it != statsMap_.end()) { + s = it->second; + } + else { + throw MvException(moduleLabel_ + "Invalid AREA_STATISTICS=" + stStr); + } + } + return s; +} + + +StatsComputePtr HovToolkit::makeStatsCompute() const +{ + StatsComputePtr comp = nullptr; + switch (stats_) { + case MeanStats: + comp = metview::StatsComputePtr(new metview::MeanStatsCompute); + break; + case MaxStats: + comp = metview::StatsComputePtr(new metview::MaxStatsCompute); + break; + case MinStats: + comp = metview::StatsComputePtr(new metview::MinStatsCompute); + break; + case StdevStats: + comp = metview::StatsComputePtr(new metview::StdevStatsCompute); + break; + case VarianceStats: + comp = metview::StatsComputePtr(new metview::VarianceStatsCompute); + break; + case MedianStats: + comp = metview::StatsComputePtr(new metview::MedianStatsCompute); + break; + default: + throw MvException(moduleLabel_ + "Invalid internal statistics type=" + std::to_string(stats_)); + break; + } + return comp; +} + bool HovToolkit::Initialiser() { // Create temporary netcdf file name @@ -685,7 +783,7 @@ // produce a title and Hovmoeller plots only the first variable then // we are adding this code below. REMOVE it when Magics is capable to // produce a title from the Variable Attributes. - auto ii = params_.begin(); + auto ii = params_.begin(); ParamInfo* par = (*ii).second; netcdf_->addAttribute("title", this->GetTitle(par).c_str()); } @@ -723,14 +821,14 @@ std::vector vname(2); int nrIndexes = this->NrIndexes(); if (verticalAxis_ == HOV_TIME) { - vdim[0] = nrIndexes; - vdim[1] = nrPoints_; + vdim[0] = nrIndexes; + vdim[1] = nrPoints_; vname[0] = HOV_VARTIME; vname[1] = this->GetSecondCoordName(); } else { - vdim[0] = nrPoints_; - vdim[1] = nrIndexes; + vdim[0] = nrPoints_; + vdim[1] = nrIndexes; vname[0] = this->GetSecondCoordName(); vname[1] = HOV_VARTIME; } @@ -787,9 +885,9 @@ // Create data matrix according to the input parameters // Write matrix to the netcdf file IndexesMap lmap = par->Indexes(); - int k; + int k = 0; - if (verticalAxis_ == HOV_TIME) //vertical time axis + if (verticalAxis_ == HOV_TIME) // vertical time axis { // 'Expand' option: write previous values first int pos = 0; @@ -800,10 +898,10 @@ NcWriteValues(ncvar, lInfo, k + pos); } } - else //vertical geo/height axis: transpose values + else // vertical geo/height axis: transpose values { // Retrieve all values from the internal structure - int i, j = 0; + int i = 0, j = 0; int nrInd = lmap.size(); // or nrIndexes_ - nrIndexesIn_ std::vector mat(nrInd * nrPoints_); IndexIterator ii; @@ -814,7 +912,7 @@ } // Write matrix data to the netcdf file - const char* key = ncvar->name(); //get variable name + const char* key = ncvar->name(); // get variable name std::vector cp(nrIndexes_); for (i = 0; i < nrPoints_; i++) { // 'Expand' option: write previous values @@ -923,7 +1021,7 @@ { if (netcdfIn_) { delete netcdfIn_; - netcdfIn_ = 0; + netcdfIn_ = nullptr; } return; @@ -937,9 +1035,9 @@ // Copy values from the input netcdf file std::vector vals; - std::string key = ncvar->name(); //get variable name + std::string key = ncvar->name(); // get variable name MvNcVar* ncvarIn = netcdfIn_->getVariable(key.c_str()); - long* edges = ncvarIn->edges(); + long* edges = ncvarIn->edges(); ncvarIn->get(vals, edges); ncvar->setCurrent(pos); ncvar->put(vals, edges[0], edges[1]); @@ -957,7 +1055,7 @@ // Get values from the input netcdf file std::vector vals; MvNcVar* ncvarIn = netcdfIn_->getVariable(key); - long* edges = ncvarIn->edges(); + long* edges = ncvarIn->edges(); ncvarIn->setCurrent(pos); ncvarIn->get(vals, 1, edges[1]); @@ -981,8 +1079,8 @@ // Copy 'time' values from the input file std::vector vals; MvNcVar* tvar = netcdfIn_->getVariable(HOV_VARTIME); - long* edges = tvar->edges(); - nrIndexesIn_ = edges[0]; + long* edges = tvar->edges(); + nrIndexesIn_ = edges[0]; tvar->get(vals, edges); for (double& val : vals) vtime_.push_back(val); @@ -995,8 +1093,8 @@ const char* caux = origReq_.getVerb(); MvRequest oreq(caux); oreq("_MACRO_DECODE_TAG") = 1; // extra info for the Macro Converter - oreq("_CLASS") = (const char*)origReq_("_CLASS") ? (const char*)origReq_("_CLASS") : caux; - oreq("_VERB") = (const char*)origReq_("_VERB") ? (const char*)origReq_("_VERB") : caux; + oreq("_CLASS") = (const char*)origReq_("_CLASS") ? (const char*)origReq_("_CLASS") : caux; + oreq("_VERB") = (const char*)origReq_("_VERB") ? (const char*)origReq_("_VERB") : caux; if (strcmp((const char*)oreq("_CLASS"), "RETRIEVE") == 0 || strcmp((const char*)oreq("_CLASS"), "GRIB") == 0) { MvRequest retReq = origReq_("DATA"); diff -Nru metview-5.17.4/metview/src/Hovmoeller/HovToolkit.h metview-5.19.2/metview/src/Hovmoeller/HovToolkit.h --- metview-5.17.4/metview/src/Hovmoeller/HovToolkit.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/HovToolkit.h 2023-07-15 08:28:47.000000000 +0000 @@ -9,37 +9,46 @@ #pragma once +#include + #include "Factory.h" #include "MvHovmFrame.h" #include "MvNetCDF.h" +#include "MvFwd.h" enum { HOV_TIME, HOV_GEO -}; //vertical axis: time or 'second' axis +}; // vertical axis: time or 'second' axis enum { HOV_NS, HOV_EW -}; //average direction: North-South or East-West -//enum -//{ -// HOV_ASINDATA, -// HOV_PRESSURE -//}; //height axis type options +}; // average direction: North-South or East-West + +// Type of input request to be processed +enum +{ + HOV_DATA_DROPPED, + HOV_DATA_MODULE, + HOV_DATA_MODULE_DROPPED +}; const std::string HOV_VARLEVEL = "nlev"; -const std::string HOV_VARTIME = "time"; -const std::string HOV_VARLAT = "lat"; -const std::string HOV_VARLON = "lon"; +const std::string HOV_VARTIME = "time"; +const std::string HOV_VARLAT = "lat"; +const std::string HOV_VARLON = "lon"; class HovToolkit { public: - HovToolkit(); + HovToolkit() = default; virtual ~HovToolkit(); + HovToolkit(const HovToolkit&) = delete; + HovToolkit& operator=(const HovToolkit&) = delete; + // Release memory void ReleaseAllMemory(); void ReleaseMemory(); @@ -48,9 +57,9 @@ // Initialise internal variables bool GetInputParameters(MvRequest&); virtual bool GetInputInfo(MvRequest&) = 0; - bool GetInputCommonInfo(MvRequest&); //from user interface + bool GetInputCommonInfo(MvRequest&); // from user interface virtual bool GetInputInfo(MvNetCDF*) = 0; - bool GetInputCommonInfo(MvNetCDF*); //from the netcdf file + bool GetInputCommonInfo(MvNetCDF*); // from the netcdf file // Compute Hovmoeller diagram (main routine) // Create a new netcdf file @@ -85,7 +94,9 @@ double GetRefTime() { return refTime_; } void SetRefTime(double ref) { refTime_ = ref; } MvDate GetDate(MvField&); - double GetDateDif(std::string&); + void GetComponentsFromTimeKeyf(const std::string& timekey, MvDate& date, double& step); + double GetDateDif(const std::string&); + std::string TimeKeyToUserString(const std::string& timekey); bool GetTimeInfo(); void GetTimeInfoFromParam(); @@ -99,7 +110,7 @@ // Functions to handle list of levels virtual void InitializeLevelList() {} virtual void collectVerticalData(MvField&, const std::string&, double) {} - virtual bool collectLnsp(MvRequest& /*data*/) {return false;} + virtual bool collectLnsp(MvRequest& /*data*/) { return false; } // Functions to handle the netcdf file bool NcAddCommonVariables(); @@ -107,7 +118,7 @@ void NcAddMetadata(MvNcVar*, ParamInfo*); std::string getNetcdfVarname(std::string); // Get netCDF variable name virtual std::string GetTitle(ParamInfo*) = 0; - virtual const char* ApplicationType() = 0; + virtual const char* ApplicationType() = 0; virtual void NcWriteGlobalAttributes(); virtual void NcWriteGlobalAttributesApp() = 0; virtual bool NcWriteTimeInfo(); @@ -131,7 +142,7 @@ virtual const char* GetSecondCoordName() = 0; // the first axis name is "time" virtual const char* GetSecondAuxiliaryCoordName() { return " "; } virtual bool SecondAuxiliaryCoord() = 0; - virtual bool ComputeSecondCoord() = 0; + virtual bool ComputeSecondCoord() = 0; virtual std::string GeolineConvention() { return glConvention_; } // Functions to handle action mode @@ -157,15 +168,36 @@ bool isParamVertCoord(int paramId) const; protected: - bool swapAxes_{false}; // swap default axes - int procType_; // process type - int verticalAxis_; // Time axis or Geo axis - int nrPoints_; // number of points of the second axis - int nrIndexes_; // number of points of the time axis - double x1_, x2_, y1_, y2_; // geographical coordinates - double gridNS_, gridEW_; // grid interval - double refTime_; // reference Time value - double dateMinD_, dateMaxD_; // min/max date values + enum Statistics + { + NoStats, + MeanStats, + MinStats, + MaxStats, + ModeStats, + MedianStats, + StdevStats, + VarianceStats + }; + static std::string statsName(Statistics s); + static Statistics statsType(MvRequest& in); + static Statistics statsType(const char* name); + StatsComputePtr makeStatsCompute() const; + + bool swapAxes_{false}; // swap default axes + int procType_{HOV_DATA_MODULE}; // process type + int verticalAxis_{HOV_TIME}; // Time axis or Geo axis + int nrPoints_{0}; // number of points of the second axis + int nrIndexes_{0}; // number of points of the time axis + double x1_{0.}; + double x2_{0.}; + double y1_{0.}; + double y2_{0.}; // geographical coordinates + double gridNS_{1.}; + double gridEW_{1.}; // grid interval + double refTime_{0.}; // reference Time value + double dateMinD_{0.}; + double dateMaxD_{0.}; // min/max date values std::string ncdfPath_; // netCDF file path std::string actionMode_; // "examine"/"save"/"execute"/... std::string glConvention_{"lonlat"}; // geoline convention: lonlat or latlon @@ -182,11 +214,14 @@ // Variables related to the Expand option bool expand_{false}; // true: expand option - int nrIndexesIn_; // number of initial time points + int nrIndexesIn_{0}; // number of initial time points std::string netfnameIn_; // input netcdf filename MvNetCDF* netcdfIn_{nullptr}; // Input netcdf structure - std::string moduleLabel_{"Hovmoeller-> "}; + static std::string moduleLabel_; int lnspParamId_{152}; int vertCoordParamId_{-1}; + + static std::map statsMap_; + Statistics stats_{NoStats}; }; diff -Nru metview-5.17.4/metview/src/Hovmoeller/MHovmoellerDataDef metview-5.19.2/metview/src/Hovmoeller/MHovmoellerDataDef --- metview-5.17.4/metview/src/Hovmoeller/MHovmoellerDataDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/MHovmoellerDataDef 2023-07-15 08:28:47.000000000 +0000 @@ -76,11 +76,22 @@ ] { @ / } - AVERAGE_DIRECTION - { - EAST_WEST - NORTH_SOUTH - } = EAST_WEST + AREA_STATISTICS + { + MEAN + MAXIMUM + MINIMUM + MEDIAN + STDEV + VARIANCE + } = MEAN + + AVERAGE_DIRECTION + { + EAST_WEST + NORTH_SOUTH + } = EAST_WEST + SWAP_AXES { @@ -167,6 +178,16 @@ / } = 30./-30./-30./30. + AREA_STATISTICS + { + MEAN + MAXIMUM + MINIMUM + MEDIAN + STDEV + VARIANCE + } = MEAN + DATA [ interface = icon, class = GRIB, exclusive = false, diff -Nru metview-5.17.4/metview/src/Hovmoeller/MHovmoellerDataRules metview-5.19.2/metview/src/Hovmoeller/MHovmoellerDataRules --- metview-5.17.4/metview/src/Hovmoeller/MHovmoellerDataRules 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/MHovmoellerDataRules 2023-07-15 08:28:47.000000000 +0000 @@ -1,5 +1,6 @@ %if INPUT_MODE = POINT %or INPUT_MODE = NEAREST_GRIDPOINT %then %unset AREA + %unset AREA_STATISTICS %if INPUT_MODE = AREA %then %unset POINT diff -Nru metview-5.17.4/metview/src/Hovmoeller/MHovmoellerViewDef metview-5.19.2/metview/src/Hovmoeller/MHovmoellerViewDef --- metview-5.17.4/metview/src/Hovmoeller/MHovmoellerViewDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/MHovmoellerViewDef 2023-07-15 08:28:47.000000000 +0000 @@ -49,11 +49,22 @@ / } = 30./-30./-30./30. - AVERAGE_DIRECTION - { - EAST_WEST - NORTH_SOUTH - } = EAST_WEST + AREA_STATISTICS + { + MEAN + MAXIMUM + MINIMUM + MEDIAN + STDEV + VARIANCE + } = MEAN + + AVERAGE_DIRECTION + { + EAST_WEST + NORTH_SOUTH + } = EAST_WEST + TIME_AXIS_MODE { @@ -64,7 +75,7 @@ DATE_MIN { - AUTOMATIC + AUTOMATICs @ } = AUTOMATIC diff -Nru metview-5.17.4/metview/src/Hovmoeller/MHovmoellerViewRules metview-5.19.2/metview/src/Hovmoeller/MHovmoellerViewRules --- metview-5.17.4/metview/src/Hovmoeller/MHovmoellerViewRules 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/MHovmoellerViewRules 2023-07-15 08:28:47.000000000 +0000 @@ -2,6 +2,7 @@ %unset INPUT_MODE %unset POINT %unset AREA + %unset AREA_STATISTICS %unset AVERAGE_DIRECTION %unset BOTTOM_LEVEL %unset TOP_LEVEL @@ -34,9 +35,11 @@ %if TYPE = VERTICAL_HOVM %and INPUT_MODE = POINT %then %unset AREA + %unset AREA_STATISTICS %if TYPE = VERTICAL_HOVM %and INPUT_MODE = NEAREST_GRIDPOINT %then %unset AREA + %unset AREA_STATISTICS %if TYPE = VERTICAL_HOVM %and INPUT_MODE = AREA %then %unset POINT diff -Nru metview-5.17.4/metview/src/Hovmoeller/MvHovmFrame.cc metview-5.19.2/metview/src/Hovmoeller/MvHovmFrame.cc --- metview-5.17.4/metview/src/Hovmoeller/MvHovmFrame.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/MvHovmFrame.cc 2023-07-15 08:28:47.000000000 +0000 @@ -57,7 +57,7 @@ std::string ParamInfo::ExpVerTitle() { if (expver_ == "_") //-- missing ExpVer is stored as "_" - return std::string(""); + return {""}; else return std::string("Expver ") + expver_; } @@ -69,19 +69,23 @@ // Save data for one entry auto ii = indexes_.find(index); if (ii == indexes_.end()) { - double ind = atof(index.substr(12, HOV_STEPSIZE).c_str()); + double ind = atof(index.substr(12, HOV_STEPSIZE).c_str()); indexes_[index] = new IndexesInfo(ind); - ii = indexes_.find(index); + ii = indexes_.find(index); } else { if ((*ii).second->values_) { delete[](*ii).second->values_; - (*ii).second->values_ = 0; + (*ii).second->values_ = nullptr; } } - if ((*ii).second->values_ == 0) + if ((*ii).second->values_ == nullptr) { (*ii).second->values_ = new double[n]; + for (int i = 0; i < n; i++) { + (*ii).second->values_[i] = DBL_MAX; + } + } double* xx = (*ii).second->values_; for (int i = 0; i < n; i++) @@ -91,7 +95,7 @@ void ParamInfo::AddIndex(std::string& index) { if (indexes_.find(index) == indexes_.end()) { - double ind = atof(index.substr(12, HOV_STEPSIZE).c_str()); + double ind = atof(index.substr(12, HOV_STEPSIZE).c_str()); indexes_[index] = new IndexesInfo(ind); } } diff -Nru metview-5.17.4/metview/src/Hovmoeller/MvHovmFrame.h metview-5.19.2/metview/src/Hovmoeller/MvHovmFrame.h --- metview-5.17.4/metview/src/Hovmoeller/MvHovmFrame.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Hovmoeller/MvHovmFrame.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,23 +25,22 @@ class IndexesInfo { public: - double* Values() { return values_; } - double Index() { return index_; } + double* Values() const { return values_; } + double Index() const { return index_; } private: friend class ParamInfo; IndexesInfo(double index) : - values_(nullptr), index_(index) {} - double* values_; - double index_; + double* values_{nullptr}; + double index_{0.}; }; -typedef std::map IndexesMap; -typedef IndexesMap::iterator IndexIterator; -typedef IndexesMap::reverse_iterator ReverseIndexIterator; +using IndexesMap = std::map; +using IndexIterator = IndexesMap::iterator; +using ReverseIndexIterator = IndexesMap::reverse_iterator; // Info about a parameter at one level and expver // Contains a IndexesMap with info about the times (date+time+step) @@ -54,15 +53,15 @@ ~ParamInfo(); MvDate& Date() { return date_; } - int Parameter() { return param_; } - std::string ParamName() { return paramName_; } - std::string ParamLongName() { return paramLongName_; } - std::string Units() { return units_; } + int Parameter() const { return param_; } + std::string ParamName() const { return paramName_; } + std::string ParamLongName() const { return paramLongName_; } + std::string Units() const { return units_; } - double Level() { return level_; } + double Level() const { return level_; } std::string LevelTitle(); - std::string ExpVer() { return expver_; } + std::string ExpVer() const { return expver_; } std::string ExpVerTitle(); void ExpVer(const char* xx) { expver_ = xx; } @@ -70,7 +69,7 @@ IndexesMap& Indexes() { return indexes_; } void AddIndex(std::string& index); - int NrIndexes() { return indexes_.size(); } + int NrIndexes() const { return static_cast(indexes_.size()); } friend int operator<(const ParamInfo& p1, const ParamInfo& p2) { @@ -88,7 +87,7 @@ IndexesMap indexes_; }; -typedef std::map ParamMap; -typedef ParamMap::iterator ParamIterator; -typedef std::pair ParamInsertPair; -typedef std::pair ParamPair; +using ParamMap = std::map; +using ParamIterator = ParamMap::iterator; +using ParamInsertPair = std::pair; +using ParamPair = std::pair; diff -Nru metview-5.17.4/metview/src/IconDescMaker/IconDescMaker.cc metview-5.19.2/metview/src/IconDescMaker/IconDescMaker.cc --- metview-5.17.4/metview/src/IconDescMaker/IconDescMaker.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/IconDescMaker/IconDescMaker.cc 2023-07-15 08:28:47.000000000 +0000 @@ -82,33 +82,33 @@ "\"[0] png:\"" + ftmp.path() + "\""; // std::cout << "cmd=" << cmd << std::endl; system(cmd.c_str()); - out("FORMAT") = "IMAGE"; + out("FORMAT") = "IMAGE"; out("TMP_IMAGE_PATH") = ftmp.path().c_str(); } else if (verb == "GRIB") { std::string txt; getGribDesc(inPath, txt); out("FORMAT") = "TEXT"; - out("TEXT") = txt.c_str(); + out("TEXT") = txt.c_str(); } else if (verb == "BUFR") { std::string txt; getBufrDesc(inPath, txt); out("FORMAT") = "TEXT"; - out("TEXT") = txt.c_str(); + out("TEXT") = txt.c_str(); } else if (verb == "GEOPOINTS") { MvTmpFile ftmp(false); std::string txt; getGeopointsDesc(inPath, ftmp.path(), txt); - out("FORMAT") = "IMAGE_AND_TEXT"; - out("TEXT") = txt.c_str(); + out("FORMAT") = "IMAGE_AND_TEXT"; + out("TEXT") = txt.c_str(); out("TMP_IMAGE_PATH") = ftmp.path().c_str(); } else if (verb == "MCOAST" || verb == "GEOVIEW" || verb == "PCOAST" || verb == "MAPVIEW") { MvTmpFile ftmp(false); makePreviewImage(inPath, ftmp.path()); - out("FORMAT") = "IMAGE"; + out("FORMAT") = "IMAGE"; out("TMP_IMAGE_PATH") = ftmp.path().c_str(); } @@ -121,7 +121,7 @@ GribMetaData data; data.setFileName(inPath); int num = data.computeTotalMessageNum(); - txt = "message num: " + std::to_string(num); + txt = "message num: " + std::to_string(num); if (num > 0) { txt += "
first message
"; MvKeyProfile prof("tmp"); @@ -164,7 +164,7 @@ BufrMetaData data; data.setFileName(inPath); int num = data.computeTotalMessageNum(); - txt = "message num: " + std::to_string(num); + txt = "message num: " + std::to_string(num); if (num > 0) { txt += "
first message
"; MvKeyProfile prof("tmp"); @@ -213,7 +213,7 @@ void IconDescMaker::makePreviewImage(const std::string& inPath, const std::string& imgPath) { - //Generate a preview image with a macro + // Generate a preview image with a macro std::string previewMacro; char* mvbin = getenv("METVIEW_BIN"); if (mvbin == nullptr) { @@ -227,25 +227,25 @@ std::vector param; - //The first param indicates that we are not in test mode + // The first param indicates that we are not in test mode param.push_back(inPath); param.push_back(imgPath); - //Build request to be sent to Macro + // Build request to be sent to Macro MvRequest req("MACRO"); - req("PATH") = previewMacro.c_str(); - req("_CLASS") = "MACRO"; + req("PATH") = previewMacro.c_str(); + req("_CLASS") = "MACRO"; req("_ACTION") = "execute"; // req("_REPLY") = processName.c_str(); req("_EXTENDMESSAGE") = "1"; - //Define argument list for the macro! + // Define argument list for the macro! for (auto& it : param) { req.addValue("_ARGUMENTS", it.c_str()); } - //Run macro - // marslog(LOG_INFO, "Execute macro: %s", previewMacro.c_str()); + // Run macro + // marslog(LOG_INFO, "Execute macro: %s", previewMacro.c_str()); int err = 0; MvApplication::waitService("macro", req, err); } @@ -258,8 +258,8 @@ "GEOPOINTS", "BUFR", "GEOVIEW", "MCOAST", "MAPVIEW", "PCOAST"}; - //we use a list here instead of a vector to avoid using the - //copy constructor in emplace_back(). MvService is non-copiable! + // we use a list here instead of a vector to avoid using the + // copy constructor in emplace_back(). MvService is non-copiable! using IconDescMaker_ptr = std::shared_ptr; std::list svcList; for (auto v : verbs) { diff -Nru metview-5.17.4/metview/src/KML/GeoToKML.cc metview-5.19.2/metview/src/KML/GeoToKML.cc --- metview-5.17.4/metview/src/KML/GeoToKML.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/KML/GeoToKML.cc 2023-07-15 08:28:47.000000000 +0000 @@ -87,16 +87,16 @@ ToPlacemark::ToPlacemark(MvRequest& def) { /* North = def("AREA", 0); - West = def("AREA", 1); - South = def("AREA", 2); - East = def("AREA", 3); - - if(North < South) - { - double tmp = North; - North = South; - South = tmp; - } + West = def("AREA", 1); + South = def("AREA", 2); + East = def("AREA", 3); + + if(North < South) + { + double tmp = North; + North = South; + South = tmp; + } */ MvRequest data; def.getValue(data, "GEOPOINTS"); @@ -133,12 +133,12 @@ if (strcmp(def("OUTPUT_MODE"), "POI") == 0) { for (size_t s = 0; s < GPoints.count(); s++) { const double value = GPoints.value(s); - const long time = GPoints.time(s); - const long date = GPoints.date(s); + const long time = GPoints.time(s); + const long date = GPoints.date(s); std::stringstream out; out << date; const std::string da = out.str(); - const double lon = (GPoints.lon_x(s) > 180) ? GPoints.lon_x(s) - 360 : GPoints.lon_x(s); + const double lon = (GPoints.lon_x(s) > 180) ? GPoints.lon_x(s) - 360 : GPoints.lon_x(s); pFile_ << " \n" << " " << value << "\n" @@ -163,13 +163,13 @@ { std::stringstream coords; for (size_t s = 0; s < GPoints.count(); s++) { - //const double value = GPoints[s].value(); + // const double value = GPoints[s].value(); const long time = GPoints.time(s); const long date = GPoints.date(s); std::stringstream out; out << date; const std::string da = out.str(); - const double lon = (GPoints.lon_x(s) > 180) ? GPoints.lon_x(s) - 360 : GPoints.lon_x(s); + const double lon = (GPoints.lon_x(s) > 180) ? GPoints.lon_x(s) - 360 : GPoints.lon_x(s); if (s == 0) { pFile_ << " \n" @@ -192,7 +192,7 @@ // Write data as loose Placemarks else if (strcmp(def("OUTPUT_MODE"), "POL") == 0) { for (size_t s = 0; s < GPoints.count(); s++) { - //const double value = GPoints[s].value(); + // const double value = GPoints[s].value(); const long time = GPoints.time(s); const long date = GPoints.date(s); std::stringstream out; @@ -223,99 +223,99 @@ // KMZ /* if(strcmp(def("OUTPUT_FORMAT"),"KMZ") == 0) { - zipFile zf; - int err=0; + zipFile zf; + int err=0; - zf = zipOpen(fileName_.c_str(),0); + zf = zipOpen(fileName_.c_str(),0); if (zf == 0) { printf("ERROR opening zip file %s\n",fileName_.c_str()); err= ZIP_ERRNO; } else - { - int size_buf = WRITEBUFFERSIZE; - void* buf = (void*)malloc(size_buf); - if (buf==0) - { - Log::error() <<"Error allocating memory for KMZ generation!"< Start adding file " << *it << " to KMZ file.\n"; - FILE * fin; - int size_read; - - const char *filename = (*it).c_str(); - - err = zipOpenNewFileInZip(zf,filename, 0, 0, 0, 0, 0, 0, Z_DEFLATED, Z_DEFAULT_COMPRESSION); - - if(err != ZIP_OK) - Log::error() << "Could NOT open ... KMZ file!" << std::endl; - else - { - fin = fopen(filename,"rb"); - if(fin==0) - { - Log::fatal() << "Open file "<0) - { - err = zipWriteInFileInZip(zf,buf,size_read); - if (err<0) - { - Log::error() << "Could NOT write KMZ file "<< fileName_<< endl; - } - } - } while ((err==ZIP_OK) && (size_read>0)); - } - if (fin) - fclose(fin); - } - - if (err<0) - err=ZIP_ERRNO; - else - { - err = zipCloseFileInZip(zf); - if (err!=ZIP_OK) - printf("error in closing xxxx in the zipfile\n"); - } + { + int size_buf = WRITEBUFFERSIZE; + void* buf = (void*)malloc(size_buf); + if (buf==0) + { + Log::error() <<"Error allocating memory for KMZ generation!"< Start adding file " << *it << " to KMZ file.\n"; + FILE * fin; + int size_read; + + const char *filename = (*it).c_str(); + + err = zipOpenNewFileInZip(zf,filename, 0, 0, 0, 0, 0, 0, Z_DEFLATED, Z_DEFAULT_COMPRESSION); + + if(err != ZIP_OK) + Log::error() << "Could NOT open ... KMZ file!" << std::endl; + else + { + fin = fopen(filename,"rb"); + if(fin==0) + { + Log::fatal() << "Open file "<0) + { + err = zipWriteInFileInZip(zf,buf,size_read); + if (err<0) + { + Log::error() << "Could NOT write KMZ file "<< fileName_<< endl; + } + } + } while ((err==ZIP_OK) && (size_read>0)); + } + if (fin) + fclose(fin); + } + + if (err<0) + err=ZIP_ERRNO; + else + { + err = zipCloseFileInZip(zf); + if (err!=ZIP_OK) + printf("error in closing xxxx in the zipfile\n"); + } // delete [] filename; - } - free(buf); + } + free(buf); - err = zipClose(zf,0); - if (err != ZIP_OK) - printf("error in closing %s\n",fileName_.c_str()); - else if (!getDebug()) - { - stringarray::iterator it = kml_output_resource_list_.begin(); - stringarray::iterator itend = kml_output_resource_list_.end(); - for(; it != itend; it++) - { - remove((*it).c_str()); - } - printOutputName("KML kmz "+fileName_); + err = zipClose(zf,0); + if (err != ZIP_OK) + printf("error in closing %s\n",fileName_.c_str()); + else if (!getDebug()) + { + stringarray::iterator it = kml_output_resource_list_.begin(); + stringarray::iterator itend = kml_output_resource_list_.end(); + for(; it != itend; it++) + { + remove((*it).c_str()); + } + printOutputName("KML kmz "+fileName_); } - }// Zipping ---> K M Z - } + }// Zipping ---> K M Z + } */ } @@ -331,8 +331,8 @@ ToPlacemark placemarks(in); placemarks.write(outname, in); - MvRequest kml = "KML"; - kml("PATH") = outname.c_str(); + MvRequest kml = "KML"; + kml("PATH") = outname.c_str(); kml("TEMPORARY") = 1; out = kml; diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fdyntime.cc metview-5.19.2/metview/src/libFTimeUtil/fdyntime.cc --- metview-5.17.4/metview/src/libFTimeUtil/fdyntime.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fdyntime.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,16 +17,18 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif const int firstYear = 1830; /* oldest comparable year ! */ static int monthLength[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - dayCount[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; + dayCount[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; static const char* weekdays[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; @@ -166,5 +168,4 @@ else return monthLength[aMonth - 1]; } - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fdyntime.h metview-5.19.2/metview/src/libFTimeUtil/fdyntime.h --- metview-5.17.4/metview/src/libFTimeUtil/fdyntime.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fdyntime.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,11 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif @@ -42,18 +44,17 @@ long DifferenceInHours(const TDynamicTime& anotherTime) const; long DifferenceInDays(const TDynamicTime& anotherTime) const; - long ClockInSeconds(void) const; // add/vk 941229 + long ClockInSeconds() const; // add/vk 941229 - short GetWeekday(void) const; // mon=1, tue=2,..., sat=6, sun=7 - void PrintWeekday(void) const; + short GetWeekday() const; // mon=1, tue=2,..., sat=6, sun=7 + void PrintWeekday() const; protected: - long GetCompareValue(void) const; + long GetCompareValue() const; void DecodeCompareValue(const long& aCompareValue); short DaysInYear(const short aYear) const; short DaysInMonth(const short aMonth, const short aYear) const; private: }; - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fmettim.cc metview-5.19.2/metview/src/libFTimeUtil/fmettim.cc --- metview-5.17.4/metview/src/libFTimeUtil/fmettim.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fmettim.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,11 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif @@ -166,8 +168,8 @@ TMetTime aNewTime; aNewTime.DecodeCompareValue (GetCompareValue() + - (long)(deltaInMinutes - (minutesSoFar % deltaInMinutes)) - ); + (long)(deltaInMinutes - (minutesSoFar % deltaInMinutes)) + ); aNewTime.SetSec((short) 0); return aNewTime; } @@ -179,8 +181,8 @@ TMetTime aNewTime; aNewTime.DecodeCompareValue (GetCompareValue() - - (long)(minutesSoFar % deltaInMinutes) - ); + (long)(minutesSoFar % deltaInMinutes) + ); aNewTime.SetSec((short) 0); return aNewTime; } @@ -191,7 +193,7 @@ int minutesSoFar = 60*GetHour() + GetMin(); if ( (deltaInMinutes - (minutesSoFar % deltaInMinutes)) < - (minutesSoFar % deltaInMinutes)) + (minutesSoFar % deltaInMinutes)) return NextObservation (deltaInMinutes); else return PreviousObservation (deltaInMinutes); @@ -213,7 +215,6 @@ short TMetTime ::GetLocalHour() const { - return (GetHour() + 2) % 24; //testiarvona vakioero + return (GetHour() + 2) % 24; // testiarvona vakioero } - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fmettim.h metview-5.19.2/metview/src/libFTimeUtil/fmettim.h --- metview-5.17.4/metview/src/libFTimeUtil/fmettim.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fmettim.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,11 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif @@ -31,8 +33,8 @@ friend std::ostream& operator<<(std::ostream& oStream, const TMetTime& myTime); public: - TMetTime(void); // latest present MetTime - // : TDynamicTime(); // { ConstructMetTime( 60 ); } + TMetTime(); // latest present MetTime + // : TDynamicTime(); // { ConstructMetTime( 60 ); } TMetTime(const int timeStepInMinutes) : TDynamicTime() { ConstructMetTime(timeStepInMinutes); } TMetTime(const long datePart, const long timePart) : @@ -48,16 +50,16 @@ TDynamicTime(year, month, day, hour, minute, sec) { ConstructMetTime(60); } TMetTime& operator=(const TMetTime&); - TMetTime operator++(void); // prefix - TMetTime operator++(int); // postfix - TMetTime operator--(void); // prefix - TMetTime operator--(int); // postfix + TMetTime operator++(); // prefix + TMetTime operator++(int); // postfix + TMetTime operator--(); // prefix + TMetTime operator--(int); // postfix - void NextMetTime(void); + void NextMetTime(); void NextMetTime(const short deltaInMinutes); - void PreviousMetTime(void); + void PreviousMetTime(); void PreviousMetTime(const short deltaInMinutes); - void NearestMetTime(void); + void NearestMetTime(); void NearestMetTime(const short deltaInMinutes); // I think these should change the internal value of the object, but return the // new value, leaving the object unchanged values! For the sake of clarity, should be @@ -67,7 +69,7 @@ // TMetTime NearestObservation( const short deltaInMinutes ) const; void SetTimeStep(const short timeStepInMinutes); - short GetTimeStep(void) const; + short GetTimeStep() const; short GetLocalHour() const; @@ -75,7 +77,6 @@ void ConstructMetTime(const short timeStepInMinutes); private: - short fTimeStepInMinutes; + short fTimeStepInMinutes{0}; }; - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fobject.cc metview-5.19.2/metview/src/libFTimeUtil/fobject.cc --- metview-5.17.4/metview/src/libFTimeUtil/fobject.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fobject.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,11 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif //_________________________________________________________ TFObject @@ -39,5 +41,4 @@ { return (bool)(!(IsEqual(aObjTest))); } - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fobject.h metview-5.19.2/metview/src/libFTimeUtil/fobject.h --- metview-5.17.4/metview/src/libFTimeUtil/fobject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fobject.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,22 +14,23 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif class TFObject { public: - TFObject(void); - virtual ~TFObject(void); + TFObject(); + virtual ~TFObject(); virtual bool IsEqual(const TFObject&) const = 0; bool operator==(const TFObject& aObjTest) const; bool operator!=(const TFObject& aObjTest) const; }; - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fsortabl.cc metview-5.19.2/metview/src/libFTimeUtil/fsortabl.cc --- metview-5.17.4/metview/src/libFTimeUtil/fsortabl.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fsortabl.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,9 +14,11 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif @@ -41,5 +43,4 @@ { return (bool)(*this < aDateObject || *this == aDateObject); } - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fsortabl.h metview-5.19.2/metview/src/libFTimeUtil/fsortabl.h --- metview-5.17.4/metview/src/libFTimeUtil/fsortabl.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fsortabl.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,16 +16,17 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif class TSortable : public TFObject { public: - virtual bool IsEqual(const TFObject& aDateObject) const = 0; virtual bool IsLessThan(const TFObject& aDateObject) const = 0; // methods as 'const', vk 940824 @@ -34,5 +35,4 @@ bool operator>=(const TSortable&) const; bool operator<=(const TSortable&) const; }; - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fstatime.cc metview-5.19.2/metview/src/libFTimeUtil/fstatime.cc --- metview-5.17.4/metview/src/libFTimeUtil/fstatime.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fstatime.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,11 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif @@ -37,12 +39,12 @@ TStaticTime ::TStaticTime(const TStaticTime& from) { - fYear = from.fYear; + fYear = from.fYear; fMonth = from.fMonth; - fDay = from.fDay; - fHour = from.fHour; - fMin = from.fMin; - fSec = from.fSec; + fDay = from.fDay; + fHour = from.fHour; + fMin = from.fMin; + fSec = from.fSec; } //__________________________________________________________________ @@ -78,12 +80,12 @@ TStaticTime& TStaticTime::operator=(const TStaticTime& from) // = { - fYear = from.fYear; + fYear = from.fYear; fMonth = from.fMonth; - fDay = from.fDay; - fHour = from.fHour; - fMin = from.fMin; - fSec = from.fSec; + fDay = from.fDay; + fHour = from.fHour; + fMin = from.fMin; + fSec = from.fSec; return *this; } //__________________________________________________________________ @@ -289,9 +291,9 @@ } void TStaticTime ::GetDate(short& year, short& month, short& day) const { - year = GetYear(); + year = GetYear(); month = GetMonth(); - day = GetDay(); + day = GetDay(); } void TStaticTime ::SetTime(const short hour, const short minute, const short sec) { @@ -301,15 +303,15 @@ } void TStaticTime ::GetTime(short& hour, short& minute, short& sec) const { - hour = GetHour(); + hour = GetHour(); minute = GetMin(); - sec = GetSec(); + sec = GetSec(); } //__________________________________________________________________ void TStaticTime ::ReadDateTime() // test function!!!! { - short y, m, d, h; + short y = 0, m = 0, d = 0, h = 0; std::cout << " Input date 'yy mm dd hh': "; std::cin >> y >> m >> d >> h; SetDate(y, m, d); @@ -380,5 +382,4 @@ #endif return oStream; } - } diff -Nru metview-5.17.4/metview/src/libFTimeUtil/fstatime.h metview-5.19.2/metview/src/libFTimeUtil/fstatime.h --- metview-5.17.4/metview/src/libFTimeUtil/fstatime.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libFTimeUtil/fstatime.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,16 +19,18 @@ #include -#include +#include #ifdef METVIEW #include "MvDate.h" #endif #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif @@ -42,8 +44,8 @@ TStaticTime(const short year, const short month, const short day); TStaticTime(const short year, const short month, const short day, const short hour, const short minute = 0, const short sec = 0); - virtual bool IsEqual(const TFObject& anotherTime) const; - virtual bool IsLessThan(const TFObject& anotherTime) const; + bool IsEqual(const TFObject& anotherTime) const override; + bool IsLessThan(const TFObject& anotherTime) const override; TStaticTime& operator=(const TStaticTime&); #ifdef METVIEW @@ -57,25 +59,43 @@ void SetTime(const short hour, const short min = 0, const short sec = 0); void GetTime(short& hour, short& min, short& sec) const; - short GetYear(void) const { return fYear; } - short GetMonth(void) const { return fMonth; } - short GetDay(void) const { return fDay; } - short GetHour(void) const { return fHour; } - short GetMin(void) const { return fMin; } - short GetSec(void) const { return fSec; } + short GetYear() const + { + return fYear; + } + short GetMonth() const + { + return fMonth; + } + short GetDay() const + { + return fDay; + } + short GetHour() const + { + return fHour; + } + short GetMin() const + { + return fMin; + } + short GetSec() const + { + return fSec; + } int dateAsInt() const; std::string timeAsString() const; // short GetLocalHour () const; const char* CharDate() const; const char* CharHhMm() const; - const char* CharValue(void) const; - const char* ShorterCharValue(void) const; + const char* CharValue() const; + const char* ShorterCharValue() const; void ReadDateTime(); // for testing - void XPrint(void) const; // for testing + void XPrint() const; // for testing void XPrint(const char* str) const; // for testing - virtual void Print(void) const; + virtual void Print() const; protected: void SetYear(const short year); @@ -84,7 +104,7 @@ void SetHour(const short hour); void SetMin(const short minute); void SetSec(const short sec); - void _setCurrent(void); + void _setCurrent(); private: short fYear; @@ -94,5 +114,4 @@ short fMin; short fSec; }; - } diff -Nru metview-5.17.4/metview/src/libMetview/Assertions.hpp metview-5.19.2/metview/src/libMetview/Assertions.hpp --- metview-5.17.4/metview/src/libMetview/Assertions.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Assertions.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -1,6 +1,6 @@ #pragma once -#include +#include // The require and ensure macros implement // the pre-conditions and post-conditions @@ -18,7 +18,7 @@ // - Eilens, "Principles of Object-Oriented Programming" -//extern "C" {void assert(int)} +// extern "C" {void assert(int)} #define require(statement) assert(statement) diff -Nru metview-5.17.4/metview/src/libMetview/bits.h metview-5.19.2/metview/src/libMetview/bits.h --- metview-5.17.4/metview/src/libMetview/bits.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/bits.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ #define SMALLOPEN "small\nopen" #define SMALLMASK "small\nmask" -static int defpix_width[2] = {pix_32_width, pix_16_width}; +static int defpix_width[2] = {pix_32_width, pix_16_width}; static int defpix_height[2] = {pix_32_height, pix_16_height}; diff -Nru metview-5.17.4/metview/src/libMetview/BufrFilterDef.h metview-5.19.2/metview/src/libMetview/BufrFilterDef.h --- metview-5.17.4/metview/src/libMetview/BufrFilterDef.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/BufrFilterDef.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,9 @@ const std::string& value(const std::string& key) const; void clear(); - //bool messageFilter(std::string& res,std::string& err) const; + // bool messageFilter(std::string& res,std::string& err) const; - //void run(); + // void run(); std::map vals_; #if 0 diff -Nru metview-5.17.4/metview/src/libMetview/BufrFilterEngine.cc metview-5.19.2/metview/src/libMetview/BufrFilterEngine.cc --- metview-5.17.4/metview/src/libMetview/BufrFilterEngine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/BufrFilterEngine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,19 +14,19 @@ #include "Tokenizer.h" #include "BufrFilterDef.h" -#include "MvKeyProfile.h" #include "BufrMetaData.h" #include "MvEccBufr.h" +#include "MvKeyProfile.h" -#include - +#include +#include #include #include #include #include "fstream_mars_fix.h" -long MvBufrValueGroup::longMissingValue_ = kBufrMissingIntValue; +long MvBufrValueGroup::longMissingValue_ = kBufrMissingIntValue; double MvBufrValueGroup::doubleMissingValue_ = kBufrMissingValue; MvBufrValueItem::MvBufrValueItem(const MvKeyValue& value, bool valueTypeKnown, const std::vector& coordCondDefs) : @@ -48,17 +48,17 @@ MvBufrValueItem::~MvBufrValueItem() = default; -//MvBufrValue::MvBufrValue(const MvKeyValue& value,MvKeyCondition* cond, bool valueTypeKnown) : -// value_(value), cond_(cond), rankCond_(0), valueTypeKnown_(valueTypeKnown), hasRank_(false) {init();} +// MvBufrValue::MvBufrValue(const MvKeyValue& value,MvKeyCondition* cond, bool valueTypeKnown) : +// value_(value), cond_(cond), rankCond_(0), valueTypeKnown_(valueTypeKnown), hasRank_(false) {init();} void MvBufrValueItem::init() { keyNameWithoutRank_ = value_.key(); if (value_.key().find("#") == 0) { - hasRank_ = true; + hasRank_ = true; keyNameWithoutRank_ = MvObs::keyWithoutOccurrenceTag(keyNameWithoutRank_); } - for (auto d : coordCondDefs_) { + for (const auto& d : coordCondDefs_) { coordConds_.push_back(nullptr); } @@ -76,12 +76,14 @@ assert(rankCond_ && rankCond_->data() == "rank"); assert(rankCond_ && hasRank_ == false); - if (rankCond_) { - if (rankCond_->data() != "rank") + if (rankCond_ != nullptr) { + if (rankCond_->data() != "rank") { throw MvException("Invalid rank condition is defined for parameter " + keyNameWithoutRank_); + } - if (hasRank_) + if (hasRank_) { throw MvException("Key name cannot contain rank! Keyname=" + value_.key()); + } } } @@ -98,19 +100,19 @@ bool st = true; for (size_t i = 0; i < coordConds_.size(); i++) { if (coordConds_[i] == nullptr) { - int eccType = obs->elementValueType(coordCondDefs_[i].key()); + int eccType = obs->elementValueType(coordCondDefs_[i].key()); MvVariant::Type type = MvVariant::LongType; - bool validType = false; + bool validType = false; if (eccType == CODES_TYPE_LONG) { - type = MvVariant::LongType; + type = MvVariant::LongType; validType = true; } else if (eccType == CODES_TYPE_DOUBLE) { - type = MvVariant::DoubleType; + type = MvVariant::DoubleType; validType = true; } else if (eccType == CODES_TYPE_STRING) { - type = MvVariant::StringType; + type = MvVariant::StringType; validType = true; } @@ -132,18 +134,14 @@ bool MvBufrValueItem::allCondsCreated() const { - for (auto item : coordConds_) { - if (item == nullptr) { - return false; - } - } - return true; + return std::all_of(coordConds_.begin(), coordConds_.end(), [](auto v) { return v != nullptr; }); } bool MvBufrValueItem::allCoordCondsMatch() const { - if (coordConds_.empty()) + if (coordConds_.empty()) { return true; + } for (auto item : coordConds_) { if (item == nullptr || !item->match()) { @@ -169,9 +167,9 @@ MvBufrValueGroup::~MvBufrValueGroup() { - for (std::size_t i = 0; i < items_.size(); i++) - if (items_[i].cond_) - delete items_[i].cond_; + for (auto& item : items_) + if (item.cond_) + delete item.cond_; } void MvBufrValueGroup::add(const MvBufrValueItem& val) @@ -227,15 +225,15 @@ return emptyVal; } -//const MvKeyValue& MvBufrValueGroup::value(const std::string& keyName) const +// const MvKeyValue& MvBufrValueGroup::value(const std::string& keyName) const //{ -// for (std::size_t i = 0; i < items_.size(); i++) { -// if (items_[i].value_.key() == keyName) -// return items_[i].value_; -// } -// static MvKeyValue emptyVal; -// return emptyVal; -//} +// for (std::size_t i = 0; i < items_.size(); i++) { +// if (items_[i].value_.key() == keyName) +// return items_[i].value_; +// } +// static MvKeyValue emptyVal; +// return emptyVal; +// } const MvBufrValueItem& MvBufrValueGroup::itemByResultIndex(int resultIndex) const { @@ -247,15 +245,15 @@ return emptyVal; } -//const MvKeyValue& MvBufrValueGroup::valueByResultIndex(int resultIndex) const +// const MvKeyValue& MvBufrValueGroup::valueByResultIndex(int resultIndex) const //{ -// for (std::size_t i = 0; i < items_.size(); i++) { -// if (items_[i].resultIndex_ == resultIndex) -// return items_[i].value_; -// } -// static MvKeyValue emptyVal; -// return emptyVal; -//} +// for (std::size_t i = 0; i < items_.size(); i++) { +// if (items_[i].resultIndex_ == resultIndex) +// return items_[i].value_; +// } +// static MvKeyValue emptyVal; +// return emptyVal; +// } void MvBufrValueGroup::setResultIndex(int idx, int resultIdx) { @@ -267,9 +265,9 @@ assert(idx >= 0 && idx < static_cast(items_.size())); if (items_[idx].valueTypeKnown_ == false) { - std::string key = items_[idx].value_.key(); + std::string key = items_[idx].value_.key(); MvVariant::Type type = items_[idx].value_.type(); - bool validType = false; + bool validType = false; if (eccType == CODES_TYPE_LONG) { validType = true; @@ -291,16 +289,16 @@ } if (validType) { - //Build the condition if there is a definition for it - if (items_[idx].cond_ == 0 && !items_[idx].condDef_.isEmpty()) { + // Build the condition if there is a definition for it + if (items_[idx].cond_ == nullptr && !items_[idx].condDef_.isEmpty()) { items_[idx].cond_ = MvKeyCondition::make(items_[idx].condDef_, items_[idx].value_.type()); } items_[idx].valueTypeKnown_ = true; - //CODES_TYPE_LONG, CODES_TYPE_DOUBLE, CODES_TYPE_STRING, - // CODES_TYPE_MISSING, CODES_TYPE_UNDEFINED + // CODES_TYPE_LONG, CODES_TYPE_DOUBLE, CODES_TYPE_STRING, + // CODES_TYPE_MISSING, CODES_TYPE_UNDEFINED } } } @@ -365,11 +363,11 @@ return checkCurrentKeyDirect(obs, idx); } - //obs->currentKey() always contains the rank. If the rank is set on the item its - //keyname contains the rank. The condition itself can never contain a rank for an item - //in a valuegroup! + // obs->currentKey() always contains the rank. If the rank is set on the item its + // keyname contains the rank. The condition itself can never contain a rank for an item + // in a valuegroup! - //the main condition + // the main condition if (items_[idx].isSameKey(obs->currentKey())) { if (items_[idx].valueTypeKnown_ == false) adjustType(idx, obs->elementValueType()); @@ -378,11 +376,11 @@ return false; std::string sVal; - long lVal = 0; - double dVal = 0; + long lVal = 0; + double dVal = 0; bool hasValue = false; - //Check rank condition + // Check rank condition if (items_[idx].rankCond_) { MvKeyCondition* rankCond = items_[idx].rankCond_; assert(rankCond->data() == "rank"); @@ -398,18 +396,18 @@ } } - //Check the condition + // Check the condition if (MvKeyCondition* cond = items_[idx].cond_) { evalCondition(cond, obs, lVal, dVal, sVal); - //if the condition does not match we reset the collected value + // if the condition does not match we reset the collected value if (!cond->match()) { items_[idx].value_.resetValue(); return true; } } - //Collect the item value + // Collect the item value switch (items_[idx].value_.type()) { case MvVariant::DoubleType: { if (!hasValue) @@ -453,24 +451,24 @@ { assert(obs); - //obs->currentKey() always contains the rank. If the rank is set on the item its - //keyname contains the rank. The condition itself can never contain a rank for an item - //in a valuegroup!! + // obs->currentKey() always contains the rank. If the rank is set on the item its + // keyname contains the rank. The condition itself can never contain a rank for an item + // in a valuegroup!! - //evaluate special coord=value/element coordinate conditions! + // evaluate special coord=value/element coordinate conditions! for (auto cond : items_[idx].coordConds_) { if (cond && cond->isEnabled()) { if (cond->key() == MvObs::keyWithoutOccurrenceTag(obs->currentKey())) { std::string sVal; - long lVal = 0; + long lVal = 0; double dVal = 0; evalCondition(cond, obs, lVal, dVal, sVal); - //std::cout << idx << " " <key() << " " << lVal << " " << dVal << std::endl; + // std::cout << idx << " " <key() << " " << lVal << " " << dVal << std::endl; } } } - //the main condition + // the main condition if (items_[idx].isSameKey(obs->currentKey())) { if (items_[idx].valueTypeKnown_ == false) adjustType(idx, obs->elementValueType()); @@ -479,11 +477,11 @@ return false; std::string sVal; - long lVal = 0; - double dVal = 0; + long lVal = 0; + double dVal = 0; bool hasValue = false; - //Check rank condition + // Check rank condition if (items_[idx].rankCond_) { MvKeyCondition* rankCond = items_[idx].rankCond_; assert(rankCond->data() == "rank"); @@ -499,11 +497,11 @@ } } - //Check the condition + // Check the condition if (MvKeyCondition* cond = items_[idx].cond_) { evalCondition(cond, obs, lVal, dVal, sVal); - //if the condition does not match we reset the collected value + // if the condition does not match we reset the collected value if (!cond->match()) { items_[idx].value_.resetValue(); return true; @@ -515,7 +513,7 @@ if (!items_[idx].allCoordCondsMatch()) return true; - //Collect the item value + // Collect the item value switch (items_[idx].value_.type()) { case MvVariant::DoubleType: { if (!hasValue) @@ -566,8 +564,8 @@ for (std::size_t i = 0; i < items_.size(); i++) { if (checkCurrentKey(obs, i)) { if (!directMode_) { - //if a given item is not collected (set) we return. A given - //item can only be collected if all the previous ones were already collected (set) + // if a given item is not collected (set) we return. A given + // item can only be collected if all the previous ones were already collected (set) if (!items_[i].value_.isSet()) return; } @@ -675,7 +673,7 @@ break; } - //all conditions must match!!! + // all conditions must match!!! if (!cond->match()) return; } @@ -948,7 +946,7 @@ lastCnt = msgData.size() - 1; for (size_t i = 0; i < msgData.size(); i++) { if (MvEccBufrMessage* msg = msgData[i]) { - //in the preFilter message indexing starts at 1 !!! + // in the preFilter message indexing starts at 1 !!! if (evalFilter(msg, i + 1)) matchVec.push_back(i); } @@ -968,20 +966,20 @@ BufrFilterEngine::BufrFilterEngine(const std::string& inFileName, FilterMode filterMode, BufrFilterEngineObserver* observer) : filterMode_(filterMode), - outBufr_(0), + outBufr_(nullptr), inFileName_(inFileName), msgCnt_(0), obsOrMsg_(NR_returnMsg), outType_(NoOutput), extractedHasRank_(false), - result_(0), + result_(nullptr), collectMode_(CollectFirst), includeMissingValue_(true), includeMissingElement_(false), - observer_(0), + observer_(nullptr), hasAttributeCondition_(false) { - inObs_ = new MvObsSet(inFileName_.c_str()); + inObs_ = new MvObsSet(inFileName_.c_str()); obsIter_ = new MvObsSetIterator(*inObs_); if (observer) setObserver(observer); @@ -1002,11 +1000,11 @@ void BufrFilterEngine::close() { - //if( outType_ == eBUFR ) + // if( outType_ == eBUFR ) if (outBufr_) outBufr_->close(); - //else - // _outFile.close(); + // else + // _outFile.close(); } @@ -1022,7 +1020,7 @@ void BufrFilterEngine::run(const BufrFilterDef& def, const std::string& resFileName, MvKeyProfile* resProf, int totalMsgNum, const std::vector& msgVec) { - //msgData=0; + // msgData=0; if (observer_) { assert(totalMsgNum > 0); @@ -1054,15 +1052,15 @@ std::vector preFilterMatch; int lastCheckedCnt = 0; - bool doPreFilter = (!msgVec.empty() && preFilter_.isEnabled()); + bool doPreFilter = (!msgVec.empty() && preFilter_.isEnabled()); //--------------------------------------------------------- // See if we can use the scanned messages - aka preFilter! //--------------------------------------------------------- if (doPreFilter) { - //We interrupt filter eval at the first NULL message (the message list might not be - //fully scanned since the scan is running in a separate thread!!!) + // We interrupt filter eval at the first NULL message (the message list might not be + // fully scanned since the scan is running in a separate thread!!!) preFilter_.evalFilter(msgVec, preFilterMatch, lastCheckedCnt); } @@ -1070,7 +1068,7 @@ // Filter only by headers //---------------------------------------------- if (obsOrMsg_ == NR_returnMsg) { - //Using prefilter + // Using prefilter for (int cnt : preFilterMatch) { currentObs_ = obsIter_->gotoMessage(msgVec[cnt]->offset(), cnt + 1); if (obsIter_->AcceptedObs(currentObs_, true)) @@ -1084,19 +1082,19 @@ bool allChecked = doPreFilter && lastCheckedCnt == static_cast(msgVec.size()) - 1; if (!allChecked) { - //If he had prefilter get the next message after the last checked position + // If he had prefilter get the next message after the last checked position if (doPreFilter) { - //If he had prefilter get the next message after the last checked position - int cnt = lastCheckedCnt; + // If he had prefilter get the next message after the last checked position + int cnt = lastCheckedCnt; currentObs_ = obsIter_->gotoMessage(msgVec[cnt]->offset(), cnt + 1); } - //Otherwise we start the scan from the first message + // Otherwise we start the scan from the first message else { currentObs_ = obsIter_->nextMessage(); } - //Check the rest of the messages + // Check the rest of the messages while (currentObs_) { if (obsIter_->AcceptedObs(currentObs_, false)) filterOne(); @@ -1105,7 +1103,7 @@ if (currentNum % progStep == 0) progress(currentNum); - //get next message + // get next message currentObs_ = obsIter_->nextMessage(); } } @@ -1118,7 +1116,7 @@ for (int cnt : preFilterMatch) { currentObs_ = obsIter_->gotoMessage(msgVec[cnt]->offset(), cnt + 1); - //iterate through the susbsets + // iterate through the susbsets while (currentObs_) { bool match = false; if ((match = obsIter_->AcceptedObs(currentObs_, true))) @@ -1138,19 +1136,19 @@ bool allChecked = doPreFilter && lastCheckedCnt == static_cast(msgVec.size()) - 1; if (!allChecked) { - //If he had prefilter get the next message after the last checked position + // If he had prefilter get the next message after the last checked position if (doPreFilter) { - int cnt = lastCheckedCnt; + int cnt = lastCheckedCnt; currentObs_ = obsIter_->gotoMessage(msgVec[cnt]->offset(), cnt + 1); } - //Otherwise we start the scan from the first message + // Otherwise we start the scan from the first message else { currentObs_ = obsIter_->nextMessage(); } bool headerDidNotMatch = false; - //Check the rest of the messages + // Check the rest of the messages while (currentObs_) { bool match = false; if ((match = obsIter_->AcceptedObs(currentObs_, false, headerDidNotMatch))) { @@ -1164,7 +1162,7 @@ writeCompressed(¤tObs_); - //get the next message + // get the next message currentObs_ = obsIter_->nextMessage(); } } @@ -1175,9 +1173,9 @@ } catch (std::exception& e) { - //marslog( LOG_WARN, "ObsFilter: %s", e.what() ); - //if( failOnError_ ) - //throw MvException( "ObsFilter failed" ); + // marslog( LOG_WARN, "ObsFilter: %s", e.what() ); + // if( failOnError_ ) + // throw MvException( "ObsFilter failed" ); } } @@ -1187,7 +1185,7 @@ return; bool didExtract = false; - int collectCnt = 0; + int collectCnt = 0; extracted_.reset(); location_.reset(); coordCond_.reset(); @@ -1196,21 +1194,21 @@ MvObs* obs = ¤tObs_; MvObs subsetObs; - //Subsets + // Subsets if (currentObs_.msgSubsetCount() > 1) { - //Uncompressed data + // Uncompressed data if (!currentObs_.compressData()) { int currentSubset = currentObs_.subsetNumber(); - subsetObs = currentObs_.cloneSubset(currentSubset); - obs = &subsetObs; + subsetObs = currentObs_.cloneSubset(currentSubset); + obs = &subsetObs; } } - //Check custom condition - it is only a message/subset filter condition, - //but it is not yet implemented in the bufr itartor so we need to - //do it here + // Check custom condition - it is only a message/subset filter condition, + // but it is not yet implemented in the bufr itartor so we need to + // do it here if (!customCond_.isEmpty()) { - //We have to make sure the message is upacked + // We have to make sure the message is upacked obs->setFirstDescriptor(); customCond_.checkConditions(obs); if (!customCond_.match()) { @@ -1219,7 +1217,7 @@ } } - //we need to extract values + // we need to extract values if (outType_ != BufrOutput) { assert(!extracted_.isEmpty()); @@ -1231,14 +1229,14 @@ } } - //If we do not do it we will have a crash + // If we do not do it we will have a crash currentObs_.clearIterator(); - //In GUI mode we always create a new bufr file containing only the messages/subsets matching the filter + // In GUI mode we always create a new bufr file containing only the messages/subsets matching the filter if ((filterMode_ == GuiMode && (outType_ == BufrOutput || didExtract)) || outType_ == BufrOutput) { assert(outBufr_); - //first time + // first time if (msgCnt_ == 0) { //-- changed 2011-12-30/vk: //-- o target BUFR file is set to contain single subsets, but this is in effect @@ -1249,19 +1247,19 @@ outBufr_->setSubsetMax(1); //-- obs_.msgSubsetCount() ); } - //If filtering requires values from data section then multisubset - //messages have to be filtered on observation (subset) level! + // If filtering requires values from data section then multisubset + // messages have to be filtered on observation (subset) level! - //filtering with header only i.e. write the whole message! + // filtering with header only i.e. write the whole message! if (obsOrMsg_ == NR_returnMsg) { outBufr_->write(currentObs_); - //msgCnt_ += currentObs_.msgSubsetCount(); + // msgCnt_ += currentObs_.msgSubsetCount(); msgCnt_++; } - //filtering also with data values, write current subset only! + // filtering also with data values, write current subset only! else { if (obs->msgSubsetCount() > 1 && obs->compressData()) { - //outBufr_->writeCompressed(obs); + // outBufr_->writeCompressed(obs); filteredSubSets_.push_back(currentObs_.subsetNumber()); } else { @@ -1295,19 +1293,19 @@ // initialise caching for compressed data initCompressedCache(obs); - //this force data to be expanded + // this force data to be expanded bool cont = obs->setFirstDescriptor(); - //We iterate through the keys + // We iterate through the keys while (cont) { //------------------------------------------------------------------------------ - //We only filter by extracted conditions. No coordinate conditions are defined. + // We only filter by extracted conditions. No coordinate conditions are defined. //------------------------------------------------------------------------------ if (coordCond_.isEmpty()) { extracted_.checkCurrentKey(obs); location_.checkCurrentKey(obs); - //if all the values are collected and all the conditions match + // if all the values are collected and all the conditions match if (extracted_.isAllValueSet()) { addToResult(obs, coordCond_); extracted_.reset(); @@ -1317,7 +1315,7 @@ } //------------------------------------------------------------------------------ - //Has coordinate conditions + // Has coordinate conditions //------------------------------------------------------------------------------ else if (!coordCond_.isEmpty()) { if (coordCond_.match()) { @@ -1351,19 +1349,19 @@ { assert(directMode_ == true); - //this force data to be expanded + // this force data to be expanded bool cont = obs->setFirstDescriptor(); - //adjust(=create) all the conditions directly set on keys + // adjust(=create) all the conditions directly set on keys extracted_.adjustConditions(obs); - //We iterate through the keys + // We iterate through the keys while (cont) { if (coordCond_.isEmpty()) { extracted_.checkCurrentKey(obs); location_.checkCurrentKey(obs); - //if all the values are collected and all the conditions match + // if all the values are collected and all the conditions match if (extracted_.isAllValueSet()) { break; } @@ -1399,7 +1397,7 @@ void BufrFilterEngine::addToResult(MvObs* obs, const MvBufrConditionGroup& coordCond) { assert(result_); - //MvLocation locData=obs->location(); + // MvLocation locData=obs->location(); TStaticTime timeData = obs->obsTime(); for (std::size_t i = 0; i < result_->size(); i++) { @@ -1410,9 +1408,9 @@ int idx = rk->valueNum(); rk->addIntValue(idx + 1); } - //The message index (starts from 1) in the filtered messages + // The message index (starts from 1) in the filtered messages else if (rk->role() == MvKey::MessageIndexRole) { - //rk->addIntValue(obsIter_->currentMessageNumber()); + // rk->addIntValue(obsIter_->currentMessageNumber()); rk->addIntValue(msgCnt_ + 1); } else if (rk->role() == MvKey::SubsetIndexRole) { @@ -1439,10 +1437,10 @@ else { MvVariant::Type type = MvVariant::NoType; - //Coordinates + // Coordinates if (rk->role() == MvKey::LevelRole) type = coordCond.item(name).value().type(); - //extracted values + // extracted values else type = extracted_.itemByResultIndex(i).value().type(); @@ -1489,7 +1487,7 @@ { for (size_t i = 0; i < result_->size(); i++) { MvKey* rkA = result_->at(i); - int cnt = 1; + int cnt = 1; for (size_t j = i + 1; j < result_->size(); j++) { MvKey* rkB = result_->at(j); if (rkA->name() == rkB->name()) { @@ -1520,7 +1518,8 @@ if (format == "GEOPOINTS") { out << "#"; dataColNum = 1; - } else if (format == "POLAR_VECTOR" || format == "XY_VECTOR") { + } + else if (format == "POLAR_VECTOR" || format == "XY_VECTOR") { out << "#FORMAT " << format << std::endl << "#"; dataColNum = 2; @@ -1559,24 +1558,24 @@ int cnt = result_->valueNum(); for (int i = 0; i < cnt; i++) { - //Using this style caused a crash: - //out << ((keys[2])?keys[2]->valueAsString(i):"0") + // Using this style caused a crash: + // out << ((keys[2])?keys[2]->valueAsString(i):"0") out << outputToString(keys[0], i) << mySeparator << outputToString(keys[1], i) << mySeparator; - //level + // level if (keys[2]) out << outputToString(keys[2], i) << mySeparator; else out << "0" << mySeparator; - //date + // date if (keys[3]) out << outputToString(keys[3], i) << mySeparator; else out << "0" << mySeparator; - //time + // time if (keys[4]) out << toGeopointsTime(keys[4]->valueAsString(i)) << mySeparator; else @@ -1634,40 +1633,40 @@ int cnt = result_->valueNum(); for (int i = 0; i < cnt; i++) { - //Using this style caused a crash: - //out << ((keys[2])?keys[2]->valueAsString(i):"0") + // Using this style caused a crash: + // out << ((keys[2])?keys[2]->valueAsString(i):"0") - //station id + // station id if (keys[0]) out << metview::stationIdForWritingToFile(keys[0]->valueAsString(i)) << mySeparator; else out << "?" << mySeparator; - //lat + // lat out << outputToString(keys[1], i) << mySeparator; - //lon + // lon out << outputToString(keys[2], i) << mySeparator; - //level + // level if (keys[3]) out << outputToString(keys[3], i) << mySeparator; else out << "0" << mySeparator; - //date + // date if (keys[4]) out << outputToString(keys[4], i) << mySeparator; else out << "0" << mySeparator; - //time + // time if (keys[5]) out << toGeopointsTime(keys[5]->valueAsString(i)) << mySeparator; else out << "0" << mySeparator; - //the rest + // the rest for (int j = 6; j < nkeys; j++) { out << outputToString(keys[j], i); if (j < nkeys - 1) { @@ -1682,7 +1681,7 @@ std::string BufrFilterEngine::outputToString(MvKey* key, int i) const { - static std::string missingVal("3.0E+38"); //GEOPOINTS_MISSING_VALUE"); + static std::string missingVal("3.0E+38"); // GEOPOINTS_MISSING_VALUE"); if (key) { if (key->valueType() == MvKey::DoubleType) { if (key->isMissingValueDefined() && key->doubleValue()[i] == key->doubleMissingValue()) @@ -1716,10 +1715,10 @@ assert(result_); const char mySeparator = ','; - int rowNum = result_->valueNum(); - size_t keyNum = result_->size(); + int rowNum = result_->valueNum(); + size_t keyNum = result_->size(); - //Header + // Header for (size_t key = 0; key < keyNum; key++) { out << result_->at(key)->name(); if (key != keyNum - 1) @@ -1728,7 +1727,7 @@ out << std::endl; } - //Data rows + // Data rows for (int row = 0; row < rowNum; row++) { for (size_t key = 0; key < keyNum; key++) { out << result_->at(key)->valueAsString(row); @@ -1748,11 +1747,11 @@ const std::string& valueKey, MvKeyConditionDefinition& condDef) { if (!oper.empty()) { - //At this point we do not know the type of the parameter, so we - //assume it is floating point value. We will determine the - //real type from the data for the first time we have a - //value to read and readjust the type of the param and that of the - //conditions. + // At this point we do not know the type of the parameter, so we + // assume it is floating point value. We will determine the + // real type from the data for the first time we have a + // value to read and readjust the type of the param and that of the + // conditions. std::vector vals; getStringValues(valueKey, valueKey, vals); if (!vals.empty()) @@ -1762,16 +1761,16 @@ void BufrFilterEngine::buildKeyCoordConditionDefs(const std::string& nameIn, std::string& keyName, std::vector& conds, bool& needConditionInOutput) { - //We do not know the type of the parameter at this point, we set it to string + // We do not know the type of the parameter at this point, we set it to string std::vector tmpVec; - std::size_t pos; + std::size_t pos = 0; std::string name = nameIn; pos = nameIn.find("[s]"); if (pos != std::string::npos) { if (pos == name.length() - 3) { needConditionInOutput = true; - name = nameIn.substr(0, pos); + name = nameIn.substr(0, pos); } else { throw MvException("Invalid column name=" + nameIn); @@ -1801,7 +1800,7 @@ for (size_t i = 0; i < tmpVec.size() - 1; i++) { std::string cond = tmpVec[i]; std::vector present; - for (auto it : opers) { + for (const auto& it : opers) { if (cond.find(it.first) != std::string::npos) { present.push_back(it.first); } @@ -1841,7 +1840,7 @@ void BufrFilterEngine::getOutputOptions() { - //Get the output type + // Get the output type std::string val = value("EXTRACT"); if (val.empty()) { throw MvException("No output type is specified"); @@ -1849,7 +1848,7 @@ std::string outputFormat = value("OUTPUT", false); - //No extraction + // No extraction if (val == "OFF") { outType_ = BufrOutput; return; @@ -1858,7 +1857,7 @@ outType_ = CsvOutput; } - //Missing data handling + // Missing data handling std::string missing = value("MISSING_DATA"); if (missing == "IGNORE") includeMissingValue_ = false; @@ -1867,7 +1866,7 @@ extracted_.setIncludeMissingValue(includeMissingValue_); - //Missing element handling + // Missing element handling std::string missingElem = value("MISSING_ELEMENT", false); if (missingElem == "IGNORE") includeMissingElement_ = false; @@ -1881,16 +1880,16 @@ values("COLUMNS", columnVec, ":"); if (!columnVec.empty() && columnVec[0] != "ANY") { directMode_ = true; - for (auto colName : columnVec) { + for (const auto& colName : columnVec) { std::string keyName; std::vector condDefs; bool needConditionInOutput = false; buildKeyCoordConditionDefs(colName, keyName, condDefs, needConditionInOutput); - //A condition is defined but we do not know its type (we only have - //the definition) - //We do not know the type of the parameter at this point, we set it to long - for (auto cdef : condDefs) { + // A condition is defined but we do not know its type (we only have + // the definition) + // We do not know the type of the parameter at this point, we set it to long + for (const auto& cdef : condDefs) { MvKeyValue cdKeyVal(cdef.key(), MvVariant::LongType); MvBufrValueItem bval(cdKeyVal, false); bval.setCollectable(false); @@ -1912,16 +1911,16 @@ extracted_.setDirectMode(directMode_); if (!directMode_) { - //Get the mumber of parameters + // Get the mumber of parameters int parCnt = 0; intValue("PARAMETER_COUNT", "parameterCount", 1, parCnt); - //The paremeters to extract (with their conditions) + // The paremeters to extract (with their conditions) for (int i = 0; i < parCnt; i++) { MvKeyConditionDefinition condDef; - std::string parKey = value("PARAMETER_" + std::to_string(i + 1)); - std::string parOper = value("PARAMETER_OPERATOR_" + std::to_string(i + 1)); + std::string parKey = value("PARAMETER_" + std::to_string(i + 1)); + std::string parOper = value("PARAMETER_OPERATOR_" + std::to_string(i + 1)); std::string parValueKey = "PARAMETER_VALUE_" + std::to_string(i + 1); if (parKey.find("->") != std::string::npos) @@ -1930,39 +1929,39 @@ std::string parRank; if (getRank("PARAMETER_RANK_" + std::to_string(i + 1), parRank)) { extractedHasRank_ = true; - parKey = "#" + parRank + "#" + parKey; + parKey = "#" + parRank + "#" + parKey; } buildConditionDef(parKey, parOper, parValueKey, condDef); - //We do not know the type of the parameter at this point, we set it to string + // We do not know the type of the parameter at this point, we set it to string MvKeyValue kVal(parKey, MvVariant::StringType); - //A condition is defined but we do not know its type (we only have - //the definition) + // A condition is defined but we do not know its type (we only have + // the definition) if (!condDef.isEmpty()) { extracted_.add(MvBufrValueItem(kVal, condDef, false)); } - //There is no condition + // There is no condition else { extracted_.add(MvBufrValueItem(kVal, false)); } } - //The coordinate conditions + // The coordinate conditions int coordCnt = 0; intValue("COORDINATE_COUNT", "coordKeyCount", 0, coordCnt); for (int i = 0; i < coordCnt; i++) { - std::string coordKey = value("COORDINATE_" + std::to_string(i + 1)); - std::string coordOper = value("COORDINATE_OPERATOR_" + std::to_string(i + 1)); + std::string coordKey = value("COORDINATE_" + std::to_string(i + 1)); + std::string coordOper = value("COORDINATE_OPERATOR_" + std::to_string(i + 1)); std::string coordValueKey = "COORDINATE_VALUE_" + std::to_string(i + 1); if (coordKey.find("->") != std::string::npos) hasAttributeCondition_ = true; - //The rank for a coordinate can be a list!!! + // The rank for a coordinate can be a list!!! std::vector coordRanks; - MvKeyCondition* rankCond = 0; + MvKeyCondition* rankCond = nullptr; if (getRanks("COORDINATE_RANK_" + std::to_string(i + 1), coordRanks)) { if (coordRanks.size() == 1) { coordKey = "#" + std::to_string(coordRanks[0]) + "#" + coordKey; @@ -1970,29 +1969,29 @@ else { assert(coordRanks.size() > 1); std::vector vv = MvVariant::makeVector(coordRanks); - rankCond = MvKeyCondition::make("RANK", coordKey, vv); + rankCond = MvKeyCondition::make("RANK", coordKey, vv); if (rankCond) rankCond->setData("rank"); } } - //We do not know the type of the parameter at this point, we set it to string + // We do not know the type of the parameter at this point, we set it to string MvKeyValue kVal(coordKey, MvVariant::StringType); - //The condition - //MvKeyCondition *cond=0; + // The condition + // MvKeyCondition *cond=0; MvKeyConditionDefinition condDef; buildConditionDef(coordKey, coordOper, coordValueKey, condDef); - //A condition is defined but we do not know its type (we only have - //the definition) + // A condition is defined but we do not know its type (we only have + // the definition) if (!condDef.isEmpty()) { MvBufrValueItem bval(kVal, condDef, false); if (rankCond) bval.setRankCondition(rankCond); coordCond_.add(bval); } - //There is no condition. We just need the existence of the coordinate. + // There is no condition. We just need the existence of the coordinate. else { MvBufrValueItem bval(kVal, false); if (rankCond) @@ -2019,7 +2018,7 @@ location_.add(MvBufrValueItem(latVal, false)); location_.add(MvBufrValueItem(lonVal, false)); - MvKey* mvk = 0; + MvKey* mvk = nullptr; #if 0 mvk=new MvKey("index","#"); @@ -2063,10 +2062,10 @@ mvk->setValuePrecision(2); result_->addKey(mvk); - //Add coordinates to result + // Add coordinates to result if (value("EXTRACT_COORDINATE") == "ON") { - //At this point we do not know the the type of these params. We set them to - //double and will adjust them on first read + // At this point we do not know the the type of these params. We set them to + // double and will adjust them on first read for (std::size_t i = 0; i < coordCond_.size(); i++) { mvk = new MvKey(coordCond_.item(i).value().key(), coordCond_.item(i).value().key()); mvk->setRole(MvKey::LevelRole); @@ -2077,7 +2076,7 @@ } } - //Add date/time to result + // Add date/time to result if (value("EXTRACT_DATE") == "ON") { mvk = new MvKey("date", "date"); mvk->setRole(MvKey::DateRole); @@ -2090,8 +2089,8 @@ result_->addKey(mvk); } - //At this point we do not know the the type of these params. We set them to - //double and will adjust them on first read + // At this point we do not know the the type of these params. We set them to + // double and will adjust them on first read for (std::size_t i = 0; i < extracted_.size(); i++) { mvk = new MvKey(extracted_.item(i).label(), extracted_.item(i).label()); mvk->setValueType(MvKey::DoubleType); @@ -2101,7 +2100,7 @@ result_->addKey(mvk); } - //We need data from the data section + // We need data from the data section obsOrMsg_ = NR_returnObs; } } @@ -2121,14 +2120,14 @@ { std::vector vals; - //Edition + // Edition getIntValues("EDITION", "edition", 1, vals); for (int val : vals) { obsIter_->setEditionNumber(val); preFilter_.setEditionNumber(val); } - //Centre - can be int or string + // Centre - can be int or string vals.clear(); if (isKeyValueNumber("CENTRE")) { getIntValues("CENTRE", "Centre", 0, vals); @@ -2146,7 +2145,7 @@ } } - //SubCentre + // SubCentre vals.clear(); getIntValues("SUBCENTRE", "subCentre", 0, vals); for (int val : vals) { @@ -2154,7 +2153,7 @@ preFilter_.setOriginatingSubCentre(val); } - //Master table version + // Master table version vals.clear(); getIntValues("MASTERTABLE", "masterTable", 0, vals); for (int val : vals) { @@ -2162,7 +2161,7 @@ preFilter_.setMasterTableVersion(val); } - //Local table version + // Local table version vals.clear(); getIntValues("LOCALTABLE", "localTable", 0, vals); for (int val : vals) { @@ -2175,14 +2174,14 @@ { std::vector vals; - //Types + // Types getIntValues("DATA_TYPE", "dataCategory", 1, vals); for (int val : vals) { obsIter_->setMessageType(val); preFilter_.setMessageType(val); } - //SubTypes + // SubTypes vals.clear(); getIntValues("DATA_SUBTYPE", "dataSubCategory", 1, vals); for (int val : vals) { @@ -2190,7 +2189,7 @@ preFilter_.setMessageSubType(val); } - //RdbTypes + // RdbTypes vals.clear(); getIntValues("RDB_TYPE", "rdbType", 1, vals); for (int val : vals) { @@ -2218,11 +2217,11 @@ } else if (keyName == "wmo_station_id") { for (auto& val : vals) { - //1000*blockNumber+stationNumber; + // 1000*blockNumber+stationNumber; obsIter_->setWmoStation(atoi(val.c_str())); } - //It is taken from the data section + // It is taken from the data section obsOrMsg_ = NR_returnObs; } else { @@ -2231,7 +2230,7 @@ obsIter_->setIdentValue(val); } - //It is taken from the data section + // It is taken from the data section obsOrMsg_ = NR_returnObs; } } @@ -2241,7 +2240,7 @@ std::string mode = value("DATEMODE"); std::string err; - //Time window + // Time window if (mode == "WINDOW") { int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0; std::string dateVal = value("DATE"); @@ -2259,7 +2258,7 @@ } std::string winVal = value("WINDOW_IN_MINUTES"); - int winSec = -1; + int winSec = -1; if (parseTimeWindow(winVal, winSec, err) == false) { throw MvException("Paramater Window:
" + err); } @@ -2267,16 +2266,16 @@ bool hasDate = (!dateVal.empty()); bool hasTime = (!timeVal.empty()); - //Has date and time + // Has date and time if (hasDate && hasTime) { TDynamicTime dt(year, month, day, hour, minute, second); - //TODO: make it work for seconds!!! Currently only takes minutes + // TODO: make it work for seconds!!! Currently only takes minutes obsIter_->setTimeRange(dt, winSec / 60); obsOrMsg_ = NR_returnObs; } - //Only has time + // Only has time else if (!hasDate && hasTime) { int t = hour * 3600 + minute * 60 + second; obsIter_->setTimeRangeInSecWithoutDate(t - winSec, t + winSec); @@ -2295,9 +2294,9 @@ } #endif } - } //end window mode + } // end window mode - //Period mode + // Period mode else { int year1 = 0, month1 = 0, day1 = 0, hour1 = 0, minute1 = 0, second1 = 0; int year2 = 0, month2 = 0, day2 = 0, hour2 = 0, minute2 = 0, second2 = 0; @@ -2336,7 +2335,7 @@ bool hasDate2 = (!dateVal2.empty()); bool hasTime2 = (!timeVal2.empty()); - //Has date and time + // Has date and time if (hasDate1 && hasDate2 && hasTime1 && hasTime2) { TDynamicTime dt1(year1, month1, day1, hour1, minute1, second1); TDynamicTime dt2(year2, month2, day2, hour2, minute2, second2); @@ -2344,7 +2343,7 @@ obsIter_->setTimeRange(dt1, dt2); obsOrMsg_ = NR_returnObs; } - //only dates, no times + // only dates, no times else if (hasDate1 && hasDate2 && !hasTime1 && !hasTime2) { TDynamicTime dt1(year1, month1, day1); TDynamicTime dt2(year2, month2, day2, 23, 59, 59); @@ -2352,9 +2351,9 @@ obsIter_->setTimeRange(dt1, dt2); obsOrMsg_ = NR_returnObs; } - //only times, no dates + // only times, no dates else if (!hasDate1 && !hasDate2 && hasTime1 && hasTime2) { - //TODO should be also supported!!! + // TODO should be also supported!!! throw MvException("Period is not speficied properly."); } else if (!hasDate1 && !hasDate2 && !hasTime1 && !hasTime2) { @@ -2365,7 +2364,7 @@ } } - obsIter_->useObsTime(true); //always use data + obsIter_->useObsTime(true); // always use data } void BufrFilterEngine::getAreaOptions() @@ -2399,7 +2398,7 @@ MvLocation c2(s, e); obsIter_->setArea(c1, c2); - //It is taken from the data section + // It is taken from the data section obsOrMsg_ = NR_returnObs; } } @@ -2412,10 +2411,10 @@ intValue("CUSTOM_COUNT", "customKeyCount", 0, customCnt); for (int i = 0; i < customCnt; i++) { - std::string customKey = value("CUSTOM_KEY_" + std::to_string(i + 1)); - std::string customOper = value("CUSTOM_OPERATOR_" + std::to_string(i + 1)); + std::string customKey = value("CUSTOM_KEY_" + std::to_string(i + 1)); + std::string customOper = value("CUSTOM_OPERATOR_" + std::to_string(i + 1)); std::string customValueKey = "CUSTOM_VALUE_" + std::to_string(i + 1); - std::string customValue = value(customValueKey); + std::string customValue = value(customValueKey); if (customOper.empty()) throw MvException("Invalid operator is specified for custom condition " + customKey); @@ -2431,25 +2430,25 @@ customKey = "#" + customRank + "#" + customKey; } - //We do not know the type of the parameter at this point, we set it to string + // We do not know the type of the parameter at this point, we set it to string MvKeyValue kVal(customKey, MvVariant::StringType); MvKeyConditionDefinition condDef; buildConditionDef(customKey, customOper, customValueKey, condDef); - //A condition is defined but we do not know its type (we only have - //the definition) + // A condition is defined but we do not know its type (we only have + // the definition) if (!condDef.isEmpty()) { customCond_.add(MvBufrValueItem(kVal, condDef, false)); } - //There is no condition + // There is no condition else { throw MvException("Invalid custom condition for customKey_" + std::to_string(i + 1)); } } - //We need data from the data section + // We need data from the data section if (customCnt > 0) obsOrMsg_ = NR_returnObs; } @@ -2594,8 +2593,8 @@ std::vector tmpVec; Tokenizer parseV(separator); parseV(v, tmpVec); - for (std::size_t i = 0; i < tmpVec.size(); i++) { - valueVec.push_back(metview::simplified(tmpVec[i])); + for (auto& i : tmpVec) { + valueVec.push_back(metview::simplified(i)); } } } @@ -2675,9 +2674,9 @@ return true; if (val.size() == 8) { - year = metview::fromString(val.substr(0, 4)); + year = metview::fromString(val.substr(0, 4)); month = metview::fromString(val.substr(4, 2)); - day = metview::fromString(val.substr(6, 2)); + day = metview::fromString(val.substr(6, 2)); if (year < 1000 || year > 9999) { err = "Invalid year specified: " + std::to_string(year) + ""; @@ -2707,34 +2706,34 @@ if (inVal.empty()) return true; - hour = -1; + hour = -1; minute = -1; second = -1; std::string val = inVal; - //hmmss + // hmmss if (val.size() == 5) val = "0" + val; - //hhmm + // hhmm else if (val.size() == 4) val = val + "00"; - //hmm + // hmm else if (val.size() == 3) val = "0" + val + "00"; - //hh + // hh else if (val.size() == 2) val = val + "0000"; - //h + // h else if (val.size() == 1) val = "0" + val + "0000"; - //invalid len + // invalid len else if (val.size() != 6) { err = "Invalid time: " + metview::toBold(val) + " Time can only contain up to 6 digits!"; return false; } - hour = metview::fromString(val.substr(0, 2)); + hour = metview::fromString(val.substr(0, 2)); minute = metview::fromString(val.substr(2, 2)); second = metview::fromString(val.substr(4, 2)); if (!checkHour(hour, err)) @@ -2817,10 +2816,10 @@ std::string BufrFilterEngine::toGeopointsTime(const std::string& tval) const { - //time is in HH:MM:SS format originally + // time is in HH:MM:SS format originally if (tval.size() == 8) // && tval[2] == ":" && tval[5] == ":") { return tval.substr(0, 2) + tval.substr(3, 2); } - return std::string("0000"); + return {"0000"}; } diff -Nru metview-5.17.4/metview/src/libMetview/BufrFilterEngine.h metview-5.19.2/metview/src/libMetview/BufrFilterEngine.h --- metview-5.17.4/metview/src/libMetview/BufrFilterEngine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/BufrFilterEngine.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ class MvKeyValue { public: - MvKeyValue() {} + MvKeyValue() = default; MvKeyValue(const std::string& key, MvVariant::Type type) : key_(key), value_(type) {} @@ -60,7 +60,7 @@ friend class MvBufrValueGroup; public: - MvBufrValueItem() {} + MvBufrValueItem() = default; MvBufrValueItem(const MvKeyValue& value, bool valueTypeKnown, const std::vector& coordCondDefs = std::vector()); MvBufrValueItem(const MvKeyValue& value, const MvKeyConditionDefinition& condDef, bool valueTypeKnown, const std::vector& coordCondDefs = std::vector()); ~MvBufrValueItem(); @@ -100,7 +100,7 @@ class MvBufrValueGroup { public: - MvBufrValueGroup() {} + MvBufrValueGroup() = default; ~MvBufrValueGroup(); static long longMissingValue_; @@ -142,11 +142,11 @@ MvBufrConditionGroup() : allMatch_(true) {} - virtual void add(const MvBufrValueItem&); + void add(const MvBufrValueItem&) override; bool match() const { return allMatch_; } - void checkCurrentKey(MvObs*); + void checkCurrentKey(MvObs*) override; void checkConditions(MvObs*); - void reset(); + void reset() override; bool valuesDiffer(const MvBufrConditionGroup& o) const; protected: @@ -158,14 +158,14 @@ class MvBufrStandardGroup : public MvBufrValueGroup { public: - MvBufrStandardGroup() {} + MvBufrStandardGroup() = default; void checkCurrentKey(MvObs*); }; class BufrFilterEngineObserver { public: - BufrFilterEngineObserver() {} + BufrFilterEngineObserver() = default; virtual void notifyBufrFilterProgress(int) = 0; }; @@ -204,7 +204,7 @@ bool evalMsgRdbType(MvEccBufrMessage* msg) const; bool enabled_; - std::vector messageNumber_; //starts at 1 + std::vector messageNumber_; // starts at 1 std::vector editionNumber_; std::vector originatingCentre_; std::vector originatingCentreStr_; @@ -233,7 +233,7 @@ const std::string& value(const std::string& key, bool mustExist = true) const; void values(const std::string& key, std::vector& valueVec, const std::string& separator = "/") const; bool isExtractedDefined() const; - void run(const BufrFilterDef& def, const std::string& resFileName, MvKeyProfile* result, + void run(const BufrFilterDef& def, const std::string& resFileName, MvKeyProfile* resProf, int totalMsgNum, const std::vector&); void runWithBufrData(const BufrFilterDef& def, const std::string& resFileName, MvKeyProfile* resProf, @@ -247,8 +247,8 @@ void toCsv(const std::string& fName); protected: - //NR_returnObs /**< - return the next available subset (from this or the next BUFR msg */ - //NR_returnMsg /**< - return the first subset from the next BUFR message */ + // NR_returnObs /**< - return the next available subset (from this or the next BUFR msg */ + // NR_returnMsg /**< - return the first subset from the next BUFR message */ enum CollectMode { diff -Nru metview-5.17.4/metview/src/libMetview/BufrLocationCollector.cc metview-5.19.2/metview/src/libMetview/BufrLocationCollector.cc --- metview-5.17.4/metview/src/libMetview/BufrLocationCollector.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/BufrLocationCollector.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,11 +19,11 @@ { assert(prof_); - msgKey_ = prof->key(MvKey::MessageIndexRole); + msgKey_ = prof->key(MvKey::MessageIndexRole); subsetKey_ = prof->key(MvKey::SubsetIndexRole); - rankKey_ = prof->key(MvKey::RankRole); - latKey_ = prof->key(MvKey::LatitudeRole); - lonKey_ = prof->key(MvKey::LongitudeRole); + rankKey_ = prof->key(MvKey::RankRole); + latKey_ = prof->key(MvKey::LatitudeRole); + lonKey_ = prof->key(MvKey::LongitudeRole); assert(msgKey_); assert(subsetKey_); diff -Nru metview-5.17.4/metview/src/libMetview/BufrMetaData.cc metview-5.19.2/metview/src/libMetview/BufrMetaData.cc --- metview-5.17.4/metview/src/libMetview/BufrMetaData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/BufrMetaData.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,8 +7,6 @@ ***************************** LICENSE END *************************************/ -#include - #include #include #include @@ -24,8 +22,8 @@ #include "MvKeyProfile.h" #include "MvMiscellaneous.h" #include "MvEccBufr.h" +#include "MvKeyProfile.h" #include "MvTmpFile.h" -#include "MvWindef.h" #include "eccodes.h" @@ -100,7 +98,7 @@ out << cbuf; } - int ret = pclose(in); + int ret = pclose(in); exitCode = WEXITSTATUS(ret); if (!(in = fopen(tmpFile.path().c_str(), "r"))) { @@ -147,18 +145,20 @@ GuiLog().task() << "Filtering out message: " << msgCnt << GuiLog::commandKey() << cmd; - //Run the command - std::stringstream in, err; + // Run the command + std::stringstream in; + std::stringstream err; bool hasError = false; - int exitCode; + int exitCode = 0; std::stringstream shellErr; bool ret = shellCommand(cmd, in, err, shellErr, exitCode); if (exitCode > 0) { hasError = true; GuiLog().error() << "Command exited with code: " << exitCode; - if (err.str().empty()) + if (err.str().empty()) { errOut += "Command" + cmd + " exited with code: " + std::to_string(exitCode) + " "; + } } if (!ret) { @@ -167,7 +167,7 @@ errOut += shellErr.str(); } - //Get stderr of command + // Get stderr of command if (!err.str().empty()) { hasError = true; GuiLog().error() << err.str(); @@ -185,7 +185,7 @@ GuiLog().task() << "Filtering out subset: " << subsetCnt << " from message: " << msgCnt << GuiLog::commandKey() << cmd; - //Create the filter + // Create the filter std::ofstream out; out.open(rulesFile.path().c_str()); if (!out.good()) { @@ -200,10 +200,10 @@ out << "if(count == " << msgCnt << " ) { write; } " << std::endl; out.close(); - //Run the filter + // Run the filter std::stringstream in, err; bool hasError = false; - int exitCode; + int exitCode = 0; std::stringstream shellErr; bool ret = shellCommand(cmd, in, err, shellErr, exitCode); @@ -220,7 +220,7 @@ errOut += shellErr.str(); } - //Get stderr of command + // Get stderr of command if (!err.str().empty()) { hasError = true; GuiLog().error() << err.str(); @@ -230,7 +230,7 @@ return !hasError; } -//msgCnt starts from 1!!! +// msgCnt starts from 1!!! bool BufrDataDump::read(const std::string& sourceFile, int msgCnt, int subsetCnt, int subsetNum, bool compressed, long offset, std::string& errOut) { @@ -239,11 +239,11 @@ MvTmpFile subsetFile; std::string cmd; - //from eccodes 2.9.0 we can specify the message offset to bufr_dump + // from eccodes 2.9.0 we can specify the message offset to bufr_dump bool useOffset = (offset > -1 && codes_get_api_version() >= 20900); if (useOffset) { - //For non-compressed messages we need to filter out the required subset + // For non-compressed messages we need to filter out the required subset if (!compressed && subsetNum > 1) { MvTmpFile msgFile; @@ -252,16 +252,16 @@ if (!filterSubset(msgFile.path(), 1, subsetCnt, subsetFile.path(), errOut)) return false; - inFile = subsetFile.path(); //safe to do - cmd = BUFR_DUMP_EXE + " -ja -w count=1 \"" + inFile + "\""; + inFile = subsetFile.path(); // safe to do + cmd = BUFR_DUMP_EXE + " -ja -w count=1 \"" + inFile + "\""; } else { inFile = sourceFile; - cmd = BUFR_DUMP_EXE + " -ja -w count=1 -X " + std::to_string(offset) + " " + "\"" + inFile + "\""; + cmd = BUFR_DUMP_EXE + " -ja -w count=1 -X " + std::to_string(offset) + " " + "\"" + inFile + "\""; } } else { - //For non-compressed messages we need to filter out the required subset + // For non-compressed messages we need to filter out the required subset if (!compressed && subsetNum > 1) { MvTmpFile msgFile; @@ -270,12 +270,12 @@ if (!filterSubset(msgFile.path(), 1, subsetCnt, subsetFile.path(), errOut)) return false; - inFile = subsetFile.path(); //safe to do - cmd = BUFR_DUMP_EXE + " -ja -w count=1 \"" + inFile + "\""; + inFile = subsetFile.path(); // safe to do + cmd = BUFR_DUMP_EXE + " -ja -w count=1 \"" + inFile + "\""; } else { inFile = sourceFile; - cmd = BUFR_DUMP_EXE + " -ja -w count=" + std::to_string(msgCnt) + " " + "\"" + inFile + "\""; + cmd = BUFR_DUMP_EXE + " -ja -w count=" + std::to_string(msgCnt) + " " + "\"" + inFile + "\""; } } @@ -291,18 +291,18 @@ bool hasError = false; - int exitCode; + int exitCode = 0; std::stringstream shellErr; bool ret = shellCommand(cmd, in, err, shellErr, exitCode); - //Get stdout of command + // Get stdout of command text_ = in.str(); - //For uncompressed subsets we need to set the correct numberOfSubsets - //in the json file. At the moment it contains 1, because to access the subset - //first we filter it out as a separate message and then run the bufr dump on it to - //generate json. Since we run the dump on a single subset the numberOfSubsets - //in the resulting dump will always be 1. + // For uncompressed subsets we need to set the correct numberOfSubsets + // in the json file. At the moment it contains 1, because to access the subset + // first we filter it out as a separate message and then run the bufr dump on it to + // generate json. Since we run the dump on a single subset the numberOfSubsets + // in the resulting dump will always be 1. if (!compressed && subsetNum > 1) { size_t pos = text_.find("numberOfSubsets"); if (pos != std::string::npos) { @@ -328,7 +328,7 @@ errOut += shellErr.str(); } - //Get stderr of command + // Get stderr of command if (!err.str().empty()) { hasError = true; GuiLog().error() << err.str(); @@ -340,7 +340,8 @@ bool BufrDataDump::debug(const std::string& sourceFile, int msgCnt, int /*subsetCnt*/, int subsetCnt, bool compressed, long offset, std::string& errOut) { - std::stringstream in, err; + std::stringstream in; + std::stringstream err; std::string inFile; MvTmpFile msgFile; MvTmpFile subsetFile; @@ -349,9 +350,9 @@ bool useOffset = (offset > -1 && codes_get_api_version() >= 20900); if (useOffset) { - //For non-compressed messages we need to filter out the required susbset + // For non-compressed messages we need to filter out the required susbset if (!compressed && subsetCnt > 1) { - //Filter out the given message + // Filter out the given message if (!filterMessage(sourceFile, msgCnt, offset, msgFile.path(), errOut)) return false; @@ -359,19 +360,19 @@ return false; inFile = subsetFile.path(); - cmd = "export ECCODES_DEBUG=1; " + BUFR_DUMP_EXE + " -ja -w count=1 \"" + inFile + "\""; + cmd = "export ECCODES_DEBUG=1; " + BUFR_DUMP_EXE + " -ja -w count=1 \"" + inFile + "\""; } else { inFile = sourceFile; - cmd = "export ECCODES_DEBUG=1; " + BUFR_DUMP_EXE + " -ja -w count=1 -X " + std::to_string(offset) + " " + "\"" + inFile + "\""; + cmd = "export ECCODES_DEBUG=1; " + BUFR_DUMP_EXE + " -ja -w count=1 -X " + std::to_string(offset) + " " + "\"" + inFile + "\""; } } else { - //Filter out the given message + // Filter out the given message if (!filterMessage(sourceFile, msgCnt, -1, msgFile.path(), errOut)) return false; - //For non-compressed messages we need to filter out the required susbset + // For non-compressed messages we need to filter out the required susbset if (!compressed && subsetCnt > 1) { if (!filterSubset(msgFile.path(), 1, subsetCnt, subsetFile.path(), errOut)) return false; @@ -387,16 +388,16 @@ GuiLog().task() << "Generating debug information for message: " << msgCnt << GuiLog::commandKey() << cmd; - //Run command - int exitCode; + // Run command + int exitCode = 0; std::stringstream shellErr; bool ret = shellCommand(cmd, in, err, shellErr, exitCode); - //Debud is dumped to stderr + // Debud is dumped to stderr debug_ = err.str(); - //Remove unwanted strings from debug text - std::string rs = "ECCODES DEBUG : "; + // Remove unwanted strings from debug text + std::string rs = "ECCODES DEBUG : "; size_t start_pos = 0; while ((start_pos = debug_.find(rs, start_pos)) != std::string::npos) { debug_.replace(start_pos, rs.length(), ""); @@ -426,10 +427,10 @@ std::string cmd = BUFR_FILTER_EXE + " -o " + outFile + " " + rulesFile.path() + " " + inFile; - //GuiLog().task() << "Filtering out subset: " << subsetCnt << " from message: " << msgCnt << - // GuiLog::commandKey() << cmd; + // GuiLog().task() << "Filtering out subset: " << subsetCnt << " from message: " << msgCnt << + // GuiLog::commandKey() << cmd; - //Create the filter + // Create the filter std::string errOut; std::ofstream out; out.open(rulesFile.path().c_str()); @@ -439,17 +440,17 @@ return false; } - //out << "set unpack=1;" << std::endl; - //out << "set extractSubset=" << subsetCnt << ";" << std::endl; - //out << "set doExtractSubsets=1;" << std::endl; - //out << "if(count == " << msgCnt << " ) { write; } " << std::endl; + // out << "set unpack=1;" << std::endl; + // out << "set extractSubset=" << subsetCnt << ";" << std::endl; + // out << "set doExtractSubsets=1;" << std::endl; + // out << "if(count == " << msgCnt << " ) { write; } " << std::endl; out << filterStr; out.close(); - //Run the filter + // Run the filter std::stringstream in, err; bool hasError = false; - int exitCode; + int exitCode = 0; std::stringstream shellErr; bool ret = shellCommand(cmd, in, err, shellErr, exitCode); @@ -466,7 +467,7 @@ errOut += shellErr.str(); } - //Get stderr of command + // Get stderr of command if (!err.str().empty()) { hasError = true; GuiLog().error() << err.str(); @@ -492,7 +493,7 @@ text_.clear(); } -//msgCnt starts from 1!!! +// msgCnt starts from 1!!! bool BufrExpandDataDump::read(const std::string& sourceFile, int msgCnt, long offset, std::string& errOut) { std::stringstream in, err; @@ -506,7 +507,7 @@ inFile = sourceFile; - cmd = BUFR_DUMP_EXE + " -d -w count=1 -X " + std::to_string(offset) + " " + "\"" + inFile + "\""; + cmd = BUFR_DUMP_EXE + " -d -w count=1 -X " + std::to_string(offset) + " " + "\"" + inFile + "\""; std::stringstream msg; msg << "Generating expanded descriptor dump for message: " << msgCnt; @@ -519,11 +520,11 @@ } bool hasError = false; - int exitCode; + int exitCode = 0; std::stringstream shellErr; bool ret = shellCommand(cmd, in, err, shellErr, exitCode); - //Get stdout of command + // Get stdout of command text_ = in.str(); if (exitCode > 0) { @@ -539,7 +540,7 @@ errOut += shellErr.str(); } - //Get stderr of command + // Get stderr of command if (!err.str().empty()) { hasError = true; GuiLog().error() << err.str(); @@ -570,7 +571,7 @@ } #endif - //Define the commnad line tools + // Define the commnad line tools #ifdef ECCODES_UI char* bdexe = getenv("CODES_UI_BUFR_DUMP"); char* bfexe = getenv("CODES_UI_BUFR_FILTER"); @@ -607,9 +608,9 @@ MvMessageMetaData(BufrType), totalSubsetNum_(0) { - fileName_ = fileName; + fileName_ = fileName; totalMessageNum_ = totalMessageNum; - messageNum_ = totalMessageNum_; + messageNum_ = totalMessageNum_; } BufrMetaData::~BufrMetaData() @@ -642,15 +643,15 @@ int BufrMetaData::computeTotalMessageNum() { - FILE* fp; + FILE* fp = nullptr; fp = fopen(fileName_.c_str(), "rb"); if (!fp) { - //log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); + // log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); return 0; } int res = 0; - if (codes_count_in_file(0, fp, &res) != CODES_SUCCESS) + if (codes_count_in_file(nullptr, fp, &res) != CODES_SUCCESS) res = 0; fclose(fp); @@ -660,7 +661,7 @@ void BufrMetaData::setTotalMessageNum(int num) { totalMessageNum_ = num; - messageNum_ = totalMessageNum_; + messageNum_ = totalMessageNum_; allocateMessages(); } @@ -691,8 +692,8 @@ clear(); fileName_ = fname; - //totalMessageNum_=computeTotalMessageNum(); - //messageNum_=totalMessageNum_; + // totalMessageNum_=computeTotalMessageNum(); + // messageNum_=totalMessageNum_; } void BufrMetaData::setMessage(size_t chunkStart, const std::vector& msgVec) @@ -725,7 +726,7 @@ { assert(messages_.empty()); if (totalMessageNum_ > 0) - messages_ = std::vector(totalMessageNum_, 0); + messages_ = std::vector(totalMessageNum_, nullptr); } const std::set& BufrMetaData::firstMessageKeys() @@ -742,16 +743,16 @@ if (!(index >= 0 && index < static_cast(messages_.size()))) return; - FILE* fp; + FILE* fp = nullptr; codes_handle* ch = nullptr; - int err = 0; - int bufr_count = 0; + int err = 0; + int bufr_count = 0; std::string cbuff; GuiLog().task() << "Collecting bufr keys from message " << index << GuiLog::methodKey() << "ecCodes C interface"; - //open bufr file for reading + // open bufr file for reading fp = fopen(fileName_.c_str(), "rb"); if (!fp) { GuiLog().error() << "BufrMetaData::readMessageKeys() ---> Cannot open bufr file: \n " << fileName_; @@ -763,9 +764,9 @@ return; } - //fseek(fp,messages_[index]->offset(),SEEK_SET); + // fseek(fp,messages_[index]->offset(),SEEK_SET); - //Get messages form the file + // Get messages form the file while ((ch = codes_handle_new_from_file(nullptr, fp, PRODUCT_BUFR, &err)) != nullptr || err != CODES_SUCCESS) { if (!ch) { GuiLog().error() << "BufrMetaData::readFirstMessageKeys() ---> Unable to create code handle for message count: " << bufr_count + 1; @@ -773,7 +774,7 @@ } else { bufr_keys_iterator* kiter = nullptr; - char* name = 0; + char* name = nullptr; codes_set_long(ch, "skipExtraKeyAttributes", 1); codes_set_long(ch, "unpack", 1); @@ -812,21 +813,21 @@ { prof->clearKeyData(); - FILE* fp; + FILE* fp = nullptr; codes_handle* ch = nullptr; - int err = 0; + int err = 0; - //open bufr file for reading + // open bufr file for reading fp = fopen(fileName_.c_str(), "rb"); if (!fp) { - //GuiLog().error() << "BufrMetaData::readMessageKeys() ---> Cannot open bufr file: \n " << fileName_; + // GuiLog().error() << "BufrMetaData::readMessageKeys() ---> Cannot open bufr file: \n " << fileName_; return; } - //Get messages form the file + // Get messages form the file while ((ch = codes_handle_new_from_file(nullptr, fp, PRODUCT_BUFR, &err)) != nullptr || err != CODES_SUCCESS) { if (!ch) { - //GuiLog().error() << "BufrMetaData::readFirstMessageKeys() ---> Unable to create code handle for message count: " << bufr_count + 1; + // GuiLog().error() << "BufrMetaData::readFirstMessageKeys() ---> Unable to create code handle for message count: " << bufr_count + 1; continue; } else { @@ -843,21 +844,21 @@ void BufrMetaData::readMessage(MvKeyProfile* prof, codes_handle* ch) { if (!ch) { - //readMessageFailed(prof, msgCnt, profIndex); + // readMessageFailed(prof, msgCnt, profIndex); return; } const int MAX_VAL_LEN = 1024; - long longValue; + long longValue = 0; char value[MAX_VAL_LEN]; std::string svalue; size_t vlen = MAX_VAL_LEN; - //long centre; - // if (MV_CODES_CHECK(codes_get_long(ch, "bufrHeaderCentre", ¢re), 0) == false) { - // //readMessageFailed(prof, msgCnt, profIndex); - // return; - // } + // long centre; + // if (MV_CODES_CHECK(codes_get_long(ch, "bufrHeaderCentre", ¢re), 0) == false) { + // //readMessageFailed(prof, msgCnt, profIndex); + // return; + // } // if (MV_CODES_CHECK(codes_get_long(ch, "section1Flags", &longValue), 0) == false) { // //readMessageFailed(prof, msgCnt, profIndex); @@ -865,26 +866,26 @@ // } - //bool hasLocal2 = (centre == 98 && longValue != 0); + // bool hasLocal2 = (centre == 98 && longValue != 0); for (unsigned int i = 0; i < prof->size(); i++) { - size_t len; - int keyType; - const char* name = prof->at(i)->name().c_str(); + size_t len = 0; + int keyType = 0; + const char* name = prof->at(i)->name().c_str(); std::string strName = prof->at(i)->name(); - bool foundValue = false; + bool foundValue = false; - //std::size_t pos; - // if ((pos = strName.find(":98")) == strName.size() - 3) { - // if (hasLocal2) { - // strName = strName.substr(0, strName.size() - 3); - // name = strName.c_str(); - // } - // else { - // prof->at(i)->setStringValue(profIndex, "N/A"); - // continue; - // } - // } + // std::size_t pos; + // if ((pos = strName.find(":98")) == strName.size() - 3) { + // if (hasLocal2) { + // strName = strName.substr(0, strName.size() - 3); + // name = strName.c_str(); + // } + // else { + // prof->at(i)->setStringValue(profIndex, "N/A"); + // continue; + // } + // } if (grib_get_native_type(ch, name, &keyType) == CODES_SUCCESS && grib_get_size(ch, name, &len) == CODES_SUCCESS && @@ -932,10 +933,10 @@ void BufrMetaData::readCompressedData(MvKeyProfile* prof, int index, int subsetNum) { - FILE* fp; + FILE* fp = nullptr; codes_handle* ch = nullptr; - int err = 0; - int bufr_count = 0; + int err = 0; + int bufr_count = 0; assert(prof); assert(prof->size() == 0); @@ -944,28 +945,28 @@ GuiLog().task() << "Generating bufr key list for all the messages" << GuiLog::methodKey() << "ecCodes C interface"; - //open bufr file for reading + // open bufr file for reading fp = fopen(fileName_.c_str(), "rb"); if (!fp) { GuiLog().error() << "BufrMetaData::readMessages() ---> Cannot open bufr file: \n " << fileName_; return; } - //For filtered datasets + // For filtered datasets if (filterEnabled_ == true) { } else { - //The first key will be the subset count + // The first key will be the subset count auto* subsetKey = new MvKey("subset", "subset"); subsetKey->setValueType(MvKey::IntType); subsetKey->setConstant(true); //!!!! prof->addKey(subsetKey); - //Get messages form the file + // Get messages form the file while ((ch = codes_handle_new_from_file(nullptr, fp, PRODUCT_BUFR, &err)) != nullptr || err != CODES_SUCCESS) { if (!ch) { GuiLog().error() << "BufrMetaData::readMessages() ---> Unable to create code handle for message count: " << bufr_count + 1; - //continue; + // continue; } if (bufr_count == index) { @@ -993,21 +994,21 @@ void BufrMetaData::readCompressedData(MvKeyProfile* prof, codes_handle* ch) { - //int codes_bufr_copy_data(grib_handle* hin, grib_handle* hout) + // int codes_bufr_copy_data(grib_handle* hin, grib_handle* hout) //{ bufr_keys_iterator* kiter = nullptr; - char* name = 0; - int nkeys = 0; - int keyType = 0; - long longValue = 0; - long* longArray = 0; - size_t longArrayLen = 0; - double doubleValue = 0.; - double* doubleArray = 0; - size_t doubleArrayLen = 0; - char** strArray = 0; - size_t strArrayLen = 0; - size_t len; + char* name = nullptr; + int nkeys = 0; + int keyType = 0; + long longValue = 0; + long* longArray = nullptr; + size_t longArrayLen = 0; + double doubleValue = 0.; + double* doubleArray = nullptr; + size_t doubleArrayLen = 0; + char** strArray = nullptr; + size_t strArrayLen = 0; + size_t len = 0; size_t maxStrLen = 128; if (ch == nullptr) { @@ -1050,13 +1051,13 @@ free(strArray); } strArrayLen = len; - strArray = (char**)malloc(len * sizeof(char*)); + strArray = (char**)malloc(len * sizeof(char*)); for (size_t i = 0; i < len; ++i) { strArray[i] = new char[maxStrLen]; } } - //Get all values + // Get all values size_t itotal = maxStrLen * len; codes_get_string_array(ch, name, strArray, &itotal); @@ -1083,12 +1084,12 @@ free(longArray); } longArrayLen = len; - longArray = (long*)malloc(len * sizeof(long)); + longArray = (long*)malloc(len * sizeof(long)); } assert(len > 1); assert(longArray); size_t itotal = len; - CODES_CHECK(codes_get_long_array(ch, name, longArray, &itotal), 0); + CODES_CHECK(codes_get_long_array(ch, name, longArray, &itotal), nullptr); for (size_t i = 0; i < len; i++) { int iv = longArray[i]; mvk->addIntValue(iv); @@ -1111,12 +1112,12 @@ free(doubleArray); } doubleArrayLen = len; - doubleArray = (double*)malloc(len * sizeof(double)); + doubleArray = (double*)malloc(len * sizeof(double)); } assert(len > 1); assert(doubleArray); size_t itotal = len; - CODES_CHECK(codes_get_double_array(ch, name, doubleArray, &itotal), 0); + CODES_CHECK(codes_get_double_array(ch, name, doubleArray, &itotal), nullptr); for (size_t i = 0; i < len; i++) mvk->addDoubleValue(doubleArray[i]); } @@ -1128,17 +1129,17 @@ identical and we want to copy what can be copied and skip what cannot be copied because is not in the output handle */ - //err=codes_copy_key(hin, hout, name, 0); - //if (err==0) nkeys++; - //grib_context_free(ch->context,name); - //free(name); - //name=0; + // err=codes_copy_key(hin, hout, name, 0); + // if (err==0) nkeys++; + // grib_context_free(ch->context,name); + // free(name); + // name=0; } } if (nkeys > 0) { /* Do the pack if something was copied */ - //err=grib_set_long(hout, "pack", 1); + // err=grib_set_long(hout, "pack", 1); } codes_bufr_keys_iterator_delete(kiter); @@ -1178,22 +1179,22 @@ return res; } -//Read all locations in the BUFR file +// Read all locations in the BUFR file bool BufrMetaData::readLocations(BufrLocationCollector* collector, std::string& errOut) { - FILE* fp; + FILE* fp = nullptr; codes_handle* ch = nullptr; - int err = 0; - int bufr_count = 1; + int err = 0; + int bufr_count = 1; - //assert(prof); - //assert(prof->size() == 0); + // assert(prof); + // assert(prof->size() == 0); std::string cbuff; GuiLog().task() << "Scanning for locations" << GuiLog::methodKey() << "ecCodes C interface"; - //open bufr file for reading + // open bufr file for reading fp = fopen(fileName_.c_str(), "rb"); if (!fp) { GuiLog().error() << "BufrMetaData::readLocations() ---> Cannot open bufr file: \n " << fileName_; @@ -1201,14 +1202,14 @@ return false; } - //For filtered datasets + // For filtered datasets if (filterEnabled_ == true) { } else { while ((ch = codes_handle_new_from_file(nullptr, fp, PRODUCT_BUFR, &err)) != nullptr || err != CODES_SUCCESS) { if (!ch) { GuiLog().error() << "BufrMetaData::readLocations() ---> Unable to create code handle for message count: " << bufr_count + 1; - //continue; + // continue; } readMessageLocations(ch, bufr_count, collector); @@ -1226,53 +1227,53 @@ return true; } -//Reads the locations from a given message amd collect them into an MvKeyProfile +// Reads the locations from a given message amd collect them into an MvKeyProfile void BufrMetaData::readMessageLocations(codes_handle* ch, int msgCnt, BufrLocationCollector* collector) { if (!ch) { - //readMessageFailed(prof,msgCnt); + // readMessageFailed(prof,msgCnt); return; } - long longValue; + long longValue = 0; - //Header keys + // Header keys long centre = 0; - if (MV_CODES_CHECK(codes_get_long(ch, "bufrHeaderCentre", ¢re), 0) == false) { - //readMessageFailed(prof,msgCnt); + if (MV_CODES_CHECK(codes_get_long(ch, "bufrHeaderCentre", ¢re), nullptr) == false) { + // readMessageFailed(prof,msgCnt); return; } - if (MV_CODES_CHECK(codes_get_long(ch, "section1Flags", &longValue), 0) == false) { - //readMessageFailed(prof,msgCnt); + if (MV_CODES_CHECK(codes_get_long(ch, "section1Flags", &longValue), nullptr) == false) { + // readMessageFailed(prof,msgCnt); return; } long subsetNum = 0; - if (MV_CODES_CHECK(codes_get_long(ch, "numberOfSubsets", &subsetNum), 0) == false) { - //readMessageFailed(prof,msgCnt); + if (MV_CODES_CHECK(codes_get_long(ch, "numberOfSubsets", &subsetNum), nullptr) == false) { + // readMessageFailed(prof,msgCnt); return; } long compressed = 0; - if (MV_CODES_CHECK(codes_get_long(ch, "compressedData", &compressed), 0) == false) { - //readMessageFailed(prof,msgCnt); + if (MV_CODES_CHECK(codes_get_long(ch, "compressedData", &compressed), nullptr) == false) { + // readMessageFailed(prof,msgCnt); return; } bool hasLocal2 = (centre == 98 && longValue != 0); - //For ECMWF bufrs with section 2 we read the lat/lon from the - //header when there are no subsets + // For ECMWF bufrs with section 2 we read the lat/lon from the + // header when there are no subsets if (hasLocal2 && subsetNum == 1) { double latVal, lonVal; - bool hasLocalPos = true; + bool hasLocalPos = true; std::string latName = "localLatitude"; std::string lonName = "localLongitude"; - if (MV_CODES_CHECK(codes_get_double(ch, latName.c_str(), &latVal), 0) == false) { + if (MV_CODES_CHECK(codes_get_double(ch, latName.c_str(), &latVal), nullptr) == false) { hasLocalPos = false; } - if (MV_CODES_CHECK(codes_get_double(ch, lonName.c_str(), &lonVal), 0) == false) { + if (MV_CODES_CHECK(codes_get_double(ch, lonName.c_str(), &lonVal), nullptr) == false) { hasLocalPos = false; } @@ -1282,23 +1283,23 @@ } } - //Read the position from the data + // Read the position from the data size_t latAllocLen = 0, lonAllocLen = 0; size_t latLen = 0, lonLen = 0; - double* lonArray = 0; - double* latArray = 0; + double* lonArray = nullptr; + double* latArray = nullptr; - //expand the message + // expand the message codes_set_long(ch, "skipExtraKeyAttributes", 1); if (codes_set_long(ch, "unpack", 1) != 0) { return; } - //compressed data + // compressed data if (compressed) { int maxRank = 1000000; - int ir = 1; + int ir = 1; while (ir < maxRank) { double latVal, lonVal; latLen = 0; @@ -1307,8 +1308,8 @@ std::string latName = "#" + std::to_string(ir) + "#latitude"; std::string lonName = "#" + std::to_string(ir) + "#longitude"; - //MV_CODES_CHECK(codes_get_size(ch, latName.c_str(), &latLen),0); - //MV_CODES_CHECK(codes_get_size(ch, lonName.c_str(), &lonLen),0); + // MV_CODES_CHECK(codes_get_size(ch, latName.c_str(), &latLen),0); + // MV_CODES_CHECK(codes_get_size(ch, lonName.c_str(), &lonLen),0); codes_get_size(ch, latName.c_str(), &latLen); codes_get_size(ch, lonName.c_str(), &lonLen); @@ -1316,20 +1317,20 @@ if (latLen == 0 || lonLen == 0) break; - //Single value + // Single value if (latLen == 1) { - MV_CODES_CHECK(codes_get_double(ch, latName.c_str(), &latVal), 0); + MV_CODES_CHECK(codes_get_double(ch, latName.c_str(), &latVal), nullptr); } - //Array + // Array else { readDoubleArray(ch, latName, latLen, latAllocLen, &latArray); } - //Single value + // Single value if (lonLen == 1) { - MV_CODES_CHECK(codes_get_double(ch, lonName.c_str(), &lonVal), 0); + MV_CODES_CHECK(codes_get_double(ch, lonName.c_str(), &lonVal), nullptr); } - //Array + // Array else { readDoubleArray(ch, lonName, lonLen, lonAllocLen, &lonArray); } @@ -1347,9 +1348,9 @@ } } - //uncompressed + // uncompressed else { - //loop for the subsets + // loop for the subsets for (int i = 0; i < subsetNum; i++) { latLen = 0; lonLen = 0; @@ -1357,22 +1358,22 @@ std::string latName = "/subsetNumber=" + std::to_string(i + 1) + "/latitude"; std::string lonName = "/subsetNumber=" + std::to_string(i + 1) + "/longitude"; - //MV_CODES_CHECK(codes_get_size(ch, latName.c_str(), &latLen),0); - //MV_CODES_CHECK(codes_get_size(ch, lonName.c_str(), &lonLen),0); + // MV_CODES_CHECK(codes_get_size(ch, latName.c_str(), &latLen),0); + // MV_CODES_CHECK(codes_get_size(ch, lonName.c_str(), &lonLen),0); codes_get_size(ch, latName.c_str(), &latLen); codes_get_size(ch, lonName.c_str(), &lonLen); if (latLen == lonLen && latLen > 0) { - //Single value + // Single value if (latLen == 1) { double latVal, lonVal; - MV_CODES_CHECK(codes_get_double(ch, latName.c_str(), &latVal), 0); - MV_CODES_CHECK(codes_get_double(ch, lonName.c_str(), &lonVal), 0); + MV_CODES_CHECK(codes_get_double(ch, latName.c_str(), &latVal), nullptr); + MV_CODES_CHECK(codes_get_double(ch, lonName.c_str(), &lonVal), nullptr); collector->add(msgCnt, i + 1, 1, latVal, lonVal); } - //array + // array else { readDoubleArray(ch, latName, latLen, latAllocLen, &latArray); readDoubleArray(ch, lonName, latLen, lonAllocLen, &lonArray); @@ -1401,16 +1402,16 @@ free(*data); } allocLen = len; - *data = (double*)malloc(len * sizeof(double)); + *data = (double*)malloc(len * sizeof(double)); } - MV_CODES_CHECK(codes_get_double_array(ch, key.c_str(), *data, &len), 0); + MV_CODES_CHECK(codes_get_double_array(ch, key.c_str(), *data, &len), nullptr); } void BufrMetaData::checkStringValue(std::string& t) { static const std::string mStr = "missing"; - static const char chFF = static_cast(0xFF); + static const char chFF = static_cast(0xFF); if (t.length() > 0) { for (char i : t) { diff -Nru metview-5.17.4/metview/src/libMetview/BufrMetaData.h metview-5.19.2/metview/src/libMetview/BufrMetaData.h --- metview-5.17.4/metview/src/libMetview/BufrMetaData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/BufrMetaData.h 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include @@ -34,7 +34,7 @@ class BufrDataDump { public: - BufrDataDump() {} + BufrDataDump() = default; ~BufrDataDump(); void clear(); bool read(const std::string&, int, int, int, bool, long, std::string&); @@ -59,13 +59,13 @@ class BufrExpandDataDump { public: - BufrExpandDataDump() {} + BufrExpandDataDump() = default; ~BufrExpandDataDump(); void clear(); bool read(const std::string&, int, long, std::string&); const std::string& text() const { return text_; } -protected: +private: std::string dumpFile_; std::string text_; }; @@ -76,12 +76,12 @@ BufrMetaData(); BufrMetaData(const std::string& fileName, int totalMessageNum); - ~BufrMetaData(); - void setFileName(std::string); + ~BufrMetaData() override; + void setFileName(std::string) override; void getKeyList(std::string, MvKeyProfile*); - void setTotalMessageNum(int); + void setTotalMessageNum(int) override; size_t totalSubsetNum(bool forceCompute); void setMessage(size_t chunkStart, const std::vector& msgVec); void setMessage(size_t pos, MvEccBufrMessage* msg); @@ -95,10 +95,10 @@ void readMessageKeys(int index, std::set&); void getKeyProfileForFirstMessage(MvKeyProfile* prof); int computeTotalMessageNum(); - void clearData(); + void clearData() override; protected: - void clear(); + void clear() override; private: void allocateMessages(); @@ -108,12 +108,12 @@ void readDoubleArray(codes_handle* ch, const std::string& key, std::size_t len, std::size_t& allocLen, double** data); std::string formatDate(std::string, std::string, std::string); std::string formatTime(std::string, std::string, std::string); - static void checkStringValue(std::string& t); + static void checkStringValue(std::string&); std::string tmpFile_; - MvKeyProfile* allKey_; + MvKeyProfile* allKey_{nullptr}; std::vector messages_; std::string firstTypicalDate_; std::set firstKeys_; - size_t totalSubsetNum_; + size_t totalSubsetNum_{0}; }; diff -Nru metview-5.17.4/metview/src/libMetview/Cached.cc metview-5.19.2/metview/src/libMetview/Cached.cc --- metview-5.17.4/metview/src/libMetview/Cached.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Cached.cc 2023-07-15 08:28:47.000000000 +0000 @@ -71,8 +71,8 @@ Cached Cached::toUpper() { const char* t = Str; - char* data = new char[strlen(Str) + 1]; - int i = 0; + char* data = new char[strlen(Str) + 1]; + int i = 0; while (*t) { data[i] = toupper(*t); diff -Nru metview-5.17.4/metview/src/libMetview/Cached.h metview-5.19.2/metview/src/libMetview/Cached.h --- metview-5.17.4/metview/src/libMetview/Cached.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Cached.h 2023-07-15 08:28:47.000000000 +0000 @@ -74,20 +74,20 @@ //! Concatenation operator for \c int /*! The numeric value is first converted to a number string - * and the number string is concatenated to the original string. - */ + * and the number string is concatenated to the original string. + */ Cached operator+(int) const; //! Concatenation operator for \c long /*! The numeric value is first converted to a number string - * and the number string is concatenated to the original string. - */ + * and the number string is concatenated to the original string. + */ Cached operator+(long) const; //! Concatenation operator for \c double /*! The numeric value is first converted to a number string - * and the number string is concatenated to the original string. - */ + * and the number string is concatenated to the original string. + */ Cached operator+(double) const; //! Comparision operator diff -Nru metview-5.17.4/metview/src/libMetview/CMakeLists.txt metview-5.19.2/metview/src/libMetview/CMakeLists.txt --- metview-5.17.4/metview/src/libMetview/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -68,6 +68,7 @@ MvVersionInfo.cc Point.cc proj_braz.cc + StatsCompute.cc Request.cc TableReader.cc Tokenizer.cc diff -Nru metview-5.17.4/metview/src/libMetview/ConfigLoader.cc metview-5.19.2/metview/src/libMetview/ConfigLoader.cc --- metview-5.17.4/metview/src/libMetview/ConfigLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/ConfigLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -46,9 +46,9 @@ int order = 0; bool more = true; -// marsinit(&argc,argv,0,0,0); + // marsinit(&argc,argv,0,0,0); while (more || order <= 2) { - more = false; + more = false; request* r = mars.setup; while (r) { if (ConfigLoader::process(r, order)) { diff -Nru metview-5.17.4/metview/src/libMetview/FortranTypes.h metview-5.19.2/metview/src/libMetview/FortranTypes.h --- metview-5.17.4/metview/src/libMetview/FortranTypes.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/FortranTypes.h 2023-07-15 08:28:47.000000000 +0000 @@ -9,8 +9,8 @@ #pragma once -//This definition was taken from mars.h -//We only need this when mars.h cannot be used (e.g. inW codes_ui) +// This definition was taken from mars.h +// We only need this when mars.h cannot be used (e.g. inW codes_ui) #ifndef METVIEW #if !defined(I32) && !defined(I64) && !defined(I128) diff -Nru metview-5.17.4/metview/src/libMetview/gdefines.h metview-5.19.2/metview/src/libMetview/gdefines.h --- metview-5.17.4/metview/src/libMetview/gdefines.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/gdefines.h 2023-07-15 08:28:47.000000000 +0000 @@ -69,7 +69,7 @@ /* define data types Note: As a temporary solution the data type is been used - to define the icon class + to define the icon class */ #define DATA_FIELD "Field" diff -Nru metview-5.17.4/metview/src/libMetview/GribMetaData.cc metview-5.19.2/metview/src/libMetview/GribMetaData.cc --- metview-5.17.4/metview/src/libMetview/GribMetaData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/GribMetaData.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,6 +12,9 @@ #include #include #include +#include +#include +#include #include "GribMetaData.h" #include "LogHandler.h" @@ -72,7 +75,7 @@ out << cbuf; } - int ret = pclose(in); + int ret = pclose(in); exitCode = WEXITSTATUS(ret); if (!(in = fopen(tmpFile.path().c_str(), "r"))) { @@ -165,11 +168,11 @@ text_.clear(); } -//msgCnt starts from 1!!! +// msgCnt starts from 1!!! bool GribWmoDump::read(const std::string& fgrib, int msgCnt) { - //Get grib dump for the given field - //int count=1; + // Get grib dump for the given field + // int count=1; std::string errOut; std::string cmd = GRIB_DUMP_EXE + " -O -w count=" + std::to_string(msgCnt) + " " + "\"" + fgrib + "\""; @@ -195,7 +198,7 @@ errOut += shellErr.str(); } - //Get stderr of command + // Get stderr of command if (!err.str().empty()) { hasError = true; GuiLog().error() << err.str(); @@ -205,18 +208,18 @@ if (hasError) return false; - //Run dump command - //shellCommand(cmd,in,err,tmpFile); + // Run dump command + // shellCommand(cmd,in,err,tmpFile); - //Get stdout of command + // Get stdout of command text_ = in.str(); - //Get stderr of command - //if(!err.str().empty()) + // Get stderr of command + // if(!err.str().empty()) //{ - // GuiLog().error() << err.str(); - // return false; - //} + // GuiLog().error() << err.str(); + // return false; + // } GuiLog().task() << "Parsing default dump for message: " << msgCnt; parse(in); @@ -241,7 +244,7 @@ } else if ((pos = stmp.find("SECTION_")) != std::string::npos || (pos = stmp.find("SECTION")) != std::string::npos) { - auto* sec = new GribSection; + auto* sec = new GribSection; std::string::size_type posNumEnd = stmp.find(" ", pos + 8); if (posNumEnd != std::string::npos) { sec->name("Section " + stmp.substr(pos + 8, posNumEnd - pos - 8)); @@ -255,7 +258,7 @@ } else if (asec != 0) { - int i = 0; + int i = 0; auto* item = new GribItem; while (ss >> buf) { if (i == 0) { @@ -265,7 +268,7 @@ item->setName(buf); } else if (i == 2 && buf == "=") { - pos = stmp.find("="); + pos = stmp.find("="); pos1 = stmp.rfind("{"); if (pos1 != std::string::npos) { item->setValue(stmp.substr(pos, pos1 - pos + 1)); @@ -294,13 +297,13 @@ if (stmp.find("}") != std::string::npos) { item->addArrayData(stmp); } - //stmp now contains the "}" character + // stmp now contains the "}" character } - else //if(buf.find("[") ==std::string::npos || buf.find("]") == string::npos ) + else // if(buf.find("[") ==std::string::npos || buf.find("]") == string::npos ) { item->setValue(stmp.substr(pos + 1)); - //item->value(buf); + // item->value(buf); } @@ -310,7 +313,7 @@ } asec->addItem(item); } - //GribFieldMetaData* field = new GribFieldMetaData; + // GribFieldMetaData* field = new GribFieldMetaData; } } @@ -334,7 +337,7 @@ text_.clear(); } -//msgCnt starts from 1!!! +// msgCnt starts from 1!!! bool GribStdDump::read(const std::string& fname, int msgCnt) { std::string errOut; @@ -342,7 +345,7 @@ GuiLog().task() << "Generating default dump for message: " << msgCnt << GuiLog::commandKey() << cmd; - //Run the command + // Run the command std::stringstream in, err; bool hasError = false; int exitCode; @@ -362,7 +365,7 @@ errOut += shellErr.str(); } - //Get stderr of command + // Get stderr of command if (!err.str().empty()) { hasError = true; GuiLog().error() << err.str(); @@ -372,7 +375,7 @@ if (hasError) return false; - //Get stdout of command + // Get stdout of command text_ = in.str(); GuiLog().task() << "Parsing default dump for message: " << msgCnt; @@ -393,7 +396,7 @@ } while (in.getline(c, 512)) { - //std::cout << c << std::endl ; + // std::cout << c << std::endl ; std::string buf; // Have a buffer string stmp = c; @@ -403,7 +406,7 @@ descText = stmp; } else { - //std::vector sv; + // std::vector sv; int i = 0; auto* item = new GribItem; @@ -456,7 +459,7 @@ if (stmp.find("}") != std::string::npos) { item->addArrayData(stmp); } - //stmp now contains the "}" character + // stmp now contains the "}" character } i++; @@ -473,11 +476,11 @@ GribMvDump::GribMvDump() { - //tmpfilename_ = tmpfilename; + // tmpfilename_ = tmpfilename; if (keyMap_.empty()) { keyMap_[CODES_TYPE_STRING] = "string"; - keyMap_[CODES_TYPE_LONG] = "long"; + keyMap_[CODES_TYPE_LONG] = "long"; keyMap_[CODES_TYPE_DOUBLE] = "double"; } } @@ -495,7 +498,7 @@ item_.clear(); } -//msgCnt starts from 1!!! +// msgCnt starts from 1!!! bool GribMvDump::read(const std::string& fname, int count) { std::vector name_space = {"Default", "geography", "ls", "mars", @@ -504,23 +507,23 @@ // list of skipped keys - these can be very expensive to compute; we can // always put them back in if someone really really needs them... // to be considered: minimum, maximum - std::vector key_skiplist ={"distinctLatitudes", "distinctLongitudes","distinctLatitudes"}; + std::vector key_skiplist = {"distinctLatitudes", "distinctLongitudes", "distinctLatitudes"}; // keys which are redundant or not properly defined key_skiplist.push_back("GRIBEditionNumber"); - //Other keys which define constant values and are not really useful for users + // Other keys which define constant values and are not really useful for users key_skiplist.push_back("7777"); key_skiplist.push_back("x"); FILE* fp; - grib_handle* gh = nullptr; + grib_handle* gh = nullptr; grib_keys_iterator* kiter = nullptr; - //const int MAX_KEY_LEN=255; - const int MAX_VAL_LEN = 1024; + // const int MAX_KEY_LEN=255; + const int MAX_VAL_LEN = 1024; unsigned long key_iterator_filter_flags = GRIB_KEYS_ITERATOR_ALL_KEYS; - int err = 0; + int err = 0; int grib_count = 0; int keyType; @@ -530,25 +533,25 @@ GuiLog().task() << "Generating namespace dump for message: " << count << GuiLog::methodKey() << "ecCodes C interface"; - //open grib file for reading + // open grib file for reading fp = fopen(fname.c_str(), "rb"); if (!fp) { GuiLog().error() << "Cannot open grib file: \n " << fname << "\n"; return false; } - //Get messages form the file - while ((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err !=CODES_SUCCESS) { + // Get messages form the file + while ((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err != CODES_SUCCESS) { grib_count++; - //if(!gh) + // if(!gh) //{ // log->error("GribMvDump::read() ---> Unable to create grib handle\n"); // return; - //} + // } if (grib_count == count) { - //std::cout << "-- GRIB N. " << grib_count << "---/n"; + // std::cout << "-- GRIB N. " << grib_count << "---/n"; if (!gh) { GuiLog().error() << "Unable to create grib handle for message no: " << grib_count << "\n"; @@ -556,7 +559,7 @@ } for (auto& ns : name_space) { - //Get key iterator + // Get key iterator if (ns != "Default") kiter = grib_keys_iterator_new(gh, key_iterator_filter_flags, const_cast(ns.c_str())); else @@ -567,7 +570,7 @@ return false; } - //Loop for the keys in the current message until all the keys are found + // Loop for the keys in the current message until all the keys are found while (grib_keys_iterator_next(kiter)) { const char* name = grib_keys_iterator_get_name(kiter); @@ -583,12 +586,12 @@ continue; - //Add namespace prefix to the key name (e.g. mars.param) + // Add namespace prefix to the key name (e.g. mars.param) if (ns != "Default") { cbuff = ns + "." + cbuff; } - //Get string value + // Get string value vlen = MAX_VAL_LEN; size_t len; long longValue; @@ -603,7 +606,7 @@ item_.push_back(item); item->setName(cbuff); - if(keyType == CODES_TYPE_STRING || len == 1) { + if (keyType == CODES_TYPE_STRING || len == 1) { grib_get_string(gh, name, value, &vlen); } @@ -611,13 +614,16 @@ if (codes_get_long(gh, name, &longValue) == CODES_SUCCESS) { item->setValue(longValue, value); } - } else if (keyType == CODES_TYPE_DOUBLE && len == 1) { + } + else if (keyType == CODES_TYPE_DOUBLE && len == 1) { if (codes_get_double(gh, name, &doubleValue) == CODES_SUCCESS) { item->setValue(doubleValue, value); } - } else if (keyType == CODES_TYPE_STRING) { + } + else if (keyType == CODES_TYPE_STRING) { item->setValue(value); - } else { + } + else { svalue = "Array (" + std::to_string(len) + ")"; item->setValue(svalue); } @@ -649,26 +655,26 @@ // //=================================================== -//msgCnt starts from 1!!! +// msgCnt starts from 1!!! bool GribTableDump::read(const std::string& fgrib, int msgCnt, std::vector& tablesMasterDir, std::vector& tablesLocalDir) { FILE* fp; grib_handle* gh = nullptr; - int err = 0; - int grib_count = 0; + int err = 0; + int grib_count = 0; GuiLog().task() << "Generating table dump for message: " << msgCnt << GuiLog::methodKey() << "ecCodes C interface"; - //open grib file for reading + // open grib file for reading fp = fopen(fgrib.c_str(), "rb"); if (!fp) { GuiLog().error() << "Cannot open grib file: \n " << fgrib << "\n"; return false; } - //Get messages form the file - while (((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err !=CODES_SUCCESS) && grib_count < msgCnt) { + // Get messages form the file + while (((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err != CODES_SUCCESS) && grib_count < msgCnt) { grib_count++; if (grib_count == msgCnt) { if (!gh) { @@ -736,14 +742,7 @@ // //=================================================== -GribValueDump::GribValueDump() -{ - latitude_ = 0; - longitude_ = 0; - value_ = 0; - num_ = 0; - decimalPlaces_ = 0; -} +const int GribValueDump::maxNum_ = 7000000; GribValueDump::~GribValueDump() { @@ -752,19 +751,22 @@ void GribValueDump::clear() { - if (latitude_) + if (latitude_) { delete[] latitude_; + } - if (longitude_) + if (longitude_) { delete[] longitude_; + } - if (value_) + if (value_) { delete[] value_; + } - latitude_ = 0; - longitude_ = 0; - value_ = 0; - num_ = 0; + latitude_ = nullptr; + longitude_ = nullptr; + value_ = nullptr; + num_ = 0; gridType_.clear(); } @@ -775,157 +777,142 @@ clear(); } -bool GribValueDump::read(const std::string& fgrib, int msgCnt) +bool GribValueDump::read(const std::string& fgrib, int msgCnt, std::string& errMsg, std::string& warnMsg) { - //Get grib dump for the given field - - FILE* fp; + // Get grib dump for the given field grib_handle* gh = nullptr; - int err = 0; + int err = 0; int grib_count = 0; GuiLog().task() << "Generating value dump for message: " << msgCnt << GuiLog::methodKey() << "ecCodes C interface"; - //Clear the currently allocated data + // Clear the currently allocated data clear(); + assert(latitude_ == nullptr); + assert(longitude_ == nullptr); + assert(value_ == nullptr); + assert(num_ == 0); - //open grib file for reading - fp = fopen(fgrib.c_str(), "rb"); + // open grib file for reading + FILE* fp = fopen(fgrib.c_str(), "rb"); if (!fp) { + errMsg = "Cannot open grib file: " + fgrib; GuiLog().error() << "Cannot open grib file: \n " << fgrib << "\n"; return false; } - //Get messages form the file - while (((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err !=CODES_SUCCESS) && grib_count < msgCnt) { + // Get messages form the file + while (((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err != CODES_SUCCESS) && grib_count < msgCnt) { grib_count++; - //if(!gh) + // if(!gh) //{ // log->error("GribValueDump::read() ---> Unable to create grib handle\n"); // return; - //} + // } if (grib_count == msgCnt) { if (!gh) { - GuiLog().error() << "Unable to create grib handle for message no: " << grib_count; + errMsg = "Unable to create grib handle for message no: " + std::to_string(grib_count); + GuiLog().error() << errMsg; fclose(fp); return false; } - size_t latNum, lonNum, valNum; - std::string latName, lonName; - - //std::cout << "-- GRIB N. " << grib_count << "---/n"; - - const int MAX_VAL_LEN = 1024; + long dataNum = 0; + size_t llvNum = 0; + std::string llvName = "latLonValues"; + constexpr int triple = 3; + constexpr int MAX_VAL_LEN = 1024; char cval[MAX_VAL_LEN]; size_t vlen = MAX_VAL_LEN; - //Grid type - if (grib_get_string(gh, "gridType", cval, &vlen) ==CODES_SUCCESS) { + // Grid type + if (grib_get_string(gh, "gridType", cval, &vlen) == CODES_SUCCESS) { gridType_ = std::string(cval); } else { - GuiLog().error() << "No gridType data found"; + errMsg = "gridType is not defined"; + GuiLog().error() << errMsg; readFailed(fp, gh); return false; } if (gridType_ == "sh") { - latName = ""; - lonName = ""; - GuiLog().error() << "gridType \"sh\" is not supported"; + errMsg = "gridType=sh is not supported"; + GuiLog().error() << errMsg; readFailed(fp, gh); return false; } - else { - latName = "latitudes"; - lonName = "longitudes"; - } - - //Latitude - grib_get_size(gh, latName.c_str(), &latNum); - if (latNum > 0) { - latitude_ = new double[latNum]; - } - else { - GuiLog().error() << "No latitude data found"; + if (grib_get_long(gh, "numberOfDataPoints", &dataNum) != 0) { + errMsg = "Failed to read numberOfDataPoints"; + GuiLog().error() << errMsg; readFailed(fp, gh); return false; } - if (grib_get_double_array(gh, latName.c_str(), latitude_, &latNum) != 0) { - GuiLog().error() << "Failed to read latitude data"; + num_ = static_cast(dataNum); + if (num_ > maxNum_) { + warnMsg = "Cannot generate values dump. Number of data values=" + + std::to_string(dataNum) + " is too large."; + GuiLog().error() << warnMsg; readFailed(fp, gh); return false; } - //Longitude - grib_get_size(gh, lonName.c_str(), &lonNum); - if (lonNum != latNum) { - GuiLog().error() << "No longitude data found"; + // LatLonValues + grib_get_size(gh, llvName.c_str(), &llvNum); + if (llvNum == 0) { + errMsg = "Failed to read " + llvName + " size"; + GuiLog().error() << errMsg; readFailed(fp, gh); return false; - } - else { - longitude_ = new double[lonNum]; - } - - if (grib_get_double_array(gh, lonName.c_str(), longitude_, &lonNum) != 0) { - GuiLog().error() << "Failed to read longitude data"; + } else if (static_cast(llvNum) != triple*num_) { + errMsg = llvName + " num=" + std::to_string(llvNum) + + " differs to 3*numberOfDataPoints=" + std::to_string(num_); + GuiLog().error() << errMsg; readFailed(fp, gh); return false; } - //Value - grib_get_size(gh, "values", &valNum); - if (valNum != latNum) { - GuiLog().error() << "No value data found"; - readFailed(fp, gh); - return false; - } - else { - value_ = new double[valNum]; - } - if (grib_get_double_array(gh, "values", value_, &valNum) != 0) { - GuiLog().error() << "Failed to read value data"; + std::unique_ptr llv(new double[triple*dataNum]); + if (grib_get_double_array(gh, llvName.c_str(), llv.get(), &llvNum) != 0) { + errMsg = "Failed to read " + llvName; + GuiLog().error() << errMsg; readFailed(fp, gh); return false; } - double max = -999999999.; - double min = 999999999.; - for (unsigned int i = 0; i < valNum; i++) { - if (value_[i] > max) - max = value_[i]; - if (value_[i] < min) - min = value_[i]; - } - double maxAbs = (fabs(max) > fabs(min)) ? fabs(max) : fabs(min); + latitude_ = new double[num_]; + longitude_ = new double[num_]; + value_ = new double[num_]; + + std::size_t pos=0; + for (std::size_t i=0; i < llvNum; i+=triple, pos++) { + latitude_[pos] = llv[i]; + longitude_[pos] = llv[i+1]; + value_[pos] = llv[i+2]; + } + + llv.reset(); + + auto res = std::minmax_element(value_, value_ + num_); + auto minVal = *(res.first); + auto maxVal = *(res.second); +// MvLog().dbg() << MV_FN_INFO << "minVal=" << minVal << " maxvVal=" << maxVal; + auto maxAbs = std::max(std::fabs(minVal), std::fabs(maxVal)); decimalPlaces_ = 0; for (int i = 0; i > -10; i--) { - if (maxAbs > pow(10, static_cast(i))) { + if (maxAbs > std::pow(10, static_cast(i))) { decimalPlaces_ = -i; break; } } - - //Statistics - /*double dval; - if(grib_get_double(gh,"average",&dval) ==CODES_SUCCESS) - average_=dval; - if(grib_get_double(gh,"standardDeviation",&dval) ==CODES_SUCCESS) - stdev_=dval; - if(grib_get_double(gh,"skewness",&dval) ==CODES_SUCCESS) - skewness_=dval; - if(grib_get_double(gh,"kurtosis",&dval) ==CODES_SUCCESS) - kurtosis_=dval;*/ - num_ = latNum; +// MvLog().dbg() << "decimalPlaces=" << decimalPlaces_; } if (gh) @@ -956,7 +943,7 @@ GRIB_DEFINITION_PATH_ENV = std::string(grb_def_path); } - //Define the grib dump program name + // Define the grib dump program name #ifdef ECCODES_UI char* gdexe = getenv("CODES_UI_GRIB_DUMP"); #else @@ -988,7 +975,7 @@ void GribMetaData::setFilter(const std::vector& offset, const std::vector& len) { filterOffset_ = offset; - filterLen_ = len; + filterLen_ = len; filterCnt_.clear(); if (filterOffset_.size() > 0) { @@ -998,14 +985,14 @@ if (offset.size() != 0 && offset.size() == len.size()) { filterEnabled_ = true; - messageNum_ = filterOffset_.size(); + messageNum_ = filterOffset_.size(); } } void GribMetaData::updateFilterCnt(const std::vector& offset, const std::vector& cnt) { filterOffset_ = offset; - filterCnt_ = cnt; + filterCnt_ = cnt; } void GribMetaData::setFileName(std::string fname) @@ -1013,9 +1000,9 @@ clear(); fileName_ = fname; - //totalMessageNum_=computeTotalMessageNum(); - //if(messageNum_ == 0) - // messageNum_=totalMessageNum_; + // totalMessageNum_=computeTotalMessageNum(); + // if(messageNum_ == 0) + // messageNum_=totalMessageNum_; } int GribMetaData::computeTotalMessageNum() @@ -1023,12 +1010,12 @@ FILE* fp; fp = fopen(fileName_.c_str(), "rb"); if (!fp) { - //log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); + // log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); return 0; } int res = 0; - if (grib_count_in_file(0, fp, &res) !=CODES_SUCCESS) + if (grib_count_in_file(0, fp, &res) != CODES_SUCCESS) res = 0; fclose(fp); @@ -1049,19 +1036,19 @@ FILE* fp; grib_handle* gh = nullptr; - int err = 0; + int err = 0; std::string cbuff; - //open grib file for reading + // open grib file for reading fp = fopen(fileName_.c_str(), "r"); if (!fp) { - //GuiLog().error() << "GribMetaData::readMessages() ---> Cannot open grib file: \n " << fileName_ << "\n"; + // GuiLog().error() << "GribMetaData::readMessages() ---> Cannot open grib file: \n " << fileName_ << "\n"; return; } - while ((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err !=CODES_SUCCESS) { + while ((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err != CODES_SUCCESS) { if (!gh) { - //GuiLog().error() << "GribMetaData::readMessages() ---> Unable to create grib handle for message count: " << grib_count+1 << std::endl; + // GuiLog().error() << "GribMetaData::readMessages() ---> Unable to create grib handle for message count: " << grib_count+1 << std::endl; } readMessage(prof, gh); @@ -1299,47 +1286,47 @@ // to be considered: minimum, maximum std::vector key_skiplist = {"distinctLatitudes", "distinctLongitudes", "distinctLatitudes"}; - //Other keys which define constant values and are not really useful for users + // Other keys which define constant values and are not really useful for users key_skiplist.push_back("7777"); key_skiplist.push_back("x"); FILE* fp; - grib_handle* gh = nullptr; + grib_handle* gh = nullptr; grib_keys_iterator* kiter = nullptr; - //const int MAX_KEY_LEN=255; - //const int MAX_VAL_LEN=1024; + // const int MAX_KEY_LEN=255; + // const int MAX_VAL_LEN=1024; unsigned long key_iterator_filter_flags = GRIB_KEYS_ITERATOR_ALL_KEYS; - int err = 0; + int err = 0; int grib_count = 0; int keyType; - //char value[MAX_VAL_LEN]; - //size_t vlen=MAX_VAL_LEN; + // char value[MAX_VAL_LEN]; + // size_t vlen=MAX_VAL_LEN; std::string cbuff; GuiLog().task() << "Generating grib key list for message: " << count << GuiLog::methodKey() << "ecCodes C interface"; - //open grib file for reading + // open grib file for reading fp = fopen(fileName_.c_str(), "rb"); if (!fp) { GuiLog().error() << "GribMetaData::getKeyList() ---> Cannot open grib file: \n " << fileName_ << "\n"; return; } - //Get messages form the file - while ((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err !=CODES_SUCCESS) { + // Get messages form the file + while ((gh = grib_handle_new_from_file(0, fp, &err)) != nullptr || err != CODES_SUCCESS) { grib_count++; - /*if(!gh) - { - log->error("GribMetaData::getKeyList() ---> Unable to create grib handle\n"); - return; - }*/ + /*if(!gh) + { + log->error("GribMetaData::getKeyList() ---> Unable to create grib handle\n"); + return; + }*/ if (grib_count == count) { - //std::cout << "-- GRIB N. " << grib_count << "---/n"; + // std::cout << "-- GRIB N. " << grib_count << "---/n"; if (!gh) { GuiLog().error() << "GribMetaData::getKeyList() ---> Unable to create grib handle for message no: " << grib_count << "\n"; @@ -1353,7 +1340,7 @@ } for (unsigned int ns = 0; ns < nameSpaceL.size(); ns++) { - //Get key iterator + // Get key iterator kiter = grib_keys_iterator_new(gh, key_iterator_filter_flags, nameSpaceL[ns]); if (!kiter) { GuiLog().error() << "GribMetaData::getKeyList() ---> Unable to create keys iterator for message no: " << grib_count << "\n"; @@ -1366,7 +1353,7 @@ return; } - //Loop for the keys in the current message until all the keys are found + // Loop for the keys in the current message until all the keys are found while (grib_keys_iterator_next(kiter)) { const char* name = grib_keys_iterator_get_name(kiter); if (!name) { @@ -1380,12 +1367,12 @@ if (i != key_skiplist.end()) continue; - //Add namespace prefix to the key name (e.g. mars.param) + // Add namespace prefix to the key name (e.g. mars.param) if (nameSpaceL[ns] != 0) { cbuff = std::string(nameSpaceL[ns]) + "." + cbuff; } - if (grib_get_native_type(gh, cbuff.c_str(), &keyType) ==CODES_SUCCESS && + if (grib_get_native_type(gh, cbuff.c_str(), &keyType) == CODES_SUCCESS && (keyType == CODES_TYPE_STRING || keyType == CODES_TYPE_LONG || keyType == CODES_TYPE_DOUBLE)) { keys.push_back(cbuff); @@ -1406,7 +1393,7 @@ fclose(fp); - //This has to be called before calling return in this method!! + // This has to be called before calling return in this method!! for (auto& it : nameSpaceL) { if (it != 0) delete[] it; @@ -1437,16 +1424,16 @@ size_t len; int keyType; const std::string& name = prof->at(i)->name(); - bool foundValue = false; + bool foundValue = false; - if (grib_get_native_type(gh, name.c_str(), &keyType) ==CODES_SUCCESS && - grib_get_size(gh, name.c_str(), &len) ==CODES_SUCCESS && + if (grib_get_native_type(gh, name.c_str(), &keyType) == CODES_SUCCESS && + grib_get_size(gh, name.c_str(), &len) == CODES_SUCCESS && (keyType == CODES_TYPE_STRING || keyType == CODES_TYPE_LONG || keyType == CODES_TYPE_DOUBLE)) { if (keyType == CODES_TYPE_STRING || len == 1) { if (prof->at(i)->readIntAsString() == false && keyType == CODES_TYPE_LONG) { - if (grib_get_long(gh, name.c_str(), &longValue) ==CODES_SUCCESS) { + if (grib_get_long(gh, name.c_str(), &longValue) == CODES_SUCCESS) { std::stringstream s; s << longValue; prof->at(i)->addValue(s.str().c_str()); @@ -1455,7 +1442,7 @@ } else { vlen = MAX_VAL_LEN; - if (grib_get_string(gh, name.c_str(), value, &vlen) ==CODES_SUCCESS) { + if (grib_get_string(gh, name.c_str(), value, &vlen) == CODES_SUCCESS) { prof->at(i)->addValue(value); foundValue = true; } @@ -1464,7 +1451,7 @@ else if ((strcmp(name.c_str(), "paramId") == 0 || strcmp(name.c_str(), "parameter.paramId") == 0) && keyType == CODES_TYPE_LONG) { if (prof->at(i)->readIntAsString() == false) { - if (grib_get_long(gh, name.c_str(), &longValue) ==CODES_SUCCESS) { + if (grib_get_long(gh, name.c_str(), &longValue) == CODES_SUCCESS) { std::stringstream s; s << longValue; prof->at(i)->addValue(s.str().c_str()); @@ -1473,7 +1460,7 @@ } else { vlen = MAX_VAL_LEN; - if (grib_get_string(gh, name.c_str(), value, &vlen) ==CODES_SUCCESS) { + if (grib_get_string(gh, name.c_str(), value, &vlen) == CODES_SUCCESS) { prof->at(i)->addValue(value); foundValue = true; } diff -Nru metview-5.17.4/metview/src/libMetview/GribMetaData.h metview-5.19.2/metview/src/libMetview/GribMetaData.h --- metview-5.17.4/metview/src/libMetview/GribMetaData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/GribMetaData.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ #include "MvVariant.h" #ifdef METVIEW -//for off_t +// for off_t #include "mars.h" #endif @@ -39,16 +39,17 @@ const std::string& type() const { return type_; } template - void setValue(T val, const std::string& strVal={}) { + void setValue(T val, const std::string& strVal = {}) + { value_ = MvVariant(val); - strValue_ = (strVal.empty())?value_.toString():strVal; + strValue_ = (strVal.empty()) ? value_.toString() : strVal; } -// void setValue(long val, const std::string& strVal ={}) { -// value_ = val; strValue_ = strVal.empty()?val:strVal;} -// void setValue(double val, const std::string& strVal ={}) { -// value_ = val; strValue_ = strVal.empty()?val:strVal;} -// void setValue(const std::string& val) { -// value_ = val; strValue_ = val;} + // void setValue(long val, const std::string& strVal ={}) { + // value_ = val; strValue_ = strVal.empty()?val:strVal;} + // void setValue(double val, const std::string& strVal ={}) { + // value_ = val; strValue_ = strVal.empty()?val:strVal;} + // void setValue(const std::string& val) { + // value_ = val; strValue_ = val;} const MvVariant& value() const { return value_; } const std::string& strValue() const { return strValue_; } void setDescription(const std::string& s) { description_ = s; } @@ -158,33 +159,26 @@ class GribValueDump { public: - GribValueDump(); + GribValueDump() = default; ~GribValueDump(); void clear(); - bool read(const std::string&, int); + bool read(const std::string&, int, std::string&, std::string&); double* latitude() { return latitude_; } double* longitude() { return longitude_; } double* value() { return value_; } int num() { return num_; } int decimalPlaces() { return decimalPlaces_; } - double average() { return average_; } - double stdev() { return stdev_; } - double skewness() { return skewness_; } - double kurtosis() { return kurtosis_; } protected: void readFailed(FILE*, grib_handle*); - double* latitude_; - double* longitude_; - double* value_; - int num_; - int decimalPlaces_; + double* latitude_{nullptr}; + double* longitude_{nullptr}; + double* value_{nullptr}; + int num_{0}; + int decimalPlaces_{0}; std::string gridType_; - double average_; - double stdev_; - double skewness_; - double kurtosis_; + static const int maxNum_; }; @@ -210,7 +204,7 @@ void clear(); private: - //void readMessages(MvKeyProfile *); + // void readMessages(MvKeyProfile *); void readMessage(MvKeyProfile*, grib_handle*); void setDateStructure(); diff -Nru metview-5.17.4/metview/src/libMetview/GribVertical.cc metview-5.19.2/metview/src/libMetview/GribVertical.cc --- metview-5.17.4/metview/src/libMetview/GribVertical.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/GribVertical.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,25 +24,34 @@ #include "MvLog.h" #include "MvSci.h" -namespace metview { +namespace metview +{ class SimpleFieldMetaData { friend class SimpleField; + public: SimpleFieldMetaData() = default; - int level() const {return level_;} - int paramId() const {return paramId_;} + int level() const { return level_; } + int paramId() const { return paramId_; } int levelInPa() const; - bool isSpectral() const {return spectral_;} - bool isPressureLevel() const {return levelType_ == IsobaricInHPaLevel || levelType_ == IsobaricInPaLevel;} - bool isModelLevel() const {return levelType_ == ModelLevel;} + bool isSpectral() const { return spectral_; } + bool isPressureLevel() const { return levelType_ == IsobaricInHPaLevel || levelType_ == IsobaricInPaLevel; } + bool isModelLevel() const { return levelType_ == ModelLevel; } protected: void setSpectral(const std::string& gridType); void setLevelType(const std::string& typeOfLevel); - enum LevelType {NoLevelType, IsobaricInPaLevel, IsobaricInHPaLevel, ModelLevel, OtherLevelType}; + enum LevelType + { + NoLevelType, + IsobaricInPaLevel, + IsobaricInHPaLevel, + ModelLevel, + OtherLevelType + }; int level_{-1}; int paramId_{-1}; bool spectral_{false}; @@ -56,20 +65,21 @@ class SimpleField : public std::enable_shared_from_this { friend class SimpleFieldset; + public: - static SimpleFieldPtr make(field* f=nullptr); + static SimpleFieldPtr make(field* f = nullptr); ~SimpleField(); SimpleField(const SimpleField&) = delete; SimpleField& operator=(const SimpleField&) = delete; - field* rawField() const {return field_;} - double* values() const {return field_->values;} - std::size_t valueNum() const {return field_?(field_->value_count):0;} + field* rawField() const { return field_; } + double* values() const { return field_->values; } + std::size_t valueNum() const { return field_ ? (field_->value_count) : 0; } bool hasValidValues() const; - bool isExpanded() const {return field_?(field_->shape == expand_mem):false;} + bool isExpanded() const { return field_ ? (field_->shape == expand_mem) : false; } void expandMemory(); void releaseMemory(); - bool isEmpty() const {return field_ == nullptr;} + bool isEmpty() const { return field_ == nullptr; } field* cloneRaw(bool copyValues); @@ -91,31 +101,59 @@ void computeDiffMinMax(SimpleFieldPtr other, double& spMin, double& spMax); // pressure + ml - void halfPres(double *sp, double* mlPres, std::size_t num, int ml); + void halfPres(double* sp, double* mlPres, std::size_t num, int ml); void meanMlPressureFromSp(double* sp, double* mlPres, std::size_t num, int ml); double meanMlPressureFromSp(double sp, int ml); void mlPressureLayerFromSp(double* sp, double* mlPres, std::size_t num, int ml); void addMlPressureIntegralDeltaFromSp(SimpleFieldPtr sp, double* res); - int totalMlLevelNum() {return pvPairCount()-1;} + int totalMlLevelNum() { return pvPairCount() - 1; } // metadat access - int level() {loadMetaData(); return md_->level();} - int levelInPa() {loadMetaData(); return md_->levelInPa();} - int paramId() {loadMetaData(); return md_->paramId();} - bool isPressureLevel() {loadMetaData(); return md_->isPressureLevel();} - bool isModelLevel() {loadMetaData(); return md_->isModelLevel();} - bool isSpectral() {loadMetaData(); return md_->isSpectral();} - - SimpleFieldMetaDataPtr metaData() {loadMetaData(); return md_;} + int level() + { + loadMetaData(); + return md_->level(); + } + int levelInPa() + { + loadMetaData(); + return md_->levelInPa(); + } + int paramId() + { + loadMetaData(); + return md_->paramId(); + } + bool isPressureLevel() + { + loadMetaData(); + return md_->isPressureLevel(); + } + bool isModelLevel() + { + loadMetaData(); + return md_->isModelLevel(); + } + bool isSpectral() + { + loadMetaData(); + return md_->isSpectral(); + } + + SimpleFieldMetaDataPtr metaData() + { + loadMetaData(); + return md_; + } protected: - SimpleField(field* f=nullptr); + SimpleField(field* f = nullptr); void loadPv(); void loadMetaData(); int pvPairCount(); bool mlCoeffs(double& c1, double& c2, int ml); - static void computeMinMax(field *fs, double& minv, double& maxv); - static void computeDiffMinMax(field *fs1, field *fs2, double& minv, double& maxv); + static void computeMinMax(field* fs, double& minv, double& maxv); + static void computeDiffMinMax(field* fs1, field* fs2, double& minv, double& maxv); long getLongValue(const std::string& key); void getStringValue(const std::string& key, std::string& val); @@ -134,8 +172,8 @@ void sort(const std::string& key, bool ascending); void sortLevelsByPa(bool ascending); SimpleFieldPtr operator[](int i); - std::size_t size() const {return fields_.size();} - bool isEmpty() const {return size() == 0;} + std::size_t size() const { return fields_.size(); } + bool isEmpty() const { return size() == 0; } protected: fieldset* fs_{nullptr}; @@ -147,10 +185,11 @@ { public: virtual ~SimpleFieldExpander() = default; - SimpleFieldPtr field() const {return field_;} + SimpleFieldPtr field() const { return field_; } protected: - SimpleFieldExpander(SimpleFieldPtr f) : field_{f} {} + SimpleFieldExpander(SimpleFieldPtr f) : + field_{f} {} SimpleFieldPtr field_{nullptr}; field_state oriState_{unknown}; @@ -168,6 +207,7 @@ public: SimpleFieldMetaDataExpander(SimpleFieldPtr); ~SimpleFieldMetaDataExpander(); + private: bool revert_{false}; }; @@ -178,8 +218,11 @@ FieldExpanderOrArray(SimpleFieldPtr); FieldExpanderOrArray(std::size_t num, double val); ~FieldExpanderOrArray(); - double* values() const {return (xp_)?xp_->field()->values():vals_;} - std::size_t num() const {return (xp_)?xp_->field()->valueNum():num_;} + FieldExpanderOrArray(const FieldExpanderOrArray&) = delete; + FieldExpanderOrArray& operator=(const FieldExpanderOrArray&) = delete; + + double* values() const { return (xp_) ? xp_->field()->values() : vals_; } + std::size_t num() const { return (xp_) ? xp_->field()->valueNum() : num_; } private: SimpleFieldDataExpander* xp_{nullptr}; @@ -202,11 +245,14 @@ { if (typeOfLevel == "isobaricInPa") { levelType_ = IsobaricInPaLevel; - } else if (typeOfLevel == "isobaricInhPa") { + } + else if (typeOfLevel == "isobaricInhPa") { levelType_ = IsobaricInHPaLevel; - } else if (typeOfLevel == "hybrid") { + } + else if (typeOfLevel == "hybrid") { levelType_ = ModelLevel; - } else if (!typeOfLevel.empty()) { + } + else if (!typeOfLevel.empty()) { levelType_ = OtherLevelType; } } @@ -215,8 +261,9 @@ { if (levelType_ == IsobaricInPaLevel) { return level_; - } else if (levelType_ == IsobaricInHPaLevel) { - return level_*100; + } + else if (levelType_ == IsobaricInHPaLevel) { + return level_ * 100; } return -1; } @@ -232,7 +279,8 @@ return SimpleFieldPtr(new SimpleField(f)); } -SimpleField::SimpleField(field* f) : field_(f) +SimpleField::SimpleField(field* f) : + field_(f) { } @@ -259,13 +307,17 @@ { // make sure the raw field is expanded field_state ori = field_->shape; - int oriRefCnt = (field_->r)?field_->r->refcnt:-1000; + int oriRefCnt = (field_->r) ? field_->r->refcnt : -1000; set_field_state(field_, expand_mem); // create new field - field* r = copy_field(field_, copyValues); + field* r = copy_field(field_, true); set_field_state(r, expand_mem); - r->bitmap = copyValues?field_->bitmap:false; + r->bitmap = copyValues ? field_->bitmap : false; + + if (!copyValues) { + setValues(r, 0.); + } // decouple the request from the source if (r->r && field_->r && r->r == field_->r) { @@ -284,7 +336,7 @@ int SimpleField::pvPairCount() { loadPv(); - return pv_.size()/2; + return pv_.size() / 2; } void SimpleField::loadPv() @@ -299,9 +351,9 @@ int err = grib_get_double_array(field_->handle, "pv", vals, &pvNum); if (err == 0) { pv_.reserve(pvNum); - pv_.assign(vals, vals+pvNum); + pv_.assign(vals, vals + pvNum); } - delete [] vals; + delete[] vals; } } } @@ -310,7 +362,7 @@ { c1 = c2 = 0.; loadPv(); - if (lev >=0 && lev < pvPairCount()) { + if (lev >= 0 && lev < pvPairCount()) { c1 = pv_[lev]; c2 = pv_[lev + pvPairCount()]; return true; @@ -318,14 +370,15 @@ return false; } -void SimpleField::halfPres(double *sp, double* mlPres, std::size_t num, int ml) +void SimpleField::halfPres(double* sp, double* mlPres, std::size_t num, int ml) { double A, B; - mlCoeffs(A, B, ml-1); - for (std::size_t i=0; i < num; i++) { + mlCoeffs(A, B, ml - 1); + for (std::size_t i = 0; i < num; i++) { if (!MISSING_VALUE(sp[i])) { mlPres[i] = A + B * sp[i]; - } else { + } + else { mlPres[i] = mars.grib_missing_value; } } @@ -340,7 +393,7 @@ void SimpleField::meanMlPressureFromSp(double* sp, double* mlPres, std::size_t num, int ml) { - assert(ml>=1); + assert(ml >= 1); if (pvPairCount() > 1) { double C11, C12, C21, C22; @@ -348,10 +401,11 @@ mlCoeffs(C12, C22, ml); auto A = C11 + C12; auto B = C21 + C22; - for (std::size_t i=0; i < num; i++) { + for (std::size_t i = 0; i < num; i++) { if (!MISSING_VALUE(sp[i])) { - mlPres[i] = ( A + B * sp[i]) / 2.0; - } else { + mlPres[i] = (A + B * sp[i]) / 2.0; + } + else { mlPres[i] = mars.grib_missing_value; } } @@ -359,20 +413,20 @@ else { double C12, C22; mlCoeffs(C12, C22, ml); - for (std::size_t i=0; i < num; i++) { + for (std::size_t i = 0; i < num; i++) { if (!MISSING_VALUE(sp[i])) { mlPres[i] = C12 + C22 * sp[i]; - } else { + } + else { mlPres[i] = mars.grib_missing_value; } - } } } void SimpleField::mlPressureLayerFromSp(double* sp, double* mlPres, std::size_t num, int ml) { - assert(ml>=1); + assert(ml >= 1); if (pvPairCount() > 1) { double C11, C12, C21, C22; @@ -380,16 +434,17 @@ mlCoeffs(C12, C22, ml); auto A = C12 - C11; auto B = C22 - C21; - for (std::size_t i=0; i < num; i++) { + for (std::size_t i = 0; i < num; i++) { if (!MISSING_VALUE(sp[i])) { mlPres[i] = A + B * sp[i]; - } else { + } + else { mlPres[i] = mars.grib_missing_value; } } } else { - for (std::size_t i=0; i < num; i++) { + for (std::size_t i = 0; i < num; i++) { mlPres[i] = mars.grib_missing_value; } } @@ -400,24 +455,26 @@ assert(sp); auto num = valueNum(); if (sp->pvPairCount() > 1) { - assert(level()>=1); + auto lev = level(); + assert(lev >= 1); double C11, C12, C21, C22; - sp->mlCoeffs(C11, C21, level() - 1); - sp->mlCoeffs(C12, C22, level()); + sp->mlCoeffs(C11, C21, lev - 1); + sp->mlCoeffs(C12, C22, lev); auto A = C12 - C11; auto B = C22 - C21; double* spVals = sp->values(); double* vals = values(); - for (std::size_t i=0; i < num; i++) { + for (std::size_t i = 0; i < num; i++) { if (!MISSING_VALUE(spVals[i]) && !MISSING_VALUE(res[i]) && !MISSING_VALUE(vals[i])) { - res[i] += (A + B * spVals[i])*vals[i]; - } else { + res[i] += (A + B * spVals[i]) * vals[i]; + } + else { res[i] = mars.grib_missing_value; } } } else { - for (std::size_t i=0; i < num; i++) { + for (std::size_t i = 0; i < num; i++) { res[i] = mars.grib_missing_value; } } @@ -426,7 +483,7 @@ void SimpleField::transformValues(DoubleFuncPtr1 func) { assert(isExpanded()); - for (std::size_t i=0; i < field_->value_count; i++) { + for (std::size_t i = 0; i < field_->value_count; i++) { if (!MISSING_VALUE(field_->values[i])) { field_->values[i] = func(field_->values[i]); } @@ -436,7 +493,7 @@ void SimpleField::transformValues(DoubleFuncPtr2 func) { assert(isExpanded()); - for (std::size_t i=0; i < field_->value_count; i++) { + for (std::size_t i = 0; i < field_->value_count; i++) { if (!MISSING_VALUE(field_->values[i])) { field_->values[i] = func(field_->values[i]); } @@ -447,7 +504,7 @@ { assert(isExpanded()); auto of = other->rawField(); - for (std::size_t i=0; i < field_->value_count; i++) { + for (std::size_t i = 0; i < field_->value_count; i++) { if (!MISSING_VALUE(field_->values[i]) && !MISSING_VALUE(of->values[i])) { field_->values[i] -= of->values[i]; } @@ -457,7 +514,7 @@ bool SimpleField::hasValidValues() const { assert(isExpanded()); - for (std::size_t i=0; i < field_->value_count; i++) { + for (std::size_t i = 0; i < field_->value_count; i++) { if (!MISSING_VALUE(field_->values[i])) { return true; } @@ -486,7 +543,7 @@ if (f) { for (std::size_t i = 0; i < f->value_count; i++) { if (!MISSING_VALUE(f->values[i])) { - f->values[i] = val; + f->values[i] = val; } } } @@ -497,7 +554,7 @@ if (f) { for (std::size_t i = 0; i < f->value_count; i++) { if (!MISSING_VALUE(f->values[i])) { - f->values[i] *= val; + f->values[i] *= val; } } } @@ -508,8 +565,8 @@ assert(isExpanded()); assert(f); assert(field_->value_count == f->value_count); - for (std::size_t i=0; i < field_->value_count; i++) { - f->values[i] = field_->values[i] ; + for (std::size_t i = 0; i < field_->value_count; i++) { + f->values[i] = field_->values[i]; } } @@ -519,12 +576,12 @@ computeMinMax(field_, spMin, spMax); } -void SimpleField::computeMinMax(field *fs, double& minv, double& maxv) +void SimpleField::computeMinMax(field* fs, double& minv, double& maxv) { assert(fs); minv = std::numeric_limits::max(); maxv = std::numeric_limits::min(); - for (size_t i=0; i < fs->value_count; i++) { + for (size_t i = 0; i < fs->value_count; i++) { if (!MISSING_VALUE(fs->values[i])) { if (fs->values[i] < minv) { minv = fs->values[i]; @@ -542,7 +599,7 @@ computeDiffMinMax(field_, other->rawField(), spMin, spMax); } -void SimpleField::computeDiffMinMax(field *fs1, field *fs2, double& minv, double& maxv) +void SimpleField::computeDiffMinMax(field* fs1, field* fs2, double& minv, double& maxv) { assert(fs1); assert(fs2); @@ -552,9 +609,9 @@ } minv = std::numeric_limits::max(); maxv = std::numeric_limits::min(); - for (size_t i=0; i < fs1->value_count; i++) { + for (size_t i = 0; i < fs1->value_count; i++) { if (!MISSING_VALUE(fs1->values[i]) && !MISSING_VALUE(fs2->values[i])) { - auto d = fs1->values[i]-fs2->values[i]; + auto d = fs1->values[i] - fs2->values[i]; if (d < minv) { minv = d; } @@ -567,7 +624,8 @@ long SimpleField::getLongValue(const std::string& key) { - long val = std::numeric_limits::max();; + long val = std::numeric_limits::max(); + ; if (field_) { SimpleFieldMetaDataExpander mdx(shared_from_this()); assert(field_->shape == packed_mem || field_->shape == expand_mem); @@ -614,14 +672,15 @@ // //======================================== -SimpleFieldset::SimpleFieldset(fieldset *fs) : fs_(fs) +SimpleFieldset::SimpleFieldset(fieldset* fs) : + fs_(fs) { if (fs_) { for (int i = 0; i < fs_->count; i++) { fields_.push_back(SimpleField::make(fs->fields[i])); order_.push_back(i); } - } + } } SimpleFieldPtr SimpleFieldset::operator[](int i) @@ -633,30 +692,32 @@ { std::iota(order_.begin(), order_.end(), 0); std::vector md; - for(std::size_t i=0; i < fields_.size(); i++) { + for (std::size_t i = 0; i < fields_.size(); i++) { if (key == "level") { md.push_back(fields_[i]->metaData()->level()); - } else if (key == "levelInPa") { + } + else if (key == "levelInPa") { md.push_back(fields_[i]->metaData()->levelInPa()); - } else { + } + else { md.push_back(fields_[i]->getLongValue(key)); } } std::stable_sort(order_.begin(), order_.end(), - [&md, ascending](size_t i1, size_t i2) { return (ascending)?(md[i1] < md[i2]):(md[i1] > md[i2]);}); + [&md, ascending](size_t i1, size_t i2) { return (ascending) ? (md[i1] < md[i2]) : (md[i1] > md[i2]); }); } void SimpleFieldset::sortLevelsByPa(bool ascending) { std::iota(order_.begin(), order_.end(), 0); std::vector md; - for(std::size_t i=0; i < fields_.size(); i++) { + for (std::size_t i = 0; i < fields_.size(); i++) { md.push_back(fields_[i]->metaData()->levelInPa()); } std::stable_sort(order_.begin(), order_.end(), - [&md, ascending](size_t i1, size_t i2) { return (ascending)?(md[i1] < md[i2]):(md[i1] > md[i2]);}); + [&md, ascending](size_t i1, size_t i2) { return (ascending) ? (md[i1] < md[i2]) : (md[i1] > md[i2]); }); } //======================================== @@ -665,10 +726,11 @@ // //======================================== -SimpleFieldDataExpander::SimpleFieldDataExpander(SimpleFieldPtr f) : SimpleFieldExpander(f) +SimpleFieldDataExpander::SimpleFieldDataExpander(SimpleFieldPtr f) : + SimpleFieldExpander(f) { if (field_) { - auto *g = field_->rawField(); + auto* g = field_->rawField(); if (g) { oriState_ = g->shape; set_field_state(g, expand_mem); @@ -680,7 +742,7 @@ SimpleFieldDataExpander::~SimpleFieldDataExpander() { if (field_) { - auto *g = field_->rawField(); + auto* g = field_->rawField(); if (g) { // if we revert back to packed_mem (from expand_mem) set_field_state() // will always write the values back to the grib_handle. This is unnecessary @@ -689,10 +751,11 @@ // it so could avoid using this low level code here! if (oriState_ == packed_mem) { release_mem(g->values); - g->values = NULL; + g->values = NULL; g->value_count = 0; - g->shape = packed_mem; - } else { + g->shape = packed_mem; + } + else { set_field_state(g, oriState_); } } @@ -705,10 +768,11 @@ // //======================================== -SimpleFieldMetaDataExpander::SimpleFieldMetaDataExpander(SimpleFieldPtr f) : SimpleFieldExpander(f) +SimpleFieldMetaDataExpander::SimpleFieldMetaDataExpander(SimpleFieldPtr f) : + SimpleFieldExpander(f) { if (field_) { - auto *g = field_->rawField(); + auto* g = field_->rawField(); if (g) { if (g->shape != packed_mem && g->shape != expand_mem) { oriState_ = field_->rawField()->shape; @@ -722,12 +786,12 @@ SimpleFieldMetaDataExpander::~SimpleFieldMetaDataExpander() { - if (revert_ && field_) { - auto *g = field_->rawField(); - if (g) { + if (revert_ && field_) { + auto* g = field_->rawField(); + if (g) { set_field_state(g, oriState_); - } - } + } + } } //======================================== @@ -741,10 +805,11 @@ xp_ = new SimpleFieldDataExpander(fld); } -FieldExpanderOrArray::FieldExpanderOrArray(std::size_t num, double val) : num_(num) +FieldExpanderOrArray::FieldExpanderOrArray(std::size_t num, double val) : + num_(num) { vals_ = new double[num_]; - for(std::size_t k=0; k < num_; k++) { + for (std::size_t k = 0; k < num_; k++) { vals_[k] = val; } } @@ -755,7 +820,7 @@ delete xp_; } if (vals_) { - delete [] vals_; + delete[] vals_; } } @@ -770,7 +835,7 @@ { } -void VerticalInterpolation::setTargetVc(fieldset *fs) +void VerticalInterpolation::setTargetVc(fieldset* fs) { targetVcMode_ = FieldsetTargetCoord; targetVcFs_ = fs; @@ -794,19 +859,20 @@ surfVal_ = v; } -void VerticalInterpolation::computeSurfaceVcMinMax(SimpleFieldPtr f, double &vmin, double &vmax) +void VerticalInterpolation::computeSurfaceVcMinMax(SimpleFieldPtr f, double& vmin, double& vmax) { if (targetLevType_ == HeightLevelAGR) { vmin = 0.; vmax = 0.; - } else { + } + else { assert(f); assert(f->isExpanded()); f->computeMinMax(vmin, vmax); } } -void VerticalInterpolation::computeVcMinMax(SimpleFieldPtr vcF, SimpleFieldPtr surfVcF, double &vmin, double &vmax) +void VerticalInterpolation::computeVcMinMax(SimpleFieldPtr vcF, SimpleFieldPtr surfVcF, double& vmin, double& vmax) { assert(vcF); assert(vcF->isExpanded()); @@ -814,7 +880,8 @@ assert(surfVcF); assert(surfVcF->isExpanded()); vcF->computeDiffMinMax(surfVcF, vmin, vmax); - } else { + } + else { vcF->computeMinMax(vmin, vmax); } } @@ -823,7 +890,7 @@ { if (vcScaleNeeded_) { if (!MISSING_VALUE(v)) { - return v*vcFactor_; + return v * vcFactor_; } } return v; @@ -834,46 +901,46 @@ assert(f); assert(!f->isEmpty()); if (vcScaleNeeded_) { - auto p = [this](double v) ->double {return v*vcFactor_;}; + auto p = [this](double v) -> double { return v * vcFactor_; }; f->transformValues(p); -// auto v = f->values(); -// for(std::size_t k=0; k < f->valueNum(); k++) { -// if (!MISSING_VALUE(v[k])) { -// v[k] *= vcFactor_; -// } -// } + // auto v = f->values(); + // for(std::size_t k=0; k < f->valueNum(); k++) { + // if (!MISSING_VALUE(v[k])) { + // v[k] *= vcFactor_; + // } + // } } - } bool VerticalInterpolation::findBracketingIdx(double vcVal, const std::vector& vcMin, const std::vector& vcMax, - int& idxFrom, int& idxTo) + int& idxFrom, int& idxTo) { if (targetAscending_) { if (vcMin.front() <= vcVal && vcMax.back() >= vcVal) { - for(std::size_t j=0; j vcVal) { - idxTo=j; + idxTo = j; break; } } return true; } - } else { + } + else { if (vcMin.back() <= vcVal && vcMax.front() >= vcVal) { - for(std::size_t j=0; j vcVal) { - idxFrom=j; + idxFrom = j; } } - for(std::size_t j=0; j < vcMax.size(); j++) { + for (std::size_t j = 0; j < vcMax.size(); j++) { if (vcMax[j] < vcVal) { - idxTo=j; + idxTo = j; break; } } @@ -884,17 +951,17 @@ } bool VerticalInterpolation::findBracketingIdx(double targetMin, double targetMax, const std::vector& vcMin, const std::vector& vcMax, - int& idxFrom, int& idxTo) + int& idxFrom, int& idxTo) { if (vcMin.front() <= targetMax && vcMax.back() >= targetMin) { - for(std::size_t j=0; j targetMax) { - idxTo=j; + idxTo = j; break; } } @@ -906,20 +973,20 @@ // fixed coordinate levels bool VerticalInterpolation::findBracketingIdx(double targetVc, const std::vector& vc, int& idxFrom, int& idxTo) { - double eps=1e-5; + double eps = 1e-5; if (!targetAscending_) { if (vc.front() >= targetVc && vc.back() <= targetVc) { - for(std::size_t j=0; j targetVc && vc[j+1] < targetVc) { - idxFrom =j; - idxTo = j+1; + for (std::size_t j = 0; j < vc.size() - 1; j++) { + if (vc[j] > targetVc && vc[j + 1] < targetVc) { + idxFrom = j; + idxTo = j + 1; return true; } } @@ -939,27 +1006,29 @@ method = LinearInterpolation; } - double dTarget = targetVcVal-vc1; - double dVc = (vc2-vc1); - double dLogTarget = std::log(targetVcVal/vc1); - double dLogVc = std::log(vc2/vc1); + double dTarget = targetVcVal - vc1; + double dVc = (vc2 - vc1); + double dLogTarget = std::log(targetVcVal / vc1); + double dLogVc = std::log(vc2 / vc1); - //vc1 <= targetVcVal && targetVcVal < vc2 - for (std::size_t k=0; k < num; k++) { + // vc1 <= targetVcVal && targetVcVal < vc2 + for (std::size_t k = 0; k < num; k++) { if (!MISSING_VALUE(f1[k]) && !MISSING_VALUE(f2[k])) { if (method == LinearInterpolation) { - fRes->values[k] = f1[k] + dTarget*(f2[k]-f1[k])/dVc; - } else { - fRes->values[k] = f1[k] + dLogTarget*(f2[k]-f1[k])/dLogVc; + fRes->values[k] = f1[k] + dTarget * (f2[k] - f1[k]) / dVc; } - } else { + else { + fRes->values[k] = f1[k] + dLogTarget * (f2[k] - f1[k]) / dLogVc; + } + } + else { fRes->values[k] = mars.grib_missing_value; fRes->bitmap = 1; } } } -void VerticalInterpolation::interpolate(double targetVcVal, double *vc1, double* vc2, +void VerticalInterpolation::interpolate(double targetVcVal, double* vc1, double* vc2, double* f1, double* f2, field* fRes, size_t num, int idx, int idxFrom, int idxTo, double vcMin) { auto method = interMethod_; @@ -969,29 +1038,32 @@ method = LinearInterpolation; } - for (std::size_t k=0; k < num; k++) { - if ( !MISSING_VALUE(vc1[k]) && !MISSING_VALUE(vc2[k]) && - vc1[k] <= targetVcVal && targetVcVal < vc2[k]) { + for (std::size_t k = 0; k < num; k++) { + if (!MISSING_VALUE(vc1[k]) && !MISSING_VALUE(vc2[k]) && + vc1[k] <= targetVcVal && targetVcVal < vc2[k]) { if (!MISSING_VALUE(f1[k]) && !MISSING_VALUE(f2[k])) { if (method == LinearInterpolation) { - fRes->values[k] = f1[k] + (targetVcVal-vc1[k])*(f2[k]-f1[k])/(vc2[k]-vc1[k]); - } else { + fRes->values[k] = f1[k] + (targetVcVal - vc1[k]) * (f2[k] - f1[k]) / (vc2[k] - vc1[k]); + } + else { fRes->values[k] = f1[k] + - std::log(targetVcVal/vc1[k])*(f2[k]-f1[k])/std::log(vc2[k]/vc1[k]); + std::log(targetVcVal / vc1[k]) * (f2[k] - f1[k]) / std::log(vc2[k] / vc1[k]); } - } else { + } + else { fRes->values[k] = mars.grib_missing_value; fRes->bitmap = 1; } - } else if ((targetAscending_ && ((idx==idxFrom && targetVcVal < vc1[k]) || (idx == idxTo-1 && targetVcVal > vc2[k]))) || - (!targetAscending_ && ((idx==idxFrom && targetVcVal > vc2[k]) || (idx == idxTo-1 && targetVcVal < vc1[k])))) { + } + else if ((targetAscending_ && ((idx == idxFrom && targetVcVal < vc1[k]) || (idx == idxTo - 1 && targetVcVal > vc2[k]))) || + (!targetAscending_ && ((idx == idxFrom && targetVcVal > vc2[k]) || (idx == idxTo - 1 && targetVcVal < vc1[k])))) { fRes->values[k] = mars.grib_missing_value; fRes->bitmap = 1; } } } -void VerticalInterpolation::interpolate(double* targetVcVal, double *vc1, double* vc2, +void VerticalInterpolation::interpolate(double* targetVcVal, double* vc1, double* vc2, double* f1, double* f2, field* fRes, size_t num, int idx, int idxFrom, int idxTo, double vcMin, double targetVcMin, double targetVcMax) { @@ -1007,22 +1079,25 @@ std::cout << "idx=" << idx << " target=" << targetVcVal[pos] << " vc1=" << vc1[pos] << " vc2=" << vc2[pos] << std::endl; #endif - for (std::size_t k=0; k < num; k++) { - if ( !MISSING_VALUE(vc1[k]) && !MISSING_VALUE(vc2[k] && !MISSING_VALUE(targetVcVal[k])) && - vc1[k] <= targetVcVal[k] && targetVcVal[k] < vc2[k]) { + for (std::size_t k = 0; k < num; k++) { + if (!MISSING_VALUE(vc1[k]) && !MISSING_VALUE(vc2[k] && !MISSING_VALUE(targetVcVal[k])) && + vc1[k] <= targetVcVal[k] && targetVcVal[k] < vc2[k]) { if (!MISSING_VALUE(f1[k]) && !MISSING_VALUE(f2[k])) { if (method == LinearInterpolation) { - fRes->values[k] = f1[k] + (targetVcVal[k]-vc1[k])*(f2[k]-f1[k])/(vc2[k]-vc1[k]); - } else { + fRes->values[k] = f1[k] + (targetVcVal[k] - vc1[k]) * (f2[k] - f1[k]) / (vc2[k] - vc1[k]); + } + else { fRes->values[k] = f1[k] + - std::log(targetVcVal[k]/vc1[k])*(f2[k]-f1[k])/std::log(vc2[k]/vc1[k]); + std::log(targetVcVal[k] / vc1[k]) * (f2[k] - f1[k]) / std::log(vc2[k] / vc1[k]); } - } else { + } + else { fRes->values[k] = mars.grib_missing_value; fRes->bitmap = 1; } - } else if ((targetAscending_ && ((idx==idxFrom && targetVcMax < vc1[k]) || (idx == idxTo-1 && targetVcMin > vc2[k]))) || - (!targetAscending_ && ((idx==idxFrom && targetVcMin > vc2[k]) || (idx == idxTo-1 && targetVcMax < vc1[k])))) { + } + else if ((targetAscending_ && ((idx == idxFrom && targetVcMax < vc1[k]) || (idx == idxTo - 1 && targetVcMin > vc2[k]))) || + (!targetAscending_ && ((idx == idxFrom && targetVcMin > vc2[k]) || (idx == idxTo - 1 && targetVcMax < vc1[k])))) { fRes->values[k] = mars.grib_missing_value; fRes->bitmap = 1; } @@ -1050,7 +1125,7 @@ vcFs.sort("level", srcAscending_); // compute min and max vc on all the levels ... - size_t num =0; + size_t num = 0; std::vector vcMax, vcMin; std::vector vcLev; int surfIdxOffset = 0; @@ -1065,7 +1140,7 @@ // ... but first handle the surface if (surfValMode_ != NoSurfaceValue) { - vcLev.push_back(0); // a made up level + vcLev.push_back(0); // a made up level double vmin, vmax; assert(surfVcF); computeSurfaceVcMinMax(surfVcF, vmin, vmax); @@ -1075,10 +1150,10 @@ } // ... then the other levels - for (std::size_t i=0; i < vcFs.size(); i++) { + for (std::size_t i = 0; i < vcFs.size(); i++) { SimpleFieldDataExpander fx(vcFs[i]); double vmin, vmax; - computeVcMinMax( vcFs[i], surfVcF, vmin, vmax); + computeVcMinMax(vcFs[i], surfVcF, vmin, vmax); vcMin.push_back(vmin); vcMax.push_back(vmax); vcLev.push_back(vcFs[i]->metaData()->level()); @@ -1098,20 +1173,20 @@ // define the resulting fieldset fieldset* result = new_fieldset(targetVc_.size()); - //SimpleField surfValF; + // SimpleField surfValF; SimpleFieldPtr surfValF; SimpleFieldset targetVcFs(targetVcFs_); - int targetVcNum = (targetVcMode_ == VectorTargetCoord)?static_cast(targetVc_.size()):targetVcFs.size(); + int targetVcNum = (targetVcMode_ == VectorTargetCoord) ? static_cast(targetVc_.size()) : targetVcFs.size(); // perform the interpolation for all the target vc levels - for (int i=0; i < targetVcNum; i++) { + for (int i = 0; i < targetVcNum; i++) { // create a field for the result field* fRes = fs[0]->cloneRaw(false); assert(fRes->shape = expand_mem); // find bracketing levels - int idxFrom=0; - int idxTo=static_cast(vcMin.size())-1; + int idxFrom = 0; + int idxTo = static_cast(vcMin.size()) - 1; bool hasBracket = false; double targetVcMin, targetVcMax; if (targetVcMode_ == VectorTargetCoord) { @@ -1120,7 +1195,8 @@ // units as the vc fields. This is the most effective way to carry out the computations double targetVcVal = scaleVc(targetVc_[i]); hasBracket = findBracketingIdx(targetVcVal, vcMin, vcMax, idxFrom, idxTo) && idxFrom < idxTo; - } else { + } + else { assert(!targetVcFs.isEmpty()); targetVcFs[i]->expandMemory(); scaleVc(targetVcFs[i]); @@ -1129,8 +1205,9 @@ } if (!hasBracket) { - SimpleField::setAllValuesToMissing(fRes); - } else { + SimpleField::setAllValuesToMissing(fRes); + } + else { // Iterate through level pairs // Only keep two data/vc levels expanded at the same time. @@ -1141,48 +1218,50 @@ if (surfIdxOffset == 1 && idxFrom == 0) { assert(surfValMode_ != NoSurfaceValue); // surf data - if (surfValMode_ == FieldsetSurfaceValue) { + if (surfValMode_ == FieldsetSurfaceValue) { if (!surfValF) { - surfValF = SimpleField::make(surfValFs_->fields[0]); + surfValF = SimpleField::make(surfValFs_->fields[0]); } expandValMap.emplace(idxFrom, surfValF); - } else if (surfValMode_ == NumberSurfaceValue) { + } + else if (surfValMode_ == NumberSurfaceValue) { expandValMap.emplace(std::piecewise_construct, - std::forward_as_tuple(idxFrom), - std::forward_as_tuple(num, surfVal_)); + std::forward_as_tuple(idxFrom), + std::forward_as_tuple(num, surfVal_)); } if (targetLevType_ == HeightLevelAGR) { expandVcMap.emplace(std::piecewise_construct, - std::forward_as_tuple(idxFrom), - std::forward_as_tuple(num, 0.)); - } else { + std::forward_as_tuple(idxFrom), + std::forward_as_tuple(num, 0.)); + } + else { // surfVcF is already expanded! expandVcMap.emplace(idxFrom, surfVcF); } - // The start level is not the surface - } else { - expandValMap.emplace(idxFrom, fs[idxFrom-surfIdxOffset]); - expandVcMap.emplace(idxFrom, vcFs[idxFrom-surfIdxOffset]); + // The start level is not the surface + } + else { + expandValMap.emplace(idxFrom, fs[idxFrom - surfIdxOffset]); + expandVcMap.emplace(idxFrom, vcFs[idxFrom - surfIdxOffset]); // temporary modification, will not be written back to the GRIB data if (targetLevType_ == HeightLevelAGR) { - vcFs[idxFrom-surfIdxOffset]->subtractValues(surfVcF); + vcFs[idxFrom - surfIdxOffset]->subtractValues(surfVcF); } } - for (int j=idxFrom; j <= idxTo-1; j++) { + for (int j = idxFrom; j <= idxTo - 1; j++) { // unexpand the data for the previous level if (j > idxFrom) { - auto it = expandValMap.find(j-1); + auto it = expandValMap.find(j - 1); if (it != expandValMap.end()) { expandValMap.erase(it); } - it = expandVcMap.find(j-1); + it = expandVcMap.find(j - 1); if (it != expandVcMap.end()) { expandVcMap.erase(it); } - } // expand the next level @@ -1196,8 +1275,8 @@ } // 1=smaller vc 2=larger vc - int idx1 = (targetAscending_)?j:j+1; - int idx2 = (targetAscending_)?j+1:j; + int idx1 = (targetAscending_) ? j : j + 1; + int idx2 = (targetAscending_) ? j + 1 : j; assert(expandValMap.size() == 2); assert(expandVcMap.size() == 2); @@ -1206,7 +1285,7 @@ auto vc1 = expandVcMap.at(idx1).values(); auto vc2 = expandVcMap.at(idx2).values(); - for (int k: {idx1, idx2}) { + for (int k : {idx1, idx2}) { if (expandValMap.at(k).num() != num) { throw MvException("Level=" + std::to_string(vcLev[k]) + "in data has different number of points than first data field!"); @@ -1221,12 +1300,13 @@ if (targetVcMode_ == VectorTargetCoord) { double targetVcVal = scaleVc(targetVc_[i]); interpolate(targetVcVal, - vc1, vc2, f1, f2, - fRes, num, j, idxFrom, idxTo, vcMin[idx1]); - } else { + vc1, vc2, f1, f2, + fRes, num, j, idxFrom, idxTo, vcMin[idx1]); + } + else { interpolate(targetVcFs[i]->values(), - vc1, vc2, f1, f2, - fRes, num, j, idxFrom, idxTo, vcMin[idx1], targetVcMin, targetVcMax); + vc1, vc2, f1, f2, + fRes, num, j, idxFrom, idxTo, vcMin[idx1], targetVcMin, targetVcMax); } } } @@ -1250,13 +1330,14 @@ if (paramId == -1) { grib_get_long(fRes->handle, "paramId", ¶mId); } - if (paramId == 131 || paramId == 132 || paramId == 10) { - adjustLevelInOutput = true; + if (paramId == 131 || paramId == 132 || paramId == 10) { + adjustLevelInOutput = true; } } - if (adjustLevelInOutput && (tv == 10 || tv == 100 || tv == 200 )) { - grib_set_double(fRes->handle, "level", tv+0.00001); - } else { + if (adjustLevelInOutput && (tv == 10 || tv == 100 || tv == 200)) { + grib_set_double(fRes->handle, "level", tv + 0.00001); + } + else { grib_set_long(fRes->handle, "level", tv); } } @@ -1297,7 +1378,7 @@ } if (*std::min_element(targetVc_.begin(), targetVc_.end()) <= 0.) { - throw MvException("Target pressure values must always be positive!"); + throw MvException("Target pressure values must always be positive!"); } // Sort by model levels in descending order (bottom -> top). @@ -1306,7 +1387,7 @@ // compute surface pressure (Pa). We store the values in the lnsp values pointer and // make sure this is not written back to the file. - assert(lnspFs_->count >=1); + assert(lnspFs_->count >= 1); SimpleFieldPtr sp = SimpleField::make(lnspFs_->fields[0]); sp->expandMemory(); if (!sp->hasValidValues()) { @@ -1324,7 +1405,7 @@ // the first field to do so. std::vector mlPMax, mlPMin; std::vector mlVec; - for (std::size_t i=0; i < fs.size(); i++) { + for (std::size_t i = 0; i < fs.size(); i++) { int ml = fs[i]->metaData()->level(); mlVec.push_back(ml); mlPMin.push_back(fs[0]->meanMlPressureFromSp(spMin, ml)); @@ -1337,12 +1418,12 @@ fieldset* result = new_fieldset(targetVc_.size()); // allocate and initialise data for the computations - double *pLower = new double[num]; - double *pUpper = new double[num]; + double* pLower = new double[num]; + double* pUpper = new double[num]; // perform the interpolation for all the target pressure levels - for (std::size_t i=0; i < targetVc_.size(); i++) { - auto pres=targetVc_[i]*100; + for (std::size_t i = 0; i < targetVc_.size(); i++) { + auto pres = targetVc_[i] * 100; // create resulting field field* fRes = fs[0]->cloneRaw(false); @@ -1353,12 +1434,13 @@ // find bracketing model levels. Both mlPMax and mlPMin are supposed to be sorted // in descending order - int idxFrom=0; - int idxTo=static_cast(mlPMin.size())-1; + int idxFrom = 0; + int idxTo = static_cast(mlPMin.size()) - 1; if (!findBracketingIdx(pres, mlPMin, mlPMax, idxFrom, idxTo) || idxFrom >= idxTo) { - SimpleField::setAllValuesToMissing(fRes); - } else { + SimpleField::setAllValuesToMissing(fRes); + } + else { // iterate through level pairs // Only keep two levels expanded at the same time. Expand start level. @@ -1368,26 +1450,25 @@ // compute pressure on start level fs[0]->meanMlPressureFromSp(sp->values(), pLower, num, mlVec[idxFrom]); - for (int j=idxFrom; j <= idxTo-1; j++) { - + for (int j = idxFrom; j <= idxTo - 1; j++) { // expand the necessary fields if (j > idxFrom) { - auto it = expandMap.find(j-1); + auto it = expandMap.find(j - 1); if (it != expandMap.end()) { expandMap.erase(it); } } - expandMap.emplace(j+1, fs[j+1]); + expandMap.emplace(j + 1, fs[j + 1]); assert(expandMap.find(j) != expandMap.end()); assert(expandMap.size() == 2); auto fLower = fs[j]; - auto fUpper = fs[j+1]; + auto fUpper = fs[j + 1]; if (fLower->valueNum() != num) { throw MvException("Model level=" + std::to_string(mlVec[j]) + " has different number of points than lnsp!"); } if (fUpper->valueNum() != num) { - throw MvException("Model level=" + std::to_string(mlVec[j+1]) + " has different number of points than lnsp!"); + throw MvException("Model level=" + std::to_string(mlVec[j + 1]) + " has different number of points than lnsp!"); } // compute pressure on ML and make sure pLower stores the pressure on the @@ -1395,11 +1476,11 @@ if (j > idxFrom) { std::swap(pLower, pUpper); } - fs[0]->meanMlPressureFromSp(sp->values(), pUpper, num, mlVec[j+1]); + fs[0]->meanMlPressureFromSp(sp->values(), pUpper, num, mlVec[j + 1]); interpolate(pres, - pUpper, pLower, fUpper->values(), fLower->values(), - fRes, num, j, idxFrom, idxTo, mlPMin[j+1]); + pUpper, pLower, fUpper->values(), fLower->values(), + fRes, num, j, idxFrom, idxTo, mlPMin[j + 1]); } } @@ -1408,8 +1489,9 @@ std::string levType = "isobaricInhPa"; size_t len = levType.size(); grib_set_string(fRes->handle, "typeOfLevel", levType.c_str(), &len); - grib_set_long(fRes->handle, "level", static_cast(pres)/100.); - } else { + grib_set_long(fRes->handle, "level", static_cast(pres) / 100.); + } + else { std::string levType = "isobaricInPa"; size_t len = levType.size(); grib_set_string(fRes->handle, "typeOfLevel", levType.c_str(), &len); @@ -1420,8 +1502,8 @@ save_fieldset(result); } - delete [] pLower; - delete [] pUpper; + delete[] pLower; + delete[] pUpper; sp->releaseMemory(); return result; } @@ -1436,7 +1518,7 @@ bool aboveSea, VerticalInterpolationMethod interpolationMethod) : VerticalInterpolation(dataFs, zFs, zsFs) { - vcScaleNeeded_=true; + vcScaleNeeded_ = true; // go from metres to gpm vcFactor_ = MvSci::cEarthG; @@ -1445,7 +1527,8 @@ if (aboveSea) { targetLevType_ = HeightLevelABS; eccTargetLevType_ = "heightAboveSea"; - } else { + } + else { targetLevType_ = HeightLevelAGR; eccTargetLevType_ = "heightAboveGround"; } @@ -1482,14 +1565,14 @@ q.sort("level", false); // check levels - for (std::size_t i=0; i < t.size(); i++) { + for (std::size_t i = 0; i < t.size(); i++) { if (t[i]->level() != q[i]->level()) { - throw MvException("t and q must contain the same model levels!"); + throw MvException("t and q must contain the same model levels!"); } if (i > 0) { - if (t[i]->level() != t[i-1]->level() - 1) { + if (t[i]->level() != t[i - 1]->level() - 1) { throw MvException("There can be no gaps in the model level range! Level=" + - std::to_string(t[i-1]->level() - 1) + " is missing!"); + std::to_string(t[i - 1]->level() - 1) + " is missing!"); } } } @@ -1498,12 +1581,12 @@ int bottomLevel = t[0]->level(); if (bottomLevel != t[0]->totalMlLevelNum()) { throw MvException("Bottom level should be " + std::to_string(t[0]->totalMlLevelNum()) + - " instead of " + std::to_string(bottomLevel)); + " instead of " + std::to_string(bottomLevel)); } // compute surface pressure (Pa). We store the values in the lnsp values pointer and // make sure this is not written back to the file. - assert(lnspFs->count >=1); + assert(lnspFs->count >= 1); SimpleFieldPtr sp = SimpleField::make(lnspFs->fields[0]); sp->expandMemory(); if (!sp->hasValidValues()) { @@ -1515,7 +1598,7 @@ // We use the zs field to store the half level z values. We must not write // the values back to file! - assert(zsFs->count >=1); + assert(zsFs->count >= 1); SimpleFieldPtr zHalf = SimpleField::make(zsFs->fields[0]); zHalf->expandMemory(); if (!zHalf->hasValidValues()) { @@ -1528,15 +1611,15 @@ fieldset* result = new_fieldset(t.size()); // work arrays - double *pHalfBelow = new double[num]; - double *pHalf = new double[num]; + double* pHalfBelow = new double[num]; + double* pHalf = new double[num]; // initialise presssure on half level below - t[0]->halfPres(sp->values(), pHalfBelow, num, bottomLevel+1); + t[0]->halfPres(sp->values(), pHalfBelow, num, bottomLevel + 1); - for (std::size_t i=0; i < t.size(); i++) { + for (std::size_t i = 0; i < t.size(); i++) { int lev = t[i]->level(); - assert(lev >0); + assert(lev > 0); SimpleFieldDataExpander fxT(t[i]); SimpleFieldDataExpander fxQ(q[i]); @@ -1550,19 +1633,20 @@ // z_f is the geopotential of this full level // integrate from previous (lower) half-level z_h to the full level double dLogP, alpha; - double *tVal = t[i]->values(); - double *qVal = q[i]->values(); - double *zHalfVal = zHalf->values(); + double* tVal = t[i]->values(); + double* qVal = q[i]->values(); + double* zHalfVal = zHalf->values(); double tv; for (std::size_t k = 0; k < num; k++) { - if (!MISSING_VALUE(pHalfBelow[k]) && !MISSING_VALUE(zHalfVal[k]) && !MISSING_VALUE(tVal[k]) && !MISSING_VALUE(qVal[k]) ) { - tv = tVal[k]*(1.+0.609133*qVal[k])*cRD; + if (!MISSING_VALUE(pHalfBelow[k]) && !MISSING_VALUE(zHalfVal[k]) && !MISSING_VALUE(tVal[k]) && !MISSING_VALUE(qVal[k])) { + tv = tVal[k] * (1. + 0.609133 * qVal[k]) * cRD; if (lev == 1) { - dLogP = std::log(pHalfBelow[k]/0.1); + dLogP = std::log(pHalfBelow[k] / 0.1); alpha = cLog2; - } else { - dLogP = std::log(pHalfBelow[k]/pHalf[k]); - alpha = 1. - dLogP*pHalf[k]/(pHalfBelow[k]-pHalf[k]); + } + else { + dLogP = std::log(pHalfBelow[k] / pHalf[k]); + alpha = 1. - dLogP * pHalf[k] / (pHalfBelow[k] - pHalf[k]); } // zFull @@ -1574,11 +1658,12 @@ " zHalf=" << zHalf->values()[k] << " zFull=" << fRes->values[k] << std::endl; } #endif - //zHalf - if (i != levNum-1) { + // zHalf + if (i != levNum - 1) { zHalfVal[k] += (tv * dLogP); } - } else { + } + else { fRes->values[k] = mars.grib_missing_value; fRes->bitmap = 1; pHalfBelow[k] = mars.grib_missing_value; @@ -1592,12 +1677,12 @@ grib_set_long(fRes->handle, "paramId", 129); grib_set_long(fRes->handle, "generatingProcessIdentifier", 128); - set_field(result, fRes, t.size()-i-1); + set_field(result, fRes, t.size() - i - 1); save_fieldset(result); } - delete [] pHalf; - delete [] pHalfBelow; + delete[] pHalf; + delete[] pHalfBelow; sp->releaseMemory(); zHalf->releaseMemory(); return result; @@ -1624,7 +1709,7 @@ } if (*std::min_element(targetVc_.begin(), targetVc_.end()) <= 0.) { - throw MvException("Target pressure values must always be positive!"); + throw MvException("Target pressure values must always be positive!"); } // Sort by pressure levels (using Pa) in descending order (bottom -> top). @@ -1633,7 +1718,7 @@ // get pressure in Pa on all the levels std::vector plVec; - for (std::size_t i=0; i < fs.size(); i++) { + for (std::size_t i = 0; i < fs.size(); i++) { if (!fs[i]->isPressureLevel()) { throw MvException("Input data can only contain pressure level fields!"); } @@ -1641,7 +1726,7 @@ plVec.push_back(p); } -// MvLog().info() << MV_FN_INFO << " plVec=" << plVec; + // MvLog().info() << MV_FN_INFO << " plVec=" << plVec; std::size_t num = 0; @@ -1649,8 +1734,8 @@ fieldset* result = new_fieldset(targetVc_.size()); // perform the interpolation for all the target pressure levels - for (std::size_t i=0; i < targetVc_.size(); i++) { - auto pres=targetVc_[i]*100; + for (std::size_t i = 0; i < targetVc_.size(); i++) { + auto pres = targetVc_[i] * 100; // create resulting field field* fRes = fs[0]->cloneRaw(false); @@ -1664,18 +1749,20 @@ // find bracketing pressure levels. Both mlPMax and mlPMin are supposed to be sorted // in descending order - int idxFrom=0; - int idxTo=static_cast(plVec.size())-1; + int idxFrom = 0; + int idxTo = static_cast(plVec.size()) - 1; if (!findBracketingIdx(pres, plVec, idxFrom, idxTo) || idxFrom > idxTo) { - //MvLog().info() << " idxFrom=" << idxFrom << " idxTo=" << idxTo; - SimpleField::setAllValuesToMissing(fRes); - } else { + // MvLog().info() << " idxFrom=" << idxFrom << " idxTo=" << idxTo; + SimpleField::setAllValuesToMissing(fRes); + } + else { // the target level is in the input data if (idxFrom == idxTo) { SimpleFieldDataExpander fx(fs[idxFrom]); fs[idxFrom]->copyValuesTo(fRes); - } else { + } + else { assert(idxFrom + 1 == idxTo); SimpleFieldDataExpander fx(fs[idxFrom]); SimpleFieldDataExpander fx1(fs[idxTo]); @@ -1688,16 +1775,16 @@ auto pUpper = plVec[idxUpper]; if (fLower->valueNum() != num) { throw MvException("Pressure level=" + std::to_string(plVec[idxLower]) + "Pa has unexpected different number of points! " + - std::to_string(fLower->valueNum()) + "!=" + std::to_string(num)); + std::to_string(fLower->valueNum()) + "!=" + std::to_string(num)); } if (fUpper->valueNum() != num) { throw MvException("Pressure level=" + std::to_string(plVec[idxUpper]) + "Pa has unexpected different number of points! " + - std::to_string(fUpper->valueNum()) + "!=" + std::to_string(num)); + std::to_string(fUpper->valueNum()) + "!=" + std::to_string(num)); } interpolate(pres, - pUpper, pLower, fUpper->values(), fLower->values(), - fRes, num); + pUpper, pLower, fUpper->values(), fLower->values(), + fRes, num); } } @@ -1706,8 +1793,9 @@ std::string levType = "isobaricInhPa"; size_t len = levType.size(); grib_set_string(fRes->handle, "typeOfLevel", levType.c_str(), &len); - grib_set_long(fRes->handle, "level", static_cast(pres)/100.); - } else { + grib_set_long(fRes->handle, "level", static_cast(pres) / 100.); + } + else { std::string levType = "isobaricInPa"; size_t len = levType.size(); grib_set_string(fRes->handle, "typeOfLevel", levType.c_str(), &len); @@ -1735,12 +1823,12 @@ } SimpleFieldset lnsp(lnspFs); - assert(lnspFs->count >=1); + assert(lnspFs->count >= 1); // define the resulting fieldset fieldset* result = new_fieldset(0); - for (std::size_t i=0; i < lnsp.size(); i++) { + for (std::size_t i = 0; i < lnsp.size(); i++) { // compute surface pressure (Pa). We store the values in the lnsp values pointer and // make sure this is not written back to the file. auto sp = lnsp[i]; @@ -1762,7 +1850,7 @@ std::iota(targetLevels.begin(), targetLevels.end(), 1); } - for (std::size_t k=0; k < targetLevels.size(); k++) { + for (std::size_t k = 0; k < targetLevels.size(); k++) { int ml = targetLevels[k]; if (ml < 1 || ml > sp->totalMlLevelNum()) { throw MvException("Invalid target model level=" + std::to_string(ml) + " specified!"); @@ -1773,8 +1861,9 @@ // mean pressure on model level if (!layer) { sp->meanMlPressureFromSp(sp->values(), fRes->values, num, ml); - // size of the pressure layer (=thickness) around the model level - } else { + // size of the pressure layer (=thickness) around the model level + } + else { sp->mlPressureLayerFromSp(sp->values(), fRes->values, num, ml); } @@ -1797,7 +1886,7 @@ std::vector levels; // check levels - for (std::size_t i=0; i < levFs.size(); i++) { + for (std::size_t i = 0; i < levFs.size(); i++) { levels.push_back(levFs[i]->level()); } return pressureOnMl(lnspFs, lnspId, layer, levels); @@ -1819,9 +1908,10 @@ for (std::size_t i = 0; i < fs.size(); i++) { auto md = fs[i]->metaData(); if (!md->isSpectral()) { - presVec.emplace_back(md->levelInPa()); - } else { - throw MvException("Spherical harmonics fields are not supported! Level=" + std::to_string(md->level())); + presVec.emplace_back(md->levelInPa()); + } + else { + throw MvException("Spherical harmonics fields are not supported! Level=" + std::to_string(md->level())); } } @@ -1834,7 +1924,7 @@ } for (size_t i = 1; i < presVec.size(); i++) { - if (presVec[i] == presVec[i-1]) { + if (presVec[i] == presVec[i - 1]) { throw MvException("Pressure level " + std::to_string(presVec[i]) + " Pa appears multiple times. Pressure levels must be unique in input data!"); } @@ -1858,7 +1948,7 @@ if (fs[i]->valueNum() != num) { throw MvException("Field on level=" + std::to_string(md->level()) + " has different number of points than expected! " + - std::to_string(fs[i]->valueNum()) + " != " + std::to_string(num)); + std::to_string(fs[i]->valueNum()) + " != " + std::to_string(num)); } assert(fs[i]->valueNum() == num); @@ -1875,7 +1965,7 @@ } if (dp <= 0.) { - throw MvException("Invalid pressure layer thickness=" + std::to_string(dp) + " Pa found!" ); + throw MvException("Invalid pressure layer thickness=" + std::to_string(dp) + " Pa found!"); } assert(dp > 0.); @@ -1884,7 +1974,8 @@ if (!MISSING_VALUE(fRes->values[k])) { if (!MISSING_VALUE(vals[k])) { fRes->values[k] += vals[k] * dp; - } else { + } + else { fRes->values[k] = mars.grib_missing_value; fRes->bitmap = 1; } @@ -1892,7 +1983,7 @@ } } - SimpleField::scaleValues(fRes, 1./MvSci::cEarthG); + SimpleField::scaleValues(fRes, 1. / MvSci::cEarthG); fieldset* result = new_fieldset(0); add_field(result, fRes); @@ -1901,41 +1992,42 @@ return result; } -fieldset* verticalIntegralMl(fieldset* dataFs, fieldset* lnspFs, int lnspId, int topMl, int bottomMl) +fieldset* verticalIntegralMl(fieldset* dataFs, fieldset* lnspFs, int lnspId, int topMl, int bottomMl) { - SimpleFieldset fs(dataFs); - SimpleFieldPtr sp = nullptr; - if (!lnspFs) { - for(std::size_t i=0; i < fs.size(); i++) { - if (fs[i]->paramId() == lnspId) { + SimpleFieldset fs(dataFs); + SimpleFieldPtr sp = nullptr; + if (!lnspFs) { + for (std::size_t i = 0; i < fs.size(); i++) { + if (fs[i]->paramId() == lnspId) { sp = fs[i]; assert(sp->rawField()->shape == packed_file); if (dataFs->count - 1 < 2) { throw MvException("At least one model level field is required on top of LNSP!"); } break; - } - } - } else { - if (dataFs->count < 1) { - throw MvException("At least one model level field is required!"); - } - if (lnspFs->count < 1) { - throw MvException("LNSF fieldset seems to be empty!"); - } - sp = SimpleField::make(lnspFs->fields[0]); - assert(sp->rawField()->shape = packed_file); - } + } + } + } + else { + if (dataFs->count < 1) { + throw MvException("At least one model level field is required!"); + } + if (lnspFs->count < 1) { + throw MvException("LNSF fieldset seems to be empty!"); + } + sp = SimpleField::make(lnspFs->fields[0]); + assert(sp->rawField()->shape = packed_file); + } if (!sp) { - throw MvException("No LNSP field found!"); + throw MvException("No LNSP field found!"); } assert(sp->rawField()->shape != expand_mem); if (sp->paramId() != lnspId) { throw MvException("LNSP field has a diffrent paramId than expected! " + - std::to_string(sp->paramId()) + " != " + std::to_string(lnspId)); + std::to_string(sp->paramId()) + " != " + std::to_string(lnspId)); } if (sp->isSpectral()) { @@ -1950,14 +2042,14 @@ assert(sp->rawField()->shape = expand_mem); if (!sp->hasValidValues()) { throw MvException("No valid values found in LNSP!"); - } + } sp->transformValues(std::exp); std::size_t num = sp->valueNum(); assert(num > 0); assert(sp->rawField()->shape = expand_mem); bool limitedRange = false; - if (topMl >=0 && bottomMl >= 0) { + if (topMl >= 0 && bottomMl >= 0) { if (sp->totalMlLevelNum() < topMl) { throw MvException("Top level=" + std::to_string(topMl) + " cannot be larger than " + std::to_string(sp->totalMlLevelNum()) + " for the input data!"); @@ -1975,7 +2067,7 @@ assert(sp->rawField()->shape = expand_mem); // create resulting field from the first non-lnsp field - field* fRes = nullptr; + field* fRes = nullptr; for (size_t i = 0; i < fs.size(); i++) { if (fs[i] != sp) { fRes = fs[i]->cloneRaw(false); @@ -1999,14 +2091,14 @@ assert(fs[i]->rawField()->shape = expand_mem); if (fs[i]->isSpectral()) { - throw MvException("Data field (level=" + std::to_string(fs[i]->level()) + ") cannot be spectral!"); + throw MvException("Data field (level=" + std::to_string(fs[i]->level()) + ") cannot be spectral!"); } if (!fs[i]->isModelLevel()) { throw MvException("Data field (level=" + std::to_string(fs[i]->level()) + ") must be defined on a model levels!"); } if (fs[i]->valueNum() != num) { throw MvException("Data field (level=" + std::to_string(fs[i]->level()) + ") has different number of points than expected! " + - std::to_string(fs[i]->valueNum()) + " != " + std::to_string(num)); + std::to_string(fs[i]->valueNum()) + " != " + std::to_string(num)); } fs[i]->addMlPressureIntegralDeltaFromSp(sp, fRes->values); assert(fs[i]->rawField()->shape = expand_mem); @@ -2016,7 +2108,7 @@ } } - SimpleField::scaleValues(fRes, 1/MvSci::cEarthG); + SimpleField::scaleValues(fRes, 1 / MvSci::cEarthG); sp->releaseMemory(); assert(sp->rawField()->shape = packed_file); @@ -2034,10 +2126,10 @@ if (!lnspFs) { SimpleFieldset f(dataFs); if (f[0]->isPressureLevel()) { - return verticalIntegralPl(dataFs); + return verticalIntegralPl(dataFs); } } return verticalIntegralMl(dataFs, lnspFs, lnspId, topMl, bottomMl); } -} // metview +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/GribVertical.h metview-5.19.2/metview/src/libMetview/GribVertical.h --- metview-5.17.4/metview/src/libMetview/GribVertical.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/GribVertical.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,8 @@ #include -namespace metview { +namespace metview +{ class SimpleField; using SimpleFieldPtr = std::shared_ptr; @@ -23,10 +24,13 @@ class MarsComputeFlagDisabler { public: - MarsComputeFlagDisabler() : flag_(mars.computeflg) { + MarsComputeFlagDisabler() : + flag_(mars.computeflg) + { mars.computeflg = 0; } - ~MarsComputeFlagDisabler() {mars.computeflg = flag_;} + ~MarsComputeFlagDisabler() { mars.computeflg = flag_; } + protected: int flag_{0}; }; @@ -34,34 +38,54 @@ class VerticalInterpolation { public: - enum TargetCoordMode {VectorTargetCoord, FieldsetTargetCoord}; - enum SurfaceValueMode {NoSurfaceValue, NumberSurfaceValue, FieldsetSurfaceValue}; - enum VerticalInterpolationMethod {LinearInterpolation, LogInterpolation}; - enum LevelType {NoLevelType, ModelLevel, PressureLevel, HeightLevelABS, HeightLevelAGR}; + enum TargetCoordMode + { + VectorTargetCoord, + FieldsetTargetCoord + }; + enum SurfaceValueMode + { + NoSurfaceValue, + NumberSurfaceValue, + FieldsetSurfaceValue + }; + enum VerticalInterpolationMethod + { + LinearInterpolation, + LogInterpolation + }; + enum LevelType + { + NoLevelType, + ModelLevel, + PressureLevel, + HeightLevelABS, + HeightLevelAGR + }; VerticalInterpolation(fieldset* srcFs, fieldset* vcFs, fieldset* surfVcFs); - void setTargetVc(fieldset *fs); + void setTargetVc(fieldset* fs); void setTargetVc(const std::vector&); void setSurfaceValues(fieldset* fs); void setSurfaceValues(double v); virtual fieldset* compute(); protected: - void computeSurfaceVcMinMax(SimpleFieldPtr surfVcF, double &vmin, double &vmax); - void computeVcMinMax(SimpleFieldPtr vcF, SimpleFieldPtr surfVcF, double &vmin, double &vmax); + void computeSurfaceVcMinMax(SimpleFieldPtr surfVcF, double& vmin, double& vmax); + void computeVcMinMax(SimpleFieldPtr vcF, SimpleFieldPtr surfVcF, double& vmin, double& vmax); double scaleVc(double v); void scaleVc(SimpleFieldPtr f); bool findBracketingIdx(double vcVal, const std::vector& vcMin, const std::vector& vcMax, - int& idxFrom, int& idxTo); + int& idxFrom, int& idxTo); bool findBracketingIdx(double targetMin, double targetMax, const std::vector& vcMin, const std::vector& vcMax, - int& idxFrom, int& idxTo); + int& idxFrom, int& idxTo); bool findBracketingIdx(double targetVc, const std::vector& vc, int& idxFrom, int& idxTo); void interpolate(double targetVcVal, double vc1, double vc2, double* f1, double* f2, field* fRes, size_t num); - void interpolate(double targetVcVal, double *vcLower, double* vcUpper, + void interpolate(double targetVcVal, double* vcLower, double* vcUpper, double* fLower, double* fUpper, field* fsRes, size_t num, int idx, int idxFrom, int idxTo, double vcMin); - void interpolate(double* targetVcVal, double *vc1, double* vc2, + void interpolate(double* targetVcVal, double* vc1, double* vc2, double* f1, double* f2, field* fRes, size_t num, int idx, int idxFrom, int idxTo, double vcMin, double targetVcMin, double targetVcMax); @@ -86,7 +110,6 @@ bool srcAscending_{false}; bool targetAscending_{false}; VerticalInterpolationMethod interMethod_{LinearInterpolation}; - }; class MlToPlInter : public VerticalInterpolation @@ -120,4 +143,4 @@ fieldset* verticalIntegralMl(fieldset* dataFs, fieldset* lnspFs, int lnspId, int topMl, int bottomMl); fieldset* verticalIntegral(fieldset* dataFs, fieldset* lnspFs, int lnspId, int topMl, int bottomMl); -} // interpolation +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/LLMatrixToGRIB.cc metview-5.19.2/metview/src/libMetview/LLMatrixToGRIB.cc --- metview-5.17.4/metview/src/libMetview/LLMatrixToGRIB.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/LLMatrixToGRIB.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,8 @@ void do_swap(double& s1, double& s2) { double t = s1; - s1 = s2; - s2 = t; + s1 = s2; + s2 = t; } err LLMatrixToGRIB(const char* matrixFile, const char* gribFileName) @@ -43,7 +43,7 @@ //-- temporary file to store LatLonMatrix metadata as a Request char* requestFile = marstmp(); - FILE* reqFILE = fopen(requestFile, "w"); + FILE* reqFILE = fopen(requestFile, "w"); if (!reqFILE) { marslog(LOG_EROR | LOG_PERR, "Cannot open %s", requestFile); return -1; @@ -102,11 +102,11 @@ const char* p; double north = atof((p = get_value(r, "NORTH", 0)) ? p : "0"); - double west = atof((p = get_value(r, "WEST", 0)) ? p : "0"); - int nlat = atol((p = get_value(r, "NLAT", 0)) ? p : "0"); - int nlon = atol((p = get_value(r, "NLON", 0)) ? p : "0"); - double ew = atof((p = get_value(r, "GRID", 0)) ? p : "0"); - double ns = atof((p = get_value(r, "GRID", 1)) ? p : "0"); + double west = atof((p = get_value(r, "WEST", 0)) ? p : "0"); + int nlat = atol((p = get_value(r, "NLAT", 0)) ? p : "0"); + int nlon = atol((p = get_value(r, "NLON", 0)) ? p : "0"); + double ew = atof((p = get_value(r, "GRID", 0)) ? p : "0"); + double ns = atof((p = get_value(r, "GRID", 1)) ? p : "0"); if (ns == 0) ns = ew; @@ -116,28 +116,28 @@ return -1; } - p = get_value(r, "HSCAN", 0); //-- 'WE' (default) or 'EW' + p = get_value(r, "HSCAN", 0); //-- 'WE' (default) or 'EW' int hscan = (p && (*p == 'E' || *p == 'e')) ? 128 : 0; - p = get_value(r, "VSCAN", 0); //-- 'NS' (default) or 'SN' + p = get_value(r, "VSCAN", 0); //-- 'NS' (default) or 'SN' int vscan = (p && (*p == 'S' || *p == 's')) ? 64 : 0; - p = get_value(r, "SCANDIR", 0); //-- 'HORIZONTAL' (default) or 'VERTICAL' + p = get_value(r, "SCANDIR", 0); //-- 'HORIZONTAL' (default) or 'VERTICAL' int scandir = (p && (*p == 'V' || *p == 'v')) ? 32 : 0; double missing = (p = get_value(r, "MISSING", 0)) ? atof(p) : mars.grib_missing_value; //-- extract PARAM, TABLE2, LEVEL, CENTRE, DATE, FCAST - int param = (p = get_value(r, "PARAM", 0)) ? atol(p) : 255; - int table = (p = get_value(r, "TABLE2", 0)) ? atol(p) : 128; - int level = (p = get_value(r, "LEVEL", 0)) ? atol(p) : 0; + int param = (p = get_value(r, "PARAM", 0)) ? atol(p) : 255; + int table = (p = get_value(r, "TABLE2", 0)) ? atol(p) : 128; + int level = (p = get_value(r, "LEVEL", 0)) ? atol(p) : 0; int centre = (p = get_value(r, "CENTRE", 0)) ? atol(p) : localWmoSiteNumber(); if (param == 0) param = 255; - long msave = expand_flags(0); - p = get_value(r, "DATE", 0); + long msave = expand_flags(0); + p = get_value(r, "DATE", 0); double dseed = p ? atof(p) : 0.0; MvDate date(dseed); expand_flags(msave); @@ -148,13 +148,13 @@ //-- set correct boarder values double first_lat = north; - double last_lat = north - (nlat - 1) * ns; + double last_lat = north - (nlat - 1) * ns; if (vscan > 0) do_swap(first_lat, last_lat); double first_lon = west; - double last_lon = west + (nlon - 1) * ew; + double last_lon = west + (nlon - 1) * ew; if (hscan > 0) do_swap(first_lon, last_lon); @@ -163,10 +163,10 @@ //-- read data values from LatLonMatrix file - int npoints = nlat * nlon; + int npoints = nlat * nlon; auto* dataValues = new double[npoints]; - n = 0; + n = 0; int miss = 0; for (int i = 0; i < npoints; ++i) { if (matrixStream.eof()) { @@ -346,9 +346,9 @@ grib_set_double_array(h, "values", dataValues, npoints); //-- get the GRIB1 message into 'buffer' - size_t buflen = 0; + size_t buflen = 0; const void* buffer = nullptr; - stat = grib_get_message(h, &buffer, &buflen); + stat = grib_get_message(h, &buffer, &buflen); if (stat > 0) { delete[] dataValues; diff -Nru metview-5.17.4/metview/src/libMetview/LogHandler.h metview-5.19.2/metview/src/libMetview/LogHandler.h --- metview-5.17.4/metview/src/libMetview/LogHandler.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/LogHandler.h 2023-07-15 08:28:47.000000000 +0000 @@ -65,16 +65,14 @@ std::map BaseLog::logKeys_; template -BaseLog::BaseLog() -{ -} +BaseLog::BaseLog() = default; template const std::string& BaseLog::keyToStr(metview::LogKey key) { if (logKeys_.empty()) { logKeys_[metview::CommandKey] = "--CMD"; - logKeys_[metview::MethodKey] = "--MTD"; + logKeys_[metview::MethodKey] = "--MTD"; logKeys_[metview::RequestKey] = "--REQ"; } @@ -148,4 +146,4 @@ static LogObserver* observer_; }; -typedef BaseLog GuiLog; +using GuiLog = BaseLog; diff -Nru metview-5.17.4/metview/src/libMetview/MtInputEvent.cc metview-5.19.2/metview/src/libMetview/MtInputEvent.cc --- metview-5.17.4/metview/src/libMetview/MtInputEvent.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MtInputEvent.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,7 +12,7 @@ MtInputEvent::MtInputEvent() : type_(Mt::NoEvent) { - //empty + // empty } @@ -21,11 +21,11 @@ x_(0), y_(0) { - //empty + // empty } MtKeyEvent::MtKeyEvent() : key_(Mt::Key_Unknown) { - //empty + // empty } \ No newline at end of file diff -Nru metview-5.17.4/metview/src/libMetview/MtInputEvent.h metview-5.19.2/metview/src/libMetview/MtInputEvent.h --- metview-5.17.4/metview/src/libMetview/MtInputEvent.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MtInputEvent.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,10 +25,10 @@ }; enum MouseButton { - NoButton = 0, - LeftButton = 1, + NoButton = 0, + LeftButton = 1, RightButton = 2, - MidButton = 4 + MidButton = 4 }; enum Key { @@ -45,7 +45,7 @@ { public: MtInputEvent(); - //MtInputEvent(MtInputEvent&); + // MtInputEvent(MtInputEvent&); void setType(Mt::InputEvent t) { type_ = t; } Mt::InputEvent type() const { return type_; } @@ -59,7 +59,7 @@ { public: MtMouseEvent(); - //MtMouseEvent(MtMouseEvent&); + // MtMouseEvent(MtMouseEvent&); int x() { return x_; } int y() { return y_; } @@ -80,7 +80,7 @@ { public: MtKeyEvent(); - //MtKeyEvent(MtKeyEvent&); + // MtKeyEvent(MtKeyEvent&); Mt::Key key() const { return key_; } void setKey(Mt::Key k) { key_ = k; } diff -Nru metview-5.17.4/metview/src/libMetview/MvAbstractApplication.h metview-5.19.2/metview/src/libMetview/MvAbstractApplication.h --- metview-5.17.4/metview/src/libMetview/MvAbstractApplication.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvAbstractApplication.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,9 +26,9 @@ static void abortWithPopup(const std::string& text); protected: - virtual void writeToLog(const std::string& msg, MvLogLevel level) = 0; + virtual void writeToLog(const std::string& msg, MvLogLevel level) = 0; virtual void writeToUiLog(const std::string& msg, MvLogLevel level, bool popup) = 0; - virtual void exitWithError() = 0; + virtual void exitWithError() = 0; private: static MvAbstractApplication* abcApp_; diff -Nru metview-5.17.4/metview/src/libMetview/MvAlmostObsoleteRequest.cc metview-5.19.2/metview/src/libMetview/MvAlmostObsoleteRequest.cc --- metview-5.17.4/metview/src/libMetview/MvAlmostObsoleteRequest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvAlmostObsoleteRequest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,9 @@ MvDataGen ::MvDataGen(svcid* i, request* r, const char* typ) { datatype = strdup(typ); - req = clone_all_requests(r); + req = clone_all_requests(r); setElemCode((long)req); //-- 'hpcd' C++ fails with 'int' cast - id = i; + id = i; tasks = 0; // Generate the temporary file name where result will be written @@ -45,14 +45,14 @@ setElemName(datafile); } -MvDataGen ::MvDataGen(svcid* i, MvDataGen* mdg) +MvDataGen::MvDataGen(svcid* i, MvDataGen* mdg) { datatype = strdup(mdg->datatype); datafile = strdup(mdg->datafile); req = nullptr; setElemCode(mdg->getElemCode()); - id = i; + id = i; tasks = 0; setElemName(mdg->getElemName()); @@ -132,7 +132,7 @@ { req = clone_all_requests(r); setElemCode((long)req); //-- 'hpcd' C++ fails with 'int' cast - id = i; + id = i; tasks = 0; // Generate the temporary file name where result will be written diff -Nru metview-5.17.4/metview/src/libMetview/MvAlmostObsoleteRequest.hpp metview-5.19.2/metview/src/libMetview/MvAlmostObsoleteRequest.hpp --- metview-5.17.4/metview/src/libMetview/MvAlmostObsoleteRequest.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvAlmostObsoleteRequest.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -14,15 +14,18 @@ class MvDataGen : public MvElement { public: - request* req; - svcid* id; - int tasks; - char* datatype; - char* datafile; - MvDataGen() {} + MvDataGen() = default; MvDataGen(svcid*, request*, const char*); MvDataGen(svcid*, MvDataGen*); ~MvDataGen(); + MvDataGen(const MvDataGen&) = delete; + MvDataGen& operator=(const MvDataGen&) = delete; + + request* req{nullptr}; + svcid* id{nullptr}; + int tasks{0}; + char* datatype{nullptr}; + char* datafile{nullptr}; void SendStatus(const char*); void SendReply(err); void DeleteFile(); diff -Nru metview-5.17.4/metview/src/libMetview/MvApplication.cc metview-5.19.2/metview/src/libMetview/MvApplication.cc --- metview-5.17.4/metview/src/libMetview/MvApplication.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvApplication.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,9 +11,9 @@ #include #include -svc* MvApplication::service_ = nullptr; -MvApplication* MvApplication::app_ = nullptr; -int KeepAlive::count_ = 0; +svc* MvApplication::service_ = nullptr; +MvApplication* MvApplication::app_ = nullptr; +int KeepAlive::count_ = 0; static const char* cPreferencesFile = "General"; // This class is used by method MvApplication::wantPreferences(). @@ -83,12 +83,12 @@ void MvApplication::callService(const char* s, const MvRequest& r, void* d) { /* - if(ProcessReplies) - while(service_ready(Service)) - { - marslog(LOG_DBUG,"Processing async replies..."); - process_service(Service); - } + if(ProcessReplies) + while(service_ready(Service)) + { + marslog(LOG_DBUG,"Processing async replies..."); + process_service(Service); + } */ call_service(service_, s, r, (long)d); } @@ -168,7 +168,7 @@ MvRequest MvApplication::getExpandedPreferences(const char* name) { const char* prefs_name = (name == nullptr) ? cPreferencesFile : name; - //MvRequest req=get_preferences(Service,prefs_name); + // MvRequest req=get_preferences(Service,prefs_name); MvRequest req = getPreferences(prefs_name); char* shareDir = getenv("METVIEW_DIR_SHARE"); @@ -178,7 +178,7 @@ std::string path(shareDir); path.append("/etc/"); - std::string defFileName = path + "ConfigDef"; + std::string defFileName = path + "ConfigDef"; std::string rulesFileName = path + "ConfigRules"; MvLanguage langMetview(defFileName.c_str(), @@ -238,7 +238,7 @@ void MvApplication::writeToLog(const std::string& msg, MvLogLevel level) { // TODO: figure out when sendMessage is to use -// sendMessage(msg); + // sendMessage(msg); // TODO: break multiline text into lines for marslog if (level == MvLogLevel::INFO) { @@ -254,7 +254,7 @@ marslog(LOG_INFO, msg.c_str()); // marslog(LOG_DBUG, msg.c_str()); } - //marslog(LOG_INFO | LOG_PERR, msg.c_str()); + // marslog(LOG_INFO | LOG_PERR, msg.c_str()); } // The module will exit with an error code @@ -268,7 +268,7 @@ { MvRequest r = MvApplication::getPreferences(); if (const char* ch = (const char*)r("DEFAULT_FOLDER_FOR_FILE_DIALOGS")) { - return (strcmp(ch, "CURRENT") == 0)?CurrentFoldertarget:PreviousFolderTarget; + return (strcmp(ch, "CURRENT") == 0) ? CurrentFoldertarget : PreviousFolderTarget; } return CurrentFoldertarget; } diff -Nru metview-5.17.4/metview/src/libMetview/MvApplication.h metview-5.19.2/metview/src/libMetview/MvApplication.h --- metview-5.17.4/metview/src/libMetview/MvApplication.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvApplication.h 2023-07-15 08:28:47.000000000 +0000 @@ -69,7 +69,11 @@ static void saveErrorAsRequest(const std::string& outPath, const std::string& msg); static std::string buildAppName(const std::string& name); - enum SaveAsFolderTarget {CurrentFoldertarget, PreviousFolderTarget}; + enum SaveAsFolderTarget + { + CurrentFoldertarget, + PreviousFolderTarget + }; static SaveAsFolderTarget saveAsFolderTarget(); protected: diff -Nru metview-5.17.4/metview/src/libMetview/MvBinaryReader.cc metview-5.19.2/metview/src/libMetview/MvBinaryReader.cc --- metview-5.17.4/metview/src/libMetview/MvBinaryReader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvBinaryReader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,16 +16,12 @@ #include -MvBinaryReader::MvBinaryReader(const std::string& fname) : - data_(nullptr), - dataStart_(nullptr), - recordMarker_(4), - size_(0) +MvBinaryReader::MvBinaryReader(const std::string& fname) { std::ifstream file(fname.c_str(), std::ios::in | std::ios::binary | std::ios::ate); if (file.is_open()) { - size_ = file.tellg(); - data_ = new char[size_]; + size_ = file.tellg(); + data_ = new char[size_]; dataStart_ = data_; std::cout << "size" << " " << size_ << std::endl; diff -Nru metview-5.17.4/metview/src/libMetview/MvBinaryReader.h metview-5.19.2/metview/src/libMetview/MvBinaryReader.h --- metview-5.17.4/metview/src/libMetview/MvBinaryReader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvBinaryReader.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,14 +16,16 @@ #include #include -//This class is meant to read binary files. It is mainly used to -//decode the binary output generated by flexpart. +// This class is meant to read binary files. It is mainly used to +// decode the binary output generated by flexpart. class MvBinaryReader { public: MvBinaryReader(const std::string&); ~MvBinaryReader(); + MvBinaryReader(const MvBinaryReader&) = delete; + MvBinaryReader& operator=(const MvBinaryReader&) = delete; bool isValid() const; void skipRecMarker(); @@ -31,10 +33,10 @@ bool hasData() const; private: - char* data_; - char* dataStart_; - int recordMarker_; - std::streampos size_; + char* data_{nullptr}; + char* dataStart_{nullptr}; + int recordMarker_{4}; + std::streampos size_{0}; public: template @@ -66,6 +68,6 @@ std::memcpy((char*)&vArray, data_, num * s); data_ += num * s; vArray[num] = '\0'; - str = std::string(vArray); + str = std::string(vArray); } }; diff -Nru metview-5.17.4/metview/src/libMetview/MvBufrEdition.cc metview-5.19.2/metview/src/libMetview/MvBufrEdition.cc --- metview-5.17.4/metview/src/libMetview/MvBufrEdition.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvBufrEdition.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,9 +10,11 @@ #include "MvBufrEdition.h" #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif static std::vector bufrEditionItems; @@ -22,7 +24,8 @@ masterVersion_(masterVersion), localVersion_(localVersion), centre_(centre), - subCentre_(subCentre) { + subCentre_(subCentre) +{ bufrEditionItems.push_back(this); } diff -Nru metview-5.17.4/metview/src/libMetview/MvBufrEdition.h metview-5.19.2/metview/src/libMetview/MvBufrEdition.h --- metview-5.17.4/metview/src/libMetview/MvBufrEdition.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvBufrEdition.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,12 +13,15 @@ #include #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif -class MvBufrEdition { +class MvBufrEdition +{ public: int masterTablesNumber() const { return masterNumber_; } int masterTablesVersionNumber() const { return masterVersion_; } diff -Nru metview-5.17.4/metview/src/libMetview/MvBufrElementTable.cc metview-5.19.2/metview/src/libMetview/MvBufrElementTable.cc --- metview-5.17.4/metview/src/libMetview/MvBufrElementTable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvBufrElementTable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,13 +11,15 @@ #include "MvBufrEdition.h" #include "eccodes.h" -#include +#include #include #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif @@ -25,7 +27,8 @@ static std::vector bufrElementTableItems; -bool codesCheck(const char* call, const char* /*file*/, int /*line*/, int e, const char* /*msg*/) { +bool codesCheck(const char* call, const char* /*file*/, int /*line*/, int e, const char* /*msg*/) +{ if (e) { std::cout << call << grib_get_error_message(e); return false; @@ -33,7 +36,9 @@ return true; } -MvBufrElementTable::MvBufrElementTable(MvBufrEdition* edition) : edition_(edition) { +MvBufrElementTable::MvBufrElementTable(MvBufrEdition* edition) : + edition_(edition) +{ // Build descriptor-key table buildElementTable(); @@ -41,13 +46,15 @@ bufrElementTableItems.push_back(this); } -MvBufrElementTable::~MvBufrElementTable() { +MvBufrElementTable::~MvBufrElementTable() +{ std::cout << "delete element" << std::endl; edition_ = nullptr; melems_.clear(); } -MvBufrElementTable* MvBufrElementTable::find(MvBufrEdition* edition) { +MvBufrElementTable* MvBufrElementTable::find(MvBufrEdition* edition) +{ for (auto item : bufrElementTableItems) { if (item->edition_ == edition) return item; @@ -134,468 +141,469 @@ using map_bufr_table = std::map; -static map_bufr_table create_map() { +static map_bufr_table create_map() +{ map_bufr_table map; - map[1001] = "blockNumber"; - map[1002] = "stationNumber"; - map[1003] = "regionNumber"; - map[1004] = "wmoRegionSubArea"; - map[1005] = "buoyOrPlatformIdentifier"; - map[1006] = "aircraftFlightNumber"; - map[1007] = "satelliteIdentifier"; - map[1008] = "aircraftRegistrationNumberOrOtherIdentification"; - map[1009] = "commercialAircraftType"; - map[1010] = "stationaryBuoyPlatformIdentifierEGCManBuoys"; - map[1011] = "shipOrMobileLandStationIdentifier"; - map[1012] = "directionOfMotionOfMovingObservingPlatform"; - map[1013] = "movingObservingPlatformSpeed"; - map[1014] = "platformDriftSpeed"; - map[1015] = "stationOrSiteName"; - map[1018] = "shortStationName"; - map[1019] = "longStationName"; - map[1020] = "wmoRegionSubArea"; - map[1021] = "synopticFeatureIdentifier"; - map[1022] = "featureName"; - map[1023] = "observationSequenceNumber"; - map[1024] = "windSpeedSource"; - map[1025] = "stormIdentifier"; - map[1026] = "stormName"; - map[1027] = "longStormName"; - map[1028] = "aerosolOpticalDepthSource"; - map[1029] = "ssiSource"; - map[1030] = "numericalModelIdentifier"; - map[1031] = "centre"; - map[1032] = "generatingApplication"; - map[1033] = "centre"; - map[1034] = "subCentre"; - map[1035] = "centre"; - map[1036] = "agencyInChargeOfOperatingObservingPlatform"; - map[1037] = "sigmetSequenceIdentifier"; - map[1038] = "sourceOfSeaIceFraction"; - map[1039] = "graphicalAreaForecastSequenceIdentifier"; - map[1040] = "processingCentreIdCode"; - map[1041] = "absolutePlatformVelocityFirstComponent"; - map[1042] = "absolutePlatformVelocitySecondComponent"; - map[1043] = "absolutePlatformVelocityThirdComponent"; - map[1050] = "platformTransmitterIdNumber"; - map[1051] = "platformTransmitterIdNumber"; - map[1052] = "platformTransmitterId"; - map[1053] = "tsunameterReportSequenceNumber"; - map[1060] = "aircraftReportingPointBeaconIdentifier"; - map[1062] = "shortIcaoLocationIndicator"; - map[1063] = "icaoLocationIndicator"; - map[1064] = "runwayDesignator"; - map[1065] = "icaoRegionIdentifier"; - map[1075] = "tideStationIdentification"; - map[1079] = "uniqueIdentifierForProfile"; - map[1080] = "shipLineNumberAccordingToSoop"; - map[1081] = "radiosondeSerialNumber"; - map[1082] = "radiosondeAscensionNumber"; - map[1083] = "radiosondeReleaseNumber"; - map[1085] = "observingPlatformManufacturerModel"; - map[1086] = "observingPlatformManufacturerSerialNumber"; - map[1087] = "marineObservingPlatformIdentifier"; - map[1090] = "techniqueForMakingUpInitialPerturbations"; - map[1091] = "ensembleMemberNumber"; - map[1092] = "ensembleForecastType"; - map[1093] = "balloonLotNumber"; - map[1094] = "wbanNumber"; - map[1095] = "observerIdentification"; - map[1096] = "stationAcquisition"; - map[1099] = "uniqueProductDefinition"; - map[1101] = "stateIdentifier"; - map[1102] = "nationalStationNumber"; - map[1103] = "imoNumber"; - map[1104] = "stateOrFederalStateIdentifier"; - map[1105] = "highwayDesignator"; - map[1106] = "locationAlongHighwayAsIndicatedByPositionMarkers"; - map[1110] = "aircraftTailNumber"; - map[1111] = "originationAirport"; - map[1112] = "destinationAirport"; - map[1113] = "templateVersionNumberDefinedByOriginatingCentre"; - map[1114] = "encryptedStationIdentifierBase64Encoding"; - map[1115] = "identifierOfTheCruiseOrMission"; - map[1124] = "gridPointIdentifier"; - map[1144] = "snapshotIdentifier"; - map[1150] = "coordinateReferenceSystem"; - map[1151] = "fixedMeanSeaLevelReferenceDatum"; - map[1152] = "semiMajorAxisOfRotationEllipsoid"; - map[1153] = "semiMinorAxisOfRotationEllipsoid"; - map[2001] = "stationType"; - map[2002] = "instrumentationForWindMeasurement"; - map[2003] = "measuringEquipmentType"; - map[2004] = "typeOfInstrumentationForEvaporationMeasurement"; - map[2005] = "temperatureObservationPrecision"; - map[2007] = "sensorForWaterLevelMeasuringInstrumentType"; - map[2011] = "radiosondeType"; - map[2012] = "radiosondeComputationalMethod"; - map[2013] = "solarAndInfraredRadiationCorrection"; - map[2014] = "trackingTechniqueOrStatusOfSystem"; - map[2015] = "radiosondeCompleteness"; - map[2016] = "radiosondeConfiguration"; - map[2017] = "correctionAlgorithmsForHumidityMeasurements"; - map[2019] = "satelliteInstruments"; - map[2020] = "satelliteClassification"; - map[2021] = "satelliteInstrumentDataUsedInProcessing"; - map[2022] = "satelliteDataProcessingTechnique"; - map[2023] = "satelliteDerivedWindComputationMethod"; - map[2024] = "meanHumidityComputationalMethod"; - map[2025] = "satelliteChannelsUsedInComputation"; - map[2026] = "crossTrackResolution"; - map[2027] = "alongTrackResolution"; - map[2028] = "segmentSizeAtNadirInXDirection"; - map[2029] = "segmentSizeAtNadirInYDirection"; - map[2030] = "methodOfCurrentMeasurement"; - map[2031] = "durationAndTimeOfCurrentMeasurement"; - map[2032] = "indicatorForDigitization"; - map[2033] = "methodOfSalinityOrDepthMeasurement"; - map[2034] = "drogueType"; - map[2035] = "cableLength"; - map[2036] = "buoyType"; - map[2037] = "methodOfTidalObservation"; - map[2038] = "methodOfWaterTemperatureAndOrOrSalinityMeasurement"; - map[2039] = "methodOfWetBulbTemperatureMeasurement"; - map[2040] = "methodOfRemovingVelocityAndMotionOfPlatformFromCurrent"; - map[2041] = "methodForEstimatingReportsRelatedToSynopticFeatures"; - map[2042] = "indicatorForSeaSurfaceCurrentSpeed"; - map[2044] = "indicatorForMethodOfCalculatingSpectralWaveData"; - map[2045] = "platformType"; - map[2046] = "waveMeasurementInstrumentation"; - map[2047] = "deepOceanTsunameterType"; - map[2048] = "satelliteSensorIndicator"; - map[2049] = "geostationarySatelliteDataProcessingTechnique"; - map[2050] = "geostationarySounderSatelliteChannels"; - map[2051] = "indicatorToSpecifyObservingMethodForExtremeTemperatures"; - map[2052] = "geostationaryImagerSatelliteChannels"; - map[2053] = "goesBrightnessTemperatureCharacteristics"; - map[2054] = "goesSoundingsParameter"; - map[2055] = "geostationarySoundingsStatisticalParameters"; - map[2056] = "geostationarySoundingsAccuracyStatistics"; - map[2057] = "originOfFirstGuessInformationForGoesIOrMSoundings"; - map[2058] = "validTimesOfFirstGuessInformationForGoesIOrMSoundings"; - map[2059] = "originOfAnalysisInformationForGoesIOrMSoundings"; - map[2060] = "originOfSurfaceInformationForGoesIOrMSoundings"; - map[2061] = "aircraftNavigationalSystem"; - map[2062] = "aircraftDataRelaySystemType"; - map[2063] = "aircraftRollAngle"; - map[2064] = "aircraftRollAngleQuality"; - map[2065] = "acarsGroundReceivingStation"; - map[2066] = "radiosondeGroundReceivingSystem"; - map[2067] = "radiosondeOperatingFrequency"; - map[2070] = "originalSpecificationOfLatitudeOrLongitude"; - map[2071] = "spectrographicWavelength"; - map[2072] = "spectrographicWidth"; - map[2080] = "balloonManufacturer"; - map[2081] = "balloonType"; - map[2082] = "weightOfBalloon"; - map[2083] = "balloonShelterType"; - map[2084] = "typeOfGasUsedInBalloon"; - map[2085] = "amountOfGasUsedInBalloon"; - map[2086] = "balloonFlightTrainLength"; - map[2087] = "parachuteSurfaceArea"; - map[2091] = "entrySensor4Or20Ma"; - map[2095] = "pressureSensorType"; - map[2096] = "temperatureSensorType"; - map[2097] = "humiditySensorType"; - map[2099] = "polarization"; - map[2100] = "radarConstant"; - map[2101] = "antennaType"; - map[2102] = "antennaHeightAboveTowerBase"; - map[2103] = "radome"; - map[2104] = "antennaPolarization"; - map[2105] = "maximumAntennaGain"; - map[2106] = "3DbBeamwidth"; - map[2107] = "sidelobeSuppression"; - map[2108] = "crosspolDiscriminationOnAxis"; - map[2109] = "antennaSpeedAzimuth"; - map[2110] = "antennaSpeedElevation"; - map[2111] = "radarIncidenceAngle"; - map[2112] = "radarLookAngle"; - map[2113] = "numberOfAzimuthLooks"; - map[2114] = "antennaEffectiveSurfaceArea"; - map[2115] = "surfaceObservingEquipmentType"; - map[2116] = "percentageOf320MhzBandProcessed"; - map[2117] = "percentageOf80MhzBandProcessed"; - map[2118] = "percentageOf20MhzBandProcessed"; - map[2119] = "ra2InstrumentOperations"; - map[2120] = "oceanWaveFrequency"; - map[2121] = "meanFrequency"; - map[2122] = "frequencyAgilityRange"; - map[2123] = "peakPower"; - map[2124] = "averagePower"; - map[2125] = "pulseRepetitionFrequency"; - map[2126] = "pulseWidth"; - map[2127] = "receiverIntermediateFrequency"; - map[2128] = "intermediateFrequencyBandwidth"; - map[2129] = "minimumDetectableSignal"; - map[2130] = "dynamicRange"; - map[2131] = "sensitivityTimeControl"; - map[2132] = "azimuthPointingAccuracy"; - map[2133] = "elevationPointingAccuracy"; - map[2134] = "antennaBeamAzimuth"; - map[2135] = "antennaElevation"; - map[2136] = "rangeProcessedByRangeAttenuationCorrection"; - map[2137] = "radarDualPrfRatio"; - map[2138] = "antennaRotationDirection"; - map[2139] = "siralInstrumentConfiguration"; - map[2140] = "satelliteRadarBeamAzimuthAngle"; - map[2141] = "measurementType"; - map[2142] = "ozoneInstrument"; - map[2143] = "ozoneInstrumentType"; - map[2144] = "lightSourceTypeForBrewerSpectrophotometer"; - map[2145] = "wavelengthSettingForDobsonInstruments"; - map[2146] = "sourceConditionsForDobsonInstruments"; - map[2147] = "methodOfTransmissionToCollectionCentre"; - map[2148] = "dataCollectionLocationSystem"; - map[2149] = "dataBuoyType"; - map[2150] = "tovsOrAtovsOrAvhrrInstrumentationChannelNumber"; - map[2151] = "radiometerIdentifier"; - map[2152] = "satelliteInstrumentUsedInDataProcessing"; - map[2153] = "satelliteChannelCentreFrequency"; - map[2154] = "satelliteChannelBandWidth"; - map[2155] = "satelliteChannelWavelength"; - map[2156] = "percentageOfValidKuOceanRetrackerMeasurements"; - map[2157] = "percentageOfValidSOceanRetrackerMeasurements"; - map[2158] = "ra2Instrument"; - map[2159] = "mwrInstrument"; - map[2160] = "radarWaveLength"; - map[2163] = "heightAssignmentMethod"; - map[2164] = "tracerCorrelationMethod"; - map[2165] = "radianceTypeFlags"; - map[2166] = "radianceType"; - map[2167] = "radianceComputationalMethod"; - map[2168] = "hydrostaticPressureOfLowerEndOfCableThermistorString"; - map[2169] = "anemometerType"; - map[2170] = "aircraftHumiditySensors"; - map[2171] = "instrumentSerialNumberForWaterTemperatureProfile"; - map[2172] = "productTypeForRetrievedAtmosphericGases"; - map[2173] = "squareOfOffNadirAngle"; - map[2174] = "meanAcrossTrackPixelNumber"; - map[2175] = "methodOfPrecipitationMeasurement"; - map[2176] = "methodOfStateOfGroundMeasurement"; - map[2177] = "methodOfSnowDepthMeasurement"; - map[2178] = "methodOfLiquidContentMeasurementOfPrecipitation"; - map[2179] = "skyConditionAlgorithmType"; - map[2180] = "mainPresentWeatherDetectingSystem"; - map[2181] = "supplementaryPresentWeatherSensor"; - map[2182] = "visibilityMeasurementSystem"; - map[2183] = "cloudDetectionSystem"; - map[2184] = "lightningDetectionSensorType"; - map[2185] = "methodOfEvaporationMeasurement"; - map[2186] = "capabilityToDetectPrecipitationPhenomena"; - map[2187] = "capabilityToDetectOtherWeatherPhenomena"; - map[2188] = "capabilityToDetectObscuration"; - map[2189] = "capabilityToDiscriminateLightningStrikes"; - map[2190] = "lagrangianDrifterSubmergenceTimeSubmerged"; - map[2191] = "geopotentialHeightCalculation"; - map[3001] = "surfaceStationType"; - map[3003] = "thermometerOrHygrometerHousing"; - map[3004] = "typeOfScreenOrShelterOrRadiationShield"; - map[3005] = "horizontalWidthOfScreenOrShieldX"; - map[3006] = "horizontalDepthOfScreenOrShieldY"; - map[3007] = "verticalHeightOfScreenOrShieldZ"; - map[3008] = "artificiallyVentilatedScreenOrShield"; - map[3009] = "amountOfForcedVentilationAtTimeOfReading"; - map[3010] = "methodOfSeaOrWaterCurrentMeasurement"; - map[3011] = "methodOfDepthCalculation"; - map[3012] = "instrumentTypeOrSensorForDissolvedOxygenMeasurement"; - map[3016] = "positionOfRoadSensors"; - map[3017] = "extendedTypeOfStation"; - map[3018] = "typeOfRoad"; - map[3019] = "typeOfConstruction"; - map[3020] = "materialForThermometerOrHygrometerHousing"; - map[3021] = "hygrometerHeating"; - map[3022] = "instrumentOwner"; - map[3023] = "configurationOfLouversForThermometerOrHygrometerScreen"; - map[3024] = "psychrometricCoefficient"; - map[3025] = "crossTrackEstimationAreaSize"; - map[3026] = "alongTrackEstimationAreaSize"; - map[4001] = "year"; - map[4002] = "month"; - map[4003] = "day"; - map[4004] = "hour"; - map[4005] = "minute"; - map[4006] = "second"; - map[4007] = "secondsWithinAMinuteMicrosecond"; - map[4011] = "timeIncrement"; - map[4012] = "timeIncrement"; - map[4013] = "timeIncrement"; - map[4014] = "timeIncrement"; - map[4015] = "timeIncrement"; - map[4016] = "timeIncrement"; - map[4017] = "referenceTimePeriodForAccumulatedOrExtremeData"; - map[4021] = "timePeriod"; - map[4022] = "timePeriod"; - map[4023] = "timePeriod"; - map[4024] = "timePeriod"; - map[4025] = "timePeriod"; - map[4026] = "timePeriod"; - map[4031] = "durationOfTimeRelatingToFollowingValue"; - map[4032] = "durationOfTimeRelatingToFollowingValue"; - map[4041] = "timeDifferenceUtcLmt"; - map[4043] = "dayOfYear"; - map[4051] = "principalTimeOfDailyReadingOfMaximumTemperature"; - map[4052] = "principalTimeOfDailyReadingOfMinimumTemperature"; - map[4053] = "numberOfDaysWithPrecipitationEqualToOrMoreThan1Mm"; - map[4059] = "timesOfObservationUsedToComputeReportedMeanValues"; - map[4065] = "timeIncrement"; - map[4066] = "timeIncrement"; - map[4073] = "timePeriod"; - map[4074] = "timePeriod"; - map[4075] = "timePeriod"; - map[4080] = "averagingPeriodForFollowingValue"; - map[4086] = "timePeriod"; - map[5001] = "latitude"; - map[5002] = "latitude"; - map[5011] = "latitudeIncrement"; - map[5012] = "latitudeIncrement"; - map[5015] = "latitudeDisplacement"; - map[5016] = "latitudeDisplacement"; - map[5021] = "bearingOrAzimuth"; - map[5022] = "solarAzimuth"; - map[5023] = "sunToSatelliteAzimuthDifference"; - map[5030] = "directionSpectral"; - map[5031] = "rowNumber"; - map[5032] = "yOffset"; - map[5033] = "pixelSizeOnHorizontal1"; - map[5034] = "alongTrackRowNumber"; - map[5035] = "xDimensionMaximumSize"; - map[5036] = "shipTransectNumberAccordingToSoop"; - map[5040] = "orbitNumber"; - map[5041] = "scanLineNumber"; - map[5042] = "channelNumber"; - map[5043] = "fieldOfViewNumber"; - map[5044] = "satelliteCycleNumber"; - map[5045] = "fieldOfRegardNumber"; - map[5052] = "channelNumberIncrement"; - map[5053] = "fieldOfViewNumberIncrement"; - map[5060] = "yAngularPositionFromCentreOfGravity"; - map[5061] = "zAngularPositionFromCentreOfGravity"; - map[5063] = "spacecraftRoll"; - map[5064] = "spacecraftPitch"; - map[5066] = "spacecraftYaw"; - map[5067] = "numberOfScanLines"; - map[5068] = "profileNumber"; - map[5069] = "receiverChannel"; - map[5070] = "observationIdentifier"; - map[5071] = "stripmapIdentifier"; - map[5072] = "numberOfSpectraInRangeDirection"; - map[5073] = "numberOfSpectraInAzimuthalDirection"; - map[5074] = "indexInRangeDirection"; - map[5075] = "indexInAzimuthalDirection"; - map[6001] = "longitude"; - map[6002] = "longitude"; - map[6011] = "longitudeIncrement"; - map[6012] = "longitudeIncrement"; - map[6015] = "longitudeDisplacement"; - map[6016] = "longitudeDisplacement"; - map[6021] = "distance"; - map[6029] = "waveNumber"; - map[6030] = "waveNumberSpectral"; - map[6031] = "columnNumber"; - map[6032] = "xOffset"; - map[6033] = "pixelSizeOnHorizontal2"; - map[6034] = "crossTrackCellNumber"; - map[6035] = "yDimensionMaximumSize"; - map[6040] = "radiusOfConfidence"; - map[7001] = "heightOfStation"; - map[7002] = "height"; - map[7003] = "geopotential"; - map[7004] = "pressure"; - map[7005] = "heightIncrement"; - map[7006] = "heightAboveStation"; - map[7007] = "height"; - map[7008] = "geopotential"; - map[7009] = "geopotentialHeight"; - map[7010] = "flightLevel"; - map[7012] = "gridPointAltitude"; - map[7021] = "elevation"; - map[7022] = "solarElevation"; - map[7024] = "satelliteZenithAngle"; - map[7025] = "solarZenithAngle"; - map[7026] = "satelliteZenithAngle"; - map[7030] = "heightOfStationGroundAboveMeanSeaLevel"; - map[7031] = "heightOfBarometerAboveMeanSeaLevel"; - map[7032] = "heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform"; - map[7033] = "heightOfSensorAboveWaterSurface"; - map[7035] = "zDimensionMaximumSize"; - map[7036] = "levelIndexOfZ"; - map[7040] = "impactParameter"; - map[7061] = "depthBelowLandSurface"; - map[7062] = "depthBelowWaterSurface"; - map[7063] = "depthBelowWaterSurface"; - map[7064] = "representativeHeightOfSensorAboveStation"; - map[7065] = "waterPressure"; - map[7070] = "drogueDepth"; - map[7071] = "height"; - map[8001] = "verticalSoundingSignificance"; - map[8002] = "verticalSignificanceSurfaceObservations"; - map[8003] = "verticalSignificanceSatelliteObservations"; - map[8004] = "phaseOfAircraftFlight"; - map[8005] = "meteorologicalAttributeSignificance"; - map[8006] = "ozoneVerticalSoundingSignificance"; - map[8007] = "dimensionalSignificance"; - map[8008] = "radiationVerticalSoundingSignificance"; - map[8009] = "detailedPhaseOfFlight"; - map[8010] = "surfaceQualifierForTemperatureData"; - map[8011] = "meteorologicalFeature"; - map[8012] = "landOrSeaQualifier"; - map[8013] = "dayOrNightQualifier"; - map[8014] = "qualifierForRunwayVisualRange"; - map[8015] = "significantQualifierForSensor"; - map[8016] = "changeQualifierOfATrendTypeForecastOrAnAerodromeForecast"; - map[8017] = "qualifierOfTimeWhenForecastChangeExpected"; - map[8018] = "seawindsLandOrIceSurfaceType"; - map[8019] = "qualifierForFollowingCentreIdentifier"; - map[8020] = "totalNumberOfMissingEntitiesWithRespectToAccumulationOrAverage"; - map[8021] = "timeSignificance"; - map[8022] = "totalNumberWithRespectToAccumulationOrAverage"; - map[8023] = "firstOrderStatistics"; - map[8024] = "differenceStatistics"; - map[8025] = "timeDifferenceQualifier"; - map[8026] = "matrixSignificance"; - map[8029] = "surfaceType"; - map[8030] = "manualOnCodesVolumeI1SectionCCodeTableFromWhichDataAreDerived"; - map[8031] = "dataCategoryCrexTableA"; - map[8032] = "statusOfOperation"; - map[8033] = "methodOfDerivationOfPercentageConfidence"; - map[8034] = "temperatureOrSalinityMeasurementQualifier"; - map[8035] = "monitoringExerciseType"; - map[8036] = "typeOfCentreOrStationPerformingMonitoring"; - map[8039] = "timeSignificanceAviationForecast"; - map[8040] = "flightLevelSignificance"; - map[8041] = "dataSignificance"; - map[8042] = "extendedVerticalSoundingSignificance"; - map[8043] = "atmosphericChemical"; - map[8044] = "casRegistryNumber"; - map[8046] = "atmosphericChemical"; - map[8049] = "numberOfObservations"; - map[8050] = "qualifierForNumberOfMissingValuesInCalculationOfStatistic"; - map[8051] = "qualifierForNumberOfMissingValuesInCalculationOfStatistic"; - map[8052] = "conditionForWhichNumberOfDaysOfOccurrenceFollows"; - map[8053] = "dayOfOccurrenceQualifier"; - map[8054] = "qualifierForWindSpeedOrWindGusts"; - map[8060] = "sampleScanningModeSignificance"; - map[8065] = "sunGlintIndicator"; - map[8066] = "semiTransparencyIndicator"; - map[8070] = "tovsOrAtovsProductQualifier"; - map[8072] = "pixelType"; - map[8074] = "altimeterEchoType"; - map[8075] = "orbitQualifier"; - map[8076] = "band"; - map[8077] = "radiometerSensedSurfaceType"; - map[8079] = "productStatus"; - map[8080] = "qualifierForGtsppQualityFlag"; - map[8081] = "equipmentType"; - map[8082] = "modificationOfSensorHeightToAnotherValue"; - map[8083] = "nominalValueIndicator"; - map[8085] = "beamIdentifier"; - map[8086] = "verticalSignificanceForNwp"; - map[8087] = "cornerPositionOfObservation"; - map[8088] = "mapSignificance"; - map[8090] = "decimalScaleOfFollowingSignificands"; - map[8091] = "coordinatesSignificance"; + map[1001] = "blockNumber"; + map[1002] = "stationNumber"; + map[1003] = "regionNumber"; + map[1004] = "wmoRegionSubArea"; + map[1005] = "buoyOrPlatformIdentifier"; + map[1006] = "aircraftFlightNumber"; + map[1007] = "satelliteIdentifier"; + map[1008] = "aircraftRegistrationNumberOrOtherIdentification"; + map[1009] = "commercialAircraftType"; + map[1010] = "stationaryBuoyPlatformIdentifierEGCManBuoys"; + map[1011] = "shipOrMobileLandStationIdentifier"; + map[1012] = "directionOfMotionOfMovingObservingPlatform"; + map[1013] = "movingObservingPlatformSpeed"; + map[1014] = "platformDriftSpeed"; + map[1015] = "stationOrSiteName"; + map[1018] = "shortStationName"; + map[1019] = "longStationName"; + map[1020] = "wmoRegionSubArea"; + map[1021] = "synopticFeatureIdentifier"; + map[1022] = "featureName"; + map[1023] = "observationSequenceNumber"; + map[1024] = "windSpeedSource"; + map[1025] = "stormIdentifier"; + map[1026] = "stormName"; + map[1027] = "longStormName"; + map[1028] = "aerosolOpticalDepthSource"; + map[1029] = "ssiSource"; + map[1030] = "numericalModelIdentifier"; + map[1031] = "centre"; + map[1032] = "generatingApplication"; + map[1033] = "centre"; + map[1034] = "subCentre"; + map[1035] = "centre"; + map[1036] = "agencyInChargeOfOperatingObservingPlatform"; + map[1037] = "sigmetSequenceIdentifier"; + map[1038] = "sourceOfSeaIceFraction"; + map[1039] = "graphicalAreaForecastSequenceIdentifier"; + map[1040] = "processingCentreIdCode"; + map[1041] = "absolutePlatformVelocityFirstComponent"; + map[1042] = "absolutePlatformVelocitySecondComponent"; + map[1043] = "absolutePlatformVelocityThirdComponent"; + map[1050] = "platformTransmitterIdNumber"; + map[1051] = "platformTransmitterIdNumber"; + map[1052] = "platformTransmitterId"; + map[1053] = "tsunameterReportSequenceNumber"; + map[1060] = "aircraftReportingPointBeaconIdentifier"; + map[1062] = "shortIcaoLocationIndicator"; + map[1063] = "icaoLocationIndicator"; + map[1064] = "runwayDesignator"; + map[1065] = "icaoRegionIdentifier"; + map[1075] = "tideStationIdentification"; + map[1079] = "uniqueIdentifierForProfile"; + map[1080] = "shipLineNumberAccordingToSoop"; + map[1081] = "radiosondeSerialNumber"; + map[1082] = "radiosondeAscensionNumber"; + map[1083] = "radiosondeReleaseNumber"; + map[1085] = "observingPlatformManufacturerModel"; + map[1086] = "observingPlatformManufacturerSerialNumber"; + map[1087] = "marineObservingPlatformIdentifier"; + map[1090] = "techniqueForMakingUpInitialPerturbations"; + map[1091] = "ensembleMemberNumber"; + map[1092] = "ensembleForecastType"; + map[1093] = "balloonLotNumber"; + map[1094] = "wbanNumber"; + map[1095] = "observerIdentification"; + map[1096] = "stationAcquisition"; + map[1099] = "uniqueProductDefinition"; + map[1101] = "stateIdentifier"; + map[1102] = "nationalStationNumber"; + map[1103] = "imoNumber"; + map[1104] = "stateOrFederalStateIdentifier"; + map[1105] = "highwayDesignator"; + map[1106] = "locationAlongHighwayAsIndicatedByPositionMarkers"; + map[1110] = "aircraftTailNumber"; + map[1111] = "originationAirport"; + map[1112] = "destinationAirport"; + map[1113] = "templateVersionNumberDefinedByOriginatingCentre"; + map[1114] = "encryptedStationIdentifierBase64Encoding"; + map[1115] = "identifierOfTheCruiseOrMission"; + map[1124] = "gridPointIdentifier"; + map[1144] = "snapshotIdentifier"; + map[1150] = "coordinateReferenceSystem"; + map[1151] = "fixedMeanSeaLevelReferenceDatum"; + map[1152] = "semiMajorAxisOfRotationEllipsoid"; + map[1153] = "semiMinorAxisOfRotationEllipsoid"; + map[2001] = "stationType"; + map[2002] = "instrumentationForWindMeasurement"; + map[2003] = "measuringEquipmentType"; + map[2004] = "typeOfInstrumentationForEvaporationMeasurement"; + map[2005] = "temperatureObservationPrecision"; + map[2007] = "sensorForWaterLevelMeasuringInstrumentType"; + map[2011] = "radiosondeType"; + map[2012] = "radiosondeComputationalMethod"; + map[2013] = "solarAndInfraredRadiationCorrection"; + map[2014] = "trackingTechniqueOrStatusOfSystem"; + map[2015] = "radiosondeCompleteness"; + map[2016] = "radiosondeConfiguration"; + map[2017] = "correctionAlgorithmsForHumidityMeasurements"; + map[2019] = "satelliteInstruments"; + map[2020] = "satelliteClassification"; + map[2021] = "satelliteInstrumentDataUsedInProcessing"; + map[2022] = "satelliteDataProcessingTechnique"; + map[2023] = "satelliteDerivedWindComputationMethod"; + map[2024] = "meanHumidityComputationalMethod"; + map[2025] = "satelliteChannelsUsedInComputation"; + map[2026] = "crossTrackResolution"; + map[2027] = "alongTrackResolution"; + map[2028] = "segmentSizeAtNadirInXDirection"; + map[2029] = "segmentSizeAtNadirInYDirection"; + map[2030] = "methodOfCurrentMeasurement"; + map[2031] = "durationAndTimeOfCurrentMeasurement"; + map[2032] = "indicatorForDigitization"; + map[2033] = "methodOfSalinityOrDepthMeasurement"; + map[2034] = "drogueType"; + map[2035] = "cableLength"; + map[2036] = "buoyType"; + map[2037] = "methodOfTidalObservation"; + map[2038] = "methodOfWaterTemperatureAndOrOrSalinityMeasurement"; + map[2039] = "methodOfWetBulbTemperatureMeasurement"; + map[2040] = "methodOfRemovingVelocityAndMotionOfPlatformFromCurrent"; + map[2041] = "methodForEstimatingReportsRelatedToSynopticFeatures"; + map[2042] = "indicatorForSeaSurfaceCurrentSpeed"; + map[2044] = "indicatorForMethodOfCalculatingSpectralWaveData"; + map[2045] = "platformType"; + map[2046] = "waveMeasurementInstrumentation"; + map[2047] = "deepOceanTsunameterType"; + map[2048] = "satelliteSensorIndicator"; + map[2049] = "geostationarySatelliteDataProcessingTechnique"; + map[2050] = "geostationarySounderSatelliteChannels"; + map[2051] = "indicatorToSpecifyObservingMethodForExtremeTemperatures"; + map[2052] = "geostationaryImagerSatelliteChannels"; + map[2053] = "goesBrightnessTemperatureCharacteristics"; + map[2054] = "goesSoundingsParameter"; + map[2055] = "geostationarySoundingsStatisticalParameters"; + map[2056] = "geostationarySoundingsAccuracyStatistics"; + map[2057] = "originOfFirstGuessInformationForGoesIOrMSoundings"; + map[2058] = "validTimesOfFirstGuessInformationForGoesIOrMSoundings"; + map[2059] = "originOfAnalysisInformationForGoesIOrMSoundings"; + map[2060] = "originOfSurfaceInformationForGoesIOrMSoundings"; + map[2061] = "aircraftNavigationalSystem"; + map[2062] = "aircraftDataRelaySystemType"; + map[2063] = "aircraftRollAngle"; + map[2064] = "aircraftRollAngleQuality"; + map[2065] = "acarsGroundReceivingStation"; + map[2066] = "radiosondeGroundReceivingSystem"; + map[2067] = "radiosondeOperatingFrequency"; + map[2070] = "originalSpecificationOfLatitudeOrLongitude"; + map[2071] = "spectrographicWavelength"; + map[2072] = "spectrographicWidth"; + map[2080] = "balloonManufacturer"; + map[2081] = "balloonType"; + map[2082] = "weightOfBalloon"; + map[2083] = "balloonShelterType"; + map[2084] = "typeOfGasUsedInBalloon"; + map[2085] = "amountOfGasUsedInBalloon"; + map[2086] = "balloonFlightTrainLength"; + map[2087] = "parachuteSurfaceArea"; + map[2091] = "entrySensor4Or20Ma"; + map[2095] = "pressureSensorType"; + map[2096] = "temperatureSensorType"; + map[2097] = "humiditySensorType"; + map[2099] = "polarization"; + map[2100] = "radarConstant"; + map[2101] = "antennaType"; + map[2102] = "antennaHeightAboveTowerBase"; + map[2103] = "radome"; + map[2104] = "antennaPolarization"; + map[2105] = "maximumAntennaGain"; + map[2106] = "3DbBeamwidth"; + map[2107] = "sidelobeSuppression"; + map[2108] = "crosspolDiscriminationOnAxis"; + map[2109] = "antennaSpeedAzimuth"; + map[2110] = "antennaSpeedElevation"; + map[2111] = "radarIncidenceAngle"; + map[2112] = "radarLookAngle"; + map[2113] = "numberOfAzimuthLooks"; + map[2114] = "antennaEffectiveSurfaceArea"; + map[2115] = "surfaceObservingEquipmentType"; + map[2116] = "percentageOf320MhzBandProcessed"; + map[2117] = "percentageOf80MhzBandProcessed"; + map[2118] = "percentageOf20MhzBandProcessed"; + map[2119] = "ra2InstrumentOperations"; + map[2120] = "oceanWaveFrequency"; + map[2121] = "meanFrequency"; + map[2122] = "frequencyAgilityRange"; + map[2123] = "peakPower"; + map[2124] = "averagePower"; + map[2125] = "pulseRepetitionFrequency"; + map[2126] = "pulseWidth"; + map[2127] = "receiverIntermediateFrequency"; + map[2128] = "intermediateFrequencyBandwidth"; + map[2129] = "minimumDetectableSignal"; + map[2130] = "dynamicRange"; + map[2131] = "sensitivityTimeControl"; + map[2132] = "azimuthPointingAccuracy"; + map[2133] = "elevationPointingAccuracy"; + map[2134] = "antennaBeamAzimuth"; + map[2135] = "antennaElevation"; + map[2136] = "rangeProcessedByRangeAttenuationCorrection"; + map[2137] = "radarDualPrfRatio"; + map[2138] = "antennaRotationDirection"; + map[2139] = "siralInstrumentConfiguration"; + map[2140] = "satelliteRadarBeamAzimuthAngle"; + map[2141] = "measurementType"; + map[2142] = "ozoneInstrument"; + map[2143] = "ozoneInstrumentType"; + map[2144] = "lightSourceTypeForBrewerSpectrophotometer"; + map[2145] = "wavelengthSettingForDobsonInstruments"; + map[2146] = "sourceConditionsForDobsonInstruments"; + map[2147] = "methodOfTransmissionToCollectionCentre"; + map[2148] = "dataCollectionLocationSystem"; + map[2149] = "dataBuoyType"; + map[2150] = "tovsOrAtovsOrAvhrrInstrumentationChannelNumber"; + map[2151] = "radiometerIdentifier"; + map[2152] = "satelliteInstrumentUsedInDataProcessing"; + map[2153] = "satelliteChannelCentreFrequency"; + map[2154] = "satelliteChannelBandWidth"; + map[2155] = "satelliteChannelWavelength"; + map[2156] = "percentageOfValidKuOceanRetrackerMeasurements"; + map[2157] = "percentageOfValidSOceanRetrackerMeasurements"; + map[2158] = "ra2Instrument"; + map[2159] = "mwrInstrument"; + map[2160] = "radarWaveLength"; + map[2163] = "heightAssignmentMethod"; + map[2164] = "tracerCorrelationMethod"; + map[2165] = "radianceTypeFlags"; + map[2166] = "radianceType"; + map[2167] = "radianceComputationalMethod"; + map[2168] = "hydrostaticPressureOfLowerEndOfCableThermistorString"; + map[2169] = "anemometerType"; + map[2170] = "aircraftHumiditySensors"; + map[2171] = "instrumentSerialNumberForWaterTemperatureProfile"; + map[2172] = "productTypeForRetrievedAtmosphericGases"; + map[2173] = "squareOfOffNadirAngle"; + map[2174] = "meanAcrossTrackPixelNumber"; + map[2175] = "methodOfPrecipitationMeasurement"; + map[2176] = "methodOfStateOfGroundMeasurement"; + map[2177] = "methodOfSnowDepthMeasurement"; + map[2178] = "methodOfLiquidContentMeasurementOfPrecipitation"; + map[2179] = "skyConditionAlgorithmType"; + map[2180] = "mainPresentWeatherDetectingSystem"; + map[2181] = "supplementaryPresentWeatherSensor"; + map[2182] = "visibilityMeasurementSystem"; + map[2183] = "cloudDetectionSystem"; + map[2184] = "lightningDetectionSensorType"; + map[2185] = "methodOfEvaporationMeasurement"; + map[2186] = "capabilityToDetectPrecipitationPhenomena"; + map[2187] = "capabilityToDetectOtherWeatherPhenomena"; + map[2188] = "capabilityToDetectObscuration"; + map[2189] = "capabilityToDiscriminateLightningStrikes"; + map[2190] = "lagrangianDrifterSubmergenceTimeSubmerged"; + map[2191] = "geopotentialHeightCalculation"; + map[3001] = "surfaceStationType"; + map[3003] = "thermometerOrHygrometerHousing"; + map[3004] = "typeOfScreenOrShelterOrRadiationShield"; + map[3005] = "horizontalWidthOfScreenOrShieldX"; + map[3006] = "horizontalDepthOfScreenOrShieldY"; + map[3007] = "verticalHeightOfScreenOrShieldZ"; + map[3008] = "artificiallyVentilatedScreenOrShield"; + map[3009] = "amountOfForcedVentilationAtTimeOfReading"; + map[3010] = "methodOfSeaOrWaterCurrentMeasurement"; + map[3011] = "methodOfDepthCalculation"; + map[3012] = "instrumentTypeOrSensorForDissolvedOxygenMeasurement"; + map[3016] = "positionOfRoadSensors"; + map[3017] = "extendedTypeOfStation"; + map[3018] = "typeOfRoad"; + map[3019] = "typeOfConstruction"; + map[3020] = "materialForThermometerOrHygrometerHousing"; + map[3021] = "hygrometerHeating"; + map[3022] = "instrumentOwner"; + map[3023] = "configurationOfLouversForThermometerOrHygrometerScreen"; + map[3024] = "psychrometricCoefficient"; + map[3025] = "crossTrackEstimationAreaSize"; + map[3026] = "alongTrackEstimationAreaSize"; + map[4001] = "year"; + map[4002] = "month"; + map[4003] = "day"; + map[4004] = "hour"; + map[4005] = "minute"; + map[4006] = "second"; + map[4007] = "secondsWithinAMinuteMicrosecond"; + map[4011] = "timeIncrement"; + map[4012] = "timeIncrement"; + map[4013] = "timeIncrement"; + map[4014] = "timeIncrement"; + map[4015] = "timeIncrement"; + map[4016] = "timeIncrement"; + map[4017] = "referenceTimePeriodForAccumulatedOrExtremeData"; + map[4021] = "timePeriod"; + map[4022] = "timePeriod"; + map[4023] = "timePeriod"; + map[4024] = "timePeriod"; + map[4025] = "timePeriod"; + map[4026] = "timePeriod"; + map[4031] = "durationOfTimeRelatingToFollowingValue"; + map[4032] = "durationOfTimeRelatingToFollowingValue"; + map[4041] = "timeDifferenceUtcLmt"; + map[4043] = "dayOfYear"; + map[4051] = "principalTimeOfDailyReadingOfMaximumTemperature"; + map[4052] = "principalTimeOfDailyReadingOfMinimumTemperature"; + map[4053] = "numberOfDaysWithPrecipitationEqualToOrMoreThan1Mm"; + map[4059] = "timesOfObservationUsedToComputeReportedMeanValues"; + map[4065] = "timeIncrement"; + map[4066] = "timeIncrement"; + map[4073] = "timePeriod"; + map[4074] = "timePeriod"; + map[4075] = "timePeriod"; + map[4080] = "averagingPeriodForFollowingValue"; + map[4086] = "timePeriod"; + map[5001] = "latitude"; + map[5002] = "latitude"; + map[5011] = "latitudeIncrement"; + map[5012] = "latitudeIncrement"; + map[5015] = "latitudeDisplacement"; + map[5016] = "latitudeDisplacement"; + map[5021] = "bearingOrAzimuth"; + map[5022] = "solarAzimuth"; + map[5023] = "sunToSatelliteAzimuthDifference"; + map[5030] = "directionSpectral"; + map[5031] = "rowNumber"; + map[5032] = "yOffset"; + map[5033] = "pixelSizeOnHorizontal1"; + map[5034] = "alongTrackRowNumber"; + map[5035] = "xDimensionMaximumSize"; + map[5036] = "shipTransectNumberAccordingToSoop"; + map[5040] = "orbitNumber"; + map[5041] = "scanLineNumber"; + map[5042] = "channelNumber"; + map[5043] = "fieldOfViewNumber"; + map[5044] = "satelliteCycleNumber"; + map[5045] = "fieldOfRegardNumber"; + map[5052] = "channelNumberIncrement"; + map[5053] = "fieldOfViewNumberIncrement"; + map[5060] = "yAngularPositionFromCentreOfGravity"; + map[5061] = "zAngularPositionFromCentreOfGravity"; + map[5063] = "spacecraftRoll"; + map[5064] = "spacecraftPitch"; + map[5066] = "spacecraftYaw"; + map[5067] = "numberOfScanLines"; + map[5068] = "profileNumber"; + map[5069] = "receiverChannel"; + map[5070] = "observationIdentifier"; + map[5071] = "stripmapIdentifier"; + map[5072] = "numberOfSpectraInRangeDirection"; + map[5073] = "numberOfSpectraInAzimuthalDirection"; + map[5074] = "indexInRangeDirection"; + map[5075] = "indexInAzimuthalDirection"; + map[6001] = "longitude"; + map[6002] = "longitude"; + map[6011] = "longitudeIncrement"; + map[6012] = "longitudeIncrement"; + map[6015] = "longitudeDisplacement"; + map[6016] = "longitudeDisplacement"; + map[6021] = "distance"; + map[6029] = "waveNumber"; + map[6030] = "waveNumberSpectral"; + map[6031] = "columnNumber"; + map[6032] = "xOffset"; + map[6033] = "pixelSizeOnHorizontal2"; + map[6034] = "crossTrackCellNumber"; + map[6035] = "yDimensionMaximumSize"; + map[6040] = "radiusOfConfidence"; + map[7001] = "heightOfStation"; + map[7002] = "height"; + map[7003] = "geopotential"; + map[7004] = "pressure"; + map[7005] = "heightIncrement"; + map[7006] = "heightAboveStation"; + map[7007] = "height"; + map[7008] = "geopotential"; + map[7009] = "geopotentialHeight"; + map[7010] = "flightLevel"; + map[7012] = "gridPointAltitude"; + map[7021] = "elevation"; + map[7022] = "solarElevation"; + map[7024] = "satelliteZenithAngle"; + map[7025] = "solarZenithAngle"; + map[7026] = "satelliteZenithAngle"; + map[7030] = "heightOfStationGroundAboveMeanSeaLevel"; + map[7031] = "heightOfBarometerAboveMeanSeaLevel"; + map[7032] = "heightOfSensorAboveLocalGroundOrDeckOfMarinePlatform"; + map[7033] = "heightOfSensorAboveWaterSurface"; + map[7035] = "zDimensionMaximumSize"; + map[7036] = "levelIndexOfZ"; + map[7040] = "impactParameter"; + map[7061] = "depthBelowLandSurface"; + map[7062] = "depthBelowWaterSurface"; + map[7063] = "depthBelowWaterSurface"; + map[7064] = "representativeHeightOfSensorAboveStation"; + map[7065] = "waterPressure"; + map[7070] = "drogueDepth"; + map[7071] = "height"; + map[8001] = "verticalSoundingSignificance"; + map[8002] = "verticalSignificanceSurfaceObservations"; + map[8003] = "verticalSignificanceSatelliteObservations"; + map[8004] = "phaseOfAircraftFlight"; + map[8005] = "meteorologicalAttributeSignificance"; + map[8006] = "ozoneVerticalSoundingSignificance"; + map[8007] = "dimensionalSignificance"; + map[8008] = "radiationVerticalSoundingSignificance"; + map[8009] = "detailedPhaseOfFlight"; + map[8010] = "surfaceQualifierForTemperatureData"; + map[8011] = "meteorologicalFeature"; + map[8012] = "landOrSeaQualifier"; + map[8013] = "dayOrNightQualifier"; + map[8014] = "qualifierForRunwayVisualRange"; + map[8015] = "significantQualifierForSensor"; + map[8016] = "changeQualifierOfATrendTypeForecastOrAnAerodromeForecast"; + map[8017] = "qualifierOfTimeWhenForecastChangeExpected"; + map[8018] = "seawindsLandOrIceSurfaceType"; + map[8019] = "qualifierForFollowingCentreIdentifier"; + map[8020] = "totalNumberOfMissingEntitiesWithRespectToAccumulationOrAverage"; + map[8021] = "timeSignificance"; + map[8022] = "totalNumberWithRespectToAccumulationOrAverage"; + map[8023] = "firstOrderStatistics"; + map[8024] = "differenceStatistics"; + map[8025] = "timeDifferenceQualifier"; + map[8026] = "matrixSignificance"; + map[8029] = "surfaceType"; + map[8030] = "manualOnCodesVolumeI1SectionCCodeTableFromWhichDataAreDerived"; + map[8031] = "dataCategoryCrexTableA"; + map[8032] = "statusOfOperation"; + map[8033] = "methodOfDerivationOfPercentageConfidence"; + map[8034] = "temperatureOrSalinityMeasurementQualifier"; + map[8035] = "monitoringExerciseType"; + map[8036] = "typeOfCentreOrStationPerformingMonitoring"; + map[8039] = "timeSignificanceAviationForecast"; + map[8040] = "flightLevelSignificance"; + map[8041] = "dataSignificance"; + map[8042] = "extendedVerticalSoundingSignificance"; + map[8043] = "atmosphericChemical"; + map[8044] = "casRegistryNumber"; + map[8046] = "atmosphericChemical"; + map[8049] = "numberOfObservations"; + map[8050] = "qualifierForNumberOfMissingValuesInCalculationOfStatistic"; + map[8051] = "qualifierForNumberOfMissingValuesInCalculationOfStatistic"; + map[8052] = "conditionForWhichNumberOfDaysOfOccurrenceFollows"; + map[8053] = "dayOfOccurrenceQualifier"; + map[8054] = "qualifierForWindSpeedOrWindGusts"; + map[8060] = "sampleScanningModeSignificance"; + map[8065] = "sunGlintIndicator"; + map[8066] = "semiTransparencyIndicator"; + map[8070] = "tovsOrAtovsProductQualifier"; + map[8072] = "pixelType"; + map[8074] = "altimeterEchoType"; + map[8075] = "orbitQualifier"; + map[8076] = "band"; + map[8077] = "radiometerSensedSurfaceType"; + map[8079] = "productStatus"; + map[8080] = "qualifierForGtsppQualityFlag"; + map[8081] = "equipmentType"; + map[8082] = "modificationOfSensorHeightToAnotherValue"; + map[8083] = "nominalValueIndicator"; + map[8085] = "beamIdentifier"; + map[8086] = "verticalSignificanceForNwp"; + map[8087] = "cornerPositionOfObservation"; + map[8088] = "mapSignificance"; + map[8090] = "decimalScaleOfFollowingSignificands"; + map[8091] = "coordinatesSignificance"; map[10001] = "heightOfLandSurface"; map[10002] = "nonCoordinateHeight"; map[10003] = "nonCoordinateGeopotential"; @@ -1732,7 +1740,8 @@ return map; } -bool MvBufrElementTable::buildElementTable() { +bool MvBufrElementTable::buildElementTable() +{ melems_ = create_map(); return true; } diff -Nru metview-5.17.4/metview/src/libMetview/MvBufrElementTable.h metview-5.19.2/metview/src/libMetview/MvBufrElementTable.h --- metview-5.17.4/metview/src/libMetview/MvBufrElementTable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvBufrElementTable.h 2023-07-15 08:28:47.000000000 +0000 @@ -12,14 +12,17 @@ #include #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif class MvBufrEdition; -class MvBufrElementTable { +class MvBufrElementTable +{ public: const std::string& keyName(int); // const; bool buildElementTable(); diff -Nru metview-5.17.4/metview/src/libMetview/MvBufr.h metview-5.19.2/metview/src/libMetview/MvBufr.h --- metview-5.17.4/metview/src/libMetview/MvBufr.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvBufr.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,11 @@ /*! \file */ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif //-------------------------------------------------------- @@ -33,7 +35,7 @@ //------------------------------------------------------// // missing value code to be used in C/C++ routines // //------------------------------------------------------// -const float kBufrMissingValue = 1.7e38; +const float kBufrMissingValue = 1.7e38; const int kBufrMissingIntValue = 2147483647; @@ -49,15 +51,15 @@ // NOTE2: IBM/AIX cannot handle bigger arrays in -q32 mode //-------------------------------------------------------- #if defined(AIX) || defined(MV_USE_SMALL_ARRAYS) -const int MAX_KELEM = 40000; // 12000; -const int NUM_MAX_KVALS = 3; +const int MAX_KELEM = 40000; // 12000; +const int NUM_MAX_KVALS = 3; const int aMAX_KVALS[NUM_MAX_KVALS] = {90000, 180000, 360000}; // previous max values: 80000 // 7MB 14MB 27MB // (vals*80)/(1024*1024)MB const int MAX_KVALS = aMAX_KVALS[NUM_MAX_KVALS - 1]; // biggest entry in aMAX_KVALS #else -const int MAX_KELEM = 160000; // max allowed is 160,000 !!! // 80000; // 40000; //12000; -const int NUM_MAX_KVALS = 3; +const int MAX_KELEM = 160000; // max allowed is 160,000 !!! // 80000; // 40000; //12000; +const int NUM_MAX_KVALS = 3; const int aMAX_KVALS[NUM_MAX_KVALS] = {600000, 1500000, 4096000}; // 360000; //80000; // 45MB 115MB 312MB @@ -96,7 +98,8 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS // Sections of a BUFR message -typedef struct { +typedef struct +{ unsigned char startStr; // "B" unsigned char startStr2; // "U" unsigned char startStr3; // "F" @@ -139,7 +142,8 @@ const unsigned char cOctetMissingIndicator = 255; -class Section1Base { +class Section1Base +{ public: Section1Base(const unsigned char* octs); Section1Base(const Section1Base* aSec1); @@ -149,66 +153,74 @@ bool isDifferent(const Section1Base* aSec1) const; const unsigned char* start() const { return octets_; } - virtual bool hasSection2() = 0; - virtual TDynamicTime date() = 0; - virtual int msgType() = 0; - virtual int msgSubtypeWMO() = 0; - virtual int msgSubtypeLocal() = 0; - virtual int msgSubtype() = 0; - virtual int origCentre() = 0; - virtual int origSubCentre() = 0; - virtual int masterTable() = 0; + virtual bool hasSection2() = 0; + virtual TDynamicTime date() = 0; + virtual int msgType() = 0; + virtual int msgSubtypeWMO() = 0; + virtual int msgSubtypeLocal() = 0; + virtual int msgSubtype() = 0; + virtual int origCentre() = 0; + virtual int origSubCentre() = 0; + virtual int masterTable() = 0; virtual int masterTableVersion() = 0; - virtual int localTableVersion() = 0; + virtual int localTableVersion() = 0; protected: unsigned char* octets_; }; -class Section1_preEd4 : public Section1Base { +class Section1_preEd4 : public Section1Base +{ public: - Section1_preEd4(const unsigned char* octs) : Section1Base(octs){}; - Section1_preEd4(const Section1Base* aSec1) : Section1Base(aSec1){}; - - bool hasSection2(); - TDynamicTime date(); - int msgType(); - int msgSubtypeWMO(); - int msgSubtypeLocal(); - int msgSubtype(); - int origCentre(); - int origSubCentre(); - int masterTable(); - int masterTableVersion(); - int localTableVersion(); + Section1_preEd4(const unsigned char* octs) : + Section1Base(octs){}; + Section1_preEd4(const Section1Base* aSec1) : + Section1Base(aSec1){}; + + bool hasSection2() override; + TDynamicTime date() override; + int msgType() override; + int msgSubtypeWMO() override; + int msgSubtypeLocal() override; + int msgSubtype() override; + int origCentre() override; + int origSubCentre() override; + int masterTable() override; + int masterTableVersion() override; + int localTableVersion() override; }; -class Section1_Ed4 : public Section1Base { +class Section1_Ed4 : public Section1Base +{ public: - Section1_Ed4(const unsigned char* octs) : Section1Base(octs){}; - Section1_Ed4(const Section1Base* aSec1) : Section1Base(aSec1){}; - - bool hasSection2(); - TDynamicTime date(); - int msgType(); - int msgSubtypeWMO(); - int msgSubtypeLocal(); - int msgSubtype(); - int origCentre(); - int origSubCentre(); - int masterTable(); - int masterTableVersion(); - int localTableVersion(); + Section1_Ed4(const unsigned char* octs) : + Section1Base(octs){}; + Section1_Ed4(const Section1Base* aSec1) : + Section1Base(aSec1){}; + + bool hasSection2() override; + TDynamicTime date() override; + int msgType() override; + int msgSubtypeWMO() override; + int msgSubtypeLocal() override; + int msgSubtype() override; + int origCentre() override; + int origSubCentre() override; + int masterTable() override; + int masterTableVersion() override; + int localTableVersion() override; }; -typedef struct { +using TSection2 = struct +{ unsigned char len; // : 24; unsigned char len2; unsigned char len3; unsigned char reserved; // : 8; -} TSection2; +}; -typedef struct { +using TSection3 = struct +{ unsigned char len; // : 24; unsigned char len2; unsigned char len3; @@ -216,14 +228,15 @@ unsigned char subsetCnt; // 16; unsigned char subsetCnt2; unsigned char bitField; // 8; -} TSection3; +}; -typedef struct { +using TSection4 = struct +{ unsigned char len; // : 24; unsigned char len2; unsigned char len3; unsigned char reserved; // : 8; -} TSection4; +}; // DOXYGEN_SHOULD_SKIP_THIS #endif @@ -236,7 +249,8 @@ * subroutine 'bufren'. This class should be hidden from Metview applications * and the methods of this class should be called only from MvObs. */ -class MvBufrBase { +class MvBufrBase +{ friend class MvBufrOut; //??? // friend class MvObsSet; @@ -264,13 +278,13 @@ protected: MvBufrBase(const long len); //( char *msg, long len ); - virtual ~MvBufrBase(void); + virtual ~MvBufrBase(); - void attach(void); // { _refCount++; } - void detach(void); // { if( --_refCount == 0 ) delete this; } - void createFortranArrays(void); - void createDataArrays(void); - void deleteDataArrays(void); + void attach(); // { _refCount++; } + void detach(); // { if( --_refCount == 0 ) delete this; } + void createFortranArrays(); + void createDataArrays(); + void deleteDataArrays(); unsigned int unsignedInt(const unsigned char* firstOctet, int octetCount); int subsetCount() { return unsignedInt(&(fSec3->subsetCnt), 2); } int totalLen() { return unsignedInt(&(fSec0->totalLen), 3); } @@ -282,7 +296,8 @@ /*! This class and its methods are a lower level wrapper around Fortran * subroutine 'bufren'. These methods should be called only via MvObs class. */ -class MvBufr : public MvBufrBase { +class MvBufr : public MvBufrBase +{ friend class MvObs; friend class MvObsSet; friend class MvObsSetIterator; @@ -293,15 +308,15 @@ protected: MvBufr(char* msg, long len, long aMessageNumber = 0); - ~MvBufr(void); + ~MvBufr() override; // F void setEccodes(codes_handle** ecH); - void Decode(void); - void Decode_012(void); + void Decode(); + void Decode_012(); void ExpandDescriptors(int subsetNumber); int descriptorToFortranIndex(const long aDescr, const int firstIndex = 0); - long currentBufrRef(void) const { return _bufrIn_ref; }; + long currentBufrRef() const { return _bufrIn_ref; }; EElementValueType elementValueType(const int aSubsetNr); EElementValueType elementValueType(const long aDescriptor, const int aSubsetNr); @@ -318,23 +333,23 @@ std::string feedbackItemUnit(int row, int subset); TDynamicTime obsTime(const int subsetNr); //- from msg body (section 4) - TDynamicTime msgTime(void); //- from msg header (section 1) + TDynamicTime msgTime(); //- from msg header (section 1) std::string stringValue(const long aDescriptor, const int aSubsetNr); std::string stringValue(const int aSubsetNr); std::string stringValueByIndex(const int anIndex, const int aSubsetNr); std::string unit(const long aDescriptor); - std::string unit(void); + std::string unit(); std::string unitByIndex(const int anIndex); std::string name(const long aDescriptor); - std::string name(void); + std::string name(); std::string nameByIndex(const int anIndex); - bool SetFirstDescriptor(void); - bool SetNextDescriptor(void); - long CurrentDescriptor(void) { return _currentDescr; } + bool SetFirstDescriptor(); + bool SetNextDescriptor(); + long CurrentDescriptor() { return _currentDescr; } double CurrentValue(const int aSubsetNr) { return DataValue(_currentDescrInd, aSubsetNr); } bool printSection(std::ostream& aStream, int which); @@ -349,7 +364,7 @@ void setSubset(int subsetNumber) { _lastKnownSubsetValue = subsetNumber; } private: - void computeIn_KELEM(void); + void computeIn_KELEM(); codes_handle** _ecH; // F ec diff -Nru metview-5.17.4/metview/src/libMetview/MvBufrObs.h metview-5.19.2/metview/src/libMetview/MvBufrObs.h --- metview-5.17.4/metview/src/libMetview/MvBufrObs.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvBufrObs.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,9 +32,11 @@ #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -54,7 +56,8 @@ /*! Warning: This is Q&C ("quick&dirty") hack to access * QC FB data behind operator descriptor 222000. */ -class MvBufrConfidence { +class MvBufrConfidence +{ public: MvBufrConfidence(int aSubsetNr); ~MvBufrConfidence(); @@ -77,12 +80,14 @@ }; #endif // DOXYGEN_SHOULD_SKIP_THIS -const float kBufrMissingValue = 1.7e38; +const float kBufrMissingValue = 1.7e38; const int kBufrMissingIntValue = 2147483647; -class MvEccHandle { +class MvEccHandle +{ public: - MvEccHandle(codes_handle* ecH) : ecH_(ecH) {} + MvEccHandle(codes_handle* ecH) : + ecH_(ecH) {} codes_handle* handle() const { return ecH_; } void clear() { ecH_ = nullptr; } @@ -90,7 +95,7 @@ codes_handle* ecH_; }; -typedef std::shared_ptr MvEccHandle_ptr; +using MvEccHandle_ptr = std::shared_ptr; //--------------------------------------------------------------- MvObs @@ -122,14 +127,16 @@ class MvBufrEdition; -class MvBufrSubsetData { +class MvBufrSubsetData +{ friend class MvObs; public: - MvBufrSubsetData() {} - void clear() { + MvBufrSubsetData() = default; + void clear() + { initialised_ = false; - current_ = -1; + current_ = -1; longData_.clear(); doubleData_.clear(); stringData_.clear(); @@ -141,7 +148,8 @@ bool initialised() const { return initialised_; } void resetCurrent() { current_ = -1; } - bool next() { + bool next() + { current_++; return current_ + 1 <= static_cast(keys_.size()); } @@ -170,7 +178,8 @@ std::unordered_map keyIndex_; }; -class MvObs { +class MvObs +{ friend class MvObsSet; friend class MvObsSetIterator; void _copy(const MvObs& b); @@ -181,7 +190,7 @@ * Applications normally call this constructor without arguments. */ MvObs(MvEccHandle_ptr, int subset_current = 1, bool unpacked = false, bool cacheCompressedData = true); - MvObs() {} + MvObs() = default; //! Copy constructor MvObs(const MvObs&); @@ -461,22 +470,22 @@ //! Looks for an ident from the BUFR message /*! Looks for the following message identifiers: \n - * - WMO Station Identifier 'BBSSS' \n - * - Ship or mobile land station identifier (001011) \n - * - Buoy/platform identifier (001005) \n - * - Aircraft flight number (001006) \n - * - Satellite identifier (001007) \n - * - Aircraft registration number (001008) \n - * - Stationary buoy platform identifier (001010) \n - * - Storm identifier (001025) - * - WMO storm name (001026) - * - WMO long storm name (001027) - * - * and returns the first one found, as a string. If none - * of the above is found, returns "id???". - * - * It is used in MAGICS!!! - */ + * - WMO Station Identifier 'BBSSS' \n + * - Ship or mobile land station identifier (001011) \n + * - Buoy/platform identifier (001005) \n + * - Aircraft flight number (001006) \n + * - Satellite identifier (001007) \n + * - Aircraft registration number (001008) \n + * - Stationary buoy platform identifier (001010) \n + * - Storm identifier (001025) + * - WMO storm name (001026) + * - WMO long storm name (001027) + * + * and returns the first one found, as a string. If none + * of the above is found, returns "id???". + * + * It is used in MAGICS!!! + */ std::string findSomeIdent(); //-- APIs for accessing replicated parameters --// @@ -636,7 +645,8 @@ // It is implemeted in MvMiscellanous, but because of magics we cannot // use MvMisc ... here! template - inline std::string toString(const TYPE& in) { + inline std::string toString(const TYPE& in) + { std::ostringstream os; os << in; return os.str(); @@ -695,15 +705,16 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS //--------------------------------------------------------------- MvBufrParam -class MvBufrParam { +class MvBufrParam +{ public: MvBufrParam(const char* aParamName); MvBufrParam(const long anIntAsDescriptor) { fDescriptor = anIntAsDescriptor; } - long Descriptor(void) const { return fDescriptor; } - void PrintAllKnownParameters(void) const; + long Descriptor() const { return fDescriptor; } + void PrintAllKnownParameters() const; - operator int(void) const { return fDescriptor; } + operator int() const { return fDescriptor; } private: long fDescriptor; @@ -720,13 +731,14 @@ class MvObsSet; -class MvBufrOut { +class MvBufrOut +{ friend class MvObs; friend class MvObsSet; protected: MvBufrOut(MvObsSet*); - ~MvBufrOut(void); + ~MvBufrOut(); void add(MvObs& anObs); // void write( MvObs& anObs ); //FAMI20171023 maybe we do not need this function or maybe diff -Nru metview-5.17.4/metview/src/libMetview/MvCommandHistory.h metview-5.19.2/metview/src/libMetview/MvCommandHistory.h --- metview-5.17.4/metview/src/libMetview/MvCommandHistory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvCommandHistory.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ class MvCommandHistory { public: - MvCommandHistory() : - pos_(0) {} + MvCommandHistory() = default; void clear(); bool canRedo(); @@ -32,7 +31,7 @@ T defaultItem_; std::vector items_; - int pos_; + int pos_{0}; }; template @@ -87,9 +86,9 @@ } /*template -const T& MvCommandHistory::current() -{ - return (isPosCorrect())?items_[pos_]:defaultItem_; +const T& MvCommandHistory::current() +{ + return (isPosCorrect())?items_[pos_]:defaultItem_; }*/ template diff -Nru metview-5.17.4/metview/src/libMetview/MvDate.cc metview-5.19.2/metview/src/libMetview/MvDate.cc --- metview-5.17.4/metview/src/libMetview/MvDate.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvDate.cc 2023-07-15 08:28:47.000000000 +0000 @@ -126,7 +126,7 @@ const char* MvDate::MonthName(int n, boolean full) { - request* p = pref(); + request* p = pref(); const char* s = get_value(p, full ? "MONTH_LONG_NAMES" : "MONTH_SHORT_NAMES", n - 1); return s ? s : _month[n - 1][int(full)]; @@ -134,21 +134,21 @@ const char* MvDate::DayName(int n, boolean full) { - request* p = pref(); + request* p = pref(); const char* s = get_value(p, full ? "DAY_LONG_NAMES" : "DAY_SHORT_NAMES", n - 1); return s ? s : _day[n - 1][int(full)]; } const char* MvDate::StringFormat() { - request* p = pref(); + request* p = pref(); const char* s = no_quotes(get_value(p, "STRING_DATE_FORMAT", 0)); return s ? s : stringFormat; } const char* MvDate::NumberFormat() { - request* p = pref(); + request* p = pref(); const char* s = no_quotes(get_value(p, "NUMBER_DATE_FORMAT", 0)); return s ? s : numberFormat; } @@ -193,7 +193,7 @@ MvDate::MvDate(double n) { - julian = (long)n; + julian = (long)n; double s = n - (double)julian; if (s < 0.0) { //-- 'n' is a negative decimal value; decimal part thus @@ -247,7 +247,7 @@ return (res.size() == 8) ? true : false; } -//Convert hh:mm:ss format to hhmmss +// Convert hh:mm:ss format to hhmmss bool MvDate::timeToHHMMSS(const std::string& tt, std::string& res) { res.clear(); @@ -280,23 +280,23 @@ return false; } - res = hh + mm + ss; + res = hh + mm + ss; retVal = (res.size() == 6) ? true : false; } return retVal; } -//Convert hhmmss format to seconds +// Convert hhmmss format to seconds bool MvDate::HHMMSStoSec(const std::string& tt, int& sec) { if (tt.size() != 6) return false; sec = 0; - int ival; + int ival = 0; - //Hour + // Hour std::istringstream hh(tt.substr(0, 1)); hh >> ival; @@ -305,7 +305,7 @@ sec += ival * 3600; - //Minute + // Minute std::istringstream mm(tt.substr(2, 3)); mm >> ival; @@ -314,7 +314,7 @@ sec += ival * 60; - //Second + // Second std::istringstream ss(tt.substr(4, 5)); ss >> ival; @@ -326,13 +326,13 @@ return true; } -//Convert hhmmss format to seconds +// Convert hhmmss format to seconds bool MvDate::HHMMSStoSec(int tt, int& sec) { if (tt < 0 || tt > 235959) return false; - sec = 0; + sec = 0; int hh = 0, mm = 0, ss = 0; if (tt > 5959) { @@ -348,7 +348,7 @@ ss = tt; } - //std::cout << "hh=" << hh << " mm=" << mm << " ss=" << ss << std::endl; + // std::cout << "hh=" << hh << " mm=" << mm << " ss=" << ss << std::endl; if (hh < 0 || hh > 23) return false; @@ -367,7 +367,7 @@ return true; } -//Convert hhh:mm:ss format to seconds +// Convert hhh:mm:ss format to seconds bool MvDate::timeToLenInSec(const std::string& tt, std::string& res) { res.clear(); @@ -400,7 +400,7 @@ } if (retVal) { - int sec, i; + int sec = 0, i = 0; std::istringstream ish(hh); ish >> i; sec = i * 3600; @@ -413,14 +413,14 @@ std::stringstream sst; sst << sec; - res = sst.str(); + res = sst.str(); retVal = true; } return retVal; } -//Convert hhh:mm:ss format to hhhmmss format +// Convert hhh:mm:ss format to hhhmmss format bool MvDate::timeToLenAsHHHMMSS(const std::string& tt, std::string& res) { res.clear(); @@ -459,7 +459,7 @@ } if (retVal) { - res = hh + mm + ss; + res = hh + mm + ss; retVal = (res.size() == 7); } @@ -537,7 +537,7 @@ static int collect(const char*& f, char* buf, int& i, char& c) { - int n; + int n = 0; c = 0; while (*f) switch (*f) { @@ -587,7 +587,7 @@ void MvDate::Format(const char* f, char* buf) const { - int i = 0; + int i = 0; char c = 0; for (;;) { @@ -748,7 +748,7 @@ double MvDate::dayOfTheYear() const { - auto y = Year(); + auto y = Year(); auto first = MvDate(y * 1E4 + 101); return first.time_interval_days(*this); } @@ -768,13 +768,13 @@ MvDate MvDate::magicsAdd(long n) const { int yyyy = Year(); - int mm = Month() + n / 10000; - int dd = Day() + (n / 100) % 100; - int MM = Minute(); - int SS = Second(); - int HH = Hour() + n % 100; + int mm = Month() + n / 10000; + int dd = Day() + (n / 100) % 100; + int MM = Minute(); + int SS = Second(); + int HH = Hour() + n % 100; - return MvDate(yyyy * 10000 + mm * 100 + dd + (HH * 3600 + MM * 60 + SS) / 86400.0); + return {yyyy * 10000 + mm * 100 + dd + (HH * 3600 + MM * 60 + SS) / 86400.0}; } //-- It seems that the old code of 'magicsSub' has some bugs; @@ -787,13 +787,13 @@ { MvDate d1 = *this; MvDate d2 = d; - double x = d1 - d2; + double x = d1 - d2; if (x < 0) { - x = -x; + x = -x; MvDate d = d1; - d1 = d2; - d2 = d; + d1 = d2; + d2 = d; } int dd = int(x); @@ -834,7 +834,7 @@ { static char buf[32]; Format("yyyy-mm-dd HH:MM", buf); - return std::string(buf); + return {buf}; } std::string @@ -842,7 +842,7 @@ { static char buf[32]; Format("yyyy-mm-ddTHH:MM:00Z", buf); - return std::string(buf); + return {buf}; } diff -Nru metview-5.17.4/metview/src/libMetview/MvDate.h metview-5.19.2/metview/src/libMetview/MvDate.h --- metview-5.17.4/metview/src/libMetview/MvDate.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvDate.h 2023-07-15 08:28:47.000000000 +0000 @@ -39,8 +39,8 @@ { //! Friend function to write MvDate objects /*! The format is taken from user's Metview Preferences. - * The default in Metview is ISO 8601 standard date and time format. - */ + * The default in Metview is ISO 8601 standard date and time format. + */ friend std::ostream& operator<<(std::ostream& aStream, const MvDate& dd); static const char* stringFormat; @@ -58,14 +58,14 @@ public: //! Constructor; by default sets today's date at 00UTC /*! Negative values can be used to indicate a relative date. - * By default relative days are relative to today, unless - * environment variable \c MARS_REFERENCE_DATE has been set.\n \n - * The desimal part is interpreted as a fraction of a day (of 24 hours), - * thus 0.25 indicates 06 utc and 0.875 indicates 21 utc.\n \n - * NOTE that there is no validity test for the syntax and - * some clearly invalid values are converted to valid dates, - * for example \c 20081535 becomes 2009-04-06! - */ + * By default relative days are relative to today, unless + * environment variable \c MARS_REFERENCE_DATE has been set.\n \n + * The desimal part is interpreted as a fraction of a day (of 24 hours), + * thus 0.25 indicates 06 utc and 0.875 indicates 21 utc.\n \n + * NOTE that there is no validity test for the syntax and + * some clearly invalid values are converted to valid dates, + * for example \c 20081535 becomes 2009-04-06! + */ MvDate(double n = 0); //! Copy constructor @@ -77,13 +77,13 @@ //! Constructor from a string /*! If \c dd has a valid date syntax, the constructor - * parses \c dd into the internal presentation. - * Otherwise first converts \c dd into an integer which - * is then interpreted as a date.\n \n - * NOTE that there is no validity test for the syntax and - * some clearly invalid values are converted to valid dates, - * for example "2008-15-35" becomes 2009-04-06! - */ + * parses \c dd into the internal presentation. + * Otherwise first converts \c dd into an integer which + * is then interpreted as a date.\n \n + * NOTE that there is no validity test for the syntax and + * some clearly invalid values are converted to valid dates, + * for example "2008-15-35" becomes 2009-04-06! + */ MvDate(const char* dd); //! Assignment operator @@ -102,32 +102,32 @@ //! Decreases the date/time /*! The integer part of \c ddtt represents days and the decimal part - * is for hours and minutes (as a fraction of 24 hours). Thus the value - * of \c 1.75 as an operand would "subtract" one day and 18 hours - * from the operand MvDate object.\n \n - * Example:\n - *
-	 *     MvDate d;            //-- today at 00 utc
-	 *     MvDate x = d - 1.75; //-- day before yesterday at 06 utc
-	 *  
- */ + * is for hours and minutes (as a fraction of 24 hours). Thus the value + * of \c 1.75 as an operand would "subtract" one day and 18 hours + * from the operand MvDate object.\n \n + * Example:\n + *
+     *     MvDate d;            //-- today at 00 utc
+     *     MvDate x = d - 1.75; //-- day before yesterday at 06 utc
+     *  
+ */ MvDate operator-(double ddtt) const; //! Increases the date/time /*! The integer part of \c ddtt represents days and the decimal part - * is for hours and minutes (as a fraction of a day). Thus the value - * of \c 1.25 as an argument would "add" one day and 6 hours - * to the operand MvDate object. - */ + * is for hours and minutes (as a fraction of a day). Thus the value + * of \c 1.25 as an argument would "add" one day and 6 hours + * to the operand MvDate object. + */ MvDate operator+(double ddtt) const; //! Increases the current date/time /*! Example:\n - *
-	 *     MvDate d(0);   //-- today at 00 utc
-	 *     d += 1.125;    //-- tomorrow at 03 utc
-	 *  
- */ + *
+     *     MvDate d(0);   //-- today at 00 utc
+     *     d += 1.125;    //-- tomorrow at 03 utc
+     *  
+ */ MvDate& operator+=(double ddtt); //! Decreases the current date/time @@ -135,8 +135,8 @@ //! Returns the time difference between two MvDate objects /*! The integer part of the returned value represents days - * and the decimal part represents the fraction of a day - */ + * and the decimal part represents the fraction of a day + */ double operator-(const MvDate&) const; //! 'Greater-than' comparison operator @@ -159,13 +159,13 @@ //! "C" style print method for standard output /*! Use "C++" style friend operator<<() for chaining several output - * objects or for writing to any stream - */ + * objects or for writing to any stream + */ void Print() const; //! Returns the date part as an integer YYMMDD /*! WARNING: two digit year! - */ + */ int YyMmDd(void) const { return mars_julian_to_date(julian, false); } //! Returns the date part as an integer YYYYMMDD @@ -173,7 +173,7 @@ //! Returns the date part as an integer YYYYddd /*! Digits \c ddd represent the running day (Julian) of the year - */ + */ int yyyyddd(void) const; //! Returns the year part of the date @@ -205,47 +205,47 @@ //! Creates a custom formatted date/time text string /*! Argument \c fmt defines the format and \c buf is the target character array. - * Recognised format letter combinations are: - *
-	 *     yy   - year with 2 digits
-	 *     yyyy - year with 4 digits
-	 *     m    - month with minimum digits
-	 *     mm   - month with 2 digits
-	 *     mmm  - short month name (user customisable)
-	 *     mmmm - full month name (user customisable)
-	 *     d    - day of the month with minimum digits
-	 *     dd   - day of the month with 2 digits
-	 *     ddd  - short weekday name (user customisable)
-	 *     dddd - full weekday name (user customisable)
-	 *     D    - Julian day with minimum digits
-	 *     DDD  - Julian day with 3 digits
-	 *     H    - hour with minimum digits (24 hour clock)
-	 *     HH   - hour with 2 digits (24 hour clock)
-	 *     M    - minutes with minimum digits
-	 *     MM   - minutes with 2 digits
-	 *     S    - seconds with minimum digits
-	 *     SS   - seconds with 2 digits
-	 *  
All other characters are used as is. Users can customise - * month and weekday names through Metview User Interface.\n - * Here are some (non-customised) examples: - *
-	 *    MvDate d(20080105.375);
-	 *    std::cout << d << std::endl;   //-- 2008-01-05 09:00:00
-	 *
-	 *    char buf[100];
-	 *    d.Format("d mmm yyyy at H:M", buf);
-	 *    std::cout << buf << std::endl; //-- 5 Jan 2008 at 9:0
-	 *
-	 *    d.Format("d/m/yy - yymmdd:HH", buf);
-	 *    std::cout << buf << std::endl; //-- 5/1/08 - 080105:09
-	 *
-	 *    d.Format("dd/mm/yyyy @ HH:MM", buf);
-	 *    std::cout << buf << std::endl; //-- 05/01/2008 @ 09:00
-	 *
-	 *    d.Format("dddd d mmmm yyyy", buf);
-	 *    std::cout << buf << std::endl; //-- Saturday 5 January 2008
-	 *  
- */ + * Recognised format letter combinations are: + *
+     *     yy   - year with 2 digits
+     *     yyyy - year with 4 digits
+     *     m    - month with minimum digits
+     *     mm   - month with 2 digits
+     *     mmm  - short month name (user customisable)
+     *     mmmm - full month name (user customisable)
+     *     d    - day of the month with minimum digits
+     *     dd   - day of the month with 2 digits
+     *     ddd  - short weekday name (user customisable)
+     *     dddd - full weekday name (user customisable)
+     *     D    - Julian day with minimum digits
+     *     DDD  - Julian day with 3 digits
+     *     H    - hour with minimum digits (24 hour clock)
+     *     HH   - hour with 2 digits (24 hour clock)
+     *     M    - minutes with minimum digits
+     *     MM   - minutes with 2 digits
+     *     S    - seconds with minimum digits
+     *     SS   - seconds with 2 digits
+     *  
All other characters are used as is. Users can customise + * month and weekday names through Metview User Interface.\n + * Here are some (non-customised) examples: + *
+     *    MvDate d(20080105.375);
+     *    std::cout << d << std::endl;   //-- 2008-01-05 09:00:00
+     *
+     *    char buf[100];
+     *    d.Format("d mmm yyyy at H:M", buf);
+     *    std::cout << buf << std::endl; //-- 5 Jan 2008 at 9:0
+     *
+     *    d.Format("d/m/yy - yymmdd:HH", buf);
+     *    std::cout << buf << std::endl; //-- 5/1/08 - 080105:09
+     *
+     *    d.Format("dd/mm/yyyy @ HH:MM", buf);
+     *    std::cout << buf << std::endl; //-- 05/01/2008 @ 09:00
+     *
+     *    d.Format("dddd d mmmm yyyy", buf);
+     *    std::cout << buf << std::endl; //-- Saturday 5 January 2008
+     *  
+ */ void Format(const char* fmt, char* buf) const; //! Returns the number of days of the month in the current object @@ -257,79 +257,79 @@ //! Subtracts date \c dd from the current object /*! The returned value is an integer of the form \c mmddHH - * where \c mm is for months, \c dd for days, and \c HH for hours. - * Thus returned value \c 1506 indicates a difference of \c 0 - * months, \c 15 days and \c 6 hours. - */ + * where \c mm is for months, \c dd for days, and \c HH for hours. + * Thus returned value \c 1506 indicates a difference of \c 0 + * months, \c 15 days and \c 6 hours. + */ long magicsSub(const MvDate& dd) const; //! Advances the current object date/time /*! The argument \c mmddHH is an integer, as described - * for the return value from method magicsSub() - */ + * for the return value from method magicsSub() + */ MvDate magicsAdd(long mmddHH) const; //! Returns the date formatted as "yyyy-mm-dd HH:MM", suitable for Magics 6 /*! See Format() - */ + */ std::string magicsDate() const; //! Returns the date formatted as ISO8641 "YYYY-MM-DDTHH:00:00Z" /*! See Format() - */ + */ std::string ISO8601() const; //! Returns the date formatted as "yyyymmdd.f" /*! Where \c .f is a fraction of a day (of 24 hours) - */ + */ double YyyyMmDd_r() const; //! Returns the time difference between \c dd and the current object, in days /*! The decimal part will represent a fraction of a day (of 24 hours), - * i.e. 3.25 would represent 3 days and 6 hours - */ + * i.e. 3.25 would represent 3 days and 6 hours + */ double time_interval_days(const MvDate& dd) const; //! Returns the time difference between \c dd and the current object, in hours /*! The decimal part will represent a fraction of an hour (of 60 minutes) - * i.e. 3.25 would represent 3 hours and 15 minutes - */ + * i.e. 3.25 would represent 3 hours and 15 minutes + */ double time_interval_hours(const MvDate& dd) const; //! Returns the time difference between \c dd and the current object, in minutes /*! The decimal part will represent a fraction of a minute (of 60 seconds) - * i.e. 3.2 would represent 3 minutes and 12 seconds - */ + * i.e. 3.2 would represent 3 minutes and 12 seconds + */ double time_interval_mins(const MvDate& dd) const; //! Returns the default format string for text output /*! The default format string is taken from user's Preferences - * and thus different users can have different defaults. - */ + * and thus different users can have different defaults. + */ static const char* StringFormat(); //! Returns the default format string for numeric output /*! The default format string is taken from user's Preferences - * and thus different users can have different defaults. - */ + * and thus different users can have different defaults. + */ static const char* NumberFormat(); //! Returns the name of the month \c mm (\c mm = 1...12) /*! If \c full is \c true, then the full name is returned, - * otherwise the short name is returned. - * The name is taken from user's Preferences + * otherwise the short name is returned. + * The name is taken from user's Preferences * and thus different users can have diff:time_interval_dayserent defaults. - */ + */ static const char* MonthName(int mm, boolean full); //! Returns the name of the day \c dd (\c dd = 1...7) /*! If \c full is \c true, then the full name is returned, - * otherwise the short name is returned. - * The name is taken from user's Preferences - * and thus different users can have different defaults. - */ + * otherwise the short name is returned. + * The name is taken from user's Preferences + * and thus different users can have different defaults. + */ static const char* DayName(int dd, boolean full); diff -Nru metview-5.17.4/metview/src/libMetview/MvDebugPrintControl.cc metview-5.19.2/metview/src/libMetview/MvDebugPrintControl.cc --- metview-5.17.4/metview/src/libMetview/MvDebugPrintControl.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvDebugPrintControl.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ // -#include +#include #include "MvDebugPrintControl.h" #include "mars.h" @@ -49,8 +49,8 @@ const char* myEnv = getenv("MV_QLOG"); //-- "quiet log" - only errors! if (myEnv && strcmp(myEnv, "yes") == 0) { - mars.debug = false; - mars.info = false; + mars.debug = false; + mars.info = false; mars.warning = false; } } diff -Nru metview-5.17.4/metview/src/libMetview/MvEccBufr.cc metview-5.19.2/metview/src/libMetview/MvEccBufr.cc --- metview-5.17.4/metview/src/libMetview/MvEccBufr.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvEccBufr.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,9 @@ #include "fstream_mars_fix.h" -#include -#include -#include +#include +#include +#include std::vector MvEccBufrMessage::definitionsDir_; @@ -62,28 +62,28 @@ { if (!bh || bh->message_size == 0) { headerValid_ = false; - dataValid_ = false; + dataValid_ = false; return; } - offset_ = bh->message_offset; + offset_ = bh->message_offset; totalLenght_ = bh->message_size; - dataCategory_ = bh->dataCategory; + dataCategory_ = bh->dataCategory; dataSubCategory_ = bh->dataSubCategory; - //Edition - long masterNumber, masterVersion, localVersion, centre, subCentre; + // Edition + long masterNumber = 0, masterVersion = 0, localVersion = 0, centre = 0, subCentre = 0; masterVersion = bh->masterTablesVersionNumber; - masterNumber = bh->masterTableNumber; - localVersion = bh->localTablesVersionNumber; - centre = bh->bufrHeaderCentre; - subCentre = bh->bufrHeaderSubCentre; + masterNumber = bh->masterTableNumber; + localVersion = bh->localTablesVersionNumber; + centre = bh->bufrHeaderCentre; + subCentre = bh->bufrHeaderSubCentre; edition_ = MvBufrEdition::find(masterNumber, masterVersion, localVersion, centre, subCentre); assert(edition_); if (edition_->centreAsStr().empty()) { - size_t vlen = 0; + size_t vlen = 0; char charVal[512] = { 0, }; @@ -94,7 +94,7 @@ } } - //Subsets + // Subsets subsetNum_ = bh->numberOfSubsets; if (bh->compressedData == 1) compressed_ = true; @@ -123,45 +123,45 @@ if (!h) return; - long longVal; + long longVal = 0; size_t vlen = 0; - MV_CODES_CHECK_HEADER(codes_get_long(h, "offset", &offset_), 0); - MV_CODES_CHECK_HEADER(codes_get_long(h, "editionNumber", &longVal), 0); + MV_CODES_CHECK_HEADER(codes_get_long(h, "offset", &offset_), nullptr); + MV_CODES_CHECK_HEADER(codes_get_long(h, "editionNumber", &longVal), nullptr); bufrEditionNumber_ = longVal; - MV_CODES_CHECK_HEADER(codes_get_long(h, "dataCategory", &dataCategory_), 0); - MV_CODES_CHECK_HEADER(codes_get_long(h, "dataSubCategory", &dataSubCategory_), 0); + MV_CODES_CHECK_HEADER(codes_get_long(h, "dataCategory", &dataCategory_), nullptr); + MV_CODES_CHECK_HEADER(codes_get_long(h, "dataSubCategory", &dataSubCategory_), nullptr); - //Edition - long masterNumber, masterVersion, localVersion, centre, subCentre; - MV_CODES_CHECK_HEADER(codes_get_long(h, "masterTableNumber", &masterNumber), 0); - MV_CODES_CHECK_HEADER(codes_get_long(h, "masterTablesVersionNumber", &masterVersion), 0); - MV_CODES_CHECK_HEADER(codes_get_long(h, "localTablesVersionNumber", &localVersion), 0); - MV_CODES_CHECK_HEADER(codes_get_long(h, "bufrHeaderCentre", ¢re), 0); - MV_CODES_CHECK_HEADER(codes_get_long(h, "bufrHeaderSubCentre", &subCentre), 0); + // Edition + long masterNumber = 0, masterVersion = 0, localVersion = 0, centre = 0, subCentre = 0; + MV_CODES_CHECK_HEADER(codes_get_long(h, "masterTableNumber", &masterNumber), nullptr); + MV_CODES_CHECK_HEADER(codes_get_long(h, "masterTablesVersionNumber", &masterVersion), nullptr); + MV_CODES_CHECK_HEADER(codes_get_long(h, "localTablesVersionNumber", &localVersion), nullptr); + MV_CODES_CHECK_HEADER(codes_get_long(h, "bufrHeaderCentre", ¢re), nullptr); + MV_CODES_CHECK_HEADER(codes_get_long(h, "bufrHeaderSubCentre", &subCentre), nullptr); edition_ = MvBufrEdition::find(masterNumber, masterVersion, localVersion, centre, subCentre); assert(edition_); if (edition_->centreAsStr().empty()) { const int MAX_CHAR_LEN = 1024; char charVal[MAX_CHAR_LEN]; vlen = MAX_CHAR_LEN; - MV_CODES_CHECK_HEADER(codes_get_string(h, "bufrHeaderCentre", charVal, &vlen), 0); + MV_CODES_CHECK_HEADER(codes_get_string(h, "bufrHeaderCentre", charVal, &vlen), nullptr); if (vlen > 0) edition_->setCentreAsStr(std::string(charVal)); } - //Subsets - MV_CODES_CHECK_HEADER(codes_get_long(h, "numberOfSubsets", &subsetNum_), 0); - MV_CODES_CHECK_HEADER(codes_get_long(h, "compressedData", &longVal), 0); + // Subsets + MV_CODES_CHECK_HEADER(codes_get_long(h, "numberOfSubsets", &subsetNum_), nullptr); + MV_CODES_CHECK_HEADER(codes_get_long(h, "compressedData", &longVal), nullptr); if (longVal == 1) compressed_ = true; - //Unexpanded descriptors - MV_CODES_CHECK_HEADER(codes_get_size(h, "unexpandedDescriptors", &vlen), 0); + // Unexpanded descriptors + MV_CODES_CHECK_HEADER(codes_get_size(h, "unexpandedDescriptors", &vlen), nullptr); if (vlen > 0) { long* descriptors = (long*)malloc(vlen * sizeof(long)); - MV_CODES_CHECK_HEADER(codes_get_long_array(h, "unexpandedDescriptors", descriptors, &vlen), 0); + MV_CODES_CHECK_HEADER(codes_get_long_array(h, "unexpandedDescriptors", descriptors, &vlen), nullptr); for (size_t i = 0; i < vlen; i++) { unexpanded_.push_back(descriptors[i]); } @@ -220,9 +220,9 @@ return; size_t vlen = 0; - int err = 0; + int err = 0; - FILE* fp; + FILE* fp = nullptr; fp = fopen(fileInfo_->fileName().c_str(), "rb"); if (!fp) { return; @@ -234,10 +234,10 @@ } if (codes_handle* ch = codes_handle_new_from_file(nullptr, fp, PRODUCT_BUFR, &err)) { - MV_CODES_CHECK_HEADER(codes_get_size(ch, "unexpandedDescriptors", &vlen), 0); + MV_CODES_CHECK_HEADER(codes_get_size(ch, "unexpandedDescriptors", &vlen), nullptr); if (vlen > 0) { long* descriptors = (long*)malloc(vlen * sizeof(long)); - MV_CODES_CHECK_HEADER(codes_get_long_array(ch, "unexpandedDescriptors", descriptors, &vlen), 0); + MV_CODES_CHECK_HEADER(codes_get_long_array(ch, "unexpandedDescriptors", descriptors, &vlen), nullptr); for (size_t i = 0; i < vlen; i++) { unexpanded_.push_back(descriptors[i]); } @@ -249,8 +249,8 @@ fclose(fp); } -//We do not want to store the dir path in the class to reduce memory usage. Instead we construct these -//strings on demand! +// We do not want to store the dir path in the class to reduce memory usage. Instead we construct these +// strings on demand! void MvEccBufrMessage::tablesDirs(std::vector& tablesMasterDir, std::vector& tablesLocalDir) { if (!fileInfo_) @@ -259,12 +259,12 @@ const int MAX_CHAR_LEN = 1024; char charVal[MAX_CHAR_LEN]; size_t vlen = 0; - int err = 0; + int err = 0; - FILE* fp; + FILE* fp = nullptr; fp = fopen(fileInfo_->fileName().c_str(), "rb"); if (!fp) { - //log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); + // log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); return; } @@ -275,14 +275,14 @@ std::string masterDirPattern, localDirPattern; if (codes_handle* ch = codes_handle_new_from_file(nullptr, fp, PRODUCT_BUFR, &err)) { - //tables + // tables vlen = MAX_CHAR_LEN; - if (MV_CODES_CHECK(codes_get_string(ch, "tablesMasterDir", charVal, &vlen), 0)) { + if (MV_CODES_CHECK(codes_get_string(ch, "tablesMasterDir", charVal, &vlen), nullptr)) { masterDirPattern = std::string(charVal); } vlen = MAX_CHAR_LEN; - if (MV_CODES_CHECK(codes_get_string(ch, "tablesLocalDir", charVal, &vlen), 0)) { + if (MV_CODES_CHECK(codes_get_string(ch, "tablesLocalDir", charVal, &vlen), nullptr)) { localDirPattern = std::string(charVal); } @@ -301,7 +301,7 @@ } } - for (auto defDir : definitionsDir_) { + for (const auto& defDir : definitionsDir_) { tablesMasterDir.push_back(defDir + "/" + masterDirPattern); tablesLocalDir.push_back(defDir + "/" + localDirPattern); } @@ -355,22 +355,21 @@ MvEccBufr::MvEccBufr(const std::string& path) : fileName_(path), - messageNum_(0) + messageNum_(computeMessageNum()) { - messageNum_ = computeMessageNum(); } int MvEccBufr::computeMessageNum() { - FILE* fp; + FILE* fp = nullptr; fp = fopen(fileName_.c_str(), "rb"); if (!fp) { - //log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); + // log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); return 0; } int res = 0; - if (codes_count_in_file(0, fp, &res) != CODES_SUCCESS) + if (codes_count_in_file(nullptr, fp, &res) != CODES_SUCCESS) res = 0; fclose(fp); @@ -415,7 +414,7 @@ MvEccBufr::ElementDefType MvEccBufr::elementDefType(int elem) { if (elem > 0 && elem < 64255) { - int cat = elem / 1000; + int cat = elem / 1000; int code = elem % 1000; if (cat >= 0 && cat <= 63 && code >= 1 && code <= 255) { if (cat < 48 && code < 192) @@ -476,7 +475,7 @@ MvBufrCodeTable* MvBufrCodeTable::make(int element, MvEccBufrMessage* msg) { - //Try + // Try std::vector path; std::vector masterDir, localDir; msg->tablesDirs(masterDir, localDir); @@ -489,12 +488,12 @@ path = localDir; break; default: - return 0; + return nullptr; break; } - for (auto p : path) { - //Check if the file exists and can be open for reading + for (const auto& p : path) { + // Check if the file exists and can be open for reading std::string fname = buildFileName(element, p); std::ifstream in(fname.c_str(), std::ios::in); if (in.is_open()) { @@ -520,7 +519,7 @@ std::string line; while (getline(in, line)) { - int code; + int code = 0; std::stringstream sst(line); sst >> code >> code; std::string val; @@ -564,7 +563,7 @@ tables_.push_back(this); } -void MvBufrFlagTable::values(int code, int width, MvBufrFlagInfo& v) const //std::vector& vals) const +void MvBufrFlagTable::values(int code, int width, MvBufrFlagInfo& v) const // std::vector& vals) const { std::vector bits; getBits(code, width, bits); @@ -583,7 +582,7 @@ if (it != items_.end()) { desc = it->second; } - v.flags_.push_back(std::make_pair(std::to_string(i + 1), desc)); + v.flags_.emplace_back(std::to_string(i + 1), desc); } } } @@ -617,7 +616,7 @@ MvBufrFlagTable* MvBufrFlagTable::make(int element, MvEccBufrMessage* msg) { - //Try + // Try std::vector path; std::vector masterDir, localDir; msg->tablesDirs(masterDir, localDir); @@ -630,12 +629,12 @@ path = localDir; break; default: - return 0; + return nullptr; break; } - for (auto p : path) { - //Check if the file exists and can be open for read! + for (const auto& p : path) { + // Check if the file exists and can be open for read! std::string fname = buildFileName(element, p); std::ifstream in(fname.c_str(), std::ios::in); if (in.is_open()) { @@ -660,7 +659,7 @@ std::string line; while (getline(in, line)) { - int code; + int code = 0; std::stringstream sst(line); sst >> code >> code; std::string val; diff -Nru metview-5.17.4/metview/src/libMetview/MvEccBufr.h metview-5.19.2/metview/src/libMetview/MvEccBufr.h --- metview-5.17.4/metview/src/libMetview/MvEccBufr.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvEccBufr.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,8 @@ #include "MvVariant.h" -namespace metview { +namespace metview +{ class MvBufrEdition; } @@ -53,7 +54,7 @@ friend class MvBufrFlagTable; public: - MvBufrFlagInfo() {} + MvBufrFlagInfo() = default; int num() const { return flags_.size(); } const std::string& bits() const { return bits_; } @@ -133,7 +134,7 @@ void checkPar(int, const std::string& name); bool codesCheck(const char* call, const char* file, int line, int e, const char* msg); - int index_; //message index within the file. Starts at 0! + int index_; // message index within the file. Starts at 0! bool headerValid_; bool dataValid_; int bufrEditionNumber_; diff -Nru metview-5.17.4/metview/src/libMetview/MvElement.cc metview-5.19.2/metview/src/libMetview/MvElement.cc --- metview-5.17.4/metview/src/libMetview/MvElement.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvElement.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ { setElemName(dl._elem_name); _elem_code = dl._elem_code; - _count = 0; + _count = 0; } // Operator = diff -Nru metview-5.17.4/metview/src/libMetview/MvElement.hpp metview-5.19.2/metview/src/libMetview/MvElement.hpp --- metview-5.17.4/metview/src/libMetview/MvElement.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvElement.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ _elem_name() { _elem_code = -1; - _count = 0; + _count = 0; } MvElement(MvElement& dl); diff -Nru metview-5.17.4/metview/src/libMetview/MvFieldSet.cc metview-5.19.2/metview/src/libMetview/MvFieldSet.cc --- metview-5.17.4/metview/src/libMetview/MvFieldSet.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFieldSet.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,22 +16,22 @@ #include "fstream_mars_fix.h" -#include -#include -#include +#include +#include +#include #include "Metview.h" #include "MvGrid.h" #include "MvException.h" #include "MvVariant.h" - +#include "StatsCompute.h" const bool cReleaseMemoryTrue = true; const bool cReleaseMemoryFlag = cReleaseMemoryTrue; const bool cExpandGridFalse = false; -const double cGridEpsilon = 5e-5; //-- 0.05 millidegrees +const double cGridEpsilon = 5e-5; //-- 0.05 millidegrees const double cFullGlobeLimit = 359.9; const double cCDR = atan(1.0) / 45.0; //-- conversion factor Degrees->Radians @@ -226,7 +226,7 @@ Fs = new_fieldset(0); // Make sure we have something Writable = false; - Fields = new MvField*[Fs->count]; + Fields = new MvField*[Fs->count]; for (int i = 0; i < Fs->count; i++) { Fields[i] = new MvField; @@ -275,10 +275,10 @@ return Fs->count; } -//MvRequest MvFieldSet::getRequest( bool clone ) //original had an unused argument +// MvRequest MvFieldSet::getRequest( bool clone ) //original had an unused argument MvRequest MvFieldSet::getRequest() { - return MvRequest(fieldset_to_request(Fs), false); //-- clone ); + return {fieldset_to_request(Fs), false}; //-- clone ); } MvField& MvFieldSet::operator[](int n) @@ -318,7 +318,7 @@ add_field(Fs, copy_field(f.libmars_field(), true)); //-- add new field also to 'Fields' - int cnt = Fs->count; + int cnt = Fs->count; auto** tmp = new MvField*[cnt]; for (int i = 0; i < cnt - 1; i++) //-- copy existing pointers @@ -338,9 +338,9 @@ MvFieldSetIterator::MvFieldSetIterator(MvFieldSet& fs) { FieldSet = &fs; - Count = fs.countFields(); - Current = 0; - Order = new int[Count]; + Count = fs.countFields(); + Current = 0; + Order = new int[Count]; for (int i = 0; i < Count; i++) Order[i] = i; @@ -356,7 +356,7 @@ if (Filter) { do { - MvField* f = &((*FieldSet)[Order[Current++]]); + MvField* f = &((*FieldSet)[Order[Current++]]); MvRequest r = f->getRequest(); if (Filter(r)) @@ -367,7 +367,7 @@ return EmptyField; // if there is no match } - std::cout << "Iter: " << Order[Current] << std::endl; + // std::cout << "Iter: " << Order[Current] << std::endl; return (*FieldSet)[Order[Current++]]; } @@ -380,9 +380,7 @@ std::string key(keyCh); // the most typical keys - static std::map keys {{"EXPVER", "str"}, {"PARAM","str"}, - {"LEVELIST", "long"}, {"STEP", "long"}, {"TIME", "long"}, - {"DATE", "date"}, {"NUMBER", "long"}, {"_DIAGITER", "str"}}; + static std::map keys{{"EXPVER", "str"}, {"PARAM", "str"}, {"LEVELIST", "long"}, {"STEP", "long"}, {"TIME", "long"}, {"DATE", "date"}, {"NUMBER", "long"}, {"_DIAGITER", "str"}}; // determine type. By default string value is used std::string t = "str"; @@ -396,42 +394,47 @@ long save = expand_flags(0); // So MvDate work.. std::vector md(Count); std::vector orderVec; - for(int i=0; i < Count; i++) { + for (int i = 0; i < Count; i++) { int idx = Order[i]; orderVec.push_back(idx); - MvField& f = (*FieldSet)[idx]; - MvRequest& r = f.getRequest(); - if (const char *v = get_value(r, keyCh, 0)) { + MvField& f = (*FieldSet)[idx]; + MvRequest& r = f.getRequest(); + if (const char* v = get_value(r, keyCh, 0)) { if (t == "str") { md[idx] = MvVariant(std::string(v)); - } else if (t == "long") { + } + else if (t == "long") { md[idx] = MvVariant(atol(v)); - } else if (t == "date") { + } + else if (t == "date") { // date can be a climate date e.g. JAN-16. We convert it into a number for sorting int cld = MvDate::climDateNumber(v); if (cld != 0) { md[idx] = MvVariant(cld); - // dates are treated as string otherwise - } else { + // dates are treated as string otherwise + } + else { md[idx] = MvVariant(std::string(v)); } } - } else { + } + else { if (t == "str" || t == "date") { md[idx] = MvVariant(""); - } else if (t == "int") { + } + else if (t == "int") { md[idx] = MvVariant(std::numeric_limits::min()); } } } - assert (md.size() == orderVec.size()); - assert (orderVec.size() == static_cast(Count)); + assert(md.size() == orderVec.size()); + assert(orderVec.size() == static_cast(Count)); std::stable_sort(orderVec.begin(), orderVec.end(), - [&md, ascending](size_t i1, size_t i2) { return (ascending)?(md[i1] < md[i2]):(md[i1] > md[i2]);}); + [&md, ascending](size_t i1, size_t i2) { return (ascending) ? (md[i1] < md[i2]) : (md[i1] > md[i2]); }); - for (std::size_t i=0; i < orderVec.size(); i++) { + for (std::size_t i = 0; i < orderVec.size(); i++) { Order[i] = orderVec[i]; } #if 0 @@ -478,7 +481,7 @@ OldState(state_to_revert_to) { readonly = readonlyflag; - Field = &(MvField&)f; + Field = &(MvField&)f; if (f.libmars_field()) { if (state_to_revert_to == unknown) // by default, we will revert to the previous state @@ -492,9 +495,9 @@ MvFieldState::~MvFieldState() { - // Restore field state + // Restore field state if (Field->mvgrid_ && Field->mvgrid_->fieldPtr()) { - auto *g = Field->mvgrid_->fieldPtr(); + auto* g = Field->mvgrid_->fieldPtr(); assert(g); if (readonly) { @@ -504,14 +507,15 @@ // most efficient way. Ideally set_field_state() should offer an option for // it so could avoid using this low level code here! if (OldState == packed_mem) { - release_mem(g->values); - g->values = NULL; - g->value_count = 0; - g->shape = packed_mem; - } - } else { - set_field_state(g, OldState); - } + release_mem(g->values); + g->values = nullptr; + g->value_count = 0; + g->shape = packed_mem; + } + } + else { + set_field_state(g, OldState); + } } } @@ -519,8 +523,8 @@ MvField::MvField() { - //Grib = 0; - //Grd = 0; + // Grib = 0; + // Grd = 0; mvgrid_ = 0; } @@ -531,15 +535,15 @@ MvField::MvField(field* f) { - //Grib = f; - //Grd = 0; + // Grib = f; + // Grd = 0; mvgrid_ = MvGridFactory(f, cReleaseMemoryFlag, cExpandGridFalse); } MvField::MvField(const MvField& f) { - //Grib = f.Grib; - //Grd = 0; + // Grib = f.Grib; + // Grd = 0; Request = f.Request; mvgrid_ = MvGridFactory(f.libmars_field(), cReleaseMemoryFlag, cExpandGridFalse); } @@ -589,19 +593,19 @@ if (strGridType == cSatelliteImage) { - Request("REPRES") = "SV"; - Request("_IMAGE_MAP_COLUMNS") = mvgrid_->getLong("numberOfPointsAlongXAxis", cThrowOnError); - Request("_IMAGE_MAP_ROWS") = mvgrid_->getLong("numberOfPointsAlongYAxis", cThrowOnError); - Request("_IMAGE_MAP_SUB_SAT_LATITUDE") = mvgrid_->getLong("latitudeOfSubSatellitePoint", cThrowOnError); + Request("REPRES") = "SV"; + Request("_IMAGE_MAP_COLUMNS") = mvgrid_->getLong("numberOfPointsAlongXAxis", cThrowOnError); + Request("_IMAGE_MAP_ROWS") = mvgrid_->getLong("numberOfPointsAlongYAxis", cThrowOnError); + Request("_IMAGE_MAP_SUB_SAT_LATITUDE") = mvgrid_->getLong("latitudeOfSubSatellitePoint", cThrowOnError); Request("_IMAGE_MAP_SUB_SAT_LONGITUDE") = mvgrid_->getLong("longitudeOfSubSatellitePoint", cThrowOnError); - Request("_IMAGE_MAP_X_EARTH_DIAMETER") = mvgrid_->getLong("dx", cThrowOnError); - Request("_IMAGE_MAP_Y_EARTH_DIAMETER") = mvgrid_->getLong("dy", cThrowOnError); - Request("_IMAGE_MAP_SUB_SAT_X") = mvgrid_->getLong("XpInGridLengths", cThrowOnError); - Request("_IMAGE_MAP_SUB_SAT_Y") = mvgrid_->getLong("YpInGridLengths", cThrowOnError); - Request("_IMAGE_MAP_GRID_ORIENTATION") = mvgrid_->getLong("orientationOfTheGrid", cThrowOnError); - Request("_IMAGE_MAP_CAMERA_ALTITUDE") = mvgrid_->getLong("NrInRadiusOfEarth", cThrowOnError); - Request("_IMAGE_MAP_INITIAL_COLUMN") = mvgrid_->getLong("xCoordinateOfOriginOfSectorImage", cThrowOnError); - Request("_IMAGE_MAP_INITIAL_ROW") = mvgrid_->getLong("yCoordinateOfOriginOfSectorImage", cThrowOnError); + Request("_IMAGE_MAP_X_EARTH_DIAMETER") = mvgrid_->getLong("dx", cThrowOnError); + Request("_IMAGE_MAP_Y_EARTH_DIAMETER") = mvgrid_->getLong("dy", cThrowOnError); + Request("_IMAGE_MAP_SUB_SAT_X") = mvgrid_->getLong("XpInGridLengths", cThrowOnError); + Request("_IMAGE_MAP_SUB_SAT_Y") = mvgrid_->getLong("YpInGridLengths", cThrowOnError); + Request("_IMAGE_MAP_GRID_ORIENTATION") = mvgrid_->getLong("orientationOfTheGrid", cThrowOnError); + Request("_IMAGE_MAP_CAMERA_ALTITUDE") = mvgrid_->getLong("NrInRadiusOfEarth", cThrowOnError); + Request("_IMAGE_MAP_INITIAL_COLUMN") = mvgrid_->getLong("xCoordinateOfOriginOfSectorImage", cThrowOnError); + Request("_IMAGE_MAP_INITIAL_ROW") = mvgrid_->getLong("yCoordinateOfOriginOfSectorImage", cThrowOnError); } } @@ -618,7 +622,7 @@ } -//double MvField::modelLevelToPressureexp(double sp, int ml) +// double MvField::modelLevelToPressureexp(double sp, int ml) double MvField::meanML_to_Pressure_bySP(double sp, int ml) { //-- if GRIB header contains vertical coordinate @@ -662,13 +666,13 @@ #endif } -//double MvField::modelLevelToPressure(double lnsp, int ml) +// double MvField::modelLevelToPressure(double lnsp, int ml) double MvField::meanML_to_Pressure_byLNSP(double lnsp, int ml) { return meanML_to_Pressure_bySP(exp(lnsp), ml); } -//double MvField::modelLevelToPressure2(double lnsp, int ml) +// double MvField::modelLevelToPressure2(double lnsp, int ml) double MvField::ML_to_Pressure_byLNSP(double lnsp, int ml_in) { return ML_to_Pressure_bySP(exp(lnsp), ml_in); @@ -755,36 +759,40 @@ return mvgrid_->vertCoordCoefPairCount(); - //assert(Grib->ksec2); + // assert(Grib->ksec2); //-- C array index 11 = Fortran array index 12 (Emoslib API) - //return (int)Grib->ksec2[11]/2; + // return (int)Grib->ksec2[11]/2; } - -bool MvField::averageAlong(double* val, +// Perform computations along a direction (ew or ns) within an area +bool MvField::computeAlong(double* val, double X1, double Y1, double X2, double Y2, int equat, int npoints, double res, bool cUseNearestPoint, - double* coords) + double* coords, + metview::StatsComputePtr comp) { + if (!comp) { + return false; + } + mvgrid_->init(); if (!mvgrid_->hasLocationInfo()) { - marslog(LOG_EROR, "averageAlong(): unimplemented or spectral data - unable to extract location data"); + marslog(LOG_EROR, "computeAlong(): unimplemented or spectral data - unable to extract location data"); return false; } double x, y, rx, ry; - double cumul, cang, weight, myValue; - int i, j, samples; + double cang, myValue; + int i = 0, j = 0; // Set resolution. If it is not given, try to compute it. if (res == 0.) { rx = gridWE(); ry = gridNS(); - // treatment of missing x/y increments (as in reduced Gaussian grids) - // prior to Metview 4.8.1, there was a bug here. gridWE() would give a very // tiny value when given a reduced Gaussian grid (based on misinterpreting @@ -804,7 +812,7 @@ if (ry == cValueNotGiven) { rx = ry = 1.0; - marslog(LOG_WARN, "averageAlong(): grid interval set to 1.0/1.0"); + marslog(LOG_WARN, "computeAlong(): grid interval set to 1.0/1.0"); } } else @@ -816,39 +824,35 @@ double last_X = X2 > X1 + cFullGlobeLimit ? X2 - rx : X2; //-- do not duplicate edges if global - - if (equat == 1) //-- average E->W + if (equat == 1) //-- E->W { for (i = 0, y = Y1; y >= Y2;) { if (i == npoints) { - marslog(LOG_EROR, "averageAlong(): too small output array!"); + marslog(LOG_EROR, "computeAlong(): too small output array!"); return false; } - val[i] = DBL_MAX; - cumul = 0; - samples = 0; + val[i] = DBL_MAX; + comp->reset(); for (j = 0, x = X1; x <= last_X;) { if (cUseNearestPoint) { MvGridPoint myPoint = mvgrid_->nearestGridpoint(y, x, false); - myValue = myPoint.value_; + myValue = myPoint.value_; } else myValue = mvgrid_->interpolatePoint(y, x); if ((myValue != DBL_MAX) && !(MISSING_VALUE(myValue))) { - cumul += myValue; - samples++; + comp->add(myValue); } j++; x = X1 + (j * rx); // do not add within the loop becuase of cumulative errors } - if (samples) - val[i] = cumul / (double)samples; + val[i] = comp->compute(false); if (coords) // save geographical coordinates coords[i] = y; @@ -858,40 +862,34 @@ } } - else //-- average N->S + else //-- N->S { for (x = X1, i = 0; x <= X2;) { if (i == npoints) { - marslog(LOG_EROR, "averageAlong(): too small output array!"); + marslog(LOG_EROR, "computeAlong(): too small output array!"); return false; } - cumul = weight = 0; - val[i] = DBL_MAX; - samples = 0; + comp->reset(); for (j = 0, y = Y1; y >= Y2;) { cang = cos(cCDR * y); if (cUseNearestPoint) { MvGridPoint myPoint = mvgrid_->nearestGridpoint(y, x, false); - myValue = myPoint.value_; + myValue = myPoint.value_; } - else + else { myValue = mvgrid_->interpolatePoint(y, x); - + } if ((myValue != DBL_MAX) && !(MISSING_VALUE(myValue))) { - cumul += cang * myValue; - weight += cang; - samples++; + comp->add(myValue, cang); } j++; y = Y1 - (j * ry); // do not add within the loop becuase of cumulative errors } - if (samples) - val[i] = cumul / weight; - + val[i] = comp->compute(true); if (coords) // save geographical coordinates coords[i] = x; @@ -899,10 +897,20 @@ x = X1 + (i * rx); // do not add within the loop becuase of cumulative errors } } - return true; } +bool MvField::averageAlong(double* val, + double X1, double Y1, + double X2, double Y2, + int equat, int npoints, + double res, bool cUseNearestPoint, + double* coords) +{ + auto comp = metview::StatsComputePtr(new metview::MeanStatsCompute()); + return computeAlong(val, X1, Y1, X2, Y2, equat, npoints, res, cUseNearestPoint, coords, comp); +} + //------- //------ averageAt() works fine when area coordinates fit //----- with the underlying lat-lon grid points; integrate() @@ -947,14 +955,14 @@ int i, j, samples = 0; double cang, weight = 0., - val = 0.; + val = 0.; for (y = Y1, i = 0; y >= Y2;) //-- Scan East->West { if (y > y1 || y <= y1min) continue; - iy = int((y1 - y) / ry); + iy = int((y1 - y) / ry); cang = cos(cCDR * y); for (x = X1, j = 0; x <= X2;) { xx = x; @@ -976,7 +984,7 @@ ix = int((xx - x1) / rx); #if 1 //-- this block for debugging... - int myInd = nhcells * iy + ix; + int myInd = nhcells * iy + ix; double myVal = Grib->rsec4[myInd]; val += cang * myVal; #else @@ -996,7 +1004,7 @@ val /= weight; else val = DBL_MAX; - //std::cout << samples << '\t' << val << std::endl; + // std::cout << samples << '\t' << val << std::endl; return val; #endif } @@ -1037,79 +1045,79 @@ #if 0 // Where is this point in matrix ? - int nhcells = (int) Grib->ksec2[1]; - int nvcells = (int) Grib->ksec2[2]; + int nhcells = (int) Grib->ksec2[1]; + int nvcells = (int) Grib->ksec2[2]; + + int ix, iy, ix1, iy1; // cell index that contains point + double x1, y1; // coordinates of cell that contains point + double rx, ry; // cell resolution + + double w1, w2; + x1 = Grib->ksec2[4]/1000.; + y1 = Grib->ksec2[3]/1000.; - int ix, iy, ix1, iy1; // cell index that contains point - double x1, y1; // coordinates of cell that contains point - double rx, ry; // cell resolution - - double w1, w2; - x1 = Grib->ksec2[4]/1000.; - y1 = Grib->ksec2[3]/1000.; - - rx = gridWE(); //- Grib->ksec2[8]/1000.; - ry = gridNS(); //- Grib->ksec2[9]/1000.; - - int globe = FALSE; - if (nhcells*rx > cFullGlobeLimit) - globe = TRUE; + rx = gridWE(); //- Grib->ksec2[8]/1000.; + ry = gridNS(); //- Grib->ksec2[9]/1000.; + + int globe = FALSE; + if (nhcells*rx > cFullGlobeLimit) + globe = TRUE; // Transform longitude from -180<->180 to 0<->360 - /* Bug fix for: - if (x < 0.) x = 360. + x; - else if (x<180. && x1>180.) x += 360.; - */ - if (globe ) - { - if( x < 0.) x = 360. + x; - else if (x<180. && x1>180.) x += 360.; - } + /* Bug fix for: + if (x < 0.) x = 360. + x; + else if (x<180. && x1>180.) x += 360.; + */ + if (globe ) + { + if( x < 0.) x = 360. + x; + else if (x<180. && x1>180.) x += 360.; + } // Check if the point is inside grid - if (x < x1) return DBL_MAX; - if (x > (nhcells-1)*rx+x1 && !globe) return DBL_MAX; - if (y > y1 || y < y1-(nvcells-1)*ry) return DBL_MAX; + if (x < x1) return DBL_MAX; + if (x > (nhcells-1)*rx+x1 && !globe) return DBL_MAX; + if (y > y1 || y < y1-(nvcells-1)*ry) return DBL_MAX; // Let's find which cell contains the point - ix = int((x-x1)/rx); + ix = int((x-x1)/rx); - double xx = x+rx; - // Arne's bugfix - //if (xx > (nhcells-1)*rx+x1) - if (xx >= nhcells*rx+x1) - if (globe) ix1 = 0; - else - ix1 = ix; - else - ix1 = int((xx-x1)/rx); + double xx = x+rx; + // Arne's bugfix + //if (xx > (nhcells-1)*rx+x1) + if (xx >= nhcells*rx+x1) + if (globe) ix1 = 0; + else + ix1 = ix; + else + ix1 = int((xx-x1)/rx); - iy = int((y1-y)/ry); + iy = int((y1-y)/ry); - double yy = y-ry; - if (yy < y1-(nvcells-1)*ry) iy1 = iy; - else - iy1 = int((y1-yy)/ry); + double yy = y-ry; + if (yy < y1-(nvcells-1)*ry) iy1 = iy; + else + iy1 = int((y1-yy)/ry); - x1 += ix*rx; - y1 -= iy*ry; + x1 += ix*rx; + y1 -= iy*ry; - w1 = (x - x1)/rx; - w2 = 1. - w1; + w1 = (x - x1)/rx; + w2 = 1. - w1; - int ix_found; - ix_found = (w1 < w2) ? ix : ix1; + int ix_found; + ix_found = (w1 < w2) ? ix : ix1; - w1 = (y1 - y)/ry; - w2 = 1. - w1; + w1 = (y1 - y)/ry; + w2 = 1. - w1; - int iy_found; - iy_found = (w1 < w2) ? iy : iy1; + int iy_found; + iy_found = (w1 < w2) ? iy : iy1; - return Grib->rsec4[nhcells*iy_found+ix_found]; + return Grib->rsec4[nhcells*iy_found+ix_found]; } #endif @@ -1126,9 +1134,9 @@ int nhcells = mvgrid_->getLong("numberOfPointsAlongAParallel"); // (int) Grib->ksec2[1]; int nvcells = mvgrid_->getLong("numberOfPointsAlongAMeridian"); // (int) Grib->ksec2[2]; - int ix, iy, ix1, iy1; // cell index that contains point - double x1, y1; // coordinates of cell that contains point - double rx, ry; // cell resolution + int ix = 0, iy = 0, ix1 = 0, iy1 = 0; // cell index that contains point + double x1, y1; // coordinates of cell that contains point + double rx, ry; // cell resolution double val1, val2; double w1 = 0.5, w2 = 0.5; @@ -1182,26 +1190,26 @@ // x1 += ix * rx; // y1 -= iy * ry; - int ix_found, iy_found; + int ix_found = 0, iy_found = 0; if (c == 0) { ix_found = ix; iy_found = iy; - val1 = (*mvgrid_)[nhcells * iy_found + ix_found]; + val1 = (*mvgrid_)[nhcells * iy_found + ix_found]; } else if (c == 1) { ix_found = ix; iy_found = iy1; - val1 = (*mvgrid_)[nhcells * iy_found + ix_found]; + val1 = (*mvgrid_)[nhcells * iy_found + ix_found]; } else if (c == 2) { ix_found = ix1; iy_found = iy1; - val1 = (*mvgrid_)[nhcells * iy_found + ix_found]; + val1 = (*mvgrid_)[nhcells * iy_found + ix_found]; } else if (c == 3) { ix_found = ix1; iy_found = iy; - val1 = (*mvgrid_)[nhcells * iy_found + ix_found]; + val1 = (*mvgrid_)[nhcells * iy_found + ix_found]; } else { val1 = w2 * (*mvgrid_)[nhcells * iy + ix] + w1 * (*mvgrid_)[nhcells * iy + ix1]; @@ -1214,8 +1222,9 @@ } -double MvField::integrate(double north, double west, double south, double east) +double MvField::computeInArea(double north, double west, double south, double east, bool weighted, StatsComputePtr comp) { + assert(comp); MvGeoBox geoArea(north, west, south, east); mvgrid_->init(); @@ -1225,40 +1234,37 @@ return DBL_MAX; } - double val = 0; - double wght = 0; - double sum = 0; - bool have_valid_values = false; - // The init function is not expanding the field. // So, we must expand it here before accessing its values MvFieldExpander x(*this); + comp->reset(); + comp->setInvalidValue(mars.grib_missing_value); + for (int j = 0; j < mvgrid_->length(); ++j) { if (geoArea.isInside(mvgrid_->lat_y(), mvgrid_->lon_x())) { - double w = mvgrid_->weight(); //-- for debugging - double v = mvgrid_->value(); //-- for debugging + double v = mvgrid_->value(); //-- for debugging if (!MISSING_VALUE(v)) // only consider the non-missing values { - wght += w; - sum += w * v; - have_valid_values = true; + if (weighted) { + double w = mvgrid_->weight(); //-- for debugging + comp->add(v, w); + } + else { + comp->add(v); + } } } - mvgrid_->advance(); } + return comp->compute(weighted); +} - if (have_valid_values) { - if (wght) - val = sum / wght; - } - else - val = mars.grib_missing_value; // all values were missing - - //std::cout << pcnt << '\t' << val << std::endl; - return val; +double MvField::integrate(double north, double west, double south, double east) +{ + auto comp = StatsComputePtr(new MeanStatsCompute()); + return computeInArea(north, west, south, east, true, comp); } //-- should be checked and tested!!! vk/981106... @@ -1274,11 +1280,11 @@ return DBL_MAX; } - double val = 0; + double val = 0; double wght = 0; - double sum = 0; + double sum = 0; double sum2 = 0; - int pcnt = 0; + int pcnt = 0; for (int j = 0; j < mvgrid_->length(); ++j) { if (geoArea.isInside(mvgrid_->lat_y(), mvgrid_->lon_x())) { @@ -1321,12 +1327,12 @@ return DBL_MAX; } - double val = 0; - double wght = 0; - double sumx = 0; - double sumy = 0; + double val = 0; + double wght = 0; + double sumx = 0; + double sumy = 0; double sumxy = 0; - int pcnt = 0; + int pcnt = 0; for (int j = 0; j < mvgrid_->length(); ++j) { if (geoArea.isInside(mvgrid_->lat_y(), mvgrid_->lon_x())) { @@ -1367,67 +1373,67 @@ bool MvField::isLatLon() { - //gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; - //return (s2->data_rep == GRIB_LAT_LONG); - //return mvgrid_->getLong("dataRepresentationType") == GRIB_LAT_LONG; + // gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; + // return (s2->data_rep == GRIB_LAT_LONG); + // return mvgrid_->getLong("dataRepresentationType") == GRIB_LAT_LONG; return mvgrid_->gridType() == cLatLonGrid; } int MvField::numberOfLat() { - //gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; - //return s2->points_meridian; + // gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; + // return s2->points_meridian; return mvgrid_->getLong("numberOfPointsAlongAMeridian"); } int MvField::numberOfLon() { - //gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; - //return s2->points_parallel; + // gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; + // return s2->points_parallel; return mvgrid_->getLong("numberOfPointsAlongAParallel"); } double MvField::north() { - //gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; - //return (double)s2->limit_north/(double)GRIB_FACTOR; + // gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; + // return (double)s2->limit_north/(double)GRIB_FACTOR; return mvgrid_->getDouble("latitudeOfFirstGridPointInDegrees"); } double MvField::south() { - //gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; - //return (double)s2->limit_south/(double)GRIB_FACTOR; + // gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; + // return (double)s2->limit_south/(double)GRIB_FACTOR; return mvgrid_->getDouble("latitudeOfLastGridPointInDegrees"); } double MvField::east() { - //gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; - //return (double)s2->limit_east/(double)GRIB_FACTOR; + // gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; + // return (double)s2->limit_east/(double)GRIB_FACTOR; return mvgrid_->getDouble("longitudeOfLastGridPointInDegrees"); } double MvField::west() { - //gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; - //return (double)s2->limit_west/(double)GRIB_FACTOR; + // gribsec2_ll *s2 = (gribsec2_ll*) &Grib->ksec2[0]; + // return (double)s2->limit_west/(double)GRIB_FACTOR; return mvgrid_->getDouble("longitudeOfFirstGridPointInDegrees"); } double MvField::gridNS() { - //TODO: implement this method in MvGrid since it has to be grid specific!!! + // TODO: implement this method in MvGrid since it has to be grid specific!!! double suppliedDy = mvgrid_->getDouble("jDirectionIncrementInDegrees"); if (fabs(suppliedDy) > 180.) { suppliedDy = cValueNotGiven; } - bool scanNeg = (mvgrid_->getLong("jScansPositively") != 0); + bool scanNeg = (mvgrid_->getLong("jScansPositively") != 0); double northVal = north(); double southVal = south(); - long numLat = numberOfLat(); + long numLat = numberOfLat(); double computed = cValueNotGiven; if (northVal != cValueNotGiven && southVal != cValueNotGiven && numLat != GRIB_MISSING_LONG) { @@ -1461,16 +1467,16 @@ double MvField::gridWE() { - //TODO: implement this method in MvGrid since it has to be grid specific!!! + // TODO: implement this method in MvGrid since it has to be grid specific!!! double suppliedDx = mvgrid_->getDouble("iDirectionIncrementInDegrees"); if (fabs(suppliedDx) > 360.) { suppliedDx = cValueNotGiven; } - bool scanPos = (mvgrid_->getLong("iScansNegatively") != 0); - double eastVal = east(); - double westVal = west(); - long numLon = numberOfLon(); + bool scanPos = (mvgrid_->getLong("iScansNegatively") != 0); + double eastVal = east(); + double westVal = west(); + long numLon = numberOfLon(); double computed = cValueNotGiven; if (eastVal != cValueNotGiven && westVal != cValueNotGiven && numLon != GRIB_MISSING_LONG) { @@ -1504,22 +1510,22 @@ bool MvField::isDerived() { - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - //return s1->generation == mars.computeflg; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // return s1->generation == mars.computeflg; return mvgrid_->getLong("generatingProcessIdentifier") == mars.computeflg; } double MvField::parameter() { - //if( Grib->buffer ) + // if( Grib->buffer ) // return (unsigned char)*(Grib->buffer+(8+9-1)); //-- 9th octet in sec1 - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - //return s1->parameter; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // return s1->parameter; #if 1 - //return mvgrid_->getDouble("mars.param"); //- does not work in GRIB 2 ??? + // return mvgrid_->getDouble("mars.param"); //- does not work in GRIB 2 ??? std::string p = mvgrid_->getString("mars.param"); - double d = atof(p.c_str()); + double d = atof(p.c_str()); return d; #else if (mvgrid_->getLong("editionNumber") > 1) @@ -1536,11 +1542,11 @@ int MvField::table() { - //if( Grib->buffer ) + // if( Grib->buffer ) // return (unsigned char)*(Grib->buffer+(8+4-1)); //-- 4th octet in sec1 - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - //return s1->version; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // return s1->version; long ed = mvgrid_->getLong("editionNumber"); if (ed > 1) { @@ -1553,23 +1559,23 @@ int MvField::centre() { - //if( Grib->buffer ) + // if( Grib->buffer ) // return (unsigned char)*(Grib->buffer+(8+5-1)); //-- 5th octet in sec1 - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - //return s1->center; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // return s1->center; return mvgrid_->getLong("centre"); } int MvField::generatingProcess() { - //if( Grib->buffer ) + // if( Grib->buffer ) // return (unsigned char)*(Grib->buffer+(8+6-1)); //-- 6th octet in sec1 - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - //return s1->generation; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // return s1->generation; return mvgrid_->getLong("generatingProcessIdentifier"); } @@ -1615,8 +1621,8 @@ int MvField::levelType() { - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - //return s1->level_type; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // return s1->level_type; int lev = mvgrid_->getLong("levelType"); return lev; @@ -1624,8 +1630,8 @@ int MvField::dataRepres() { - //return (int)Grib->ksec2[0]; //-- fortran index (1) - //return mvgrid_->getLong("dataRepresentationType"); + // return (int)Grib->ksec2[0]; //-- fortran index (1) + // return mvgrid_->getLong("dataRepresentationType"); // maybe not the very best way to do it, but we have quite a few @@ -1660,10 +1666,10 @@ bool MvField::isModelLevel() { - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - //return s1->level_type == GRIB_MODEL_LEVEL; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // return s1->level_type == GRIB_MODEL_LEVEL; - //return levelType() == GRIB_MODEL_LEVEL || levelType() == cML_UKMO_ND; + // return levelType() == GRIB_MODEL_LEVEL || levelType() == cML_UKMO_ND; std::string levTyp = mvgrid_->getString("mars.levtype"); if (levTyp == "ml" || levTyp == cML_UKMO_ND_STR) { @@ -1678,9 +1684,9 @@ bool MvField::isPressureLevel() { - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - //return levelType() == GRIB_PRESSURE_LEVEL || + // return levelType() == GRIB_PRESSURE_LEVEL || // levelType() == GRIB_ABOVE_1HPA; std::string levTyp = mvgrid_->getString("mars.levtype"); @@ -1689,7 +1695,7 @@ bool MvField::isDepth() { - //gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; + // gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; return levelType() == GRIB_DEPTH_BELOW_SEA_LEVEL; } @@ -1709,36 +1715,7 @@ double MvField::yyyymmddFoh() { -#if 0 - gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - if ( s1 ) - { - double year = (long)((s1->century-1) * 100 + s1->year); - double d1 = year*10000. + (double)s1->month*100. + (double)s1->day; - double d2 = (( (double)s1->hour*60. + (double)s1->minute ) * 60. ) / 86400.; - - return (d1 + d2); //-- using obsolete GRIBEX API (needs struct expansion) - } - else if( Grib->buffer ) - { - //-- set octet ptr 'sec1' in such a way that following indices - //-- refer to GRIB section 1 octets, i.e. skip section 0 except the last octet - unsigned char* sec1 = (unsigned char*)(Grib->buffer + 7); - - double year = (long)((sec1[25]-1) * 100 + sec1[13]); - double d1 = year*10000. + (double)sec1[14]*100. + (double)sec1[15]; - double d2 = (( (double)sec1[16]*60. + (double)sec1[17] ) * 60. ) / 86400.; - - return (d1 + d2); //-- using original GRIB octets (works without expansion) - } - - return 0; //-- failed to extract date -#endif - double dat = mvgrid_->getDouble("dataDate"); - double tim = mvgrid_->getDouble("time"); - - //nontested_eccodes_port("MvField::yyyymmddFoh()"); - return dat + tim / 2400.0; //--HHMM + return mvgrid_->yyyymmddFoh(); } @@ -1749,75 +1726,9 @@ double MvField::stepFoh() { -#if 0 - double d3 = 0.0; - gribsec1 *s1 = (gribsec1*)&Grib->ksec1[0]; - if ( s1 ) //-- using obsolete GRIBEX API (needs expanding) - { - fortint p1 = s1->p1; - if ( p1 > 0 ) - { - fortint timeUnit = s1->time_unit; - if ( timeUnit == 0 ) // minutes - d3 = (double)p1 / (24.*60.); - else if ( timeUnit == 1 ) // hours - d3 = (double)p1 / 24.; - else if ( timeUnit == 2 ) // days - d3 = (double)p1; - else - marslog(LOG_EROR,"Time unit code not implemented yet. General date value used"); - } - } - else if( Grib->buffer ) //-- use original GRIB octets (works without expansion) - { - //-- set octet ptr 'sec1' in such a way that following indices - //-- refer to GRIB section 1 octets, i.e. skip section 0 except the last octet - unsigned char* sec1 = (unsigned char*)(Grib->buffer + 7); - - double p1 = (double)sec1[19]; - if( sec1[21] == 10 ) //-- p1 may occupy both octets p1 & p2 ? - p1 = 256.*p1 + (double)sec1[20]; - - if( p1 > 0 ) - { - if( sec1[18] == 0 ) // minutes - d3 = p1 / (24.*60.); - else if( sec1[18] == 1 ) // hours - d3 = p1 / 24.; - else if( sec1[18] == 2 ) // days - d3 = p1; - else - marslog(LOG_EROR,"Time unit code not implemented yet. General date value used"); - } - } - - return d3; -#endif - - double d3 = mvgrid_->getDouble("mars.step", false, true); // throw, quiet - if (d3 == DBL_MAX) { - d3 = mvgrid_->getDouble("step", false, true); - if (d3 == DBL_MAX) { - d3 = mvgrid_->getDouble("endStep", false, true); - if (d3 == DBL_MAX) - d3 = 0; // can't find a step key, so step=0 - } - } - - - // https://apps.ecmwf.int/codes/grib/format/grib2/ctables/4/4 for the complete list - // note that 1 is hours, which is what we assume by default - long stepUnit = mvgrid_->getLong("indicatorOfUnitOfTimeRange"); - if (stepUnit < 0) // means that the key could not be found, therefore assume 'hours' - stepUnit = 1; - - if (stepUnit == 0) // minutes - d3 /= 60.0; - - return d3 / 24.0; + return mvgrid_->stepFoh(); } - // stepRangeDecoder // -- Returns the step number from a step string. // -- e.g. '72' -> 72; @@ -1830,7 +1741,7 @@ int MvField::stepRangeDecoder(const char* stepString) { char buff[100]; - long start_step, step; + long start_step = 0, step = 0; char* p = buff; if (stepString != nullptr) { @@ -1879,77 +1790,77 @@ Cached MvField::vectorPair() { - char buf[ 512 ]; + char buf[ 512 ]; + + std::ifstream istrm( (const char*)MagicsTable2FileName(), std::ios::in ); + if( ! istrm ) + { + marslog(LOG_INFO, "Magics Extended GRIB Table 2 Version %d open error", table() ); + return Cached( "no_pair" ); + } - std::ifstream istrm( (const char*)MagicsTable2FileName(), std::ios::in ); - if( ! istrm ) - { - marslog(LOG_INFO, "Magics Extended GRIB Table 2 Version %d open error", table() ); - return Cached( "no_pair" ); - } - - char tableVers[ 5 ]; - ostrstream tvstr( tableVers, sizeof( tableVers ) ); - tvstr << "." - << table() //-- required for new (030612) MARS param syntax - << std::ends; + char tableVers[ 5 ]; + ostrstream tvstr( tableVers, sizeof( tableVers ) ); + tvstr << "." + << table() //-- required for new (030612) MARS param syntax + << std::ends; - istrm.getline( buf, sizeof( buf ) ); - int current = atoi( buf ); + istrm.getline( buf, sizeof( buf ) ); + int current = atoi( buf ); int param = (int)parameter(); - while( ! istrm.eof() && istrm.good() && current < param ) - { - istrm.getline( buf, sizeof( buf ) ); - current = atoi( buf ); - } - - if( current == param ) - { - //-- there are max 12 entries on a line, separated by '&'s - //-- if 9th entry > 0 - //-- then entry 10 is the param number for the pair - - char* start = buf; - for( int i=1; i<9; ++i ) //-- locate 9th entry - { - start = strstr( start, "&" ); - if( start ) - ++start; //-- i:th entry exists - else - break; //-- less than 9 entries - } - if( start ) //-- did the 9th entry exist? - { - if( atol( start ) > 0 ) //-- entry value > 0 => has a pair - { - start = strstr( start, "&" ); - if( start ) //-- does the 10th entry exist? - { - ++start; - while( *start == ' ' ) - ++start; //-- remove leading spaces - - char* amp = strstr( start, "&" ); - if( amp ) - { - *amp-- = '\0'; - while( *amp == ' ' ) - *amp-- = '\0'; //-- remove trailing spaces - } - - return Cached( start ) + Cached( tableVers ); //-- OK, return pair! - } - } - } + while( ! istrm.eof() && istrm.good() && current < param ) + { + istrm.getline( buf, sizeof( buf ) ); + current = atoi( buf ); + } - return Cached( "no_pair" ); //-- scalar, has no pair! - } + if( current == param ) + { + //-- there are max 12 entries on a line, separated by '&'s + //-- if 9th entry > 0 + //-- then entry 10 is the param number for the pair + + char* start = buf; + for( int i=1; i<9; ++i ) //-- locate 9th entry + { + start = strstr( start, "&" ); + if( start ) + ++start; //-- i:th entry exists + else + break; //-- less than 9 entries + } + if( start ) //-- did the 9th entry exist? + { + if( atol( start ) > 0 ) //-- entry value > 0 => has a pair + { + start = strstr( start, "&" ); + if( start ) //-- does the 10th entry exist? + { + ++start; + while( *start == ' ' ) + ++start; //-- remove leading spaces + + char* amp = strstr( start, "&" ); + if( amp ) + { + *amp-- = '\0'; + while( *amp == ' ' ) + *amp-- = '\0'; //-- remove trailing spaces + } - marslog(LOG_INFO , "Param %d missing from Magics Extended GRIB Table 2 Vers %d" - , param , table() ); + return Cached( start ) + Cached( tableVers ); //-- OK, return pair! + } + } + } + + return Cached( "no_pair" ); //-- scalar, has no pair! + } - return Cached( "no_pair" ); + marslog(LOG_INFO , "Param %d missing from Magics Extended GRIB Table 2 Vers %d" + , param , table() ); + + return Cached( "no_pair" ); } */ @@ -1961,7 +1872,7 @@ if (mvgrid_->hasLocationInfo()) { MvGridPoint nearestPoint = mvgrid_->nearestGridpoint(l.latitude(), l.longitude(), false); - nearestLoc = nearestPoint.loc_; + nearestLoc = nearestPoint.loc_; } else { marslog(LOG_EROR, "nearestGridPointLocation(): unimplemented or spectral data - unable to extract location data"); @@ -1981,7 +1892,7 @@ MvFieldExpander x(*this); mvgrid_->init(); for (int j = 0; j < mvgrid_->length(); ++j) { - if (!mvgrid_->hasValue()) //missing value + if (!mvgrid_->hasValue()) // missing value continue; if (mvgrid_->value() >= min && mvgrid_->value() <= max) { @@ -2000,4 +1911,3 @@ { return getGribKeyValueString("gridType") == "sh"; } - diff -Nru metview-5.17.4/metview/src/libMetview/MvFieldSet.h metview-5.19.2/metview/src/libMetview/MvFieldSet.h --- metview-5.17.4/metview/src/libMetview/MvFieldSet.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFieldSet.h 2023-07-15 08:28:47.000000000 +0000 @@ -12,13 +12,14 @@ #include "MvRequest.h" #include "MvFilter.h" #include "MvGrid.h" +#include "MvFwd.h" //-- activate next line if you need old ml-to-pressure methods -//for-the-moment//#define INCLUDE_OLD_CODE +// for-the-moment//#define INCLUDE_OLD_CODE -const double cValueNotGiven = DBL_MAX; -const int cML_UKMO_ND = 205; //-- level type for UKMO New Dynamics data +const double cValueNotGiven = DBL_MAX; +const int cML_UKMO_ND = 205; //-- level type for UKMO New Dynamics data const std::string cML_UKMO_ND_STR = "205"; //-- level type for UKMO New Dynamics data #if 0 @@ -56,23 +57,23 @@ //! Copy constructor 1 /*! Builds a new MvField object by copying the internal pointers - * (GRIB data and request) from argument \c f .\n \n - * Note that both objects will share the same data! - */ + * (GRIB data and request) from argument \c f .\n \n + * Note that both objects will share the same data! + */ MvField(const MvField& f); //! Copy constructor 2 /*! Builds a new MvField object from libMars \c field struct \c f. \n \n - * Note that the created object will share the GRIB data with struct \c f ! - */ + * Note that the created object will share the GRIB data with struct \c f ! + */ MvField(field* f); //! Assignment operator /*! This operator copies the internal pointers (GRIB data and request) - * of object pointed by argument \c f to the other MvField - * in an assignment operation.\n \n - * Note that both objects will share the same data! - */ + * of object pointed by argument \c f to the other MvField + * in an assignment operation.\n \n + * Note that both objects will share the same data! + */ MvField& operator=(const MvField& f); //! Returns a pointer to the internal libMars \c field struct @@ -88,12 +89,15 @@ // Converters //! Returns a copy of the RETRIEVE command that describes the field contents. /*! Creates the request if the request has not been given in the constructor - * or if not already created. - */ + * or if not already created. + */ MvRequest& getRequest(); // Create a MvRequest - // Data access, expanding is taken care of - //! Non-OOP style method to calculate average in NS or WE direction over an area + // Performs computations with a StatsCompute object + double computeInArea(double north, double west, double south, double east, bool weighted, StatsComputePtr comp); + bool computeAlong(double* n, double, double, double, double, int, int, + double res, bool useNearestPoint, double* coords, metview::StatsComputePtr); + bool averageAlong(double* n, double, double, double, double, int, int, double res = 0., bool useNearestPoint = true, double* coords = 0); @@ -102,24 +106,24 @@ //! Interpolates a value for the given geographical location /*! Uses the internal MvGridBase object (method MvGridBase::interpolatePoint) - * to do the calculation (which depend on the underlying grid - * presentation.\n \n - * Note that arguments are (longitude, latitude). - */ + * to do the calculation (which depend on the underlying grid + * presentation.\n \n + * Note that arguments are (longitude, latitude). + */ double interpolateAt(double x_lon, double y_lat); //! Returns the value from a grid point nearest to the given geographical location /*! Uses the internal MvGridBase object (method MvGridBase::nearestGridpoint) - * to do the search (which depends on the underlying grid presentation.\n \n - * Use method nearestGridPointLocation() to get the location of the nearest grid point.\n \n - * Note that arguments are (longitude, latitude). - */ + * to do the search (which depends on the underlying grid presentation.\n \n + * Use method nearestGridPointLocation() to get the location of the nearest grid point.\n \n + * Note that arguments are (longitude, latitude). + */ double nearestGridpoint(double x_lon, double y_lat, bool nearestValid); //! Returns the value from a grid point nearest to the given geographical location /*! Same as nearestGridpoint, but we return the whole MvGridPoint. - */ + */ MvGridPoint nearestGridpointInfo(double x_lon, double y_lat, bool nearestValid); @@ -128,43 +132,43 @@ //! Get a matrix of values around the given geographical location /*! Uses the internal MvGridBase object (method MvGridBase::getMatrixNN) - * to extract the requested matrix. Used mainly for satellite images. - */ + * to extract the requested matrix. Used mainly for satellite images. + */ bool getMatrixNN(double, double, MvMatrix&); //-- new versions -- //! Evaluates the corresponding pressure level for the given model level \c ml /*! This method is for the vertical discretisation used at ECMWF, based on - * model level layers. - * The pressure level is evaluated using \c sp and the coefficient pairs ( \c C1 - * and \c C2 ) for the two surrounding "half-levels" ( \c ml-0.5 and \c ml+0.5 ), - * stored in the GRIB header, using the layer mean.\n \n - * If the GRIB header contains only one pair of coefficients \c C1 and \c C2 - * then method ML_to_Pressure_bySP() is called internally. - */ + * model level layers. + * The pressure level is evaluated using \c sp and the coefficient pairs ( \c C1 + * and \c C2 ) for the two surrounding "half-levels" ( \c ml-0.5 and \c ml+0.5 ), + * stored in the GRIB header, using the layer mean.\n \n + * If the GRIB header contains only one pair of coefficients \c C1 and \c C2 + * then method ML_to_Pressure_bySP() is called internally. + */ double meanML_to_Pressure_bySP(double sp, int ml); //! Evaluates the corresponding pressure level for a given model level \c ml /*! Internally converts \c lnsp to \c sp and calls method meanML_to_Pressure_bySP() - */ + */ double meanML_to_Pressure_byLNSP(double lnsp, int ml); //! Evaluates the corresponding pressure level for the given model level \c ml /*! The pressure level is evaluated using \c sp and the coefficient pair \c C1 - * and \c C2 stored in the GRIB header. - */ + * and \c C2 stored in the GRIB header. + */ double ML_to_Pressure_bySP(double sp, int ml); //! Evaluates the corresponding pressure level for a given model level \c ml /*! Internally converts \c lnsp to \c sp and calls method ML_to_Pressure_bySP() - */ + */ double ML_to_Pressure_byLNSP(double lnsp, int ml); //! Computes the pressure level for a single model level /*! Arguments \c C1 and \c C2 are the vertical coordinate coefficient pair - * and \c sp is the surface pressure. - */ + * and \c sp is the surface pressure. + */ double pressureLevel(double C1, double C2, double sp) { return C1 + C2 * sp; @@ -182,8 +186,8 @@ //! Gets a vertical coordinate coefficient pair /*! Vertical coordinate coefficient pair ( \c C1 , \c C2 ) - * for level \c level is extracted from the GRIB header - */ + * for level \c level is extracted from the GRIB header + */ bool vertCoordCoefs(int level, double& C1, double& C2); //! Returns the number of vertical coordinate coefficient pairs stored in the GRIB header @@ -191,25 +195,25 @@ //! Grid point weighted integration over the given area /*! Weighting is done according to the geographical area that - * each grid point represents, e.g. in cylindrical projection - * grid points closer to the Poles represent smaller areas - * than those closer to the Equator - */ + * each grid point represents, e.g. in cylindrical projection + * grid points closer to the Poles represent smaller areas + * than those closer to the Equator + */ double integrate(double north, double west, double south, double east); //! Grid point weighted standard deviation calculated over the given area /*! About the weighting used, see integrate(). - */ + */ double stdev(double north, double west, double south, double east); //! Grid point weighted covariance over the given area /*! About the weighting used, see integrate(). - */ + */ double covar(MvField& other, double north, double west, double south, double east); //! Returns the offset of the GRIB message /*! This is the offset from the beginning of the input file, in bytes - */ + */ long getOffset() { if (libmars_field()) @@ -234,9 +238,9 @@ //! Returns the value of the \c n'th element in the field /*! Element type depends on the field presentation: - * it can be a value of a grid point or of a spectral coefficient.\n - * For the first element \c n = 0 ( \c n = 0, 1, 2, ...) - */ + * it can be a value of a grid point or of a spectral coefficient.\n + * For the first element \c n = 0 ( \c n = 0, 1, 2, ...) + */ double& operator[](int n) { return libmars_field()->values[n]; } //! Returns \c true if the GRIB message contains a missing field @@ -271,15 +275,15 @@ //! Returns \c true if the field is derived, \c false if retrieved /*! Metview and MARS mark derived (computed) fields with a special - * value in generatingProcess() octet.\n \n - * In Metview visualisation derived fields - * are indicated by an extra asterisk in the parameter name - * in the plot title, and some fields get different unit conversions. - * For instance retrieved temperature field values (stored in Kelvin - * in GRIB message) are converted (by default) to Celsius for - * plotting, but a computed temperature difference field is plotted - * (by default) as is, without conversion. - */ + * value in generatingProcess() octet.\n \n + * In Metview visualisation derived fields + * are indicated by an extra asterisk in the parameter name + * in the plot title, and some fields get different unit conversions. + * For instance retrieved temperature field values (stored in Kelvin + * in GRIB message) are converted (by default) to Celsius for + * plotting, but a computed temperature difference field is plotted + * (by default) as is, without conversion. + */ bool isDerived(); //! Returns the GRIB Edition number of the current GRIB message @@ -305,8 +309,8 @@ //! Returns the code number for the 'generating process' /*! This code is also used by Metview/MARS to mark a field - * as 'computed', see isDerived(). - */ + * as 'computed', see isDerived(). + */ int generatingProcess(); //! Returns the primary level value (octet 11, or combined octets 11&12 in GRIB 1) @@ -326,29 +330,29 @@ //! Returns the parameter name used by MARS Cached marsName(); //-- from Emoslib Table 2 versions - //Cached fullName_DeleteMe(); //-- from Emoslib Table 2 versions + // Cached fullName_DeleteMe(); //-- from Emoslib Table 2 versions //! Returns the parameter name used by Magics 6 Cached magicsName(); //-- from Magics Table 2 versions - //OBSOLETE: Remove later + // OBSOLETE: Remove later //! Returns the pairing parameter for vector parameters, as a string /*! Method searches Magics 6 Extended GRIB Table 2 files for the current - * parameter, to see if it is part of a vector pair (u/v, speed/direction, - * vorticity/divergence). If this is a part of a vector, then returns - * the other parameter code in format \c "ppp.tt" , where \c ppp is the code - * for the parameter in Table 2 version \c tt. \n \n - * Returns \c "no_pair" if this is a scalar parameter. - */ + * parameter, to see if it is part of a vector pair (u/v, speed/direction, + * vorticity/divergence). If this is a part of a vector, then returns + * the other parameter code in format \c "ppp.tt" , where \c ppp is the code + * for the parameter in Table 2 version \c tt. \n \n + * Returns \c "no_pair" if this is a scalar parameter. + */ // Cached vectorPair(); //-- from Magics Table 2 versions //! [Obsolete!]] Returns \c true if the GRIB message has been fully expanded into memory /*! Expanded state was a requirement for the obsolete GRIBEX based implementation. - * With the current ecCodes implementation messages do not need to be - * expanded in order to have access to data values, thus calling this - * calling this function is obsolete. - */ + * With the current ecCodes implementation messages do not need to be + * expanded in order to have access to data values, thus calling this + * calling this function is obsolete. + */ bool isExpanded() { return mvgrid_->field_->shape == expand_mem; } //! This method reads the GRIB message into memory, in case it is not already there @@ -420,26 +424,26 @@ // Compare with nullptr //! Operator for testing the validity of MvField object /*! This operator returns the pointer of the internal libMars - * GRIB structure as a \c void* . - * It is useful to compare the contents of a MvField to nullptr - * in a \c while or \c if statements.\n \n - * Usage: - *
-	 *      MvField f;
-	 *      if ( f ) ...
-	 * 
- */ + * GRIB structure as a \c void* . + * It is useful to compare the contents of a MvField to nullptr + * in a \c while or \c if statements.\n \n + * Usage: + *
+     *      MvField f;
+     *      if ( f ) ...
+     * 
+ */ operator void*(); //! Operator for testing the validity of MvField object /*! This operator compares the pointer of the internal libMars - * GRIB structure to nullptr and returns the result.\n \n - * Usage: - *
-	 *       MvField f;
-	 *       if ( !f ) ...
-	 * 
- */ + * GRIB structure to nullptr and returns the result.\n \n + * Usage: + *
+     *       MvField f;
+     *       if ( !f ) ...
+     * 
+ */ int operator!(); // Clone the data... @@ -458,14 +462,14 @@ //! Returns the location of the nearest grid point for the given geographical location /*! Use method nearestGridpoint() to get the value of the grid point - */ + */ MvLocation nearestGridPointLocation(const MvLocation& l); //! Returns the data date-time as a double number /*! Integer part shows \c yyyymmdd and the decimal part shows the hours - * as a fraction of a day. For instance 20080724.5 represents 12:00 UTC - * on 24 July 2008, and 20070620.75 represents 18:00 UTC on 20 June 2007. - */ + * as a fraction of a day. For instance 20080724.5 represents 12:00 UTC + * on 24 July 2008, and 20070620.75 represents 18:00 UTC on 20 June 2007. + */ double yyyymmddFoh(); // return date: yyyymmdd.f, f=fraction of hour //! Returns the validity date-time as a double number @@ -476,27 +480,27 @@ //! Returns the forecast step in fractions of a day. /*! For instance 0.25 represents a forecast of 6 hours, - * and 2.5 represents a forecast of 60 hours. - */ + * and 2.5 represents a forecast of 60 hours. + */ double stepFoh(); // return step in fraction of hour //! Returns the step number from a step string. /*! Normally the two are basically the same (e.g. '72' -> 72), but - * in some cases the step is a range (e.g. '96-120'). - * When we used grib_api <= 1.7.0, mars.step (string) was returning the 'endStep' - * parameter (in this case 120). However, with grib_api 1.8.0, mars.step - * returns the whole range. In this case, Metview was 'unthinkingly' converting - * to a number, and the result was the first in the range (in this case 96). - * The solution, it would appear, is to scan for a range and if so, then take - * the second number. This will at least give the same results as previous versions. - */ + * in some cases the step is a range (e.g. '96-120'). + * When we used grib_api <= 1.7.0, mars.step (string) was returning the 'endStep' + * parameter (in this case 120). However, with grib_api 1.8.0, mars.step + * returns the whole range. In this case, Metview was 'unthinkingly' converting + * to a number, and the result was the first in the range (in this case 96). + * The solution, it would appear, is to scan for a range and if so, then take + * the second number. This will at least give the same results as previous versions. + */ static int stepRangeDecoder(const char* stepString); //! Returns the embedded grib_handle /*! This method is for "lower" level GRIB access, for cases - * not available in MvField class - */ + * not available in MvField class + */ grib_handle* getGribHandle() { return mvgrid_->field_->handle; } //! Returns a list of locations (lat/long pairs), where the values of the input field @@ -600,16 +604,16 @@ //! Constructor, reads fields from a file /*! Reads the GRIB data file pointed by argument \c filename - * and builds the fieldset that contains all the fields in the file. - */ + * and builds the fieldset that contains all the fields in the file. + */ MvFieldSet(const char* filename); // Contruction from a file name //! Constructor, creates a fieldset from a request /*! Builds a fieldset from a GRIB command. - * This command specifies the file name in parameter PATH. - * The order of the fields within the file may be specified - * by parameter INDEX or by parameters OFFSET and LENGTH. - */ + * This command specifies the file name in parameter PATH. + * The order of the fields within the file may be specified + * by parameter INDEX or by parameters OFFSET and LENGTH. + */ MvFieldSet(const MvRequest& req); // Contruction from a request //! Destructor @@ -623,20 +627,20 @@ //! Returns one field from the fieldset /*! Argument \c n defines which field to return. - * First field is returned when \c n = 0 (\c n = 0, 1, 2,...). - */ + * First field is returned when \c n = 0 (\c n = 0, 1, 2,...). + */ MvField& operator[](int); // Return a single field //! Returns a request describing the fieldset /*! Returns a GRIB command that describes the position of the fields - * within the file. The GRIB command contains the parameters: - *
-	 *      PATH - file name.
-	 *      TEMPORARY - 0 or 1. When 1, file may be deleted
-	 *      OFFSET - byte offset of field within file.
-	 *      LENGTH - size of field in bytes.
-	 * 
- */ + * within the file. The GRIB command contains the parameters: + *
+     *      PATH - file name.
+     *      TEMPORARY - 0 or 1. When 1, file may be deleted
+     *      OFFSET - byte offset of field within file.
+     *      LENGTH - size of field in bytes.
+     * 
+ */ MvRequest getRequest(); // Create a MvRequest // MvRequest getRequest(bool clone=false); // original had an argument which is never used @@ -668,48 +672,51 @@ //! Destructor ~MvFieldSetIterator(); + MvFieldSetIterator(const MvFieldSetIterator&) = delete; + MvFieldSetIterator& operator=(const MvFieldSetIterator&) = delete; + //! Method that associates MvFilter \c f to the iterator. /*! Only fields that satisfy the filter conditions will be - * returned by the iterator - */ + * returned by the iterator + */ void setFilter(const MvFilter& f); //! This method specifies the sorting criteria to be used when accessing the fieldset /*! Argument \c name defines which parameter of the field description command - * will be used as a sorting key. - * Argument \c ord specifies if fields will be sorted in - * ascending ('<') or descending ('>') order. - * When more than one parameter are defined as sorting key, - * the first one varies more quickly - */ + * will be used as a sorting key. + * Argument \c ord specifies if fields will be sorted in + * ascending ('<') or descending ('>') order. + * When more than one parameter are defined as sorting key, + * the first one varies more quickly + */ void sort(const char* name, char ord = '<'); // '<' = ascending, '>' = descending //! Returns the next iterated field /*! This operator sequentially returns a MvField from a MvFieldSet - * in the order specified by method sort() and - if used - MvFilter object.\n \n - * Usage:\n - *
-	 *  MvRequest  grib;             // a GRIB command
-	 *  MvFieldSet fs(grib);         // construct field set
-	 *
-	 *  MvFieldSetIterator iter(fs); // define an iterator
-	 *  iter.sort("STEP,'>'");       // sort STEP in descending order
-	 *  iter.sort("DATE");           // sort DATE in ascending order
-	 *
-	 *  MvFilter level("LEVEL");
-	 *  MvFilter param("PARAM");
-	 *
-	 *  iter.setFilter(param==129 && level>5 && level<=20);
-	 *
-	 *  MvField field;
-	 *
-	 *  while(field = iter())
-	 *  {
-	 *  	// fields that have PARAM=129 and LEVEL in
-	 *  	// the range [6...20] may be accessed here
-	 *  }
-	 * 
- */ + * in the order specified by method sort() and - if used - MvFilter object.\n \n + * Usage:\n + *
+     *  MvRequest  grib;             // a GRIB command
+     *  MvFieldSet fs(grib);         // construct field set
+     *
+     *  MvFieldSetIterator iter(fs); // define an iterator
+     *  iter.sort("STEP,'>'");       // sort STEP in descending order
+     *  iter.sort("DATE");           // sort DATE in ascending order
+     *
+     *  MvFilter level("LEVEL");
+     *  MvFilter param("PARAM");
+     *
+     *  iter.setFilter(param==129 && level>5 && level<=20);
+     *
+     *  MvField field;
+     *
+     *  while(field = iter())
+     *  {
+     *  	// fields that have PARAM=129 and LEVEL in
+     *  	// the range [6...20] may be accessed here
+     *  }
+     * 
+ */ MvField& operator()(); // returns NULL at end of list //! Rewinds the iterator diff -Nru metview-5.17.4/metview/src/libMetview/MvFilter.cc metview-5.19.2/metview/src/libMetview/MvFilter.cc --- metview-5.17.4/metview/src/libMetview/MvFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ void MvFilter::_init(const char* name) { - value* v = new_value(strcache(name)); + value* v = new_value(strcache(name)); Condition = new_condition(t_val, (condition*)v, nullptr); } @@ -61,7 +61,7 @@ condition* c = new_condition(t_and, clone_condition(Condition), clone_condition(f.Condition)); - return MvFilter(c); + return {c}; } MvFilter MvFilter::operator||(const MvFilter& f) @@ -69,14 +69,14 @@ condition* c = new_condition(t_or, clone_condition(Condition), clone_condition(f.Condition)); - return MvFilter(c); + return {c}; } MvFilter MvFilter::operator!() { condition* c = new_condition(t_not, clone_condition(Condition), nullptr); - return MvFilter(c); + return {c}; } //------------------------------------------------------------------------ @@ -86,7 +86,7 @@ MvFilter f(x); condition* c = new_condition(op, clone_condition(Condition), clone_condition(f.Condition)); - return MvFilter(c); + return {c}; } MvFilter MvFilter::_newop(testop op, double x) diff -Nru metview-5.17.4/metview/src/libMetview/MvFilter.h metview-5.19.2/metview/src/libMetview/MvFilter.h --- metview-5.17.4/metview/src/libMetview/MvFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -56,7 +56,7 @@ // Convertors //! Operator that returns the pointer to the internal condition structure /*! It may be used to check if a condition is defined. - */ + */ operator condition*() { return Condition; } // Utilities @@ -65,9 +65,9 @@ //! Equality test for a string /*! These three operators build atomic comparison conditions - * that do an equality test between the parameter defined - * in the constructor and the argument of the operator - */ + * that do an equality test between the parameter defined + * in the constructor and the argument of the operator + */ MvFilter operator==(char* str); //! Equality test for a double @@ -78,9 +78,9 @@ //! Non-equality test for a string /*! These three operators build atomic comparison conditions - * that do a non-equality test between the parameter defined - * in the constructor and the argument of the operator - */ + * that do a non-equality test between the parameter defined + * in the constructor and the argument of the operator + */ MvFilter operator!=(char* str); //! Non-equality test for a double @@ -91,9 +91,9 @@ //! Less-or-equal test for a string /*! These three operators build atomic comparison conditions - * that do a less-or-equal test between the parameter defined - * in the constructor and the argument of the operator - */ + * that do a less-or-equal test between the parameter defined + * in the constructor and the argument of the operator + */ MvFilter operator<=(char* str); //! Less-or-equal test for a double @@ -104,9 +104,9 @@ //! Greater-or-equal test for a string /*! These three operators build atomic comparison conditions - * that do a greater-or-equal test between the parameter defined - * in the constructor and the argument of the operator - */ + * that do a greater-or-equal test between the parameter defined + * in the constructor and the argument of the operator + */ MvFilter operator>=(char* str); //! Greater-or-equal test for a double @@ -117,9 +117,9 @@ //! Greater-than test for a string /*! These three operators build atomic comparison conditions - * that do a greater-than test between the parameter defined - * in the constructor and the argument of the operator - */ + * that do a greater-than test between the parameter defined + * in the constructor and the argument of the operator + */ MvFilter operator>(char* str); //! Greater-than test for a double @@ -130,9 +130,9 @@ //! Less-than test for a string /*! These three operators build atomic comparison conditions - * that do a less-than test between the parameter defined - * in the constructor and the argument of the operator - */ + * that do a less-than test between the parameter defined + * in the constructor and the argument of the operator + */ MvFilter operator<(char* str); //! Less-than test for a double diff -Nru metview-5.17.4/metview/src/libMetview/MvFlexpart.cc metview-5.19.2/metview/src/libMetview/MvFlexpart.cc --- metview-5.17.4/metview/src/libMetview/MvFlexpart.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFlexpart.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,20 +42,20 @@ r.skipRecMarker(); r.skipRecMarker(); - interval = r.read(); + interval = r.read(); averagingInterval = r.read(); - samplingInterval = r.read(); + samplingInterval = r.read(); r.skipRecMarker(); r.skipRecMarker(); - west = r.read(); + west = r.read(); south = r.read(); - nx = r.read(); - ny = r.read(); - dx = r.read(); - dy = r.read(); + nx = r.read(); + ny = r.read(); + dx = r.read(); + dy = r.read(); north = south + (ny - 1) * dy; - east = west + (nx - 1) * dx; + east = west + (nx - 1) * dx; r.skipRecMarker(); r.skipRecMarker(); @@ -68,20 +68,20 @@ r.skipRecMarker(); r.skipRecMarker(); - specNum = r.read() / 3; + specNum = r.read() / 3; specPointNum = r.read(); r.skipRecMarker(); - //Species + // Species for (int i = 0; i < specNum; i++) { std::string wd, dd, sp; r.skipRecMarker(); - r.skip(4); //1 + r.skip(4); // 1 r.read(10, wd); r.skipRecMarker(); r.skipRecMarker(); - r.skip(4); //1 + r.skip(4); // 1 r.read(10, dd); r.skipRecMarker(); @@ -91,10 +91,10 @@ specNames.push_back(sp); r.skipRecMarker(); - //std::cout << "spec" << " " << i << " " << wd << " " << dd << " " << sp << std::endl; + // std::cout << "spec" << " " << i << " " << wd << " " << dd << " " << sp << std::endl; } - //Release points + // Release points r.skipRecMarker(); int releaseNum = r.read(); @@ -104,27 +104,27 @@ MvFlexpartRelease rel; r.skipRecMarker(); - rel.start = r.read(); - rel.end = r.read(); + rel.start = r.read(); + rel.end = r.read(); rel.levType = r.read(); r.skipRecMarker(); r.skipRecMarker(); - rel.west = r.read(); - rel.south = r.read(); - rel.east = r.read(); - rel.north = r.read(); + rel.west = r.read(); + rel.south = r.read(); + rel.east = r.read(); + rel.north = r.read(); rel.bottom = r.read(); - rel.top = r.read(); + rel.top = r.read(); r.skipRecMarker(); r.skipRecMarker(); rel.num = r.read(); - r.skip(4); //1 + r.skip(4); // 1 r.skipRecMarker(); r.skipRecMarker(); - r.read(45, rel.name); //compoint + r.read(45, rel.name); // compoint r.skipRecMarker(); for (int j = 0; j < specNum; j++) { @@ -145,11 +145,11 @@ } r.skipRecMarker(); - method = r.read(); - hasSubGrid = r.read(); + method = r.read(); + hasSubGrid = r.read(); hasConvection = r.read(); - indSource = r.read(); - indReceptor = r.read(); + indSource = r.read(); + indReceptor = r.read(); r.skipRecMarker(); r.skipRecMarker(); @@ -172,7 +172,7 @@ } } #endif - //delete [] d; + // delete [] d; } void MvFlexpartHeader::print() @@ -249,7 +249,7 @@ std::string line; - //run date and time + // run date and time while (getline(in, line)) { std::string dateStr = line.substr(0, 7); std::string timeStr = line.substr(8, 13); diff -Nru metview-5.17.4/metview/src/libMetview/MvFlextra.cc metview-5.19.2/metview/src/libMetview/MvFlextra.cc --- metview-5.17.4/metview/src/libMetview/MvFlextra.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFlextra.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,8 @@ #include "MvDate.h" -//This is how flextra writes out the trajectory output in trajout.f -//format(i9,2f9.4,f7.4,f7.1,2f8.1,f8.3,f6.1,e9.2) +// This is how flextra writes out the trajectory output in trajout.f +// format(i9,2f9.4,f7.4,f7.1,2f8.1,f8.3,f6.1,e9.2) static const int fieldWidthArr[] = {9, 9, 9, 7, 7, 8, 8, 8, 6, 9}; static std::vector fieldWidthVec(fieldWidthArr, fieldWidthArr + sizeof(fieldWidthArr) / sizeof(fieldWidthArr[0])); @@ -34,27 +34,27 @@ MvFlextraItem::MvFlextraItem(int id) : id_(id) { - pointKeyIndex_["date"] = 0; - pointKeyIndex_["elapsedTime"] = 1; - pointKeyIndex_["lon"] = 2; - pointKeyIndex_["lat"] = 3; - pointKeyIndex_["eta"] = 4; - pointKeyIndex_["pres"] = 5; - pointKeyIndex_["z"] = 6; + pointKeyIndex_["date"] = 0; + pointKeyIndex_["elapsedTime"] = 1; + pointKeyIndex_["lon"] = 2; + pointKeyIndex_["lat"] = 3; + pointKeyIndex_["eta"] = 4; + pointKeyIndex_["pres"] = 5; + pointKeyIndex_["z"] = 6; pointKeyIndex_["zAboveGround"] = 7; - pointKeyIndex_["pv"] = 8; - pointKeyIndex_["theta"] = 9; + pointKeyIndex_["pv"] = 8; + pointKeyIndex_["theta"] = 9; - pointKeyType_["date"] = DateType; - pointKeyType_["elapsedTime"] = IntType; - pointKeyType_["lon"] = FloatType; - pointKeyType_["lat"] = FloatType; - pointKeyType_["eta"] = FloatType; - pointKeyType_["pres"] = FloatType; - pointKeyType_["z"] = FloatType; + pointKeyType_["date"] = DateType; + pointKeyType_["elapsedTime"] = IntType; + pointKeyType_["lon"] = FloatType; + pointKeyType_["lat"] = FloatType; + pointKeyType_["eta"] = FloatType; + pointKeyType_["pres"] = FloatType; + pointKeyType_["z"] = FloatType; pointKeyType_["zAboveGround"] = FloatType; - pointKeyType_["pv"] = FloatType; - pointKeyType_["theta"] = FloatType; + pointKeyType_["pv"] = FloatType; + pointKeyType_["theta"] = FloatType; } std::string MvFlextraItem::metaData(const std::string& key) const @@ -94,8 +94,8 @@ MvFlextraBlock::MvFlextraBlock() { - direction_ = "Forward"; - constantStep_ = true; + direction_ = "Forward"; + constantStep_ = true; uncertaintyTr_ = false; } @@ -117,8 +117,8 @@ void MvFlextraBlock::decode(std::ifstream& in, std::string& line) { - bool headerPassed = false; - bool firstRowPassed = false; + bool headerPassed = false; + bool firstRowPassed = false; bool directionDetected = false; std::map trTypeName; @@ -135,7 +135,7 @@ int cnt = 0; - //Read meta-data first + // Read meta-data first metaData_["Metview::type"] = "FLEXTRA"; @@ -165,8 +165,8 @@ metaData_["cflTime"] = value; else if (parseHeaderLine(line, "START POINT COMMENT:", value)) { metaData_["startComment"] = value; - metaData_["name"] = value; - comment_ = value; + metaData_["name"] = value; + comment_ = value; } else if (parseHeaderLine(line, "MODEL RUN COMMENT:", value)) metaData_["runComment"] = value; @@ -198,12 +198,12 @@ std::ostringstream sst_cnt; sst_cnt << cnt; - //Parse "Date:" line + // Parse "Date:" line std::istringstream sst(line); std::string s, sDate, sTime, sIndex; sst >> s >> sDate >> s >> sTime >> s >> s >> sIndex; - s = sDate; + s = sDate; sDate = s.substr(0, 4) + "-" + s.substr(4, 2) + "-" + s.substr(6, 2); s = sTime; @@ -212,7 +212,7 @@ } sTime = s.substr(0, 2) + ":" + s.substr(3, 2) + ":" + s.substr(4, 2); - s = sDate + " " + sTime; + s = sDate + " " + sTime; baseDate = MvDate(s.c_str()); item->addMetaData("startDate", sDate); @@ -220,7 +220,7 @@ item->addMetaData("id", sst_cnt.str()); item->addMetaData("stopIndex", sIndex); - //Initialise the rest of the meta-data + // Initialise the rest of the meta-data item->addMetaData("startLat", "-"); item->addMetaData("startLon", "-"); item->addMetaData("startEta", "-"); @@ -230,10 +230,10 @@ item->addMetaData("startPv", "-"); item->addMetaData("startTheta", "-"); - //Get header line + // Get header line getline(in, line); - headerPassed = true; + headerPassed = true; firstRowPassed = false; } else if (headerPassed) { @@ -263,12 +263,12 @@ direction_ = "Backward"; } metaData_["direction"] = direction_; - directionDetected = true; + directionDetected = true; } } - //Parse the line with the data taking the widths form the - //original flextra ouput fortran FORMAT statement + // Parse the line with the data taking the widths form the + // original flextra ouput fortran FORMAT statement std::vector pointData; int pos = 0; for (size_t i = 0; i < fieldWidthVec.size(); i++) { @@ -297,8 +297,8 @@ ssNum << items_.size(); metaData_["trNum"] = ssNum.str(); - //Find meta-data that is the same for all the trajectories - //Check lat-lon + // Find meta-data that is the same for all the trajectories + // Check lat-lon if (isMetaDataConst("startLat") && isMetaDataConst("startLon")) { metaData_["startLat"] = items_.at(0)->metaData("startLat"); metaData_["startLon"] = items_.at(0)->metaData("startLon"); @@ -316,11 +316,11 @@ } } - //Check the timestep type (constant ot non-constant) + // Check the timestep type (constant ot non-constant) checkStepType(); - //in.close(); + // in.close(); } @@ -332,7 +332,7 @@ metaDataCnt = 0; writeMetaData(out, metaDataCnt); - //Write out trajectory data + // Write out trajectory data for (auto item : items_) { for (const auto& P : item->points()) { out << item->id(); @@ -354,7 +354,7 @@ metaDataCnt = 0; writeMetaData(out, metaDataCnt); - //Write out trajectory data + // Write out trajectory data for (auto item : items_) { for (auto itP = item->points().begin(); itP != item->points().end(); itP++) { const std::vector& data = (*itP); @@ -398,7 +398,7 @@ metaDataCnt = 0; writeMetaData(out, metaDataCnt); - //Write out trajectory data + // Write out trajectory data for (auto item : items_) { for (const auto& data : item->points()) { if (data.size() > 0) { @@ -439,14 +439,14 @@ { metaDataCnt = 0; - //Write out global meta-data + // Write out global meta-data for (auto it = metaData_.begin(); it != metaData_.end(); it++) { out << it->first + "=" + it->second << " "; } out << "direction=" << direction_ << std::endl; metaDataCnt++; - //Write out trajectory meta-data + // Write out trajectory meta-data std::string keys[12] = {"id", "startDate", "startTime", "startLat", "startLon", "startEta", "startPres", "startZ", "startZAboveGround", "startPv", "startTheta", "stopIndex"}; @@ -543,7 +543,7 @@ double prev; iss1 >> prev; - double diff = prev - first; + double diff = prev - first; bool sameDiff = true; for (unsigned int i = 2; i < item->points().size() && i < 6; i++) { std::istringstream iss(item->points().at(i).at(1)); @@ -605,13 +605,13 @@ in.close(); - //Guess if a trajectory block contains uncertainty trajecories or not! - //It is working only if the FLEXTRA file containing several blocks was - //generated by metview. + // Guess if a trajectory block contains uncertainty trajecories or not! + // It is working only if the FLEXTRA file containing several blocks was + // generated by metview. std::vector > ref; for (auto& block : blocks_) { std::string comment = block->comment(); - bool cstep = block->constantStep(); + bool cstep = block->constantStep(); std::pair p = make_pair(comment, cstep); diff -Nru metview-5.17.4/metview/src/libMetview/MvFlextra.h metview-5.19.2/metview/src/libMetview/MvFlextra.h --- metview-5.17.4/metview/src/libMetview/MvFlextra.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFlextra.h 2023-07-15 08:28:47.000000000 +0000 @@ -78,7 +78,7 @@ bool isMetaDataConst(const std::string& key); void checkStepType(); - //std::string fileName_; + // std::string fileName_; std::string comment_; std::string direction_; std::map metaData_; diff -Nru metview-5.17.4/metview/src/libMetview/MvFortran.cc metview-5.19.2/metview/src/libMetview/MvFortran.cc --- metview-5.17.4/metview/src/libMetview/MvFortran.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFortran.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ { MvRequest r("NUMBER"); r("VALUE") = x; - Param = Param + r; + Param = Param + r; Param.save(Temp); } @@ -41,7 +41,7 @@ { MvRequest r("STRING"); r("VALUE") = x; - Param = Param + r; + Param = Param + r; Param.save(Temp); } diff -Nru metview-5.17.4/metview/src/libMetview/MvFortran.h metview-5.19.2/metview/src/libMetview/MvFortran.h --- metview-5.17.4/metview/src/libMetview/MvFortran.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFortran.h 2023-07-15 08:28:47.000000000 +0000 @@ -37,9 +37,9 @@ public: //! Constructor /*! Argument \c name is used in messages for identification.\n \n - * Constructor reserves an empty file for the "Fortranized" request - * and assigns environment variable \c MREQUEST to point to this file. - */ + * Constructor reserves an empty file for the "Fortranized" request + * and assigns environment variable \c MREQUEST to point to this file. + */ MvFortran(const char* name); //! Destructor diff -Nru metview-5.17.4/metview/src/libMetview/MvFunction.cc metview-5.19.2/metview/src/libMetview/MvFunction.cc --- metview-5.17.4/metview/src/libMetview/MvFunction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFunction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,8 @@ MvFunction::MvFunction(const char* name, const argdef* args) { Arguments = args; - Count = 0; - Name = strcache(name); + Count = 0; + Name = strcache(name); while (args->name) { Count++; @@ -30,7 +30,7 @@ if (First == nullptr) support_recording(MvApplication::getService()); - Next = First; + Next = First; First = this; add_function_callback(MvApplication::getService(), Name, _serve, diff -Nru metview-5.17.4/metview/src/libMetview/MvFwd.h metview-5.19.2/metview/src/libMetview/MvFwd.h --- metview-5.17.4/metview/src/libMetview/MvFwd.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvFwd.h 2023-07-15 08:28:47.000000000 +0000 @@ -9,6 +9,8 @@ #pragma once +#include + enum class MvLogLevel { INFO, @@ -17,3 +19,9 @@ DBG }; class MvApplication; + +namespace metview +{ +class StatsCompute; +using StatsComputePtr = std::shared_ptr; +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/MvGeoPoints.cc metview-5.19.2/metview/src/libMetview/MvGeoPoints.cc --- metview-5.17.4/metview/src/libMetview/MvGeoPoints.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvGeoPoints.cc 2023-07-15 08:28:47.000000000 +0000 @@ -70,7 +70,7 @@ void MvGeoPointColumnInfo::ensureOnlyOneValueColumn() { // resize the column arrays to have only one elment, 'value' - nvalcols_ = 1; + nvalcols_ = 1; nvalcolsforcompute_ = 1; colTypes_.resize(ncoordcols_ + nvalcols_); colNames_.resize(ncoordcols_); @@ -121,8 +121,8 @@ _stringOrNumber(buf); - //if (gfmt_ == eGeoString) // update the 'global' geo format? - // geoFmt = eGeoString; + // if (gfmt_ == eGeoString) // update the 'global' geo format? + // geoFmt = eGeoString; } set_lat_y(d_latitude); @@ -203,8 +203,8 @@ void MvGeoPoints::_stringOrNumber(char* buf) { bool isNumeric = true; - int dcnt = 0; - char* p = buf; + int dcnt = 0; + char* p = buf; if (*p == '-' || *p == '+') //-- sign is OK ++p; @@ -268,7 +268,7 @@ MvGeoPoints::column(size_t row, size_t col, MvGeoPointColumnInfo& colinfo, int& type) { size_t totalcols = colinfo.ncoordcols_ + colinfo.nvalcols_; - type = eGeoVDouble; + type = eGeoVDouble; if (col < 0 || col >= totalcols) return "BAD COLUMN INDEX"; @@ -368,7 +368,7 @@ std::ostream& operator<<(std::ostream& aStream, const MvGeop1Writer& gpw) { - MvGeoPoints& gp = gpw.gp_; + MvGeoPoints& gp = gpw.gp_; const char cSeparator[] = "\t"; @@ -376,8 +376,8 @@ // was being written to the start of each value line. I have now (July 2018) // removed this, for time and file size efficiency. - //const char cStartOfLine[] = " "; - //aStream << cStartOfLine; + // const char cStartOfLine[] = " "; + // aStream << cStartOfLine; // General note about precision settings: we must be careful if a @@ -490,15 +490,15 @@ const std::map& MvGeoPoints::coordColMap() { if (coordColMap_.empty()) { - coordColMap_["latitude"] = eGeoColLat; + coordColMap_["latitude"] = eGeoColLat; coordColMap_["longitude"] = eGeoColLon; - coordColMap_["level"] = eGeoColLevel; + coordColMap_["level"] = eGeoColLevel; coordColMap_["elevation"] = eGeoColElevation; - coordColMap_["date"] = eGeoColDate; - coordColMap_["time"] = eGeoColTime; - coordColMap_["stnid"] = eGeoColStnId; - coordColMap_["value"] = eGeoColValue; - coordColMap_["value2"] = eGeoColValue2; + coordColMap_["date"] = eGeoColDate; + coordColMap_["time"] = eGeoColTime; + coordColMap_["stnid"] = eGeoColStnId; + coordColMap_["value"] = eGeoColValue; + coordColMap_["value2"] = eGeoColValue2; } return coordColMap_; } @@ -506,7 +506,7 @@ eGeoColType MvGeoPoints::colTypeFromName(const std::string& name, bool failIfUnknown) { auto& colmap = coordColMap(); - auto it = colmap.find(name); + auto it = colmap.find(name); if (it == colmap.end()) if (failIfUnknown) return eGeoColError; @@ -597,33 +597,33 @@ { unload(); - gfmt_ = gp.format(); - count_ = gp.count(); - sgfmt_ = gp.format(); + gfmt_ = gp.format(); + count_ = gp.count(); + sgfmt_ = gp.format(); colInfo_ = gp.colInfo_; - vi_ = 0; - r_ = 0; + vi_ = 0; + r_ = 0; if (mode == eGeoCopyAll) { - dbSystem_ = gp.dbSystem(); - dbColumn_ = gp.dbColumn(); + dbSystem_ = gp.dbSystem(); + dbColumn_ = gp.dbColumn(); dbColumnAlias_ = gp.dbColumnAlias(); - dbPath_ = gp.dbPath(); - dbQuery_ = gp.dbQuery(); - metadata_ = gp.metadataConst(); + dbPath_ = gp.dbPath(); + dbQuery_ = gp.dbQuery(); + metadata_ = gp.metadataConst(); } else { colInfo_.ensureOnlyOneValueColumn(); } if (count() > 0) { - strings_ = gp.strings_; - latitudes_ = gp.latitudes_; - longitudes_ = gp.longitudes_; - heights_ = gp.heights_; - elevations_ = gp.elevations_; - dates_ = gp.dates_; - times_ = gp.times_; + strings_ = gp.strings_; + latitudes_ = gp.latitudes_; + longitudes_ = gp.longitudes_; + heights_ = gp.heights_; + elevations_ = gp.elevations_; + dates_ = gp.dates_; + times_ = gp.times_; bool copyAll = (mode == eGeoCopyAll); if (copyAll) { values_ = gp.values_; @@ -640,13 +640,13 @@ void MvGeoPoints::copyRow(const MvGeoPoints& src, size_t srcRow, size_t destRow) { - strings_[destRow] = src.strings_[srcRow]; // XXX do we always need to copy this? - latitudes_[destRow] = src.latitudes_[srcRow]; + strings_[destRow] = src.strings_[srcRow]; // XXX do we always need to copy this? + latitudes_[destRow] = src.latitudes_[srcRow]; longitudes_[destRow] = src.longitudes_[srcRow]; - heights_[destRow] = src.heights_[srcRow]; + heights_[destRow] = src.heights_[srcRow]; elevations_[destRow] = src.elevations_[srcRow]; - dates_[destRow] = src.dates_[srcRow]; - times_[destRow] = src.times_[srcRow]; + dates_[destRow] = src.dates_[srcRow]; + times_[destRow] = src.times_[srcRow]; for (size_t i = 0; i < nValCols(); i++) { values_[i][destRow] = src.values_[i][srcRow]; @@ -696,8 +696,8 @@ //_____________________________________________________________________ bool MvGeoPoints::areRowsEqual(size_t r1, size_t r2) { - //if (gfmt_ != in.gfmt_) - // return false; + // if (gfmt_ != in.gfmt_) + // return false; if (lat_y(r1) != lat_y(r2)) return false; if (lon_x(r1) != lon_x(r2)) @@ -904,7 +904,7 @@ // for each string on the line colInfo_.ncoordcols_ = 0; - bool valcols = false; // co-ordinate cols first, then value cols + bool valcols = false; // co-ordinate cols first, then value cols clearColNames(); clearColTypes(); @@ -980,8 +980,8 @@ bool MvGeoPoints::load(std::ifstream& f, const size_t nmax) { char line[10240]; - size_t n = 0; - int numPts = 0; + size_t n = 0; + int numPts = 0; std::streampos sp = f.tellg(); @@ -997,12 +997,12 @@ f.clear(); f.seekg(sp); - //f.seekg(0, std::ios::beg); + // f.seekg(0, std::ios::beg); gfmt_ = eGeoTraditional; bool metadata = false; - bool db_info = false; + bool db_info = false; bool db_query = false; bool colnames = false; @@ -1054,7 +1054,7 @@ else if (strncmp(line, "#METADATA", 9) == 0) // start of meta-data { metadata = true; - db_info = false; + db_info = false; } else if (metadata == true) // within the meta-data block @@ -1068,49 +1068,49 @@ } - //Information about the database, query etc. that - //generated the geopoints file + // Information about the database, query etc. that + // generated the geopoints file else if (strncmp(line, "#DB_INFO ", 8) == 0) { - db_info = true; + db_info = true; metadata = false; } else if (db_info == true && strstr(line, "DB_SYSTEM:") != 0) { std::string sbuf(line); std::string::size_type pos = sbuf.find("DB_SYSTEM:"); - sbuf = sbuf.substr(pos + 10); - dbSystem_ = sbuf; + sbuf = sbuf.substr(pos + 10); + dbSystem_ = sbuf; } else if (db_info == true && strstr(line, "DB_COLUMN:") != 0) { std::string sbuf(line); std::string::size_type pos = sbuf.find("DB_COLUMN:"); - sbuf = sbuf.substr(pos + 10); + sbuf = sbuf.substr(pos + 10); std::vector sv; Tokenizer parse(";"); parse(sbuf, sv); if (gfmt_ == eGeoTraditional && sv.size() == 6) { - dbColumn_["lat"] = sv[0]; - dbColumn_["lon"] = sv[1]; + dbColumn_["lat"] = sv[0]; + dbColumn_["lon"] = sv[1]; dbColumn_["level"] = sv[2]; - dbColumn_["date"] = sv[3]; - dbColumn_["time"] = sv[4]; + dbColumn_["date"] = sv[3]; + dbColumn_["time"] = sv[4]; dbColumn_["value"] = sv[5]; } else if (gfmt_ == eGeoXYV && sv.size() == 3) { - dbColumn_["lon"] = sv[0]; - dbColumn_["lat"] = sv[1]; + dbColumn_["lon"] = sv[0]; + dbColumn_["lat"] = sv[1]; dbColumn_["value"] = sv[2]; } else if ((gfmt_ == eGeoVectorPolar || gfmt_ == eGeoVectorXY) && sv.size() == 7) { - dbColumn_["lat"] = sv[0]; - dbColumn_["lon"] = sv[1]; - dbColumn_["level"] = sv[2]; - dbColumn_["date"] = sv[3]; - dbColumn_["time"] = sv[4]; - dbColumn_["value"] = sv[5]; + dbColumn_["lat"] = sv[0]; + dbColumn_["lon"] = sv[1]; + dbColumn_["level"] = sv[2]; + dbColumn_["date"] = sv[3]; + dbColumn_["time"] = sv[4]; + dbColumn_["value"] = sv[5]; dbColumn_["value2"] = sv[6]; } } @@ -1118,32 +1118,32 @@ else if (db_info == true && strstr(line, "DB_COLUMN_ALIAS:") != 0) { std::string sbuf(line); std::string::size_type pos = sbuf.find("DB_COLUMN_ALIAS:"); - sbuf = sbuf.substr(pos + 16); + sbuf = sbuf.substr(pos + 16); std::vector sv; Tokenizer parse(";"); parse(sbuf, sv); if (gfmt_ == eGeoTraditional && sv.size() == 6) { - dbColumnAlias_["lat"] = sv[0]; - dbColumnAlias_["lon"] = sv[1]; + dbColumnAlias_["lat"] = sv[0]; + dbColumnAlias_["lon"] = sv[1]; dbColumnAlias_["level"] = sv[2]; - dbColumnAlias_["date"] = sv[3]; - dbColumnAlias_["time"] = sv[4]; + dbColumnAlias_["date"] = sv[3]; + dbColumnAlias_["time"] = sv[4]; dbColumnAlias_["value"] = sv[5]; } else if (gfmt_ == eGeoXYV && sv.size() == 3) { - dbColumnAlias_["lon"] = sv[0]; - dbColumnAlias_["lat"] = sv[1]; + dbColumnAlias_["lon"] = sv[0]; + dbColumnAlias_["lat"] = sv[1]; dbColumnAlias_["value"] = sv[2]; } else if ((gfmt_ == eGeoVectorPolar || gfmt_ == eGeoVectorXY) && sv.size() == 7) { - dbColumnAlias_["lat"] = sv[0]; - dbColumnAlias_["lon"] = sv[1]; - dbColumnAlias_["level"] = sv[2]; - dbColumnAlias_["date"] = sv[3]; - dbColumnAlias_["time"] = sv[4]; - dbColumnAlias_["value"] = sv[5]; + dbColumnAlias_["lat"] = sv[0]; + dbColumnAlias_["lon"] = sv[1]; + dbColumnAlias_["level"] = sv[2]; + dbColumnAlias_["date"] = sv[3]; + dbColumnAlias_["time"] = sv[4]; + dbColumnAlias_["value"] = sv[5]; dbColumnAlias_["value2"] = sv[6]; } } @@ -1151,8 +1151,8 @@ else if (db_info == true && strstr(line, "DB_PATH:") != 0) { std::string sbuf(line); std::string::size_type pos = sbuf.find("DB_PATH:"); - sbuf = sbuf.substr(pos + 8); - dbPath_ = sbuf; + sbuf = sbuf.substr(pos + 8); + dbPath_ = sbuf; } else if (db_info == true && strstr(line, "DB_QUERY_BEGIN") != 0) { @@ -1174,15 +1174,9 @@ newReservedSize(numPts); - - db_info = false; - db_query = false; - metadata = false; - // Read data if (nmax == 0) { - bool inSameGpts = true; // used when in a geopointset file - while (f.getline(line, sizeof(line)) && inSameGpts) { + while (f.getline(line, sizeof(line))) { if ((*line != '#') && (strlen(line) > 4)) { if (n == 0 && gfmt_ == eGeoNCols) { // first time only - count the number of values @@ -1199,7 +1193,6 @@ } else if (!strncmp(line, "#GEO", 4)) // start of new geopoints file { - inSameGpts = false; break; } } @@ -1323,7 +1316,7 @@ auto it = md.begin(); while (it != md.end()) { std::string key = it->first; - MvVariant val = it->second; + MvVariant val = it->second; fout << key << "=" << val.toString() << std::endl; it++; } @@ -1471,7 +1464,7 @@ //-- several latitude band lists; //-- here we define the width and the number of these latitude bands const double cLatBandSize = 1.0; - const int cLatBandCount = (int)(180.0 / cLatBandSize) + 1; + const int cLatBandCount = (int)(180.0 / cLatBandSize) + 1; //-- STL provides tools for sorting std::vector > LatListVec; @@ -1603,14 +1596,14 @@ if (colInfo_.colTypes_.size()) colInfo_.colTypes_.clear(); - colInfo_.ncoordcols_ = 5; // should be 5, but 4 will give us numvals=2 for backwards compatibility + colInfo_.ncoordcols_ = 5; // should be 5, but 4 will give us numvals=2 for backwards compatibility colInfo_.nvalcolsforcompute_ = 1; // all formats except xy_vector and ncols only operate on one column hasStnIds(false); // assume they're not there unless we read them or the user sets them hasElevations(false); // assume they're not there unless we read them or the user sets them if (gfmt_ == eGeoTraditional || gfmt_ == eGeoString) { - sgfmt_ = "Traditional"; + sgfmt_ = "Traditional"; colInfo_.ncols_ = 6; nValCols(1); colInfo_.colNames_.reserve(colInfo_.ncols_); @@ -1622,7 +1615,7 @@ addColName("value"); } else if (gfmt_ == eGeoXYV) { - sgfmt_ = "XYV"; + sgfmt_ = "XYV"; colInfo_.ncols_ = 3; nValCols(1); colInfo_.ncoordcols_ = 2; @@ -1632,7 +1625,7 @@ addColName("value"); } else if (gfmt_ == eGeoVectorPolar) { - sgfmt_ = "Polar_Vector"; + sgfmt_ = "Polar_Vector"; colInfo_.ncols_ = 7; nValCols(2); colInfo_.nvalcolsforcompute_ = 1; @@ -1646,7 +1639,7 @@ addColName("angle"); } else if (gfmt_ == eGeoVectorXY) { - sgfmt_ = "XY_Vector"; + sgfmt_ = "XY_Vector"; colInfo_.ncols_ = 7; nValCols(2); colInfo_.nvalcolsforcompute_ = 2; @@ -1661,7 +1654,7 @@ } else if (gfmt_ == eGeoNCols) { - sgfmt_ = "NCols"; + sgfmt_ = "NCols"; colInfo_.ncols_ = 7; nValCols(0); colInfo_.ncoordcols_ = 7; diff -Nru metview-5.17.4/metview/src/libMetview/MvGeoPoints.h metview-5.19.2/metview/src/libMetview/MvGeoPoints.h --- metview-5.17.4/metview/src/libMetview/MvGeoPoints.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvGeoPoints.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,7 +34,7 @@ #define GEOPOINTS_MISSING_VALUE 3.0E+38 -//const double cIsStringValue = 0.5e37; +// const double cIsStringValue = 0.5e37; //! \enum eGeoFormat Enum for different geopoints file types enum eGeoFormat @@ -169,7 +169,7 @@ public: static const size_t INVALID_INDEX = std::numeric_limits::max(); - typedef std::map metadata_t; + using metadata_t = std::map; // constructors @@ -301,7 +301,7 @@ } - //void set_value_missing(size_t r, size_t c) { value(c, r, GEOPOINTS_MISSING_VALUE); } + // void set_value_missing(size_t r, size_t c) { value(c, r, GEOPOINTS_MISSING_VALUE); } void set_value_missing() { set_value(GEOPOINTS_MISSING_VALUE); } // use row r_ and default val col void set_value_missing(size_t c) { set_ivalue(GEOPOINTS_MISSING_VALUE, c); } void set_value_missing(size_t r, size_t c) { set_ivalue(GEOPOINTS_MISSING_VALUE, r, c); } @@ -322,7 +322,7 @@ //! Resets the size of MvGeoPoints object to be \c n points /*! Old points are deleted and \c n new empty points are created. - */ + */ void newReservedSize(size_t n, bool init = true); void copy(const MvGeoPoints& gp, eGeoCopyMode mode = eGeoCopyAll); @@ -364,7 +364,7 @@ void nValColsForCompute(size_t n) { colInfo_.nvalcolsforcompute_ = n; } void nValCols(size_t n) { - colInfo_.nvalcols_ = n; + colInfo_.nvalcols_ = n; colInfo_.nvalcolsforcompute_ = n; resizeValueColumns(); } @@ -386,7 +386,7 @@ //! Returns whether another geopoints variable is compatible with this one in terms of columns - bool isCompatibleForMerging(const MvGeoPoints& in) { return colInfo_.isCompatibleForMerging(in.colInfo_);} //colInfo_ == in.colInfo_; } + bool isCompatibleForMerging(const MvGeoPoints& in) { return colInfo_.isCompatibleForMerging(in.colInfo_); } // colInfo_ == in.colInfo_; } //! Returns index of the named value (e.g. 'temperature'), or -1 if it does not exist for this data @@ -425,19 +425,19 @@ //! Removes duplicate geopoints /*! First all points are sorted using sort() and then all duplicate - * points are removed. Operator MvGeoP1::operator== is used to - * test the equality. - */ + * points are removed. Operator MvGeoP1::operator== is used to + * test the equality. + */ void removeDuplicates(); //! Offsets the latitude/longitude values /*! This method can be used to print values from two or more - * MvGeoPoints objects containing same locations, to prevent - * the values to be printed on top of each other.\n \n - * Note that the offset values are given in degrees and thus - * the visual offset on the plot depends on the scale of - * the plot (which also depends on the level of zooming). - */ + * MvGeoPoints objects containing same locations, to prevent + * the values to be printed on top of each other.\n \n + * Note that the offset values are given in degrees and thus + * the visual offset on the plot depends on the scale of + * the plot (which also depends on the level of zooming). + */ void offset(double latOffset, double lonOffset); void location(double lat, double lon); //{ latitude_=lat; longitude_=lon; } @@ -445,7 +445,7 @@ //! Returns the index of the first point not having a missing value /*! Note: index starts from zero. - */ + */ size_t indexOfFirstValidPoint(size_t c = 0) const; diff -Nru metview-5.17.4/metview/src/libMetview/MvGrid.cc metview-5.19.2/metview/src/libMetview/MvGrid.cc --- metview-5.17.4/metview/src/libMetview/MvGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,9 @@ #include #include +#include #include +#include #include #include #include @@ -24,6 +26,7 @@ #include "MvGrid.h" #include "MvException.h" #include "proj_braz.hpp" +#include "MvLog.h" // define this if you want to use a version of MvLatLonGrid::interpolatePoint() // which uses built_in ecCodes functions to get the nearest 4 points. @@ -36,14 +39,15 @@ GaussianLatitudes MvGaussianGridBase::gLatitudes_; // global variable for the class +const double cFullGlobeD = 360.; const double cFullGlobeLimitX = 359.9; const double cFullGlobeLimitY = 179.9; -const double cGridEpsilon = 5e-5; //-- 0.05 millidegrees -const double cToRadians = M_PI / 180.0; +const double cGridEpsilon = 5e-5; //-- 0.05 millidegrees +const double cToRadians = M_PI / 180.0; const double cEarthRadius = 6371200.0; //-- MARS code -//const double cEarthRadius = 6367470.0; //-- WMO, for GRIB headers -//const double cEarthRadius = 6371221.3; //-- NCAR Fortran routines +// const double cEarthRadius = 6367470.0; //-- WMO, for GRIB headers +// const double cEarthRadius = 6371221.3; //-- NCAR Fortran routines //-- temporary function: @@ -64,18 +68,48 @@ void MvGridPoint::sortByDistance(std::vector& points, const MvLocation& refPoint) { - std::vector > sortVec; - for (size_t i = 0; i < points.size(); i++) { - sortVec.push_back(std::make_pair(i, refPoint.distanceInMeters(points[i].loc_))); + using SortD = std::pair; + std::vector sortVec; + for (auto const &p: points) { + sortVec.push_back(std::make_pair(p, refPoint.distanceInMeters(p.loc_))); } - static auto sortFunc = [](const std::pair& a, const std::pair& b) { return a.second < b.second; }; - std::sort(sortVec.begin(), sortVec.end(), sortFunc); + auto sortFunc = [&refPoint](const SortD& a, const SortD& b) { + if (a.second < b.second) {return true;} + else if (a.second > b.second) {return false;} + // if the distance is the same + else { + // we prefer the one closer in longitude + auto d1 = std::fabs(a.first.loc_.longitude() - refPoint.longitude()); + auto d2 = std::fabs(b.first.loc_.longitude() - refPoint.longitude()); + if (d1 < d2) { return true;} + else if (d1 > d2) {return false;} + // if the longitudes are equally close + else { + // prefers the smaller longitude + if (a.first.loc_.longitude() < b.first.loc_.longitude()) { + return true; + } else if (a.first.loc_.longitude() > b.first.loc_.longitude()) { + return false; + // if the logitudes are the same we prefer the one closer in latutude + } else { + d1 = std::fabs(a.first.loc_.latitude() - refPoint.latitude()); + d2 = std::fabs(b.first.loc_.latitude() - refPoint.latitude()); + return (d1 < d2); + } + } + } + return a.first.index_ < b.first.index_; + }; + + std::stable_sort(sortVec.begin(), sortVec.end(), sortFunc); - std::vector tmp = points; + assert(points.size() == sortVec.size()); for (size_t i = 0; i < points.size(); i++) { - int idx = sortVec[i].first; - points[i] = tmp[idx]; + points[i] = sortVec[i].first; +// std::cout << std::setprecision(26) << " idx=" << points[i].index_+1 << " lon=" << +// points[i].loc_.longitude() << " " << +// refPoint.longitude() << " dist=" << sortVec[i].second << std::endl; } } @@ -132,14 +166,13 @@ // to delete the values and go back from expand_mem to packed mem in a safe way. if (field_->shape == expand_mem) { release_mem(field_->values); - field_->values = NULL; + field_->values = NULL; field_->value_count = 0; - field_->shape = packed_mem; + field_->shape = packed_mem; } } if (memoryToBeReleased_) { - // see comment below, and note that mars_free_field will() decrement field_->refcnt first and if // it is <=0 it will completely deallocate the field_!!! bool restore_field_state = restoreShapeOnDestroy_ && (field_->refcnt > 1); @@ -172,7 +205,7 @@ if (err == GRIB_SUCCESS) { size_t len; - err = grib_get_size(fld->handle, name, &len); + err = grib_get_size(fld->handle, name, &len); bool array = (len > 1); if (err == GRIB_SUCCESS) { switch (valueType) { @@ -240,7 +273,7 @@ if (!err1 && numVals != 0) { *lvals = (long*)malloc(numVals * sizeof(long)); - err2 = grib_get_long_array(fld->handle, name, *lvals, &numVals); + err2 = grib_get_long_array(fld->handle, name, *lvals, &numVals); } if (err1 || err2) { @@ -281,7 +314,7 @@ << ">>> " << s << "\n" << ">>\n" << ">" << std::endl; - //throw MvException( s.c_str() ); + // throw MvException( s.c_str() ); return false; } @@ -293,6 +326,35 @@ { return setLong(field_, name, val); } + +//------------------------------------------------------ + +bool MvGridBase::setLongArray(field* fld, const char* name, long* val, size_t len) +{ + int err = grib_set_long_array(fld->handle, name, val, len); + if (err) { + std::string ge = grib_get_error_message(err); + std::string s("grib_set_long_array: error setting "); + s = s + name + " (" + ge + ")"; + marslog(LOG_WARN, "%s", s.c_str()); + std::cerr << ">>>>>-------------------------------------------------\n" + << ">>>>\n" + << ">>> " << s << "\n" + << ">>\n" + << ">" << std::endl; + // throw MvException( s.c_str() ); + return false; + } + + return true; +} + + +bool MvGridBase::setLongArray(const char* name, long* val, size_t len) +{ + return setLongArray(field_, name, val, len); +} + //------------------------------------------------------ double MvGridBase::getDouble(field* fld, const char* name, bool throwOnError, bool quiet) @@ -338,7 +400,7 @@ if (!err1 && numVals != 0) { *dvals = (double*)malloc(numVals * sizeof(double)); - err2 = grib_get_double_array(fld->handle, name, *dvals, &numVals); + err2 = grib_get_double_array(fld->handle, name, *dvals, &numVals); } if (err1 || err2) { @@ -379,7 +441,7 @@ << ">>> " << s << "\n" << ">>\n" << ">" << std::endl; - //throw MvException( s.c_str() ); + // throw MvException( s.c_str() ); return false; } return true; @@ -394,7 +456,7 @@ bool MvGridBase::setString(field* fld, const char* name, std::string& val) { size_t len = val.size(); - int err = grib_set_string(fld->handle, name, val.c_str(), &len); + int err = grib_set_string(fld->handle, name, val.c_str(), &len); if (err) { std::string ge = grib_get_error_message(err); std::string s("grib_set_string: error setting "); @@ -405,7 +467,7 @@ << ">>> " << s << "\n" << ">>\n" << ">" << std::endl; - //throw MvException( s.c_str() ); + // throw MvException( s.c_str() ); return false; } @@ -469,6 +531,47 @@ return validityDateTime(field_); } +double MvGridBase::yyyymmddFoh(field* fld) +{ + double dat = getDouble(fld, "dataDate"); + double tim = getDouble(fld, "time"); + return dat + tim / 2400.0; //--HHMM +} + +double MvGridBase::yyyymmddFoh() const +{ + return yyyymmddFoh(field_); +} + +double MvGridBase::stepFoh(field* fld) +{ + double d3 = getDouble(fld, "mars.step", false, true); // throw, quiet + if (d3 == DBL_MAX) { + d3 = getDouble(fld, "step", false, true); + if (d3 == DBL_MAX) { + d3 = getDouble(fld, "endStep", false, true); + if (d3 == DBL_MAX) + d3 = 0; // can't find a step key, so step=0 + } + } + + // https://apps.ecmwf.int/codes/grib/format/grib2/ctables/4/4 for the complete list + // note that 1 is hours, which is what we assume by default + long stepUnit = getLong(fld, "indicatorOfUnitOfTimeRange"); + if (stepUnit < 0) // means that the key could not be found, therefore assume 'hours' + stepUnit = 1; + + if (stepUnit == 0) // minutes + d3 /= 60.0; + + return d3 / 24.0; +} + +double MvGridBase::stepFoh() const +{ + return stepFoh(field_); +} + //------------------------------------------------------ long MvGridBase::vertCoordCoefPairCount() { @@ -491,8 +594,8 @@ if (!vertCoord_) //-- get vertical coordinate coefficients { auto nvc_st = (size_t)(nvccp * 2); - vertCoord_ = new double[nvc_st]; - int err = grib_get_double_array(field_->handle, "pv", vertCoord_, &nvc_st); + vertCoord_ = new double[nvc_st]; + int err = grib_get_double_array(field_->handle, "pv", vertCoord_, &nvc_st); if (err) { marslog(LOG_EROR, "MvGridBase::vertCoordCoefs: unable to access coefficients"); return false; @@ -624,7 +727,7 @@ init(); MvGridPoint myCurrentPoint = gridPoint(); MvGridPoint myClosestPoint = myCurrentPoint; - double myClosestDistance = myCurrentPoint.loc_.distanceInMeters(myPoint); + double myClosestDistance = myCurrentPoint.loc_.distanceInMeters(myPoint); for (int p = 1; p < length(); ++p) { advance(); @@ -632,7 +735,7 @@ if (!nearestValid || myCurrentPoint.value_ != mars.grib_missing_value) { double myDistance = myCurrentPoint.loc_.distanceInMeters(myPoint); if (myDistance < myClosestDistance) { - myClosestPoint = myCurrentPoint; + myClosestPoint = myCurrentPoint; myClosestDistance = myDistance; } } @@ -641,11 +744,11 @@ std::cout << "INFO: " << MvLocation(lat_y,lon_x) << ": nearest grid point at " - << myClosestPoint.loc_ - << ", distance " - << ( (int)(myClosestDistance/100.0) / 10.0 ) //-- xx.x km - << " km" - << std::endl; + << myClosestPoint.loc_ + << ", distance " + << ( (int)(myClosestDistance/100.0) / 10.0 ) //-- xx.x km + << " km" + << std::endl; */ return myClosestPoint; } @@ -676,11 +779,11 @@ //-- to access values (via MARS interface) msg needs to be expanded // Aug 2008 - no, MvGrid is no longer just for accessing grid values // - don't *assume* that we want the values at all now. - //ir set_field_state( field_, expand_mem ); + // ir set_field_state( field_, expand_mem ); currentIndex_ = 0; - currentLaty_ = firstLatY(); - currentLonx_ = firstLonX(); + currentLaty_ = firstLatY(); + currentLonx_ = firstLonX(); } //------------------------------------------------------ @@ -718,14 +821,14 @@ marslog(LOG_INFO, "average_xx: grid interval negative or zero, set to 1"); } - double dif = (E - W) - 360.0; //-- check if E/W boarders coincide + double dif = (E - W) - cFullGlobeD; //-- check if E/W boarders coincide bool isGlobalEW = dif < cEps && dif > -cEps; double halfGrid = grid / 2; - double N2 = N + halfGrid; - double W2 = W - halfGrid; - double S2 = S - halfGrid + cEps / 4; //-- full half grid may introduce index overflows! - double E2 = E + halfGrid - cEps / 4; + double N2 = N + halfGrid; + double W2 = W - halfGrid; + double S2 = S - halfGrid + cEps / 4; //-- full half grid may introduce index overflows! + double E2 = E + halfGrid - cEps / 4; MvGeoBox box(N2, W2, S2, E2); if (isGlobalEW) { @@ -734,7 +837,7 @@ } double geoDif = isEW ? (N - S) : (E - W); - int listSize = (int)(geoDif / grid) + 1; + int listSize = (int)(geoDif / grid) + 1; std::vector sum(listSize, 0.0); std::vector wgt(listSize, 0.0); @@ -748,7 +851,7 @@ else { double lonX = lon_x(); if (lonX > E2) - dist = lonX - 360.0 - W2; + dist = lonX - cFullGlobeD - W2; else dist = lonX - W2; } @@ -803,7 +906,7 @@ MvUnimplementedGrid::MvUnimplementedGrid(field* myfield, field_state oldState) : MvGridBase(myfield, oldState, false) { - //field_ = 0; + // field_ = 0; currentLaty_ = cMvlatLonMissingValue; currentLonx_ = cMvlatLonMissingValue; } @@ -846,7 +949,7 @@ // One reason to do it here is that we will now know whether we can // iterate over the points or not (hasIterator() function). int griberr = 0; - iter_ = grib_iterator_new(field_->handle, 0, &griberr); + iter_ = grib_iterator_new(field_->handle, 0, &griberr); if (griberr != GRIB_SUCCESS) { iter_ = nullptr; } @@ -900,7 +1003,7 @@ return; } - long grid_ew = getLong("iDirectionIncrementInDegrees"); + long grid_ew = getLong("iDirectionIncrementInDegrees"); long points_parallel = getLong("numberOfPointsAlongAParallel"); if (!(grid_ew || points_parallel)) { //-- thinned grid needs to be implemented field_ = 0; @@ -909,20 +1012,20 @@ } long jPointsConsecutive = getLong("jPointsAreConsecutive"); //-- adjacent points in j dir are consequtive - long iNegative = getLong("iScansNegatively"); //-- points scan in -i dir + long iNegative = getLong("iScansNegatively"); //-- points scan in -i dir if (jPointsConsecutive || iNegative) { marslog(LOG_EROR, "LatLon grid jPointsConsecutive and iScansNegatively scanning mode not supported"); field_ = 0; return; } - horisLines_ = getLong("numberOfPointsAlongAMeridian"); + horisLines_ = getLong("numberOfPointsAlongAMeridian"); horisPoints_ = getLong("numberOfPointsAlongAParallel"); firstLonX_ = DBL_MAX; firstLatY_ = DBL_MAX; - lastLonX_ = DBL_MAX; - lastLatY_ = DBL_MAX; + lastLonX_ = DBL_MAX; + lastLatY_ = DBL_MAX; currentLaty_ = firstLatY(); currentLonx_ = firstLonX(); @@ -938,8 +1041,8 @@ } else //-- increments given => check { - dx_ = getDouble("iDirectionIncrementInDegrees"); // sec2_->grid_ew / cGridScaling; - double dx2 = (horisPoints_ == 1) ? 1 : (lon9 - lon1) / (horisPoints_ - 1.0); + dx_ = getDouble("iDirectionIncrementInDegrees"); // sec2_->grid_ew / cGridScaling; + double dx2 = (horisPoints_ == 1) ? 1 : (lon9 - lon1) / (horisPoints_ - 1.0); double dxErr = fabs(dx_ - dx2); if (dxErr > cGridEpsilon && dxErr < 1.0) { marslog(LOG_INFO, "Using computed lon grid interval %g (instead of %g)", dx2, dx_); @@ -957,8 +1060,8 @@ } else //-- increments given => check { - dy_ = getDouble("jDirectionIncrementInDegrees"); // sec2_->grid_ns / cGridScaling; - double dy2 = (horisLines_ == 1) ? 1 : (MAX(lat9, lat1) - MIN(lat9, lat1)) / (horisLines_ - 1.0); + dy_ = getDouble("jDirectionIncrementInDegrees"); // sec2_->grid_ns / cGridScaling; + double dy2 = (horisLines_ == 1) ? 1 : (MAX(lat9, lat1) - MIN(lat9, lat1)) / (horisLines_ - 1.0); double dyErr = fabs(dy_ - dy2); if (dyErr > cGridEpsilon && dyErr < 1.0) { marslog(LOG_INFO, "Using computed lat grid interval %g (instead of %g)", dy2, dy_); @@ -977,6 +1080,7 @@ marslog(LOG_INFO, "Ignoring jScansPositively flag (%d), setting j step to %g", (int)jPositive, dy_); } + globalEW_ = (horisPoints_ * fabs(dx_) > cFullGlobeLimitX); globalNS_ = (horisLines_ * fabs(dy_) > cFullGlobeLimitY); @@ -984,7 +1088,7 @@ southernLat_ = lat1; northernLat_ = lat9; if (southernLat_ > northernLat_) { - double tmp = southernLat_; + double tmp = southernLat_; southernLat_ = northernLat_; northernLat_ = tmp; } @@ -1002,7 +1106,7 @@ double x9 = lastLonX(); if (x1 > x9) - x1 -= 360.0; + x1 -= cFullGlobeD; firstLonX_ = x1; } @@ -1071,8 +1175,8 @@ v[3] = 180; } if (v[1] > 180 && v[3] > 180) { - v[1] = v[1] - 360; - v[3] = v[3] - 360; + v[1] = v[1] - cFullGlobeD; + v[3] = v[3] - cFullGlobeD; } } @@ -1089,7 +1193,7 @@ if (++horisPointCount_ >= horisPoints_) { currentLaty_ += dy_; - currentLonx_ = firstLonX(); + currentLonx_ = firstLonX(); horisPointCount_ = 0; } else { @@ -1112,15 +1216,15 @@ double gLat; - //north pole + // north pole if (lat_y > northernLat_) { gLat = northernLat_; - row = (northernLat_ == firstLatY()) ? 0 : horisLines_ - 1; + row = (northernLat_ == firstLatY()) ? 0 : horisLines_ - 1; // south pole } else if (lat_y < southernLat_) { gLat = southernLat_; - row = (southernLat_ == lastLatY()) ? horisLines_ - 1 : 0; + row = (southernLat_ == lastLatY()) ? horisLines_ - 1 : 0; } else { marslog(LOG_EROR, "Point is inside the area, it can not be extrapolated"); @@ -1133,13 +1237,13 @@ // normalise accordingly if (startLon > lon_x) - startLon -= 360.0; + startLon -= cFullGlobeD; // reverse order so that we could get the same nearest point as with nearest_gridpoint!! for (int i = np - 1; i >= 0; i--) { double gLon = startLon + i * dx_; - int idx = firstIndex + i; - double val = valueAt(idx); + int idx = firstIndex + i; + double val = valueAt(idx); if (!canHaveMissing && val == mars.grib_missing_value) return false; else @@ -1171,20 +1275,20 @@ // force longitudes >= 0 while (lon1 < 0) { - lon1 += 360.; - lon9 += 360.; + lon1 += cFullGlobeD; + lon9 += cFullGlobeD; } // now point is either inside or above! while (lon_x < lon1) { - lon_x += 360.; + lon_x += cFullGlobeD; } // check that lats are: lat1=southern, lat9=northern if (lat1 > lat9) { double tmp = lat1; - lat1 = lat9; - lat9 = tmp; + lat1 = lat9; + lat9 = tmp; } // check if the point is outside grid @@ -1240,7 +1344,7 @@ // point 12 index = horisPoints_ * iy1 + ix2; - val = valueAt(index); + val = valueAt(index); if (!canHaveMissing && val == mars.grib_missing_value) return false; @@ -1248,7 +1352,7 @@ // point 21 index = horisPoints_ * iy2 + ix1; - val = valueAt(index); + val = valueAt(index); if (!canHaveMissing && val == mars.grib_missing_value) return false; @@ -1256,7 +1360,7 @@ // point 22 index = horisPoints_ * iy2 + ix2; - val = valueAt(index); + val = valueAt(index); if (!canHaveMissing && val == mars.grib_missing_value) return false; @@ -1330,15 +1434,15 @@ double lat9 = lat1 + (nlat - 1) * dy_; //-- ending corner double lon9 = lon1 + (nlon - 1) * dx_; - double west = lon1 < lon9 ? lon1 : lon9; //-- scanning E->W or W->E ? - double east = lon1 < lon9 ? lon9 : lon1; + double west = lon1 < lon9 ? lon1 : lon9; //-- scanning E->W or W->E ? + double east = lon1 < lon9 ? lon9 : lon1; double eastpoint = east; // backup of this in case we change 'east' MvGeoBox myArea(lat1, west, lat9, east); if (lon9 - lon1 + dx_ > 359.9) //-- extend for globe { - myArea.set(lat1, 0, lat9, 360); + myArea.set(lat1, 0, lat9, cFullGlobeD); west = 0; } @@ -1348,11 +1452,11 @@ // adjust longitude inside grid while (lon_x < west) - lon_x += 360.0; + lon_x += cFullGlobeD; // half a gridpoint over the eastmost point while (lon_x > eastpoint + (dx_ / 2.0)) - lon_x -= 360.0; + lon_x -= cFullGlobeD; // nearest gridpoint int j = int(rint((lat_y - lat1) / dy_)); @@ -1372,45 +1476,35 @@ return cERRVAL; } - // get GRIB field parameters - double lat1 = firstLatY(); double lon1 = firstLonX(); double lat9 = lastLatY(); double lon9 = lastLonX(); - while (lon1 < 0) //-- force longitudes >= 0 { - lon1 += 360.; - lon9 += 360.; + lon1 += cFullGlobeD; + lon9 += cFullGlobeD; } while (lon_x < lon1) { - lon_x += 360.; //-- now point is either inside or above! + lon_x += cFullGlobeD; //-- now point is either inside or above! } - // check that lats are: lat1=southern, lat9=northern - if (lat1 > lat9) { - double tmp = lat1; - lat1 = lat9; - lat9 = tmp; + std::swap(lat1, lat9); } - //-- check if the point is outside grid - - char globe = horisPoints_ * dx_ > cFullGlobeLimitX ? 'y' : 'n'; - - if (globe == 'n' && (lon_x < lon1 || lon_x > lon9)) + if (!globalEW_ && (lon_x < lon1 || lon_x > lon9)) { return cERRVAL; + } - if (lat_y < lat1 || lat_y > lat9) + if (lat_y < lat1 || lat_y > lat9) { return cERRVAL; - + } #if defined(USE_GRIB_API_FOR_INTERPOLATE) @@ -1479,10 +1573,10 @@ else { #use_first_non_missing USE_NEAREST_NON_MISSING = 1 - test_nearest_gridpoint_info(data, 90, 0, 90, 0, 1) #top row, - first point + test_nearest_gridpoint_info(data, 90, 0, 90, 0, 1) #top row, + first point - USE_NEAREST_NON_MISSING = 0 marslog(LOG_EROR, "MvLatLonGrid::interpolatePoint grib_nearest_find() returned %d", err); + USE_NEAREST_NON_MISSING = 0 marslog(LOG_EROR, "MvLatLonGrid::interpolatePoint grib_nearest_find() returned %d", err); grib_nearest_delete(gn); return cERRVAL; } @@ -1496,38 +1590,52 @@ #else - // use our own routine to find the 4 nearest grid points + // make sure lon9 is 360 deg away from lon1 + if (globalEW_) { + lon9 = lon1 + cFullGlobeD; + } + // use our own routine to find the 4 nearest grid points int ix1 = int((lon_x - lon1) / dx_); //-- index for column on the west + int ix2 = -1; //-- index for column on the east - if (ix1 > (horisPoints_ - 1)) { - if (globe) - ix1 = 0; //-- wrap around globe - else + // check situation when lon is extremely close to the eastern border + if (globalEW_) { + if (ix1 == horisPoints_) { + if (lon_x <= lon9 && (lon9 - lon_x) < lonDeltaNearEastBorder_) { + ix1 = horisPoints_ - 1; + } else { + ix1 = 0; + } + } else if (ix1 > horisPoints_) { return false; + } + ix2 = ix1 + 1; + if (ix2 >= horisPoints_) { + ix2 = 0; + } + } else { + if (ix1 == horisPoints_ - 1) { + if (lon_x <= lon9 && (lon9 - lon_x) < lonDeltaNearEastBorder_) { + ix1 = horisPoints_ - 2; + } + } else if (ix1 > horisPoints_ - 1) { + return false; + } + ix2 = ix1 + 1; + if (ix2 > horisPoints_-1) { + return false; + } } - int ix2 = ix1 + 1; //-- index for column on the east - - if (ix2 > (horisPoints_ - 1)) { - if (globe == 'y') - ix2 = 0; //-- wrap around globe - else - ix2 = ix1; //-- possible if lon==lon9 (east boundary) - } - - // start either from north or from south depending on scanning mode -- - int iy1 = int((lat_y - (dy_ < 0 ? lat9 : lat1)) / dy_); int iy2 = iy1 + 1; if (iy2 > (horisLines_ - 1)) iy2 = iy1; //-- possible at "higher" boarder - // get and check grid point values - int index_x1y1 = horisPoints_ * iy1 + ix1; int index_x2y1 = horisPoints_ * iy1 + ix2; int index_x1y2 = horisPoints_ * iy2 + ix1; @@ -1545,9 +1653,7 @@ return DBL_MAX; } - // interpolate - double lon_ix1 = lon1 + ix1 * dx_; double lon_ix2 = lon1 + ix2 * dx_; double lat_iy1 = (dy_ < 0 ? lat9 : lat1) + iy1 * dy_; @@ -1569,7 +1675,6 @@ surroundingPoints->push_back(MvGridPoint(grid_22, lat_iy2, lon_ix2, index_x2y2)); } - /* std::cout << "interpolating point: " << "(" << lat_y << "," << lon_x << ")" << std::endl; std::cout << " nearest: (" << lat_iy1 << "," << lon_ix1 << ") " << std::endl; @@ -1626,11 +1731,11 @@ return mars.grib_missing_value; } else if (v2 == mars.grib_missing_value) { - //first order accuracy + // first order accuracy return (v1 - v0) / (0.5 * w); } - //second order accuracy + // second order accuracy return (-3 * v0 + 4 * v1 - v2) / w; } @@ -1646,11 +1751,11 @@ return mars.grib_missing_value; } else if (v3 == mars.grib_missing_value) { - //first order accuracy + // first order accuracy return (v0 - 2.0 * v1 + v2) / w; } - //second order accuracy + // second order accuracy return (2.0 * v0 - 5.0 * v1 + 4.0 * v2 - v3) / w; } @@ -1665,11 +1770,11 @@ return mars.grib_missing_value; } else if (v2 == mars.grib_missing_value) { - //first order accuracy + // first order accuracy return (v0 - v1) / (0.5 * w); } - //second order accuracy + // second order accuracy return (3 * v0 - 4 * v1 + v2) / w; } @@ -1685,28 +1790,28 @@ return mars.grib_missing_value; } else if (v3 == mars.grib_missing_value) { - //first order accuracy + // first order accuracy return (v0 - 2.0 * v1 + v2) / w; } - //second order accuracy + // second order accuracy return (2.0 * v0 - 5.0 * v1 + 4.0 * v2 - v3) / w; } -//Compute west-east derivative (positive towards east) with -//finite difference schemes (second order accuracy) +// Compute west-east derivative (positive towards east) with +// finite difference schemes (second order accuracy) void MvLatLonGrid::firstDerivativeX(MvGridBase* outGrd) { assert(outGrd); - //the basic weight, we need to multiply it by the - //cosine of the latitude - double w = 2 * cEarthRadius * dx_ * cToRadians; + // the basic weight, we need to multiply it by the + // cosine of the latitude + double w = 2 * cEarthRadius * dx_ * cToRadians; double wLat = 1.; for (int p = 0; p < length(); ++p) { - //for missing value or if the row size is too short we set the - //gradient to missing value + // for missing value or if the row size is too short we set the + // gradient to missing value if (value() == mars.grib_missing_value || horisPoints_ <= 3) { outGrd->setValueToMissing(); outGrd->advance(); @@ -1714,40 +1819,40 @@ continue; } - double v = mars.grib_missing_value; //default, this will be the value on the poles + double v = mars.grib_missing_value; // default, this will be the value on the poles - //we are outside the pole + // we are outside the pole if (currentLaty_ <= 90. - cGridEpsilon && currentLaty_ >= -90. + cGridEpsilon) { wLat = cos(currentLaty_ * cToRadians) * w; - //new row (lon band) + // new row (lon band) if (horisPointCount_ == 0) { - //periodic in lon - central diff - // west ---> east - // .. v1 v0 v2 .. + // periodic in lon - central diff + // west ---> east + // .. v1 v0 v2 .. if (isGlobalInLon()) { v = centralDiff(currentIndex_ + horisPoints_ - 1, currentIndex_ + 1, wLat); } - //western edge - we need forward difference - // west ---> east - // v0 v1 v2 .... + // western edge - we need forward difference + // west ---> east + // v0 v1 v2 .... else { v = forwardDiff(currentIndex_, currentIndex_ + 1, currentIndex_ + 2, wLat); } } - //end of row (lon band) + // end of row (lon band) else if (horisPointCount_ == horisPoints_ - 1) { - //periodic in lon - central diff - // west ---> east - // .. v1 v0 v2 ... + // periodic in lon - central diff + // west ---> east + // .. v1 v0 v2 ... if (isGlobalInLon()) { v = centralDiff(currentIndex_ - 1, currentIndex_ - (horisPoints_ - 1), wLat); } - //eastern edge - we need backward difference - // west ---> east - // ... v2 v1 v0 + // eastern edge - we need backward difference + // west ---> east + // ... v2 v1 v0 else { v = backwardDiff(currentIndex_, currentIndex_ - 1, currentIndex_ - 2, wLat); } @@ -1771,17 +1876,17 @@ } } -//Compute north-south derivative (positive towards north) with -//finite difference schemes (second order accuracy) +// Compute north-south derivative (positive towards north) with +// finite difference schemes (second order accuracy) void MvLatLonGrid::firstDerivativeY(MvGridBase* outGrd) { assert(outGrd); bool nsScan = (dy_ < 0); - double w = 2 * cEarthRadius * dy_ * cToRadians * ((nsScan) ? -1 : 1); + double w = 2 * cEarthRadius * dy_ * cToRadians * ((nsScan) ? -1 : 1); for (int p = 0; p < length(); ++p) { - //for missing value or if the column lenght is too short we set the - //gradient to missing value + // for missing value or if the column lenght is too short we set the + // gradient to missing value if (value() == mars.grib_missing_value || horisLines_ <= 3) { outGrd->setValueToMissing(); outGrd->advance(); @@ -1789,71 +1894,71 @@ continue; } - double v = mars.grib_missing_value; //default, this will be the value on the poles + double v = mars.grib_missing_value; // default, this will be the value on the poles - //we are outside the pole + // we are outside the pole if (currentLaty_ <= 90. - cGridEpsilon && currentLaty_ >= -90. + cGridEpsilon) { - //N->S scan + // N->S scan if (nsScan) { - //new column - we are on the northern edge - //backward difference - // north - // v0 ^ - // v1 | - // v2 | - // south + // new column - we are on the northern edge + // backward difference + // north + // v0 ^ + // v1 | + // v2 | + // south if (currentIndex_ - horisPoints_ < 0) { v = backwardDiff(currentIndex_, currentIndex_ + horisPoints_, currentIndex_ + 2 * horisPoints_, w); } - //bottom of the column - we are on the souther edge - //forward difference - // north - // v2 ^ - // v1 | - // v0 | - // south + // bottom of the column - we are on the souther edge + // forward difference + // north + // v2 ^ + // v1 | + // v0 | + // south else if (currentIndex_ + horisPoints_ > length() - 1) { v = forwardDiff(currentIndex_, currentIndex_ - horisPoints_, currentIndex_ - 2 * horisPoints_, w); } - //central difference - // north - // v2 ^ - // v0 | - // v1 | - // south + // central difference + // north + // v2 ^ + // v0 | + // v1 | + // south else { v = centralDiff(currentIndex_ + horisPoints_, currentIndex_ - horisPoints_, w); } } - //S->N scan + // S->N scan else { - //new column - we are on the southern edge - //forward difference - // north - // v2 ^ - // v1 | - // v0 | - // south + // new column - we are on the southern edge + // forward difference + // north + // v2 ^ + // v1 | + // v0 | + // south if (currentIndex_ - horisPoints_ < 0) { v = forwardDiff(currentIndex_, currentIndex_ + horisPoints_, currentIndex_ + 2 * horisPoints_, w); } - //bottom of the column - we are on the northern edge - //backward difference - // north - // v0 ^ - // v1 | - // v2 | - // south + // bottom of the column - we are on the northern edge + // backward difference + // north + // v0 ^ + // v1 | + // v2 | + // south else if (currentIndex_ + horisPoints_ > length() - 1) { v = forwardDiff(currentIndex_, currentIndex_ - horisPoints_, currentIndex_ - 2 * horisPoints_, w); } - //central difference - // north - // v2 ^ - // v0 | - // v1 | - // south + // central difference + // north + // v2 ^ + // v0 | + // v1 | + // south else { v = centralDiff(currentIndex_ - horisPoints_, currentIndex_ + horisPoints_, w); } @@ -1871,20 +1976,20 @@ } } -//Compute east-west second derivative (positive towards east) with -//finite difference schemes (second order accuracy) +// Compute east-west second derivative (positive towards east) with +// finite difference schemes (second order accuracy) void MvLatLonGrid::secondDerivativeX(MvGridBase* outGrd) { assert(outGrd); - //the basic weight, we need to multiply it by - //cosine of the latitude - double w = cEarthRadius * dx_ * cToRadians; + // the basic weight, we need to multiply it by + // cosine of the latitude + double w = cEarthRadius * dx_ * cToRadians; double wLat = 1.; for (int p = 0; p < length(); ++p) { - //for missing value or if the row size is too short we set the - //gradient to missing value + // for missing value or if the row size is too short we set the + // gradient to missing value if (value() == mars.grib_missing_value || horisPoints_ <= 4) { outGrd->setValueToMissing(); outGrd->advance(); @@ -1892,41 +1997,41 @@ continue; } - double v = mars.grib_missing_value; //default, this will be the value on the poles + double v = mars.grib_missing_value; // default, this will be the value on the poles - //we are outside the pole + // we are outside the pole if (currentLaty_ <= 90. - cGridEpsilon && currentLaty_ >= -90. + cGridEpsilon) { wLat = cos(currentLaty_ * cToRadians) * w; wLat *= wLat; - //new row (lon band) + // new row (lon band) if (horisPointCount_ == 0) { - //periodic in lon - central diff - // west ---> east - // .. v1 v0 v2 .. + // periodic in lon - central diff + // west ---> east + // .. v1 v0 v2 .. if (isGlobalInLon()) { v = centralDiffSecond(currentIndex_, currentIndex_ + horisPoints_ - 1, currentIndex_ + 1, wLat); } - //western edge - we need forward difference - // west ---> east - // v0 v1 v2 v3 .... + // western edge - we need forward difference + // west ---> east + // v0 v1 v2 v3 .... else { v = forwardDiffSecond(currentIndex_, currentIndex_ + 1, currentIndex_ + 2, currentIndex_ + 3, wLat); } } - //end of row (lon band) + // end of row (lon band) else if (horisPointCount_ == horisPoints_ - 1) { - //periodic in lon - central diff - // west ---> east - // .. v1 v0 v2 ... + // periodic in lon - central diff + // west ---> east + // .. v1 v0 v2 ... if (isGlobalInLon()) { v = centralDiffSecond(currentIndex_, currentIndex_ - 1, currentIndex_ - (horisPoints_ - 1), wLat); } - //eastern edge - we need backward difference - // west ---> east - // ... v3 v2 v1 v0 + // eastern edge - we need backward difference + // west ---> east + // ... v3 v2 v1 v0 else { v = backwardDiffSecond(currentIndex_, currentIndex_ - 1, currentIndex_ - 2, currentIndex_ - 3, wLat); } @@ -1950,8 +2055,8 @@ } } -//Compute north-south derivative (positive towards north) with -//finite difference schemes (second order accuracy) +// Compute north-south derivative (positive towards north) with +// finite difference schemes (second order accuracy) void MvLatLonGrid::secondDerivativeY(MvGridBase* outGrd) { assert(outGrd); @@ -1961,8 +2066,8 @@ w *= w; for (int p = 0; p < length(); ++p) { - //for missing value or if the column lenght is too short we set the - //gradient to missing value + // for missing value or if the column lenght is too short we set the + // gradient to missing value if (value() == mars.grib_missing_value || horisLines_ <= 4) { outGrd->setValueToMissing(); outGrd->advance(); @@ -1970,79 +2075,79 @@ continue; } - double v = mars.grib_missing_value; //default, this will be the value on the poles + double v = mars.grib_missing_value; // default, this will be the value on the poles - //we are outside the pole + // we are outside the pole if (currentLaty_ <= 90. - cGridEpsilon && currentLaty_ >= -90. + cGridEpsilon) { - //N->S scan + // N->S scan if (nsScan) { - //new column - we are on the northern edge - //backward difference - // north - // v0 ^ - // v1 | - // v2 | - // v3 | - // south + // new column - we are on the northern edge + // backward difference + // north + // v0 ^ + // v1 | + // v2 | + // v3 | + // south if (currentIndex_ - horisPoints_ < 0) { v = backwardDiffSecond(currentIndex_, currentIndex_ + horisPoints_, currentIndex_ + 2 * horisPoints_, currentIndex_ + 3 * horisPoints_, w); } - //bottom of the column - we are on the southern edge - //forward difference - // north - // v3 ^ - // v2 | - // v1 | - // v0 | - // south + // bottom of the column - we are on the southern edge + // forward difference + // north + // v3 ^ + // v2 | + // v1 | + // v0 | + // south else if (currentIndex_ + horisPoints_ > length() - 1) { v = forwardDiffSecond(currentIndex_, currentIndex_ - horisPoints_, currentIndex_ - 2 * horisPoints_, currentIndex_ - 3 * horisPoints_, w); } - //central difference - // north - // v2 ^ - // v0 | - // v1 | - // south + // central difference + // north + // v2 ^ + // v0 | + // v1 | + // south else { v = centralDiffSecond(currentIndex_, currentIndex_ + horisPoints_, currentIndex_ - horisPoints_, w); } } - //S->N scan + // S->N scan else { - //new column - we are on the southern edge - //forward difference - // north - // v3 ^ - // v2 | - // v1 | - // v0 | - // south + // new column - we are on the southern edge + // forward difference + // north + // v3 ^ + // v2 | + // v1 | + // v0 | + // south if (currentIndex_ - horisPoints_ < 0) { v = forwardDiffSecond(currentIndex_, currentIndex_ + horisPoints_, currentIndex_ + 2 * horisPoints_, currentIndex_ + 3 * horisPoints_, w); } - //bottom of the column - we are on the northern edge - //backward difference - // north - // v0 ^ - // v1 | - // v2 | - // v3 | - // south + // bottom of the column - we are on the northern edge + // backward difference + // north + // v0 ^ + // v1 | + // v2 | + // v3 | + // south else if (currentIndex_ + horisPoints_ > length() - 1) { v = forwardDiffSecond(currentIndex_, currentIndex_ - horisPoints_, currentIndex_ - 2 * horisPoints_, currentIndex_ - 3 * horisPoints_, w); } - //central difference - // north - // v2 ^ - // v0 | - // v1 | - // south + // central difference + // north + // v2 ^ + // v0 | + // v1 | + // south else { v = centralDiffSecond(currentIndex_, currentIndex_ - horisPoints_, currentIndex_ + horisPoints_, w); } @@ -2114,7 +2219,7 @@ { assert(outGrd); - //the basic weight + // the basic weight double w = fabs(2 * cEarthRadius * cEarthRadius * sin(dy_ * cToRadians / 2.) * dx_ * cToRadians); // the cell area on the Pole is constant @@ -2123,7 +2228,7 @@ double v = 0; for (int p = 0; p < length(); ++p) { - //we are outside the Pole + // we are outside the Pole if (currentLaty_ <= 90. - cGridEpsilon && currentLaty_ >= -90. + cGridEpsilon) { // we start a new latitude row - @@ -2175,7 +2280,7 @@ MvLocation MvLatLonRotatedGrid::unRotate(double lat_y, double lon_x) const { - double ZRADI = 1. / cToRadians; + double ZRADI = 1. / cToRadians; double ZSYCEN = sin(cToRadians * (southPoleLaty_ + 90.)); double ZCYCEN = cos(cToRadians * (southPoleLaty_ + 90.)); @@ -2184,15 +2289,15 @@ double ZSYROT = sin(cToRadians * lat_y); double ZCYROT = cos(cToRadians * lat_y); double ZSYREG = ZCYCEN * ZSYROT + ZSYCEN * ZCYROT * ZCXROT; - ZSYREG = MAX(MIN(ZSYREG, +1.0), -1.0); + ZSYREG = MAX(MIN(ZSYREG, +1.0), -1.0); double PYREG = asin(ZSYREG) * ZRADI; double ZCYREG = cos(PYREG * cToRadians); double ZCXMXC = (ZCYCEN * ZCYROT * ZCXROT - ZSYCEN * ZSYROT) / ZCYREG; - ZCXMXC = MAX(MIN(ZCXMXC, +1.0), -1.0); + ZCXMXC = MAX(MIN(ZCXMXC, +1.0), -1.0); double ZSXMXC = ZCYROT * ZSXROT / ZCYREG; - double ZXMXC = acos(ZCXMXC) * ZRADI; + double ZXMXC = acos(ZCXMXC) * ZRADI; if (ZSXMXC < 0.0) ZXMXC = -ZXMXC; @@ -2205,23 +2310,23 @@ MvLocation MvLatLonRotatedGrid::rotate(double lat_y, double lon_x) const { - double ZRADI = 1. / cToRadians; + double ZRADI = 1. / cToRadians; double ZSYCEN = sin(cToRadians * (southPoleLaty_ + 90.)); double ZCYCEN = cos(cToRadians * (southPoleLaty_ + 90.)); - double ZXMXC = cToRadians * (lon_x - southPoleLonx_); + double ZXMXC = cToRadians * (lon_x - southPoleLonx_); double ZSXMXC = sin(ZXMXC); double ZCXMXC = cos(ZXMXC); double ZSYREG = sin(cToRadians * lat_y); double ZCYREG = cos(cToRadians * lat_y); double ZSYROT = ZCYCEN * ZSYREG - ZSYCEN * ZCYREG * ZCXMXC; - ZSYROT = MAX(MIN(ZSYROT, +1.0), -1.0); + ZSYROT = MAX(MIN(ZSYROT, +1.0), -1.0); double PYROT = asin(ZSYROT) * ZRADI; double ZCYROT = cos(PYROT * cToRadians); double ZCXROT = (ZCYCEN * ZCYREG * ZCXMXC + ZSYCEN * ZSYREG) / ZCYROT; - ZCXROT = MAX(MIN(ZCXROT, +1.0), -1.0); + ZCXROT = MAX(MIN(ZCXROT, +1.0), -1.0); double ZSXROT = ZCYREG * ZSXMXC / ZCYROT; double PXROT = acos(ZCXROT) * ZRADI; @@ -2369,7 +2474,7 @@ MvGridPoint MvLatLonRotatedGrid::nearestGridpoint(double lat_y, double lon_x, bool nearestValid) { MvLocation rLoc = rotate(lat_y, lon_x); - MvGridPoint gp = MvLatLonGrid::nearestGridpoint(rLoc.latitude(), rLoc.longitude(), nearestValid); + MvGridPoint gp = MvLatLonGrid::nearestGridpoint(rLoc.latitude(), rLoc.longitude(), nearestValid); //-- this one for debug checking, dbLoc should be equal to input loc -- MvLocation dbLoc = unRotate(gp.loc_.latitude(), gp.loc_.longitude()); @@ -2417,13 +2522,13 @@ } long jPointsConsecutive = getLong("jPointsAreConsecutive"); //-- adjacent points in j dir are consequtive - long iNegative = getLong("iScansNegatively"); //-- points scan in -i dir + long iNegative = getLong("iScansNegatively"); //-- points scan in -i dir if (jPointsConsecutive || iNegative) { marslog(LOG_EROR, "Lambert grid jPointsConsecutive or iScansNegatively not supported"); return; } - dx_ = getDouble("DxInMetres"); + dx_ = getDouble("DxInMetres"); double dy_ = getDouble("DyInMetres"); if (dy_ != dx_) { marslog(LOG_EROR, "MvLambertGrid: dx!=dy: not implemented!"); @@ -2432,13 +2537,13 @@ } long jPositive = getLong("jScansPositively"); //-- points scan in +j dir - jPositive_ = (jPositive == 1); + jPositive_ = (jPositive == 1); earthRadius_ = cEarthRadius; - gridTanLat_ = getDouble("Latin1InDegrees") * 1000; // sec2_[cInterSecLat1]; + gridTanLat_ = getDouble("Latin1InDegrees") * 1000; // sec2_[cInterSecLat1]; double tanLat2 = getDouble("Latin2InDegrees") * 1000; - //if( sec2_[cInterSecLat2] != gridTanLat_ ) //-- two latitudes...? + // if( sec2_[cInterSecLat2] != gridTanLat_ ) //-- two latitudes...? if (tanLat2 != gridTanLat_) { //-- The original Fortran code was made only for a projection defined //-- by a single tangenting latitude. This is my personal solution @@ -2449,11 +2554,11 @@ //-- shrinks Earth to touch the Lambert cone only in one latitude ;-) //-- set tangenting latitude as the mean of the two latitudes - //gridTanLat_ = (sec2_[cInterSecLat1] + sec2_[cInterSecLat2]) / 2.0; + // gridTanLat_ = (sec2_[cInterSecLat1] + sec2_[cInterSecLat2]) / 2.0; gridTanLat_ = (gridTanLat_ + tanLat2) / 2.0; //-- use simple trigonometry to shrink the Earth radius - //double delta = 0.5 * (sec2_[cInterSecLat1] - sec2_[cInterSecLat2]) / cGridScaling; + // double delta = 0.5 * (sec2_[cInterSecLat1] - sec2_[cInterSecLat2]) / cGridScaling; double delta = 0.5 * (gridTanLat_ - tanLat2); if (delta < 0) delta = -delta; @@ -2463,19 +2568,19 @@ } earthRadiusPerDx_ = earthRadius_ / dx_; - //std::cout << "R, dx, R/dx:\t" << earthRadius_ << "\t" << dx_ << "\t" << earthRadiusPerDx_ << std::endl; + // std::cout << "R, dx, R/dx:\t" << earthRadius_ << "\t" << dx_ << "\t" << earthRadiusPerDx_ << std::endl; hemiSphere_ = gridTanLat_ > 0 ? 1 : 0; gridTanLat_ = (gridTanLat_ / cGridScaling) * cToRadians; //--aki cGridScaling--// - sinLatTan_ = hemiSphere_ * sin(gridTanLat_); - cosLatTan_ = cos(gridTanLat_); + sinLatTan_ = hemiSphere_ * sin(gridTanLat_); + cosLatTan_ = cos(gridTanLat_); gridVertLon_ = getDouble("LoVInDegrees"); // sec2_[cGridVertLon] / cGridScaling; - horisLines_ = getLong("numberOfPointsAlongYAxis"); //sec2_[cPointsAlongY]; + horisLines_ = getLong("numberOfPointsAlongYAxis"); // sec2_[cPointsAlongY]; horisPoints_ = getLong("numberOfPointsAlongXAxis"); // sec2_[cPointsAlongX]; - gridLat1_ = getDouble("latitudeOfFirstGridPointInDegrees"); //sec2_[cGridFirstLat] / cGridScaling; + gridLat1_ = getDouble("latitudeOfFirstGridPointInDegrees"); // sec2_[cGridFirstLat] / cGridScaling; gridLon1_ = getDouble("longitudeOfFirstGridPointInDegrees"); // sec2_[cGridFirstLon] / cGridScaling; //-- based on Fortran code from 'http://maps.fsl.noaa.gov/fslparms/w3fb12.f': @@ -2489,9 +2594,9 @@ // double ELON1L = gridLon1_; if ((gridLon1_ - gridVertLon_) > 180.0) - ELON1L = gridLon1_ - 360.0; + ELON1L = gridLon1_ - cFullGlobeD; if ((gridLon1_ - gridVertLon_) < -180.0) - ELON1L = gridLon1_ + 360.0; + ELON1L = gridLon1_ + cFullGlobeD; double ELONVR = gridVertLon_ * cToRadians; // @@ -2505,16 +2610,16 @@ // USE LL POINT (LowerLeft) INFO TO LOCATE POLE POINT // double ELO1 = ELON1L * cToRadians; - double ARG = sinLatTan_ * (ELO1 - ELONVR); - poleI_ = 1. - hemiSphere_ * RMLL * sin(ARG); - poleJ_ = 1. + RMLL * cos(ARG); + double ARG = sinLatTan_ * (ELO1 - ELONVR); + poleI_ = 1. - hemiSphere_ * RMLL * sin(ARG); + poleJ_ = 1. + RMLL * cos(ARG); // // NOW THE LATITUDE // RECALCULATE THE THING ONLY IF MAP IS NEW SINCE LAST TIME // - double ANINV = 1. / sinLatTan_; + double ANINV = 1. / sinLatTan_; sinLatTanInvPer2_ = ANINV / 2.; - theThing_ = pow((sinLatTan_ / earthRadiusPerDx_), ANINV) / + theThing_ = pow((sinLatTan_ / earthRadiusPerDx_), ANINV) / (pow(cosLatTan_, ((1. - sinLatTan_) * ANINV)) * (1. + sinLatTan_)); currentLaty_ = firstLatY(); @@ -2571,7 +2676,7 @@ // YY MUST BE POSITIVE UP FOR THIS TEST // double THETA = M_PI * (1. - sinLatTan_); - double BETA = atan2(XX, -YY); + double BETA = atan2(XX, -YY); if (BETA < 0) BETA = -BETA; @@ -2589,7 +2694,7 @@ } else { currentLonx_ = gridVertLon_ + atan2(hemiSphere_ * XX, YY) / sinLatTan_ / cToRadians; - currentLonx_ = fmod(currentLonx_ + 360.0, 360.0); + currentLonx_ = fmod(currentLonx_ + cFullGlobeD, cFullGlobeD); currentLaty_ = hemiSphere_ * (M_PI / 2.0 - 2.0 * atan(theThing_ * pow(R2, sinLatTanInvPer2_))) / cToRadians; @@ -2662,15 +2767,15 @@ field_ = 0; } - long jScansPositively = getLong("jScansPositively"); + long jScansPositively = getLong("jScansPositively"); isSouthToNorthScanning_ = jScansPositively; - globalNS_ = true; - globalEW_ = true; + globalNS_ = true; + globalEW_ = true; horisLines_ = getLong("numberOfPointsAlongAMeridian"); // sec2_->points_meridian; firstLonX_ = DBL_MAX; - lastLonX_ = DBL_MAX; + lastLonX_ = DBL_MAX; } //------------------------------------------------------ @@ -2682,15 +2787,15 @@ firstLon = firstLonX(); - lastLon = lastLonX(); + lastLon = lastLonX(); firstLat = getDouble("latitudeOfFirstGridPointInDegrees"); - lastLat = getDouble("latitudeOfLastGridPointInDegrees"); + lastLat = getDouble("latitudeOfLastGridPointInDegrees"); if (horisLines_ == numGlobalParallels_) //-- field is global (N <-> S) { firstLatIndex_ = 0; - lastLatIndex_ = horisLines_ - 1; + lastLatIndex_ = horisLines_ - 1; // some grids have rows with no points in them - skip past them while (pointsInRow(firstLatIndex_) == 0 && firstLatIndex_ < horisLines_) { @@ -2701,21 +2806,21 @@ else //-- subarea only { firstLatIndex_ = findLatIndex(firstLat); - lastLatIndex_ = findLatIndex(lastLat); - globalNS_ = false; + lastLatIndex_ = findLatIndex(lastLat); + globalNS_ = false; } // additional check to make sure it's global - we extend the grid by another point and see whether // it would end up where the first point is - we use the 'middle' row, since that should extend // the furthest - int numPoints = pointsInRow(firstLatIndex_ + (horisLines_ / 2)); // middle line - double dx = (lastLon - firstLon) / (numPoints - 1); + int numPoints = pointsInRow(firstLatIndex_ + (horisLines_ / 2)); // middle line + double dx = (lastLon - firstLon) / (numPoints - 1); double wrapAroundLong = dx * (numPoints); - double epsilon = dx * 0.9; + double epsilon = dx * 0.9; - if (wrapAroundLong >= (360.0 - dx)) - wrapAroundLong -= 360.0; + if (wrapAroundLong >= (cFullGlobeD - dx)) + wrapAroundLong -= cFullGlobeD; double diff = wrapAroundLong - firstLon; @@ -2726,9 +2831,9 @@ if (isSouthToNorthScanning_) { - long tmp = firstLatIndex_; + long tmp = firstLatIndex_; firstLatIndex_ = lastLatIndex_; - lastLatIndex_ = tmp; + lastLatIndex_ = tmp; } } //------------------------------------------------------ @@ -2739,7 +2844,7 @@ { for (int indx = 0; indx < numGlobalParallels_; ++indx) { double diff = latitudes_[indx] - latitude; - diff = diff < 0 ? -diff : diff; + diff = diff < 0 ? -diff : diff; if (diff < 0.001) //-- 0.001 = precision in GRIB header return indx; //-- OK, close enough @@ -2776,7 +2881,7 @@ double x0 = getDouble("longitudeOfFirstGridPointInDegrees"); // sec2_->limit_west / cGridScaling; if (x0 > lastLonX()) - x0 -= 360.0; + x0 -= cFullGlobeD; firstLonX_ = x0; } @@ -2860,10 +2965,9 @@ return false; // longitude of 360 should be converted to 0 - if (lon_x == 360.0) + if (lon_x == cFullGlobeD) lon_x = 0.0; - // -- before first row or after last row ? if (lat_y > latitudes_[firstLatIndex_] || lat_y < latitudes_[lastLatIndex_]) { if (globalNS_) @@ -2872,17 +2976,19 @@ return false; } - int row9 = firstLatIndex_; //-- find row S of pt + int row9 = firstLatIndex_; //-- find row S of pt double lat9 = latitudes_[row9]; while (lat9 > lat_y && row9 < firstLatIndex_ + horisLines_) { lat9 = latitudes_[++row9]; } - bool borderRow = (row9 == firstLatIndex_); - // what about South Pole? + bool borderRow = (row9 == firstLatIndex_ || row9 == lastLatIndex_+1); + if (row9 == lastLatIndex_ + 1) { // spill over the last row? then go back to the last row + row9 = lastLatIndex_; + } - int row1 = borderRow ? row9 : row9 - 1; //-- previous row is N of pt - double lat1 = latitudes_[row1]; + int row1 = (borderRow) ? row9 : row9 - 1; //-- previous row is N of pt + double lat1 = latitudes_[row1]; int pointsInRow1 = pointsInRow(row1); int pointsInRow9 = pointsInRow(row9); @@ -2903,27 +3009,26 @@ // is not a valid concept and we set it to zero int moreThanOnePointInRow = (pointsInRow1 > 1); - double dataLonWidth = (globalEW_) ? 360.0 : lastLonXInArea(row1) - firstLonXInArea(row1); - int numIntervals = (globalEW_) ? pointsInRow1 : pointsInRow1 - 1; - double dx1 = (moreThanOnePointInRow) ? (dataLonWidth / numIntervals) : 0; //-- N row increment + double dataLonWidth = (globalEW_) ? cFullGlobeD : lastLonXInArea(row1) - firstLonXInArea(row1); + int numIntervals = (globalEW_) ? pointsInRow1 : pointsInRow1 - 1; + double dx1 = (moreThanOnePointInRow) ? (dataLonWidth / numIntervals) : 0; //-- N row increment int firstIndex = 0; //-- => find pts on N row <= for (int i = firstLatIndex_; i < row1; ++i) firstIndex += pointsInRow(i); //-- offset + // normalise lon range double firstLon = firstLonXInArea(row1); - if (globalEW_ && (firstLon > lon_x)) //-- normalise acording to lon_x - firstLon -= 360.0; - - int ix1 = (moreThanOnePointInRow) ? int((lon_x - firstLon) / dx1) : 0; //-- column W of pt - - // true -> column E of pt, false -> first or next! - int ix2 = (ix1 == (pointsInRow1 - 1)) ? 0 : ix1 + 1; + double lastLon = lastLonXInArea(row1); + MvLocation::normaliseRangeToLongitude(firstLon, lastLon, lon_x); - // ix1 outside the data row? - // sub-area, and ix2 is first point? - if (ix1 > pointsInRow1 || (!globalEW_ && (ix2 < ix1))) { - return false; + // determine column on west (ix1) and east (ix2) side of the point + int ix1 = 0; + int ix2 = 0; + if (moreThanOnePointInRow) { + if (!computeLonIndex(lon_x, firstLon, dataLonWidth, dx1, pointsInRow1, ix1, ix2)) { + return false; + } } double grid_11 = valueAt(firstIndex + ix1); //-- value in W pt @@ -2938,30 +3043,32 @@ double lon_x2 = firstLon + ix2 * dx1; // TODO: has to be treated properly - //if (borderRow) + // if (borderRow) // return val1; //-- => find pts on S row <= int firstIndexRow2 = firstIndex + pointsInRow1; - firstLon = firstLonXInArea(row9); - if (globalEW_ && (firstLon > lon_x)) //-- normalise acording to lon_x - firstLon -= 360.0; + + // normalise lon range + firstLon = firstLonXInArea(row9); + lastLon = lastLonXInArea(row9); + MvLocation::normaliseRangeToLongitude(firstLon, lastLon, lon_x); + +// if (globalEW_ && (firstLon > lon_x)) //-- normalise acording to lon_x +// firstLon -= cFullGlobeD; moreThanOnePointInRow = (pointsInRow9 > 1); - dataLonWidth = (globalEW_) ? 360.0 : lastLonXInArea(row9) - firstLonXInArea(row9); - numIntervals = (globalEW_) ? pointsInRow9 : pointsInRow9 - 1; - double dx9 = (moreThanOnePointInRow) ? (dataLonWidth / numIntervals) : 0; //-- S row increment - //double dy = lat1 - lat9; - - int ix3 = (moreThanOnePointInRow) ? int((lon_x - firstLon) / dx9) : 0; //-- column W of pt - - // true -> column E of pt, false -> first or next! - int ix4 = (ix3 == (pointsInRow9 - 1)) ? 0 : ix3 + 1; - - //-- ix1 outside the data row? - //-- sub-area, and ix2 is first point? - if (ix3 > pointsInRow9 || (!globalEW_ && (ix4 < ix3))) { - return false; + dataLonWidth = (globalEW_) ? cFullGlobeD : lastLonXInArea(row9) - firstLonXInArea(row9); + numIntervals = (globalEW_) ? pointsInRow9 : pointsInRow9 - 1; + double dx9 = (moreThanOnePointInRow) ? (dataLonWidth / numIntervals) : 0; //-- S row increment + // double dy = lat1 - lat9; + + int ix3 = 0; + int ix4 = 0; + if (moreThanOnePointInRow) { + if (!computeLonIndex(lon_x, firstLon, dataLonWidth, dx9, pointsInRow9, ix3, ix4)) { + return false; + } } double grid_21 = valueAt(firstIndexRow2 + ix3); //-- value in W pt @@ -2975,10 +3082,10 @@ double lon_x8 = firstLon + ix3 * dx9; double lon_x9 = firstLon + ix4 * dx9; - points.push_back(MvGridPoint(grid_11, lat1, lon_x1, firstIndex + ix1)); - points.push_back(MvGridPoint(grid_12, lat1, lon_x2, firstIndex + ix2)); - points.push_back(MvGridPoint(grid_21, lat9, lon_x8, firstIndexRow2 + ix3)); - points.push_back(MvGridPoint(grid_22, lat9, lon_x9, firstIndexRow2 + ix4)); + points.push_back(MvGridPoint(grid_11, lat1, MvLocation::normaliseLongitude(lon_x1, -180.), firstIndex + ix1)); + points.push_back(MvGridPoint(grid_12, lat1, MvLocation::normaliseLongitude(lon_x2, -180.), firstIndex + ix2)); + points.push_back(MvGridPoint(grid_21, lat9, MvLocation::normaliseLongitude(lon_x8, -180.), firstIndexRow2 + ix3)); + points.push_back(MvGridPoint(grid_22, lat9, MvLocation::normaliseLongitude(lon_x9, -180.), firstIndexRow2 + ix4)); if (doSort) { MvGridPoint::sortByDistance(points, MvLocation(lat_y, lon_x)); @@ -3017,21 +3124,19 @@ if (!globalNS_ && lat_y < latitudes_[lastLatIndex_]) //-- after last row in a sub-area? return cMissingPoint; - int row9 = firstLatIndex_; //-- find row S of pt + int row9 = firstLatIndex_; //-- find row S of pt double lat9 = latitudes_[row9]; while (lat9 > lat_y && row9 < firstLatIndex_ + horisLines_) { lat9 = latitudes_[++row9]; } - - if (row9 == lastLatIndex_ + 1) // spill over the last row? then go back to the last row + bool borderRow = (row9 == firstLatIndex_ || row9 == lastLatIndex_+1); + if (row9 == lastLatIndex_ + 1) { // spill over the last row? then go back to the last row row9 = lastLatIndex_; + } - - bool borderRow = (row9 == firstLatIndex_ || row9 == lastLatIndex_); - - int row1 = (borderRow) ? row9 : row9 - 1; //-- previous row is N of pt - double lat1 = latitudes_[row1]; + int row1 = (borderRow) ? row9 : row9 - 1; //-- previous row is N of pt + double lat1 = latitudes_[row1]; int pointsInRow1 = pointsInRow(row1); // to get the longitude interval, we need to consider the difference @@ -3046,33 +3151,39 @@ // is not a valid concept and we set it to zero int moreThanOnePointInRow = (pointsInRow1 > 1); - double dataLonWidth = (globalEW_) ? 360.0 : lastLonXInArea(row1) - firstLonXInArea(row1); - int numIntervals = (globalEW_) ? pointsInRow1 : pointsInRow1 - 1; - double dx1 = (moreThanOnePointInRow) ? (dataLonWidth / numIntervals) : 0; //-- N row increment + double dataLonWidth = (globalEW_) ? cFullGlobeD : lastLonXInArea(row1) - firstLonXInArea(row1); + int numIntervals = (globalEW_) ? pointsInRow1 : pointsInRow1 - 1; + double dx1 = (moreThanOnePointInRow) ? (dataLonWidth / numIntervals) : 0; //-- N row increment int firstIndex = 0; //-- => find pts on N row <= --// for (int i = firstLatIndex_; i < row1; ++i) firstIndex += pointsInRow(i); //-- offset - double firstLon = firstLonXInArea(row1); //firstLonX(); - if (firstLon > lon_x) - if (globalEW_ || ((firstLon > 180) && (firstLon - 360.0 <= lon_x))) //-- normalise acording to lon_x - firstLon -= 360.0; - - - int ix1 = (moreThanOnePointInRow) ? int((lon_x - firstLon) / dx1) : 0; //-- column W of pt - int ix2 = (ix1 == (pointsInRow1 - 1)) ? //-- column E of pt: - 0 - : ix1 + 1; //-- first or next! + // normalise lon range + double firstLon = firstLonXInArea(row1); + double lastLon = lastLonXInArea(row1); + MvLocation::normaliseRangeToLongitude(firstLon, lastLon, lon_x); - if (ix1 > pointsInRow1) //-- outside the data row? - { - return cMissingPoint; + // determine column on west (ix1) and east (ix2) side of the point + bool northJustOutSide = false; + int ix1 = 0; + int ix2 = 0; + if (moreThanOnePointInRow) { + if (!computeLonIndex(lon_x, firstLon, dataLonWidth, dx1, pointsInRow1, ix1, ix2)) { + if (!globalEW_ && + ix1 == pointsInRow1-1 && ix2 == pointsInRow1) { + ix1--; + ix2--; + northJustOutSide = true; + } else { + return cMissingPoint; + } + } } double grid_11 = valueAt(firstIndex + ix1); //-- value in W pt double grid_12 = valueAt(firstIndex + ix2); //-- value in E pt - double lon_x1 = firstLon + ix1 * dx1; //-- longitude of W pt + double lon_x1 = firstLon + ix1 * dx1; //-- longitude of W pt MvLocation point(lat_y, lon_x); MvGridPoint gridPoint[4]; //-- surrounding grid points @@ -3083,7 +3194,7 @@ double closestDistance = point.distanceInMeters(gridPoint[0].loc_); if (point.distanceInMeters(gridPoint[1].loc_) < closestDistance) { closestDistance = point.distanceInMeters(gridPoint[1].loc_); - gridPoint[0] = gridPoint[1]; + gridPoint[0] = gridPoint[1]; } if (borderRow) // border row - no need to look at another row @@ -3094,23 +3205,36 @@ //-- => find pts on S row <= --// firstIndex += pointsInRow1; - firstLon = firstLonXInArea(row9); - if (firstLon > lon_x) - if (globalEW_ || ((firstLon > 180) && (firstLon - 360.0 <= lon_x))) //-- normalise acording to lon_x - firstLon -= 360.0; + // normalise lon range + firstLon = firstLonXInArea(row9); + lastLon = lastLonXInArea(row9); + MvLocation::normaliseRangeToLongitude(firstLon, lastLon, lon_x); - int pointsInRow9 = pointsInRow(row9); + int pointsInRow9 = pointsInRow(row9); moreThanOnePointInRow = (pointsInRow9 > 1); - dataLonWidth = (globalEW_) ? 360.0 : lastLonXInArea(row9) - firstLonXInArea(row9); + dataLonWidth = (globalEW_) ? cFullGlobeD : lastLonXInArea(row9) - firstLonXInArea(row9); numIntervals = (globalEW_) ? pointsInRow9 : pointsInRow9 - 1; - double dx9 = (moreThanOnePointInRow) ? (dataLonWidth / numIntervals) : 0; //-- S row increment + double dx9 = (moreThanOnePointInRow) ? (dataLonWidth / numIntervals) : 0; //-- S row increment - ix1 = (moreThanOnePointInRow) ? int((lon_x - firstLon) / dx9) : 0; //-- column W of pt - ix2 = (ix1 == (pointsInRow9 - 1)) ? //-- column E of pt: - 0 - : ix1 + 1; //-- first or next! + // determine column on west (ix1) and east (ix2) side of the point + ix1 = 0; + ix2 = 0; + if (moreThanOnePointInRow) { + if (!computeLonIndex(lon_x, firstLon, dataLonWidth, dx9, pointsInRow9, ix1, ix2)) { + if (!globalEW_) { + if (!northJustOutSide && ix1 == pointsInRow9-1 && ix2 == pointsInRow9) { + ix1--; + ix2--; + } else { + return cMissingPoint; + } + } else { + return cMissingPoint; + } + } + } grid_11 = valueAt(firstIndex + ix1); //-- value in W pt grid_12 = valueAt(firstIndex + ix2); //-- value in E pt @@ -3124,15 +3248,14 @@ { if (point.distanceInMeters(gridPoint[p].loc_) < closestDistance) { closestDistance = point.distanceInMeters(gridPoint[p].loc_); - gridPoint[0] = gridPoint[p]; + gridPoint[0] = gridPoint[p]; } } - if (gridPoint[0].loc_.longitude() >= 360.0) - gridPoint[0].loc_.set(gridPoint[0].loc_.latitude(), - gridPoint[0].loc_.longitude() - 360.0); - + // lon will be in the range of [-180, 180] + gridPoint[0].loc_.set(gridPoint[0].loc_.latitude(), + MvLocation::normaliseLongitude(gridPoint[0].loc_.longitude(), -180.)); #if 0 std::cout << "Closest point: " @@ -3141,58 +3264,12 @@ << std::endl; #endif - return gridPoint[0]; + return gridPoint[0]; } //------------------------------------------------------ double MvIrregularGrid::interpolatePoint(double lat_y, double lon_x, std::vector* surroundingPoints) { -// This should be the new method -#if 0 - if (!field_) //-- non-valid msg? - return DBL_MAX; - - if (isSouthToNorthScanning_) { - marslog(LOG_INFO, "Nearest grid point used (no interpolation yet for S->N Gaussian grids)"); - return nearestGridpoint(lat_y, lon_x, false).value_; - } - - // before first row or after last row ? - if (lat_y > latitudes_[firstLatIndex_] || lat_y < latitudes_[lastLatIndex_]) { - if (globalNS_) - return extrapolatePoint(lat_y, lon_x, surroundingPoints); //// XXXX don't forget to do this!!! - else - return DBL_MAX; - } - - std::vector points; - if (!surroundingGridpoints(lat_y, lon_x, points, false)) { - return cMissingPoint; - } - - assert(points.size() == 4); - - // interpolate north row - double dx1 = fabs(point[0].loc_.longitude() - point[1].loc_.longitude()); - double w = fabs((lon_x - point[0].loc_.longitude()) / dx1); - double w2 = 1. - w1; - double val1 = w2 * point[0].value_ + w1 * point[1].value_; - - // interpolate on S row - double dx9 = fabs(point[2].loc_.longitude() - point[3].loc_.longitude()); - w1 = fabs((lon_x - point[2].loc_.longitude()) / dx9); - w2 = 1. - w1; - double val2 = w2 * point[2].value_ + w1 * point[3].value_; - - // interpolate in lat - double dy = fabs(point[0].loc_.latitude() - point[2].loc_.latitude()); - w1 = (lat_y - (point[2].loc_.latitude())) / dy; //-- interpolate in lat - w2 = 1. - w1; - return val1 * w1 + val2 * w2; - -#endif - - if (isSouthToNorthScanning_) { marslog(LOG_INFO, "Nearest grid point used (no interpolation yet for S->N Gaussian grids)"); return nearestGridpoint(lat_y, lon_x, false).value_; @@ -3209,17 +3286,16 @@ return DBL_MAX; } - int row9 = firstLatIndex_; //-- find row S of pt + int row9 = firstLatIndex_; //-- find row S of pt double lat9 = latitudes_[row9]; while (lat9 > lat_y && row9 < firstLatIndex_ + horisLines_) { lat9 = latitudes_[++row9]; } bool borderRow = (row9 == firstLatIndex_); - //-- what about South Polish? - int row1 = borderRow ? row9 : row9 - 1; //-- previous row is N of pt - double lat1 = latitudes_[row1]; + int row1 = borderRow ? row9 : row9 - 1; //-- previous row is N of pt + double lat1 = latitudes_[row1]; int pointsInRow1 = pointsInRow(row1); // to get the longitude interval, we need to consider the difference @@ -3231,34 +3307,33 @@ // a) |o o o | // b) |o o o | - double dataLonWidth = (globalEW_) ? 360.0 : lastLonXInArea(row1) - firstLonXInArea(row1); - int numIntervals = (globalEW_) ? pointsInRow1 : pointsInRow1 - 1; - double dx1 = dataLonWidth / numIntervals; //-- N row increment - + double dataLonWidth = (globalEW_) ? cFullGlobeD : lastLonXInArea(row1) - firstLonXInArea(row1); + int numIntervals = (globalEW_) ? pointsInRow1 : pointsInRow1 - 1; + double dx1 = dataLonWidth / numIntervals; //-- N row increment int firstIndex = 0; //-- => find pts on N row <= for (int i = firstLatIndex_; i < row1; ++i) firstIndex += pointsInRow(i); //-- offset + // normalise lon range double firstLon = firstLonXInArea(row1); - if (globalEW_ && (firstLon > lon_x)) //-- normalise acording to lon_x - firstLon -= 360.0; - - int ix1 = int((lon_x - firstLon) / dx1); //-- column W of pt - int ix2 = (ix1 == (pointsInRow1 - 1)) ? //-- column E of pt: - 0 - : ix1 + 1; //-- first or next! - - if (ix1 > pointsInRow1 || //-- ix1 outside the data row? - (!globalEW_ && (ix2 < ix1))) //-- sub-area, and ix2 is first point? - { - return DBL_MAX; + double lastLon = lastLonXInArea(row1); + MvLocation::normaliseRangeToLongitude(firstLon, lastLon, lon_x); +// std::cout << std::setprecision(20) << "term1= " << lon_x - firstLon << " term2=" << (lon_x - firstLon) / dx1 << std::endl; + + // determine column on west (ix1) and east (ix2) side of the point + int ix1 = 0; + int ix2 = 0; + if (!computeLonIndex(lon_x, firstLon, dataLonWidth, dx1, pointsInRow1, ix1, ix2)) { + return DBL_MAX; } - double grid_11 = valueAt(firstIndex + ix1); //-- value in W pt double grid_12 = valueAt(firstIndex + ix2); //-- value in E pt +// std::cout << "lat1=" << lat1 << " pointsInRow1=" << pointsInRow1 << " ix1=" << ix1 << " ix2=" << ix2 << +// " grid_11=" << grid_11 << " grid_12=" << grid_12 << std::endl; + if (grid_11 == mars.grib_missing_value || grid_12 == mars.grib_missing_value) { return DBL_MAX; @@ -3266,39 +3341,41 @@ //-- interpolate on N row double lon_x1 = firstLon + ix1 * dx1; double lon_x2 = firstLon + ix2 * dx1; - double w1 = fabs((lon_x - lon_x1) / dx1); - double w2 = 1. - w1; - double val1 = w2 * grid_11 + w1 * grid_12; + double w1 = fabs((lon_x - lon_x1) / dx1); + double w2 = 1. - w1; + double val1 = w2 * grid_11 + w1 * grid_12; if (borderRow) return val1; + //-- => find pts on S row <= int firstIndexRow2 = firstIndex + pointsInRow1; - firstLon = firstLonXInArea(row9); - if (globalEW_ && (firstLon > lon_x)) //-- normalise acording to lon_x - firstLon -= 360.0; + + // normalise lon range + firstLon = firstLonXInArea(row9); + lastLon = lastLonXInArea(row9); + MvLocation::normaliseRangeToLongitude(firstLon, lastLon, lon_x); int pointsInRow9 = pointsInRow(row9); - dataLonWidth = (globalEW_) ? 360.0 : lastLonXInArea(row9) - firstLonXInArea(row9); + dataLonWidth = (globalEW_) ? cFullGlobeD : lastLonXInArea(row9) - firstLonXInArea(row9); numIntervals = (globalEW_) ? pointsInRow9 : pointsInRow9 - 1; - double dx9 = dataLonWidth / numIntervals; //-- S row increment - double dy = lat1 - lat9; - - int ix3 = int((lon_x - firstLon) / dx9); //-- column W of pt - int ix4 = (ix3 == (pointsInRow9 - 1)) ? //-- column E of pt: - 0 - : ix3 + 1; //-- first or next! + double dx9 = dataLonWidth / numIntervals; //-- S row increment + double dy = lat1 - lat9; - if (ix3 > pointsInRow9 || //-- ix1 outside the data row? - (!globalEW_ && (ix4 < ix3))) //-- sub-area, and ix2 is first point? - { - return DBL_MAX; + // determine column on west (ix3) and east (ix4) side of the point + int ix3 = -1; + int ix4 = -1; + if (!computeLonIndex(lon_x, firstLon, dataLonWidth, dx9, pointsInRow9, ix3, ix4)) { + return DBL_MAX; } double grid_21 = valueAt(firstIndexRow2 + ix3); //-- value in W pt double grid_22 = valueAt(firstIndexRow2 + ix4); //-- value in E pt +// std::cout << "lat9=" << lat9 << " pointsInRow9=" << pointsInRow9 << " ix3=" << ix3 << " ix4=" << ix4 << +// " grid_21=" << grid_21 << " grid_22=" << grid_22 << std::endl; + if (grid_21 == mars.grib_missing_value || grid_22 == mars.grib_missing_value) { return DBL_MAX; @@ -3309,17 +3386,17 @@ double lon_x9 = firstLon + ix4 * dx9; // the calling function wants a list of the surrounding grid points sorted by distance - surroundingPoints->push_back(MvGridPoint(grid_11, lat1, lon_x1, firstIndex + ix1)); - surroundingPoints->push_back(MvGridPoint(grid_12, lat1, lon_x2, firstIndex + ix2)); - surroundingPoints->push_back(MvGridPoint(grid_21, lat9, lon_x8, firstIndexRow2 + ix3)); - surroundingPoints->push_back(MvGridPoint(grid_22, lat9, lon_x9, firstIndexRow2 + ix4)); + surroundingPoints->push_back(MvGridPoint(grid_11, lat1, MvLocation::normaliseLongitude(lon_x1, -180.), firstIndex + ix1)); + surroundingPoints->push_back(MvGridPoint(grid_12, lat1, MvLocation::normaliseLongitude(lon_x2, -180.), firstIndex + ix2)); + surroundingPoints->push_back(MvGridPoint(grid_21, lat9, MvLocation::normaliseLongitude(lon_x8, -180.), firstIndexRow2 + ix3)); + surroundingPoints->push_back(MvGridPoint(grid_22, lat9, MvLocation::normaliseLongitude(lon_x9, -180.), firstIndexRow2 + ix4)); } //-- interpolate on S row double lon_x9 = firstLon + ix3 * dx9; - w1 = fabs((lon_x - lon_x9) / dx9); - w2 = 1. - w1; + w1 = fabs((lon_x - lon_x9) / dx9); + w2 = 1. - w1; double val2 = w2 * grid_21 + w1 * grid_22; w1 = (lat_y - lat9) / dy; //-- interpolate in lat @@ -3327,6 +3404,40 @@ return val1 * w1 + val2 * w2; } +// determines west (idx1) and east (idx2) gridpoint index for the specified lon_x value. +bool MvIrregularGrid::computeLonIndex(double lon_x, double firstLon, double dataLonWidth, double dx, int pointsInRow, int& idx1, int& idx2) const +{ + idx1 = -1; + idx2 = -1; + + idx1 = int((lon_x - firstLon) / dx); + + // check situation when lon is extremely close to the eastern border + if (globalEW_) { + if (idx1 == pointsInRow && + lon_x <= firstLon + dataLonWidth && + std::fabs(dataLonWidth - (lon_x - firstLon)) < lonDeltaNearEastBorder_) { + idx1--; + } + idx2 = (idx1 == (pointsInRow - 1)) ? 0: idx1 + 1; + if (idx1 >= pointsInRow || idx2 > pointsInRow) { + return false; + } + } else { + if (idx1 == pointsInRow-1 && + lon_x <= firstLon + dataLonWidth && + std::fabs(dataLonWidth - (lon_x - firstLon)) < lonDeltaNearEastBorder_) { + idx1--; + } + idx2 = idx1 + 1; + if (idx1 > pointsInRow-2 || idx2 > pointsInRow) { + return false; + } + } + + return (idx1 >= 0 && idx2 >= 0); +} + // see the description at MvLatLonGrid::gridCellArea void MvIrregularGrid::gridCellArea(MvGridBase* outGrd) { @@ -3342,10 +3453,10 @@ assert(currentLatIndex_ == 0 || currentLatIndex_ == numGlobalParallels_ - 1); - double lat1 = latitudes_[0]; - double lat2 = latitudes_[1]; + double lat1 = latitudes_[0]; + double lat2 = latitudes_[1]; double latCap = (fabs(lat1) + fabs(lat2)) / 2.; - areaPole = fabs(cEarthRadius * cEarthRadius * (1. - sin(latCap * cToRadians)) * dx_ * cToRadians); + areaPole = fabs(cEarthRadius * cEarthRadius * (1. - sin(latCap * cToRadians)) * dx_ * cToRadians); } double v = 0; @@ -3366,7 +3477,7 @@ currentBoundingLats(lat_b1, lat_b2); double lat1 = (currentLaty_ + lat_b1) / 2; double lat2 = (currentLaty_ + lat_b2) / 2; - v = w * cos(((lat1 + lat2) / 2.) * cToRadians) * sin((fabs(lat1 - lat2) / 2.) * cToRadians) * dx_ * cToRadians; + v = w * cos(((lat1 + lat2) / 2.) * cToRadians) * sin((fabs(lat1 - lat2) / 2.) * cToRadians) * dx_ * cToRadians; } } @@ -3392,8 +3503,8 @@ } if (v[1] > 180 && v[3] > 180) { - v[1] = v[1] - 360; - v[3] = v[3] - 360; + v[1] = v[1] - cFullGlobeD; + v[3] = v[3] - cFullGlobeD; } } @@ -3417,7 +3528,7 @@ // create and populate the array of latutudes (these are constantly spaced) - double dy = getDouble("jDirectionIncrementInDegrees"); // sec2_->grid_ew / cGridScaling; + double dy = getDouble("jDirectionIncrementInDegrees"); // sec2_->grid_ew / cGridScaling; numGlobalParallels_ = (long)(180.0 / dy) + 1; latitudes_ = new double[numGlobalParallels_]; @@ -3430,11 +3541,11 @@ checkAreaLimits(); //-- maybe only a subarea currentLatIndex_ = firstLatIndex_; - currentLaty_ = latitudes_[currentLatIndex_]; - currentLonx_ = firstLonX(); + currentLaty_ = latitudes_[currentLatIndex_]; + currentLonx_ = firstLonX(); horisPoints_ = pointsInRow(currentLatIndex_); - dx_ = horisPoints_ ? (360.0 / horisPoints_) : 0; + dx_ = horisPoints_ ? (cFullGlobeD / horisPoints_) : 0; } //------------------------------------------------------ @@ -3456,9 +3567,9 @@ return 0; //-- must be valid message if (!pointsInRow_) { - size_t len = horisLines_; + size_t len = horisLines_; pointsInRow_ = new long[len]; - int err = grib_get_long_array(field_->handle, "pl", pointsInRow_, &len); + int err = grib_get_long_array(field_->handle, "pl", pointsInRow_, &len); if (err) marslog(LOG_EROR, "MvReducedLatLongGrid::pointsInRow - ecCodes: 'pl' not found!"); } @@ -3484,11 +3595,11 @@ currentLaty_ = latitudes_[currentLatIndex_]; currentLonx_ = firstLonX(); - //horisPoints_ = field_->ksec2[ cNPtsIndexBegin + currentLatIndex_ ]; - horisPoints_ = pointsInRow(currentLatIndex_); - dx_ = (360.0 / horisPoints_); + // horisPoints_ = field_->ksec2[ cNPtsIndexBegin + currentLatIndex_ ]; + horisPoints_ = pointsInRow(currentLatIndex_); + dx_ = (cFullGlobeD / horisPoints_); horisPointCount_ = 0; - //cout << currentIndex_ << '\t' << currentLaty_ << '\t' << horisPoints_ << std::endl; + // cout << currentIndex_ << '\t' << currentLaty_ << '\t' << horisPoints_ << std::endl; } else { currentLonx_ += dx_; @@ -3564,8 +3675,8 @@ long halfNumParallels_ = getLong("numberOfParallelsBetweenAPoleAndTheEquator"); // sec2_->gauss_trunc * 2; - numGlobalParallels_ = halfNumParallels_ * 2; - latitudes_ = new double[numGlobalParallels_]; + numGlobalParallels_ = halfNumParallels_ * 2; + latitudes_ = new double[numGlobalParallels_]; int err = MvGaussianGridBase::gLatitudes_.latitudes(halfNumParallels_, latitudes_, numGlobalParallels_); @@ -3577,30 +3688,27 @@ } //------------------------------------------------------ +// extract surrounding gridpoints when target location is outside the grid +// (i.e. north or south polar cap). bool MvGaussianGridBase::surroundingGridpointsForExtrapolation(double lat_y, double lon_x, std::vector& points, bool canHaveMissing, bool doSort) { - // 1. compute the mean of the first/last latitude values - // 2. associate this mean value to the north/south pole - // 3. retrieve the 2 nearest points along the first/last longitude values - // 4. interpolate using these 3 values (triangle) - // Initialize variablesCompute the initial position and npoints in the data array int firstIndex; // first position in the data array int np; // number of points along the latitude double gLat; - //north pole + // north pole if (lat_y > latitudes_[0]) { - np = pointsInRow(0); - gLat = latitudes_[0]; + np = pointsInRow(0); + gLat = latitudes_[0]; firstIndex = 0; // south pole } else if (lat_y < latitudes_[horisLines_ - 1]) { - np = pointsInRow(horisLines_ - 1); - gLat = latitudes_[horisLines_ - 1]; + np = pointsInRow(horisLines_ - 1); + gLat = latitudes_[horisLines_ - 1]; firstIndex = length() - np; } else { @@ -3608,18 +3716,18 @@ return false; } - double dx = 360.0 / np; //-- N row increment - double startLon = firstLonX(); //-- first longitude value + double dx = cFullGlobeD / np; //-- N row increment - // normalise acordingly - if (startLon > lon_x) - startLon -= 360.0; + // normalise lon range + double startLon = firstLonX(); + double endLon = lastLonX(); + MvLocation::normaliseRangeToLongitude(startLon, endLon, lon_x); // reverse order so that we could get the same nearest point as with nearest_gridpoint!! for (int i = np - 1; i >= 0; i--) { double gLon = startLon + i * dx; - int idx = firstIndex + i; - double val = valueAt(idx); + int idx = firstIndex + i; + double val = valueAt(idx); if (!canHaveMissing && val == mars.grib_missing_value) return false; else @@ -3630,6 +3738,10 @@ MvGridPoint::sortByDistance(points, MvLocation(lat_y, lon_x)); } + for (int i = np - 1; i >= 0; i--) { + points[i].loc_.normaliseLongitude(-180.); + } + return true; } @@ -3647,21 +3759,21 @@ double dy; // latitude interval = lat1 - lat9; double wlat; // latitude weight double gLat; - if (lat_y > latitudes_[0]) //north pole + if (lat_y > latitudes_[0]) // north pole { - np = pointsInRow(0); - dy = 90. - latitudes_[0]; - wlat = (lat_y - latitudes_[0]) / dy; - gLat = latitudes_[0]; + np = pointsInRow(0); + dy = 90. - latitudes_[0]; + wlat = (lat_y - latitudes_[0]) / dy; + gLat = latitudes_[0]; firstIndex = row = 0; } else if (lat_y < latitudes_[horisLines_ - 1]) // south pole { - np = pointsInRow(horisLines_ - 1); - row = horisLines_ - 1; - dy = latitudes_[horisLines_ - 1] - (-90.); - wlat = (latitudes_[horisLines_ - 1] - lat_y) / dy; - gLat = latitudes_[horisLines_ - 1]; + np = pointsInRow(horisLines_ - 1); + row = horisLines_ - 1; + dy = latitudes_[horisLines_ - 1] - (-90.); + wlat = (latitudes_[horisLines_ - 1] - lat_y) / dy; + gLat = latitudes_[horisLines_ - 1]; firstIndex = length() - np; } else { @@ -3671,17 +3783,17 @@ // if we only need the surrounding points if (surroundingPoints) { - double dx = 360.0 / np; //-- N row increment - double startLon = firstLonX(); //-- first longitude value + double dx = cFullGlobeD / np; //-- N row increment - // normalise acordingly - if (startLon > lon_x) - startLon -= 360.0; + // normalise lon range + double startLon = firstLonX(); + double endLon = lastLonX(); + MvLocation::normaliseRangeToLongitude(startLon, endLon, lon_x); for (int i = 0; i < np; i++) { double gLon = startLon + i * dx; - int idx = firstIndex + i; - surroundingPoints->push_back(MvGridPoint(valueAt(idx), gLat, gLon, idx)); + int idx = firstIndex + i; + surroundingPoints->push_back(MvGridPoint(valueAt(idx), gLat, MvLocation::normaliseLongitude(gLon, -180.), idx)); } } @@ -3694,16 +3806,22 @@ if (mean == mars.grib_missing_value) return DBL_MAX; + auto pointsInCurrentRow = pointsInRow(row); + // Retrieve the 2 nearest points along the first/last latitude line - double dx1 = 360.0 / pointsInRow(row); //-- N row increment - double firstLon = firstLonX(); //-- first longitude value - if (firstLon > lon_x) //-- normalise acordingly - firstLon -= 360.0; - - int ix1 = int((lon_x - firstLon) / dx1); //-- column W of pt - int ix2 = (ix1 == (pointsInRow(row))) ? //-- column E of pt: - 0 - : ix1 + 1; //-- first or next! + double dx1 = cFullGlobeD / pointsInCurrentRow; //-- N row increment + + // normalise lon range + double firstLon = firstLonX(); + double lastLon = lastLonX(); + MvLocation::normaliseRangeToLongitude(firstLon, lastLon, lon_x); + + //-- columns W (ix1) and E (ix2) of pt + int ix1 = 0; + int ix2 = 0; + if (!computeLonIndex(lon_x, firstLon, cFullGlobeD, dx1, pointsInCurrentRow, ix1, ix2)) { + return DBL_MAX; + } double grid_11 = valueAt(firstIndex + ix1); //-- value in W pt double grid_12 = valueAt(firstIndex + ix2); //-- value in E pt @@ -3714,9 +3832,9 @@ // Interpolate on latitude row double lon_x1 = firstLon + ix1 * dx1; - double w1 = (lon_x - lon_x1) / dx1; - double w2 = 1. - w1; - double val1 = w2 * grid_11 + w1 * grid_12; + double w1 = (lon_x - lon_x1) / dx1; + double w2 = 1. - w1; + double val1 = w2 * grid_11 + w1 * grid_12; // Interpolate in lat w2 = 1. - wlat; @@ -3753,9 +3871,9 @@ checkAreaLimits(); //-- maybe only a subarea currentLatIndex_ = firstLatIndex_; - currentLaty_ = latitudes_[currentLatIndex_]; - currentLonx_ = firstLonX(); - dx_ = getDouble("iDirectionIncrementInDegrees"); // sec2_->grid_ew / cGridScaling; + currentLaty_ = latitudes_[currentLatIndex_]; + currentLonx_ = firstLonX(); + dx_ = getDouble("iDirectionIncrementInDegrees"); // sec2_->grid_ew / cGridScaling; } //------------------------------------------------------ @@ -3770,8 +3888,8 @@ else ++currentLatIndex_; - currentLaty_ = latitudes_[currentLatIndex_]; - currentLonx_ = firstLonX(); + currentLaty_ = latitudes_[currentLatIndex_]; + currentLonx_ = firstLonX(); horisPointCount_ = 0; } else { @@ -3797,15 +3915,15 @@ MvReducedGaussianGrid::MvReducedGaussianGrid(field* myfield, field_state oldState, bool memoryToBeReleased) : MvGaussianGridBase(myfield, oldState, memoryToBeReleased) { - //horisPoints_ = field_->ksec2[ cNPtsIndexBegin ]; + // horisPoints_ = field_->ksec2[ cNPtsIndexBegin ]; pointsInRow_ = 0; checkAreaLimits(); //-- maybe only a subarea currentLatIndex_ = firstLatIndex_; - currentLaty_ = latitudes_[currentLatIndex_]; - currentLonx_ = firstLonX(); + currentLaty_ = latitudes_[currentLatIndex_]; + currentLonx_ = firstLonXInArea(firstLatIndex_); // this sets the current dx_ as well horisPoints_ = pointsInRow(firstLatIndex_); @@ -3828,7 +3946,7 @@ long numPts = 0; if (!globalEW_) { - double lonlast = 0; + double lonlast = 0; int globalPointsInThisRow = pointsInRow_ ? pointsInRow_[row - firstLatIndex_] : 0; grib_get_reduced_row_p(globalPointsInThisRow, firstLonX(), lastLonX(), &numPts, &firstLonXInArea, &lonlast); } @@ -3875,11 +3993,11 @@ currentLaty_ = latitudes_[currentLatIndex_]; currentLonx_ = firstLonXInArea(currentLatIndex_); - //horisPoints_ = field_->ksec2[ cNPtsIndexBegin + currentLatIndex_ ]; + // horisPoints_ = field_->ksec2[ cNPtsIndexBegin + currentLatIndex_ ]; horisPoints_ = pointsInRow(currentLatIndex_); - //dx_ = ( 360.0 / horisPoints_ ); + // dx_ = ( 360.0 / horisPoints_ ); horisPointCount_ = 0; - //std::cout << currentIndex_ << '\t' << currentLaty_ << '\t' << horisPoints_ << std::endl; + // std::cout << currentIndex_ << '\t' << currentLaty_ << '\t' << horisPoints_ << std::endl; } else { currentLonx_ += dx_; @@ -3898,9 +4016,9 @@ return 0; //-- must be valid message if (!pointsInRow_) { - size_t len = horisLines_; + size_t len = horisLines_; pointsInRow_ = new long[len]; - int err = grib_get_long_array(field_->handle, "pl", pointsInRow_, &len); + int err = grib_get_long_array(field_->handle, "pl", pointsInRow_, &len); if (err) marslog(LOG_EROR, "MvReducedGaussianGrid::pointsInRow - ecCodes: 'pl' not found!"); } @@ -3909,7 +4027,7 @@ //-- row: 0,1,2,... //-- int globalPointsInThisRow = pointsInRow_ ? pointsInRow_[row - firstLatIndex_] : 0; - dx_ = (360.0 / globalPointsInThisRow); + dx_ = (cFullGlobeD / globalPointsInThisRow); if (globalEW_) return globalPointsInThisRow; else { @@ -3942,7 +4060,7 @@ pimin1_(); // Initialize Datum - double Prd = 6378160.; + double Prd = 6378160.; double Pflt = 0.00335289186; pimind_(PROJSATELLITE, (char*)"satellite", 0., 0., 0., Prd, Pflt); @@ -3951,27 +4069,27 @@ pimg1_(1, 0., 0., 0., 0.); // Initialize Satellite projection - double satnr = getDouble("NrInRadiusOfEarthScaled", SATHROW); //float(sec2_->altitude); - double satdy = getLong("dy", SATHROW); //float(sec2_->y_diameter); - double satdx = getLong("dx", SATHROW); //float(sec2_->x_diameter); + double satnr = getDouble("NrInRadiusOfEarthScaled", SATHROW); // float(sec2_->altitude); + double satdy = getLong("dy", SATHROW); // float(sec2_->y_diameter); + double satdx = getLong("dx", SATHROW); // float(sec2_->x_diameter); double SPri = 2.0 * asin(1.0 / satnr) / satdy; double SPrj = 2.0 * asin(1.0 / satnr) / satdx; - double SPis = getDouble("YpInGridLengths", SATHROW); //double(sec2_->y_coordinate); - double SPjs = getDouble("XpInGridLengths", SATHROW); //double(sec2_->x_coordinate); + double SPis = getDouble("YpInGridLengths", SATHROW); // double(sec2_->y_coordinate); + double SPjs = getDouble("XpInGridLengths", SATHROW); // double(sec2_->x_coordinate); - //double SPla0 = double(sec2_->latitude_point) * 0.001*CDR; - //double SPlo0 = double(sec2_->longitude_point) * 0.001*CDR; + // double SPla0 = double(sec2_->latitude_point) * 0.001*CDR; + // double SPlo0 = double(sec2_->longitude_point) * 0.001*CDR; double lat_pt = getDouble("latitudeOfSubSatellitePoint", SATHROW); double lon_pt = getDouble("longitudeOfSubSatellitePoint", SATHROW); - double SPla0 = lat_pt * 0.001 * CDR; - double SPlo0 = lon_pt * 0.001 * CDR; + double SPla0 = lat_pt * 0.001 * CDR; + double SPlo0 = lon_pt * 0.001 * CDR; - double SPrs = satnr * EARTH_RADIUS; - double SPscn = getLong("scanningMode", SATHROW); //double(sec2_->scan_mode); + double SPrs = satnr * EARTH_RADIUS; + double SPscn = getLong("scanningMode", SATHROW); // double(sec2_->scan_mode); - //double SPyaw = double(sec2_->orientation) * 0.001*CDR; + // double SPyaw = double(sec2_->orientation) * 0.001*CDR; double orien = getDouble("orientationOfTheGrid", SATHROW); // previous key name (ga 1.8.0): orientationOfTheGridInMillidegrees double SPyaw = orien * 0.001 * CDR; @@ -3983,10 +4101,10 @@ pims1_(SPri, SPrj, SPis, SPjs, SPla0, SPlo0, SPrs, SPscn, SPyaw); // Initialize Image - long lin = getLong("numberOfPointsAlongYAxis", SATHROW); //short(sec2_->ny); - long col = getLong("numberOfPointsAlongXAxis", SATHROW); //short(sec2_->nx); - double satx0 = getDouble("xCoordinateOfOriginOfSectorImage", SATHROW); //double(sec2_->x_origin); - double saty0 = getDouble("yCoordinateOfOriginOfSectorImage", SATHROW); //double(sec2_->y_origin); + long lin = getLong("numberOfPointsAlongYAxis", SATHROW); // short(sec2_->ny); + long col = getLong("numberOfPointsAlongXAxis", SATHROW); // short(sec2_->nx); + double satx0 = getDouble("xCoordinateOfOriginOfSectorImage", SATHROW); // double(sec2_->x_origin); + double saty0 = getDouble("yCoordinateOfOriginOfSectorImage", SATHROW); // double(sec2_->y_origin); double bllx = satx0 * atan(tan(2.0 * asin(1.0 / satnr) / satdx) * (satnr - 1.0)) * EARTH_RADIUS; @@ -4006,7 +4124,7 @@ MvSatelliteImage::~MvSatelliteImage() = default; -//static int ftest=0; +// static int ftest=0; MvGridPoint MvSatelliteImage::nearestGridpoint(double lat_y, double lon_x, bool /*nearestValid*/) { //-- @@ -4133,9 +4251,9 @@ long flg = getLong("section4.flag"); if (flg == 0) // field_->ksec4[4] == 0 ) - return dd; //float representation + return dd; // float representation else { -#ifdef LITTLE_END //integer representation +#ifdef LITTLE_END // integer representation return (double)ia[0]; #else return (double)ia[1]; @@ -4187,7 +4305,7 @@ size_t slen = cMaxBuf; MvGridBase* grd = 0; - int err = grib_get_string(myfield->handle, "typeOfGrid", strbuf, &slen); + int err = grib_get_string(myfield->handle, "typeOfGrid", strbuf, &slen); if (err != 0) { grd = new MvUnimplementedGrid(myfield, oldState); marslog(LOG_EROR, "MvGridFactory: failed getting grib_get_long->typeOfGrid"); @@ -4292,15 +4410,15 @@ n = north > south ? north : south; //-- force n >= s s = south < north ? south : north; //-- force s <= n - e = east > 0 ? east : east + 360.0; //-- force 0 < e <= 360 + e = east > 0 ? east : east + cFullGlobeD; //-- force 0 < e <= 360 if (west == east) w = e; //-- vertical line else - w = west > east ? west - 360.0 : west; //-- force -360 <= w <= e + w = west > east ? west - cFullGlobeD : west; //-- force -360 <= w <= e - if ((e - w) > 360.0) //-- force (e-w) <= 360 - w += 360.0; + if ((e - w) > cFullGlobeD) //-- force (e-w) <= 360 + w += cFullGlobeD; // marslog( LOG_DBUG, "MvGeoBox [ %g, %g, %g, %g ]", n,w,s,e ); } @@ -4324,9 +4442,9 @@ return 0; //-- outside n-s band! if (lon_x > e) //-- assume -360 <= lon_x <= 360 - lon_x -= 360.0; //-- and try to normalize + lon_x -= cFullGlobeD; //-- and try to normalize if (lon_x < w) - lon_x += 360.0; + lon_x += cFullGlobeD; if (lon_x > e || lon_x < w) return 0; //-- outside! diff -Nru metview-5.17.4/metview/src/libMetview/MvGrid.h metview-5.19.2/metview/src/libMetview/MvGrid.h --- metview-5.17.4/metview/src/libMetview/MvGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -47,7 +47,7 @@ const std::string cSatelliteImage("space_view"); const double cGridScaling = 1000.0; -//const int cLevelNotGiven = -999; +// const int cLevelNotGiven = -999; //-- temporary functions: @@ -61,7 +61,7 @@ //! Function to create an instance of a suitable MvGrid object. MvGridBase* MvGridFactory(field* myfield, bool memoryToBeReleased = true, - bool expandGrid = true); + bool expandGrid = true); //=================================================================== @@ -96,8 +96,8 @@ long index_; }; -const double cMvGridMissingValue = DBL_MAX; // mars.grib_missing_value; -const double cMvlatLonMissingValue = -999.9; // mars.grib_missing_value; +const double cMvGridMissingValue = DBL_MAX; // mars.grib_missing_value; +const double cMvlatLonMissingValue = -999.9; // mars.grib_missing_value; const MvGridPoint cMissingPoint(cMvGridMissingValue, cMvlatLonMissingValue, cMvlatLonMissingValue); //! Class to handle rectangular areas @@ -149,8 +149,8 @@ //! Tests if the given point is inside the area /*! The longitude argument \c lon_x is normalised before testing, - * trying to fit it between the normalised East-West values. - */ + * trying to fit it between the normalised East-West values. + */ int isInside(double lat_y, double lon_x) const; private: @@ -196,7 +196,7 @@ //! Advances the iterator to the next grid point /*! Returns \c false if no more grid points left - */ + */ virtual bool advance() = 0; //! Returns the relative area weight of the grid point [iterator] @@ -217,12 +217,12 @@ //! Returns \c true if the underlying grid is geographical and implemented /*! Returns \c false for spectral data and for unimplemented grids - */ + */ virtual bool hasLocationInfo() const { return true; } //! Returns \c true if the underlying grid has at least the iterator methods implemented /*! Returns \c false for spectral data and for unimplemented grids - */ + */ virtual bool hasIterator() const { return true; } @@ -231,8 +231,8 @@ //! Returns \c true when the current grid is similar to \c otherGrib /*! Returns \c false if grids contain different number of points - * or grid scanning modes are different - */ + * or grid scanning modes are different + */ bool isEqual(const MvGridBase* otherGrib) const; //-- isSimilar() to be removed (011025/vk) --// // bool isSimilar( const MvGridBase* g ) const { return isEqual(g); } @@ -266,7 +266,7 @@ { if (field_) { field_->values[currentIndex_] = mars.grib_missing_value; - field_->bitmap = true; + field_->bitmap = true; } } @@ -275,12 +275,12 @@ { if (field_) { field_->values[index] = mars.grib_missing_value; - field_->bitmap = true; + field_->bitmap = true; } } - void setAllValuesToMissing(bool flagBitmap=true); - static void setAllValuesToMissing(field*,bool flagBitmap=true); + void setAllValuesToMissing(bool flagBitmap = true); + static void setAllValuesToMissing(field*, bool flagBitmap = true); //! Returns the value of the \c i:th grid point double valueAt(int i) const; @@ -296,7 +296,7 @@ //! Returns \c true when the grid point has a value /*! Returns \c false when the grid point is missing its value - */ + */ bool hasValue() const { return value() != mars.grib_missing_value; } //! Returns the code used for representing missing values @@ -310,8 +310,8 @@ //! Returns the number of data values in the GRIB message /*! This is either the number of grid points (for geographical - * grids) or the number spectral coefficient (spherical harmonics) - */ + * grids) or the number spectral coefficient (spherical harmonics) + */ long length() const { return field_ ? (long)(field_->value_count) : 0; } //! Returns the value and the location of the current grid point [iterator] @@ -336,7 +336,7 @@ long getLong(const char* name, bool throwOnError = false, bool quiet = false) const; static double getDouble(field* fld, const char* name, bool throwOnError = false, bool quiet = false); double getDouble(const char* name, bool throwOnError = false, bool quiet = false) const; - static std::string getString(field* fld,const char* name, bool throwOnError = false, bool quiet = false); + static std::string getString(field* fld, const char* name, bool throwOnError = false, bool quiet = false); std::string getString(const char* name, bool throwOnError = false, bool quiet = false) const; static long getLongArray(field* fld, const char* name, long** lvals, bool throwOnError = false, bool quiet = false); @@ -349,17 +349,26 @@ static bool setDouble(field* fld, const char* name, double val); bool setDouble(const char* name, double val); + static bool setLongArray(field* fld, const char* name, long* val, size_t len); + bool setLongArray(const char* name, long* va, size_t len); + static bool setString(field* fld, const char* name, std::string& val); bool setString(const char* name, std::string& val); static double validityDateTime(field* fld); double validityDateTime() const; + static double yyyymmddFoh(field* fld); + double yyyymmddFoh() const; + + static double stepFoh(field* fld); + double stepFoh() const; + long vertCoordCoefPairCount(); bool vertCoordCoefs(double& C1, double& C2, int level); field* fieldPtr() { return field_; } - void setForgetValuesOnDestroy(bool b) {forgetValuesOnDestroy_=b;} + void setForgetValuesOnDestroy(bool b) { forgetValuesOnDestroy_ = b; } protected: virtual bool ScanModeCheck(double first, double last, double step) const; @@ -379,6 +388,7 @@ bool memoryToBeReleased_; bool restoreShapeOnDestroy_; bool forgetValuesOnDestroy_{false}; + static constexpr double lonDeltaNearEastBorder_{1E-7}; }; //=================================================================== @@ -487,7 +497,7 @@ void boundingBox(std::vector&) override; protected: - //gribsec2_ll* sec2_; + // gribsec2_ll* sec2_; private: bool isGlobalInLon() const; @@ -580,7 +590,7 @@ // fortint* sec2_; private: - //double dy_; + // double dy_; double gridLat1_; double gridLon1_; double gridVertLon_; @@ -686,17 +696,16 @@ protected: void checkAreaLimits(); int findLatIndex(double latitude); + bool computeLonIndex(double lon_x, double firstLon, double dataLonWidth, double dx, int pointsInRow, int& idx1, int& idx2) const; -protected: - // gribsec2_gg* sec2_; - long numGlobalParallels_; - double* latitudes_; - int firstLatIndex_; - int lastLatIndex_; - int currentLatIndex_; - bool isSouthToNorthScanning_; - double firstLonX_; - double lastLonX_; + long numGlobalParallels_{0}; + double* latitudes_{nullptr}; + int firstLatIndex_{0}; + int lastLatIndex_{0}; + int currentLatIndex_{0}; + bool isSouthToNorthScanning_{false}; + double firstLonX_{0.}; + double lastLonX_{0.}; }; @@ -741,7 +750,7 @@ class GaussianLatitudes { public: - GaussianLatitudes() = default; + GaussianLatitudes() = default; ~GaussianLatitudes() = default; int latitudes(long trunc, double* v, unsigned int numLatitudes); diff -Nru metview-5.17.4/metview/src/libMetview/MvIconClassCore.cc metview-5.19.2/metview/src/libMetview/MvIconClassCore.cc --- metview-5.17.4/metview/src/libMetview/MvIconClassCore.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvIconClassCore.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,14 +16,14 @@ #include -//static std::map classes; +// static std::map classes; // All icon classed subclass from this one -//static MvIconClassCore super("*", nullptr); +// static MvIconClassCore super("*", nullptr); MvIconClassCore::MvIconClassCore(const std::string& name, request* r) : - //super_(sup), + // super_(sup), name_(name), request_(r) { @@ -274,4 +274,4 @@ return MvIconLanguage::find(this); } -//static SimpleLoader loadClasses("object", 0); +// static SimpleLoader loadClasses("object", 0); diff -Nru metview-5.17.4/metview/src/libMetview/MvIconClassCore.h metview-5.19.2/metview/src/libMetview/MvIconClassCore.h --- metview-5.17.4/metview/src/libMetview/MvIconClassCore.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvIconClassCore.h 2023-07-15 08:28:47.000000000 +0000 @@ -41,18 +41,18 @@ virtual bool isObsolete() const; virtual bool isFamilyMember() const; - //virtual bool isSubClassOf(const MvIconClass&) const; - //virtual bool canBecome(const MvIconClass&) const; + // virtual bool isSubClassOf(const MvIconClass&) const; + // virtual bool canBecome(const MvIconClass&) const; virtual MvIconLanguage& language() const; - //static bool isValid(const std::string& name); - //static const MvIconClass& find(const std::string&); - //static const MvIconClass& find(const std::string& name, const std::string& defaultType, bool); - //static void find(const std::string&, std::vector&, bool onlyCreatable = true); - //static void load(request*); + // static bool isValid(const std::string& name); + // static const MvIconClass& find(const std::string&); + // static const MvIconClass& find(const std::string& name, const std::string& defaultType, bool); + // static void find(const std::string&, std::vector&, bool onlyCreatable = true); + // static void load(request*); - //static void scan(ClassScanner&); + // static void scan(ClassScanner&); protected: std::string name_; request* request_; diff -Nru metview-5.17.4/metview/src/libMetview/MvIconLanguage.cc metview-5.19.2/metview/src/libMetview/MvIconLanguage.cc --- metview-5.17.4/metview/src/libMetview/MvIconLanguage.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvIconLanguage.cc 2023-07-15 08:28:47.000000000 +0000 @@ -63,22 +63,22 @@ inited_ = true; std::string langs = class_->definitionFile().str(); - auto j = lang_cache.find(langs); + auto j = lang_cache.find(langs); if (j != lang_cache.end()) lang_ = (*j).second; else { - //std::cout << "read " << langs << std::endl; - lang_ = read_language_file(langs.c_str()); + // std::cout << "read " << langs << std::endl; + lang_ = read_language_file(langs.c_str()); lang_cache[langs] = lang_; } std::string rules = class_->rulesFile().str(); - auto k = rule_cache.find(rules); + auto k = rule_cache.find(rules); if (k != rule_cache.end()) rule_ = (*k).second; else { - //std::cout << "read " << rules << std::endl; - rule_ = read_check_file(rules.c_str()); + // std::cout << "read " << rules << std::endl; + rule_ = read_check_file(rules.c_str()); rule_cache[rules] = rule_; } @@ -201,21 +201,21 @@ const request* r = def; - lang_ = empty_request(c->name().c_str()); + lang_ = empty_request(c->name().c_str()); languages[c->name()] = this; while (r) { name = get_value(r, "name", 0); if (!name) break; - param = new_parameter(strcache(name), nullptr); - ui = r->name; - val = find_values(r, "values"); - param->values = clone_all_values(val); - val = find_values(r, "default"); + param = new_parameter(strcache(name), nullptr); + ui = r->name; + val = find_values(r, "values"); + param->values = clone_all_values(val); + val = find_values(r, "default"); param->default_values = clone_all_values(val); param->current_values = clone_all_values(val); - param->interface = clone_one_request(r); + param->interface = clone_one_request(r); set_value(param->interface, "interface", ui); strfree(param->interface->name); diff -Nru metview-5.17.4/metview/src/libMetview/MvIconLanguage.h metview-5.19.2/metview/src/libMetview/MvIconLanguage.h --- metview-5.17.4/metview/src/libMetview/MvIconLanguage.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvIconLanguage.h 2023-07-15 08:28:47.000000000 +0000 @@ -60,5 +60,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(MvIconLanguage); +// OS_MARK_SCHEMA_TYPE(MvIconLanguage); //#endif diff -Nru metview-5.17.4/metview/src/libMetview/MvIconParameter.cc metview-5.19.2/metview/src/libMetview/MvIconParameter.cc --- metview-5.17.4/metview/src/libMetview/MvIconParameter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvIconParameter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,6 +10,7 @@ #include "MvIconParameter.h" #include +#include #include @@ -32,9 +33,9 @@ GuessInterface::GuessInterface(MvIconParameter& /*p*/) { choices_["on_off"] = 4; - choices_["menu"] = 3; //combobox - choices_["string"] = 2; //textedit line - choices_["text"] = 1; //textedit line with lists + choices_["menu"] = 3; // combobox + choices_["string"] = 2; // textedit line + choices_["text"] = 1; // textedit line with lists } void GuessInterface::next(const MvIconParameter&, const char* name, const char*) @@ -55,12 +56,12 @@ std::string GuessInterface::choice() { - int max = 0; + int max = 0; std::string result = "text"; for (auto& choice : choices_) { if (choice.second > max) { - max = choice.second; + max = choice.second; result = choice.first; } } @@ -75,7 +76,7 @@ param_(p), multiple_(false) { - // std::cout << "param:" << param_->name << std::endl; +// std::cout << "param:" << param_->name << std::endl; if (param_->interface == 0) param_->interface = empty_request(0); @@ -97,14 +98,14 @@ scan(guess); std::string choice = guess.choice(); - //If it can hold a list it is a colourlist + // If it can hold a list it is a colourlist if (choice == "text") { set_value(param_->interface, "interface", "colourlist"); if (get_value(param_->interface, "help", 0) == 0 || strcmp(get_value(param_->interface, "help", 0), "help_colour") == 0) set_value(param_->interface, "help", "help_colourlist"); } - //otherwise a single colour + // otherwise a single colour else { if (get_value(param_->interface, "help", 0) == 0) set_value(param_->interface, "help", "help_colour"); @@ -120,15 +121,15 @@ set_value(param_->interface, "interface", "none"); } - //if( ( h= get_value(param_->interface,"exclusive",0)) !=0 && (*h == 'T' || *h == 't')) + // if( ( h= get_value(param_->interface,"exclusive",0)) !=0 && (*h == 'T' || *h == 't')) //{ // multiple_=false; - //} + // } h = interface(); if (h != 0) { - //std::cout << " interface:" << h << std::endl; + // std::cout << " interface:" << h << std::endl; if (strcmp(h, "text") == 0) { multiple_ = true; @@ -153,7 +154,7 @@ } } - //No helper if the interface is "none" + // No helper if the interface is "none" if (h == 0 || strcmp(h, "none") == 0) { set_value(param_->interface, "help", "none"); } @@ -164,10 +165,12 @@ } const char* b = get_value(param_->interface, "beautify", 0); - beautify_ = (b == 0) || (*b != 'f'); + beautify_ = (b == 0) || (*b != 'f'); name_ = beautify(param_->name); +// std::cout << "name=" << param_->name << " interface" << param_->interface << std::endl; + value* v = param_->default_values; while (v) { defaults_.push_back(v->name); @@ -269,8 +272,8 @@ return (*j).second; std::string& result = const_cast(this)->beau_[name]; - bool up = true; - result = name; + bool up = true; + result = name; for (char& it : result) { char j = it; diff -Nru metview-5.17.4/metview/src/libMetview/MvIconParameter.h metview-5.19.2/metview/src/libMetview/MvIconParameter.h --- metview-5.17.4/metview/src/libMetview/MvIconParameter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvIconParameter.h 2023-07-15 08:28:47.000000000 +0000 @@ -78,5 +78,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(Parameter); +// OS_MARK_SCHEMA_TYPE(Parameter); //#endif diff -Nru metview-5.17.4/metview/src/libMetview/MvKeyCondition.cc metview-5.19.2/metview/src/libMetview/MvKeyCondition.cc --- metview-5.17.4/metview/src/libMetview/MvKeyCondition.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvKeyCondition.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,16 +25,16 @@ } else if (type == MvVariant::LongType) { std::vector vals; - for (size_t i = 0; i < condDef.values_.size(); i++) - vals.push_back(metview::fromString(condDef.values_[i])); + for (const auto& value : condDef.values_) + vals.push_back(metview::fromString(value)); std::vector vv = MvVariant::makeVector(vals); return MvKeyCondition::make(condDef.oper_, condDef.key_, vv); } else if (type == MvVariant::DoubleType) { std::vector vals; - for (size_t i = 0; i < condDef.values_.size(); i++) - vals.push_back(metview::fromString(condDef.values_[i])); + for (const auto& value : condDef.values_) + vals.push_back(metview::fromString(value)); std::vector vv = MvVariant::makeVector(vals); return MvKeyCondition::make(condDef.oper_, condDef.key_, vv); @@ -54,8 +54,6 @@ if (condOper == "RANK" || condOper == "VALUE") return new MvKeyValueCondition(key, v); - else if (condOper == "VALUE") - return new MvKeyValueCondition(key, v); else if (condOper == "NOT_VALUE") return new MvKeyNotValueCondition(key, v); else if (condOper == "RANGE") { diff -Nru metview-5.17.4/metview/src/libMetview/MvKeyCondition.h metview-5.19.2/metview/src/libMetview/MvKeyCondition.h --- metview-5.17.4/metview/src/libMetview/MvKeyCondition.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvKeyCondition.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ friend class MvKeyCondition; public: - MvKeyConditionDefinition() {} + MvKeyConditionDefinition() = default; MvKeyConditionDefinition(const std::string& key, const std::string& oper, const std::vector& values) : key_(key), @@ -43,7 +43,7 @@ MvKeyCondition(const std::string& key) : key_(key), match_(false) {} - virtual ~MvKeyCondition() {} + virtual ~MvKeyCondition() = default; const std::string& key() const { return key_; } virtual MvVariant::Type type() const = 0; @@ -76,10 +76,10 @@ MvKeyValueCondition(const std::string& key, const std::vector& v) : MvKeyCondition(key), values_(v) {} - MvVariant::Type type() const; + MvVariant::Type type() const override; protected: - void eval(const MvVariant& value); + void eval(const MvVariant& value) override; std::vector values_; }; @@ -90,7 +90,7 @@ MvKeyValueCondition(key, v) {} protected: - void eval(const MvVariant& value); + void eval(const MvVariant& value) override; }; class MvKeyRangeCondition : public MvKeyCondition @@ -100,10 +100,10 @@ MvKeyCondition(key), start_(start), end_(end) {} - MvVariant::Type type() const; + MvVariant::Type type() const override; protected: - void eval(const MvVariant& value); + void eval(const MvVariant& value) override; MvVariant start_; MvVariant end_; }; @@ -115,7 +115,7 @@ MvKeyRangeCondition(key, start, end) {} protected: - void eval(const MvVariant& value); + void eval(const MvVariant& value) override; }; class MvKeyLessThanCondition : public MvKeyCondition @@ -124,10 +124,10 @@ MvKeyLessThanCondition(const std::string& key, const MvVariant& v) : MvKeyCondition(key), value_(v) {} - MvVariant::Type type() const; + MvVariant::Type type() const override; protected: - void eval(const MvVariant& value); + void eval(const MvVariant& value) override; MvVariant value_; }; @@ -138,7 +138,7 @@ MvKeyLessThanCondition(key, v) {} protected: - void eval(const MvVariant& value); + void eval(const MvVariant& value) override; }; class MvKeyLessEqThanCondition : public MvKeyLessThanCondition @@ -148,7 +148,7 @@ MvKeyLessThanCondition(key, v) {} protected: - void eval(const MvVariant& value); + void eval(const MvVariant& value) override; }; class MvKeyGreaterEqThanCondition : public MvKeyLessThanCondition @@ -158,5 +158,5 @@ MvKeyLessThanCondition(key, v) {} protected: - void eval(const MvVariant& value); + void eval(const MvVariant& value) override; }; diff -Nru metview-5.17.4/metview/src/libMetview/MvKeyManager.cc metview-5.19.2/metview/src/libMetview/MvKeyManager.cc --- metview-5.17.4/metview/src/libMetview/MvKeyManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvKeyManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,17 +19,17 @@ #include "MvKeyProfile.h" /*key_.push_back(MvKey("count","Count",true)); - key_.push_back(MvKey("mars.date","Date",true)); - key_.push_back(MvKey("mars.time","Time",true)); - key_.push_back(MvKey("mars.step","Step",true)); - key_.push_back(MvKey("mars.param","Param",true)); - key_.push_back(MvKey("dataRepresentationType","Rep",true)); - key_.push_back(MvKey("mars.levelist","Level",true)); - key_.push_back(MvKey("mars.levtype","Levtype",true)); - key_.push_back(MvKey("mars.class","Class",false)); - key_.push_back(MvKey("mars.type","Type",false)); - key_.push_back(MvKey("mars.stream","Stream",false)); - key_.push_back(MvKey("editionNumber","Edition",false));*/ + key_.push_back(MvKey("mars.date","Date",true)); + key_.push_back(MvKey("mars.time","Time",true)); + key_.push_back(MvKey("mars.step","Step",true)); + key_.push_back(MvKey("mars.param","Param",true)); + key_.push_back(MvKey("dataRepresentationType","Rep",true)); + key_.push_back(MvKey("mars.levelist","Level",true)); + key_.push_back(MvKey("mars.levtype","Levtype",true)); + key_.push_back(MvKey("mars.class","Class",false)); + key_.push_back(MvKey("mars.type","Type",false)); + key_.push_back(MvKey("mars.stream","Stream",false)); + key_.push_back(MvKey("editionNumber","Edition",false));*/ MvKeyManager::~MvKeyManager() @@ -80,13 +80,13 @@ saveProfiles(); } else { - //Create a deafult profile + // Create a deafult profile char c[256]; std::string name, sname; MvKeyProfile* prof = nullptr; while (in.getline(c, 256)) { - //cout << c << std::endl; + // cout << c << std::endl; std::string s = c; @@ -121,7 +121,7 @@ for (auto prof : *this) { out << "#PROFILE" << std::endl; out << prof->name() << std::endl; - //out << prof->size() << std::endl; + // out << prof->size() << std::endl; for (auto key : *prof) { out << key->name() << std::endl; out << key->shortName() << std::endl; diff -Nru metview-5.17.4/metview/src/libMetview/MvKeyProfile.cc metview-5.19.2/metview/src/libMetview/MvKeyProfile.cc --- metview-5.17.4/metview/src/libMetview/MvKeyProfile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvKeyProfile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,62 +22,31 @@ // MvKey //----------------------------------- -MvKey::MvKey() : - name_(""), - shortName_(""), - description_(""), - role_(NoRole), - keyType_(NormalKey), - precision_(0), - valueType_(StringType), - constant_(false), - intMissingVal_(0), - longMissingVal_(0), - floatMissingVal_(0.), - doubleMissingVal_(0.), - missingValDefined_(false), - readIntAsString_(true), - editable_(true) -{ -} - MvKey::MvKey(const std::string& n, const std::string& sn, std::string d) : name_(n), shortName_(sn), - description_(d), - role_(NoRole), - keyType_(NormalKey), - precision_(0), - valueType_(StringType), - constant_(false), - intMissingVal_(0), - longMissingVal_(0), - floatMissingVal_(0.), - doubleMissingVal_(0.), - missingValDefined_(false), - readIntAsString_(true), - editable_(true) + description_(d) { } -MvKey::MvKey(const MvKey& o) -{ - name_ = o.name(); - shortName_ = o.shortName(); - description_ = o.description(); - role_ = o.role_; - keyType_ = o.keyType_, - precision_ = o.precision_; - valueType_ = o.valueType_; - constant_ = o.constant_; - metaData_ = o.metaData(); - intMissingVal_ = o.intMissingVal_; - longMissingVal_ = o.longMissingVal_; - floatMissingVal_ = o.floatMissingVal_; - doubleMissingVal_ = o.doubleMissingVal_; - missingValDefined_ = o.missingValDefined_; - readIntAsString_ = o.readIntAsString(); - editable_ = o.editable(); +MvKey::MvKey(const MvKey& o) : + name_(o.name()), + shortName_(o.shortName()), + description_(o.description()), + metaData_(o.metaData()), + role_(o.role_), + keyType_(o.keyType_), + precision_(o.precision_), + valueType_(o.valueType_), + constant_(o.constant_), + intMissingVal_(o.intMissingVal_), + longMissingVal_(o.longMissingVal_), + floatMissingVal_(o.floatMissingVal_), + doubleMissingVal_(o.doubleMissingVal_), + missingValDefined_(o.missingValDefined_), + readIntAsString_(o.readIntAsString()), + editable_(o.editable()) +{ } MvKey* MvKey::clone() @@ -397,15 +366,13 @@ // MvKeyProfile //----------------------------------- -MvKeyProfile::MvKeyProfile(const MvKeyProfile& copy) +MvKeyProfile::MvKeyProfile(const MvKeyProfile& copy) : + name_(copy.name_), systemProfile_(copy.systemProfile_), errorRows_(copy.errorRows_) { - name_ = copy.name_; - systemProfile_ = copy.systemProfile_; for (auto it : copy) { MvKey* key = it->clone(); push_back(key); } - errorRows_ = copy.errorRows_; } MvKeyProfile::~MvKeyProfile() @@ -486,7 +453,7 @@ if (size() != pos.size()) return; - //Create a copy + // Create a copy std::vector profCopy; for (size_t i = 0; i < size(); i++) profCopy.push_back(at(i)); @@ -550,7 +517,7 @@ if (size() == 0) return 0; - //everything is constant + // everything is constant return 1; } @@ -598,7 +565,7 @@ { assert(chunkProf); assert(chunkStart >= 0); - //assert(chunkStart+chunkSize < ) + // assert(chunkStart+chunkSize < ) assert(size() == chunkProf->size()); for (int& errorRow : chunkProf->errorRows_) { diff -Nru metview-5.17.4/metview/src/libMetview/MvKeyProfile.h metview-5.19.2/metview/src/libMetview/MvKeyProfile.h --- metview-5.17.4/metview/src/libMetview/MvKeyProfile.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvKeyProfile.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ class MvKey { public: - MvKey(); + MvKey() = default; MvKey(const std::string& name, const std::string& shortName, std::string description = std::string("")); MvKey(const MvKey&); @@ -77,7 +77,7 @@ int valuePrecision() const { return precision_; } void setValuePrecision(int p) { precision_ = p; } - //TODO: refactor the usage of the "value" functions + // TODO: refactor the usage of the "value" functions void addValue(const std::string& v) { addStringValue(v); } const std::vector& value() const { return stringVal_; } void setValue(int idx, const std::string& v) { setStringValue(idx, v); } @@ -95,7 +95,7 @@ void setIntRange(int, int); void setIntMissingValue(int v) { - intMissingVal_ = v; + intMissingVal_ = v; missingValDefined_ = true; } int intMissingValue() const { return intMissingVal_; } @@ -107,7 +107,7 @@ void setLongRange(long, long); void setLongMissingValue(long v) { - longMissingVal_ = v; + longMissingVal_ = v; missingValDefined_ = true; } long longMissingValue() const { return longMissingVal_; } @@ -118,7 +118,7 @@ void setDoubleValue(int, double); void setDoubleMissingValue(double v) { - doubleMissingVal_ = v; + doubleMissingVal_ = v; missingValDefined_ = true; } double doubleMissingValue() const { return doubleMissingVal_; } @@ -130,7 +130,7 @@ void clearMetaData(); void clearData(); - //const std::map& counter() const {return counter_;} + // const std::map& counter() const {return counter_;} bool readIntAsString() const { return readIntAsString_; } void setReadIntAsString(bool b) { readIntAsString_ = b; } @@ -144,7 +144,7 @@ bool operator==(const MvKey&) const; bool operator!=(const MvKey&) const; -protected: +private: void addToCounter(const std::string&); std::string name_; @@ -152,33 +152,33 @@ std::string description_; std::map metaData_; - Role role_; - KeyType keyType_; - int precision_; - ValueType valueType_; - bool constant_; + Role role_{NoRole}; + KeyType keyType_{NormalKey}; + int precision_{0}; + ValueType valueType_{StringType}; + bool constant_{false}; std::vector stringVal_; std::vector intVal_; std::vector longVal_; std::vector floatVal_; std::vector doubleVal_; - int intMissingVal_; - long longMissingVal_; - float floatMissingVal_; - double doubleMissingVal_; - bool missingValDefined_; - - //std::map counter_; - bool readIntAsString_; - bool editable_; //if false only shortname is editable + int intMissingVal_{0}; + long longMissingVal_{0}; + float floatMissingVal_{0.}; + double doubleMissingVal_{0.}; + bool missingValDefined_{false}; + + // std::map counter_; + bool readIntAsString_{true}; + bool editable_{true}; // if false only shortname is editable }; + class MvKeyProfile : public std::vector { public: MvKeyProfile(std::string n) : - name_(n), - systemProfile_(false) {} + name_(n) {} MvKeyProfile(const MvKeyProfile&); ~MvKeyProfile(); @@ -216,7 +216,7 @@ private: std::string name_; - bool systemProfile_; + bool systemProfile_{false}; std::vector errorRows_; std::map metaData_; }; diff -Nru metview-5.17.4/metview/src/libMetview/MvLanguage.cc metview-5.19.2/metview/src/libMetview/MvLanguage.cc --- metview-5.17.4/metview/src/libMetview/MvLanguage.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvLanguage.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,8 @@ MvLanguage::MvLanguage(const char* lang, const char* rule, long flags) { - Lang = lang ? read_language_file(lang) : nullptr; - Rule = rule ? read_check_file(rule) : nullptr; + Lang = lang ? read_language_file(lang) : nullptr; + Rule = rule ? read_check_file(rule) : nullptr; Flags = flags; } @@ -49,7 +49,7 @@ reset(); long oldFlags = expand_flags(Flags); MvRequest one = r.justOneRequest(); - request* req = expand_all_requests(Lang, Rule, one); + request* req = expand_all_requests(Lang, Rule, one); expand_flags(oldFlags); // restore the expand flags to their previous value return MvRequest(req, false); } diff -Nru metview-5.17.4/metview/src/libMetview/MvLanguage.h metview-5.19.2/metview/src/libMetview/MvLanguage.h --- metview-5.17.4/metview/src/libMetview/MvLanguage.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvLanguage.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,11 +26,11 @@ public: //! Constructor /*! Argument \c langFile is the file name of the language syntax file, - * \c rulesFile is the name of the rules file (use \c 0 if no rules file) - * and \c expandFlags is a combination of bits defining how requests - * should be expanded (see file \c src/libMars/mars.h for - * defined mnemonics and their values). - */ + * \c rulesFile is the name of the rules file (use \c 0 if no rules file) + * and \c expandFlags is a combination of bits defining how requests + * should be expanded (see file \c src/libMars/mars.h for + * defined mnemonics and their values). + */ MvLanguage(const char* langFile, const char* rulesFile, long expandFlags = EXPAND_2ND_NAME); //! Destructor @@ -40,8 +40,8 @@ //! Removes non-matching parameters /*! Removes parameters that are not defined in the language file - * from all requests in \c req - */ + * from all requests in \c req + */ MvRequest trimAll(const MvRequest& req); //! Expands all parameters in all requests in \c req @@ -49,8 +49,8 @@ //! Removes non-matching parameters /*! Removes parameters that are not defined in the language file - * from the current request in \c req - */ + * from the current request in \c req + */ MvRequest trimOne(const MvRequest& req); //! Expands all parameters in the current request in \c req @@ -59,7 +59,7 @@ // //! Set request expansion flags /*! For values and mnemonics, see \c EXPAND_* defines in file \c src/libMars/mars.h - */ + */ void setFlags(long f) { Flags = f; } //! Resets the language file diff -Nru metview-5.17.4/metview/src/libMetview/MvList.cc metview-5.19.2/metview/src/libMetview/MvList.cc --- metview-5.17.4/metview/src/libMetview/MvList.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvList.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,9 @@ { setListTypes(SequentialList, NoSortBy, NoSortType, NoCase); _first = _last = nullptr; - _n = 0; - _protect = protect; - _curpos = -1; + _n = 0; + _protect = protect; + _curpos = -1; } MvList ::MvList(ListType lst, ListSortBy sb, ListSortType st, ListCase lc, int protect, MvElement* delem) @@ -33,7 +33,7 @@ insertLastPrivate(delem); else { _first = _last = nullptr; - _n = 0; + _n = 0; } first(); _protect = protect; @@ -47,7 +47,7 @@ { _list_type = lst; _list_case = c; - _current = nullptr; + _current = nullptr; if (_list_type == SortedList) { switch (sb) { @@ -65,7 +65,7 @@ _sort_type = st; } else { - _sort_by = NoSortBy; + _sort_by = NoSortBy; _sort_type = NoSortType; } } @@ -77,7 +77,7 @@ curr = _first; for (int i = 0; i < _n; i++) { - outro = curr->_next; + outro = curr->_next; MvElement* elem = curr->_self; delete curr; @@ -87,7 +87,7 @@ delete elem; } - _n = 0; + _n = 0; _first = _last = nullptr; } @@ -286,7 +286,7 @@ if (_n == 1) _first = _last = nullptr; // Last element deleted else { - _first = _first->_next; + _first = _first->_next; _first->_previous = nullptr; } @@ -295,17 +295,17 @@ } else if (posit == _n - 1) { - tokill = _last; - _last = _last->_previous; + tokill = _last; + _last = _last->_previous; _last->_next = nullptr; } else { tokill = _first; for (i = 0; i < posit; i++) tokill = tokill->_next; - tmp = tokill->_previous; - tmp->_next = tokill->_next; - tmp = tokill->_next; + tmp = tokill->_previous; + tmp->_next = tokill->_next; + tmp = tokill->_next; tmp->_previous = tokill->_previous; } @@ -343,8 +343,8 @@ return; for (i = 1; i < _n; i++) current = current->_next; - current->_next = nullptr; - _last = current; + current->_next = nullptr; + _last = current; _first->_previous = nullptr; } @@ -353,31 +353,31 @@ /* void MvList :: sort(int pos, MvLink* toinsert) { - if (pos <= 1) return; + if (pos <= 1) return; + + MvLink *current = _first, *previous = nullptr; + for (int i = 1; i < pos; i++) + { + if (compare(toinsert, current) < 0) + { + if (current == _first) + { + _first = toinsert; + toinsert->_next = current; + } + else + { + previous->_next = toinsert; + toinsert->_next = current; + } + break; - MvLink *current = _first, *previous = nullptr; - for (int i = 1; i < pos; i++) - { - if (compare(toinsert, current) < 0) - { - if (current == _first) - { - _first = toinsert; - toinsert->_next = current; - } - else - { - previous->_next = toinsert; - toinsert->_next = current; - } - break; - - } - toinsert->_previous = previous; - current->_previous = toinsert; - previous = current; - current = current->_next; - } + } + toinsert->_previous = previous; + current->_previous = toinsert; + previous = current; + current = current->_next; + } } */ @@ -388,8 +388,8 @@ return; MvLink* current = _first; - MvLink *cnext = nullptr, - *tprev = nullptr; + MvLink *cnext = nullptr, + *tprev = nullptr; if (toinsert == nullptr) return; @@ -403,9 +403,9 @@ tprev = toinsert->_previous; toinsert->_previous = current->_previous; - current->_next = toinsert->_next; - toinsert->_next = (cnext == toinsert) ? (current) : (cnext); - current->_previous = (tprev == current) ? (toinsert) : (tprev); + current->_next = toinsert->_next; + toinsert->_next = (cnext == toinsert) ? (current) : (cnext); + current->_previous = (tprev == current) ? (toinsert) : (tprev); if (cnext != nullptr && cnext != toinsert) cnext->_previous = toinsert; @@ -444,7 +444,7 @@ MvElement* MvList::first() { _current = _first; - _curpos = 0; + _curpos = 0; return (_current ? _current->_self : nullptr); } @@ -504,7 +504,7 @@ return nullptr; MvElement* elem = nullptr; - char* n = new char[strlen(name) + 1]; + char* n = new char[strlen(name) + 1]; strcpy(n, name); convertCase(n); for (elem = first(); elem; elem = next()) { @@ -549,7 +549,7 @@ return nullptr; MvElement* elem = nullptr; - char* n = new char[strlen(name) + 1]; + char* n = new char[strlen(name) + 1]; strcpy(n, name); convertCase(n); diff -Nru metview-5.17.4/metview/src/libMetview/MvList.hpp metview-5.19.2/metview/src/libMetview/MvList.hpp --- metview-5.17.4/metview/src/libMetview/MvList.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvList.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -1,10 +1,10 @@ #pragma once /**************************************************************************** -* -* Classes MvLink and MvList - sorted double linked list -* -****************************************************************************/ + * + * Classes MvLink and MvList - sorted double linked list + * + ****************************************************************************/ typedef enum { @@ -52,8 +52,8 @@ public: MvLink(MvElement* itself, MvLink* previous = nullptr, MvLink* next = nullptr) { - _self = itself; - _next = next; + _self = itself; + _next = next; _previous = previous; _self->increment(); } diff -Nru metview-5.17.4/metview/src/libMetview/MvLocation.cc metview-5.19.2/metview/src/libMetview/MvLocation.cc --- metview-5.17.4/metview/src/libMetview/MvLocation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvLocation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,11 @@ #endif #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif //=================================================== @@ -26,30 +28,79 @@ // //=================================================== -const double MvLocation::cRadian = 180. / M_PI; -const double MvLocation::cDegree = 1 / MvLocation::cRadian; +const double MvLocation::cRadian = 180. / M_PI; +const double MvLocation::cDegree = 1 / MvLocation::cRadian; const double MvLocation::cRadianToMetre = 1852 * 180.0 * 60.0 / M_PI; const double MvLocation::cMetreToRadian = 1. / MvLocation::cRadianToMetre; -MvLocation& MvLocation::operator=(const MvLocation& aLoc) { +MvLocation& MvLocation::operator=(const MvLocation& aLoc) +{ set(aLoc.latitude(), aLoc.longitude()); return *this; } -void MvLocation::set(double aLat, double aLong) { +void MvLocation::set(double aLat, double aLong) +{ lat_ = aLat; lon_ = aLong; } -void MvLocation::ensureLongitudeBelow360() { +void MvLocation::ensureLongitudeBelow360() +{ while (lon_ >= 360) { lon_ -= 360; } } +void MvLocation::normaliseLongitude(double minimum) +{ + lon_ = normaliseLongitude(lon_, minimum); +} + +double MvLocation::normaliseLongitude(double lon, double minimum) +{ + while (lon < minimum) { + lon += 360.; + } + while (lon >= minimum + 360.) { + lon -= 360.; + } + return lon; +} + +double MvLocation::normaliseLongitudeToOther(double lon, double lonOther) +{ + double minimum = 0.; + while (lonOther < minimum) { + minimum -= 360.; + } + while (lonOther > minimum + 360.) { + minimum += 360.; + } + return normaliseLongitude(lon, minimum); +} + + +void MvLocation::normaliseRangeToLongitude(double& lon1, double& lon2, double lon) +{ + if (lon < lon1 || lon > lon2) { + auto dLon = lon2 - lon1; + // TODO: make it work when lon is outsise [-360, 360] + double minLon = (lon >= 0.)?0.:-360.; + double maxLon = minLon + 360.; + lon1 = normaliseLongitudeToOther(lon1, minLon); + lon2 = lon1 + dLon; + if (lon2 > maxLon && lon < minLon + 180.) { + lon1 -= 360.; + lon2 -= 360.; + } + } +} + // compute the cosine of the angular distance between the current and the other location -double MvLocation::cosOfDistance(double aLat, double aLon) const { +double MvLocation::cosOfDistance(double aLat, double aLon) const +{ // short-circuit if the two points are the same, because floating-point // imprecisions can cause a 'nan' on the next calculation if ((lat_ == aLat) && (lon_ == aLon)) { @@ -65,27 +116,32 @@ } // compute the cosine of the angular distance between the current and the other location -double MvLocation::cosOfDistance(const MvLocation& other) const { +double MvLocation::cosOfDistance(const MvLocation& other) const +{ return cosOfDistance(other.latitude(), other.longitude()); } // compute the angular distance in radians between the current and the other location -double MvLocation::distanceInRadians(const MvLocation& other) const { +double MvLocation::distanceInRadians(const MvLocation& other) const +{ return std::acos(cosOfDistance(other)); } // compute the angular distance in degrees between the current and the other location -double MvLocation::distanceInDegrees(const MvLocation& other) const { +double MvLocation::distanceInDegrees(const MvLocation& other) const +{ return radToDeg(distanceInRadians(other)); } // compute the distance in metres on the surface of Earth // between the current and the other location -double MvLocation::distanceInMeters(const MvLocation& other) const { +double MvLocation::distanceInMeters(const MvLocation& other) const +{ return radiansToMetres(distanceInRadians(other)); } -std::ostream& operator<<(std::ostream& aStream, const MvLocation& aLocation) { +std::ostream& operator<<(std::ostream& aStream, const MvLocation& aLocation) +{ aStream << "(" << aLocation.latitude() << "," << aLocation.longitude() << ")"; /*--- How to get a constant field width + constant nr of decimal digits!? aStream << "("; @@ -103,14 +159,16 @@ // //=================================================== -MvLocationHub& MvLocationHub::operator=(const MvLocationHub& aLoc) { +MvLocationHub& MvLocationHub::operator=(const MvLocationHub& aLoc) +{ set(aLoc.latitude(), aLoc.longitude()); cosLat_ = aLoc.cosLat_; sinLat_ = aLoc.sinLat_; return *this; } -double MvLocationHub::cosOfDistance(double aLat, double aLon) const { +double MvLocationHub::cosOfDistance(double aLat, double aLon) const +{ if (sinLat_ < -100) { sinLat_ = std::sin(degToRad(lat_)); cosLat_ = std::cos(degToRad(lat_)); @@ -133,33 +191,36 @@ //============================================================================ MvArea //____________________________________________________________________________ -MvArea ::MvArea() { +MvArea ::MvArea() +{ MvLocation myLocation; set(myLocation, myLocation); } //____________________________________________________________________ -void MvArea ::set(const MvLocation& aLocation1, const MvLocation& aLocation2) { +void MvArea ::set(const MvLocation& aLocation1, const MvLocation& aLocation2) +{ double y1 = aLocation1.latitude(); double x1 = aLocation1.longitude(); double y2 = aLocation2.latitude(); double x2 = aLocation2.longitude(); if (y1 > y2) { double yy = y1; - y1 = y2; - y2 = yy; + y1 = y2; + y2 = yy; } if (x1 > x2) { double xx = x1; - x1 = x2; - x2 = xx; + x1 = x2; + x2 = xx; } fLowerLeft.set(y1, x1); fUpperRight.set(y2, x2); } //____________________________________________________________________ -bool MvArea ::inside(const MvLocation& aPoint) const { +bool MvArea ::inside(const MvLocation& aPoint) const +{ if (aPoint.latitude() >= fLowerLeft.latitude() && aPoint.latitude() <= fUpperRight.latitude() && aPoint.longitude() >= fLowerLeft.longitude() && aPoint.longitude() <= fUpperRight.longitude()) return true; @@ -168,13 +229,15 @@ } //____________________________________________________________________ -MvArea& MvArea ::operator=(const MvArea& anArea) { +MvArea& MvArea ::operator=(const MvArea& anArea) +{ set(anArea.lowerLeft(), anArea.upperRight()); return *this; } //____________________________________________________________________ -std::ostream& operator<<(std::ostream& aStream, const MvArea& anArea) { +std::ostream& operator<<(std::ostream& aStream, const MvArea& anArea) +{ aStream << anArea.lowerLeft() << "-" << anArea.upperRight(); return aStream; } @@ -184,7 +247,8 @@ //______________________________________________________________________ //_____________________________________________________________ WithinDelta -bool MvXSectionLine ::withinDelta(const MvLocation& aLocation) const { +bool MvXSectionLine ::withinDelta(const MvLocation& aLocation) const +{ //-- check that max delta has been set if (fMaxDeltaInMeters < 0) return false; @@ -197,7 +261,8 @@ return insideXLine(aLocation); } //_____________________________________________________________ InsideXLine -bool MvXSectionLine ::insideXLine(const MvLocation& aLocation) const { +bool MvXSectionLine ::insideXLine(const MvLocation& aLocation) const +{ MvLocation myLocation = nearestPointOnXLine(aLocation); MvArea myArea(fLocation1, fLocation2); return myArea.inside(myLocation); @@ -209,7 +274,8 @@ // WARNING: calculates distance from a line going through end // points of XSectionLine, NOT ONLY between points! //------------------------------------------------------------- -MvLocation MvXSectionLine ::nearestPointOnXLine(const MvLocation& aLocation) const { +MvLocation MvXSectionLine ::nearestPointOnXLine(const MvLocation& aLocation) const +{ MvLocation myNearestPointOnXLine; double dy = fLocation1.latitude() - fLocation2.latitude(); @@ -242,19 +308,22 @@ return myNearestPointOnXLine; } //_____________________________________________________________ DeltaInDegrees -double MvXSectionLine ::deltaInDegrees(const MvLocation& aLocation) const { +double MvXSectionLine ::deltaInDegrees(const MvLocation& aLocation) const +{ return aLocation.distanceInDegrees(nearestPointOnXLine(aLocation)); } //_____________________________________________________________ DeltaInMeters // Q&D approximation for delta, uses DeltaInDegrees //------------------------------------------------------------- -double MvXSectionLine ::deltaInMeters(const MvLocation& aLocation) const { +double MvXSectionLine ::deltaInMeters(const MvLocation& aLocation) const +{ //-- Q&D formula, out of my old used brains, unchecked!!!! (vk 940901) -- double degreeIntoMeters = 6370. * 1000. * 2. * M_PI / 360.; return deltaInDegrees(aLocation) * degreeIntoMeters; } //_____________________________________________________________ operator= -MvXSectionLine& MvXSectionLine ::operator=(const MvXSectionLine& anXLine) { +MvXSectionLine& MvXSectionLine ::operator=(const MvXSectionLine& anXLine) +{ setLine(anXLine.startPoint(), anXLine.endPoint()); setMaxDelta(anXLine.maxDelta()); return *this; @@ -263,9 +332,10 @@ // output format: "(lat1,long1)-(lat2,long2)/delta" //------------------------------------------------- -std::ostream& operator<<(std::ostream& aStream, const MvXSectionLine& anXLine) { +std::ostream& operator<<(std::ostream& aStream, const MvXSectionLine& anXLine) +{ aStream << anXLine.startPoint() << "-" << anXLine.endPoint() << "/" << anXLine.fMaxDeltaInMeters; // << std::endl; return aStream; } -} // namespace \ No newline at end of file +} // namespace diff -Nru metview-5.17.4/metview/src/libMetview/MvLocation.h metview-5.19.2/metview/src/libMetview/MvLocation.h --- metview-5.17.4/metview/src/libMetview/MvLocation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvLocation.h 2023-07-15 08:28:47.000000000 +0000 @@ -12,9 +12,11 @@ #include #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif const double MISSING_LOC_VALUE = -99999.; @@ -29,7 +31,8 @@ * Class also provides methods to calculate the distance to another * geographical location */ -class MvLocation { +class MvLocation +{ //! Output operator for MvLocation object /*! The output is enclosed in parenthesis and latitude and longitude values * are separated by a comma, for instance: @@ -46,7 +49,7 @@ friend std::ostream& operator<<(std::ostream& aStream, const MvLocation& aLocation); public: - MvLocation() {} + MvLocation() = default; MvLocation(double aLat, double aLong) { set(aLat, aLong); } MvLocation& operator=(const MvLocation& aLoc); @@ -59,6 +62,11 @@ // Subtracts 360 until the longitude is below 360 (e.g. 360 becomes 0, 370 becomes 10) void ensureLongitudeBelow360(); + void normaliseLongitude(double minimum); + + static double normaliseLongitude(double lon, double minimum); + static double normaliseLongitudeToOther(double lon, double lonOther); + static void normaliseRangeToLongitude(double& lon1, double& lon2, double lon); double latitude() const { return lat_; } double y() const { return lat_; } @@ -95,7 +103,8 @@ // A location from that the distance to other locations are computed. It // caches some trigonometric values to make the computations faster. -class MvLocationHub : public MvLocation { +class MvLocationHub : public MvLocation +{ public: using MvLocation::MvLocation; MvLocationHub& operator=(const MvLocationHub& aLoc); @@ -111,7 +120,8 @@ /*! This is another incarnation of MvGeoBox class, used mainly by * MvObsSetIterator. For other usage MvGeoBox is recommended over MvArea. */ -class MvArea { +class MvArea +{ friend std::ostream& operator<<(std::ostream& aStream, const MvArea& aArea); public: @@ -120,8 +130,8 @@ void set(const MvLocation& aLoc1, const MvLocation& aLoc2); bool inside(const MvLocation& aPoint) const; - MvLocation lowerLeft(void) const { return fLowerLeft; } - MvLocation upperRight(void) const { return fUpperRight; } + MvLocation lowerLeft() const { return fLowerLeft; } + MvLocation upperRight() const { return fUpperRight; } MvArea& operator=(const MvArea& aLoc); @@ -136,12 +146,14 @@ * distance (max delta) from the given line, i.e. close enough to be * considered to be within the line. */ -class MvXSectionLine { +class MvXSectionLine +{ friend std::ostream& operator<<(std::ostream& aStream, const MvXSectionLine& aXSectionLine); public: //! Empty constructor creates a missing line - MvXSectionLine(void) { + MvXSectionLine() + { fLocation1.set(MISSING_LOC_VALUE, MISSING_LOC_VALUE); fLocation2.set(MISSING_LOC_VALUE, MISSING_LOC_VALUE); fMaxDeltaInMeters = -1; @@ -150,36 +162,37 @@ //! Constructor, only points defined, no max delta given /*! Use method setMaxDelta() to set the maximum allowed distance from the line */ - MvXSectionLine(const MvLocation& aLoc1, const MvLocation& aLoc2) { - fLocation1 = aLoc1; - fLocation2 = aLoc2; - fMaxDeltaInMeters = -1; + MvXSectionLine(const MvLocation& aLoc1, const MvLocation& aLoc2) : + fLocation1(aLoc1), fLocation2(aLoc2), fMaxDeltaInMeters(-1) + { } //! Constructor, two points and max distance from the line - MvXSectionLine(const MvLocation& aLoc1, const MvLocation& aLoc2, double aDelta) { - fLocation1 = aLoc1; - fLocation2 = aLoc2; + MvXSectionLine(const MvLocation& aLoc1, const MvLocation& aLoc2, double aDelta) + { + fLocation1 = aLoc1; + fLocation2 = aLoc2; fMaxDeltaInMeters = aDelta; } //! Set a new line between points aLoc1 and aLoc2 - void setLine(const MvLocation& aLoc1, const MvLocation& aLoc2) { + void setLine(const MvLocation& aLoc1, const MvLocation& aLoc2) + { fLocation1 = aLoc1; fLocation2 = aLoc2; } //! Return the current start point of the line - MvLocation startPoint(void) const { return fLocation1; } + MvLocation startPoint() const { return fLocation1; } //! Return the current end point of the line - MvLocation endPoint(void) const { return fLocation2; } + MvLocation endPoint() const { return fLocation2; } //! Set the maximum allowed distance from the line void setMaxDelta(double aDelta) { fMaxDeltaInMeters = aDelta; } //! Return the current maximum allowed distance from the line - double maxDelta(void) const { return fMaxDeltaInMeters; } + double maxDelta() const { return fMaxDeltaInMeters; } //! Returns true if the given point is within the given proximity of the line bool withinDelta(const MvLocation& aLocation) const; diff -Nru metview-5.17.4/metview/src/libMetview/MvLog.cc metview-5.19.2/metview/src/libMetview/MvLog.cc --- metview-5.17.4/metview/src/libMetview/MvLog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvLog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -54,7 +54,7 @@ std::ostringstream& MvLog::errNoExit() { - level_ = MvLogLevel::ERROR; + level_ = MvLogLevel::ERROR; exitOnError_ = false; return os_; } @@ -111,15 +111,15 @@ // Overload ostringstream for various objects //-------------------------------------------- -//std::ostream& operator <<(std::ostream &stream,const std::vector& vec) +// std::ostream& operator <<(std::ostream &stream,const std::vector& vec) //{ -// stream << "["; -// for(size_t i=0; i < vec.size(); i++) -// { -// if(i > 0) stream << ","; -// stream << vec[i]; -// } -// stream << "]"; +// stream << "["; +// for(size_t i=0; i < vec.size(); i++) +// { +// if(i > 0) stream << ","; +// stream << vec[i]; +// } +// stream << "]"; // return stream; //} diff -Nru metview-5.17.4/metview/src/libMetview/MvLog.h metview-5.19.2/metview/src/libMetview/MvLog.h --- metview-5.17.4/metview/src/libMetview/MvLog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvLog.h 2023-07-15 08:28:47.000000000 +0000 @@ -45,7 +45,7 @@ static MvAbstractApplication* app_; }; -//Overload ostringstream for various objects +// Overload ostringstream for various objects template std::ostream& operator<<(std::ostream& stream, const std::vector& vec) { diff -Nru metview-5.17.4/metview/src/libMetview/MvMatrix.cc metview-5.19.2/metview/src/libMetview/MvMatrix.cc --- metview-5.17.4/metview/src/libMetview/MvMatrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvMatrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ nlin_(nlin), ncol_(ncol) // vec_ (nlin*ncol) //Unfortunately, SGI compiler gives an error. -//Solution: the use of the resize command. +// Solution: the use of the resize command. { vec_.resize(nlin * ncol); } @@ -28,7 +28,7 @@ nlin_ = m.nlin_; ncol_ = m.ncol_; - vec_ = m.vec_; + vec_ = m.vec_; } bool MvMatrix::Mput(int lin, int col, double val) diff -Nru metview-5.17.4/metview/src/libMetview/MvMatrix.h metview-5.19.2/metview/src/libMetview/MvMatrix.h --- metview-5.17.4/metview/src/libMetview/MvMatrix.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvMatrix.h 2023-07-15 08:28:47.000000000 +0000 @@ -7,11 +7,11 @@ ***************************** LICENSE END *************************************/ -//MvMatrix class provides tools to manipulate a matrix of elements. -//The type of the elements are double. -//The template facility could be used to define a general type for -//the elements. However, compilation problems was found in SGI -// platforms (probably in Alpha too). IBM and Linux work fine. +// MvMatrix class provides tools to manipulate a matrix of elements. +// The type of the elements are double. +// The template facility could be used to define a general type for +// the elements. However, compilation problems was found in SGI +// platforms (probably in Alpha too). IBM and Linux work fine. #pragma once @@ -30,7 +30,7 @@ int ncol_; // number of columns std::vector vec_; // matrix - MvMatrix() {} + MvMatrix() = default; public: //! Constructor for \c nlin times \c ncol matrix @@ -53,11 +53,11 @@ //! Assign value \c val into matrix element [ \c lin , \c col ] /*! Returns \c false if [ \c lin , \c col ] is outside the matrix - */ + */ bool Mput(int lin, int col, double val); //! Get the value from matrix cell [ \c lin , \c col ] /*! Returns \c DBL_MAX if [ \c lin , \c col ] is outside the matrix - */ + */ double Mget(int lin, int col); }; diff -Nru metview-5.17.4/metview/src/libMetview/MvMessageMetaData.h metview-5.19.2/metview/src/libMetview/MvMessageMetaData.h --- metview-5.17.4/metview/src/libMetview/MvMessageMetaData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvMessageMetaData.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,7 +13,7 @@ #include #ifdef METVIEW -//For off_t +// For off_t #include "mars.h" #else #include @@ -38,7 +38,7 @@ totalMessageNum_(0), firstScan_(true), filterEnabled_(false) {} - virtual ~MvMessageMetaData() {} + virtual ~MvMessageMetaData() = default; Type type() const { return type_; } const std::string& fileName() const { return fileName_; } @@ -66,28 +66,29 @@ virtual void clearData() { - messageNum_ = 0; + messageNum_ = 0; totalMessageNum_ = 0; - firstScan_ = true, - filterEnabled_ = false, + firstScan_ = true, + filterEnabled_ = false, filterOffset_.clear(); filterLen_.clear(); filterCnt_.clear(); } protected: - typedef void (MvMessageMetaDataObserver::*IntMethod)(int); - typedef void (MvMessageMetaDataObserver::*VoidMethod)(); + using IntMethod = void (MvMessageMetaDataObserver::*)(int); + + using VoidMethod = void (MvMessageMetaDataObserver::*)(); void broadcast(IntMethod, int); void broadcast(VoidMethod); virtual void clear() { fileName_.clear(); - messageNum_ = 0; + messageNum_ = 0; totalMessageNum_ = 0; - firstScan_ = true, - filterEnabled_ = false, + firstScan_ = true, + filterEnabled_ = false, filterOffset_.clear(); filterLen_.clear(); filterCnt_.clear(); @@ -110,8 +111,8 @@ class MvMessageMetaDataObserver { public: - MvMessageMetaDataObserver() {} - virtual ~MvMessageMetaDataObserver() {} + MvMessageMetaDataObserver() = default; + virtual ~MvMessageMetaDataObserver() = default; virtual void messageScanStepChanged(int) {} virtual void locationScanStepChanged(int) {} diff -Nru metview-5.17.4/metview/src/libMetview/MvMiscellaneous.cc metview-5.19.2/metview/src/libMetview/MvMiscellaneous.cc --- metview-5.17.4/metview/src/libMetview/MvMiscellaneous.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvMiscellaneous.cc 2023-07-15 08:28:47.000000000 +0000 @@ -46,8 +46,8 @@ { static std::string rDir; if (rDir.empty()) { - auto ch = getenv("METVIEW_USER_DIRECTORY"); - rDir = (ch)?std::string(ch):""; + auto ch = getenv("METVIEW_USER_DIRECTORY"); + rDir = (ch) ? std::string(ch) : ""; } return rDir; } @@ -57,7 +57,7 @@ static std::string shDir; if (shDir.empty()) { auto ch = getenv("METVIEW_DIR_SHARE"); - shDir = (ch)?std::string(ch):""; + shDir = (ch) ? std::string(ch) : ""; } return shDir; } @@ -67,7 +67,7 @@ static std::string uDir; if (uDir.empty()) { auto ch = getenv("METVIEW_USER_DIRECTORY"); - uDir = (ch)?std::string(ch):""; + uDir = (ch) ? std::string(ch) : ""; } return uDir; } @@ -77,7 +77,7 @@ static std::string mpDir; if (mpDir.empty()) { auto ch = getenv("MAGPLUS_HOME"); - mpDir = (ch)?std::string(ch):""; + mpDir = (ch) ? std::string(ch) : ""; } return mpDir; } @@ -124,7 +124,7 @@ static std::string linkDir; if (linkDir.empty()) { auto ch = getenv("METVIEW_LINK_DIR"); - linkDir = (ch)?std::string(ch):""; + linkDir = (ch) ? std::string(ch) : ""; } return linkDir + "/" + fName; #endif @@ -149,7 +149,7 @@ { static std::string resPath; if (resPath.empty()) { - if (auto ch = getenv("METVIEW_EXTRA_FEATURE_SYMBOLS_DIR")) { + if (auto ch = getenv("METVIEW_EXTRA_FEATURE_SYMBOLS_DIR")) { resPath = std::string(ch) + "/images"; } } @@ -160,7 +160,7 @@ { static std::string resPath; if (resPath.empty()) { - if (auto ch = getenv("METVIEW_EXTRA_FEATURE_SYMBOLS_DIR")) { + if (auto ch = getenv("METVIEW_EXTRA_FEATURE_SYMBOLS_DIR")) { resPath = std::string(ch) + "/icons"; } } @@ -213,7 +213,7 @@ static std::string linkDir; if (linkDir.empty()) { auto ch = getenv("METVIEW_LINK_DIR"); - linkDir = (ch)?std::string(ch):""; + linkDir = (ch) ? std::string(ch) : ""; } return linkDir + "/images/" + fName; #endif @@ -225,7 +225,7 @@ #ifndef ECCODES_UI if (browser.empty()) { auto ch = getenv("MV_BROWSER_NAME"); - browser = (ch)?std::string(ch):""; + browser = (ch) ? std::string(ch) : ""; } #endif return browser; @@ -245,7 +245,7 @@ if (ret != 0) return false; - //This code caused the app to hang + // This code caused the app to hang #if 0 std::stringstream out; std::stringstream err; @@ -262,7 +262,7 @@ // Returns the result and an error message void shellCommand(const std::string& command, std::stringstream& out, std::stringstream& err) { - FILE* in; + FILE* in = nullptr; char cbuf[512]; // Create a temporary file @@ -301,7 +301,7 @@ } time_t sec = time(nullptr); - pid_t pid = getpid(); + pid_t pid = getpid(); std::stringstream out; out << tmpRoot << "/" + prefix + "_" << sec << "_" << pid; @@ -392,14 +392,14 @@ if (pos1 != std::string::npos && pos2 != std::string::npos && pos2 >= pos1) { return str.substr(pos1, pos2 - pos1 + 1); } - return std::string(); + return {}; } std::string replace(const std::string& data, const std::string& oldStr, const std::string& newStr) { std::string res = data; - size_t pos = res.find(oldStr); + size_t pos = res.find(oldStr); while (pos != std::string::npos) { res.replace(pos, oldStr.size(), newStr); pos = res.find(oldStr, pos + newStr.size()); @@ -432,7 +432,7 @@ return "?"; else { std::string strToWrite = metview::replace(in, space, spaceReplacement); - strToWrite = metview::replace(strToWrite, tab, tabReplacement); + strToWrite = metview::replace(strToWrite, tab, tabReplacement); return strToWrite; } } @@ -445,10 +445,10 @@ static std::string tabReplacement("\\9\\"); if (in == "?") - return std::string(""); + return {""}; std::string stnid = metview::replace(in, spaceReplacement, space); - stnid = metview::replace(stnid, tabReplacement, tab); + stnid = metview::replace(stnid, tabReplacement, tab); return stnid; } @@ -487,17 +487,17 @@ std::string beautify(const std::string& name) { std::string result = name; - bool up = true; + bool up = true; for (int it = 0; it < static_cast(name.length()); ++it) { char j = result[it]; if (j == '_' || j == ' ') { - up = true; + up = true; result[it] = ' '; } else { result[it] = up ? toupper(j) : tolower(j); - up = false; + up = false; } } @@ -562,7 +562,7 @@ std::string getLastLines(const std::string& fileName, int lastLineNum, std::string& error_msg) { if (lastLineNum <= 0) - return std::string(); + return {}; std::ifstream source(fileName.c_str(), std::ios_base::in); if (!source) { @@ -570,7 +570,7 @@ error_msg += " ("; error_msg += strerror(errno); error_msg += ")"; - return std::string(); + return {}; } size_t const granularity = 100 * lastLineNum; @@ -591,7 +591,7 @@ --newlineCount; } - return std::string(start, buffer.end()); + return {start, buffer.end()}; } #ifdef METVIEW @@ -602,10 +602,10 @@ if ((const char*)req("FIELDSET_FROM_FILTER") && (int)req("FIELDSET_FROM_FILTER") == 1) { fieldset* fs = request_to_fieldset(req); - fieldset* z = copy_fieldset(fs, fs->count, true); + fieldset* z = copy_fieldset(fs, fs->count, true); save_fieldset(z); request* finalreq = fieldset_to_request(z); - path = get_value(finalreq, "PATH", 0); + path = get_value(finalreq, "PATH", 0); } else { if (const char* ch = (const char*)req("PATH")) { @@ -675,4 +675,16 @@ return res; } -} //namespace metview +bool is_locale_numeric_set() +{ + static bool *st = nullptr; + if (st == nullptr) { + auto ch = getenv("LC_NUMERIC"); + std::string localeStr = (ch) ? std::string(ch) : ""; + st = new bool; + *st = (localeStr == "C"); + } + return *st; +} + +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/MvMiscellaneous.h metview-5.19.2/metview/src/libMetview/MvMiscellaneous.h --- metview-5.17.4/metview/src/libMetview/MvMiscellaneous.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvMiscellaneous.h 2023-07-15 08:28:47.000000000 +0000 @@ -126,4 +126,6 @@ return v; } +bool is_locale_numeric_set(); + } // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/MvMsg.h metview-5.19.2/metview/src/libMetview/MvMsg.h --- metview-5.17.4/metview/src/libMetview/MvMsg.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvMsg.h 2023-07-15 08:28:47.000000000 +0000 @@ -43,16 +43,16 @@ #ifdef _MV_DECLARE /* -*deleteme*char* MAGPROC_ERRLIST[] = -*deleteme*{ -*deleteme* "MagProc.MAG", * 0 * -*deleteme* "MagProc.VISDEF", * 1 * -*deleteme* "MagProc.FILE", * 2 * -*deleteme* "MagProc.GKS", * 3 * -*deleteme* "MagProc.SLIDE", * 4 * -*deleteme* "MagProc.PHYSICAL" * 5 * -*deleteme*}; -*/ + *deleteme*char* MAGPROC_ERRLIST[] = + *deleteme*{ + *deleteme* "MagProc.MAG", * 0 * + *deleteme* "MagProc.VISDEF", * 1 * + *deleteme* "MagProc.FILE", * 2 * + *deleteme* "MagProc.GKS", * 3 * + *deleteme* "MagProc.SLIDE", * 4 * + *deleteme* "MagProc.PHYSICAL" * 5 * + *deleteme*}; + */ const char* MAGPROC_ERRLIST[] = { diff -Nru metview-5.17.4/metview/src/libMetview/MvNetCDF.cc metview-5.19.2/metview/src/libMetview/MvNetCDF.cc --- metview-5.17.4/metview/src/libMetview/MvNetCDF.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvNetCDF.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,9 +41,9 @@ // First try to open the file // If it does not exist then try to create it in_define_mode_ = 0; - ncStatus_ = nc_open(path.c_str(), mode, &ncId_); + ncStatus_ = nc_open(path.c_str(), mode, &ncId_); if (ncStatus_ != NC_NOERR) { - ncStatus_ = nc_create(path.c_str(), mode, &ncId_); + ncStatus_ = nc_create(path.c_str(), mode, &ncId_); in_define_mode_ = 1; } } @@ -104,7 +104,7 @@ vchar_(0), vshort_(0), vushort_(0), - vint_(0), //vlong_(0), + vint_(0), // vlong_(0), vfloat_(0), vdouble_(0), vstring_(0) @@ -117,7 +117,7 @@ // Instantiate a new object ncId_ = nc->ncId(); - id_ = nc->id(); + id_ = nc->id(); name_ = nc->name(); type_ = nc->type(); @@ -138,7 +138,7 @@ vchar_(0), vshort_(0), vushort_(0), - vint_(0), //vlong_(0), + vint_(0), // vlong_(0), vfloat_(0), vdouble_(0), vstring_(0) @@ -151,7 +151,7 @@ // Instantiate a new object ncId_ = nc->ncId(); - id_ = nc->id(); + id_ = nc->id(); name_ = nc->name(); type_ = nc->type(); @@ -190,7 +190,7 @@ delete[](unsigned int*) values_; break; case NC_INT64: - delete[](long *) values_; + delete[](long*) values_; break; case NC_FLOAT: delete[](float*) values_; @@ -310,7 +310,7 @@ case NC_FLOAT: return (double)(*((float*)values_ + n)); case NC_DOUBLE: - //return *((double*)values_ + n*sizeof(double)); + // return *((double*)values_ + n*sizeof(double)); return *((double*)values_ + n); default: return 0.; @@ -353,22 +353,22 @@ } case NC_USHORT: { vushort_ = new ushort[nvalues_]; - values_ = (void*)vushort_; + values_ = (void*)vushort_; break; } case NC_INT: { - vint_ = new int[nvalues_]; + vint_ = new int[nvalues_]; values_ = (void*)vint_; break; } case NC_UINT: { - vuint_ = new unsigned int[nvalues_]; + vuint_ = new unsigned int[nvalues_]; values_ = (void*)vuint_; break; - } // case NC_LONG: + } // case NC_LONG: case NC_INT64: { - vint64_ = new long[nvalues_]; + vint64_ = new long[nvalues_]; values_ = (void*)vint64_; break; } @@ -381,21 +381,21 @@ break; case NC_DOUBLE: vdouble_ = new double[nvalues_]; - values_ = (void*)vdouble_; + values_ = (void*)vdouble_; break; case NC_CHAR: - vchar_ = new char[nvalues_ + 1]; + vchar_ = new char[nvalues_ + 1]; vchar_[nvalues_] = 0; - values_ = (void*)vchar_; + values_ = (void*)vchar_; break; case NC_BYTE: - vschar_ = new signed char[nvalues_ + 1]; + vschar_ = new signed char[nvalues_ + 1]; vschar_[nvalues_] = 0; - values_ = (void*)vschar_; + values_ = (void*)vschar_; break; case NC_STRING: vstring_ = new std::string[nvalues_]; - values_ = (void*)vstring_; + values_ = (void*)vstring_; break; default: return NC_ENOMEM; @@ -459,7 +459,7 @@ // Instantiate an existent attribute // Get attribute values - type_ = type; + type_ = type; values_ = new MvNcValues(this); } #endif @@ -655,13 +655,13 @@ MvNcVar::MvNcVar(const MvNcVar& aa) { - ncId_ = aa.ncId_; - id_ = aa.id_; - name_ = aa.name_; - type_ = aa.type_; + ncId_ = aa.ncId_; + id_ = aa.id_; + name_ = aa.name_; + type_ = aa.type_; attributes_ = aa.attributes_; - values_ = aa.values_; - isGlobal_ = aa.isGlobal_; + values_ = aa.values_; + isGlobal_ = aa.isGlobal_; int numd = getNumberOfDimensions(); the_cur_ = new size_t[numd]; @@ -689,7 +689,7 @@ // if (options().detectMissingValues()) MvNcAtt* att = getAttribute(options().missingValuesAttribute()); if (att != nullptr) { - missingValueIndicator_ = att->as_double(0); + missingValueIndicator_ = att->as_double(0); hasMissingValueIndicator_ = true; } } @@ -859,7 +859,7 @@ bool ok = parseDate(refDateString, refDate); if (ok) { refDate_ = refDate; - isTime_ = true; + isTime_ = true; } } // "since" @@ -882,7 +882,7 @@ if (from->hasMissingValueIndicator_ && !this->hasMissingValueIndicator_ && options().detectMissingValues()) { hasMissingValueIndicator_ = from->hasMissingValueIndicator_; - missingValueIndicator_ = from->missingValueIndicator_; + missingValueIndicator_ = from->missingValueIndicator_; options().missingValuesAttribute( from->options().missingValuesAttribute()); @@ -920,7 +920,7 @@ // Save info std::string sname = cname; - auto* tmpatt = new MvNcAtt(ncId_, id_, sname); + auto* tmpatt = new MvNcAtt(ncId_, id_, sname); if (!tmpatt) { return; } @@ -988,7 +988,7 @@ return true; bool ret_code = false; - NcType type = att->type(); + NcType type = att->type(); if (type == NC_BYTE || type == NC_CHAR) { const char* vals = (const char*)att->values()->base(); ret_code = @@ -1083,7 +1083,7 @@ return ncStatus_ == NC_NOERR; } -#if 0 //F +#if 0 // F NcBool MvNcVar::put(MvNcVar *var) { if (!isValid() || !var->isValid()) return false; @@ -1221,10 +1221,6 @@ // Allocate char array to hold all the values char* ptr = new char[num_values]; - // Allocate space to hold one string. NetCDF does not - // nullterminate strings, so the 0 should be added - char* one_str = new char[last_dim + 1]; - // F ret_val = ncVar_->get(ptr,counts); ret_val = nc_get_var(ncId_, id_, ptr); if (ret_val == NC_NOERR) { @@ -1236,20 +1232,26 @@ else num_values1 = num_values; - i = 0; + i = 0; int j = 0; + + // Allocate space to hold one string. NetCDF does not + // nullterminate strings, so the 0 should be added + char* one_str = new char[last_dim + 1]; + while (i < num_values1) { strncpy(one_str, &ptr[i], last_dim); one_str[last_dim] = 0; - vals[j] = one_str; + vals[j] = one_str; i += last_dim; ++j; } + + delete[] one_str; } // Delete temporaries delete[] ptr; - delete[] one_str; } else { char* scalarval = (char*)values()->base(); @@ -1269,12 +1271,12 @@ { // F return ncVar_->set_cur(c0,c1,c2,c3,c4); long t[6]; - t[0] = c0; - t[1] = c1; - t[2] = c2; - t[3] = c3; - t[4] = c4; - t[5] = -1; + t[0] = c0; + t[1] = c1; + t[2] = c2; + t[3] = c3; + t[4] = c4; + t[5] = -1; int num_dims = getNumberOfDimensions(); for (int j = 0; j < 6; j++) { // find how many parameters were used @@ -1422,11 +1424,11 @@ if (idx == NC_DOUBLE) // would not be able to repack doubles anyway return; - double max = -DBL_MAX; - double min = DBL_MAX; - double midrange = 0; - int64_t scaled_max = 0; - int64_t scaled_min = 0; + double max = -DBL_MAX; + double min = DBL_MAX; + double midrange = 0; + int64_t scaled_max = 0; + int64_t scaled_min = 0; int64_t scaled_midrange = 0; double ao = 0.0, sf = 0.0; double x; @@ -1466,9 +1468,9 @@ minPacked > nc_type_values_[idx].nc_type_max) { // yes - we will need to repack midrange = (max + min) / 2.0; - sf = (double)((max - min) / (double)(nc_type_values_[idx].nc_type_max - + sf = (double)((max - min) / (double)(nc_type_values_[idx].nc_type_max - nc_type_values_[idx].nc_type_min)); - ao = ((max + min) - sf * (nc_type_values_[idx].nc_type_min + + ao = ((max + min) - sf * (nc_type_values_[idx].nc_type_min + nc_type_values_[idx].nc_type_max)) / 2; @@ -1480,17 +1482,17 @@ x = ((midrange - ao)); x /= sf; - scaled_max = rint((max - ao) / sf); - scaled_min = rint((min - ao) / sf); + scaled_max = rint((max - ao) / sf); + scaled_min = rint((min - ao) / sf); scaled_midrange = rint((midrange - ao) / sf); - max = scaled_max * sf + ao; - min = scaled_min * sf + ao; + max = scaled_max * sf + ao; + min = scaled_min * sf + ao; midrange = scaled_midrange * sf + ao; if (scaleFactor_ != sf || addOffset_ != ao) { scaleFactor_ = sf; - addOffset_ = ao; + addOffset_ = ao; // can't use the MvNcVar version because it will not // overwrite an existing attribute @@ -1504,7 +1506,7 @@ if (hasMissingValueIndicator_) { missingValueIndicator_ = nc_type_values_[idx].nc_type_missing; - ret_code3 = putAttributeWithType(options().missingValuesAttribute(), + ret_code3 = putAttributeWithType(options().missingValuesAttribute(), idx, missingValueIndicator_); } @@ -1513,9 +1515,9 @@ int natts; ncStatus_ = nc_inq_natts(id_, &natts); char cname[NC_MAX_NAME]; - ncStatus_ = nc_inq_attname(ncId_, id_, natts - 1, cname); + ncStatus_ = nc_inq_attname(ncId_, id_, natts - 1, cname); std::string sname = cname; - auto* tmpatt = new MvNcAtt(ncId_, id_, sname); + auto* tmpatt = new MvNcAtt(ncId_, id_, sname); attributes_.push_back(tmpatt); } } @@ -1553,7 +1555,7 @@ int MvNcVar::getNumberOfDimensions() { - int ndim = -1; + int ndim = -1; ncStatus_ = nc_inq_varndims(ncId_, id_, &ndim); return ndim; @@ -1577,7 +1579,7 @@ int MvNcVar::getDimension(long& dim) { long* edges1 = edges(); - dim = numValsFromCounts(edges1); + dim = numValsFromCounts(edges1); return NC_NOERR; } @@ -1655,7 +1657,8 @@ {0xfffffff, 0, NC_FILL_UINT}, /* NC_UINT, unsigned 4 byte integer */ {0xfffffff, 0, - NC_FILL_UINT}, /* NC_INT64, signed 8 byte integer */}; + NC_FILL_UINT}, + /* NC_INT64, signed 8 byte integer */}; // note: fillvalue for NC_INT64 should be NC_FILL_INT64 but this does not fit into a double. // this is ok for now, because we only need this type for attributes rather than data @@ -1726,8 +1729,7 @@ void MvNetCDF::init(const std::string& path, int imode) { ncFile_ = new MvNcFile(path, imode); - - if (!ncFile_ || !ncFile_->isValid()) { + if (!ncFile_->isValid()) { ncStatus_ = ncFile_->status(); return; } @@ -1816,7 +1818,7 @@ // Create and save variable internal structure std::string sname = name; - auto* tmpvar = new MvNcVar(varId, sname, type, false, this); + auto* tmpvar = new MvNcVar(varId, sname, type, false, this); variables_.push_back(tmpvar); if (dimIds) { @@ -2020,7 +2022,7 @@ } std::string sname = name; - auto* tmpvar = new MvNcVar(varids[i], sname, type, false, this); + auto* tmpvar = new MvNcVar(varids[i], sname, type, false, this); variables_.push_back(tmpvar); } @@ -2043,8 +2045,8 @@ MvNcDim* tmpdim; for (auto& variable : variables_) { - tmpvar = variable; - num_dim = tmpvar->getNumberOfDimensions(); + tmpvar = variable; + num_dim = tmpvar->getNumberOfDimensions(); num_attr = tmpvar->getNumberOfAttributes(); // For each variable, add subrequest with dimensions and attributes @@ -2082,7 +2084,7 @@ const char* req_name; for (i = 0; i < getNumberOfAttributes(); i++) { MvNcAtt* tmpatt = getAttribute(i); - req_name = tmpatt->name(); + req_name = tmpatt->name(); if (tmpatt->type() == NC_CHAR) r.addValue(req_name, tmpatt->as_string(0).c_str()); @@ -2141,7 +2143,7 @@ int MvNetCDF::getNumberOfDimensions() { - int ndim = -1; + int ndim = -1; ncStatus_ = nc_inq_ndims(ncId(), &ndim); return ndim; @@ -2187,7 +2189,7 @@ { // Create a variable structure std::string name = "global_attr"; - globalVar_ = new MvNcVar(NC_GLOBAL, name, 0, true, this); + globalVar_ = new MvNcVar(NC_GLOBAL, name, 0, true, this); return ncStatus_; } diff -Nru metview-5.17.4/metview/src/libMetview/MvNetCDF.h metview-5.19.2/metview/src/libMetview/MvNetCDF.h --- metview-5.17.4/metview/src/libMetview/MvNetCDF.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvNetCDF.h 2023-07-15 08:28:47.000000000 +0000 @@ -59,12 +59,12 @@ { D_ISNUMBER = 1, D_ISSTRING = 2, - D_ISANY = 3 + D_ISANY = 3 }; // F enum { CDF_FILL = NcFile::Fill,CDF_NOFILL = NcFile::NoFill}; enum { - CDF_FILL = NC_FILL, + CDF_FILL = NC_FILL, CDF_NOFILL = NC_NOFILL }; @@ -89,18 +89,18 @@ // Functions members // F NcVar *globalVariable() { return globalv; } - int ncId() { return ncId_; } + int ncId() const { return ncId_; } - bool isValid() { return ncStatus_ == NC_NOERR; } - int status() { return ncStatus_; } + bool isValid() const { return ncStatus_ == NC_NOERR; } + int status() const { return ncStatus_; } // Handle file mode bool dataMode(); bool defineMode(); - int sync() { return nc_sync(ncId_); } + int sync() const { return nc_sync(ncId_); } - int close() { return nc_close(ncId_); } + int close() const { return nc_close(ncId_); } int getFillMode(); int setFillMode(int); @@ -224,7 +224,7 @@ ushort* vushort_; int* vint_; unsigned int* vuint_; - long *vint64_; + long* vint64_; // long* vlong_; float* vfloat_; double* vdouble_; @@ -276,8 +276,8 @@ std::string as_string(long n) { return values()->as_string(n); } MvDate as_date(long n) { return processDate(values()->as_double(n)); } - //template - //int get(std::vector &vec) { return values()->get(vec); } + // template + // int get(std::vector &vec) { return values()->get(vec); } virtual MvNcValues* values() = 0; // F virtual NcTypedComponent *delegate() = 0; @@ -295,7 +295,7 @@ int ncStatus_; virtual double processValue(double val) = 0; - virtual MvDate processDate(double val) = 0; + virtual MvDate processDate(double val) = 0; bool hasScaling() { return (scaleFactor_ != 1 || addOffset_ != 0); } }; @@ -401,7 +401,10 @@ void storeTimeInformation(); void getStringType(std::string&); - bool isTime() { return isTime_; } + bool isTime() + { + return isTime_; + } MvNetCDFBehaviour& options(); @@ -519,7 +522,7 @@ long numValsFromCounts(const long* counts) { long num_values = 1; - int ndim = getNumberOfDimensions(); + int ndim = getNumberOfDimensions(); for (int i = 0; i < ndim; i++) num_values *= counts[i]; @@ -535,8 +538,8 @@ return false; long num_values = 1; - long nvals = nvals1; - int ndim = getNumberOfDimensions(); + long nvals = nvals1; + int ndim = getNumberOfDimensions(); int i; vals.erase(vals.begin(), vals.end()); @@ -558,13 +561,13 @@ } else { len[i] = counts[i]; - nvals = (nvals / counts[i]) + 1; + nvals = (nvals / counts[i]) + 1; np *= len[i]; } } vals.resize(np); - //F ret_val = ncVar_->get(&vals.front(),len); + // F ret_val = ncVar_->get(&vals.front(),len); ncStatus_ = get_vara(vals, len); } else { @@ -664,7 +667,7 @@ { for (int i = 0; i < getNumberOfDimensions(); i++) std::cout << the_cur_[i] << " " << counts[i] << std::endl; -ncStatus_=nc_get_var_double(ncId_,id_,(double*)&vals.front()); +ncStatus_=nc_get_var_double(ncId_,id_,(double*)&vals.front()); switch(type_) { case NC_DOUBLE: @@ -706,7 +709,7 @@ template void packValues(T* vals, const long* counts) { - bool isInt = isIntegerType(); + bool isInt = isIntegerType(); bool doScale = hasScaling() && options().scaleValues(); bool doMissing = hasMissingValueIndicator_ && options().detectMissingValues(); @@ -825,7 +828,7 @@ vals[i] = vecvals[i]; // F bool retVal = ncVar_->put(vals,c0,c1,c2,c3,c4); - //ncStatus_ = nc_put_var(ncId_, id_, vals); + // ncStatus_ = nc_put_var(ncId_, id_, vals); bool ret = put(vals, c0, c1, c2, c3, c4); delete[] vals; return ret; diff -Nru metview-5.17.4/metview/src/libMetview/MvNetwork.cc metview-5.19.2/metview/src/libMetview/MvNetwork.cc --- metview-5.17.4/metview/src/libMetview/MvNetwork.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvNetwork.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,15 +42,15 @@ void MvNetworkData::clear() { buffer_ = 0; - pos_ = 0; - len_ = 0; + pos_ = 0; + len_ = 0; } size_t MvNetworkData::add(char* ptr, size_t size) { if (buffer_ == nullptr) { - pos_ = 0; - len_ = initialSize_; + pos_ = 0; + len_ = initialSize_; buffer_ = static_cast(malloc(len_)); } @@ -61,7 +61,7 @@ buffer_ = static_cast(realloc(buffer_, len_)); if (!buffer_) { - //error_++; + // error_++; return 0; } } @@ -119,7 +119,7 @@ // get the Metview user preferences MvRequest myPref = MvApplication::getExpandedPreferences(); - bool use = false; + bool use = false; const char* useProxy = myPref("USE_NETWORK_PROXY"); if ((useProxy != nullptr)) use = (strcmp(useProxy, "Yes") == 0 || @@ -208,7 +208,7 @@ size_t MvNetwork::writeCb(char* ptr, size_t size, size_t nmemb, void* userdata) { - //std::cout << "writeCB " << size*nmemb << std::endl; + // std::cout << "writeCB " << size*nmemb << std::endl; if (!userdata) return 0; diff -Nru metview-5.17.4/metview/src/libMetview/MvObs.cc metview-5.19.2/metview/src/libMetview/MvObs.cc --- metview-5.17.4/metview/src/libMetview/MvObs.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvObs.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,7 @@ ***************************** LICENSE END *************************************/ -#include +#include #include #include @@ -32,9 +32,11 @@ #include "MvObsSet.h" #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif //____________________________________________________________________ @@ -45,13 +47,16 @@ // MvObsSet. Maybe, this class can be removed in the future. //______________________________________________________________________ -MvBufrOut::MvBufrOut(MvObsSet* aSet) : _outSet(aSet) {} +MvBufrOut::MvBufrOut(MvObsSet* aSet) : + _outSet(aSet) {} -MvBufrOut::~MvBufrOut() { +MvBufrOut::~MvBufrOut() +{ // _outSet->close(); // the owner should be responsible to close this file } -void MvBufrOut::add(MvObs& anObs) { +void MvBufrOut::add(MvObs& anObs) +{ _outSet->write(anObs); } @@ -60,14 +65,13 @@ //-------------------------------------------------------- #ifndef DOXYGEN_SHOULD_SKIP_THIS -struct descriptorStruct { +struct descriptorStruct +{ const char* name; long descriptor; }; -static descriptorStruct knownParams[] = {{"z", 10003}, {"p", 10004}, {"ddd", 11001}, {"ff", 11002}, - {"u", 11003}, {"v", 11004}, {"w", 11006}, {"T", 12001}, - {"Td", 12003}, {"T(2m)", 12004}, {"Td(2m)", 12006}, {"END", 0}}; +static descriptorStruct knownParams[] = {{"z", 10003}, {"p", 10004}, {"ddd", 11001}, {"ff", 11002}, {"u", 11003}, {"v", 11004}, {"w", 11006}, {"T", 12001}, {"Td", 12003}, {"T(2m)", 12004}, {"Td(2m)", 12006}, {"END", 0}}; #endif // e Remove cPressureCoordinate @@ -78,70 +82,75 @@ //______________________________________________________________________ MvObs::MvObs(MvEccHandle_ptr ecH, int subset_current, bool unpacked, bool cacheCompressedData) : - _subsetNr(subset_current), _unpacked(unpacked), cacheCompressedData_(cacheCompressedData), _ecH(ecH) { + _subsetNr(subset_current), _unpacked(unpacked), cacheCompressedData_(cacheCompressedData), _ecH(ecH) +{ if (_ecH && _ecH->handle()) init(); } -MvObs::MvObs(const MvObs& obs) { +MvObs::MvObs(const MvObs& obs) +{ _copy(obs); } //___________________________________________________________________Destructor -MvObs::~MvObs() { +MvObs::~MvObs() +{ clear(); } //___________________________________________________________________ _copy -void MvObs::_copy(const MvObs& b) { - _subsetNr = b._subsetNr; - _compressed_data = b._compressed_data; - _unpacked = b._unpacked; - _messageTotalLen = b._messageTotalLen; +void MvObs::_copy(const MvObs& b) +{ + _subsetNr = b._subsetNr; + _compressed_data = b._compressed_data; + _unpacked = b._unpacked; + _messageTotalLen = b._messageTotalLen; _currentLevelOccurrence = b._currentLevelOccurrence; - _currentLevelKey = b._currentLevelKey; - _currentKey = b._currentKey; - _editionNumber = b._editionNumber; - _number_of_subsets = b._number_of_subsets; - _messageType = b._messageType; - _subTypeInternational = b._subTypeInternational; - _subTypeLocal = b._subTypeLocal; - _rdbType = b._rdbType; - _originatingCentre = b._originatingCentre; - _originatingCentreStr = b._originatingCentreStr; - _originatingSubCentre = b._originatingSubCentre; - _masterTable = b._masterTable; - _masterTableVersion = b._masterTableVersion; - _localTableVersion = b._localTableVersion; - _lyear = b._lyear; - _lmonth = b._lmonth; - _lday = b._lday; - _lhour = b._lhour; - _lminute = b._lminute; - headerIdent_ = b.headerIdent_; - _edition = b._edition; + _currentLevelKey = b._currentLevelKey; + _currentKey = b._currentKey; + _editionNumber = b._editionNumber; + _number_of_subsets = b._number_of_subsets; + _messageType = b._messageType; + _subTypeInternational = b._subTypeInternational; + _subTypeLocal = b._subTypeLocal; + _rdbType = b._rdbType; + _originatingCentre = b._originatingCentre; + _originatingCentreStr = b._originatingCentreStr; + _originatingSubCentre = b._originatingSubCentre; + _masterTable = b._masterTable; + _masterTableVersion = b._masterTableVersion; + _localTableVersion = b._localTableVersion; + _lyear = b._lyear; + _lmonth = b._lmonth; + _lday = b._lday; + _lhour = b._lhour; + _lminute = b._lminute; + headerIdent_ = b.headerIdent_; + _edition = b._edition; useSkipExtraAttributes_ = b.useSkipExtraAttributes_; - cacheCompressedData_ = b.cacheCompressedData_; - _ecH = b._ecH; - _ecIter = 0; - _ecHSS = 0; - _bufferSS = 0; + cacheCompressedData_ = b.cacheCompressedData_; + _ecH = b._ecH; + _ecIter = nullptr; + _ecHSS = nullptr; + _bufferSS = nullptr; if (cacheCompressedData_) compressedData_ = b.compressedData_; } //___________________________________________________________________ clear -void MvObs::clear() { +void MvObs::clear() +{ // Delete iterator if (_ecH && _ecH->handle() && _ecIter) { codes_bufr_keys_iterator_delete(_ecIter); - _ecIter = 0; + _ecIter = nullptr; } // Delete handle/iterator/buffer related to a subset if (_bufferSS) - _bufferSS = 0; + _bufferSS = nullptr; if (_ecH && _ecH->handle() && _ecHSS) { codes_handle_delete(_ecHSS); @@ -152,34 +161,40 @@ } //___________________________________________________________________ operator= -MvObs& MvObs::operator=(const MvObs& b) { +MvObs& MvObs::operator=(const MvObs& b) +{ clear(); _copy(b); return *this; } //___________________________________________________________________ operator void* -MvObs::operator void*() { +MvObs::operator void*() +{ return (_ecH) ? (_ecH->handle()) : nullptr; } //___________________________________________________________________ operator! -bool MvObs::operator!() { +bool MvObs::operator!() +{ return !(_ecH && _ecH->handle()); } -codes_handle* MvObs::getHandle() const { +codes_handle* MvObs::getHandle() const +{ return (_ecH) ? (_ecH->handle()) : nullptr; } //___________________________________________________________________ msg_ok // -bool MvObs::msg_ok() const { +bool MvObs::msg_ok() const +{ return (_ecH && _ecH->handle()); } //___________________________________________________________________ Advance -bool MvObs::Advance() { +bool MvObs::Advance() +{ _subsetNr++; if (cacheCompressedData_ && _compressed_data) { compressedData_.resetCurrent(); @@ -195,7 +210,8 @@ } //____________________________________________________________________ hasSection2 -bool MvObs::hasSection2() { +bool MvObs::hasSection2() +{ long val = intValue("section2Present"); return val ? true : false; } @@ -203,7 +219,8 @@ //____________________________________________________________________ value // returns 'kBufrMissingValue' if not found! //------------------------------------------------- -double MvObs::valueC(const std::string& aDescriptor) { +double MvObs::valueC(const std::string& aDescriptor) +{ // Check only positive integer values; otherwise, use "-.0123456789" std::string skey; if (strspn(aDescriptor.c_str(), "0123456789") == aDescriptor.size()) @@ -215,33 +232,37 @@ } // Parameter occurrence must start from 1 -double MvObs::value(long aDescriptor, int occurrence) { +double MvObs::value(long aDescriptor, int occurrence) +{ // Build key and get value std::string skey = this->key(aDescriptor, occurrence); - double myValue = value(skey); + double myValue = value(skey); return myValue; } -double MvObs::value(long aDescriptor) { +double MvObs::value(long aDescriptor) +{ // Build key and get value std::string skey = this->key(aDescriptor); - double myValue = value(skey); + double myValue = value(skey); return myValue; } -double MvObs::value(const std::string& key, const int occurrence) { +double MvObs::value(const std::string& key, const int occurrence) +{ // Build key and get value std::string skey = this->key(key, occurrence); return value(skey); } -double MvObs::value(const std::string& skey) { +double MvObs::value(const std::string& skey) +{ // Check input key if (skey.empty()) return kBufrMissingValue; // Get number of elements - size_t nelems; + size_t nelems = 0; codes_get_size(_ecH->handle(), skey.c_str(), &nelems); // No elements found @@ -294,7 +315,7 @@ } dvalue = v1[_subsetNr - 1]; delete[] v1; - v1 = 0; + v1 = nullptr; } else // uncompressed data { @@ -306,7 +327,7 @@ std::ostringstream sstream; sstream << _subsetNr << "/"; sskey = "/subsetNumber=" + sstream.str() + skey; - size_t nn; + size_t nn = 0; codes_get_size(_ecH->handle(), sskey.c_str(), &nn); if (nn == 0) sskey = skey; // retrieve using the original key @@ -322,14 +343,15 @@ codes_get_double_array(_ecH->handle(), sskey.c_str(), v1, &nelems); dvalue = v1[0]; // first occurrence delete[] v1; - v1 = 0; + v1 = nullptr; } return dvalue == CODES_MISSING_DOUBLE ? kBufrMissingValue : dvalue; } //___________________________________________________________ valueByOccurrence -double MvObs::valueByOccurrenceC(int anOccurrenceIndex, const std::string& aDescriptor) { +double MvObs::valueByOccurrenceC(int anOccurrenceIndex, const std::string& aDescriptor) +{ // Check only positive integer values; otherwise, use "-.0123456789" std::string skey; if (strspn(aDescriptor.c_str(), "0123456789") == aDescriptor.size()) @@ -340,28 +362,31 @@ return value(skey); } -double MvObs::valueByOccurrence(int anOccurrenceIndex, const std::string& aDescriptor) { +double MvObs::valueByOccurrence(int anOccurrenceIndex, const std::string& aDescriptor) +{ // Build key and get value std::string skey = key(aDescriptor, anOccurrenceIndex); return value(skey); } -double MvObs::valueByOccurrence(int anOccurrenceIndex, long aDescriptor) { +double MvObs::valueByOccurrence(int anOccurrenceIndex, long aDescriptor) +{ // Build key and get value std::string skey = this->key(aDescriptor, anOccurrenceIndex); - double myValue = value(skey); + double myValue = value(skey); return myValue; } // Returns all values of a given key from a message/subset. The key is either a simple string // e.g. "airTemperature" or a containing the rank e.g. "#1#airTemperature" -void MvObs::allValues(const std::string& keyName, std::vector& vals) { +void MvObs::allValues(const std::string& keyName, std::vector& vals) +{ // Check input key if (keyName.empty()) return; // Get number of elements - size_t valLen; + size_t valLen = 0; codes_get_size(_ecH->handle(), keyName.c_str(), &valLen); // No elements found @@ -376,24 +401,24 @@ return; } - double* valArr = nullptr; + double* valArr = nullptr; size_t valArrNum = 0; // It is an array of elements if (_compressed_data) { int maxRank = 1000000; // we do not know how many ranks we have! - int ir = 1; - int rank = occurenceFromKey(keyName); + int ir = 1; + int rank = occurenceFromKey(keyName); // we read a single rank only if (rank >= 1) { - ir = rank; + ir = rank; maxRank = ir + 1; } // loop for the ranks while (ir < maxRank) { - valLen = 0; + valLen = 0; std::string rKeyName = keyName; if (rank < 1) { rKeyName = "#" + toString(ir) + "#" + keyName; @@ -413,7 +438,7 @@ else if (_subsetNr <= static_cast(valLen)) { if (valArrNum < valLen) { delete[] valArr; - valArr = new double[valLen]; + valArr = new double[valLen]; valArrNum = valLen; } assert(valArr); @@ -427,7 +452,7 @@ } else // uncompressed data { - valLen = 0; + valLen = 0; std::string rKeyName = "/subsetNumber=" + toString(_subsetNr) + "/" + keyName; codes_get_size(_ecH->handle(), rKeyName.c_str(), &valLen); @@ -439,7 +464,7 @@ // Array else { assert(!valArr); - valArr = new double[valLen]; + valArr = new double[valLen]; valArrNum = valLen; codes_get_double_array(_ecH->handle(), rKeyName.c_str(), valArr, &valLen); for (size_t i = 0; i < valLen; i++) @@ -455,37 +480,42 @@ //____________________________________________________________________ intValue -long MvObs::currentIntValue() { +long MvObs::currentIntValue() +{ return intValue(_currentKey); } -long MvObs::intValue(const long aDescriptor, const int occurrence) { +long MvObs::intValue(const long aDescriptor, const int occurrence) +{ // Build key and get value std::string skey = this->key(aDescriptor, occurrence); - long myValue = intValue(skey); + long myValue = intValue(skey); return myValue; } -long MvObs::intValue(const long aDescriptor) { +long MvObs::intValue(const long aDescriptor) +{ // Build key and get value std::string skey = this->key(aDescriptor); - long myValue = intValue(skey); + long myValue = intValue(skey); return myValue; } -long MvObs::intValue(const std::string& key, const int occurrence) { +long MvObs::intValue(const std::string& key, const int occurrence) +{ // Build key and get value std::string skey = this->key(key, occurrence); return intValue(skey); } -long MvObs::intValue(const std::string& skey) { +long MvObs::intValue(const std::string& skey) +{ // Check input key if (skey.empty()) return kBufrMissingIntValue; // Get number of elements - size_t nelems; + size_t nelems = 0; codes_get_size(_ecH->handle(), skey.c_str(), &nelems); // No elements found @@ -537,7 +567,7 @@ compressedData_.addLongData(sskey, v1, nelems); // add to cache } delete[] v1; - v1 = 0; + v1 = nullptr; } else // uncompressed data { @@ -549,7 +579,7 @@ std::ostringstream sstream; sstream << _subsetNr << "/"; sskey = "/subsetNumber=" + sstream.str() + skey; - size_t nn; + size_t nn = 0; codes_get_size(_ecH->handle(), sskey.c_str(), &nn); if (nn == 0) sskey = skey; // retrieve using the original key @@ -565,7 +595,7 @@ codes_get_long_array(_ecH->handle(), sskey.c_str(), v1, &nelems); value = v1[0]; // first occurrence delete[] v1; - v1 = 0; + v1 = nullptr; } return value == CODES_MISSING_LONG ? kBufrMissingIntValue : value; @@ -573,13 +603,14 @@ // Returns all values of a given key from a message/subset. The key is either a simple string // e.g. "airTemperature" or one containing the rank e.g. "#1#airTemperature" -void MvObs::allIntValues(const std::string& keyName, std::vector& vals) { +void MvObs::allIntValues(const std::string& keyName, std::vector& vals) +{ // Check input key if (keyName.empty()) return; // Get number of elements - size_t valLen; + size_t valLen = 0; codes_get_size(_ecH->handle(), keyName.c_str(), &valLen); // No elements found @@ -594,24 +625,24 @@ return; } - long* valArr = 0; + long* valArr = nullptr; size_t valArrNum = 0; // It is an array of elements if (_compressed_data) { int maxRank = 1000000; // we do not know how many ranks we have! - int ir = 1; - int rank = occurenceFromKey(keyName); + int ir = 1; + int rank = occurenceFromKey(keyName); // we read a single rank only if (rank >= 1) { - ir = rank; + ir = rank; maxRank = ir + 1; } // loop for the ranks while (ir < maxRank) { - valLen = 0; + valLen = 0; std::string rKeyName = keyName; if (rank < 1) rKeyName = "#" + toString(ir) + "#" + keyName; @@ -652,7 +683,7 @@ else if (_subsetNr <= static_cast(valLen)) { if (valArrNum < valLen) { delete[] valArr; - valArr = new long[valLen]; + valArr = new long[valLen]; valArrNum = valLen; } assert(valArr); @@ -671,7 +702,7 @@ else // uncompressed data { - valLen = 0; + valLen = 0; std::string rKeyName = "/subsetNumber=" + toString(_subsetNr) + "/" + keyName; codes_get_size(_ecH->handle(), rKeyName.c_str(), &valLen); @@ -683,7 +714,7 @@ // Array else { assert(!valArr); - valArr = new long[valLen]; + valArr = new long[valLen]; valArrNum = valLen; codes_get_long_array(_ecH->handle(), rKeyName.c_str(), valArr, &valLen); for (size_t i = 0; i < valLen; i++) @@ -698,27 +729,31 @@ } //_________________________________________________________________ stringValue -std::string MvObs::stringValue(const long aDescriptor, const int occurrence) { +std::string MvObs::stringValue(const long aDescriptor, const int occurrence) +{ // Build key and get value - std::string skey = this->key(aDescriptor, occurrence); + std::string skey = this->key(aDescriptor, occurrence); std::string myValue = stringValue(skey); return myValue; } -std::string MvObs::stringValue(const long aDescriptor) { +std::string MvObs::stringValue(const long aDescriptor) +{ // Build key and get value - std::string skey = this->key(aDescriptor); + std::string skey = this->key(aDescriptor); std::string myValue = stringValue(skey); return myValue; } -std::string MvObs::stringValue(const std::string& key, const int occurrence) { +std::string MvObs::stringValue(const std::string& key, const int occurrence) +{ // Build key and get value std::string skey = this->key(key, occurrence); return stringValue(skey); } -std::string MvObs::stringValue(const std::string& skeyi) { +std::string MvObs::stringValue(const std::string& skeyi) +{ // skeyi could be a numerical descriptor coded as a string std::string skey = keyC(skeyi); @@ -743,11 +778,11 @@ if (buf[0] == -1) // missing value - cannot convert to string return {}; else - return std::string(buf); + return {buf}; } // It is an array of elements - size_t isize = 128; //???? + size_t isize = 128; //???? char** cValues = nullptr; if (_compressed_data) { @@ -776,7 +811,7 @@ if (cacheCompressedData_) { compressedData_.addStringData(sskey, buf); // add to cache } - return std::string(buf); + return {buf}; // multiple values } else { @@ -802,14 +837,14 @@ std::ostringstream sstream; sstream << _subsetNr << "/"; sskey = "/subsetNumber=" + sstream.str() + skey; - size_t nn; + size_t nn = 0; codes_get_size(_ecH->handle(), sskey.c_str(), &nn); if (nn == 0) sskey = skey; // retrieve using the original key else if (nn == 1) { codes_get_string(_ecH->handle(), sskey.c_str(), buf, &len); // buf[len] = 0; //??? - return std::string(buf); + return {buf}; } else nelems = nn; @@ -832,11 +867,12 @@ delete[] cValues; } - return std::string(buf); + return {buf}; } // It should only be used through the iterator -std::string MvObs::stringValue() { +std::string MvObs::stringValue() +{ std::string myValue = stringValue(_currentKey); return myValue; } @@ -844,13 +880,14 @@ // Returns all values of a given key from a message/subset. The key is either a simple string // e.g. "airTemperature" or a containing the rank e.g. "#1#airTemperature" -void MvObs::allStringValues(const std::string& keyName, std::vector& vals) { +void MvObs::allStringValues(const std::string& keyName, std::vector& vals) +{ // Check input key if (keyName.empty()) return; // Get number of elements - size_t valLen; + size_t valLen = 0; codes_get_size(_ecH->handle(), keyName.c_str(), &valLen); // No elements found @@ -863,29 +900,29 @@ std::size_t sLen = 1024; if (valLen == 1) { codes_get_string(_ecH->handle(), keyName.c_str(), buf, &sLen); - vals.push_back(std::string(buf)); + vals.emplace_back(buf); return; } - char** valArr = 0; + char** valArr = nullptr; size_t valArrNum = 0; - size_t sLenArr = 128; // the maximum string size we handle + size_t sLenArr = 128; // the maximum string size we handle // It is an array of elements if (_compressed_data) { int maxRank = 1000000; // we do not know how many ranks we have! - int ir = 1; - int rank = occurenceFromKey(keyName); + int ir = 1; + int rank = occurenceFromKey(keyName); // we read a sing rank only if (rank >= 1) { - ir = rank; + ir = rank; maxRank = ir + 1; } // loop for the ranks while (ir < maxRank) { - valLen = 0; + valLen = 0; std::string rKeyName = keyName; if (rank < 1) rKeyName = "#" + toString(ir) + "#" + keyName; @@ -898,7 +935,7 @@ // Single value if (valLen == 1) { codes_get_string(_ecH->handle(), rKeyName.c_str(), buf, &sLen); - vals.push_back(std::string(buf)); + vals.emplace_back(buf); } // Array else if (_subsetNr <= static_cast(valLen)) { @@ -926,14 +963,14 @@ else // uncompressed data { - valLen = 0; + valLen = 0; std::string rKeyName = "/subsetNumber=" + toString(_subsetNr) + "/" + keyName; codes_get_size(_ecH->handle(), rKeyName.c_str(), &valLen); assert(!valArr); if (valLen == 1) { codes_get_string(_ecH->handle(), rKeyName.c_str(), buf, &sLen); - vals.push_back(std::string(buf)); + vals.emplace_back(buf); } // Array else { @@ -942,11 +979,11 @@ for (std::size_t i = 0; i < valLen; ++i) valArr[i] = new char[sLenArr]; - valArrNum = valLen; + valArrNum = valLen; std::size_t sTotal = valLen * sLenArr; codes_get_string_array(_ecH->handle(), rKeyName.c_str(), valArr, &sTotal); for (size_t i = 0; i < valLen; i++) - vals.push_back(std::string(valArr[i])); + vals.emplace_back(valArr[i]); } } @@ -958,7 +995,8 @@ } } -void MvObs::initCompressedCache(const std::set& neededKeys) { +void MvObs::initCompressedCache(const std::set& neededKeys) +{ if (_compressed_data && cacheCompressedData_ && !compressedData_.initialised()) { compressedData_.clear(); if (!neededKeys.empty()) { @@ -973,7 +1011,8 @@ } } -bool MvObs::setFirstDescriptor(bool skipConfidence) { +bool MvObs::setFirstDescriptor(bool skipConfidence) +{ if (cacheCompressedData_ && _compressed_data && compressedData_.initialised()) { compressedData_.resetCurrent(); } @@ -984,7 +1023,7 @@ // Delete previous iterator if (_ecIter) { codes_bufr_keys_iterator_delete(_ecIter); - _ecIter = 0; + _ecIter = nullptr; } // Data needs to be unpacked @@ -1011,7 +1050,8 @@ return true; } -bool MvObs::setNextDescriptor() { +bool MvObs::setNextDescriptor() +{ if (cacheCompressedData_ && _compressed_data && compressedData_.initialised()) { if (compressedData_.next()) { _currentKey = compressedData_.currentKey(); @@ -1025,7 +1065,7 @@ // Advance iterator if (!codes_bufr_keys_iterator_next(_ecIter)) { codes_bufr_keys_iterator_delete(_ecIter); - _ecIter = 0; + _ecIter = nullptr; return false; } @@ -1045,7 +1085,7 @@ if (!flag) { codes_bufr_keys_iterator_delete(_ecIter); - _ecIter = 0; + _ecIter = nullptr; } return flag; @@ -1053,14 +1093,16 @@ return false; } -void MvObs::clearIterator() { +void MvObs::clearIterator() +{ if (_ecIter) { codes_bufr_keys_iterator_delete(_ecIter); - _ecIter = 0; + _ecIter = nullptr; } } -void MvObs::expand() { +void MvObs::expand() +{ if (!_unpacked && _ecH && _ecH->handle()) { if (useSkipExtraAttributes_) { codes_set_long(_ecH->handle(), "skipExtraKeyAttributes", 1); @@ -1070,17 +1112,20 @@ } } -long MvObs::currentDescriptor() { +long MvObs::currentDescriptor() +{ std::string skey = _currentKey + "->code"; - long descriptor = intValue(skey); + long descriptor = intValue(skey); return descriptor; } -const std::string& MvObs::currentKey() { +const std::string& MvObs::currentKey() +{ return _currentKey; } -const std::string MvObs::currentKeyWithoutRank() { +const std::string MvObs::currentKeyWithoutRank() +{ // No occurrence tag if (_currentKey[0] != '#') return _currentKey; @@ -1091,30 +1136,33 @@ } // It should only be used through the iterator -double MvObs::currentValue() { +double MvObs::currentValue() +{ double myValue = value(_currentKey); return myValue; } -double MvObs::nextValue() { +double MvObs::nextValue() +{ std::cout << "MvObs :: nextValue() -> not yet implemented" << std::endl; exit(0); } -MvObs MvObs::cloneSubset(long subset_number) { +MvObs MvObs::cloneSubset(long subset_number) +{ if (!_ecH || !_ecH->handle()) - return MvObs(nullptr); + return {nullptr}; // Check if the input subset number is vali if (subset_number > msgSubsetCount()) { std::cout << "ERROR MvObs::cloneSubset() -> invalid input subset number" << std::endl; - return MvObs(nullptr); + return {nullptr}; } if (_ecHSS) { codes_handle_delete(_ecHSS); - _ecHSS = 0; - _bufferSS = 0; + _ecHSS = nullptr; + _bufferSS = nullptr; } // Clone, unpack and extract that particular subset @@ -1129,15 +1177,15 @@ // Put result into buffer then form new handle from it size_t size = 0; codes_get_message(h2, &_bufferSS, &size); - _ecHSS = codes_handle_new_from_message_copy(0, _bufferSS, size); + _ecHSS = codes_handle_new_from_message_copy(nullptr, _bufferSS, size); assert(_ecHSS); codes_set_long(_ecHSS, "unpack", 1); // Delete the temporary codes handle codes_handle_delete(h2); - h2 = 0; + h2 = nullptr; auto p = std::make_shared(_ecHSS); - return MvObs(p, 1); + return {p, 1}; } //__________________________________________________________________elementValueType @@ -1146,47 +1194,53 @@ // ecCodes always returns the Type of the element: CODES_TYPE_LONG, // CODES_TYPE_DOUBLE or CODES_TYPE_STRING. It does not check if the // value is a missing value or not. -int MvObs::elementValueType(long aDescriptor) { +int MvObs::elementValueType(long aDescriptor) +{ // Build key and get type of the value std::string skey = this->key(aDescriptor); - int itype = elementValueType(skey); + int itype = elementValueType(skey); return itype; } -int MvObs::elementValueType(const std::string& skeyi) { +int MvObs::elementValueType(const std::string& skeyi) +{ // skeyi could be a numerical descriptor coded as a string std::string skey = keyC(skeyi); - int itype; + int itype = 0; codes_get_native_type(_ecH->handle(), skey.c_str(), &itype); return itype; } -int MvObs::elementValueType() { +int MvObs::elementValueType() +{ // return elementValueType(_currentKey); int itype = elementValueType(_currentKey); return itype; } //______________________________________________________ numberOfPressureLevels -int MvObs::numberOfPressureLevels() { +int MvObs::numberOfPressureLevels() +{ int npl = numberOfLevels(sPressureCoordinate); return npl; } //______________________________________________________ numberOfLevels -int MvObs::numberOfLevels(long levelDescriptor) { +int MvObs::numberOfLevels(long levelDescriptor) +{ // Build key and get value std::string skey = this->key(levelDescriptor); - int nelems = numberOfLevels(skey); + int nelems = numberOfLevels(skey); return nelems; } //______________________________________________________ numberOfLevels -int MvObs::numberOfLevels(const std::string& skey) { +int MvObs::numberOfLevels(const std::string& skey) +{ // Get number of elements - size_t nelems; + size_t nelems = 0; codes_get_size(_ecH->handle(), skey.c_str(), &nelems); // _currentLevelOccurrence = 0; @@ -1195,42 +1249,48 @@ } //__________________________________________________________ firstPressureLevel -double MvObs::firstPressureLevel() { +double MvObs::firstPressureLevel() +{ return pressureLevel(1); } //______________________________________________________________ pressureLevel // Parameter indexValue must start from 1...N -double MvObs::pressureLevel(int indexValue) { - _currentLevelKey = sPressureCoordinate; +double MvObs::pressureLevel(int indexValue) +{ + _currentLevelKey = sPressureCoordinate; _currentLevelOccurrence = indexValue; - double myLevelValue = level(_currentLevelKey, _currentLevelOccurrence); + double myLevelValue = level(_currentLevelKey, _currentLevelOccurrence); return myLevelValue == kBufrMissingValue ? kBufrMissingValue : myLevelValue / 100.; } //___________________________________________________________ nextPressureLevel -double MvObs::nextPressureLevel() { +double MvObs::nextPressureLevel() +{ double myLevelValue = pressureLevel(_currentLevelOccurrence + 1); return myLevelValue; } //__________________________________________________________ firstLevel -double MvObs::firstLevel(long levelDescriptor) { - std::string skey = key(levelDescriptor); +double MvObs::firstLevel(long levelDescriptor) +{ + std::string skey = key(levelDescriptor); double myLevelValue = firstLevel(skey); return myLevelValue; } -double MvObs::firstLevel(const std::string& skey) { +double MvObs::firstLevel(const std::string& skey) +{ _currentLevelOccurrence = 1; - _currentLevelKey = skey; + _currentLevelKey = skey; return level(_currentLevelKey, _currentLevelOccurrence); } //___________________________________________________________ nextLevel -double MvObs::nextLevel() { +double MvObs::nextLevel() +{ _currentLevelOccurrence++; double myLevelValue = level(_currentLevelKey, _currentLevelOccurrence); return myLevelValue; @@ -1241,7 +1301,8 @@ // to update parameters _currentLevelKey and _currentLevelOccurrence . // Parameter indexValue must start from 1...N // -double MvObs::level(const std::string& key, int indexValue) { +double MvObs::level(const std::string& key, int indexValue) +{ // Get value double myLevelValue = value(key, indexValue); @@ -1254,7 +1315,8 @@ // (e.g. temperature at a certain pressure level) //-------------------------------------------------------------------- double MvObs::valueBySpecifier(long aSpecifierDescriptor, double aSpecifierValue, long aDescriptor, - int /*firstIndexValue*/) { + int /*firstIndexValue*/) +{ // Get the correspondent keys std::string s1key = key(aSpecifierDescriptor); std::string s2key = key(aDescriptor); @@ -1263,7 +1325,8 @@ return value; } -double MvObs::valueBySpecifier(const std::string& coordinateKey, double coordinateValue, const std::string& paramKey) { +double MvObs::valueBySpecifier(const std::string& coordinateKey, double coordinateValue, const std::string& paramKey) +{ // This is a temporary solution while the above code is not available // Find a coordinate key whose value matches the input value this->setFirstDescriptor(); // initialise key iterator @@ -1326,7 +1389,7 @@ double MvObs::valueByPressureLevel(float aLevelValue, long aDescriptor) // in 'hPa' { std::string s2key = key(aDescriptor); - double value = valueByPressureLevel(aLevelValue, s2key); + double value = valueByPressureLevel(aLevelValue, s2key); return value; } @@ -1336,7 +1399,8 @@ } //________________________________________________________ valueByLevel -double MvObs::valueByLevelC(const std::string& aLevelDescriptor, float aLevelValue, const std::string& aDescriptor) { +double MvObs::valueByLevelC(const std::string& aLevelDescriptor, float aLevelValue, const std::string& aDescriptor) +{ // Check only positive integer values; otherwise, use "-.0123456789" std::string s1key; if (strspn(aLevelDescriptor.c_str(), "0123456789") == aLevelDescriptor.size()) @@ -1353,14 +1417,16 @@ return valueByLevel(s1key, aLevelValue, s2key); } -double MvObs::valueByLevel(long aLevelDescriptor, float aLevelValue, long aDescriptor) { +double MvObs::valueByLevel(long aLevelDescriptor, float aLevelValue, long aDescriptor) +{ std::string s1key = key(aLevelDescriptor); std::string s2key = key(aDescriptor); - double value = valueByLevel(s1key, aLevelValue, s2key); + double value = valueByLevel(s1key, aLevelValue, s2key); return value; } -double MvObs::valueByLevel(const std::string& s1key, float aLevelValue, const std::string& s2key) { +double MvObs::valueByLevel(const std::string& s1key, float aLevelValue, const std::string& s2key) +{ return valueBySpecifier(s1key, aLevelValue, s2key); } @@ -1368,7 +1434,8 @@ // Get the first value from aDescriptor whose value from aLevelDescriptor // is within level1 and level2 (both in Pa) double MvObs::valueByLevelRangeC(const std::string& aLevelDescriptor, float level1, float level2, - const std::string& aDescriptor) { + const std::string& aDescriptor) +{ // Check only positive integer values; otherwise, use "-.0123456789" std::string s1key; if (strspn(aLevelDescriptor.c_str(), "0123456789") == aLevelDescriptor.size()) @@ -1385,16 +1452,18 @@ return valueByLevelRange(s1key, level1, level2, s2key); } -double MvObs::valueByLevelRange(long aLevelDescriptor, float level1, float level2, long aDescriptor) { +double MvObs::valueByLevelRange(long aLevelDescriptor, float level1, float level2, long aDescriptor) +{ std::string s1key = key(aLevelDescriptor); std::string s2key = key(aDescriptor); - double value = valueByLevelRange(s1key, level1, level2, s2key); + double value = valueByLevelRange(s1key, level1, level2, s2key); return value; } -double MvObs::valueByLevelRange(const std::string& s1key, float level1, float level2, const std::string& s2key) { +double MvObs::valueByLevelRange(const std::string& s1key, float level1, float level2, const std::string& s2key) +{ // Get number of elements - size_t nelems, len; + size_t nelems = 0, len = 0; codes_get_size(_ecH->handle(), s1key.c_str(), &nelems); // Allocate memory for the values to be read @@ -1402,11 +1471,11 @@ // Get values double myValue = kBufrMissingValue; - len = nelems; - int ierr = codes_get_double_array(_ecH->handle(), s1key.c_str(), dlevels, &len); + len = nelems; + int ierr = codes_get_double_array(_ecH->handle(), s1key.c_str(), dlevels, &len); if (ierr || len != nelems) { delete[] dlevels; - dlevels = 0; + dlevels = nullptr; return kBufrMissingValue; } @@ -1433,7 +1502,7 @@ // Release memory delete[] dlevels; - dlevels = 0; + dlevels = nullptr; return myValue; } @@ -1441,26 +1510,30 @@ // e This function is not working //________________________________________________________________ valueByLayer -float MvObs::valueByLayerC(float /*firstLevel*/, float /*secondLevel*/, const std::string& /*aDescriptor*/) { +float MvObs::valueByLayerC(float /*firstLevel*/, float /*secondLevel*/, const std::string& /*aDescriptor*/) +{ std::cout << "MvObs::valueByLayerC -> not implemented yet" << std::endl; return kBufrMissingValue; //-- Not Found or Troubled Msg -- } -float MvObs::valueByLayer(float /*firstLevel*/, float /*secondLevel*/, long /*aDescriptor*/) { +float MvObs::valueByLayer(float /*firstLevel*/, float /*secondLevel*/, long /*aDescriptor*/) +{ std::cout << "MvObs :: valueByLayer -> not implemented yet" << std::endl; // exit(0); return kBufrMissingValue; //-- Not Found or Troubled Msg -- } //______________________________________________________________ printAllValues -bool MvObs::printAllValues() { +bool MvObs::printAllValues() +{ std::ostream* myStream = &std::cout; return writeAllValues(*myStream); } //_______________________________________________________________ writeAllValues -bool MvObs::writeAllValues(std::ostream& aStream) { +bool MvObs::writeAllValues(std::ostream& aStream) +{ // e remove confidence code temporarily // long myEndingIndex = _confidence->hasConfidences() ? _confidence->lastDataIndex()+1 : In_KTDEXL; long myEndingIndex = 100000; @@ -1469,11 +1542,12 @@ return true; } -bool MvObs::writeValues(std::ostream& aStream, int firstIndex, int lastIndex) { +bool MvObs::writeValues(std::ostream& aStream, int firstIndex, int lastIndex) +{ double dval; // Main loop - int index = firstIndex; + int index = firstIndex; bool dataToRead = setFirstDescriptor(); while (dataToRead && index <= lastIndex) { aStream.width(3); @@ -1517,7 +1591,8 @@ } //_______________________________________________________________ writeAllValues -bool MvObs::writeAllValues(const char* aPathName) { +bool MvObs::writeAllValues(const char* aPathName) +{ std::ofstream myStream(aPathName, std::ios::out); if (!myStream) { std::cerr << " >>> MvObs::writeAllValues(char*): error in creating file " << aPathName << std::endl; @@ -1531,18 +1606,21 @@ } //______________________________________________________________ WmoIdentNumber -long MvObs::WmoIdentNumber() { +long MvObs::WmoIdentNumber() +{ return WmoBlockNumber() * 1000 + WmoStationNumber(); } //______________________________________________________________ WmoBlockNumber -int MvObs::WmoBlockNumber() { +int MvObs::WmoBlockNumber() +{ long myValue = intValue("blockNumber"); return myValue == kBufrMissingIntValue ? 0 : (int)myValue; } //____________________________________________________________ WmoStationNumber -int MvObs::WmoStationNumber() { +int MvObs::WmoStationNumber() +{ long myValue = intValue("stationNumber"); return myValue == kBufrMissingIntValue ? 0 : (int)myValue; } @@ -1576,7 +1654,7 @@ int idVals = sizeof(idList) / sizeof(idList[0]); for (int i = 0; i < idVals; ++i) { std::string descr = idList[i]; - long myValue = intValue(descr); + long myValue = intValue(descr); if (myValue != kBufrMissingIntValue) { std::ostringstream oss; oss << std::setw(5) << std::setfill('0') << myValue; @@ -1584,7 +1662,7 @@ } } - return std::string("id???"); + return {"id???"}; } int MvObs::wigosSeries() @@ -1611,7 +1689,8 @@ } //____________________________________________________________________ location -MvLocation MvObs::location() { +MvLocation MvObs::location() +{ // F NEW CODE // ERROR ERROR ERROR ERROR // THERE IS A PROBLEM HERE. IN THE ORIGINAL CODE (ABOVE) IF "HIGH @@ -1641,27 +1720,31 @@ } //____________________________________________________________________ unit -std::string MvObs::unit(long aDescriptor) { - std::string skey = key(aDescriptor) + "->units"; +std::string MvObs::unit(long aDescriptor) +{ + std::string skey = key(aDescriptor) + "->units"; std::string sunit = stringValue(skey); return sunit; } //____________________________________________________________________ unit -std::string MvObs::unit() { - std::string skey = _currentKey + "->units"; +std::string MvObs::unit() +{ + std::string skey = _currentKey + "->units"; std::string sunit = stringValue(skey); return sunit; } //____________________________________________________________________ name -std::string MvObs::name(long aDescriptor) { +std::string MvObs::name(long aDescriptor) +{ std::string skey = key(aDescriptor); return skey; } //____________________________________________________________________ name -std::string MvObs::name() { +std::string MvObs::name() +{ return _currentKey; } @@ -1669,7 +1752,8 @@ //-- APIs for requesting info from the Header, BUFR Section 0,1,2,3 --// //___________________________________________________________________ init -void MvObs::init() { +void MvObs::init() +{ // Read initial variables masterTableVersion(); localTableVersion(); @@ -1680,7 +1764,8 @@ } //_________________________________________________________ messageTotalLen() -int MvObs::messageTotalLen() { +int MvObs::messageTotalLen() +{ if (_messageTotalLen == -1) _messageTotalLen = intValue("totalLength"); @@ -1688,7 +1773,8 @@ } //___________________________________________________________ editionNumber -int MvObs::editionNumber() { +int MvObs::editionNumber() +{ if (_editionNumber == -1) _editionNumber = intValue("edition"); @@ -1696,7 +1782,8 @@ } //_______________________________________________________________ msgSubsetCount -int MvObs::msgSubsetCount() { +int MvObs::msgSubsetCount() +{ if (_number_of_subsets == -1) _number_of_subsets = intValue("numberOfSubsets"); @@ -1705,7 +1792,8 @@ } //_________________________________________________________________ messageType -int MvObs::messageType() { +int MvObs::messageType() +{ if (_messageType == -1) _messageType = intValue("dataCategory"); @@ -1713,7 +1801,8 @@ } //______________________________________________________________ messageSubtype -int MvObs::messageSubtype() { +int MvObs::messageSubtype() +{ // FI 20170925: ecCodes does not have a flag to indicate a missing value // indicator as BUFRDC (cOctetMissingIndicator). // Update this code when ecCodes can handle a missing value indicator @@ -1726,7 +1815,8 @@ } //______________________________________________________________ messageSubtype -int MvObs::messageRdbtype() { +int MvObs::messageRdbtype() +{ if (_rdbType == -1) _rdbType = intValue("rdbType"); @@ -1734,7 +1824,8 @@ } //_________________________________________________ messageSubtypeInternational -int MvObs::messageSubtypeInternational() { +int MvObs::messageSubtypeInternational() +{ if (_subTypeInternational == -1) _subTypeInternational = intValue("internationalDataSubCategory"); @@ -1742,7 +1833,8 @@ } //_________________________________________________________ messageSubtypeLocal -int MvObs::messageSubtypeLocal() { +int MvObs::messageSubtypeLocal() +{ if (_subTypeLocal == -1) _subTypeLocal = intValue("dataSubCategory"); @@ -1750,14 +1842,16 @@ } //___________________________________________________________ originatingCentre -int MvObs::originatingCentre() { +int MvObs::originatingCentre() +{ if (_originatingCentre == -1) _originatingCentre = intValue("bufrHeaderCentre"); return (int)_originatingCentre; } -const std::string& MvObs::originatingCentreAsStr() { +const std::string& MvObs::originatingCentreAsStr() +{ if (_originatingCentreStr.empty()) _originatingCentreStr = stringValue("bufrHeaderCentre"); @@ -1766,7 +1860,8 @@ //___________________________________________________________ originatingSubCentre -int MvObs::originatingSubCentre() { +int MvObs::originatingSubCentre() +{ if (_originatingSubCentre == -1) _originatingSubCentre = intValue("bufrHeaderSubCentre"); @@ -1774,7 +1869,8 @@ } //___________________________________________________________ masterTable -int MvObs::masterTable() { +int MvObs::masterTable() +{ if (_masterTable == -1) _masterTable = intValue("masterTableNumber"); @@ -1782,7 +1878,8 @@ } //___________________________________________________________ masterTableVersion -int MvObs::masterTableVersion() { +int MvObs::masterTableVersion() +{ if (_masterTableVersion == -1) _masterTableVersion = intValue("masterTablesVersionNumber"); @@ -1790,14 +1887,16 @@ } //___________________________________________________________ localTableVersion -int MvObs::localTableVersion() { +int MvObs::localTableVersion() +{ if (_localTableVersion == -1) _localTableVersion = intValue("localTablesVersionNumber"); return (int)_localTableVersion; } -const std::string& MvObs::headerIdent() { +const std::string& MvObs::headerIdent() +{ if (headerIdent_ == "__UNDEF__") { if (hasSection2() && originatingCentre() == 98) headerIdent_ = stringValue("ident"); @@ -1808,16 +1907,15 @@ } - - //_________________________________________________________________ msgTime -TDynamicTime MvObs::msgTime() { +TDynamicTime MvObs::msgTime() +{ // Get values from the Header if (_lyear == -1) { - _lyear = intValue("typicalYear"); - _lmonth = intValue("typicalMonth"); - _lday = intValue("typicalDay"); - _lhour = intValue("typicalHour"); + _lyear = intValue("typicalYear"); + _lmonth = intValue("typicalMonth"); + _lday = intValue("typicalDay"); + _lhour = intValue("typicalHour"); _lminute = intValue("typicalMinute"); } @@ -1826,12 +1924,13 @@ } //---------------------------------------------------------------------------- -TDynamicTime MvObs::obsTime() { +TDynamicTime MvObs::obsTime() +{ // Get values - long lyear = intValue("year"); - long lmonth = intValue("month"); - long lday = intValue("day"); - long lhour = intValue("hour"); + long lyear = intValue("year"); + long lmonth = intValue("month"); + long lday = intValue("day"); + long lhour = intValue("hour"); long lminute = intValue("minute"); long lsecond = intValue("second"); @@ -1847,12 +1946,13 @@ } -TDynamicTime MvObs::obsTime(int occurrence) { +TDynamicTime MvObs::obsTime(int occurrence) +{ // Get values - long lyear = intValue("year", occurrence); - long lmonth = intValue("month", occurrence); - long lday = intValue("day", occurrence); - long lhour = intValue("hour", occurrence); + long lyear = intValue("year", occurrence); + long lmonth = intValue("month", occurrence); + long lday = intValue("day", occurrence); + long lhour = intValue("hour", occurrence); long lminute = intValue("minute", occurrence); long lsecond = intValue("second", occurrence); @@ -1870,7 +1970,8 @@ //---------------------------------------------------------------------------- //-- APIs for converting Descriptors to keys --// -std::string MvObs::keyC(const std::string& descriptor, const int index) { +std::string MvObs::keyC(const std::string& descriptor, const int index) +{ // Check only positive integer values; otherwise, use "-.0123456789" if (strspn(descriptor.c_str(), "0123456789") == descriptor.size()) return key(atol(descriptor.c_str()), index); @@ -1878,7 +1979,8 @@ return descriptor; } -std::string MvObs::key(const int descriptor, const int index) { +std::string MvObs::key(const int descriptor, const int index) +{ if (!_edition) _edition = MvBufrEdition::find(_masterTable, _masterTableVersion, _localTableVersion, _originatingCentre, _originatingSubCentre); @@ -1895,15 +1997,16 @@ return skey; } -bool MvObs::descriptorToKey(const long descriptor, std::string& key) { +bool MvObs::descriptorToKey(const long descriptor, std::string& key) +{ codes_handle* dkH = nullptr; - size_t size = 1; - char* strVal[1] = { - 0, + size_t size = 1; + char* strVal[1] = { + 0, }; bool ret = true; - dkH = codes_bufr_handle_new_from_samples(nullptr, "BUFR4"); + dkH = codes_bufr_handle_new_from_samples(nullptr, "BUFR4"); int err1 = codes_set_long(dkH, "masterTablesVersionNumber", _masterTableVersion); int err2 = codes_set_long(dkH, "localTablesVersionNumber", _localTableVersion); int err3 = codes_set_long(dkH, "unexpandedDescriptors", descriptor); @@ -1929,10 +2032,11 @@ return ret; } -bool MvObs::descriptor_to_key(const long descriptor, std::string& key) { +bool MvObs::descriptor_to_key(const long descriptor, std::string& key) +{ // Get BUFR key iterator codes_bufr_keys_iterator* kiter = nullptr; - kiter = codes_bufr_keys_iterator_new(_ecH->handle(), 0); + kiter = codes_bufr_keys_iterator_new(_ecH->handle(), 0); if (!kiter) { std::cout << "ERROR MvObs::descriptor_to_key(): Unable to create BUFR keys iterator" << std::endl; key = ""; @@ -1941,21 +2045,21 @@ bool flag = false; std::string name, name_code; - int err; + int err = 0; // Loop through the keys while (codes_bufr_keys_iterator_next(kiter)) { long codeVal = 0; - name = codes_bufr_keys_iterator_get_name(kiter); - name_code = name + "->code"; - err = codes_get_long(_ecH->handle(), name_code.c_str(), &codeVal); + name = codes_bufr_keys_iterator_get_name(kiter); + name_code = name + "->code"; + err = codes_get_long(_ecH->handle(), name_code.c_str(), &codeVal); if (!err && codeVal == descriptor) { // Remove the prefix #n# std::size_t ipos = -1; if (name[0] == '#') ipos = name.find('#', 1); - key = name.substr(ipos + 1); + key = name.substr(ipos + 1); flag = true; break; } @@ -1967,7 +2071,8 @@ return flag; } -std::string MvObs::key(const std::string& ikey, const int occurrence) { +std::string MvObs::key(const std::string& ikey, const int occurrence) +{ // Return original key if (occurrence < 1) return ikey; @@ -1980,7 +2085,8 @@ return key; } -std::string MvObs::keyWithoutOccurrenceTag(const std::string& key) { +std::string MvObs::keyWithoutOccurrenceTag(const std::string& key) +{ // Remove the prefix #n# if (!key.empty() && key[0] == '#') { std::size_t ipos = key.find('#', 1); @@ -1991,7 +2097,8 @@ return key; } -int MvObs::occurenceFromKey(const std::string& key) { +int MvObs::occurenceFromKey(const std::string& key) +{ if (!key.empty() && key[0] == '#') { std::size_t ipos = key.find('#', 1); if (ipos != std::string::npos) { @@ -2003,14 +2110,16 @@ } //______________________________________________________________ hasConfidences -bool MvObs::hasConfidences() { +bool MvObs::hasConfidences() +{ std::cout << "MvObs :: hasConfidences() -> not yet implemented" << std::endl; exit(0); return _confidence->hasConfidences(); } //__________________________________________________________________ confidence -int MvObs::confidence() { +int MvObs::confidence() +{ std::cout << "MvObs :: confidence() -> not yet implemented" << std::endl; exit(0); } @@ -2022,7 +2131,8 @@ // //========================================================== -void MvBufrSubsetData::addLongData(const std::string& key, long val) { +void MvBufrSubsetData::addLongData(const std::string& key, long val) +{ int idx = keyIndex(key); if (idx != -1) { std::vector vec; @@ -2031,7 +2141,8 @@ } } -void MvBufrSubsetData::addLongData(const std::string& key, long* val, size_t num) { +void MvBufrSubsetData::addLongData(const std::string& key, long* val, size_t num) +{ if (num > 0) { int idx = keyIndex(key); if (idx != -1) { @@ -2040,7 +2151,8 @@ } } -void MvBufrSubsetData::addDoubleData(const std::string& key, double val) { +void MvBufrSubsetData::addDoubleData(const std::string& key, double val) +{ int idx = keyIndex(key); if (idx != -1) { std::vector vec; @@ -2049,7 +2161,8 @@ } } -void MvBufrSubsetData::addDoubleData(const std::string& key, double* val, size_t num) { +void MvBufrSubsetData::addDoubleData(const std::string& key, double* val, size_t num) +{ if (num > 0) { int idx = keyIndex(key); if (idx != -1) { @@ -2058,7 +2171,8 @@ } } -void MvBufrSubsetData::addStringData(const std::string& key, const std::string& val) { +void MvBufrSubsetData::addStringData(const std::string& key, const std::string& val) +{ int idx = keyIndex(key); if (idx != -1) { std::vector vec; @@ -2067,27 +2181,29 @@ } } -void MvBufrSubsetData::addStringData(const std::string& key, char** val, size_t num) { +void MvBufrSubsetData::addStringData(const std::string& key, char** val, size_t num) +{ if (num > 0) { int idx = keyIndex(key); if (idx != -1) { std::vector vec; for (size_t i = 0; i < num; i++) { - vec.push_back(std::string(val[i])); + vec.emplace_back(val[i]); } stringData_[idx] = vec; } } } -long MvBufrSubsetData::longData(const std::string& key, int subset, bool& hasData) const { +long MvBufrSubsetData::longData(const std::string& key, int subset, bool& hasData) const +{ if (initialised_) { int idx = keyIndex(key); if (idx != -1) { auto it = longData_.find(idx); if (it != longData_.end() && subset >= 0 && subset < static_cast(it->second.size())) { hasData = true; - int n = (it->second.size() == 1) ? 0 : subset; + int n = (it->second.size() == 1) ? 0 : subset; return it->second[n]; } } @@ -2096,14 +2212,15 @@ return 0; } -double MvBufrSubsetData::doubleData(const std::string& key, int subset, bool& hasData) const { +double MvBufrSubsetData::doubleData(const std::string& key, int subset, bool& hasData) const +{ if (initialised_) { int idx = keyIndex(key); if (idx != -1) { auto it = doubleData_.find(idx); if (it != doubleData_.end() && subset >= 0 && subset < static_cast(it->second.size())) { hasData = true; - int n = (it->second.size() == 1) ? 0 : subset; + int n = (it->second.size() == 1) ? 0 : subset; return it->second[n]; } } @@ -2112,14 +2229,15 @@ return 0.; } -const std::string& MvBufrSubsetData::stringData(const std::string& key, int subset, bool& hasData) const { +const std::string& MvBufrSubsetData::stringData(const std::string& key, int subset, bool& hasData) const +{ if (initialised_) { int idx = keyIndex(key); if (idx != -1) { auto it = stringData_.find(idx); if (it != stringData_.end() && subset >= 0 && subset < static_cast(it->second.size())) { hasData = true; - int n = (it->second.size() == 1) ? 0 : subset; + int n = (it->second.size() == 1) ? 0 : subset; return it->second[n]; } } @@ -2129,7 +2247,8 @@ return emptyStr; } -const std::string& MvBufrSubsetData::currentKey() const { +const std::string& MvBufrSubsetData::currentKey() const +{ if (current_ >= 0) { return keys_[current_]; } @@ -2137,7 +2256,8 @@ return emptyStr; } -int MvBufrSubsetData::keyIndex(const std::string& key) const { +int MvBufrSubsetData::keyIndex(const std::string& key) const +{ if (current_ >= 0 && keys_[current_] == key) { return current_; } @@ -2147,14 +2267,16 @@ void MvBufrSubsetData::initKey(const std::string& key, const std::string& keyWithoutRank, - const std::set& neededKeys) { + const std::set& neededKeys) +{ if (neededKeys.find(keyWithoutRank) != neededKeys.end() || neededKeys.find(key) != neededKeys.end()) { keys_.push_back(key); keyIndex_[key] = static_cast(keys_.size()) - 1; } } -void MvBufrSubsetData::finishInit() { +void MvBufrSubsetData::finishInit() +{ initialised_ = true; } @@ -2166,7 +2288,8 @@ //-- //-- ( NOTE: U N F I N I S H E D ! ! ! ) //____________________________________________________________________ OperaRadarImage -unsigned char* MvObs::OperaRadarImage() { +unsigned char* MvObs::OperaRadarImage() +{ std::cout << " Method MvObs::OperaRadarImage() not implemented yet" << std::endl; exit(0); auto* str = (unsigned char*)' '; @@ -2178,7 +2301,8 @@ //-- //-- ( NOTE: U N F I N I S H E D ! ! ! ) //____________________________________________________________________ OperaRadarMetadata -bool MvObs::OperaRadarMetadata(/* arguments? */) { +bool MvObs::OperaRadarMetadata(/* arguments? */) +{ return false; } #endif // METVIEW @@ -2197,7 +2321,8 @@ // * Data Present group is used to define index into Confidence group //____________________________________________________________ MvBufrConfidence -MvBufrConfidence ::MvBufrConfidence(int /*aSubsetNr*/) { +MvBufrConfidence ::MvBufrConfidence(int /*aSubsetNr*/) +{ std::cout << " Method MvBufrConfidence::MvBufrConfidence() not implemented yet" << std::endl; // e exit(0); } @@ -2205,41 +2330,48 @@ MvBufrConfidence ::~MvBufrConfidence() = default; //______________________________________________________________ hasConfidences -bool MvBufrConfidence ::hasConfidences() { +bool MvBufrConfidence ::hasConfidences() +{ std::cout << " Method MvBufrConfidence::hasConfidences() not implemented yet" << std::endl; exit(0); } //_______________________________________________________________ confidence -int MvBufrConfidence ::confidence(long /*aDescr*/) { +int MvBufrConfidence ::confidence(long /*aDescr*/) +{ std::cout << " Method MvBufrConfidence::confidence() not implemented yet" << std::endl; exit(0); } //___________________________________________________________ confidenceByIndex -int MvBufrConfidence ::confidenceByIndex(int /*aDataInd*/) { +int MvBufrConfidence ::confidenceByIndex(int /*aDataInd*/) +{ std::cout << " Method MvBufrConfidence::confidenceByIndex() not implemented yet" << std::endl; exit(0); } //_______________________________________________________________ lastDataIndex -int MvBufrConfidence ::lastDataIndex() { +int MvBufrConfidence ::lastDataIndex() +{ std::cout << " Method MvBufrConfidence::lastDataIndex() not implemented yet" << std::endl; exit(0); } //__________________________________________________________ startOfDataPresent // Q&D hack !!! -int MvBufrConfidence ::startOfDataPresent() { +int MvBufrConfidence ::startOfDataPresent() +{ std::cout << " Method MvBufrConfidence::startOfDataPresent() not implemented yet" << std::endl; exit(0); } //_______________________________________________________________ startOfConfidences // Q&D hack !!! -int MvBufrConfidence ::startOfConfidences() { +int MvBufrConfidence ::startOfConfidences() +{ std::cout << " Method MvBufrConfidence::startOfConfidences() not implemented yet" << std::endl; exit(0); } //_______________________________________________________________ delta -int MvBufrConfidence ::delta(int /*anInd*/) { +int MvBufrConfidence ::delta(int /*anInd*/) +{ std::cout << " Method MvBufrConfidence::delta() not implemented yet" << std::endl; exit(0); } @@ -2248,7 +2380,8 @@ //======================================================================== MvBufrParam //________________________________________________________________________ -MvBufrParam ::MvBufrParam(const char* aParamName) { +MvBufrParam ::MvBufrParam(const char* aParamName) +{ std::cout << " Method MvBufrParam::MvBufrParam() not implemented yet" << std::endl; exit(0); @@ -2265,7 +2398,8 @@ } //_____________________________________________________________ PrintAllKnownParameters -void MvBufrParam ::PrintAllKnownParameters() const { +void MvBufrParam ::PrintAllKnownParameters() const +{ std::cout << " Method MvBufrParam::PrintAllKnownParameters() not implemented yet" << std::endl; exit(0); diff -Nru metview-5.17.4/metview/src/libMetview/MvObsSet.cc metview-5.19.2/metview/src/libMetview/MvObsSet.cc --- metview-5.17.4/metview/src/libMetview/MvObsSet.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvObsSet.cc 2023-07-15 08:28:47.000000000 +0000 @@ -8,7 +8,7 @@ #include "MvObsSet.h" -#include +#include #include #include #include @@ -24,13 +24,14 @@ #ifdef MAGICS #include "MagException.h" #include "MagicsGlobal.h" -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif - int MAX_MESSAGE_LENGTH = 32000; // e maybe delete in the future static std::string WRITE("w"); // I/O mode @@ -45,7 +46,8 @@ _minTime(2247, 6, 20), _maxTime(1799, 12, 31), useSkipExtraAttributes_(true), - cacheCompressedData_(true) { + cacheCompressedData_(true) +{ _IO_mode = "r"; _init(aName); } @@ -57,7 +59,8 @@ _minTime(2247, 6, 20), _maxTime(1799, 12, 31), useSkipExtraAttributes_(true), - cacheCompressedData_(true) { + cacheCompressedData_(true) +{ _IO_mode = aMode; _init(aName); } @@ -65,8 +68,9 @@ //____________________________________________________________________ #ifdef METVIEW MvObsSet::MvObsSet(MvRequest& aRequest, const char* aMode) : - _unpacked(false), _msgCount(0), _minTime(2247, 6, 20), _maxTime(1799, 12, 31) { - _IO_mode = aMode; + _unpacked(false), _msgCount(0), _minTime(2247, 6, 20), _maxTime(1799, 12, 31) +{ + _IO_mode = aMode; const char* aName = nullptr; aRequest.getValue(aName, "PATH"); _init(aName); @@ -74,7 +78,8 @@ #endif //____________________________________________________________________ -MvObsSet::~MvObsSet() { +MvObsSet::~MvObsSet() +{ close(); #ifdef METVIEW_PREPBUFR @@ -86,16 +91,17 @@ } //____________________________________________________________________ -void MvObsSet::_init(const char* aName) { - _ecFile = nullptr; - _obsCount = -1; - _msgNumber = -1; - _minMaxDone = false; +void MvObsSet::_init(const char* aName) +{ + _ecFile = nullptr; + _obsCount = -1; + _msgNumber = -1; + _minMaxDone = false; _IO_buffer_OK = false; #ifdef METVIEW_PREPBUFR _isPrepBufrFile = false; - _prepBufr = 0; + _prepBufr = 0; #endif // Open input bufr file @@ -117,14 +123,16 @@ } //____________________________________________________________________ setSubsetMax -void MvObsSet::setSubsetMax(int /*subsetMax*/) { +void MvObsSet::setSubsetMax(int /*subsetMax*/) +{ // I think ecCodes does not need this function (_maxNrSubsets). // If this is the case delete it later. } //____________________________________________________________________ Open -bool MvObsSet::Open(const char* aFileName) { - _msgCount = 0; +bool MvObsSet::Open(const char* aFileName) +{ + _msgCount = 0; _msgNumber = 0; // Open bufr file @@ -143,11 +151,12 @@ } //____________________________________________________________________ close -bool MvObsSet::close() { +bool MvObsSet::close() +{ long myReturnValue = -1; if (_ecFile) { myReturnValue = fclose(_ecFile); - _ecFile = nullptr; + _ecFile = nullptr; // Clean eccodes handler if (_ecH && _ecH->handle()) { @@ -162,7 +171,8 @@ } //____________________________________________________________________ rewind -void MvObsSet::rewind() { +void MvObsSet::rewind() +{ _msgNumber = 0; if (_ecFile) { // Clean previous handler @@ -178,12 +188,13 @@ } // msgCnt indexed from one!!!! -MvObs MvObsSet::gotoMessage(long offset, int msgCnt) { +MvObs MvObsSet::gotoMessage(long offset, int msgCnt) +{ if (!_ecFile) - return MvObs(); // nothing if file not ok + return {}; // nothing if file not ok if (_IO_mode == WRITE) - return MvObs(); // no next when writing ! + return {}; // no next when writing ! // Clean previous handler if (_ecH && _ecH->handle()) { @@ -196,15 +207,15 @@ fseek(_ecFile, offset, SEEK_SET); - int err = 0; + int err = 0; codes_handle* ch = codes_handle_new_from_file(nullptr, _ecFile, PRODUCT_BUFR, &err); - _ecH = std::make_shared(ch); + _ecH = std::make_shared(ch); if (ch || err != CODES_SUCCESS) { if (!ch) { std::cout << "Failed reading next BUFR msg: unable to create handle for message = " << _msgNumber << std::endl; _IO_buffer_OK = false; - return MvObs(); + return {}; } // Expand all the descriptors i.e. unpack the data values @@ -216,19 +227,20 @@ } // subset number = 1 - return MvObs(_ecH, 1, _unpacked, cacheCompressedData_); + return {_ecH, 1, _unpacked, cacheCompressedData_}; } //__________________________________________________________________ next // Reads next BUFR message and returns an MvObs constructed with it. // An MvObs without a message is returned at EOF. //------------------------------------------------ -MvObs MvObsSet::next(bool unpack) { +MvObs MvObsSet::next(bool unpack) +{ if (!_ecFile) - return MvObs(); // nothing if file not ok + return {}; // nothing if file not ok if (_IO_mode == WRITE) - return MvObs(); // no next when writing ! + return {}; // no next when writing ! _msgNumber++; @@ -240,15 +252,15 @@ } // Get next message - int err = 0; + int err = 0; codes_handle* ch = codes_handle_new_from_file(nullptr, _ecFile, PRODUCT_BUFR, &err); - _ecH = std::make_shared(ch); + _ecH = std::make_shared(ch); if (ch || err != CODES_SUCCESS) { if (!ch) { std::cout << "Failed reading next BUFR msg: unable to create handle for message = " << _msgNumber << std::endl; _IO_buffer_OK = false; - return MvObs(); + return {}; } // Expand all the descriptors i.e. unpack the data values @@ -259,16 +271,17 @@ _IO_buffer_OK = true; // subset number = 1 - return MvObs(_ecH, 1, _unpacked, cacheCompressedData_); + return {_ecH, 1, _unpacked, cacheCompressedData_}; } _IO_buffer_OK = false; - return MvObs(); + return {}; } //____________________________________________________________________ add -void MvObsSet::add(MvObs& anObs) { +void MvObsSet::add(MvObs& anObs) +{ if (_IO_mode != WRITE) return; // no add when reading ! @@ -277,7 +290,8 @@ } //____________________________________________________________________ write -bool MvObsSet::write(const void* aMsg, const size_t aMsgLen) { +bool MvObsSet::write(const void* aMsg, const size_t aMsgLen) +{ if (_IO_mode != WRITE) return false; @@ -291,7 +305,8 @@ return true; } -bool MvObsSet::write(MvObs& anObs) { +bool MvObsSet::write(MvObs& anObs) +{ // Clone the input handle codes_handle* clone_handle = codes_handle_clone(anObs.getHandle()); if (clone_handle == nullptr) { @@ -301,7 +316,7 @@ // Get the coded message in a buffer const void* buffer = nullptr; - size_t size = 0; + size_t size = 0; if (codes_get_message(clone_handle, &buffer, &size)) { std::cout << "ERROR - MvObsSet::write(MvObs&) -> could not create a buffer message" << std::endl; @@ -319,7 +334,8 @@ return err; } -bool MvObsSet::writeCompressed(MvObs* obs) { +bool MvObsSet::writeCompressed(MvObs* obs) +{ assert(obs); if (!obs->compressData()) @@ -339,7 +355,7 @@ // Get the coded message in a buffer const void* buffer = nullptr; - size_t size = 0; + size_t size = 0; if (codes_get_message(cloneH, &buffer, &size)) { std::cout << "ERROR - MvObsSet::write(MvObs&) -> could not create a buffer message" << std::endl; @@ -357,7 +373,8 @@ return err; } -bool MvObsSet::writeCompressed(MvObs* obs, const std::vector& subsetVec) { +bool MvObsSet::writeCompressed(MvObs* obs, const std::vector& subsetVec) +{ assert(obs); if (!obs->compressData()) @@ -373,7 +390,7 @@ return false; } - size_t arrSize = subsetVec.size(); + size_t arrSize = subsetVec.size(); long* subsetArr = new long[arrSize]; for (size_t i = 0; i < subsetVec.size(); i++) subsetArr[i] = subsetVec[i]; @@ -385,7 +402,7 @@ // Get the coded message in a buffer const void* buffer = nullptr; - size_t size = 0; + size_t size = 0; if (codes_get_message(cloneH, &buffer, &size)) { std::cout << "ERROR - MvObsSet::write(MvObs&) -> could not create a buffer message" << std::endl; @@ -413,7 +430,8 @@ // i.e. the nr of BUFR msgs found <= nr of observation msgs // i.e. messageCount() <= obsCount() //------------------------------------------------------------------ -int MvObsSet::messageCount() { +int MvObsSet::messageCount() +{ #if 0 // Fec // old code removed. Counts message using eccodes only. if( _msgCount < 1 ) @@ -438,7 +456,8 @@ } //____________________________________________________________________ obsCount -int MvObsSet::obsCount() { +int MvObsSet::obsCount() +{ // The number of total messages has been already computed if (_obsCount >= 1) return _obsCount; @@ -448,10 +467,10 @@ rewind(); // Compute total number of messages, including sub-messages - long numberOfSubsets; - int err = 0; + long numberOfSubsets = 0; + int err = 0; codes_handle* ecH = nullptr; - _obsCount = 0; + _obsCount = 0; while ((ecH = codes_handle_new_from_file(nullptr, _ecFile, PRODUCT_BUFR, &err)) != nullptr || err != CODES_SUCCESS) { if (ecH == nullptr) { @@ -475,7 +494,8 @@ } //_________________________________________________________ searchMinMaxTime -void MvObsSet::searchMinMaxTime() { +void MvObsSet::searchMinMaxTime() +{ std::cout << "MvObsSet::searchMinMaxTime() -> not implemented yet" << std::endl; exit(0); @@ -487,7 +507,8 @@ } //_________________________________________________________ expand -void MvObsSet::expand() { +void MvObsSet::expand() +{ if (_unpacked) return; // nothing to be done, it is already expanded @@ -503,14 +524,15 @@ #ifdef METVIEW_PREPBUFR //____________________________________________________________________ prepBufrFile -bool MvObsSet::prepBufrFile() { +bool MvObsSet::prepBufrFile() +{ if (_isPrepBufrFile) { std::cout << "in MvObsSet::prepBufrFile()" << std::endl; std::cout << "BUFR file contains BUFR tables, processing..." << std::endl; //-- Create new PrepBUFR table files etc... _prepBufr = new MvPrepBufrPrep(*this); - bool ok = _prepBufr->prepareAll(); + bool ok = _prepBufr->prepareAll(); if (!ok) { std::cerr << "Errors: unable to process the PrepBUFR file" << std::endl; return false; @@ -522,7 +544,8 @@ //____________________________________________________________________ minDate #ifdef METVIEW -MvDate MvObsSet ::minDate() { +MvDate MvObsSet ::minDate() +{ searchMinMaxTime(); double timfloat = 10000.0L * (double)_minTime.GetYear() + 100.0L * (double)_minTime.GetMonth() + (double)_minTime.GetDay() + (double)_minTime.GetHour() / 24.0L + @@ -530,7 +553,8 @@ return MvDate(timfloat); } //____________________________________________________________________ maxDate -MvDate MvObsSet ::maxDate() { +MvDate MvObsSet ::maxDate() +{ searchMinMaxTime(); double timfloat = 10000.0L * (double)_maxTime.GetYear() + 100.0L * (double)_maxTime.GetMonth() + (double)_maxTime.GetDay() + (double)_maxTime.GetHour() / 24.0L + @@ -544,21 +568,15 @@ //___________________________________________________________________ MvObsSetIterator::MvObsSetIterator(MvObsSet& s) : - _NoFiltersSet(true), - useObsTime_(false), - _SelectValueCount(0), - _MsgTypeCount(0), - _MsgSubtypeCount(0), - _TimeFilterState(kTFS_notSet), - _SelectState(SF_notSet), - ObsSet(&s), - observer_(nullptr), - filterProgressStep_(20) {} + ObsSet(&s) +{ +} //___________________________________________________________________ MvObsSetIterator::~MvObsSetIterator() = default; -bool MvObsSetIterator::checkOptionSize(std::size_t num, const std::string& functionName) { +bool MvObsSetIterator::checkOptionSize(std::size_t num, const std::string& functionName) +{ if (num >= MAX_FILTER_LIST_ARRAY_SIZE) { std::cerr << ">>> MvObsIterator::" + functionName + " array overflow!!!" << std::endl; return false; @@ -566,11 +584,13 @@ return true; } -int MvObsSetIterator::currentMessageNumber() const { +int MvObsSetIterator::currentMessageNumber() const +{ return (ObsSet ? (static_cast(ObsSet->_msgNumber)) : -1); } -MvObs MvObsSetIterator::operator()(ENextReturn returnType) { +MvObs MvObsSetIterator::operator()(ENextReturn returnType) +{ if (!current || (returnType == NR_returnMsg) || !current.Advance()) { if (observer_) { observer_->notifyObsIteratorProgress(currentMessageNumber()); @@ -591,7 +611,8 @@ return current; } -void MvObsSetIterator::setFilterProgressStep(int filterProgressStep) { +void MvObsSetIterator::setFilterProgressStep(int filterProgressStep) +{ filterProgressStep_ = filterProgressStep; assert(filterProgressStep_ >= 0); if (filterProgressStep_ == 0) @@ -599,15 +620,18 @@ } -MvObs MvObsSetIterator::gotoMessage(long offset, int msgCnt) { +MvObs MvObsSetIterator::gotoMessage(long offset, int msgCnt) +{ return ObsSet->gotoMessage(offset, msgCnt); } -MvObs MvObsSetIterator::nextMessage() { +MvObs MvObsSetIterator::nextMessage() +{ return ObsSet->next(false); } -void MvObsSetIterator::next() { +void MvObsSetIterator::next() +{ current = ObsSet->next(false); #ifdef METVIEW @@ -617,23 +641,26 @@ #endif } -void MvObsSetIterator::setTime(const TDynamicTime& anObsTime) { +void MvObsSetIterator::setTime(const TDynamicTime& anObsTime) +{ setTimeRange(anObsTime, anObsTime); } -void MvObsSetIterator::setTimeRange(const TDynamicTime& anObsTime, short deltaInMinutes) { +void MvObsSetIterator::setTimeRange(const TDynamicTime& anObsTime, short deltaInMinutes) +{ fBeginTime = fEndTime = anObsTime; fBeginTime.ChangeByMinutes(-deltaInMinutes); fEndTime.ChangeByMinutes(deltaInMinutes); _TimeFilterState = kTFS_bothSet; - _NoFiltersSet = false; + _NoFiltersSet = false; } -void MvObsSetIterator::setTimeRange(const TDynamicTime& aBeginTime, const TDynamicTime& anEndTime) { - fBeginTime = aBeginTime; - fEndTime = anEndTime; +void MvObsSetIterator::setTimeRange(const TDynamicTime& aBeginTime, const TDynamicTime& anEndTime) +{ + fBeginTime = aBeginTime; + fEndTime = anEndTime; _TimeFilterState = kTFS_bothSet; - _NoFiltersSet = false; + _NoFiltersSet = false; } //_____________________________________________________________ setTimeRangeWithoutDate @@ -642,10 +669,11 @@ // parameters: in format HHMM, i.e. 1200 == 12.00, 15 == 0.15, i.e. 100*hour+min!!! // values are normalized into range [0000..2400) //_________________________________________ -void MvObsSetIterator::setTimeRangeWithoutDate(int aBegin, int anEnd) { +void MvObsSetIterator::setTimeRangeWithoutDate(int aBegin, int anEnd) +{ TDynamicTime aTime; // date part is not used, so let's use today.. int myBegin = aBegin; - int myEnd = anEnd; + int myEnd = anEnd; while (myBegin < 0) myBegin += 2400; @@ -658,13 +686,14 @@ fEndTime = aTime; _TimeFilterState = kTFS_clockSet; - _NoFiltersSet = false; + _NoFiltersSet = false; } -void MvObsSetIterator::setTimeRangeInSecWithoutDate(int aBegin, int anEnd) { +void MvObsSetIterator::setTimeRangeInSecWithoutDate(int aBegin, int anEnd) +{ TDynamicTime aTime; // date part is not used, so let's use today.. int myBegin = aBegin; - int myEnd = anEnd; + int myEnd = anEnd; while (myBegin < 0) myBegin += 86400; @@ -683,12 +712,13 @@ fEndTime = aTime; _TimeFilterState = kTFS_clockSet; - _NoFiltersSet = false; + _NoFiltersSet = false; } //____________________________________________________________________ -void MvObsSetIterator::setWmoBlock(int blockNumber) { +void MvObsSetIterator::setWmoBlock(int blockNumber) +{ if (!checkOptionSize(wmoBlock_.size(), "setWmoBlock")) return; @@ -696,7 +726,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setWmoStation(long wmoStation) { +void MvObsSetIterator::setWmoStation(long wmoStation) +{ if (!checkOptionSize(wmoStation_.size(), "setWmoStation")) return; @@ -704,7 +735,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::select(const std::string& aDescriptor, double aValue) { +void MvObsSetIterator::select(const std::string& aDescriptor, double aValue) +{ if (_SelectValueCount >= MAX_FILTER_LIST_ARRAY_SIZE) { std::cerr << ">>> MvObsIterator::select: array overflow!!!" << std::endl; return; @@ -714,61 +746,68 @@ std::cerr << ">>> MvObsIterator::select: changing the descriptor while building the list!!!" << std::endl; } - _SelectDescriptor = aDescriptor; + _SelectDescriptor = aDescriptor; _SelectValue[_SelectValueCount++] = aValue; - _SelectState = SF_listSet; - _NoFiltersSet = false; + _SelectState = SF_listSet; + _NoFiltersSet = false; } -void MvObsSetIterator::selectRange(const std::string& aDescriptor, double firstValue, double secondValue) { +void MvObsSetIterator::selectRange(const std::string& aDescriptor, double firstValue, double secondValue) +{ _SelectDescriptor = aDescriptor; - _SelectValue[0] = firstValue < secondValue ? firstValue : secondValue; - _SelectValue[1] = secondValue > firstValue ? secondValue : firstValue; + _SelectValue[0] = firstValue < secondValue ? firstValue : secondValue; + _SelectValue[1] = secondValue > firstValue ? secondValue : firstValue; _SelectValueCount = 2; - _SelectState = SF_rangeSet; - _NoFiltersSet = false; + _SelectState = SF_rangeSet; + _NoFiltersSet = false; } -void MvObsSetIterator::excludeRange(const std::string& aDescriptor, double firstValue, double secondValue) { +void MvObsSetIterator::excludeRange(const std::string& aDescriptor, double firstValue, double secondValue) +{ _SelectDescriptor = aDescriptor; - _SelectValue[0] = firstValue < secondValue ? firstValue : secondValue; - _SelectValue[1] = secondValue > firstValue ? secondValue : firstValue; + _SelectValue[0] = firstValue < secondValue ? firstValue : secondValue; + _SelectValue[1] = secondValue > firstValue ? secondValue : firstValue; _SelectValueCount = 2; - _SelectState = SF_excludeRangeSet; - _NoFiltersSet = false; + _SelectState = SF_excludeRangeSet; + _NoFiltersSet = false; } void MvObsSetIterator::setXSectionLine(const MvLocation& aStartPoint, const MvLocation& anEndPoint, - float aDeltaInMeters) { + float aDeltaInMeters) +{ fXSectionLine.setLine(aStartPoint, anEndPoint); fXSectionLine.setMaxDelta(aDeltaInMeters); _NoFiltersSet = false; } -void MvObsSetIterator::setArea(const MvLocation& aCorner1, const MvLocation& aCorner2) { +void MvObsSetIterator::setArea(const MvLocation& aCorner1, const MvLocation& aCorner2) +{ fArea.set(aCorner1, aCorner2); _NoFiltersSet = false; } -void MvObsSetIterator::setMessageType(int aMsgType) { +void MvObsSetIterator::setMessageType(int aMsgType) +{ if (_MsgTypeCount >= MAX_FILTER_LIST_ARRAY_SIZE) { std::cerr << ">>> MvObsIterator::setMessageType: array overflow!!!" << std::endl; return; } _MsgType[_MsgTypeCount++] = aMsgType; - _NoFiltersSet = false; + _NoFiltersSet = false; } -void MvObsSetIterator::setMessageSubtype(int aMsgSubtype) { +void MvObsSetIterator::setMessageSubtype(int aMsgSubtype) +{ if (_MsgSubtypeCount >= MAX_FILTER_LIST_ARRAY_SIZE) { std::cerr << ">>> MvObsIterator::setMessageSubtype: array overflow!!!" << std::endl; return; } _MsgSubtype[_MsgSubtypeCount++] = aMsgSubtype; - _NoFiltersSet = false; + _NoFiltersSet = false; } -void MvObsSetIterator::setMessageNumber(int num) { +void MvObsSetIterator::setMessageNumber(int num) +{ if (!checkOptionSize(messageNumber_.size(), "setMessageNumber")) return; @@ -776,7 +815,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setEditionNumber(int edition) { +void MvObsSetIterator::setEditionNumber(int edition) +{ if (!checkOptionSize(editionNumber_.size(), "setEditionNumber")) return; @@ -784,7 +824,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setOriginatingCentre(int centre) { +void MvObsSetIterator::setOriginatingCentre(int centre) +{ if (!checkOptionSize(originatingCentre_.size(), "setOriginatingCentre")) return; @@ -792,7 +833,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setOriginatingCentreAsStr(const std::string& centre) { +void MvObsSetIterator::setOriginatingCentreAsStr(const std::string& centre) +{ if (!checkOptionSize(originatingCentreStr_.size(), "setOriginatingCentreAsStr")) return; @@ -800,7 +842,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setOriginatingSubCentre(int subCentre) { +void MvObsSetIterator::setOriginatingSubCentre(int subCentre) +{ if (!checkOptionSize(originatingSubCentre_.size(), "setOriginatingSubCentre")) return; @@ -808,7 +851,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setMasterTableVersion(int masterTable) { +void MvObsSetIterator::setMasterTableVersion(int masterTable) +{ if (!checkOptionSize(masterTableVersion_.size(), "setMasterTableVersion")) return; @@ -816,7 +860,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setLocalTableVersion(int localTable) { +void MvObsSetIterator::setLocalTableVersion(int localTable) +{ if (!checkOptionSize(localTableVersion_.size(), "setLocalTableVersion")) return; @@ -824,7 +869,8 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setHeaderIdent(const std::string& headerIdent) { +void MvObsSetIterator::setHeaderIdent(const std::string& headerIdent) +{ if (!checkOptionSize(headerIdent_.size(), "setHeaderIdent")) return; @@ -832,14 +878,16 @@ _NoFiltersSet = false; } -void MvObsSetIterator::setIdentKey(const std::string& identKey) { +void MvObsSetIterator::setIdentKey(const std::string& identKey) +{ if (!checkOptionSize(identKey_.size(), "setIdentKey")) return; identKey_.push_back(simplified(identKey)); _NoFiltersSet = false; } -void MvObsSetIterator::setIdentValue(const std::string& identVal) { +void MvObsSetIterator::setIdentValue(const std::string& identVal) +{ if (!checkOptionSize(identValue_.size(), "setIdentValue")) return; @@ -870,7 +918,8 @@ } //____________________________________________________________________ -float MvObsSetIterator::distanceFromXSectionLine(const MvLocation& aPoint) { +float MvObsSetIterator::distanceFromXSectionLine(const MvLocation& aPoint) +{ if (fXSectionLine.startPoint().latitude() == MISSING_LOC_VALUE) return MISSING_LOC_VALUE; @@ -878,13 +927,14 @@ } //____________________________________________________________________ -bool MvObsSetIterator::TimeOk(MvObs* anObs) const { +bool MvObsSetIterator::TimeOk(MvObs* anObs) const +{ switch (_TimeFilterState) { case kTFS_notSet: break; case kTFS_clockSet: { - long obsTime; + long obsTime = 0; if (useObsTime_) { // We need time from the data section so we need to expand the message anObs->expand(); @@ -928,7 +978,8 @@ } //____________________________________________________________________ -bool MvObsSetIterator::WmoBlockOk(MvObs* anObs) const { +bool MvObsSetIterator::WmoBlockOk(MvObs* anObs) const +{ if (!wmoBlock_.empty()) { // we need to expand the message anObs->expand(); @@ -941,7 +992,8 @@ return true; } -bool MvObsSetIterator::WmoStationOk(MvObs* anObs) const { +bool MvObsSetIterator::WmoStationOk(MvObs* anObs) const +{ if (!wmoStation_.empty()) { // we need to expand the message anObs->expand(); @@ -955,7 +1007,8 @@ } //____________________________________________________________________ -bool MvObsSetIterator::WithinXSectionLine(MvObs* anObs) const { +bool MvObsSetIterator::WithinXSectionLine(MvObs* anObs) const +{ if (fXSectionLine.maxDelta() < 0) // not set ? return true; @@ -969,7 +1022,8 @@ } //____________________________________________________________________ -bool MvObsSetIterator::InsideArea(MvObs* anObs) const { +bool MvObsSetIterator::InsideArea(MvObs* anObs) const +{ if (fArea.lowerLeft().latitude() == MISSING_LOC_VALUE) return true; else { @@ -980,7 +1034,8 @@ } //____________________________________________________________________ -bool MvObsSetIterator::msgTypeOk(MvObs* anObs) const { +bool MvObsSetIterator::msgTypeOk(MvObs* anObs) const +{ if (_MsgTypeCount < 1) return true; @@ -991,7 +1046,8 @@ return false; } -bool MvObsSetIterator::msgSubtypeOk(MvObs* anObs) const { +bool MvObsSetIterator::msgSubtypeOk(MvObs* anObs) const +{ if (_MsgSubtypeCount < 1) return true; @@ -1002,7 +1058,8 @@ return false; } -bool MvObsSetIterator::messageNumberOk(MvObs* /*anObs*/) const { +bool MvObsSetIterator::messageNumberOk(MvObs* /*anObs*/) const +{ if (!messageNumber_.empty()) { for (int i : messageNumber_) { if (currentMessageNumber() == i) @@ -1013,7 +1070,8 @@ return true; } -bool MvObsSetIterator::editionNumberOk(MvObs* anObs) const { +bool MvObsSetIterator::editionNumberOk(MvObs* anObs) const +{ if (!editionNumber_.empty()) { for (int i : editionNumber_) { if (anObs->editionNumber() == i) @@ -1024,7 +1082,8 @@ return true; } -bool MvObsSetIterator::originatingCentreOk(MvObs* anObs) const { +bool MvObsSetIterator::originatingCentreOk(MvObs* anObs) const +{ if (!originatingCentre_.empty()) { for (int i : originatingCentre_) { if (anObs->originatingCentre() == i) @@ -1035,7 +1094,8 @@ return true; } -bool MvObsSetIterator::originatingCentreAsStrOk(MvObs* anObs) const { +bool MvObsSetIterator::originatingCentreAsStrOk(MvObs* anObs) const +{ if (!originatingCentreStr_.empty()) { for (const auto& i : originatingCentreStr_) { if (anObs->originatingCentreAsStr() == i) @@ -1046,7 +1106,8 @@ return true; } -bool MvObsSetIterator::originatingSubCentreOk(MvObs* anObs) const { +bool MvObsSetIterator::originatingSubCentreOk(MvObs* anObs) const +{ if (!originatingSubCentre_.empty()) { for (int i : originatingSubCentre_) { if (anObs->originatingSubCentre() == i) @@ -1057,7 +1118,8 @@ return true; } -bool MvObsSetIterator::masterTableVersionOk(MvObs* anObs) const { +bool MvObsSetIterator::masterTableVersionOk(MvObs* anObs) const +{ if (!masterTableVersion_.empty()) { for (int i : masterTableVersion_) { if (anObs->masterTableVersion() == i) @@ -1068,7 +1130,8 @@ return true; } -bool MvObsSetIterator::localTableVersionOk(MvObs* anObs) const { +bool MvObsSetIterator::localTableVersionOk(MvObs* anObs) const +{ if (!localTableVersion_.empty()) { for (int i : localTableVersion_) { if (anObs->localTableVersion() == i) @@ -1079,7 +1142,8 @@ return true; } -bool MvObsSetIterator::headerIdentOk(MvObs* anObs) const { +bool MvObsSetIterator::headerIdentOk(MvObs* anObs) const +{ if (!headerIdent_.empty()) { for (const auto& i : headerIdent_) { if (simplified(anObs->headerIdent()) == i) @@ -1090,14 +1154,15 @@ return true; } -bool MvObsSetIterator::identValueOk(MvObs* anObs) const { +bool MvObsSetIterator::identValueOk(MvObs* anObs) const +{ if (!identValue_.empty()) { if (identKey_.empty()) { return false; } // We need this key from the data section so we need to expand the message anObs->expand(); - for(const auto& k : identKey_) { + for (const auto& k : identKey_) { for (const auto& v : identValue_) { if (anObs->stringValue(k, 1) == v) { return true; @@ -1113,7 +1178,6 @@ { if (!wigosSeries_.empty() || !wigosIssuer_.empty() || !wigosIssueNumber_.empty() || !wigosLocalName_.empty()) { - // We need keys from the data section so we need to expand the message anObs->expand(); @@ -1123,9 +1187,8 @@ // individual ids if (wigosSeries_.size() == wigosIssuer_.size() && wigosSeries_.size() == wigosIssueNumber_.size() && - wigosSeries_.size() == wigosLocalName_.size()) { - - for (std::size_t i=0; i < wigosSeries_.size(); i++) { + wigosSeries_.size() == wigosLocalName_.size()) { + for (std::size_t i = 0; i < wigosSeries_.size(); i++) { if (wigosSeries_[i] > -1 && wigosSeries_[i] != anObs->wigosSeries()) { continue; } @@ -1146,7 +1209,8 @@ return true; } -bool MvObsSetIterator::msgRdbtypeOk(MvObs* anObs) const { +bool MvObsSetIterator::msgRdbtypeOk(MvObs* anObs) const +{ if (!rdbType_.empty()) { for (int i : rdbType_) { if (anObs->messageRdbtype() == i) @@ -1158,7 +1222,8 @@ } //____________________________________________________________________ -bool MvObsSetIterator::selectOk(MvObs* anObs) const { +bool MvObsSetIterator::selectOk(MvObs* anObs) const +{ if (_SelectState == SF_notSet) return true; @@ -1195,7 +1260,8 @@ } //____________________________________________________________________ -bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond) const { +bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond) const +{ if (!anObs) return false; @@ -1271,7 +1337,8 @@ } -bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond, bool& headerDidNotMatch) const { +bool MvObsSetIterator::AcceptedObs(MvObs& anObs, bool skipPreFilterCond, bool& headerDidNotMatch) const +{ headerDidNotMatch = false; if (!anObs) @@ -1375,8 +1442,9 @@ //_____________________________________________________________ operator<< -std::ostream& operator<<(std::ostream& aStream, const MvObsSetIterator& aFilter) { - int i; +std::ostream& operator<<(std::ostream& aStream, const MvObsSetIterator& aFilter) +{ + int i = 0; aStream << "Observation Filter values set:\n"; if (aFilter._NoFiltersSet) { @@ -1481,14 +1549,15 @@ return aStream; } -std::string MvObsSetIterator::simplified(const std::string& str) { +std::string MvObsSetIterator::simplified(const std::string& str) +{ std::size_t pos1 = str.find_first_not_of(" "); std::size_t pos2 = str.find_last_not_of(" "); if (pos1 != std::string::npos && pos2 != std::string::npos && pos2 >= pos1) { return str.substr(pos1, pos2 - pos1 + 1); } - return std::string(); + return {}; } } // namespace diff -Nru metview-5.17.4/metview/src/libMetview/MvObsSet.h metview-5.19.2/metview/src/libMetview/MvObsSet.h --- metview-5.17.4/metview/src/libMetview/MvObsSet.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvObsSet.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,11 @@ #include #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif class MvPrepBufrPrep; @@ -31,7 +33,8 @@ /*! This class is used to handle a file containing several * observation reports stored as BUFR messages. */ -class MvObsSet { +class MvObsSet +{ friend class MvObsSetIterator; friend class MvBufrOut; @@ -89,7 +92,8 @@ int obsCount(); // nr of observation messages in a BUFR-file //! Returns the (running) number of the current BUFR message - int messageNumber() { + int messageNumber() + { return (int)_msgNumber; } @@ -105,14 +109,16 @@ bool writeCompressed(MvObs* obs, const std::vector& subsetVec); bool write(const void*, const size_t); - MvObs& firstObs() { + MvObs& firstObs() + { return _firstObs; } // Expand message void expand(); - void setCacheCompressedData(bool b) { + void setCacheCompressedData(bool b) + { cacheCompressedData_ = b; } @@ -191,9 +197,10 @@ }; -class MvObsSetIteratorObserver { +class MvObsSetIteratorObserver +{ public: - MvObsSetIteratorObserver() {} + MvObsSetIteratorObserver() = default; virtual void notifyObsIteratorProgress(int) = 0; }; @@ -206,7 +213,8 @@ * filtering criteria are set the resulting filter will use * logical AND to combine different criteria. */ -class MvObsSetIterator { +class MvObsSetIterator +{ //! Writes the current filtering options of 'anIter' into stream 'aStream' friend std::ostream& operator<<(std::ostream& aStream, const MvObsSetIterator& anIter); @@ -342,13 +350,12 @@ MvObs nextMessage(); bool AcceptedObs(MvObs&, bool skipPreFilterCond = false) const; bool AcceptedObs(MvObs&, bool skipPreFilterCond, bool& headerDidNotMatch) const; - bool useHeaderOnly() const { return useHeaderOnly_; } MvObs gotoMessage(long offset, int msgCnt); // Set the observer void setObserver(MvObsSetIteratorObserver* observer) { observer_ = observer; } - void removeObserver() { observer_ = 0; } + void removeObserver() { observer_ = nullptr; } void setFilterProgressStep(int filterProgressStep); protected: @@ -379,13 +386,13 @@ // we cannot use it from MvMiscallaneous because this code is shared // with Magics! static std::string simplified(const std::string& str); -protected: - bool _NoFiltersSet; - bool useObsTime_; - int _SelectValueCount; - int _MsgTypeCount; + + bool _NoFiltersSet{true}; + bool useObsTime_{false}; + int _SelectValueCount{0}; + int _MsgTypeCount{0}; int _MsgType[MAX_FILTER_LIST_ARRAY_SIZE]; - int _MsgSubtypeCount; + int _MsgSubtypeCount{0}; int _MsgSubtype[MAX_FILTER_LIST_ARRAY_SIZE]; double _SelectValue[MAX_FILTER_LIST_ARRAY_SIZE]; std::string _SelectDescriptor; @@ -408,18 +415,17 @@ std::vector wigosLocalName_; TDynamicTime fBeginTime, fEndTime; - ETimeFilterState _TimeFilterState; - ESelectFilterState _SelectState; + ETimeFilterState _TimeFilterState{kTFS_notSet}; + ESelectFilterState _SelectState{SF_notSet}; MvXSectionLine fXSectionLine; MvArea fArea; private: MvObs current; - MvObsSet* ObsSet; - bool useHeaderOnly_; - MvObsSetIteratorObserver* observer_; - int filterProgressStep_; + MvObsSet* ObsSet{nullptr}; + MvObsSetIteratorObserver* observer_{nullptr}; + int filterProgressStep_{20}; }; } // namespace diff -Nru metview-5.17.4/metview/src/libMetview/MvOdb.cc metview-5.19.2/metview/src/libMetview/MvOdb.cc --- metview-5.17.4/metview/src/libMetview/MvOdb.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvOdb.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,11 +22,11 @@ #include -//This include must come after the oda includes, otherwise -//compilation fails!! +// This include must come after the oda includes, otherwise +// compilation fails!! #include "MvScanFileType.h" -//const int intMissingValue = -2147480000; +// const int intMissingValue = -2147480000; const int floatMissingValue = -2.14748e+09; static std::map typeMap; @@ -35,7 +35,7 @@ { name_ = s; - shortName_ = name_; + shortName_ = name_; std::size_t pos = name_.find("@"); if (pos != std::string::npos) { shortName_ = name_.substr(0, pos); @@ -111,23 +111,18 @@ // //============================= -MvAbstractOdb::MvAbstractOdb(std::string path, std::string sourcePath, std::string query, OdbVersion version) : +MvAbstractOdb::MvAbstractOdb(const std::string& path, const std::string& sourcePath, const std::string& query, OdbVersion version) : path_(path), sourcePath_(sourcePath), query_(query), - version_(version), - chunkSize_(0), - currentChunk_(0), - nbRowsInChunk_(0) + version_(version) { - //init(); } -MvAbstractOdb::MvAbstractOdb(std::string path, OdbVersion version) : +MvAbstractOdb::MvAbstractOdb(const std::string& path, OdbVersion version) : path_(path), version_(version) { - //init(); } MvAbstractOdb::~MvAbstractOdb() @@ -194,19 +189,19 @@ return; headerIsRead_ = false; - rowNum_ = -1; + rowNum_ = -1; if (typeMap.empty() == true) { - typeMap[odc::api::IGNORE] = MvOdbColumn::None; - typeMap[odc::api::INTEGER] = MvOdbColumn::Int; - typeMap[odc::api::REAL] = MvOdbColumn::Float; - typeMap[odc::api::STRING] = MvOdbColumn::String; + typeMap[odc::api::IGNORE] = MvOdbColumn::None; + typeMap[odc::api::INTEGER] = MvOdbColumn::Int; + typeMap[odc::api::REAL] = MvOdbColumn::Float; + typeMap[odc::api::STRING] = MvOdbColumn::String; typeMap[odc::api::BITFIELD] = MvOdbColumn::Bitfield; - typeMap[odc::api::DOUBLE] = MvOdbColumn::Double; + typeMap[odc::api::DOUBLE] = MvOdbColumn::Double; } - //odb_start(); - //odc_initialise_api(); + // odb_start(); + // odc_initialise_api(); } void MvOdb::readMetaData() @@ -214,32 +209,32 @@ if (headerIsRead_) return; - //std::string SELECT = "select * from \"" + path_ + "\";"; + // std::string SELECT = "select * from \"" + path_ + "\";"; - //ODA oda(""); + // ODA oda(""); odc::Reader oda(path_); - //int row=0; + // int row=0; - //odb::Reader::iterator end = oda.end(); + // odb::Reader::iterator end = oda.end(); odc::Reader::iterator beg = oda.begin(); - //Columns + // Columns - //ODA::iterator it = oda.begin(); - //MetaData cols=oda.begin()->columns(); + // ODA::iterator it = oda.begin(); + // MetaData cols=oda.begin()->columns(); - //rowNum_=0; + // rowNum_=0; - //size_t n = beg.columns().size(); + // size_t n = beg.columns().size(); for (auto it : beg->columns()) { auto* acol = new MvOdbColumn; - //if(rowNum_==0) + // if(rowNum_==0) // rowNum_=(*it)->noRows(); std::string s = it->name(); - //std::cout << s << std::endl; + // std::cout << s << std::endl; acol->setName(s); if (typeMap.find(it->type()) != typeMap.end()) { @@ -251,7 +246,7 @@ int pos = 0; for (unsigned int i = 0; i < it->bitfieldDef().first.size(); i++) { std::string name = it->bitfieldDef().first.at(i); - int size = it->bitfieldDef().second.at(i); + int size = it->bitfieldDef().second.at(i); acol->addBitfieldMember(new MvOdbBitfieldMember(name, pos, size)); pos += size; } @@ -260,38 +255,38 @@ column_.push_back(acol); } - //int colNum=column_.size(); + // int colNum=column_.size(); /*rowNum_=0; - for (ODA::iterator it = oda.begin(); it != end; ++it) - { - rowNum_++; - }*/ + for (ODA::iterator it = oda.begin(); it != end; ++it) + { + rowNum_++; + }*/ // for (ODA::select_iterator it = oda.select(SELECT); // it != oda.selectEnd() ; ++it, ++row) // { /*for (ODA::iterator it = oda.begin(); it != end; ++it) - { + { + + for(int i=0; i < colNum; i++) + { + if(column_[i]->type() == MvOdaColumn::Float || column_[i]->type() == MvOdaColumn::Int) + { + + column_[i]->addToStats(it->data(i)); + } + } + } - for(int i=0; i < colNum; i++) - { - if(column_[i]->type() == MvOdaColumn::Float || column_[i]->type() == MvOdaColumn::Int) - { - - column_[i]->addToStats(it->data(i)); - } - } - } - - for(int col=0; col < column_.size(); col++) - { - column_[col]->compStats(); - std::cout << column_[col]->name() << " " << column_[col]->type() << std::endl; - std::cout << " " << column_[col]->min() << " " << column_[col]->max() << " " << + for(int col=0; col < column_.size(); col++) + { + column_[col]->compStats(); + std::cout << column_[col]->name() << " " << column_[col]->type() << std::endl; + std::cout << " " << column_[col]->min() << " " << column_[col]->max() << " " << column_[col]->avg() << " " << column_[col]->std() << std::endl; - }*/ + }*/ headerIsRead_ = true; } @@ -318,8 +313,8 @@ int rowNum = this->rowNum(); - size_t intSize = sizeof(int); - size_t floatSize = sizeof(float); + size_t intSize = sizeof(int); + size_t floatSize = sizeof(float); size_t doubleSize = sizeof(double); float totalSize = 0.; @@ -360,7 +355,7 @@ odc::Reader oda(path_); - //Create iterator + // Create iterator odc::Reader::iterator it = oda.begin(); int i = 0; @@ -401,22 +396,22 @@ { readMetaData(); - //We try with the full column name + // We try with the full column name for (auto& i : column_) { if (cname == i->name()) { return true; } } - //If there is no match we try without the @tablename suffix + // If there is no match we try without the @tablename suffix std::string shortName = cname; - std::size_t pos = cname.find("@"); + std::size_t pos = cname.find("@"); if (pos != std::string::npos) { shortName = cname.substr(0, pos); } - //We try with the full column name + // We try with the full column name for (auto& i : column_) { if (shortName == i->shortName()) { return true; @@ -445,10 +440,10 @@ odc::Reader oda(path_); - //Create iterator + // Create iterator odc::Reader::iterator it = oda.begin(); - //Jump to the given chunk + // Jump to the given chunk if (chunkSize_ != 0) { int i = 0; for (; it != oda.end() && i < chunkSize_ * currentChunk_; ++it, i++) { @@ -479,7 +474,7 @@ } } } - //No chunks are used for load + // No chunks are used for load else { if (column_[pos]->type() == MvOdbColumn::String) { for (; it != oda.end(); ++it) { @@ -540,10 +535,10 @@ odc::Reader oda(path_); - //Create iterator + // Create iterator odc::Reader::iterator it = oda.begin(); - //Jump to the given chunk + // Jump to the given chunk if (chunkSize_ != 0) { int i = 0; for (; it != oda.end() && i < chunkSize_ * currentChunk_; ++it, i++) { @@ -567,7 +562,7 @@ } } } - //No chunks are used for load + // No chunks are used for load else { for (; it != oda.end(); ++it) { for (int pos = 0; pos < static_cast(column_.size()); pos++) { @@ -652,11 +647,11 @@ bool MvOdb::retrieveToFile(std::string query, std::string inFile, std::string outFile) { - //odb_start(); + // odb_start(); std::string SELECT; - //Find "where" statement in query + // Find "where" statement in query std::string wd = query; std::transform(wd.begin(), wd.end(), wd.begin(), ::tolower); @@ -670,13 +665,13 @@ SELECT = query + " from \"" + inFile + "\";"; } - //std::cout << "Select: " << SELECT << std::endl; + // std::cout << "Select: " << SELECT << std::endl; odc::Writer<> writer(outFile); odc::Writer<>::iterator outit = writer.begin(); odc::Select oda(SELECT); - odc::Select::iterator it = oda.begin(); + odc::Select::iterator it = oda.begin(); odc::Select::iterator end = oda.end(); if ((it != end) == false) { @@ -691,24 +686,24 @@ bool MvOdb::toGeopoints(std::string outFile, std::string geoType) { std::map colNumForGeoType; - colNumForGeoType["GEO_STANDARD"] = 6; - colNumForGeoType["GEO_XYV"] = 3; + colNumForGeoType["GEO_STANDARD"] = 6; + colNumForGeoType["GEO_XYV"] = 3; colNumForGeoType["GEO_XY_VECTOR"] = 7; - colNumForGeoType["GEO_XY_POLAR"] = 7; + colNumForGeoType["GEO_XY_POLAR"] = 7; - //Check geopoints format + // Check geopoints format if (colNumForGeoType.find(geoType) == colNumForGeoType.end()) { return false; } - //Initialize oda - //odb_start(); + // Initialize oda + // odb_start(); odc::Reader oda(path_); - //Create iterator + // Create iterator odc::Reader::iterator it = oda.begin(); - //Columns + // Columns std::vector colName; for (auto itc : it->columns()) { std::string s = itc->name(); @@ -721,7 +716,7 @@ return false; } - //Write data into a geopoints file + // Write data into a geopoints file //======================= // GEO_STANDARD @@ -748,12 +743,12 @@ colName[5].c_str()); /*fprintf(fp,"DB_COLUMN_ALIAS: %s;%s;%s;%s;%s;%s\n", - odb["lat"].colNickname().c_str(), - odb["lon"].colNickname().c_str(), - levAlias.c_str(), - dateAlias.c_str(), - timeAlias.c_str(), - odb["value"].colNickname().c_str());*/ + odb["lat"].colNickname().c_str(), + odb["lon"].colNickname().c_str(), + levAlias.c_str(), + dateAlias.c_str(), + timeAlias.c_str(), + odb["value"].colNickname().c_str());*/ fprintf(fp, "DB_PATH: %s \n", sourcePath_.c_str()); fprintf(fp, "DB_QUERY_BEGIN \n%s \nDB_QUERY_END\n", query_.c_str()); @@ -904,7 +899,7 @@ return; headerIsRead_ = false; - rowNum_ = -1; + rowNum_ = -1; } void MvOldOdb::readMetaData() @@ -1009,7 +1004,7 @@ MvAbstractOdb* MvOdbFactory::make(std::string path, std::string sourcePath, std::string query) { - //We suppose it is an ODB + // We suppose it is an ODB std::string type = MvOdbType(path.c_str(), false); if (type == "ODB_NEW") { diff -Nru metview-5.17.4/metview/src/libMetview/MvOdb.h metview-5.19.2/metview/src/libMetview/MvOdb.h --- metview-5.17.4/metview/src/libMetview/MvOdb.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvOdb.h 2023-07-15 08:28:47.000000000 +0000 @@ -122,41 +122,41 @@ VersionNew }; - MvAbstractOdb(std::string, OdbVersion); - MvAbstractOdb(std::string, std::string, std::string, OdbVersion); + MvAbstractOdb(const std::string&, OdbVersion); + MvAbstractOdb(const std::string&, const std::string&, const std::string&, OdbVersion); virtual ~MvAbstractOdb(); virtual void init() = 0; - std::string path() { return path_; } - std::string query() { return query_; } - OdbVersion version() { return version_; } - int chunkSize() { return chunkSize_; } - int currentChunk() { return currentChunk_; } - int nbRowsInChunk() { return nbRowsInChunk_; } + const std::string& path() const { return path_; } + const std::string& query() const { return query_; } + OdbVersion version() const { return version_; } + int chunkSize() const { return chunkSize_; } + int currentChunk() const { return currentChunk_; } + int nbRowsInChunk() const { return nbRowsInChunk_; } virtual void setChunkSize(int i) { chunkSize_ = i; } virtual void setCurrentChunk(int i) { currentChunk_ = i; } - virtual int totalSizeInMb() = 0; - virtual int rowNum() = 0; - virtual int columnNum() = 0; - virtual const MvOdbColumn* column(std::string) = 0; - virtual const MvOdbColumn* column(int) = 0; - virtual const std::vector& columns() = 0; + virtual int totalSizeInMb() = 0; + virtual int rowNum() = 0; + virtual int columnNum() = 0; + virtual const MvOdbColumn* column(std::string) = 0; + virtual const MvOdbColumn* column(int) = 0; + virtual const std::vector& columns() = 0; virtual const MvOdbColumn* loadColumn(std::string, bool reload = false) = 0; - virtual const MvOdbColumn* loadColumn(int, bool reload = false) = 0; - virtual void unloadColumn(std::string) = 0; - virtual void unloadColumn(int) = 0; - virtual void loadAllColumns() = 0; - virtual void unloadAllColumns() = 0; + virtual const MvOdbColumn* loadColumn(int, bool reload = false) = 0; + virtual void unloadColumn(std::string) = 0; + virtual void unloadColumn(int) = 0; + virtual void loadAllColumns() = 0; + virtual void unloadAllColumns() = 0; - virtual void generateStats(int) = 0; + virtual void generateStats(int) = 0; virtual bool toGeopoints(std::string, std::string) = 0; - virtual bool hasColumn(const std::string&) = 0; + virtual bool hasColumn(const std::string&) = 0; protected: - virtual void readMetaData() = 0; + virtual void readMetaData() = 0; virtual int findColumn(std::string) = 0; void detectOdbVersion(); @@ -164,14 +164,14 @@ std::string sourcePath_; std::string query_; std::vector column_; - int rowNum_; - bool headerIsRead_; + int rowNum_{0}; + bool headerIsRead_{false}; OdbVersion version_; - int chunkSize_; - int currentChunk_; - int nbRowsInChunk_; + int chunkSize_{0}; + int currentChunk_{0}; + int nbRowsInChunk_{0}; }; #ifdef METVIEW_ODB_NEW @@ -252,54 +252,3 @@ MvOdbFactory() = default; static MvAbstractOdb* make(std::string path, std::string sourcePath = std::string(), std::string query = std::string()); }; - - -/* -class MvOdb -{ -public: - enum OdbVersion {UnknownVersion,Version1,Version2}; - - MvOdb(std::string); - MvOdb(std::string,std::string,std::string); - ~MvOdb(); - void init(); - - std::string path() {return path_;} - std::string query() {return query_;} - int rowNum(); - int columnNum() {readMetaData(); return column_.size();} - - void generateStats(int); - void toGeopoints(std::string,std::string); - - const std::vector& columns() {readMetaData(); return column_;} - - const MvOdbColumn* loadColumn(std::string); - const MvOdbColumn* loadColumn(int); - const MvOdbColumn* column(std::string); - const MvOdbColumn* column(int); - void unloadColumn(std::string); - void unloadColumn(int); - - OdbVersion version() {return version_;} - - static void retrieveToFile(std::string,std::string,std::string); - -protected: - void readMetaData(); - int findColumn(std::string); - void detectOdbVersion(); - - int rowNum_; - std::string path_; - std::string sourcePath_; - std::string query_; - std::vector column_; - bool headerIsRead_; - - OdbVersion version_; - - -}; -*/ diff -Nru metview-5.17.4/metview/src/libMetview/MvPath.cc metview-5.19.2/metview/src/libMetview/MvPath.cc --- metview-5.17.4/metview/src/libMetview/MvPath.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvPath.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,8 @@ #include "UtilitiesC.h" static std::string user_dir = getenv("METVIEW_USER_DIRECTORY"); -static Cached tmp_dir = getenv("METVIEW_TMPDIR"); -static Cached metv_dir = getenv("METVIEW_DIR_SHARE"); +static Cached tmp_dir = getenv("METVIEW_TMPDIR"); +static Cached metv_dir = getenv("METVIEW_DIR_SHARE"); std::string @@ -128,7 +128,7 @@ Cached MakeTmpName(const Cached& iconPrefix) { - char* p = UtRandomName(tmp_dir, iconPrefix); + char* p = UtRandomName(tmp_dir, iconPrefix); Cached newName = Cached(p); free(p); return newName; @@ -205,7 +205,7 @@ std::string fullPath(filename); if (*filename != '/') { const char* pwd = getenv("PWD"); - fullPath = std::string(pwd) + std::string("/") + fullPath; + fullPath = std::string(pwd) + std::string("/") + fullPath; } return fullPath; diff -Nru metview-5.17.4/metview/src/libMetview/MvPrepBufrPrep.cc metview-5.19.2/metview/src/libMetview/MvPrepBufrPrep.cc --- metview-5.17.4/metview/src/libMetview/MvPrepBufrPrep.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvPrepBufrPrep.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,8 @@ #include "MvObsSet.h" -namespace metview { +namespace metview +{ const std::string cNoBufrTablesDir("NO_TABLE_DIR"); const std::string cCommonNamePart("_prepbufr.txt"); @@ -46,12 +47,12 @@ MvPrepBufrPrep::~MvPrepBufrPrep() { - //revertBufrTablesDir(); //-- this would change nothing as BUFR_TABLES + // revertBufrTablesDir(); //-- this would change nothing as BUFR_TABLES //-- will not be read anymore - //std::string remove = "rm -r " + prepBufrTableDir_ + "/*"; - //std::cout << "rm command is: " << remove << std::endl; - // int s = system( remove.c_str() ); + // std::string remove = "rm -r " + prepBufrTableDir_ + "/*"; + // std::cout << "rm command is: " << remove << std::endl; + // int s = system( remove.c_str() ); } //______________________________________________________________________ @@ -62,8 +63,8 @@ if (!ok) return false; - MvObs firstObs = obsSet_.firstObs(); //-- create links to our tables that are - ok = createTablesDecodeLinks(firstObs); //-- needed to decode prepBUFR tables + MvObs firstObs = obsSet_.firstObs(); //-- create links to our tables that are + ok = createTablesDecodeLinks(firstObs); //-- needed to decode prepBUFR tables if (!ok) return false; @@ -88,12 +89,12 @@ { //-- store current value (if any) const char* oldDir = getenv("BUFR_TABLES"); - origBufrTableDir_ = oldDir ? oldDir : cNoBufrTablesDir; + origBufrTableDir_ = oldDir ? oldDir : cNoBufrTablesDir; std::cout << "MvPrepBufrPrep::prepareTempDir: origBufrTableDir_=" << origBufrTableDir_ << std::endl; - //char dirTemplate[1024]; //-- build template for unique subdir name - //strcpy( dirTemplate, getenv("METVIEW_TMPDIR") ); - //strcat( dirTemplate, "/PrepBufrTablesXXXXXX" ); + // char dirTemplate[1024]; //-- build template for unique subdir name + // strcpy( dirTemplate, getenv("METVIEW_TMPDIR") ); + // strcat( dirTemplate, "/PrepBufrTablesXXXXXX" ); // to create a unique temporary directory name without using mkdtemp (which does not // work on AIX), we create a temporary file, append '_dir' and create a directory @@ -116,7 +117,7 @@ return false; } - prepBufrTableDir_ = tmpfilename; //mkdtemp(dirTemplate); //-- create a unique subdir for PrepBufr tables + prepBufrTableDir_ = tmpfilename; // mkdtemp(dirTemplate); //-- create a unique subdir for PrepBufr tables std::cout << "MvPrepBufrPrep::prepareTempDir: prepBufrTableDir_=" << prepBufrTableDir_ << std::endl; return true; @@ -130,10 +131,10 @@ bool MvPrepBufrPrep::createTablesDecodeLinks(MvObs& firstObs) { std::ostringstream commonPart; //-- build part of filename common to both files - int centre = firstObs.originatingCentre(); - int subCentre = firstObs.originatingSubCentre(); + int centre = firstObs.originatingCentre(); + int subCentre = firstObs.originatingSubCentre(); int masterTableVer = firstObs.masterTableVersion(); - int localTableVer = firstObs.localTableVersion(); + int localTableVer = firstObs.localTableVersion(); commonPart << "00" //-- discipline: 0 = meteorology << std::setw(6) << std::setfill('0') << subCentre @@ -195,7 +196,7 @@ bool MvPrepBufrPrep::setNewBufrTablesDir() { - const int overWrite = 1; + const int overWrite = 1; std::string newEnvVar = prepBufrTableDir_ + "/"; int ok = setenv("BUFR_TABLES", newEnvVar.c_str(), overWrite); @@ -246,10 +247,10 @@ if (obs.messageType() == 11) //-- skip if msg contains BUFR tables continue; //-- get values used in building table names - int centre = obs.originatingCentre(); - int subCentre = obs.originatingSubCentre(); + int centre = obs.originatingCentre(); + int subCentre = obs.originatingSubCentre(); int masterTableVer = obs.masterTableVersion(); - int localTableVer = obs.localTableVersion(); + int localTableVer = obs.localTableVersion(); std::ostringstream commonPart; //-- build part of the filename common to both files @@ -285,7 +286,7 @@ } //-- build 'bufrdc' style Table D name std::string table_D_name = prepBufrTableDir_ + "/D" + commonPart.str(); - ok = symlink(prepBufrTable_D_.c_str(), table_D_name.c_str()); + ok = symlink(prepBufrTable_D_.c_str(), table_D_name.c_str()); if (ok != 0) { #ifdef METVIEW marslog(LOG_EROR, "Unable to create a link into PrepBUFR Table D, returned %d", ok); @@ -539,4 +540,4 @@ } #endif -} +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/MvPrepBufrPrep.h metview-5.19.2/metview/src/libMetview/MvPrepBufrPrep.h --- metview-5.17.4/metview/src/libMetview/MvPrepBufrPrep.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvPrepBufrPrep.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,8 @@ #include "MvBufrObs.h" -namespace metview { +namespace metview +{ class MvObsSet; @@ -67,7 +68,7 @@ public: MvTableExtract(MvObsSet& os) : obsSet_(os) {} - ~MvTableExtract() {} + ~MvTableExtract() = default; bool extract(std::string& prepBufrTable_B, std::string& prepBufrTable_D); bool initTableFiles(std::string& prepBufrTable_B, std::string& prepBufrTable_D); @@ -83,8 +84,8 @@ class TableB_entry { public: - TableB_entry() {} - ~TableB_entry() {} + TableB_entry() = default; + ~TableB_entry() = default; bool getEntry(MvObs& obs); void writeEntry(std::ofstream& fout); @@ -103,8 +104,8 @@ class TableD_entry { public: - TableD_entry() {} - ~TableD_entry() {} + TableD_entry() = default; + ~TableD_entry() = default; bool getEntry(MvObs& obs); void writeEntry(std::ofstream& fout); @@ -117,4 +118,4 @@ }; //_____________________________________________________ -} +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/MvProfileData.cc metview-5.19.2/metview/src/libMetview/MvProfileData.cc --- metview-5.17.4/metview/src/libMetview/MvProfileData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvProfileData.cc 2023-07-15 08:28:47.000000000 +0000 @@ -9,14 +9,6 @@ #include "MvProfileData.h" - -MvProfileData::MvProfileData() : - levelDirection_(TopDown), - auxLevelDefined_(false), - rangeSet_(false) -{ -} - void MvProfileData::valueRange(int startIndex, int endIndex, float& minv, float& maxv) { minv = 9999999999; @@ -59,4 +51,4 @@ } return true; -} \ No newline at end of file +} diff -Nru metview-5.17.4/metview/src/libMetview/MvProfileData.h metview-5.19.2/metview/src/libMetview/MvProfileData.h --- metview-5.17.4/metview/src/libMetview/MvProfileData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvProfileData.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,13 +18,13 @@ class MvProfileChange { public: - MvProfileChange() : - group_(NoGroup) {} + MvProfileChange() = default; MvProfileChange(int lev, float val, float prevVal) : level_(lev), value_(val), - prevValue_(prevVal), - group_(NoGroup) {} + prevValue_(prevVal) + { + } MvProfileChange(const MvProfileChange& c) : level_(c.level()), @@ -51,10 +51,10 @@ void setGroup(GroupStatus b) { group_ = b; } protected: - int level_; - float value_; - float prevValue_; - GroupStatus group_; + int level_{0}; + float value_{0.}; + float prevValue_{0.}; + GroupStatus group_{NoGroup}; }; class MvProfileData @@ -66,13 +66,13 @@ BootmUp }; - MvProfileData(); + MvProfileData() = default; virtual ~MvProfileData() = default; virtual float value(int) = 0; - virtual float level(int) = 0; - virtual float auxLevel(int) = 0; + virtual float level(int) = 0; + virtual float auxLevel(int) = 0; virtual void levels(std::vector&) = 0; std::string name() const { return name_; } @@ -88,7 +88,7 @@ void valueRange(float&, float&); virtual bool acceptChange(const MvProfileChange&) const; - virtual int count() const = 0; + virtual int count() const = 0; virtual void setValue(int, float) = 0; void setRange(float min, float max) @@ -106,16 +106,16 @@ std::string name_; std::string units_; std::string stepString_; - bool editable_; + bool editable_{false}; - LevelDirection levelDirection_; + LevelDirection levelDirection_{TopDown}; std::string levelName_; std::string levelUnits_; - bool auxLevelDefined_; + bool auxLevelDefined_{false}; std::string auxLevelName_; std::string auxLevelUnits_; - bool rangeSet_; - float rangeMin_; - float rangeMax_; + bool rangeSet_{false}; + float rangeMin_{0.}; + float rangeMax_{0.}; }; diff -Nru metview-5.17.4/metview/src/libMetview/MvProtocol.cc metview-5.19.2/metview/src/libMetview/MvProtocol.cc --- metview-5.17.4/metview/src/libMetview/MvProtocol.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvProtocol.cc 2023-07-15 08:28:47.000000000 +0000 @@ -183,13 +183,13 @@ MvTransaction::MvTransaction(MvTransaction* from) { - Id = from->Id; + Id = from->Id; Error = from->Error; } void MvTransaction::_call_serve(svcid* id, request* r) { - Id = id; + Id = id; Error = 0; MvTransaction* t = cloneSelf(); diff -Nru metview-5.17.4/metview/src/libMetview/MvProtocol.h metview-5.19.2/metview/src/libMetview/MvProtocol.h --- metview-5.17.4/metview/src/libMetview/MvProtocol.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvProtocol.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,19 +27,19 @@ //! Static "service" function. /*! This is the "service" function registered by the constructor, - * to be called when the module receives the command. It calls - * the virtual method \c _call_serve, which may be implemented in - * a derived class. Argument \c id is the service structure and \c obj - * points to the MvProtocol object that registered this function. - */ + * to be called when the module receives the command. It calls + * the virtual method \c _call_serve, which may be implemented in + * a derived class. Argument \c id is the service structure and \c obj + * points to the MvProtocol object that registered this function. + */ static void _serve(svcid* id, request* r, void* obj); //! The default virtual method called by \c _serve. /*! Transforms the incoming request structure \c rq into a MvRequest - * and calls the virtual method \c callback which should be - * implemented in a derived class. - */ + * and calls the virtual method \c callback which should be + * implemented in a derived class. + */ virtual void _call_serve(svcid* id, request* rq); virtual void _clear_id(); @@ -50,14 +50,14 @@ //! Returns the value of parameter \c _NAME /*! In other words, returns the name of the object that is - * currently referenced in the incoming command. - */ + * currently referenced in the incoming command. + */ const char* iconName(); //! Returns the value of parameter \c _CLASS /*! In other words, returns the class of the object that is - * currently referenced in the incoming command. - */ + * currently referenced in the incoming command. + */ const char* iconClass(); //! Returns the value of parameter \c SOURCE from incoming command. @@ -81,24 +81,24 @@ //! Constructor for command \c name /*! This constructor registers protected static method \c _serve - * to be called when the module receives command \c name. - */ + * to be called when the module receives command \c name. + */ MvProtocol(const char* name); virtual void addCallbackKeyword(const char*); //! Empty virtual method /*! This method should be implemented in a derived class. - */ + */ virtual void callback(MvRequest&) {} //-- Communication -- //! Creates an error message /*! Sets the error number \c e and formats an error message into - * the internal service structure. Arguments \c fmt and \c ... are - * formats like in C language printf function. - */ + * the internal service structure. Arguments \c fmt and \c ... are + * formats like in C language printf function. + */ void setError(err e, const char* fmt, ...); //! Sets the error number \c e into the internal service structure @@ -112,12 +112,12 @@ //! Sends back the reply request answer /*! Error code and error messages will be sent back as well. - */ + */ void sendReply(const MvRequest& answer); //! Broadcasts a progress message /*! Arguments \c fmt and \c ... are formats like in C language printf function. - */ + */ void sendProgress(const std::string& msg); void sendProgress(const char* fmt, ...); @@ -140,13 +140,13 @@ class MvTransaction : public MvProtocol { /*! This method deletes the current instance, the one - * that is created by method \c _call_serve. - */ + * that is created by method \c _call_serve. + */ virtual void _clear_id(); /*! This method creates a new instance of MvTransaction and - * calls this new instance's method callback. - */ + * calls this new instance's method callback. + */ virtual void _call_serve(svcid*, request*); //! This pure virtual method is implemented in MvTransaction template diff -Nru metview-5.17.4/metview/src/libMetview/MvRequest.cc metview-5.19.2/metview/src/libMetview/MvRequest.cc --- metview-5.17.4/metview/src/libMetview/MvRequest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvRequest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -8,21 +8,24 @@ ***************************** LICENSE END *************************************/ #include +#include + #include #include #include +#include "MvMiscellaneous.h" MvRequest::MvRequest(const char* verb) { - _overwrite = 1; + _overwrite = 1; _free_req_on_destruct = 0; CurrentRequest = FirstRequest = empty_request(verb); } MvRequest::MvRequest(request* r, boolean clone, boolean free_req) { - _overwrite = 1; + _overwrite = 1; _free_req_on_destruct = free_req; CurrentRequest = FirstRequest = clone ? clone_all_requests(r) : r; } @@ -30,14 +33,14 @@ MvRequest::MvRequest(const MvRequest& r) { - _overwrite = 1; + _overwrite = 1; _free_req_on_destruct = 0; CurrentRequest = FirstRequest = clone_all_requests(r.FirstRequest); // Make sure currents match request* s = r.FirstRequest; while (s && s != r.CurrentRequest) { - s = s->next; + s = s->next; CurrentRequest = CurrentRequest->next; } } @@ -52,7 +55,7 @@ { free_all_requests(FirstRequest); FirstRequest = CurrentRequest = 0; - CurrentValue = 0; + CurrentValue = 0; } MvRequest& MvRequest::operator=(const MvRequest& r) @@ -63,18 +66,18 @@ // Make sure currents match request* s = r.FirstRequest; while (s && s != r.CurrentRequest) { - s = s->next; + s = s->next; CurrentRequest = CurrentRequest->next; } return *this; } -//MvRequest& MvRequest::operator=(const request *r) +// MvRequest& MvRequest::operator=(const request *r) //{ // free_all_requests(FirstRequest); // CurrentRequest = FirstRequest = clone_all_requests(r); // return *this; -//} +// } MvRequest MvRequest::operator+(const MvRequest& r) const { @@ -129,13 +132,13 @@ void MvRequest::copyFromCurrent(const MvRequest& r) { - _overwrite = 1; + _overwrite = 1; CurrentRequest = FirstRequest = clone_all_requests(r.CurrentRequest); } void MvRequest::copyFromCurrentTo(const MvRequest& r, const char* verb) { - _overwrite = 1; + _overwrite = 1; CurrentRequest = FirstRequest = copyFromCurrentTo_Recursive(r.CurrentRequest, verb); } @@ -189,11 +192,11 @@ void MvRequest::read(const char* fileNamePath, bool expand, bool hidden) { - //boolean is defined in mars.h as int + // boolean is defined in mars.h as int boolean debugOriVal = mars.debug; if (hidden && !mars.debug) { debugOriVal = mars.debug; - mars.debug = 1; + mars.debug = 1; } // Read request using MARS library @@ -234,9 +237,9 @@ FILE* fp = fopen(file, "w"); if (fp) { if (hidden && !mars.debug) { - //boolean is defined in mars.h as int + // boolean is defined in mars.h as int boolean oriDebugVal = mars.debug; - mars.debug = 1; + mars.debug = 1; save(fp); mars.debug = oriDebugVal; } @@ -264,7 +267,7 @@ set_value( Request->CurrentRequest, LastGet, "%s", get_value(a.Request->CurrentRequest, a.LastGet, a.LastIndex)); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } @@ -304,7 +307,7 @@ MvAccess::operator MvDate() const { - long save = expand_flags(0); // So it is working OK + long save = expand_flags(0); // So it is working OK const char* p = get_value(Request->CurrentRequest, LastGet, LastIndex); expand_flags(save); return MvDate(p); @@ -312,7 +315,7 @@ MvConstAccess::operator MvDate() const { - long save = expand_flags(0); // So it is working OK + long save = expand_flags(0); // So it is working OK const char* p = get_value(Request->CurrentRequest, LastGet, LastIndex); expand_flags(save); return MvDate(p); @@ -353,35 +356,35 @@ { if (LastGet) set_value(Request->CurrentRequest, LastGet, "%s", val); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } void MvAccess::operator=(double val) { if (LastGet) set_value(Request->CurrentRequest, LastGet, "%.12g", val); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } void MvAccess::operator=(int val) { if (LastGet) set_value(Request->CurrentRequest, LastGet, "%d", val); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } void MvAccess::operator=(const request* val) { if (LastGet) set_subrequest(Request->CurrentRequest, LastGet, val); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } void MvAccess::operator=(long val) { if (LastGet) set_value(Request->CurrentRequest, LastGet, "%ld", val); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } @@ -392,7 +395,7 @@ if (LastGet) set_value(Request->CurrentRequest, LastGet, "%s", buf); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } @@ -408,7 +411,7 @@ if (LastGet) add_value(Request->CurrentRequest, LastGet, "%s", buf); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } @@ -416,7 +419,7 @@ { if (LastGet) add_value(Request->CurrentRequest, LastGet, "%s", val); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } @@ -431,20 +434,20 @@ add_value( Request->CurrentRequest, LastGet, "%s", get_value(a.Request->CurrentRequest, a.LastGet, a.LastIndex)); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } void MvRequest::getValue(int& v, const char* p, int i) const { const char* t = get_value(CurrentRequest, p, i); - v = (t) ? atoi(get_value(CurrentRequest, p, i)) : 0; + v = (t) ? atoi(get_value(CurrentRequest, p, i)) : 0; } void MvRequest::getValue(double& v, const char* p, int i) const { const char* t = get_value(CurrentRequest, p, i); - v = (t) ? atof(get_value(CurrentRequest, p, i)) : 0; + v = (t) ? atof(get_value(CurrentRequest, p, i)) : 0; } void MvRequest::getValue(const char*& v, const char* p, int i) const @@ -492,7 +495,7 @@ { bool myStat = false; if (CurrentValue && CurrentValue->name) { - val = CurrentValue->name; + val = CurrentValue->name; myStat = true; } else @@ -508,7 +511,7 @@ { bool myStat = false; if (CurrentValue && CurrentValue->name) { - val = atof(CurrentValue->name); + val = atof(CurrentValue->name); myStat = true; } else @@ -719,13 +722,13 @@ { if (!CurrentRequest) return 0; - int n = 0; - parameter* p = CurrentRequest->params; + int n = 0; + parameter* p = CurrentRequest->params; parameter* lastp = p; while (p) { n++; lastp = p; - p = p->next; + p = p->next; } // here, 'hidden' means that it starts with a double underscore, as in "__strings" if (!includeHidden) { @@ -744,7 +747,7 @@ if (!CurrentRequest) return nullptr; - int n = 0; + int n = 0; parameter* p = CurrentRequest->params; while (p) { if (n++ == i) @@ -763,7 +766,7 @@ bool MvRequest::iterGetNextParamInterface(MvRequest& req) { - if (!CurrentParam) //end of request + if (!CurrentParam) // end of request return false; // clone the Interface request @@ -808,7 +811,7 @@ const char* MvRequest ::enquire(const char* name, const char* keyw, int posit) { const char* value = nullptr; - request* reqst = FirstRequest; + request* reqst = FirstRequest; while (reqst && !value) { if (!strcmp(name, reqst->name)) @@ -852,7 +855,7 @@ void MvRequest::update(const MvRequest& r) { - request* a = CurrentRequest; + request* a = CurrentRequest; const request* b = r.CurrentRequest; if (!a || !b) @@ -867,7 +870,7 @@ } boolean b = false; - value* v = p->values; + value* v = p->values; while (v) { update_value(a, p->name, v->name, b); b = true; @@ -964,7 +967,7 @@ if (p->values) { free_all_values(p->values->next); p->values->next = nullptr; - p->count = 0; + p->count = 0; if (EQ(p->values->name, valname)) return; else { @@ -973,9 +976,9 @@ } } else { - v = new_value(strcache(valname)); + v = new_value(strcache(valname)); p->values = v; - p->count = 0; + p->count = 0; } } } @@ -983,7 +986,7 @@ MvRequest MvRequest::ExpandRequest(const char* defName, const char* rulesName, long expandFlag) { // Create the full path - std::string sdef = MakeSystemEtcPath(defName); + std::string sdef = MakeSystemEtcPath(defName); std::string srules = MakeSystemEtcPath(rulesName); MvLanguage langMetview(sdef.c_str(), srules.c_str(), expandFlag); @@ -1004,9 +1007,9 @@ return false; } - //Handle relative paths + // Handle relative paths else if (resPath[0] != '/') { - //If _MACRO and _PATH is defined it means this was run from a macro + // If _MACRO and _PATH is defined it means this was run from a macro // if (const char* fromMacro = (*this)("_MACRO")) { @@ -1026,18 +1029,18 @@ } } - //We try to use the path of the icon the request belongs to + // We try to use the path of the icon the request belongs to const char* callerIcon = (*this)("_NAME"); if (callerIcon) { std::string callerDir(callerIcon); - //special case: if callerDir is a path with "Process@" in it, then it - //very probably means that this was run from a macro - in this case, we can't - //use the returned path (because it's invalid). If we are here the logic behind - //the path resolving technique is wrong, because the path should have been resolved - //in the if block above! - //As a fallback solution we suppose that the path is relative to where the macro is run - //from; so in this case we would simplyremove the path. + // special case: if callerDir is a path with "Process@" in it, then it + // very probably means that this was run from a macro - in this case, we can't + // use the returned path (because it's invalid). If we are here the logic behind + // the path resolving technique is wrong, because the path should have been resolved + // in the if block above! + // As a fallback solution we suppose that the path is relative to where the macro is run + // from; so in this case we would simplyremove the path. if (callerDir.find("Process@") != std::string::npos) { // yes, it's called from Macro - files are relative to current dir @@ -1086,14 +1089,14 @@ { errTxt.clear(); - MvRequest dataR = (*this)(iconPar); + MvRequest dataR = (*this)(iconPar); const char* dataPath = dataR("PATH"); - //First try to get the path from the icon object + // First try to get the path from the icon object if (dataPath) { resPath = std::string(dataPath); } - //If there is no icon we use the text parameter to get the path + // If there is no icon we use the text parameter to get the path else { if (textPar) { std::string s(textPar); @@ -1313,7 +1316,7 @@ { if (LastGet) add_value(Request->CurrentRequest, LastGet, "%.12g", val); - LastGet = nullptr; + LastGet = nullptr; LastIndex = 0; } @@ -1417,7 +1420,7 @@ // Name without the Metview user directory path std::string user_dir = GetUserDirectory(); - std::size_t found = fullPath.find(user_dir); + std::size_t found = fullPath.find(user_dir); if (found != std::string::npos) reqAux("_NAME") = fullPath.substr(found + user_dir.size()).c_str(); else @@ -1493,8 +1496,8 @@ const char *v1, *v2; const char* par = param.c_str(); - int cnt1 = this->iterInit(par); - int cnt2 = req.iterInit(par); + int cnt1 = this->iterInit(par); + int cnt2 = req.iterInit(par); if (cnt1 && (cnt1 == cnt2)) { for (int j = 0; j < cnt1; j++) { this->iterGetNextValue(v1); @@ -1523,7 +1526,7 @@ int n = in.countParameters(); for (int i = 0; i < n; i++) { const char* pch = in.getParameter(i); - MvRequest sr = in.getSubrequest(pch); + MvRequest sr = in.getSubrequest(pch); if (sr) { // marslog(LOG_INFO, "replaceDotInPath: check subrequest=%s", pch); replaceDotInPath(sr); @@ -1549,3 +1552,89 @@ } return {}; } + +bool MvRequest::paramsEqual(MvRequest& req1, MvRequest& req2, + const std::string& name, + const std::string& label1, const std::string& label2, + std::string& msg) +{ + msg.clear(); + int num1 = req1.countValues(name.c_str()); + int num2 = req2.countValues(name.c_str()); + std::string inLabel1 = (!label1.empty()) ? ("in " + label1) : " in first request"; + std::string inLabel2 = (!label2.empty()) ? ("in " + label2) : " in second request"; + + if (num1 == 0) { + msg = "No parameter " + name + " found " + inLabel1; + return false; + } + if (num2 == 0) { + msg = "No parameter " + name + " found " + inLabel2; + return false; + } + if (num1 != num2) { + msg = name + " parameter has different number of items: " + + std::to_string(num1) + " (" + inLabel1 + ") and " + + std::to_string(num2) + " (" + inLabel2 + ")"; + return false; + } + + if (num1 == 1) { + std::string val1, val2; + req1.getValue(name, val1, true); + req2.getValue(name, val2, true); + if (val1 != val2) { + msg = name + " parameter has two different values: " + + val1 + " (" + inLabel1 + ") and " + val2 + " (" + inLabel2 + ")"; + return false; + } + } + else { + std::vector vec1, vec2; + req1.getValue(name, vec1, true); + req2.getValue(name, vec2, true); + std::string val1 = metview::merge(vec1, "/"); + std::string val2 = metview::merge(vec2, "/"); + if (val1 != val2) { + msg = name + " parameter has two different values: " + + val1 + " (" + inLabel1 + ") and " + val2 + " (" + inLabel2 + ")"; + return false; + } + } + + return true; +} + +bool MvRequest::paramEqualToVerb(MvRequest& req1, MvRequest& req2, + const std::string& name, + const std::string& label1, const std::string& label2, + std::string& msg) +{ + msg.clear(); + std::string inLabel1 = (!label1.empty()) ? ("in " + label1) : " in first request"; + std::string inLabel2 = (!label2.empty()) ? ("in " + label2) : " in second request"; + std::string val1, val2; + + if (const char* ch = (const char*)req1(name.c_str())) { + val1 = std::string(ch); + } + else { + msg = "No parameter " + name + " found " + inLabel1; + return false; + } + std::cout << "val1=" << val1 << std::endl; + if (const char* ch = req2.getVerb()) { + val2 = std::string(ch); + } + else { + msg = "No verb found " + inLabel2; + return false; + } + + if (val1 != val2) { + msg = name + " parameter " + inLabel1 + " does not match verb " + inLabel2 + + ": " + val1 + " != " + val2; + return false; + } + return true; +} diff -Nru metview-5.17.4/metview/src/libMetview/MvRequest.h metview-5.19.2/metview/src/libMetview/MvRequest.h --- metview-5.17.4/metview/src/libMetview/MvRequest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvRequest.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ #include #include -//!Class to help to access and convert values from/to a request +//! Class to help to access and convert values from/to a request /*! Metview provides classes MvRequest, MvAccess and MvConstAccess * that deal with the request structure. * @@ -193,13 +193,13 @@ //! Constructor to create an empty request /*! The command (request) name is taken from argument 'verb'. - */ + */ MvRequest(const char* verb); //! Creates a MvRequest from libMars request structure 'req' /*! If argument 'clone' is true, a copy of 'req' is done, - * otherwise a pointer to 'req' itself is stored in MvRequest. - */ + * otherwise a pointer to 'req' itself is stored in MvRequest. + */ MvRequest(request* req = nullptr, boolean clone = true, boolean free_req = true); //! Copy constructor @@ -211,20 +211,20 @@ //! Assignment operator MvRequest& operator=(const MvRequest& r); - //MvRequest& operator = (const request*); + // MvRequest& operator = (const request*); void copyFromCurrent(const MvRequest&); void copyFromCurrentTo(const MvRequest&, const char* verb); //! Concatenation operator /*! The operator+ concatenates two MvRequest and returns the resulting - * MvRequest.\n \n - * Example: - *
-	 *    MvRequest r1("FIRST"), r2("SECOND"), r3;
-	 *    r3 = r1 + r2;   //-- r3 contains FIRST concatenated to SECOND
-	 * 
- */ + * MvRequest.\n \n + * Example: + *
+     *    MvRequest r1("FIRST"), r2("SECOND"), r3;
+     *    r3 = r1 + r2;   //-- r3 contains FIRST concatenated to SECOND
+     * 
+ */ MvRequest operator+(const MvRequest& r) const; //! Concatenates an MvRequest to an existing MvRequest, e.g. a += b; @@ -238,28 +238,28 @@ //! Access the 'n'th value in list parameter 'p' /*! Returns a MvAccess object, which normally is not visible - * in user code (like in the example below).\n \n - * NOTE 1: Method uses C style indexing (n=0,1,...).\n - * NOTE 2: To access long lists of values, it is better to use - * methods 'iterInit' and 'iterGetNextValue'.\n \n - * Example: - *
-	 *    MvRequest r1("RETRIEVE"); //-- RETRIEVE
-	 *    r1("LEVELIST") = 500;     //-- RETRIEVE,LEVELIST=500
-	 *    r1("LEVELIST",1) = 750;   //-- RETRIEVE,LEVELIST=500/750
-	 *    //...
-	 *    const char* lev = r1("LEVELIST",1);//-- lev points to "750"
-	 * 
- * Note that the example above could have been written also like this: - *
-	 *    MvRequest r1("RETRIEVE");     //-- RETRIEVE
-	 *    r1.setValue("LEVELIST",500);  //-- RETRIEVE,LEVELIST=500
-	 *    r1.addValue("LEVELIST",750);  //-- RETRIEVE,LEVELIST=500/750
-	 *    //...
-	 *    const char* lev;
-	 *    r1.getValue(lev,"LEVELIST",1);//-- lev points to "750"
-	 * 
- */ + * in user code (like in the example below).\n \n + * NOTE 1: Method uses C style indexing (n=0,1,...).\n + * NOTE 2: To access long lists of values, it is better to use + * methods 'iterInit' and 'iterGetNextValue'.\n \n + * Example: + *
+     *    MvRequest r1("RETRIEVE"); //-- RETRIEVE
+     *    r1("LEVELIST") = 500;     //-- RETRIEVE,LEVELIST=500
+     *    r1("LEVELIST",1) = 750;   //-- RETRIEVE,LEVELIST=500/750
+     *    //...
+     *    const char* lev = r1("LEVELIST",1);//-- lev points to "750"
+     * 
+ * Note that the example above could have been written also like this: + *
+     *    MvRequest r1("RETRIEVE");     //-- RETRIEVE
+     *    r1.setValue("LEVELIST",500);  //-- RETRIEVE,LEVELIST=500
+     *    r1.addValue("LEVELIST",750);  //-- RETRIEVE,LEVELIST=500/750
+     *    //...
+     *    const char* lev;
+     *    r1.getValue(lev,"LEVELIST",1);//-- lev points to "750"
+     * 
+ */ MvAccess operator()(const char* p, int n) { return MvAccess(this, p, n); } //! Read the (first) value of parameter 'p' @@ -267,10 +267,10 @@ //! Read the 'n'th value from list parameter 'p' /*! Returns a MvConstAccess object, which normally is not visible.\n \n - * NOTE 1: Method uses C style indexing (n=0,1,...).\n - * NOTE 2: To access long lists of values, it is better to use - * methods 'iterInit' and 'iterGetNextValue'. - */ + * NOTE 1: Method uses C style indexing (n=0,1,...).\n + * NOTE 2: To access long lists of values, it is better to use + * methods 'iterInit' and 'iterGetNextValue'. + */ MvConstAccess operator()(const char* p, int n) const { return MvConstAccess(this, p, n); @@ -318,75 +318,75 @@ //! Initialise the list iterator for a list valued parameter /*! Using method 'operator()(const char* p,int n)' to access - * list valued parameters where the list contains thousands - * of values, gets very slow. The required time with this - * method grows exponentially, relative to the lenght of - * the list. - * - * Methods 'iterInit' and 'iterGetNextValue' are provided - * to speed up accessing such long list valued parameters. - * The required time with this iterator method grows - * linearly, relative to the length of the list. - * - * Use method 'iterInit' to tell the list iterator which parameter - * contains the list to be iterated, and to get the length of - * the list. Then use 'iterGetNextValue' to read each value, - * one by one. - * - * Example on how to read curve X and Y values from MvRequest - * 'req' into double arrays x[] and y[]: - *
-	 *    int cnt = req.iterInit( "X_VALUES" );
-	 *    for( int i=0; i
-	 *  The following code will do the same, but here the required
-	 *  computing resources grow exponentially:
-	 * 
-	 *    int cnt = req.countValues( "X_VALUES" ); //-- assume ok also for Y
-	 *    for( int i=0; i
-	 */
+     *  list valued parameters where the list contains thousands
+     *  of values, gets very slow. The required time with this
+     *  method grows exponentially, relative to the lenght of
+     *  the list.
+     *
+     *  Methods 'iterInit' and 'iterGetNextValue' are provided
+     *  to speed up accessing such long list valued parameters.
+     *  The required time with this iterator method grows
+     *  linearly, relative to the length of the list.
+     *
+     *  Use method 'iterInit' to tell the list iterator which parameter
+     *  contains the list to be iterated, and to get the length of
+     *  the list. Then use 'iterGetNextValue' to read each value,
+     *  one by one.
+     *
+     *  Example on how to read curve X and Y values from MvRequest
+     *  'req' into double arrays x[] and y[]:
+     * 
+     *    int cnt = req.iterInit( "X_VALUES" );
+     *    for( int i=0; i
+     *  The following code will do the same, but here the required
+     *  computing resources grow exponentially:
+     * 
+     *    int cnt = req.countValues( "X_VALUES" ); //-- assume ok also for Y
+     *    for( int i=0; i
+     */
     int iterInit(const char* param);  //-- returns 'param' count
 
     //! Get current value as 'char*' and advance the list iterator
     /*! If no more values are available in the list, returns
-	 *  'false' and sets argument 'val' to 0 (nullptr);
-	 *  otherwise returns 'true' and returns the current list
-	 *  item in argument 'val', and then advances the list iterator.
-	 */
+     *  'false' and sets argument 'val' to 0 (nullptr);
+     *  otherwise returns 'true' and returns the current list
+     *  item in argument 'val', and then advances the list iterator.
+     */
     bool iterGetNextValue(const char*& val);
 
     //! Get current value as 'double' and advance the list iterator
     /*! If no more values are available in the list, returns
-	 *  'false' and sets argument 'val' to 0;
-	 *  otherwise returns 'true' and returns the current list
-	 *  item in argument 'val', and then advances the list iterator.
-	 */
+     *  'false' and sets argument 'val' to 0;
+     *  otherwise returns 'true' and returns the current list
+     *  item in argument 'val', and then advances the list iterator.
+     */
     bool iterGetNextValue(double& val);
 
     // -----
     //! Advance to the next subrequest
     /*! When a MvRequest object contains more than one request in a single
-	 *  linked list, this method allows the sequential access to all of them.
-	 *  Each time this method is called, it advances the current request
-	 *  to the next one in the list and returns it. nullptr is returned when
-	 *  the current request points to the end of the list.\n \n
-	 *  Example:
-	 * 
-	 *    MvRequest r1("FIRST"), r2("SECOND"), r3, r4;
-	 *    r3 = r1 + r2;      // r3 contains FIRST concatenated to SECOND
-	 *    r4 = r3.advance(); // r4 contain only SECOND request.
-	 * 
- */ + * linked list, this method allows the sequential access to all of them. + * Each time this method is called, it advances the current request + * to the next one in the list and returns it. nullptr is returned when + * the current request points to the end of the list.\n \n + * Example: + *
+     *    MvRequest r1("FIRST"), r2("SECOND"), r3, r4;
+     *    r3 = r1 + r2;      // r3 contains FIRST concatenated to SECOND
+     *    r4 = r3.advance(); // r4 contain only SECOND request.
+     * 
+ */ MvRequest& advance(); // Advance to the next verb request @@ -400,14 +400,14 @@ //! Rewind the whole request /*! This method rewinds the linked list and returns - * the first request in the list. - */ + * the first request in the list. + */ MvRequest& rewind(); //! Extracts the current (sub)request from a (multi) request list structure /*! Use this method if you need to modify and/or forward just one - * subrequest that is embedded in a MvRequest containing many subrequests. - */ + * subrequest that is embedded in a MvRequest containing many subrequests. + */ MvRequest justOneRequest() const; // Get just one request // ----- @@ -451,36 +451,36 @@ //! Initialize Parameter structure /*! If structure Parameter is empty, returns 'false'; - * otherwise, returns 'true'. - */ + * otherwise, returns 'true'. + */ bool iterInitParam(); //! Get 'Interface' request from the current 'parameter' //! and advance the list iterator /*! If no more parameter is available in the current request, - * returns 'false' and sets output request to empty; - * otherwise, returns 'true' and returns the Interface request - * related to the current parameter. - */ + * returns 'false' and sets output request to empty; + * otherwise, returns 'true' and returns the Interface request + * related to the current parameter. + */ bool iterGetNextParamInterface(MvRequest&); //! Merges input request with current MvRequest using 'update' function /*! This function does a "partial merge". Only common parameters are updated, - * i.e. those parameters in 'req' that do not exist in the current object are skipped. - */ + * i.e. those parameters in 'req' that do not exist in the current object are skipped. + */ void merge(const MvRequest& req); //! Merges input request with current MvRequest using a function from Mars /*! This function does a "full merge" using Mars function 'reqcpy()'. - * If requests contain parameters with same names, it looks like the - * the values from 'req' overwrite original values (needs to be checked). - */ + * If requests contain parameters with same names, it looks like the + * the values from 'req' overwrite original values (needs to be checked). + */ void mars_merge(const MvRequest& req); //! Update current MvRequest. /*! This routine is similar to 'mars_merge' function - * but only common parameters are updated - */ + * but only common parameters are updated + */ void update(const MvRequest&); // Convert request to upper/lower case @@ -511,19 +511,19 @@ //! Returns the number of values in parameter 'pname' /*! Mostly used for list valued parameters - */ + */ int countValues(const char* pname) const; //! Prints the request to standard output /*! Hidden parameters are not printed (unless -DEBUG flag - * is used, or mars.debug is set to non-zero) - */ + * is used, or mars.debug is set to non-zero) + */ void print(bool force = false) const; //! Reads a request from file named 'file'. /*! if the second parameter is true then any request parameter, - * which is an icon (subrequest), will be expanded - */ + * which is an icon (subrequest), will be expanded + */ void read(const char* file, bool expand = false, bool shidden = false); //! Saves a request into file named 'file' @@ -537,9 +537,9 @@ //! Handles parameters marked with "_APPLICATION_OVERRIDES" in 'req' /*! All parameters marked with "_APPLICATION_OVERRIDES" parameter - * in 'req' are either replaced (if a new value is given in 'req') - * or unset (if no new value given in 'req'). - */ + * in 'req' are either replaced (if a new value is given in 'req') + * or unset (if no new value given in 'req'). + */ void appOverrides(MvRequest& req); #if 0 @@ -585,7 +585,10 @@ //! Removes everything, making the request empty void clean(); - bool isEmpty() { return (FirstRequest == 0); } + bool isEmpty() + { + return (FirstRequest == 0); + } // Get the Object request given its name request* findRequestObject(); @@ -597,7 +600,7 @@ // Get the base date from the request (specific to request from GRIB data) int getBaseDate(); - //Find out path (it can be relative path as well) stored in parameter par. + // Find out path (it can be relative path as well) stored in parameter par. bool getPath(const std::string& par, std::string& resPath, bool canBeEmpty) const; bool getPath(const char* iconPar, const char* textPar, std::string& resPath, bool canBeEmpty, std::string& errTxt); bool getPathAndReplace(const std::string& par, std::string& resPath, const std::string& replaceFrom, @@ -624,6 +627,17 @@ static void replaceDotInPath(MvRequest& in); std::string toJson() const; + + + static bool paramsEqual(MvRequest& req1, MvRequest& req2, + const std::string& name, + const std::string& label1, const std::string& label2, + std::string& msg); + + static bool paramEqualToVerb(MvRequest& req1, MvRequest& req2, + const std::string& name, + const std::string& label1, const std::string& label2, + std::string& msg); }; //! Convenience class (not used currently) @@ -636,14 +650,14 @@ public: //! Constructor for NUMBER request /*! Creates a NUMBER request with a VALUE parameter. - * Argument 'v' is assigned as the value for VALUE. - */ + * Argument 'v' is assigned as the value for VALUE. + */ MvValue(double v); //! Constructor for STRING request /*! Creates a STRING request with a VALUE parameter. - * Argument 's' is assigned as the value for VALUE. - */ + * Argument 's' is assigned as the value for VALUE. + */ MvValue(const char* s); }; diff -Nru metview-5.17.4/metview/src/libMetview/MvRequestUtil.cc metview-5.19.2/metview/src/libMetview/MvRequestUtil.cc --- metview-5.17.4/metview/src/libMetview/MvRequestUtil.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvRequestUtil.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,10 +12,11 @@ #include #include -namespace metview { +namespace metview +{ void copyParam(const MvRequest& inRequest, MvRequest& outRequest, - const std::string& oldName, const std::string& newName) + const std::string& oldName, const std::string& newName) { int n = inRequest.countValues(oldName.c_str()); outRequest.unsetParam(oldName.c_str()); @@ -150,7 +151,7 @@ const std::string& sufix) { unsigned int length = sufix.size(); - int count = inRequest.countParameters(); + int count = inRequest.countParameters(); for (int i = 0; i < count; i++) { std::string param = (const char*)inRequest.getParameter(i); if (param.size() < length) // no need to compare @@ -158,7 +159,7 @@ if (param.compare(param.size() - length, length, sufix) == 0) { const char* cparam = param.c_str(); - int n = inRequest.countValues(cparam); + int n = inRequest.countValues(cparam); for (int j = 0; j < n; j++) { const char* value = nullptr; inRequest.getValue(value, cparam, j); @@ -184,8 +185,8 @@ void RemoveParameters(MvRequest& req, const char* prefix) { MvRequest aux = req; - int length = strlen(prefix); - int count = req.countParameters(); + int length = strlen(prefix); + int count = req.countParameters(); for (int i = 0; i < count; i++) { const char* param = aux.getParameter(i); if (strncmp(param, prefix, length) == 0) @@ -209,11 +210,11 @@ bool AreEqualRequests(MvRequest& req1, MvRequest& req2) { int count = req1.countParameters(); - int i = -1; + int i = -1; if (count == req2.countParameters()) { for (i = 0; i < count; i++) { const char* param = req1.getParameter(i); - int n = req1.countValues(param); + int n = req1.countValues(param); int j; for (j = 0; j < n; j++) { const char* value2 = nullptr; @@ -268,11 +269,11 @@ // Move output TEXT_LINE_* forward according to // input TEXT_LINE_COUNT - int inCount = inRequest("TEXT_LINE_COUNT"); + int inCount = inRequest("TEXT_LINE_COUNT"); int outCount = outRequest("TEXT_LINE_COUNT"); if (inCount) { // Define constants - char saux[13]; //TEXT_LINE_* + char saux[13]; // TEXT_LINE_* int MAXCOUNT = 10; int size; @@ -316,11 +317,11 @@ if (index != -1 || !inRequestOld) outRequest("_STACKING_ORDER") = index; else { - const char* corder = (const char*)inRequestOld("_STACKING_ORDER"); + const char* corder = (const char*)inRequestOld("_STACKING_ORDER"); outRequest("_STACKING_ORDER") = (int)(corder ? atoi(corder) : -1); } return; } -} +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/MvRequestUtil.hpp metview-5.19.2/metview/src/libMetview/MvRequestUtil.hpp --- metview-5.17.4/metview/src/libMetview/MvRequestUtil.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvRequestUtil.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,8 @@ #include -namespace metview { +namespace metview +{ void copyParam(const MvRequest& inRequest, MvRequest& outRequest, const std::string& oldName, const std::string& newName); @@ -59,4 +60,4 @@ // Copy a request taking into consideration the Drawing Order parameter void CopyParametersAndStackingOrder(const MvRequest& inRequestOld, const MvRequest& inRequestNew, int index, MvRequest& outRequest); -} +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/MvRttov.cc metview-5.19.2/metview/src/libMetview/MvRttov.cc --- metview-5.17.4/metview/src/libMetview/MvRttov.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvRttov.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,9 @@ A skeleton of such a file looks like: - # RTTOV OUTPUT + # RTTOV OUTPUT ----------------- - Instrument iasi + Instrument iasi ----------------- ... ... @@ -27,10 +27,10 @@ OUTPUT: CHANNEL BRIGHTNESS TEMPERATURE EMISSIVITY: - - 1 218.8644864351669 0.9531080000000000 - 2 218.8867066300515 0.9531470000000000 - .... + + 1 218.8644864351669 0.9531080000000000 + 2 218.8867066300515 0.9531470000000000 + .... JACOBIANS: 0.0000E+00 1 2 3 ... @@ -52,7 +52,7 @@ MvRttov::MvRttov() { - fileName_ = "NO FILE SPECIFIED"; + fileName_ = "NO FILE SPECIFIED"; currentLine_ = 0; } @@ -106,7 +106,7 @@ // look for the start of the tb data std::string headerString = "OUTPUT:"; - bool found = searchForLineContainingString(in, headerString); + bool found = searchForLineContainingString(in, headerString); if (!found) // could not find the start of the data? { @@ -122,7 +122,7 @@ getline(in, line); // first, skip the blank line between the header and the data currentLine_++; - int channel; + int channel = 0; double tb, emis; bool endOfData = false; while (!endOfData && !in.eof()) { @@ -145,7 +145,7 @@ // ----- look for the start of the Jacobian data ----- headerString = "JACOBIANS:"; - found = searchForLineContainingString(in, headerString); + found = searchForLineContainingString(in, headerString); if (!found) // could not find the start of the data? { @@ -162,7 +162,7 @@ tableReader.setConsecutiveDelimitersAsOne(true); std::string errorMsg; - bool ret; + bool ret = 0; ret = tableReader.getMetaData(errorMsg); diff -Nru metview-5.17.4/metview/src/libMetview/MvScanFileType.cc metview-5.19.2/metview/src/libMetview/MvScanFileType.cc --- metview-5.17.4/metview/src/libMetview/MvScanFileType.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvScanFileType.cc 2023-07-15 08:28:47.000000000 +0000 @@ -77,6 +77,9 @@ public: File(const char* name, const char* mode) { f_ = fopen(name, mode); } ~File() { close(); } + File(const File&) = delete; + File& operator=(const File&) = delete; + void close() { if (f_) @@ -100,7 +103,7 @@ if (!f.f_) return eMissingFile; //-- missing file - bool isBinary = false; + bool isBinary = false; bool isNumbersOnly = true; const int CHECKLEN = 4000; //-- may be a huge PostScript file //-- => check beginning only is ok @@ -148,10 +151,10 @@ "WS_MARKER", "WS_SHAPE", "WS_SHEARLINE", "WS_STORM", "WS_TEXT", "WS_TROPICALWAVE", "WS_TROUGH", "WS_WARMFRONT", "WS_WMOSYMBOL", "WS_COLLECTION"}; - static char startBraceCh = '{'; - static std::string quoteCh = "\""; + static char startBraceCh = '{'; + static std::string quoteCh = "\""; static std::string classStr = "\"class_ws\":"; - static std::string conv = "metview-ws"; + static std::string conv = "metview-ws"; if (!f.f_) return nullptr; @@ -199,9 +202,9 @@ return nullptr; } -//inline static bool scan_file_extension(const char* file, int length, const char* ext) +// inline static bool scan_file_extension(const char* file, int length, const char* ext) //{ -// int ext_length = strlen(ext); +// int ext_length = strlen(ext); // return (length >= ext_length && !strcasecmp(&file[length - ext_length], ext)); //} @@ -212,7 +215,7 @@ std::string fn(file); auto pos = fn.find_last_of("."); if (pos != 0 && pos != std::string::npos && pos + 1 != fn.size()) { - suffix1 = fn.substr(pos); + suffix1 = fn.substr(pos); auto pos2 = fn.find_last_of(".", pos - 1); if (pos != 0 && pos2 != std::string::npos && pos2 + 1 != pos) { suffix2 = fn.substr(pos2); @@ -238,7 +241,7 @@ while ((dirp = readdir(dp)) != nullptr) { std::string name(dirp->d_name); - //std::cout << "dir: " << name; + // std::cout << "dir: " << name; if ((pos = name.find(".sch")) != std::string::npos && name.size() >= 5 && pos > 0 && pos + 4 == name.size()) { retval = true; @@ -263,8 +266,12 @@ // store the suffix based mappings in hash tables static std::unordered_map doubleSuffixMap = { {".tar.gz", "TAR_GZ"}, - {".tar.bz", "TAR_BZ"}, + {".tar.gzip", "TAR_GZ"}, + {".tar.bz", "TAR_BZ2"}, {".tar.bz2", "TAR_BZ2"}, + {".tar.bzip2", "TAR_BZ2"}, + {".tar.z", "TAR_Z"}, + {".tar.Z", "TAR_Z"}, {".geo.json", "GEOJSON"}}; static std::unordered_map singleSuffixMap = { @@ -289,13 +296,25 @@ {".geojson", "GEOJSON"}, {".jpg", "JPEG"}, {".jpeg", "JPEG"}, - {".py", "PYTHON"}}; + {".py", "PYTHON"}, + {".tgz", "TAR_GZ"}, + {".tbz", "TAR_BZ2"}, + {".tbz2", "TAR_BZ2"}, + {".tz", "TAR_Z"}, + {".gz", "GZ"}, + {".gzip", "GZ"}, + {".bz", "BZ2"}, + {".bz2", "BZ2"}, + {".bzip2", "BZ2"}, + {".z", "Z"}, + {".Z", "Z"}, + {".zip", "ZIP"}}; static const char* scan_file(const char* file) { - static const int cMAXSHIFT = 8; //-- search tolerance for word "GRIB" or "BUFR" - static const int cMINREAD = 4; //-- need to be able to read at least this much -// static const std::string cGEOJSON = ".geojson"; + static const int cMAXSHIFT = 8; //-- search tolerance for word "GRIB" or "BUFR" + static const int cMINREAD = 4; //-- need to be able to read at least this much + // static const std::string cGEOJSON = ".geojson"; static const char* cGEOJSON = "GEOJSON"; File f(file, "r"); @@ -305,7 +324,7 @@ // Determine type by the suffixes std::string suffix1, suffix2; - bool geojsonBySuffix=false; + bool geojsonBySuffix = false; if (get_file_extension(file, suffix1, suffix2)) { if (!suffix2.empty()) { metview::toLower(suffix2); @@ -334,7 +353,8 @@ auto ws = isWeatherSymbolJson(f); if (ws) { return ws; - } else { + } + else { return cGEOJSON; } } @@ -438,12 +458,6 @@ else if (strncmp(buf.ch, "name() != nullptr && - strcmp(att->name(), "dataID") == 0 && att->getNumberOfValues() > 0) //F num_vals() + strcmp(att->name(), "dataID") == 0 && att->getNumberOfValues() > 0) // F num_vals() { auto vStr = att->as_string(0); if (!vStr.empty()) { @@ -636,8 +650,8 @@ } } } - //F if(att != nullptr) - //F delete att; + // F if(att != nullptr) + // F delete att; } return "NETCDF"; diff -Nru metview-5.17.4/metview/src/libMetview/MvSci.cc metview-5.19.2/metview/src/libMetview/MvSci.cc --- metview-5.17.4/metview/src/libMetview/MvSci.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvSci.cc 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,7 @@ #include "MvSci.h" -#include +#include #ifdef METVIEW #include "MvDate.h" @@ -30,24 +30,24 @@ const double cR3IES = 22.587; const double cR4LES = 32.19; const double cR4IES = -0.7; -const double cRD = 287.05; -//specific heat of air on constant volume +const double cRD = 287.05; +// specific heat of air on constant volume const double cRV = 461.51; -//specific heat of air on constant pressure -const double cRP = 1005.46; -const double cKAPPA = cRD / cRP; -const double cEP = cRD / cRV; -const double cCI = 2710.; -const double cRESTT = 611.21; -const double cR2ES = cRESTT * cRD / cRV; +// specific heat of air on constant pressure +const double cRP = 1005.46; +const double cKAPPA = cRD / cRP; +const double cEP = cRD / cRV; +const double cCI = 2710.; +const double cRESTT = 611.21; +const double cR2ES = cRESTT * cRD / cRV; const double cVTMPC1 = cRV / cRD - 1.; -const double MvSci::cRadian = 180. / M_PI; -const double MvSci::cDegree = 1 / MvSci::cRadian; -const double RAD2 = 2 * MvSci::cRadian; // 360/pi -const double MvSci::cRadianToMetre = 1852 *180.0 * 60.0 / M_PI; -const double MvSci::cMetreToRadian = 1./MvSci::cRadianToMetre; +const double MvSci::cRadian = 180. / M_PI; +const double MvSci::cDegree = 1 / MvSci::cRadian; +const double RAD2 = 2 * MvSci::cRadian; // 360/pi +const double MvSci::cRadianToMetre = 1852 * 180.0 * 60.0 / M_PI; +const double MvSci::cMetreToRadian = 1. / MvSci::cRadianToMetre; -//const double cEPSILON = 0.621981; +// const double cEPSILON = 0.621981; // Computes the distance on Earth in km double MvSci::geoDistanceInKm(double fi1, double la1, double fi2, double la2) @@ -66,14 +66,14 @@ } } -//void MvSci::latLonToXyz(double lat, double lon, double &x, double &y, double &z) +// void MvSci::latLonToXyz(double lat, double lon, double &x, double &y, double &z) //{ -// double lat = degToRad(lat); -// double lon = degToRad(lon); -// x = cos(lon)*cos(lat); -// y = sin(lon)*cos(lat); -// z = sin(lat); -//} +// double lat = degToRad(lat); +// double lon = degToRad(lon); +// x = cos(lon)*cos(lat); +// y = sin(lon)*cos(lat); +// z = sin(lat); +// } /*! \brief computes the saturation mixing ratio @@ -105,7 +105,7 @@ double MvSci::relativeHumidity(double t, double p, double q) { double es = saturationVapourPressure(t); - double e = vapourPressure(p, q); + double e = vapourPressure(p, q); return e / es; } @@ -140,7 +140,7 @@ double MvSci::specificHumidity(double t, double p, double r) { double ws = saturationMixingRatio(t, p); - double w = r * ws; + double w = r * ws; return w / (1. + w); } @@ -174,21 +174,21 @@ double MvSci::saturationVapourPressure(double t) { - double c1 = 611.21; + double c1 = 611.21; double c3l = 17.502; double c4l = 32.19; double c3i = 22.587; double c4i = -0.7; - double t0 = 273.16; - double ti = 250.16; + double t0 = 273.16; + double ti = 250.16; - //Saturation vapour pressure over water + // Saturation vapour pressure over water double es_water = c1 * exp(c3l * (t - t0) / (t - c4l)); - //Saturation vapour pressure over ice + // Saturation vapour pressure over ice double es_ice = c1 * exp(c3i * (t - t0) / (t - c4i)); - //fraction of liquid water + // fraction of liquid water double alpha; if (t <= ti) alpha = 0.; @@ -256,8 +256,8 @@ double ZCVM3, ZCVM4; if (formula == cMixedFormula) { - double rtwat = cTMELT; - double rtice = cTMELT - 23.0; + double rtwat = cTMELT; + double rtice = cTMELT - 23.0; double foealfa = std::min(1., pow(((std::max(rtice, std::min(rtwat, t)) - rtice) / (rtwat - rtice)), 2.0)); ZCVM3 = foealfa * cR3LES + (1. - foealfa) * cR3IES; @@ -322,23 +322,23 @@ // q specific humidity in kg/kg bool MvSci::saturationLevel(double t, double p, double q, double& tSat, double& pSat, bool flag) { - int count = 0; + int count = 0; const int maxIter = 20; if (q < 0.000002 && p > 10000.) q = 0.000002; double pSatLimit = p * 0.2; - pSat = p * 0.98; - tSat = t; + pSat = p * 0.98; + tSat = t; while (count < maxIter) { - tSat = t * pow(pSat / p, cKAPPA); - double qSat = saturationSpecHumidity(tSat, pSat, flag); + tSat = t * pow(pSat / p, cKAPPA); + double qSat = saturationSpecHumidity(tSat, pSat, flag); double tSatTop = t * pow((pSat - 100.) / p, cKAPPA); double qSatTop = saturationSpecHumidity(tSatTop, (pSat - 100.), flag); - double ratio = (qSat - q) / (qSat - qSatTop); - //dp = p - pSat; + double ratio = (qSat - q) / (qSat - qSatTop); + // dp = p - pSat; if (fabs(ratio) < 1.) { return true; } @@ -351,7 +351,7 @@ count++; } - //error + // error return false; } @@ -485,7 +485,7 @@ { static const double cSOLARDEC1 = sin(-cDegree * 23.44); static const double cSOLARDEC2 = 360.0 / 365.24; - static double cSOLARDEC3 = RAD2 * 0.0167; + static double cSOLARDEC3 = RAD2 * 0.0167; MvDate vdt(dateTime); auto N = vdt.dayOfTheYear(); @@ -500,13 +500,13 @@ return -M_PI / 2.; } return -999.; - //return MvSci::degToRad(23.44 * cos(MvSci::degToRad((360./365.)*(N+10.)))); + // return MvSci::degToRad(23.44 * cos(MvSci::degToRad((360./365.)*(N+10.)))); } double MvSci::cosineSolarZenithAngle(double lat, double lon, double declInRad, double hourAngleGM) { auto latRad = degToRad(lat); - //local hour angle + // local hour angle auto h = MvSci::degToRad(hourAngleGM + lon); return sin(latRad) * sin(declInRad) + cos(latRad) * cos(declInRad) * cos(h); } diff -Nru metview-5.17.4/metview/src/libMetview/MvSci.h metview-5.19.2/metview/src/libMetview/MvSci.h --- metview-5.17.4/metview/src/libMetview/MvSci.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvSci.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,12 +21,12 @@ static const double cMetreToRadian; static const double cRadianToMetre; - static double degToRad(double d) {return d * cDegree;} - static double radToDeg(double r) {return r * cRadian;} - static double metresToRadians(double m) {return m*cMetreToRadian;} - static double radiansToMetres(double r) {return r*cRadianToMetre;} + static double degToRad(double d) { return d * cDegree; } + static double radToDeg(double r) { return r * cRadian; } + static double metresToRadians(double m) { return m * cMetreToRadian; } + static double radiansToMetres(double r) { return r * cRadianToMetre; } static double geoDistanceInKm(double fi1, double la1, double fi2, double la2); - //static void latLonToXyz(double lat, double lon, double &x, double &y, double &z); + // static void latLonToXyz(double lat, double lon, double &x, double &y, double &z); static double saturationMixingRatio(double t, double p); static double relativeHumidity(double t, double p, double q); static double relativeHumidityFromTd(double t, double td); @@ -40,7 +40,7 @@ static double speed(double u, double v); static double direction(double u, double v); static double saturationSpecHumidity(double t, double p, bool flag); - static bool saturationLevel(double t, double p, double q, double& pSat, double& tSat, bool flag); + static bool saturationLevel(double t, double p, double q, double& tSat, double& pSat, bool flag); static double potentialTemperature(double t, double p); static double potentialTemperaturePressureTerm(double p); static double equivalentPotentialTemperature(double t, double p, double q, bool flag); diff -Nru metview-5.17.4/metview/src/libMetview/MvScm.cc metview-5.19.2/metview/src/libMetview/MvScm.cc --- metview-5.17.4/metview/src/libMetview/MvScm.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvScm.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ #include "MvMiscellaneous.h" #include "MvSci.h" -//A nicer solution is needed! +// A nicer solution is needed! bool MvScm::needConsistency_ = false; //========================================================= @@ -66,7 +66,7 @@ if (!var_) return; - name_ = var_->longName(); + name_ = var_->longName(); units_ = var_->units(); std::stringstream sst; @@ -75,23 +75,23 @@ stepString_ += " h"; if (var_->levelType() == MvScmVar::ModelLevelType) { - levelName_ = "Model level"; - levelUnits_ = "eta"; + levelName_ = "Model level"; + levelUnits_ = "eta"; levelDirection_ = TopDown; auxLevel_ = scm->mlVar(MvScm::PresML); if (auxLevel_) { auxLevelDefined_ = true; - auxLevelName_ = "Pressure"; - auxLevelUnits_ = "hPa"; + auxLevelName_ = "Pressure"; + auxLevelUnits_ = "hPa"; } } else if (var_->levelType() == MvScmVar::SoilLevelType) { - levelName_ = "Soil"; + levelName_ = "Soil"; levelDirection_ = TopDown; } else if (var_->levelType() == MvScmVar::SurfaceLevelType) { - levelName_ = "Surface"; + levelName_ = "Surface"; levelDirection_ = TopDown; } @@ -227,12 +227,7 @@ //========================================================= MvScmVar::MvScmVar(LevelType levelType, MvNcVar* var, const MvScmDim& timeDim) : - levelType_(levelType), - changed_(false), - presentInFile_(true), - rangeSet_(false), - consistency_(0), - unitsConverter_(0) + levelType_(levelType) { setName(var); setAttributes(var); @@ -261,7 +256,7 @@ setName(var); setAttributes(var); - int tNum = timeDim.size(); + int tNum = timeDim.size(); int levNum = levDim.size(); long counts[2]; @@ -276,7 +271,7 @@ } } -//Create a new variable that is not present in the file +// Create a new variable that is not present in the file MvScmVar::MvScmVar(const std::string& name, const std::string& longName, const std::string& units, MvScmVar* var) : name_(name), longName_(longName), @@ -387,7 +382,7 @@ if (lev >= 0 && lev < static_cast(data_.at(ts).size())) { if (dataOri_.at(ts).size() == 0) { dataOri_.at(ts) = data_.at(ts); - changed_ = true; + changed_ = true; } data_.at(ts)[lev] = val; @@ -408,10 +403,10 @@ if (lev >= 0 && lev < static_cast(data_.at(ts).size())) { if (dataOri_.at(ts).size() == 0) { dataOri_.at(ts) = data_.at(ts); - changed_ = true; + changed_ = true; } - float prevVal = data_.at(ts)[lev]; + float prevVal = data_.at(ts)[lev]; data_.at(ts)[lev] = val; ch = MvScmProfileChange(this, ts, lev, val, prevVal); @@ -436,10 +431,10 @@ for (int lev = 0; lev < levnum; lev++) { if (dataOri_.at(ts).size() == 0) { dataOri_.at(ts) = data_.at(ts); - changed_ = true; + changed_ = true; } - float prevVal = data_.at(ts)[lev]; + float prevVal = data_.at(ts)[lev]; data_.at(ts)[lev] = val; MvScmProfileChange chItem(this, ts, lev, val, prevVal); @@ -662,10 +657,10 @@ if (unitsConverter_) return; - unitsConverter_ = new MvScmUnitsConverter; + unitsConverter_ = new MvScmUnitsConverter; unitsConverter_->offset_ = offset; - unitsConverter_->scale_ = scale; - unitsConverter_->units_ = units; + unitsConverter_->scale_ = scale; + unitsConverter_->units_ = units; for (auto& ts : data_) { for (unsigned int lev = 0; lev < ts.size(); lev++) { @@ -681,13 +676,13 @@ if (ts != fromTs) { if (dataOri_.at(ts).size() == 0) { dataOri_.at(ts) = data_.at(ts); - changed_ = true; + changed_ = true; } for (int lev = 0; lev < static_cast(data_.at(ts).size()); lev++) { - //float prevVal=data_.at(ts)[lev]; + // float prevVal=data_.at(ts)[lev]; data_.at(ts)[lev] = data_.at(fromTs)[lev]; - //ch=MvScmProfileChange(this,ts,lev,val,prevVal); + // ch=MvScmProfileChange(this,ts,lev,val,prevVal); } } } @@ -727,10 +722,10 @@ fileName_(fileName), convertUnits_(convertUnits) { - //Figure out the id + // Figure out the id decodeId(); - //Map variables + // Map variables if (id_.find("SCM") != std::string::npos || id_.find("scm") != std::string::npos) { mapScmVars(); } @@ -738,7 +733,7 @@ mapRttovVars(); } - //Decode data + // Decode data decode(); } @@ -761,7 +756,7 @@ { MvNetCDF nc(fileName_, 'r'); - //Get id + // Get id int n = nc.getNumberOfAttributes(); for (int i = 0; i < n; i++) { MvNcAtt* att = nc.getAttribute(i); @@ -775,68 +770,68 @@ void MvScm::mapRttovVars() { - mlVarName_["pressure"] = PresML; - mlVarName_["height_f"] = HeightML; - mlVarName_["t"] = TempML; - mlVarName_["u"] = WindUML; - mlVarName_["v"] = WindVML; - mlVarName_["q"] = SpHumML; + mlVarName_["pressure"] = PresML; + mlVarName_["height_f"] = HeightML; + mlVarName_["t"] = TempML; + mlVarName_["u"] = WindUML; + mlVarName_["v"] = WindVML; + mlVarName_["q"] = SpHumML; mlVarName_["relative_humidity"] = RelHumML; - mlVarName_["ql"] = CloudLiqML; - mlVarName_["qi"] = CloudIceML; - mlVarName_["o3"] = OzoneML; + mlVarName_["ql"] = CloudLiqML; + mlVarName_["qi"] = CloudIceML; + mlVarName_["o3"] = OzoneML; soilVarName_["t_soil"] = TempSoil; soilVarName_["q_soil"] = HumSoil; - surfVarName_["t_skin"] = TempSurf; - surfVarName_["t_sea_ice"] = TempSeaIceSurf; - surfVarName_["open_sst"] = TempSeaSurf; + surfVarName_["t_skin"] = TempSurf; + surfVarName_["t_sea_ice"] = TempSeaIceSurf; + surfVarName_["open_sst"] = TempSeaSurf; surfVarName_["sea_ice_frct"] = SeaIceFractionSurf; - surfVarName_["t_2"] = Temp2Surf; - surfVarName_["td_2"] = Td2Surf; - surfVarName_["q_2"] = SpecHum2Surf; - surfVarName_["u_10"] = WindU10Surf; - surfVarName_["v_10"] = WindV10Surf; - surfVarName_["orog"] = OrogSurf; - surfVarName_["z_sfc"] = ZSurf; - surfVarName_["lsm"] = LsmSurf; - surfVarName_["surftype"] = LsiSurf; - surfVarName_["water_type"] = WaterTypeSurf; - surfVarName_["p_cloudtop_scs"] = CloudTopPressSurf; + surfVarName_["t_2"] = Temp2Surf; + surfVarName_["td_2"] = Td2Surf; + surfVarName_["q_2"] = SpecHum2Surf; + surfVarName_["u_10"] = WindU10Surf; + surfVarName_["v_10"] = WindV10Surf; + surfVarName_["orog"] = OrogSurf; + surfVarName_["z_sfc"] = ZSurf; + surfVarName_["lsm"] = LsmSurf; + surfVarName_["surftype"] = LsiSurf; + surfVarName_["water_type"] = WaterTypeSurf; + surfVarName_["p_cloudtop_scs"] = CloudTopPressSurf; surfVarName_["cloud_fraction_scs"] = CloudFractionSurf; - surfVarName_["lat"] = LatSurf; - surfVarName_["lon"] = LonSurf; + surfVarName_["lat"] = LatSurf; + surfVarName_["lon"] = LonSurf; dimName_["time"] = "time"; - dimName_["ml"] = "nlev"; - dimName_["pl"] = "nlevp1"; + dimName_["ml"] = "nlev"; + dimName_["pl"] = "nlevp1"; dimName_["soil"] = "nlevs"; } void MvScm::mapScmVars() { - mlVarName_["pressure_f"] = PresML; - mlVarName_["height_f"] = HeightML; - mlVarName_["t"] = TempML; - mlVarName_["u"] = WindUML; - mlVarName_["v"] = WindVML; - mlVarName_["q"] = SpHumML; + mlVarName_["pressure_f"] = PresML; + mlVarName_["height_f"] = HeightML; + mlVarName_["t"] = TempML; + mlVarName_["u"] = WindUML; + mlVarName_["v"] = WindVML; + mlVarName_["q"] = SpHumML; mlVarName_["relative_humidity"] = RelHumML; - mlVarName_["ql"] = CloudLiqML; - mlVarName_["qi"] = CloudIceML; + mlVarName_["ql"] = CloudLiqML; + mlVarName_["qi"] = CloudIceML; soilVarName_["t_soil"] = TempSoil; soilVarName_["q_soil"] = HumSoil; - surfVarName_["t_skin"] = TempSurf; + surfVarName_["t_skin"] = TempSurf; surfVarName_["t_sea_ice"] = TempSeaIceSurf; - surfVarName_["open_sst"] = TempSeaSurf; + surfVarName_["open_sst"] = TempSeaSurf; dimName_["time"] = "time"; - dimName_["ml"] = "nlev"; - dimName_["pl"] = "nlevp1"; + dimName_["ml"] = "nlev"; + dimName_["pl"] = "nlevp1"; dimName_["soil"] = "nlevs"; } @@ -845,13 +840,13 @@ { MvNetCDF nc(fileName_); - //Init dimensions + // Init dimensions timeDim_.init(nc, dimName_["time"]); modelLevDim_.init(nc, dimName_["ml"]); pressureLevDim_.init(nc, dimName_["pl"]); soilLevDim_.init(nc, dimName_["soil"]); - //Get variables + // Get variables int varNum = nc.getNumberOfVariables(); for (int i = 0; i < varNum; i++) { MvNcVar* var = nc.getVariable(i); @@ -860,19 +855,19 @@ initRelHum(); - //Get id + // Get id /*int n=nc.num_atts(); - for(int i=0; i < n; i++) - { - NcAtt* att=nc.get_att(i); - if(att != nullptr && att->name() != nullptr && - strcmp(att->name(),"dataID") == 0 && att->num_vals() > 0) - { - char* v=att->as_string(0); - if(v) id_=std::string(v); - break; - } - }*/ + for(int i=0; i < n; i++) + { + NcAtt* att=nc.get_att(i); + if(att != nullptr && att->name() != nullptr && + strcmp(att->name(),"dataID") == 0 && att->num_vals() > 0) + { + char* v=att->as_string(0); + if(v) id_=std::string(v); + break; + } + }*/ } void MvScm::decodeVar(MvNcVar* var) @@ -880,7 +875,7 @@ if (!var) return; - //Dimension vars + // Dimension vars if (strcmp(var->name(), modelLevDim_.name().c_str()) == 0 || strcmp(var->name(), pressureLevDim_.name().c_str()) == 0 || strcmp(var->name(), soilLevDim_.name().c_str()) == 0 || @@ -914,7 +909,7 @@ if (it != mlVarName_.end()) { mlVarIndex_[it->second] = ml_.size() - 1; - //Insert Relhum after T + // Insert Relhum after T if (it->second == RelHumML) { MvScmVar* r = ml_.back(); r->setRange(0., 1.); @@ -948,7 +943,7 @@ void MvScm::save() { - //Open progvar + // Open progvar MvNetCDF nc(fileName_, 'w'); for (auto& i : ml_) { @@ -1059,13 +1054,13 @@ } void MvScm::initRelHum() { - MvScmVar* t = mlVar(TempML); - MvScmVar* p = mlVar(PresML); - MvScmVar* q = mlVar(SpHumML); - MvScmVar* r = mlVar(RelHumML); + MvScmVar* t = mlVar(TempML); + MvScmVar* p = mlVar(PresML); + MvScmVar* q = mlVar(SpHumML); + MvScmVar* r = mlVar(RelHumML); MvScmVar* tSurf = surfVar(TempSurf); - //MvScmVar* tSeaIce=surfVar(TempSeaIceSurf); - MvScmVar* tSea = surfVar(TempSeaSurf); + // MvScmVar* tSeaIce=surfVar(TempSeaIceSurf); + MvScmVar* tSea = surfVar(TempSeaSurf); MvScmVar* tSoil = soilVar(TempSoil); if (convertUnits_) { @@ -1077,16 +1072,16 @@ tSoil->setUnits(-273.16, 1., "C"); if (tSea && tSea->units() == "K") tSea->setUnits(-273.16, 1., "C"); - //if(tSeaIce && tSeaIce->units() == "K") - // tSeaIce->setOffset(-273.16,"C"); + // if(tSeaIce && tSeaIce->units() == "K") + // tSeaIce->setOffset(-273.16,"C"); } if (!t || !p || !q || !r) return; - //r->compute(t,p,q,&metview::relativeHumidity); + // r->compute(t,p,q,&metview::relativeHumidity); - //Consistency + // Consistency t->setConsistency(new MvScmConsistency(r, &MvSci::relativeHumidity, t, p, q)); r->setConsistency(new MvScmConsistency(q, &MvSci::specificHumidity, t, p, r)); } @@ -1103,7 +1098,7 @@ int MvScm::modelLevelNum(const std::string& fileName) { - //Open file + // Open file MvNetCDF nc(fileName); int num = -1; @@ -1117,13 +1112,13 @@ } -//We add diag and diag2 contents to progvar +// We add diag and diag2 contents to progvar bool MvScm::mergeOutFiles(const std::string& progvarFileName, const std::string& diagvarFileName, const std::string& diagvar2FileName) { - //Open progvar + // Open progvar MvNetCDF nc(progvarFileName, 'w'); - //Get dims from progvar + // Get dims from progvar std::vector dims; for (int i = 0; i < nc.getNumberOfDimensions(); i++) { MvNcDim* dim = nc.getDimension(i); @@ -1141,12 +1136,12 @@ MvNetCDF ncDiag(diagvarFileName, 'r'); - //Dimensions + // Dimensions if (!addDimensionsToFile(ncDiag, nc, dims)) { return false; } - //Variables + // Variables int varNum = ncDiag.getNumberOfVariables(); for (int i = 0; i < varNum; i++) { MvNcVar* var = ncDiag.getVariable(i); @@ -1160,13 +1155,13 @@ MvNetCDF ncDiag2(diagvar2FileName, 'r'); - //Dimensions + // Dimensions if (!addDimensionsToFile(ncDiag2, nc, dims)) { return false; } - //Variables + // Variables varNum = ncDiag2.getNumberOfVariables(); for (int i = 0; i < varNum; i++) { MvNcVar* var = ncDiag2.getVariable(i); @@ -1175,7 +1170,7 @@ ncDiag2.close(); - //Add global attributes + // Add global attributes nc.addAttribute("dataID", "SCM_OUTPUT"); nc.close(); @@ -1188,7 +1183,7 @@ { for (int i = 0; i < inNc.getNumberOfDimensions(); i++) { MvNcDim* dim = inNc.getDimension(i); - bool found = false; + bool found = false; for (auto& j : dims) { if (strcmp(dim->name(), j->name()) == 0) { if (dim->size() != j->size()) { @@ -1209,21 +1204,21 @@ void MvScm::addVarToFile(MvNcVar* inVar, MvNetCDF& outNc, const std::vector& outDims) { - //Check var name + // Check var name for (int i = 0; i < outNc.getNumberOfVariables(); i++) { MvNcVar* v = outNc.getVariable(i); if (v && strcmp(v->name(), inVar->name()) == 0) { - //std::cout << v->name() << std::endl; + // std::cout << v->name() << std::endl; return; } } - //Check dims + // Check dims std::vector dims; for (int i = 0; i < inVar->getNumberOfDimensions(); i++) { MvNcDim* dim = inVar->getDimension(i); if (dim) { - //std::cout << dim->sname() << " " << dim->size() << std::endl; + // std::cout << dim->sname() << " " << dim->size() << std::endl; for (auto outDim : outDims) { if (strcmp(dim->name(), outDim->name()) == 0 && dim->size() == outDim->size()) { @@ -1237,7 +1232,7 @@ } } - //Create var + // Create var MvNcVar* outVar = 0; if (inVar->getNumberOfDimensions() == 0) { outVar = outNc.addVariable(inVar->sname(), inVar->type(), -1); @@ -1254,14 +1249,14 @@ return; } - //Add attributes + // Add attributes for (int i = 0; i < inVar->getNumberOfAttributes(); i++) { if (MvNcAtt* att = inVar->getAttribute(i)) { outVar->addAttribute(att); } } - //Add values_ + // Add values_ if (inVar->getNumberOfDimensions() == 0) { std::vector vals; inVar->get(vals, 0, 0, 0, 0, 0); @@ -1270,7 +1265,7 @@ if (inVar->getNumberOfDimensions() == 1) { long counts[1]; counts[0] = dims[0]->size(); - //float* vals = new float[counts[0]]; + // float* vals = new float[counts[0]]; std::vector vals; inVar->get(vals, counts[0]); outVar->put(vals, counts[0]); @@ -1280,22 +1275,22 @@ counts[0] = dims[0]->size(); counts[1] = dims[1]->size(); std::vector vals; - //float* vals = new float[counts[0] * counts[1]]; + // float* vals = new float[counts[0] * counts[1]]; inVar->get(vals, counts[0], counts[1]); outVar->put(vals, counts[0], counts[1]); } } -//Create an ASCII input file for RTTOV +// Create an ASCII input file for RTTOV bool MvScm::createRttovInput(const std::string& inFileName, const std::string& outFileName, float sat_zenith_angle, float sat_azimuth_angle, float solar_zenith_angle, float solar_azimuth_angle, bool useOzone, std::string& errTxt) { - //Open input NetCDF file, and use original units + // Open input NetCDF file, and use original units MvScm in(inFileName.c_str(), false); - //Check the required profiles + // Check the required profiles std::string nfTxt = " not found!"; MvScmVar* t = in.mlVar(TempML); @@ -1317,11 +1312,11 @@ return false; } - //Compute water vapour ppmv + // Compute water vapour ppmv auto* ppmv = new MvScmVar("ppmv", "ppmv", "ppmv", q); ppmv->compute(p, q, &MvSci::vapourPPMV); - //Ozone + // Ozone MvScmVar* ozppmv = 0; if (useOzone) { MvScmVar* oz = in.mlVar(OzoneML); @@ -1330,18 +1325,18 @@ return false; } - //Compute ozone ppmv + // Compute ozone ppmv ozppmv = new MvScmVar("ozppmv", "ozppmv", "ppmv", oz); ozppmv->compute(oz, &MvSci::ozonePPMV); } - //Surface pressure in Pa + // Surface pressure in Pa double psurf = p->value(0, p->levelNum() - 1); - //Skin tempearture in K + // Skin tempearture in K MvScmVar* v; double tskin = 0.; - v = in.surfVar(TempSurf); + v = in.surfVar(TempSurf); if (!v) { errTxt = "Skin temperature" + nfTxt; return false; @@ -1349,9 +1344,9 @@ else tskin = v->value(0, 0); - //2m tempearture in K + // 2m tempearture in K double t2 = 0.; - v = in.surfVar(Temp2Surf); + v = in.surfVar(Temp2Surf); if (!v) { errTxt = "2m temperature" + nfTxt; return false; @@ -1360,9 +1355,9 @@ t2 = v->value(0, 0); - //2m q in ppmv + // 2m q in ppmv double q2ppmv = 0.; - v = in.surfVar(SpecHum2Surf); + v = in.surfVar(SpecHum2Surf); if (!v) { errTxt = "2m specific humidity" + nfTxt; return false; @@ -1371,9 +1366,9 @@ q2ppmv = MvSci::vapourPPMV(psurf, v->value(0, 0)); - //10m u in m/s + // 10m u in m/s double u10 = 0.; - v = in.surfVar(WindU10Surf); + v = in.surfVar(WindU10Surf); if (!v) { errTxt = "Wind U 10 m" + nfTxt; return false; @@ -1381,9 +1376,9 @@ else u10 = v->value(0, 0); - //10m v m/s + // 10m v m/s double v10 = 0.; - v = in.surfVar(WindV10Surf); + v = in.surfVar(WindV10Surf); if (!v) { errTxt = "Wind V 10 m" + nfTxt; return false; @@ -1391,9 +1386,9 @@ else v10 = v->value(0, 0); - //Lat + // Lat double lat = 0.; - v = in.surfVar(LatSurf); + v = in.surfVar(LatSurf); if (!v) { errTxt = "Lat" + nfTxt; return false; @@ -1401,9 +1396,9 @@ else lat = v->value(0, 0); - //Lon + // Lon double lon = 0.; - v = in.surfVar(LonSurf); + v = in.surfVar(LonSurf); if (!v) { errTxt = "Lon" + nfTxt; return false; @@ -1411,9 +1406,9 @@ else lon = v->value(0, 0); - //orog in km + // orog in km double orog = 0.; - v = in.surfVar(OrogSurf); + v = in.surfVar(OrogSurf); if (!v) { errTxt = "Orography" + nfTxt; return false; @@ -1421,9 +1416,9 @@ else orog = 0.001 * v->value(0, 0); - //Surftype + // Surftype double surfType = 0.; - v = in.surfVar(LsiSurf); + v = in.surfVar(LsiSurf); if (!v) { errTxt = "Surface type" + nfTxt; return false; @@ -1432,36 +1427,36 @@ surfType = v->value(0, 0); /*double surfType=0.; - v=in.surfVar(LsmSurf); - if(!v) - { - errTxt="LSM" + nfTxt; - return false; - } - else - { - MvScmVar* v1=in.surfVar(SeaIceFractionSurf); - if(!v1) - { - errTxt="Sea ice fraction" + nfTxt; - return false; - } - //Sea - if(v->value(0,0) > 0.5) - { - if(v1->value(0,0) > 0.5) - surfType=2; - else - surfType=1; - } - else - surfType=0; - - } */ + v=in.surfVar(LsmSurf); + if(!v) + { + errTxt="LSM" + nfTxt; + return false; + } + else + { + MvScmVar* v1=in.surfVar(SeaIceFractionSurf); + if(!v1) + { + errTxt="Sea ice fraction" + nfTxt; + return false; + } + //Sea + if(v->value(0,0) > 0.5) + { + if(v1->value(0,0) > 0.5) + surfType=2; + else + surfType=1; + } + else + surfType=0; + + } */ - //Watertype + // Watertype double waterType = 0.; - v = in.surfVar(WaterTypeSurf); + v = in.surfVar(WaterTypeSurf); if (!v) { errTxt = "Water type" + nfTxt; return false; @@ -1469,9 +1464,9 @@ else waterType = v->value(0, 0); - //cltoppres + // cltoppres double cltop = 0.; - v = in.surfVar(CloudTopPressSurf); + v = in.surfVar(CloudTopPressSurf); if (!v) { errTxt = "Cloud top pressure" + nfTxt; return false; @@ -1479,9 +1474,9 @@ else cltop = v->value(0, 0); - //clfract + // clfract double clfract = 0.; - v = in.surfVar(CloudFractionSurf); + v = in.surfVar(CloudFractionSurf); if (!v) { errTxt = "Cloud fraction" + nfTxt; return false; @@ -1489,12 +1484,12 @@ else clfract = v->value(0, 0); - //Open ASCII output + // Open ASCII output std::ofstream out(outFileName.c_str()); if (!out.good()) return false; - //Generate ASCII output + // Generate ASCII output out << "! --- Profile 1 ---" << std::endl; out << "! \n\ @@ -1531,8 +1526,8 @@ out << t2 << " " << q2ppmv << " " << psurf / 100. << " " << u10 << " " << v10 << " 100000." << std::endl; - //tSurf->write(out,0,false); - //out << " 15248.0550 1007.30 5.000 2.0000 100000." << std::endl; + // tSurf->write(out,0,false); + // out << " 15248.0550 1007.30 5.000 2.0000 100000." << std::endl; out << "!\n\ ! Skin variables:\n\ diff -Nru metview-5.17.4/metview/src/libMetview/MvScm.h metview-5.19.2/metview/src/libMetview/MvScm.h --- metview-5.17.4/metview/src/libMetview/MvScm.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvScm.h 2023-07-15 08:28:47.000000000 +0000 @@ -89,9 +89,9 @@ void setDependantVar(MvScmVar* v) { dependantVar_ = v; } protected: - MvScmVar* var_; - int step_; - MvScmVar* dependantVar_; + MvScmVar* var_{nullptr}; + int step_{0}; + MvScmVar* dependantVar_{nullptr}; }; class MvScmProfileObserver @@ -213,19 +213,19 @@ void setAttributes(MvNcVar*); void checkConsistency(int, int); - LevelType levelType_; + LevelType levelType_{NoType}; std::string name_; std::string longName_; std::string units_; std::vector > data_; - bool changed_; + bool changed_{false}; std::vector > dataOri_; - bool presentInFile_; - bool rangeSet_; - float rangeMin_; - float rangeMax_; - MvScmConsistency* consistency_; - MvScmUnitsConverter* unitsConverter_; + bool presentInFile_{false}; + bool rangeSet_{false}; + float rangeMin_{0.}; + float rangeMax_{0.}; + MvScmConsistency* consistency_{nullptr}; + MvScmUnitsConverter* unitsConverter_{nullptr}; }; class MvScm diff -Nru metview-5.17.4/metview/src/libMetview/MvSerie.cc metview-5.19.2/metview/src/libMetview/MvSerie.cc --- metview-5.17.4/metview/src/libMetview/MvSerie.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvSerie.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,12 +36,12 @@ { Xmin = Ymin = 1e300; Xmax = Ymax = -1e300; - NbPoints = 0; + NbPoints = 0; - HAxis("AXIS_ORIENTATION") = "HORIZONTAL"; + HAxis("AXIS_ORIENTATION") = "HORIZONTAL"; HAxis("AXIS_TICK_INTERVAL") = 1.; - HAxis("AXIS_GRID") = "ON"; - HAxis("AXIS_GRID_COLOUR") = "BLACK"; + HAxis("AXIS_GRID") = "ON"; + HAxis("AXIS_GRID_COLOUR") = "BLACK"; VAxis("AXIS_ORIENTATION") = "VERTICAL"; @@ -57,29 +57,29 @@ void MvSerie::setYMinMax(double y) { if (y > Ymax) { - Ymax = y; + Ymax = y; VAxis("AXIS_MAX_VALUE") = Ymax; } if (y < Ymin) { - Ymin = y; + Ymin = y; VAxis("AXIS_MIN_VALUE") = Ymin; } } void MvSerie::setXMinMax(double x) { if (x > Xmax) { - Xmax = x; + Xmax = x; HAxis("AXIS_MAX_VALUE") = Xmax; } if (x < Xmin) { - Xmin = x; + Xmin = x; HAxis("AXIS_MIN_VALUE") = Xmin; } } void MvSerie::setYAutoScale(int nticks) { double interval = (Ymax - Ymin) / double(nticks); - int exponent = (int)log10(interval); + int exponent = (int)log10(interval); if (log10(interval) < 0.) exponent -= 1; @@ -108,22 +108,22 @@ } char text[132]; sprintf(text, "x%g", scale); - VAxis("AXIS_TIP_TITLE") = "ON"; + VAxis("AXIS_TIP_TITLE") = "ON"; VAxis("AXIS_TIP_TITLE_QUALITY") = "LOW"; - VAxis("AXIS_TIP_TITLE_TEXT") = text; - VAxis("AXIS_MAX_VALUE") = Ymax / scale; - VAxis("AXIS_MIN_VALUE") = Ymin / scale; + VAxis("AXIS_TIP_TITLE_TEXT") = text; + VAxis("AXIS_MAX_VALUE") = Ymax / scale; + VAxis("AXIS_MIN_VALUE") = Ymin / scale; interval /= scale; } - VAxis("AXIS_TICK_INTERVAL") = interval; + VAxis("AXIS_TICK_INTERVAL") = interval; VAxis("AXIS_GRID_LINE_STYLE") = "DOT"; } void MvSerie::setXAutoScale(int nticks) { double interval = (Xmax - Xmin) / double(nticks); - int exponent = (int)log10(interval); + int exponent = (int)log10(interval); if (log10(interval) < 0.) exponent -= 1; @@ -152,15 +152,15 @@ } char text[132]; sprintf(text, "x%g", scale); - HAxis("AXIS_TIP_TITLE") = "ON"; + HAxis("AXIS_TIP_TITLE") = "ON"; HAxis("AXIS_TIP_TITLE_QUALITY") = "LOW"; - HAxis("AXIS_TIP_TITLE_TEXT") = text; - HAxis("AXIS_MAX_VALUE") = Xmax / scale; - HAxis("AXIS_MIN_VALUE") = Xmin / scale; + HAxis("AXIS_TIP_TITLE_TEXT") = text; + HAxis("AXIS_MAX_VALUE") = Xmax / scale; + HAxis("AXIS_MIN_VALUE") = Xmin / scale; interval /= scale; } - HAxis("AXIS_TICK_INTERVAL") = interval; + HAxis("AXIS_TICK_INTERVAL") = interval; HAxis("AXIS_GRID_LINE_STYLE") = "DOT"; } @@ -176,21 +176,21 @@ else yint = 100; - VAxis("AXIS_GRID") = "ON"; - VAxis("AXIS_GRID_COLOUR") = "BLACK"; - VAxis("AXIS_MIN_VALUE") = Ymax; - VAxis("AXIS_MAX_VALUE") = Ymin; - VAxis("AXIS_TITLE_QUALITY") = "LOW"; - VAxis("AXIS_TITLE_HEIGHT") = .8; - VAxis("AXIS_TICK_INTERVAL") = yint; - VAxis("AXIS_TICK_LABEL_HEIGHT") = .4; - VAxis("AXIS_GRID_LINE_STYLE") = "DOT"; + VAxis("AXIS_GRID") = "ON"; + VAxis("AXIS_GRID_COLOUR") = "BLACK"; + VAxis("AXIS_MIN_VALUE") = Ymax; + VAxis("AXIS_MAX_VALUE") = Ymin; + VAxis("AXIS_TITLE_QUALITY") = "LOW"; + VAxis("AXIS_TITLE_HEIGHT") = .8; + VAxis("AXIS_TICK_INTERVAL") = yint; + VAxis("AXIS_TICK_LABEL_HEIGHT") = .4; + VAxis("AXIS_GRID_LINE_STYLE") = "DOT"; VAxis("AXIS_TICK_LABEL_QUALITY") = "LOW"; - VAxis("AXIS_TIP_TITLE_QUALITY") = "LOW"; - VAxis("AXIS_TIP_TITLE") = "ON"; - VAxis("AXIS_TICK_LABEL_TYPE") = "NUMBER"; - VAxis("AXIS_TITLE_TEXT") = "Pressure"; - VAxis("AXIS_TIP_TITLE_TEXT") = "hPa"; + VAxis("AXIS_TIP_TITLE_QUALITY") = "LOW"; + VAxis("AXIS_TIP_TITLE") = "ON"; + VAxis("AXIS_TICK_LABEL_TYPE") = "NUMBER"; + VAxis("AXIS_TITLE_TEXT") = "Pressure"; + VAxis("AXIS_TIP_TITLE_TEXT") = "hPa"; } void MvSerie::setYModel() @@ -200,20 +200,20 @@ yint = 1; else yint = 5; - VAxis("AXIS_GRID") = "ON"; - VAxis("AXIS_GRID_COLOUR") = "BLACK"; - VAxis("AXIS_MIN_VALUE") = Ymax; - VAxis("AXIS_MAX_VALUE") = Ymin; - VAxis("AXIS_TITLE_QUALITY") = "LOW"; - VAxis("AXIS_TITLE_HEIGHT") = .8; - VAxis("AXIS_TICK_INTERVAL") = yint; + VAxis("AXIS_GRID") = "ON"; + VAxis("AXIS_GRID_COLOUR") = "BLACK"; + VAxis("AXIS_MIN_VALUE") = Ymax; + VAxis("AXIS_MAX_VALUE") = Ymin; + VAxis("AXIS_TITLE_QUALITY") = "LOW"; + VAxis("AXIS_TITLE_HEIGHT") = .8; + VAxis("AXIS_TICK_INTERVAL") = yint; VAxis("AXIS_TICK_LABEL_QUALITY") = "LOW"; - VAxis("AXIS_TICK_LABEL_HEIGHT") = .4; - VAxis("AXIS_GRID_LINE_STYLE") = "DOT"; - VAxis("AXIS_TIP_TITLE_QUALITY") = "LOW"; - VAxis("AXIS_TICK_LABEL_TYPE") = "NUMBER"; - VAxis("AXIS_TITLE_TEXT") = "Model Level"; - VAxis("AXIS_TIP_TITLE_TEXT") = ""; + VAxis("AXIS_TICK_LABEL_HEIGHT") = .4; + VAxis("AXIS_GRID_LINE_STYLE") = "DOT"; + VAxis("AXIS_TIP_TITLE_QUALITY") = "LOW"; + VAxis("AXIS_TICK_LABEL_TYPE") = "NUMBER"; + VAxis("AXIS_TITLE_TEXT") = "Model Level"; + VAxis("AXIS_TIP_TITLE_TEXT") = ""; } void MvSerie::addPoint(double x, double y) diff -Nru metview-5.17.4/metview/src/libMetview/MvService.cc metview-5.19.2/metview/src/libMetview/MvService.cc --- metview-5.17.4/metview/src/libMetview/MvService.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvService.cc 2023-07-15 08:28:47.000000000 +0000 @@ -46,7 +46,7 @@ MvService(name) { MainService = main; - Param = strcache(param); + Param = strcache(param); } void MvModeService::serve(MvRequest& in, MvRequest& out) @@ -156,11 +156,11 @@ } } -//Sends a special progress message back to Desktop to indicate that the -//GUI app started up. Desktop then turns the icon green. Otherwise the icon would stay -//orange and all other actions would be blocked on it until the GUI finishes!! -//Ideally we should send a reply back to Desktop but this CAN ONLY BE SENT when -//the forked process (the GUI) has finished!!! +// Sends a special progress message back to Desktop to indicate that the +// GUI app started up. Desktop then turns the icon green. Otherwise the icon would stay +// orange and all other actions would be blocked on it until the GUI finishes!! +// Ideally we should send a reply back to Desktop but this CAN ONLY BE SENT when +// the forked process (the GUI) has finished!!! void MvService::acknowledgeGuiStartup() { MvRequest a("GUI_STARTED"); @@ -186,7 +186,7 @@ std::cout << "CALLED " << iconClass(); - Id = _id = id; + Id = _id = id; mars.outproc = _out; MvRequest in(r); @@ -206,7 +206,7 @@ marsexit(0); } - _id = nullptr; + _id = nullptr; mars.outproc = nullptr; } @@ -226,7 +226,7 @@ return; } - Id = _id = id; + Id = _id = id; mars.outproc = _out; request* u; @@ -268,7 +268,7 @@ } catch (MvException& e) { setError(1, e.what()); - //marslog(LOG_EROR,"%s",e.what()); + // marslog(LOG_EROR,"%s",e.what()); sendProgress(e.what()); } catch (std::exception& e) { @@ -298,8 +298,8 @@ marsexit(0); } //_id = nullptr; - //mars.outproc = nullptr; - //return; + // mars.outproc = nullptr; + // return; } @@ -320,7 +320,7 @@ if (mars.debug) out.print(); - _id = nullptr; + _id = nullptr; mars.outproc = nullptr; svc* id_s = id->s; // send_reply will free id so keep a ptr to id->s @@ -350,7 +350,7 @@ void MvService::modeServe(MvRequest& in, MvRequest& out, svcid* id) { svcid* _id = Id; - Id = id; + Id = id; try { serve(in, out); diff -Nru metview-5.17.4/metview/src/libMetview/MvService.h metview-5.19.2/metview/src/libMetview/MvService.h --- metview-5.17.4/metview/src/libMetview/MvService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvService.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,23 +27,23 @@ //! A higher level transparent callback function /*! This method is automatically called by the callback function - * when a command arrives. It forks the process and checks in the pool - * if the command has already been executed. - * If not, it calls method \c serve. - */ + * when a command arrives. It forks the process and checks in the pool + * if the command has already been executed. + * If not, it calls method \c serve. + */ virtual void _call_serve(svcid* id, request* r); //! Synchronous call to another service /*! This method sends request \c in to service pointed by \c name - * and synchronously waits for the answer in request \c out - */ + * and synchronously waits for the answer in request \c out + */ err callService(char* name, MvRequest& in, MvRequest& out); //! Links this icon to another /*! This method tells pool service to create a dependency between - * the object currently being executed and the object identified - * by variable \c name. - */ + * the object currently being executed and the object identified + * by variable \c name. + */ void linkTo(char*); virtual MvRequest buildMode(MvRequest&); @@ -53,15 +53,15 @@ public: //! Constuctor /*! The constructor registers a static method \c MvProtocol::_serve - * to be called when the module receives the command pointed by name - */ + * to be called when the module receives the command pointed by name + */ MvService(const char* name); //! Pure virtual method /*! This is the virtual method that must be implemented in the derived class - * to process the incoming command. The incoming command is in \c in - * and the result command must be stored in \c out - */ + * to process the incoming command. The incoming command is in \c in + * and the result command must be stored in \c out + */ virtual void serve(MvRequest& in, MvRequest& out) = 0; // Create "mode" services diff -Nru metview-5.17.4/metview/src/libMetview/MvServiceTask.h metview-5.19.2/metview/src/libMetview/MvServiceTask.h --- metview-5.17.4/metview/src/libMetview/MvServiceTask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvServiceTask.h 2023-07-15 08:28:47.000000000 +0000 @@ -41,13 +41,13 @@ public: //! Constructor /*! Here \c req is the request that will be sent to - * the module that provides service \c service. - */ + * the module that provides service \c service. + */ MvServiceTask(MvClient* client, const Cached& service, const MvRequest& req, const char* taskName = 0); //! Sends the given request to the given service /*! Service and the request are set in the constructor - */ + */ virtual void run(void); MvRequest run(int&); diff -Nru metview-5.17.4/metview/src/libMetview/MvStopWatch.cc metview-5.19.2/metview/src/libMetview/MvStopWatch.cc --- metview-5.17.4/metview/src/libMetview/MvStopWatch.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvStopWatch.cc 2023-07-15 08:28:47.000000000 +0000 @@ -77,7 +77,7 @@ std::cout << anExplanationString << ": "; printTimes(previousTimeStamp_, previousClockStamp_); - previousTimeStamp_ = currentTimeStamp_; + previousTimeStamp_ = currentTimeStamp_; previousClockStamp_ = currentClockStamp_; } //_________________________________________________________ startTimer @@ -114,7 +114,7 @@ gettimeofday(¤tClockStamp_, nullptr); auto userTicks = (double)(currentTimeStamp_.tms_utime - beginTimeStamp.tms_utime); - auto sysTicks = (double)(currentTimeStamp_.tms_stime - beginTimeStamp.tms_stime); + auto sysTicks = (double)(currentTimeStamp_.tms_stime - beginTimeStamp.tms_stime); std::cout << userTicks / sClockTicks << "u/" @@ -129,7 +129,7 @@ void MvStopWatch::printDateTime() { - time_t t; + time_t t = 0; time(&t); std::cout << ctime(&t); //-- ctime ends with a '\n'!!! } diff -Nru metview-5.17.4/metview/src/libMetview/MvStopWatch.h metview-5.19.2/metview/src/libMetview/MvStopWatch.h --- metview-5.17.4/metview/src/libMetview/MvStopWatch.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvStopWatch.h 2023-07-15 08:28:47.000000000 +0000 @@ -12,7 +12,7 @@ #pragma once -#include +#include #include #include diff -Nru metview-5.17.4/metview/src/libMetview/MvTable.cc metview-5.19.2/metview/src/libMetview/MvTable.cc --- metview-5.17.4/metview/src/libMetview/MvTable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvTable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -82,7 +82,7 @@ // has the user specified a particular subset of columns? int num_col_indexes = count_values(r, "TABLE_COLUMNS"); - int num_col_types = count_values(r, "TABLE_COLUMN_TYPES"); + int num_col_types = count_values(r, "TABLE_COLUMN_TYPES"); if (num_col_indexes > 0) { if (num_col_types > 0 && num_col_types != num_col_indexes) { @@ -163,13 +163,13 @@ // get the meta-data so we know what fields are there - //reader_.setHeaderRow(false); - //reader_.setDelimiter(' '); - //reader_.setSkipRows(5); - //reader_.setConsecutiveDelimitersAsOne(true); + // reader_.setHeaderRow(false); + // reader_.setDelimiter(' '); + // reader_.setSkipRows(5); + // reader_.setConsecutiveDelimitersAsOne(true); - //reader_.setHeaderRow(true); - //reader_.setDelimiter(','); + // reader_.setHeaderRow(true); + // reader_.setDelimiter(','); ret = reader_.getMetaData(errorMsg); if (!ret) { @@ -181,7 +181,7 @@ // what are the column types and names? std::vector& types = reader_.fieldTypes(); - std::vector& colNames = reader_.fieldNames(); + std::vector& colNames = reader_.fieldNames(); // if the user has not specified a subset of columns, then we just generate @@ -222,7 +222,7 @@ // for each column, tell the table reader where to put the data for (int colnum = 0; colnum < numColumns_; colnum++) { - int index = (*columnIndexes)[colnum]; + int index = (*columnIndexes)[colnum]; MvTableColumn& col = columns_[colnum]; diff -Nru metview-5.17.4/metview/src/libMetview/MvTable.h metview-5.19.2/metview/src/libMetview/MvTable.h --- metview-5.17.4/metview/src/libMetview/MvTable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvTable.h 2023-07-15 08:28:47.000000000 +0000 @@ -46,7 +46,7 @@ private: - //void clear(); + // void clear(); std::string name_; // each column has an optional name eTableColumnType type_; // what data type is each element in the column @@ -64,7 +64,7 @@ { public: MvTable(); // constructor - //MvTable(const char *name); // constructor with path + // MvTable(const char *name); // constructor with path void setPath(std::string& path) { reader_.setPath(path); } void setDoubleMissingValue(double d) { doubleMissingValue_ = d; } diff -Nru metview-5.17.4/metview/src/libMetview/MvTask.h metview-5.19.2/metview/src/libMetview/MvTask.h --- metview-5.17.4/metview/src/libMetview/MvTask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvTask.h 2023-07-15 08:28:47.000000000 +0000 @@ -35,8 +35,8 @@ //! Callback received when a task has finished /*! This is a pure virtual method that needs to be - * implemented in the derived class - */ + * implemented in the derived class + */ virtual void endOfTask(MvTask* from) = 0; //! Message from task @@ -88,13 +88,13 @@ //! Implements the execution of a task /*! This is a pure virtual method that needs to be - * implemented in the derived class - */ + * implemented in the derived class + */ virtual void run(void) = 0; //! Returns the error/success code /*! Type \c err is defined in \c mars.h - */ + */ err getError() { return Error; } //! Returns the task name, or "(?)" if name not given diff -Nru metview-5.17.4/metview/src/libMetview/MvTemplates.h metview-5.19.2/metview/src/libMetview/MvTemplates.h --- metview-5.17.4/metview/src/libMetview/MvTemplates.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvTemplates.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,8 @@ // An other way is the following -//TODO: this should be a generic class and -// uplot specific code should not be here!!! +// TODO: this should be a generic class and +// uplot specific code should not be here!!! template class TMvServe : public MvTransaction @@ -109,7 +109,7 @@ // In order to keep uPlot alive, we need to remove from // the database (maybe other structures too) all the requests // that caused the error - //Root::Instance().Clean(); + // Root::Instance().Clean(); if (exitOnError_) { exit(0); } @@ -124,7 +124,7 @@ { // Save request to be processed by uPlotManager? if (!outParamName_.empty()) { - //if ((const char*)in("_UPLOT_MANAGER_ID")) + // if ((const char*)in("_UPLOT_MANAGER_ID")) if (const char* ch = in(outParamName_.c_str())) { out.save(ch); } diff -Nru metview-5.17.4/metview/src/libMetview/MvTimeSerie.cc metview-5.19.2/metview/src/libMetview/MvTimeSerie.cc --- metview-5.17.4/metview/src/libMetview/MvTimeSerie.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvTimeSerie.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ Header("MAGICS_PARAMETERS"), HAxis("PAXIS"), VAxis(vaxis), - PGraph(graph), - user_axis(0) + PGraph(graph) { init(); } @@ -27,20 +26,20 @@ void MvTimeSerie::init() { - Xmin = MvDate(22020202.0); //-- far-away in the future - Xmax = MvDate(18880808.0); //-- far-away in the past - Ymin = 1e300; - Ymax = -1e300; - NbPoints = 0; + Xmin = MvDate(22020202.0); //-- far-away in the future + Xmax = MvDate(18880808.0); //-- far-away in the past + Ymin = 1e300; + Ymax = -1e300; + NbPoints = 0; reqOutFilterLevel = eTsReqsAll; - Header("SUBPAGE_Y_POSITION") = 1.7; + Header("SUBPAGE_Y_POSITION") = 1.7; Header("SUBPAGE_ASPECT_RATIO") = 3; - HAxis("AXIS_TYPE") = "DATE"; - HAxis("AXIS_DATE_TYPE") = "DAYS"; + HAxis("AXIS_TYPE") = "DATE"; + HAxis("AXIS_DATE_TYPE") = "DAYS"; HAxis("AXIS_ORIENTATION") = "HORIZONTAL"; - HAxis("AXIS_GRID") = "ON"; + HAxis("AXIS_GRID") = "ON"; HAxis("AXIS_GRID_COLOUR") = "BLACK"; } @@ -51,8 +50,8 @@ int step, scale; static int nice[] = {1, 2, 3}; - Ymax = Ymax + (diff * 0.05); - Ymin = Ymin - (diff * 0.05); + Ymax = Ymax + (diff * 0.05); + Ymin = Ymin - (diff * 0.05); scale = 1; for (int i = 0; i < 5; i++) { @@ -75,9 +74,9 @@ Ymin = mini; if (!VAxis) { - VAxis = "PAXIS"; - VAxis("AXIS_MIN_VALUE") = Ymin; - VAxis("AXIS_MAX_VALUE") = Ymax; + VAxis = "PAXIS"; + VAxis("AXIS_MIN_VALUE") = Ymin; + VAxis("AXIS_MAX_VALUE") = Ymax; VAxis("AXIS_TICK_INTERVAL") = (Ymin - Ymax) / 5; } @@ -101,12 +100,12 @@ if (PGraph) magics = PGraph; else { - magics("GRAPH_TYPE") = "CURVE"; + magics("GRAPH_TYPE") = "CURVE"; magics("GRAPH_CURVE_METHOD") = "ROUNDED"; } if (legend && !(const char*)magics("LEGEND_USER_TEXT")) { - magics("LEGEND") = "ON"; + magics("LEGEND") = "ON"; magics("LEGEND_USER_TEXT") = legend; } @@ -154,11 +153,11 @@ } if (d > Xmax) { - Xmax = d; + Xmax = d; HAxis("AXIS_DATE_MAX_VALUE") = Xmax; } if (d < Xmin) { - Xmin = d; + Xmin = d; HAxis("AXIS_DATE_MIN_VALUE") = Xmin; } if (Xmin.time_interval_days(Xmax) > 180) { //-- ~ 6 months @@ -178,10 +177,10 @@ void MvTimeSerie::setDate(const MvDate& d) { - BaseDate = d; - std::string magDate = d.magicsDate(); + BaseDate = d; + std::string magDate = d.magicsDate(); HAxis("AXIS_DATE_MIN_VALUE") = magDate.c_str(); - Offset = BaseDate.Hour(); + Offset = BaseDate.Hour(); } void MvTimeSerie::setTitle(const Cached& ref, const char* fmt, ...) diff -Nru metview-5.17.4/metview/src/libMetview/MvTimeSerie.h metview-5.19.2/metview/src/libMetview/MvTimeSerie.h --- metview-5.17.4/metview/src/libMetview/MvTimeSerie.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvTimeSerie.h 2023-07-15 08:28:47.000000000 +0000 @@ -42,12 +42,12 @@ MvDate Xmax; double Ymin; double Ymax; - int Offset; + int Offset{0}; eTsReqFilter reqOutFilterLevel; //-- for Timeserie app - int NbPoints; - int user_axis; + int NbPoints{0}; + int user_axis{0}; void init(); diff -Nru metview-5.17.4/metview/src/libMetview/MvTmpFile.cc metview-5.19.2/metview/src/libMetview/MvTmpFile.cc --- metview-5.17.4/metview/src/libMetview/MvTmpFile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvTmpFile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #ifndef METVIEW_ON_WINDOWS #include @@ -28,10 +28,10 @@ autoRemove_(autoRemove) { static char name[1024]; - char* p; + char* p = nullptr; std::string tmpDir; static char* tmpDirCh = getenv("TMPDIR"); - tmpDir = std::string((tmpDirCh) ? tmpDirCh : ""); + tmpDir = std::string((tmpDirCh) ? tmpDirCh : ""); #ifdef ECCODES_UI p = tempnam(tmpDir.c_str(), "cdui_"); @@ -53,7 +53,7 @@ MvTmpFile::~MvTmpFile() { - //TODO: add further/better checks + // TODO: add further/better checks if (autoRemove_ && exists() && !path_.empty() && path_ != "/" && path_.size() > 4) { unlink(path_.c_str()); diff -Nru metview-5.17.4/metview/src/libMetview/MvVariant.cc metview-5.19.2/metview/src/libMetview/MvVariant.cc --- metview-5.17.4/metview/src/libMetview/MvVariant.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvVariant.cc 2023-07-15 08:28:47.000000000 +0000 @@ -71,10 +71,13 @@ try { if (type_ == IntType || type_ == LongType) { strVal_ = std::to_string(longVal_); - } else if (type_ == DoubleType || type_ == FloatType) { + } + else if (type_ == DoubleType || type_ == FloatType) { strVal_ = std::to_string(doubleVal_); } - } catch (...) {} + } + catch (...) { + } } return strVal_; } @@ -168,7 +171,7 @@ { std::vector vv; for (int i : v) - vv.push_back(MvVariant(i)); + vv.emplace_back(i); return vv; } @@ -176,7 +179,7 @@ { std::vector vv; for (long i : v) - vv.push_back(MvVariant(i)); + vv.emplace_back(i); return vv; } @@ -184,7 +187,7 @@ { std::vector vv; for (float i : v) - vv.push_back(MvVariant(i)); + vv.emplace_back(i); return vv; } @@ -193,7 +196,7 @@ { std::vector vv; for (double i : v) - vv.push_back(MvVariant(i)); + vv.emplace_back(i); return vv; } @@ -201,6 +204,6 @@ { std::vector vv; for (const auto& i : v) - vv.push_back(MvVariant(i)); + vv.emplace_back(i); return vv; } diff -Nru metview-5.17.4/metview/src/libMetview/MvVariant.h metview-5.19.2/metview/src/libMetview/MvVariant.h --- metview-5.17.4/metview/src/libMetview/MvVariant.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvVariant.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,11 +33,11 @@ MvVariant(const std::string& v); MvVariant(Type); - //MvVariant(const MvVariant&); + // MvVariant(const MvVariant&); - //void operator =(int); - //void operator =(double); - //void operator =(const std::string&); + // void operator =(int); + // void operator =(double); + // void operator =(const std::string&); bool operator==(const MvVariant&) const; bool operator!=(const MvVariant&) const; diff -Nru metview-5.17.4/metview/src/libMetview/MvVersionInfo.cc metview-5.19.2/metview/src/libMetview/MvVersionInfo.cc --- metview-5.17.4/metview/src/libMetview/MvVersionInfo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvVersionInfo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,8 +10,8 @@ #include #include -#include "MvVersionInfo.h" #include "MvMiscellaneous.h" +#include "MvVersionInfo.h" #include "eccodes.h" @@ -21,9 +21,9 @@ MvVersionInfo::MvVersionInfo() { - FILE* fp; + FILE* fp = nullptr; const char* user = getenv("METVIEW_DIR_SHARE"); - const char* dir = getenv("METVIEW_DIR"); + const char* dir = getenv("METVIEW_DIR"); char version_path[256]; char mv_name[64]; char mv_label[64]; @@ -38,21 +38,21 @@ if (fp) { /* e.g. - 1 Metview 4 0 0 -alpha-7 2010 1990-2010 01-February-2010 + 1 Metview 4 0 0 -alpha-7 2010 1990-2010 01-February-2010 - Note that the file version is just there in case we want to change the fomat - of the file in the future. */ - fscanf(fp, "%d %s %d %d %d %s %d %s %s", &file_version_, mv_name, &major_, + Note that the file version is just there in case we want to change the fomat + of the file in the future. */ + fscanf(fp, "%d %63s %d %d %d %63s %d %63s %63s", &file_version_, mv_name, &major_, &minor_, &revision_, mv_label, &year_, mv_period, mv_release_date); version_ = (major_ * 10000) + (minor_ * 100) + revision_; - name_ = mv_name; - label_ = mv_label; + name_ = mv_name; + label_ = mv_label; copyright_period_ = mv_period; - release_date_ = mv_release_date; + release_date_ = mv_release_date; char charNameAndVersion[64]; sprintf(charNameAndVersion, "%s %d.%d.%d", name_.c_str(), major_, minor_, revision_); @@ -72,9 +72,9 @@ MvGribApiVersionInfo::MvGribApiVersionInfo() { - version_ = codes_get_api_version(); - major_ = version_ / 10000; - minor_ = (version_ - (major_ * 10000)) / 100; + version_ = codes_get_api_version(); + major_ = version_ / 10000; + minor_ = (version_ - (major_ * 10000)) / 100; revision_ = version_ % 100; info_found_ = true; @@ -87,20 +87,20 @@ std::string str = nc_inq_libvers(); // get substring "x.x.x" - size_t pos1 = str.find('"'); - size_t pos2 = str.find('"', ++pos1); + size_t pos1 = str.find('"'); + size_t pos2 = str.find('"', ++pos1); std::string sver = str.substr(pos1, pos2 - pos1); // decode the version number - pos1 = sver.find('.'); + pos1 = sver.find('.'); std::string ss = sver.substr(0, pos1); - major_ = atoi(ss.c_str()); + major_ = atoi(ss.c_str()); - pos2 = sver.find('.', ++pos1); - ss = sver.substr(pos1, pos2 - pos1); + pos2 = sver.find('.', ++pos1); + ss = sver.substr(pos1, pos2 - pos1); minor_ = atoi(ss.c_str()); - ss = sver.substr(++pos2); + ss = sver.substr(++pos2); revision_ = atoi(ss.c_str()); version_ = major_ * 10000 + minor_ * 100 + revision_; @@ -116,15 +116,15 @@ FILE* fp; std::string version_path = metview::appDefDirFile("codes_ui_version_details"); - //const char *dir = getenv("METVIEW_DIR"); + // const char *dir = getenv("METVIEW_DIR"); char mv_name[64]; char mv_label[64]; char mv_period[64]; char mv_release_date[64]; - //install_dir_ = dir; + // install_dir_ = dir; - //sprintf (version_path, "%s/app-defaults/MvVersionDetails", user); + // sprintf (version_path, "%s/app-defaults/MvVersionDetails", user); fp = fopen(version_path.c_str(), "rt"); @@ -132,19 +132,19 @@ /* e.g. 1 Metview 4 0 0 -alpha-7 2010 1990-2010 01-February-2010 - Note that the file version is just there in case we want to change the fomat + Note that the file version is just there in case we want to change the format of the file in the future. */ - fscanf(fp, "%d %s %d %d %d %d %s %s", &file_version_, mv_name, &major_, + fscanf(fp, "%d %63s %d %d %d %d %63s %63s", &file_version_, mv_name, &major_, &minor_, &revision_, &year_, mv_period, mv_release_date); version_ = (major_ * 10000) + (minor_ * 100) + revision_; - name_ = mv_name; - label_ = mv_label; + name_ = mv_name; + label_ = mv_label; copyright_period_ = mv_period; - release_date_ = mv_release_date; + release_date_ = mv_release_date; char charNameAndVersion[64]; sprintf(charNameAndVersion, "%s %d.%d.%d", name_.c_str(), major_, minor_, revision_); diff -Nru metview-5.17.4/metview/src/libMetview/MvVersionInfo.h metview-5.19.2/metview/src/libMetview/MvVersionInfo.h --- metview-5.17.4/metview/src/libMetview/MvVersionInfo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvVersionInfo.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ class MvAbstractVersionInfo { public: - virtual ~MvAbstractVersionInfo() {} + virtual ~MvAbstractVersionInfo() = default; bool infoFound() const { return info_found_; } int fileVersion() const { return file_version_; } @@ -37,7 +37,7 @@ const std::string& installDir() const { return install_dir_; } protected: - MvAbstractVersionInfo() {} + MvAbstractVersionInfo() = default; bool info_found_; int file_version_; @@ -59,7 +59,7 @@ { public: MvVersionInfo(); - ~MvVersionInfo() {} + ~MvVersionInfo() override = default; protected: void init(); @@ -69,7 +69,7 @@ { public: MvGribApiVersionInfo(); - ~MvGribApiVersionInfo() {} + ~MvGribApiVersionInfo() override = default; }; #ifdef METVIEW diff -Nru metview-5.17.4/metview/src/libMetview/MvVisTool.cc metview-5.19.2/metview/src/libMetview/MvVisTool.cc --- metview-5.17.4/metview/src/libMetview/MvVisTool.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/MvVisTool.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,24 +10,24 @@ #include static Cached VISTOOL = "VISTOOL"; -static Cached CHANGE = "CHANGE_WINDOW"; -static Cached CLOSE = "CLOSE_WINDOW"; -static Cached INFO = "WINDOW_INFO"; +static Cached CHANGE = "CHANGE_WINDOW"; +static Cached CLOSE = "CLOSE_WINDOW"; +static Cached INFO = "WINDOW_INFO"; /*=== REGISTER, - WINDOW=... - SERVICE=... + WINDOW=... + SERVICE=... ===*/ /*=== REGISTER, - ID=... + ID=... ===*/ /* VISTOOL, - WINDOW=.... + WINDOW=.... */ #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -78,7 +78,7 @@ if (!VistoolId) return; - MvRequest r = "EXIT"; + MvRequest r = "EXIT"; r("VISTOOL_ID") = VistoolId; printf("MvVisTool::disconnect sending\n"); @@ -88,7 +88,7 @@ VistoolTarget = (Cached) "VisMod"; MvApplication::callService(VistoolTarget, r, nullptr); - VistoolId = (Cached) nullptr; + VistoolId = (Cached) nullptr; VistoolTarget = (Cached) nullptr; } @@ -98,9 +98,9 @@ void MvVisTool::connect() { - MvRequest r = "REGISTER"; + MvRequest r = "REGISTER"; r("SERVICE") = progname(); - r("WINDOW") = Window; + r("WINDOW") = Window; // Copy interest int i = 0; @@ -143,7 +143,7 @@ } else if (v == VISTOOL) { Window = r("WINDOW"); - Setup = r("SETUP"); + Setup = r("SETUP"); disconnect(); // Exit from previous window // For compatibility with VisMod diff -Nru metview-5.17.4/metview/src/libMetview/Path.cc metview-5.19.2/metview/src/libMetview/Path.cc --- metview-5.17.4/metview/src/libMetview/Path.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Path.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -22,7 +23,7 @@ #include "Path.h" #include "MvMiscellaneous.h" -//#include "Log.h" +#include "MvLog.h" Path::Path(const std::string& s) : @@ -132,7 +133,7 @@ { FILE* f = fopen(path_.c_str(), "w"); if (f == nullptr) { - //Log::error(0) << "Cannot open " << path.c_str() << Log::syserr << std::endl; + // Log::error(0) << "Cannot open " << path.c_str() << Log::syserr << std::endl; return; } @@ -140,15 +141,49 @@ fclose(f); } +bool Path::isSymLink() const +{ + struct stat s + { + }; + if (lstat(path_.c_str(), &s) == 0) { + return S_ISLNK(s.st_mode) == 1; + } + return false; +} + void Path::symlink(const Path& other) const { // Warning: reverse order ::symlink(other.path_.c_str(), path_.c_str()); - std::cout << " symlink "; - std::cout << other << std::endl; - std::cout << path_ << std::endl; +#if 0 + MvLog().info() << MV_FN_INFO << "ret=" << ret << " errno=" << errno; + MvLog().info() << "src=" << str(); + MvLog().info() << "target=" << other.str(); +#endif +} + +void Path::changeSymlink(const Path& other) const +{ + struct stat s + { + }; + if (lstat(path_.c_str(), &s) == 0) { + if (S_ISLNK(s.st_mode) == 1) { + int ret = ::unlink(path_.c_str()); + if (ret == 0) { + ::symlink(other.path_.c_str(), path_.c_str()); +#if 0 + MvLog().info() << MV_FN_INFO << "ret=" << ret << " errno=" << errno; + MvLog().info() << "src=" << str(); + MvLog().info() << "target=" << other.str(); +#endif + } + } + } } + std::string Path::symlinkTarget() const { char buf[1024]; @@ -156,7 +191,7 @@ ssize_t count = readlink(path_.c_str(), buf, sizeof(buf)); if (count > 0) { buf[count] = '\0'; - s = std::string(buf); + s = std::string(buf); } return s; } @@ -189,7 +224,7 @@ if (strncmp(d->d_name, myTmpDirLink, 17) == 0 //- start as "MvTemporaryCache_" && strcmp(d->d_name, myTmpDirLink) != 0) //- but is not for this session! { - //std::cout << ">>> NOT ours! Skipping folder " << d->d_name << std::std::endl; + // std::cout << ">>> NOT ours! Skipping folder " << d->d_name << std::std::endl; continue; //-- temporary folder link of another Metview session } @@ -225,7 +260,7 @@ if (strncmp(d->d_name, myTmpDirLink, 17) == 0 //- start as "MvTemporaryCache_" && strcmp(d->d_name, myTmpDirLink) != 0) //- but is not for this session! { - //std::cout << ">>> NOT ours! Skipping folder " << d->d_name << std::endl; + // std::cout << ">>> NOT ours! Skipping folder " << d->d_name << std::endl; continue; //-- temporary folder link of another Metview session } @@ -247,12 +282,12 @@ std::ifstream in(path_.c_str()); static std::string s; // Keep it here so it keeps its size - //s.clear(); + // s.clear(); s = ""; char c; while (in.get(c)) { - //s.push_back(c); + // s.push_back(c); s += c; } @@ -286,7 +321,9 @@ void Path::touch() const { - struct stat info; + struct stat info + { + }; if (::stat(path_.c_str(), &info) == 0 && S_ISDIR(info.st_mode)) { Path dummy = add("..."); dummy.touch(); @@ -305,19 +342,23 @@ s << path_; } -time_t Path::lastModified() const +time_t Path::lastModified(bool symLink) const { - struct stat info; - if (::stat(path_.c_str(), &info) == 0) + struct stat info + { + }; + int ret = (!symLink) ? (::stat(path_.c_str(), &info)) : (::lstat(path_.c_str(), &info)); + if (ret == 0) { return info.st_mtime; - else - return 0; + } + return 0; } - off_t Path::sizeInBytes() const { - struct stat info; + struct stat info + { + }; if (::stat(path_.c_str(), &info) == 0) return info.st_size; else @@ -326,16 +367,21 @@ void Path::makeWritableByUser() const { - struct stat info; + struct stat info + { + }; if (::stat(path_.c_str(), &info) == 0) if (!(info.st_mode & S_IWUSR)) chmod(path_.c_str(), info.st_mode | S_IWUSR); } -std::string Path::permissions() const +std::string Path::permissions(bool symLink) const { - struct stat info; - if (::stat(path_.c_str(), &info) == 0) { + struct stat info + { + }; + int ret = (!symLink) ? (::stat(path_.c_str(), &info)) : (::lstat(path_.c_str(), &info)); + if (ret == 0) { std::string str((info.st_mode & S_IRUSR) ? "r" : "-"); str += ((info.st_mode & S_IWUSR) ? "w" : "-"); str += ((info.st_mode & S_IXUSR) ? "x" : "-"); @@ -352,10 +398,13 @@ return "---------"; } -std::string Path::owner() const +std::string Path::owner(bool symLink) const { - struct stat info; - if (::stat(path_.c_str(), &info) == 0) { + struct stat info + { + }; + int ret = (!symLink) ? (::stat(path_.c_str(), &info)) : (::lstat(path_.c_str(), &info)); + if (ret == 0) { struct passwd* pw = getpwuid(info.st_uid); if (pw) { std::string str(pw->pw_name); @@ -366,10 +415,13 @@ return "???"; } -std::string Path::group() const +std::string Path::group(bool symLink) const { - struct stat info; - if (::stat(path_.c_str(), &info) == 0) { + struct stat info + { + }; + int ret = (!symLink) ? (::stat(path_.c_str(), &info)) : (::lstat(path_.c_str(), &info)); + if (ret == 0) { struct group* gg = getgrgid(info.st_gid); if (gg) { std::string str(gg->gr_name); @@ -396,7 +448,7 @@ if ((pos = namePart.find_last_of(".")) != std::string::npos) { if (pos > 0 && pos < namePart.size() - 1) { suffixPart = namePart.substr(pos + 1); - namePart = namePart.substr(0, pos); + namePart = namePart.substr(0, pos); } } } @@ -404,8 +456,8 @@ std::string Path::uniqueNameInDir() const { std::string resName(name()); - int i = 0; - const int imax = 100000; + int i = 0; + const int imax = 100000; std::set fileLst = directory().files(); if (fileLst.find(resName) == fileLst.end()) @@ -415,7 +467,7 @@ std::string fSuffix; nameAndSuffix(fName, fSuffix); - //For macro and python we want to keep the suffix + // For macro and python we want to keep the suffix if (fSuffix == "mv" || fSuffix == "py") { do { resName = fName + "_" + std::to_string(++i) + "." + fSuffix; diff -Nru metview-5.17.4/metview/src/libMetview/Path.h metview-5.19.2/metview/src/libMetview/Path.h --- metview-5.17.4/metview/src/libMetview/Path.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Path.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,24 +23,8 @@ class Path { public: - // -- Exceptions - // None - - // -- Contructors - Path(const std::string&); - - // -- Destructor - - ~Path(); // Change to virtual if base class - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods + ~Path(); const std::string& str() const; @@ -58,6 +42,7 @@ void remove() const; void mkdir() const; void symlink(const Path&) const; + void changeSymlink(const Path& other) const; std::string symlinkTarget() const; std::set files() const; @@ -65,6 +50,7 @@ bool exists() const; bool locked() const; + bool isSymLink() const; std::string loadText() const; void saveText(const std::string&) const; @@ -72,66 +58,22 @@ MvRequest loadRequest() const; void saveRequest(const MvRequest&) const; - time_t lastModified() const; + time_t lastModified(bool symLink = false) const; off_t sizeInBytes() const; void makeWritableByUser() const; - std::string permissions() const; - std::string owner() const; - std::string group() const; + std::string permissions(bool symLink = false) const; + std::string owner(bool symLink = false) const; + std::string group(bool symLink = false) const; void nameAndSuffix(std::string& namePart, std::string& suffixPart) const; std::string uniqueNameInDir() const; - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - - // Uncomment for persistent, remove otherwise - // static os_typespec* get_os_typespec(); - protected: - // -- Members - // None - - // -- Methods - void print(std::ostream&) const; // Change to virtual if base class - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - private: - // No copy allowed - - // -- Members - // None - - // -- Methods - std::string path_; - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - friend std::ostream& operator<<(std::ostream& s, const Path& p) { p.print(s); @@ -143,5 +85,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(Path); +// OS_MARK_SCHEMA_TYPE(Path); //#endif diff -Nru metview-5.17.4/metview/src/libMetview/Point.cc metview-5.19.2/metview/src/libMetview/Point.cc --- metview-5.17.4/metview/src/libMetview/Point.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Point.cc 2023-07-15 08:28:47.000000000 +0000 @@ -47,10 +47,10 @@ Point Point ::pmax(const Point& p) const { - return Point(std::max(_x, p._x), std::max(_y, p._y)); + return {std::max(_x, p._x), std::max(_y, p._y)}; } Point Point ::pmin(const Point& p) const { - return Point(std::min(_x, p._x), std::min(_y, p._y)); + return {std::min(_x, p._x), std::min(_y, p._y)}; } diff -Nru metview-5.17.4/metview/src/libMetview/Point.hpp metview-5.19.2/metview/src/libMetview/Point.hpp --- metview-5.17.4/metview/src/libMetview/Point.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Point.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -8,7 +8,7 @@ #pragma once -#include +#include #include #include @@ -24,6 +24,8 @@ } // Normal constructor. + Point(double x, double y) : + _x(static_cast(x)), _y(static_cast(y)) {} Point(const Point& p) { _x = p._x; @@ -31,7 +33,7 @@ } // Copy initializer. - ~Point() {} + ~Point() = default; // Empty destructor. void init(float v, float u) @@ -110,12 +112,12 @@ Point operator+(Point& p) { - return Point(_x + p._x, _y + p._y); + return {_x + p._x, _y + p._y}; } Point operator-(Point& p) { - return Point(_x - p._x, _y - p._y); + return {_x - p._x, _y - p._y}; } Point pmax(const Point& p) const; diff -Nru metview-5.17.4/metview/src/libMetview/proj_braz.cc metview-5.19.2/metview/src/libMetview/proj_braz.cc --- metview-5.17.4/metview/src/libMetview/proj_braz.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/proj_braz.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,8 @@ static Datum* D; static SProjection *Sp1, *Sp2; static GeneralProjection *Gp1, *Gp2; -//static CylindEquid *Ce1,*Ce2; -//static PolarStereo *Ps1,*Ps2; +// static CylindEquid *Ce1,*Ce2; +// static PolarStereo *Ps1,*Ps2; static Satellite *Sat1, *Sat2; static SImage *Imi, *Imo; static BBox *B1, *B2; @@ -84,10 +84,10 @@ { Real aux, step, - x1 = B->Bll.X, - x2 = B->Bur.X, - y1 = B->Bll.Y, - y2 = B->Bur.Y, + x1 = B->Bll.X, + x2 = B->Bur.X, + y1 = B->Bll.Y, + y2 = B->Bur.Y, xmin = MAXFLOAT, xmax = -MAXFLOAT, ymin = MAXFLOAT, @@ -98,7 +98,7 @@ /* lower edge */ p.X = aux; p.Y = y1; - p = pPC2LL(In, p); + p = pPC2LL(In, p); if (p.X < (MAXFLOAT / 10.)) { p = pLL2PC(Out, p); if (p.X < (MAXFLOAT / 10.)) { @@ -118,7 +118,7 @@ /* upper edge */ p.X = aux; p.Y = y2; - p = pPC2LL(In, p); + p = pPC2LL(In, p); if (p.X < (MAXFLOAT / 10.)) { p = pLL2PC(Out, p); if (p.X < (MAXFLOAT / 10.)) { @@ -141,7 +141,7 @@ /* left edge */ p.X = x1; p.Y = aux; - p = pPC2LL(In, p); + p = pPC2LL(In, p); if (p.X < (MAXFLOAT / 10.)) { p = pLL2PC(Out, p); if (p.X < (MAXFLOAT / 10.)) { @@ -162,7 +162,7 @@ /* right edge */ p.X = x2; p.Y = aux; - p = pPC2LL(In, p); + p = pPC2LL(In, p); if (p.X < (MAXFLOAT / 10.)) { p = pLL2PC(Out, p); if (p.X < (MAXFLOAT / 10.)) { @@ -200,10 +200,10 @@ { Real aux, step, - x1 = B->Bll.X, - x2 = B->Bur.X, - y1 = B->Bll.Y, - y2 = B->Bur.Y, + x1 = B->Bll.X, + x2 = B->Bur.X, + y1 = B->Bll.Y, + y2 = B->Bur.Y, xmin = MAXFLOAT, xmax = -MAXFLOAT, ymin = MAXFLOAT, @@ -214,7 +214,7 @@ /* lower edge */ p.X = aux; p.Y = y1; - p = pLL2PC(Out, p); + p = pLL2PC(Out, p); if (p.X < (MAXFLOAT / 10.)) { /* search for minimum and maximum coordinates,*/ /* if a valid remapped point is calculated */ @@ -231,7 +231,7 @@ /* upper edge */ p.X = aux; p.Y = y2; - p = pLL2PC(Out, p); + p = pLL2PC(Out, p); if (p.X < (MAXFLOAT / 10.)) { /* search for minimum and maximum coordinates,*/ /* if a valid remapped point is calculated */ @@ -251,7 +251,7 @@ /* left edge */ p.X = x1; p.Y = aux; - p = pLL2PC(Out, p); + p = pLL2PC(Out, p); if (p.X < (MAXFLOAT / 10.)) { /* search for minimum and maximum coordinates,*/ /* if a valid remapped point is calculated */ @@ -269,7 +269,7 @@ /* right edge */ p.X = x2; p.Y = aux; - p = pLL2PC(Out, p); + p = pLL2PC(Out, p); if (p.X < (MAXFLOAT / 10.)) { if (p.X < xmin) xmin = p.X; @@ -295,7 +295,7 @@ unsigned long pix, outsidevalue; // short lin,col; - pix = (unsigned long)pixel; + pix = (unsigned long)pixel; outsidevalue = (unsigned long)outside; // lin = (short) *Inx; @@ -315,7 +315,7 @@ int i; unsigned char* buf; - pix = (unsigned long)pixel; + pix = (unsigned long)pixel; outsidevalue = (unsigned long)outside; // lin = (short) *Inx; @@ -342,8 +342,8 @@ // valid coordinates. If the computed coordinates are outside // the image area, the returned values are the min/max coordinates. *P1 = pCoord2Index(Imi, P1); - x = P1->X; - y = P1->Y; + x = P1->X; + y = P1->Y; return; } @@ -432,7 +432,7 @@ { /* Define and Initialize Datum and Projection */ - D = (Datum*)malloc(sizeof(Datum)); + D = (Datum*)malloc(sizeof(Datum)); Imi = (SImage*)malloc(sizeof(SImage)); Imo = (SImage*)malloc(sizeof(SImage)); @@ -465,13 +465,13 @@ Pcode = (short)i1; /* - i = str_length; - while( *(tx+i-1) == ' ' && i>0 ) i--; + i = str_length; + while( *(tx+i-1) == ' ' && i>0 ) i--; - txd = (char *) malloc(sizeof(char)*i+1); + txd = (char *) malloc(sizeof(char)*i+1); - strncpy(txd,tx,i); - *(txd+i) = '\0'; + strncpy(txd,tx,i); + *(txd+i) = '\0'; */ pInitDatum(D, Pcode, tx, Pdx, Pdy, Pdz, Prd, Pflt); @@ -490,21 +490,21 @@ // Pdatum = (short)i2; /* - i = str_length1; - while( *(txo+i-1) == ' ' && i>0 ) i--; + i = str_length1; + while( *(txo+i-1) == ' ' && i>0 ) i--; - tx1 = (char *) malloc(sizeof(char)*i+1); + tx1 = (char *) malloc(sizeof(char)*i+1); - strncpy(tx1,txo,i); - *(tx1+i) = '\0'; + strncpy(tx1,txo,i); + *(tx1+i) = '\0'; - i = str_length2; - while( *(txs+i-1) == ' ' && i>0 ) i--; + i = str_length2; + while( *(txs+i-1) == ' ' && i>0 ) i--; - tx2 = (char *) malloc(sizeof(char)*i+1); + tx2 = (char *) malloc(sizeof(char)*i+1); - strncpy(tx2,txs,i); - *(tx2+i) = '\0'; + strncpy(tx2,txs,i); + *(tx2+i) = '\0'; */ pInitProj(Sp1, txs, txo, Pid, (short)Pcode, (short)Pdatum, Pdx, Pdy, Pdz, Prd, Pflt, Poffx, Poffy); @@ -523,21 +523,21 @@ // Pdatum = (short)i2; /* - i = str_length1; - while( *(txo+i-1) == ' ' && i>0 ) i--; + i = str_length1; + while( *(txo+i-1) == ' ' && i>0 ) i--; - tx3 = (char *) malloc(sizeof(char)*i+1); + tx3 = (char *) malloc(sizeof(char)*i+1); - strncpy(tx3,txo,i); - *(tx3+i) = '\0'; + strncpy(tx3,txo,i); + *(tx3+i) = '\0'; - i = str_length2; - while( *(txs+i-1) == ' ' && i>0 ) i--; + i = str_length2; + while( *(txs+i-1) == ' ' && i>0 ) i--; - tx4 = (char *) malloc(sizeof(char)*i+1); + tx4 = (char *) malloc(sizeof(char)*i+1); - strncpy(tx4,txs,i); - *(tx4+i) = '\0'; + strncpy(tx4,txs,i); + *(tx4+i) = '\0'; */ pInitProj(Sp2, txs, txo, Pid, (short)Pcode, (short)Pdatum, Pdx, Pdy, Pdz, Prd, Pflt, Poffx, Poffy); @@ -587,7 +587,7 @@ } -//F-------------- +// F-------------- #if 0 #define SIZE 128 @@ -634,7 +634,7 @@ short pTooBig(CPoint* p) { - /* old version: p->* > BIGFLOAT and p->X < -BIGFLOAT, works for SGI + /* old version: p->* > BIGFLOAT and p->X < -BIGFLOAT, works for SGI but not for Linux */ return (p->X >= BIGFLOAT || p->Y >= BIGFLOAT || p->X <= -BIGFLOAT || p->Y <= -BIGFLOAT); @@ -691,30 +691,30 @@ { D->Dproj = Pcode; D->Dname = tx2; - D->Ddx = Ddx; - D->Ddy = Ddy; - D->Ddz = Ddz; - D->Drd = Drd; - D->Dflt = Dflt; + D->Ddx = Ddx; + D->Ddy = Ddy; + D->Ddz = Ddz; + D->Drd = Drd; + D->Dflt = Dflt; } void pInitProj(SProjection* Sp, char* tx1, char* tx2, int Pid, short Pcode, short Pdatum, Real Pdx, Real Pdy, Real Pdz, double Prd, double Pflt, double Poffx, double Poffy) { - Sp->Pname = tx2; - Sp->Pdname = tx1; - Sp->Pdatum = Pdatum; - Sp->Pcode = Pcode; - Sp->Pgbcode = 0; + Sp->Pname = tx2; + Sp->Pdname = tx1; + Sp->Pdatum = Pdatum; + Sp->Pcode = Pcode; + Sp->Pgbcode = 0; Sp->Pgbcode1 = 0; - Sp->Pid = Pid; - Sp->Pdx = Pdx; - Sp->Pdy = Pdy; - Sp->Pdz = Pdz; - Sp->Prd = Prd; - Sp->Pflt = Pflt; - Sp->Poffx = Poffx; - Sp->Poffy = Poffy; - Sp->Pout = Sp; + Sp->Pid = Pid; + Sp->Pdx = Pdx; + Sp->Pdy = Pdy; + Sp->Pdz = Pdz; + Sp->Prd = Prd; + Sp->Pflt = Pflt; + Sp->Poffx = Poffx; + Sp->Poffy = Poffy; + Sp->Pout = Sp; } short pProjEq(SProjection* In, SProjection* Out) @@ -783,22 +783,22 @@ void pInitGen(GeneralProjection* Gp, short GPhemis, double GPlat0, double GPlon0, double GPstlat1, double GPstlat2) { - Gp->GPhemis = GPhemis; - Gp->GPlat0 = GPlat0; - Gp->GPlon0 = GPlon0; + Gp->GPhemis = GPhemis; + Gp->GPlat0 = GPlat0; + Gp->GPlon0 = GPlon0; Gp->GPstlat1 = GPstlat1; Gp->GPstlat2 = GPstlat2; } void pInitSat(Satellite* Sat, double SPri, double SPrj, double SPis, double SPjs, double SPla0, double SPlo0, double SPrs, double SPscn, double SPyaw) { - Sat->SPri = SPri; - Sat->SPrj = SPrj; - Sat->SPis = SPis; - Sat->SPjs = SPjs; + Sat->SPri = SPri; + Sat->SPrj = SPrj; + Sat->SPis = SPis; + Sat->SPjs = SPjs; Sat->SPla0 = SPla0; Sat->SPlo0 = SPlo0; - Sat->SPrs = SPrs; + Sat->SPrs = SPrs; Sat->SPscn = SPscn; Sat->SPyaw = SPyaw; } @@ -870,7 +870,7 @@ } /******************************************************************** - Planimetric datum transformation + Planimetric datum transformation ********************************************************************/ void ChangeLL(SProjection* Sp, double* lon1, double* lat1) { @@ -889,18 +889,18 @@ Real Pdx, Pdy, Pdz; double Prd, Pflt; - Pdx = Sp->Pdx; - Pdy = Sp->Pdy; - Pdz = Sp->Pdz; - Prd = Sp->Prd; + Pdx = Sp->Pdx; + Pdy = Sp->Pdy; + Pdz = Sp->Pdz; + Prd = Sp->Prd; Pflt = Sp->Pflt; /* Geocentric cartesian coordinates calculation - datum 1 */ equad1 = 2. * Pflt - pow(Pflt, (double)2); - n1 = Prd / sqrt((double)1 - equad1 * pow(sin(*lat1), (double)2)); - x1 = n1 * cos(*lat1) * cos(*lon1); - y1 = n1 * cos(*lat1) * sin(*lon1); - z1 = (n1 * (1 - equad1)) * sin(*lat1); + n1 = Prd / sqrt((double)1 - equad1 * pow(sin(*lat1), (double)2)); + x1 = n1 * cos(*lat1) * cos(*lon1); + y1 = n1 * cos(*lat1) * sin(*lon1); + z1 = (n1 * (1 - equad1)) * sin(*lat1); /* Geocentric cartesian coordinates calculation - datum 2 */ if (Pdx == MAXFLOAT || Sp->Pout->Pdx == MAXFLOAT) { @@ -916,19 +916,19 @@ /* Geodetic coordinates calculation - datum 2 */ equad2 = 2. * Sp->Pout->Pflt - pow(Sp->Pout->Pflt, (double)2); - lat2 = *lat1; + lat2 = *lat1; do { - n2 = Sp->Pout->Prd / sqrt((double)1 - equad2 * pow(sin(lat2), (double)2)); + n2 = Sp->Pout->Prd / sqrt((double)1 - equad2 * pow(sin(lat2), (double)2)); lat2 = atan((z2 + n2 * equad2 * sin(lat2)) / sqrt(x2 * x2 + y2 * y2)); - d = Sp->Pout->Prd / sqrt((double)1 - equad2 * pow(sin(lat2), (double)2)) - n2; + d = Sp->Pout->Prd / sqrt((double)1 - equad2 * pow(sin(lat2), (double)2)) - n2; } while (fabs(d) > 0.0000001); - lon2 = atan(y2 / x2); + lon2 = atan(y2 / x2); *lat1 = lat2; *lon1 = lon2; } /*********************************************************************** - GEODETIC COORDINATES TO SATELLITE PROJECTION + GEODETIC COORDINATES TO SATELLITE PROJECTION ***********************************************************************/ CPoint pSatLL2PC(SProjection* Sp, CPoint ptll) { @@ -946,30 +946,30 @@ return ppc; } - SPri = Sp->Proj.Sat->SPri; - SPrj = Sp->Proj.Sat->SPrj; - SPis = Sp->Proj.Sat->SPis; - SPjs = Sp->Proj.Sat->SPjs; + SPri = Sp->Proj.Sat->SPri; + SPrj = Sp->Proj.Sat->SPrj; + SPis = Sp->Proj.Sat->SPis; + SPjs = Sp->Proj.Sat->SPjs; SPla0 = Sp->Proj.Sat->SPla0; SPlo0 = Sp->Proj.Sat->SPlo0; - SPrs = Sp->Proj.Sat->SPrs; + SPrs = Sp->Proj.Sat->SPrs; SPscn = Sp->Proj.Sat->SPscn; SPyaw = Sp->Proj.Sat->SPyaw; Pflt = Sp->Pflt; - Prd = Sp->Prd; - xlo = (double)ptll.X; - yla = (double)ptll.Y; + Prd = Sp->Prd; + xlo = (double)ptll.X; + yla = (double)ptll.Y; /* Cartesian geocentric coordinates */ - xlo = xlo - SPlo0; - yla = yla - SPla0; + xlo = xlo - SPlo0; + yla = yla - SPla0; equad = 2. * Pflt - pow(Pflt, (double)2); - n = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)); - x = n * cos(yla) * cos(xlo); - y = n * cos(yla) * sin(xlo); - z = (n * (1 - equad)) * sin(yla); + n = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)); + x = n * cos(yla) * cos(xlo); + y = n * cos(yla) * sin(xlo); + z = (n * (1 - equad)) * sin(yla); /* Field of view angles */ dp = atan(y / (SPrs - x)); @@ -983,7 +983,7 @@ } else { Rd2 = Prd * Prd; - Rm = Prd * (1. - Pflt); + Rm = Prd * (1. - Pflt); Rm2 = Rm * Rm; Rs2 = SPrs * SPrs; @@ -1016,8 +1016,8 @@ lin = (-sn * dl / SPri + SPis); /* Axis rotation correction due to yaw angle */ - col = col * cos(SPyaw) - lin * sin(SPyaw); - lin = lin * cos(SPyaw) + col * sin(SPyaw); + col = col * cos(SPyaw) - lin * sin(SPyaw); + lin = lin * cos(SPyaw) + col * sin(SPyaw); resx = tan(SPrj) * (SPrs - Prd); resy = tan(SPri) * (SPrs - Prd); @@ -1027,7 +1027,7 @@ } /********************************************************************* - SATELLITE PROJECTION TO GEODETIC COORDINATES + SATELLITE PROJECTION TO GEODETIC COORDINATES **********************************************************************/ CPoint pSatPC2LL(SProjection* Sp, CPoint ptpc) { @@ -1040,21 +1040,21 @@ CPoint ppc; - SPri = Sp->Proj.Sat->SPri; - SPrj = Sp->Proj.Sat->SPrj; - SPis = Sp->Proj.Sat->SPis; - SPjs = Sp->Proj.Sat->SPjs; + SPri = Sp->Proj.Sat->SPri; + SPrj = Sp->Proj.Sat->SPrj; + SPis = Sp->Proj.Sat->SPis; + SPjs = Sp->Proj.Sat->SPjs; SPla0 = Sp->Proj.Sat->SPla0; SPlo0 = Sp->Proj.Sat->SPlo0; - SPrs = Sp->Proj.Sat->SPrs; + SPrs = Sp->Proj.Sat->SPrs; SPscn = Sp->Proj.Sat->SPscn; SPyaw = Sp->Proj.Sat->SPyaw; Pflt = Sp->Pflt; - Prd = Sp->Prd; + Prd = Sp->Prd; - resx = tan(SPrj) * (SPrs - Prd); - resy = tan(SPri) * (SPrs - Prd); + resx = tan(SPrj) * (SPrs - Prd); + resy = tan(SPri) * (SPrs - Prd); ptpcx = (double)ptpc.X / resx; ptpcy = -(double)ptpc.Y / resy; @@ -1072,7 +1072,7 @@ /* Cartesian coordinates */ Rd2 = Prd * Prd; - Rm = Prd * (1. - Pflt); + Rm = Prd * (1. - Pflt); Rm2 = Rm * Rm; Rs2 = SPrs * SPrs; @@ -1110,9 +1110,9 @@ yla = asin(SPrs * dl / Prd); do { - n = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)); + n = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)); yla = atan((z + n * equad * sin(yla)) / sqrt(x * x + y * y)); - d = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)) - n; + d = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)) - n; } while (fabs(d) > 0.001); xlo = atan(y / x) + SPlo0; @@ -1124,7 +1124,7 @@ } /******************************************************************** - GEODETIC TO EQUIDISTANT CYLINDRICAL COORDINATES + GEODETIC TO EQUIDISTANT CYLINDRICAL COORDINATES ********************************************************************/ CPoint pCylLL2PC(SProjection* Sp, CPoint ptll) { @@ -1135,8 +1135,8 @@ ptllx = (double)ptll.X; ptlly = (double)ptll.Y; - Prd = Sp->Prd; - GPlon0 = Sp->Proj.Gp->GPlon0; + Prd = Sp->Prd; + GPlon0 = Sp->Proj.Gp->GPlon0; GPstlat1 = Sp->Proj.Gp->GPstlat1; @@ -1150,7 +1150,7 @@ } /******************************************************************** - EQUIDISTANT CYLINDRICAL TO GEODETIC COORDINATES + EQUIDISTANT CYLINDRICAL TO GEODETIC COORDINATES ********************************************************************/ CPoint pCylPC2LL(SProjection* Sp, CPoint ptpc) { @@ -1162,8 +1162,8 @@ ptpcx = (double)ptpc.X; ptpcy = (double)ptpc.Y; - Prd = Sp->Prd; - GPlon0 = Sp->Proj.Gp->GPlon0; + Prd = Sp->Prd; + GPlon0 = Sp->Proj.Gp->GPlon0; GPstlat1 = Sp->Proj.Gp->GPstlat1; ptpcy = ptpcy / Prd; @@ -1179,7 +1179,7 @@ } /******************************************************************** - GEODETIC TO POLAR STEREOGRAPHIC COORDINATES + GEODETIC TO POLAR STEREOGRAPHIC COORDINATES ********************************************************************/ CPoint pPolLL2PC(SProjection* Sp, CPoint ptll) { @@ -1196,29 +1196,29 @@ ptlly = (double)ptll.Y; GPhemis = Sp->Proj.Gp->GPhemis; - //GPlat0 = Sp->Proj.Gp->GPlat0; + // GPlat0 = Sp->Proj.Gp->GPlat0; GPlon0 = Sp->Proj.Gp->GPlon0; - //GPstlat1 = Sp->Proj.Gp->GPstlat1; - //GPstlat2 = Sp->Proj.Gp->GPstlat2; + // GPstlat1 = Sp->Proj.Gp->GPstlat1; + // GPstlat2 = Sp->Proj.Gp->GPstlat2; Pflt = Sp->Pflt; - Prd = Sp->Prd; + Prd = Sp->Prd; /* k0 = 0.994; Standard parallel 80.1 degrees */ k0 = 0.933; /* Standard parallel 60 degrees */ - e = sqrt((double)2 * Pflt - pow(Pflt, (double)2)); + e = sqrt((double)2 * Pflt - pow(Pflt, (double)2)); ptlly *= GPhemis; ptllx *= GPhemis; lon0 = (GPhemis == 1) ? GPlon0 : -GPlon0; aux1 = (1. - e * sin(ptlly)) / (1. + e * sin(ptlly)); - t = tan((PI / 4.) - (ptlly / 2.)) / pow(aux1, (e / (double)2)); + t = tan((PI / 4.) - (ptlly / 2.)) / pow(aux1, (e / (double)2)); aux2 = pow(((double)1 + e), ((double)1 + e)); aux3 = pow(((double)1 - e), ((double)1 - e)); - ro = 2. * Prd * k0 * t / sqrt(aux2 * aux3); + ro = 2. * Prd * k0 * t / sqrt(aux2 * aux3); - aux1 = ro * sin(ptllx - lon0); + aux1 = ro * sin(ptllx - lon0); ptlly = -ro * cos(ptllx - lon0); aux1 *= GPhemis; ptlly *= GPhemis; @@ -1234,7 +1234,7 @@ } /******************************************************************* - POLAR STEREOGRAPHIC TO GEODETIC COORDINATES + POLAR STEREOGRAPHIC TO GEODETIC COORDINATES ********************************************************************/ CPoint pPolPC2LL(SProjection* Sp, CPoint ptpc) { @@ -1252,17 +1252,17 @@ py = (double)ptpc.Y; GPhemis = Sp->Proj.Gp->GPhemis; - //GPlat0 = Sp->Proj.Gp->GPlat0; + // GPlat0 = Sp->Proj.Gp->GPlat0; GPlon0 = Sp->Proj.Gp->GPlon0; - //GPstlat1 = Sp->Proj.Gp->GPstlat1; - //GPstlat2 = Sp->Proj.Gp->GPstlat2; + // GPstlat1 = Sp->Proj.Gp->GPstlat1; + // GPstlat2 = Sp->Proj.Gp->GPstlat2; Pflt = Sp->Pflt; - Prd = Sp->Prd; + Prd = Sp->Prd; /* k0 = 0.994; Standard parallel 80.1 degrees */ - k0 = 0.933; /* Standard parallel 60 degrees */ + k0 = 0.933; /* Standard parallel 60 degrees */ equad = 2. * Pflt - pow(Pflt, (double)2); - e = sqrt(equad); + e = sqrt(equad); if (GPhemis == -1) { px *= GPhemis; @@ -1271,11 +1271,11 @@ lon0 = (GPhemis == 1) ? GPlon0 : -GPlon0; - ro = sqrt(px * px + py * py); + ro = sqrt(px * px + py * py); aux1 = pow(((double)1 + e), ((double)1 + e)); aux2 = pow(((double)1 - e), ((double)1 - e)); - t = (ro * sqrt(aux1 * aux2)) / (2. * Prd * k0); - xx = PI / 2. - 2. * atan(t); + t = (ro * sqrt(aux1 * aux2)) / (2. * Prd * k0); + xx = PI / 2. - 2. * atan(t); aux3 = equad / 2. + 5. * equad * equad / 24. + equad * equad * equad / 12.; aux4 = 7. * equad * equad / 48. + 29. * equad * equad * equad / 240.; aux5 = 7. * equad * equad * equad / 120.; @@ -1329,14 +1329,14 @@ } /******************************************************************** - GEODETIC TO MERCATOR COORDINATES + GEODETIC TO MERCATOR COORDINATES ********************************************************************/ CPoint pMerLL2PC(SProjection* Sp, CPoint ptll) { double equad, /*Squared eccentricity */ aux1, /* Ancillary variables */ aux2, aux3, aux4, aux5, aux6, ptllx, ptlly; - //short GPhemis; + // short GPhemis; double Pflt, Prd; double GPlon0, GPstlat1; CPoint ppc; @@ -1344,22 +1344,22 @@ ptllx = (double)ptll.X; ptlly = (double)ptll.Y; - //GPhemis = Sp->Proj.Gp->GPhemis; - //GPlat0 = Sp->Proj.Gp->GPlat0; - GPlon0 = Sp->Proj.Gp->GPlon0; + // GPhemis = Sp->Proj.Gp->GPhemis; + // GPlat0 = Sp->Proj.Gp->GPlat0; + GPlon0 = Sp->Proj.Gp->GPlon0; GPstlat1 = Sp->Proj.Gp->GPstlat1; - //GPstlat2 = Sp->Proj.Gp->GPstlat2; + // GPstlat2 = Sp->Proj.Gp->GPstlat2; Pflt = Sp->Pflt; - Prd = Sp->Prd; + Prd = Sp->Prd; equad = 2. * Pflt - pow(Pflt, (double)2); - aux1 = (1. + tan(ptlly / (double)2)) / (1. - tan(ptlly / (double)2)); - aux2 = (equad + equad * equad / 4. + equad * equad * equad / 8.) * sin(ptlly); - aux3 = (equad * equad / 12. + equad * equad * equad / 16.) * sin((double)3 * ptlly); - aux4 = (equad * equad * equad / 80.) * sin((double)5 * ptlly); - aux5 = cos(GPstlat1); - aux6 = 1. / sqrt((double)1 - equad * pow(sin(GPstlat1), (double)2)); + aux1 = (1. + tan(ptlly / (double)2)) / (1. - tan(ptlly / (double)2)); + aux2 = (equad + equad * equad / 4. + equad * equad * equad / 8.) * sin(ptlly); + aux3 = (equad * equad / 12. + equad * equad * equad / 16.) * sin((double)3 * ptlly); + aux4 = (equad * equad * equad / 80.) * sin((double)5 * ptlly); + aux5 = cos(GPstlat1); + aux6 = 1. / sqrt((double)1 - equad * pow(sin(GPstlat1), (double)2)); ptllx = Prd * (ptllx - GPlon0) * aux5 * aux6; ptlly = Prd * (log(aux1) - aux2 + aux3 - aux4) * aux5 * aux6; @@ -1371,14 +1371,14 @@ } /******************************************************************** - MERCATOR TO GEODETIC COORDINATES + MERCATOR TO GEODETIC COORDINATES ********************************************************************/ CPoint pMerPC2LL(SProjection* Sp, CPoint ptpc) { double equad, /*Squared eccentricity */ t, /* Ancillary variables */ xx, aux1, aux2, aux3, aux4, aux5, ptpcx, ptpcy; - //short GPhemis; + // short GPhemis; double GPlon0, GPstlat1; double Pflt, Prd; CPoint ppc; @@ -1386,26 +1386,26 @@ ptpcx = (double)ptpc.X; ptpcy = (double)ptpc.Y; - //GPhemis = Sp->Proj.Gp->GPhemis; - //GPlat0 = Sp->Proj.Gp->GPlat0; - GPlon0 = Sp->Proj.Gp->GPlon0; + // GPhemis = Sp->Proj.Gp->GPhemis; + // GPlat0 = Sp->Proj.Gp->GPlat0; + GPlon0 = Sp->Proj.Gp->GPlon0; GPstlat1 = Sp->Proj.Gp->GPstlat1; - //GPstlat2 = Sp->Proj.Gp->GPstlat2; + // GPstlat2 = Sp->Proj.Gp->GPstlat2; Pflt = Sp->Pflt; - Prd = Sp->Prd; + Prd = Sp->Prd; equad = 2. * Pflt - pow(Pflt, (double)2); - aux1 = cos(GPstlat1); - aux2 = 1. / sqrt((double)1 - equad * pow(sin(GPstlat1), (double)2)); + aux1 = cos(GPstlat1); + aux2 = 1. / sqrt((double)1 - equad * pow(sin(GPstlat1), (double)2)); ptpcx = ptpcx / (aux1 * aux2); ptpcy = ptpcy / (aux1 * aux2); - t = exp(-ptpcy / Prd); - xx = PI / 2. - 2. * atan(t); - aux3 = (equad / 2. + 5. * equad * equad / 24. + equad * equad * equad / 12.) * sin(4. * atan(t)); - aux4 = -(7. * equad * equad / 48. + 29. * equad * equad * equad / 240.) * sin(8. * atan(t)); - aux5 = (7. * equad * equad * equad / 120.) * sin(12. * atan(t)); + t = exp(-ptpcy / Prd); + xx = PI / 2. - 2. * atan(t); + aux3 = (equad / 2. + 5. * equad * equad / 24. + equad * equad * equad / 12.) * sin(4. * atan(t)); + aux4 = -(7. * equad * equad / 48. + 29. * equad * equad * equad / 240.) * sin(8. * atan(t)); + aux5 = (7. * equad * equad * equad / 120.) * sin(12. * atan(t)); ptpcy = xx + aux3 + aux4 + aux5; ptpcx = ptpcx / Prd + GPlon0; @@ -1424,15 +1424,15 @@ unsigned long outsidevalue, unsigned char* tbuf, SProjection* IProj) { - Im->IProj = IProj; - Im->IBBox = IBBox; - Im->Inx = Inx; - Im->Iny = Iny; - Im->Irx = Irx; - Im->Iry = Iry; - Im->pixel = pixel; + Im->IProj = IProj; + Im->IBBox = IBBox; + Im->Inx = Inx; + Im->Iny = Iny; + Im->Irx = Irx; + Im->Iry = Iry; + Im->pixel = pixel; Im->outsidevalue = outsidevalue; - Im->tbuf = tbuf; + Im->tbuf = tbuf; } void pInterpolateIn(SImage* Imi, SImage* Imo, CPoint poll, CPoint pour, CPoint poul, CPoint polr, CPoint pill, CPoint piur, CPoint piul, CPoint pilr) @@ -1469,12 +1469,12 @@ pBBoxRemapInOut(Imo->IProj, p, &da); paux = pCoord2Index(Imo, &poul); - x1 = (short)(paux.X + .5); - y1 = (short)(paux.Y + .5); + x1 = (short)(paux.X + .5); + y1 = (short)(paux.Y + .5); paux = pCoord2Index(Imo, &polr); - x2 = (short)(paux.X + .5); - y2 = (short)(paux.Y + .5); + x2 = (short)(paux.X + .5); + y2 = (short)(paux.Y + .5); if (!pIntersects(&da, Imi->IBBox)) { /*printf (" Out Image x1=%4d y1=%4d x2=%4d y2=%4d",x1,y1,x2,y2);*/ @@ -1501,15 +1501,15 @@ continue; paux = pCoord2Index(Imi, &paux); - c = pInterAt(Imi, &paux); + c = pInterAt(Imi, &paux); pPut(Imo, i, j, c); } } return; } - /* Check if linear interpolation may be performed on input image -Evaluate point at middle of the edges and check if these points belong + /* Check if linear interpolation may be performed on input image +Evaluate point at middle of the edges and check if these points belong to the edges in input image domain.If they belong,a linear interpolation may be performed, else subdivide output image in four quadrants and try interpolating again */ @@ -1551,9 +1551,9 @@ } - /* Check special case for Satellite projection, when an area outside the globe - is being remapped, therefore none of these points will have valid values and - we will give up. */ + /* Check special case for Satellite projection, when an area outside the globe + is being remapped, therefore none of these points will have valid values and + we will give up. */ if (pTooBig(&piu) && pTooBig(&pib) && @@ -1703,7 +1703,7 @@ unsigned char* p; if (((lin < Im->Iny) && (col < Im->Inx) && (lin >= 0)) || col >= 0) { - p = Im->tbuf; + p = Im->tbuf; p[(int)(lin * Im->Inx + col)] = c; } else { @@ -1729,8 +1729,8 @@ CPoint q; short ss; - x = (p->X - Im->IBBox->Bll.X) / Im->Irx; - y = (Im->IBBox->Bur.Y - p->Y) / Im->Iry; + x = (p->X - Im->IBBox->Bll.X) / Im->Irx; + y = (Im->IBBox->Bur.Y - p->Y) / Im->Iry; ss = Im->Inx; if (x > ss) x = ss; @@ -1808,7 +1808,7 @@ } /* Start generating grid */ /* - printf("Start InterpolateIn:%f,%f,%f,%f\n",poll.X,poll.Y,pour.X,pour.Y); + printf("Start InterpolateIn:%f,%f,%f,%f\n",poll.X,poll.Y,pour.X,pour.Y); */ XXX = 0; pInterpolateIn(Imi, Imo, poll, pour, poul, polr, pill, piur, piul, pilr); @@ -1831,26 +1831,26 @@ resy = Imi->Iry; else resy = ry; - x1 = IBBox->Bll.X; - y1 = IBBox->Bll.Y; - x2 = IBBox->Bur.X; - y2 = IBBox->Bur.Y; - nx = (short)(ABS((x2 - x1) / resx) + 1.); - ny = (short)(ABS((y2 - y1) / resy) + 1.); - Imo->Inx = nx; - Imo->Iny = ny; - incx = (x2 - x1) / (Real)(nx - 1); - incy = (y2 - y1) / (Real)(ny - 1); - Imo->Irx = ABS(incx); - Imo->Iry = ABS(incy); - Imo->pixel = Imi->pixel; + x1 = IBBox->Bll.X; + y1 = IBBox->Bll.Y; + x2 = IBBox->Bur.X; + y2 = IBBox->Bur.Y; + nx = (short)(ABS((x2 - x1) / resx) + 1.); + ny = (short)(ABS((y2 - y1) / resy) + 1.); + Imo->Inx = nx; + Imo->Iny = ny; + incx = (x2 - x1) / (Real)(nx - 1); + incy = (y2 - y1) / (Real)(ny - 1); + Imo->Irx = ABS(incx); + Imo->Iry = ABS(incy); + Imo->pixel = Imi->pixel; Imo->outsidevalue = Imi->outsidevalue; bufp = (unsigned char*)malloc((int)(sizeof(unsigned char) * nx * ny)); bufc = bufp; for (i = 0; i < (int)nx * ny; i++) *bufc++ = (unsigned char)0; - *tmpbuf = bufp; + *tmpbuf = bufp; Imo->tbuf = bufp; pRemapI(Imi, Imo); diff -Nru metview-5.17.4/metview/src/libMetview/proj_braz.hpp metview-5.19.2/metview/src/libMetview/proj_braz.hpp --- metview-5.17.4/metview/src/libMetview/proj_braz.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/proj_braz.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -121,7 +121,7 @@ #define PFIRSTLAT 0x10 #define PSECDLAT 0x20 -//F +// F #if 0 #define MAGEnqi(par, iv) penqi_(par, iv, strlen(par)) #define MAGEnqc(par, cv) \ @@ -268,7 +268,7 @@ unsigned long pixel; /* pixel out of image*/ unsigned long outsidevalue; /* Default value to pixels outside Image -*/ + */ unsigned char* tbuf; /* buffer for transfer data*/ } SImage; diff -Nru metview-5.17.4/metview/src/libMetview/Request.cc metview-5.19.2/metview/src/libMetview/Request.cc --- metview-5.17.4/metview/src/libMetview/Request.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Request.cc 2023-07-15 08:28:47.000000000 +0000 @@ -78,7 +78,7 @@ Request Request::fromText(const std::string& txt) { - //request* r=string2request(txt.c_str()); + // request* r=string2request(txt.c_str()); MvRequest r(string2request(txt.c_str())); return Request(r); } diff -Nru metview-5.17.4/metview/src/libMetview/Request.h metview-5.19.2/metview/src/libMetview/Request.h --- metview-5.17.4/metview/src/libMetview/Request.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Request.h 2023-07-15 08:28:47.000000000 +0000 @@ -108,7 +108,7 @@ // -- Friends - //friend std::ostream& operator<<(std::ostream& s,const Request& p) + // friend std::ostream& operator<<(std::ostream& s,const Request& p) // { p.print(s); return s; } }; @@ -116,5 +116,5 @@ // If persistent, uncomment, otherwise remove //#ifdef _ODI_OSSG_ -//OS_MARK_SCHEMA_TYPE(Request); +// OS_MARK_SCHEMA_TYPE(Request); //#endif diff -Nru metview-5.17.4/metview/src/libMetview/StatsCompute.cc metview-5.19.2/metview/src/libMetview/StatsCompute.cc --- metview-5.17.4/metview/src/libMetview/StatsCompute.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/StatsCompute.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,198 @@ +/***************************** LICENSE START *********************************** + + Copyright 2012 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + +#include "StatsCompute.h" + +#include +#include + +namespace metview +{ + +void AggregateStatsCompute::reset() +{ + aggr_ = 0.; + aggr2_ = 0.; + weight_ = 0.; + cnt_ = 0; +} + +//==================================== +// +// AverageStatsCompute +// +//==================================== + +void MeanStatsCompute::add(double v) +{ + aggr_ += v; + cnt_++; +} + +void MeanStatsCompute::add(double v, double weight) +{ + aggr_ += v * weight; + weight_ += weight; + cnt_++; +} + +double MeanStatsCompute::compute(bool weighted) +{ + if (cnt_ > 0) { + if (weighted) { + return aggr_ / weight_; + } + return aggr_ / static_cast(cnt_); + } + return invalidVal_; +} + +//==================================== +// +// VarianceStatsCompute +// +//==================================== + +void VarianceStatsCompute::add(double v) +{ + aggr_ += v; + aggr2_ += v * v; + cnt_++; +} + +void VarianceStatsCompute::add(double v, double weight) +{ + double wv = v * weight; + aggr_ += wv; + aggr2_ += wv * v; + weight_ += weight; + cnt_++; +} + +double VarianceStatsCompute::compute(bool weighted) +{ + if (cnt_ > 0) { + if (weighted) { + return aggr2_ / weight_ - (aggr_ * aggr_) / (weight_ * weight_); + } + auto n = static_cast(cnt_); + return aggr2_ / n - (aggr_ * aggr_) / (n * n); + } + return invalidVal_; +} + +//==================================== +// +// StdevStatsCompute +// +//==================================== + +double StdevStatsCompute::compute(bool weighted) +{ + if (cnt_ > 0) { + return std::sqrt(VarianceStatsCompute::compute(weighted)); + } + return invalidVal_; +} + +//==================================== +// +// MaxStatsCompute +// +//==================================== + +void MaxStatsCompute::reset() +{ + val_ = startVal_; +} + +void MaxStatsCompute::add(double v) +{ + if (v > val_) { + val_ = v; + } +} + +void MaxStatsCompute::add(double v, double /*weight*/) +{ + MaxStatsCompute::add(v); +} + +double MaxStatsCompute::compute(bool /*weighted*/) +{ + if (val_ == startVal_) { + return invalidVal_; + } + return val_; +} + +//==================================== +// +// MinStatsCompute +// +//==================================== + +void MinStatsCompute::reset() +{ + val_ = startVal_; +} + +void MinStatsCompute::add(double v) +{ + if (v < val_) { + val_ = v; + } +} + +void MinStatsCompute::add(double v, double /*weight*/) +{ + MinStatsCompute::add(v); +} + +double MinStatsCompute::compute(bool /*weighted*/) +{ + if (val_ == startVal_) { + return invalidVal_; + } + return val_; +} + +//==================================== +// +// MedianStatsCompute +// +//==================================== + +void ArrayStatsCompute::reset() +{ + vals_.clear(); +} + +double MedianStatsCompute::compute(bool /*weighted*/) +{ + if (!vals_.empty()) { + using difference_type = std::vector::difference_type; + + if (vals_.size() == 1) { + return vals_[0]; + } + std::size_t n = vals_.size() / 2; + std::nth_element(vals_.begin(), vals_.begin() + static_cast(n), vals_.end()); + if (vals_.size() % 2 == 1) { + return vals_[n]; + } + auto vn = vals_[n]; + std::nth_element(vals_.begin(), vals_.begin() + static_cast(n - 1), vals_.end()); + const double c2 = 2.; + return (vn + vals_[n - 1]) / c2; + } + return invalidVal_; +} + +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/StatsCompute.h metview-5.19.2/metview/src/libMetview/StatsCompute.h --- metview-5.17.4/metview/src/libMetview/StatsCompute.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/StatsCompute.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,120 @@ +/***************************** LICENSE START *********************************** + + Copyright 2012 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + +#pragma once + +#include +#include +#include +#include + +namespace metview +{ + +class StatsCompute : public std::enable_shared_from_this +{ +public: + StatsCompute() = default; + virtual ~StatsCompute() = default; + void setInvalidValue(double v) { invalidVal_ = v; } + virtual void reset() = 0; + virtual void add(double v) = 0; + virtual void add(double v, double weight) = 0; + virtual double compute(bool weighted) = 0; + bool isInvalidValue(double v) const { return invalidVal_ == v; } + +protected: + double invalidVal_{0}; +}; + +class AggregateStatsCompute : public StatsCompute +{ +public: + AggregateStatsCompute() = default; + void reset() override; + +protected: + double aggr_{0.}; + double aggr2_{0.}; + double weight_{0.}; + std::size_t cnt_{0}; +}; + +class MeanStatsCompute : public AggregateStatsCompute +{ +public: + using AggregateStatsCompute::AggregateStatsCompute; + void add(double) override; + void add(double, double) override; + double compute(bool weighted) override; +}; + +class VarianceStatsCompute : public AggregateStatsCompute +{ +public: + using AggregateStatsCompute::AggregateStatsCompute; + void add(double) override; + void add(double, double) override; + double compute(bool weighted) override; +}; + +class StdevStatsCompute : public VarianceStatsCompute +{ +public: + using VarianceStatsCompute::VarianceStatsCompute; + double compute(bool weighted) override; +}; + +class MaxStatsCompute : public StatsCompute +{ +public: + using StatsCompute::StatsCompute; + void reset() override; + void add(double) override; + void add(double, double) override; + double compute(bool weighted) override; + +protected: + const double startVal_{std::numeric_limits::lowest()}; + double val_{std::numeric_limits::lowest()}; +}; + +class MinStatsCompute : public StatsCompute +{ +public: + using StatsCompute::StatsCompute; + void reset() override; + void add(double) override; + void add(double, double) override; + double compute(bool weighted) override; + +protected: + const double startVal_{std::numeric_limits::max()}; + double val_{std::numeric_limits::max()}; +}; + +class ArrayStatsCompute : public StatsCompute +{ + using StatsCompute::StatsCompute; + void reset() override; + void add(double v) override { vals_.push_back(v); } + void add(double v, double) override { vals_.push_back(v); } + +protected: + std::vector vals_; +}; + +class MedianStatsCompute : public ArrayStatsCompute +{ +public: + using ArrayStatsCompute::ArrayStatsCompute; + double compute(bool weighted) override; +}; + +} // namespace metview diff -Nru metview-5.17.4/metview/src/libMetview/TableReader.cc metview-5.19.2/metview/src/libMetview/TableReader.cc --- metview-5.17.4/metview/src/libMetview/TableReader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/TableReader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,12 +12,15 @@ #ifdef MAGICS #include "MagException.h" #include "MagicsGlobal.h" -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif -void TableReader::resizeDecoders(unsigned int numNeeded) { +void TableReader::resizeDecoders(unsigned int numNeeded) +{ // do we need to resize our list of decoders? if (numNeeded > decoderSets_.size()) { @@ -30,7 +33,8 @@ void TableReader::setFieldContainer(int index, std::string& name, std::vector& container, - double outputMissingIndicator) { + double outputMissingIndicator) +{ if (index == -1) // is the user wanting to find a field with the given name? { int foundIndex = indexOfField(name); // try to find it @@ -54,7 +58,7 @@ // add the decoder to the appropriate place in our list - auto* decoder = new TableDoubleVectorElementDecoder(container, outputMissingIndicator); + auto* decoder = new TableDoubleVectorElementDecoder(container, outputMissingIndicator); auto* genericDecoder = dynamic_cast(decoder); decoderSets_[index].push_back(genericDecoder); //.push_back(genericDecoder); names_[index] = &name; @@ -62,7 +66,8 @@ void TableReader::setFieldContainer(int index, std::string& name, std::vector& container, - std::string outputMissingIndicator) { + std::string outputMissingIndicator) +{ if (index == -1) // is the user wanting to find a field with the given name? { int foundIndex = indexOfField(name); // try to find it @@ -85,7 +90,7 @@ // add the decoder to the appropriate place in our list - auto* decoder = new TableStringVectorElementDecoder(container, outputMissingIndicator); + auto* decoder = new TableStringVectorElementDecoder(container, outputMissingIndicator); auto* genericDecoder = dynamic_cast(decoder); decoderSets_[index].push_back(genericDecoder); //.push_back(genericDecoder); names_[index] = &name; @@ -98,9 +103,10 @@ // NOTE: this function is destructive to the input string! // --------------------------------------------------------------------------- -void TableReader::splitLine(char* line, std::vector& tokens) { +void TableReader::splitLine(char* line, std::vector& tokens) +{ char* current = line; - char* token = current; + char* token = current; while (*current != '\0') { if (*current == delimiter_) // reached the end of a token? @@ -124,9 +130,10 @@ // NOTE: this function is destructive to the input string! // --------------------------------------------------------------------------- -void TableReader::splitLineConsecutiveDelimiters(char* line, std::vector& tokens) { +void TableReader::splitLineConsecutiveDelimiters(char* line, std::vector& tokens) +{ char* current = line; - char* token = current; + char* token = current; if (*current == '\0') // return nothing if it is a blank line return; @@ -155,7 +162,8 @@ } -void TableReader::ensureHaveMetaData() { +void TableReader::ensureHaveMetaData() +{ if (!gotMetaData_) // caller should have retrieved the meta-data already { std::string msg; @@ -166,35 +174,40 @@ } } -std::vector& TableReader::fieldTypes() { +std::vector& TableReader::fieldTypes() +{ ensureHaveMetaData(); return types_; } -std::vector& TableReader::fieldNames() { +std::vector& TableReader::fieldNames() +{ ensureHaveMetaData(); return namesAll_; } -std::map& TableReader::userMetaData() { +std::map& TableReader::userMetaData() +{ ensureHaveMetaData(); return userMetaData_; } -int TableReader::numRecords() { +int TableReader::numRecords() +{ ensureHaveMetaData(); return numRecords_; } -int TableReader::indexOfField(std::string& name) { +int TableReader::indexOfField(std::string& name) +{ ensureHaveMetaData(); @@ -217,7 +230,8 @@ // takes an element and tries to decide which data type it is, e.g. number // --------------------------------------------------------------------------- -TableReader::eTableReaderFieldType TableReader::guessFieldType(char* str) { +TableReader::eTableReaderFieldType TableReader::guessFieldType(char* str) +{ if (str) { char* pch = str; @@ -235,7 +249,8 @@ } -int TableReader::nextLineTokens(char* line, size_t sizeOfLine, std::vector& tokens) { +int TableReader::nextLineTokens(char* line, size_t sizeOfLine, std::vector& tokens) +{ // skip blank lines /* bool gotLine = true; @@ -281,9 +296,10 @@ // PARAM1=VALUE1 PARAM2=VALUE2 // --------------------------------------------------------------------------- -bool TableReader::readUserMetaData(char* line, size_t sizeOfLine, std::string& errorMessage) { - int currentRow = 1; - char oldDelimiter = delimiter_; // store because we will over-ride it +bool TableReader::readUserMetaData(char* line, size_t sizeOfLine, std::string& errorMessage) +{ + int currentRow = 1; + char oldDelimiter = delimiter_; // store because we will over-ride it bool oldConsecutive = consecutiveDelimitersAsOne_; // store because we will over-ride it // we parse each line in two steps: @@ -341,7 +357,8 @@ // into. // --------------------------------------------------------------------------- -void TableReader::skipLines(int linesToSkip, char* line, size_t sizeOfLine) { +void TableReader::skipLines(int linesToSkip, char* line, size_t sizeOfLine) +{ for (int i = 0; i < linesToSkip; i++) { f_.getline(line, sizeOfLine); } @@ -355,7 +372,8 @@ // file. // --------------------------------------------------------------------------- -bool TableReader::getMetaData(std::string& errorMessage) { +bool TableReader::getMetaData(std::string& errorMessage) +{ if (gotMetaData_) // we should only need to get the meta-data once return true; @@ -490,7 +508,8 @@ } -bool TableReader::read(std::string& errorMessage) { +bool TableReader::read(std::string& errorMessage) +{ const int MAX_CHARS_IN_LINE = 1024 * 100; char line[MAX_CHARS_IN_LINE]; @@ -589,10 +608,10 @@ auto s = tokens.begin(); for (auto& decoderSet : decoderSets_) { - for (auto decoder = decoderSet.begin(); decoder != decoderSet.end(); ++decoder) { - if (*decoder != nullptr) { + for (auto& decoder : decoderSet) { + if (decoder != nullptr) { // std::string str(*s); - (*decoder)->addValue(*s); + decoder->addValue(*s); } } s++; diff -Nru metview-5.17.4/metview/src/libMetview/TableReader.h metview-5.19.2/metview/src/libMetview/TableReader.h --- metview-5.17.4/metview/src/libMetview/TableReader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/TableReader.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,11 @@ #include "fstream_mars_fix.h" #ifdef MAGICS -namespace magics { +namespace magics +{ #else -namespace metview { +namespace metview +{ #endif /*! ----------------------------------------------------------------- @@ -28,9 +30,11 @@ file is formatted. ----------------------------------------------------------------- */ -class TableFormatAttributes { +class TableFormatAttributes +{ public: - TableFormatAttributes() : delimiter_(','), headerRow_(1), consecutiveDelimitersAsOne_(false), dataRowOffset_(0) {} + TableFormatAttributes() : + delimiter_(','), headerRow_(1), consecutiveDelimitersAsOne_(false), dataRowOffset_(0) {} void setPath(std::string& path) { path_ = path; } void setPath(const char* path) { path_ = std::string(path); } @@ -63,13 +67,15 @@ particular data types (e.g. double, string). ----------------------------------------------------------------- */ -class TableElementDecoder { +class TableElementDecoder +{ public: - TableElementDecoder() : currentIndex_(0) {} - virtual ~TableElementDecoder() {} + TableElementDecoder() : + currentIndex_(0) {} + virtual ~TableElementDecoder() = default; virtual void initialise(int numValues) = 0; - virtual void addValue(char* value) = 0; + virtual void addValue(char* value) = 0; // virtual void decodeElement (char *element) = 0; protected: @@ -83,13 +89,14 @@ table file. The data will be put into a vector of doubles. ----------------------------------------------------------------- */ -class TableDoubleVectorElementDecoder : public TableElementDecoder { +class TableDoubleVectorElementDecoder : public TableElementDecoder +{ public: TableDoubleVectorElementDecoder(std::vector& target, double outMiss) : target_(target), outputMissingIndicator_(outMiss) {} - void initialise(int numValues) { target_.reserve(numValues); } - void addValue(char* value) { target_.push_back((value[0] != '\0') ? atof(value) : outputMissingIndicator_); } + void initialise(int numValues) override { target_.reserve(numValues); } + void addValue(char* value) override { target_.push_back((value[0] != '\0') ? atof(value) : outputMissingIndicator_); } private: std::vector& target_; @@ -103,13 +110,14 @@ table file. The data will be put into a vector of strings. ----------------------------------------------------------------- */ -class TableStringVectorElementDecoder : public TableElementDecoder { +class TableStringVectorElementDecoder : public TableElementDecoder +{ public: TableStringVectorElementDecoder(std::vector& target, std::string outMiss) : target_(target), outputMissingIndicator_(outMiss) {} - void initialise(int numValues) { target_.reserve(numValues); } - void addValue(char* value) { target_.push_back((value[0] != '\0') ? value : outputMissingIndicator_); } + void initialise(int numValues) override { target_.reserve(numValues); } + void addValue(char* value) override { target_.push_back((value[0] != '\0') ? value : outputMissingIndicator_); } private: std::vector& target_; @@ -117,7 +125,7 @@ }; -typedef std::vector TableElementDecoders; // for shorthand +using TableElementDecoders = std::vector; // for shorthand /*! ----------------------------------------------------------------- @@ -132,7 +140,8 @@ ----------------------------------------------------------------- */ -class TableReader : public TableFormatAttributes { +class TableReader : public TableFormatAttributes +{ public: enum eTableReaderFieldType { @@ -140,14 +149,16 @@ TABFIELD_STRING }; - TableReader() { + TableReader() + { gotMetaData_ = false; - errorCode_ = 0; + errorCode_ = 0; } - TableReader(std::string& path) { + TableReader(std::string& path) + { setPath(path); gotMetaData_ = false; - errorCode_ = 0; + errorCode_ = 0; } void setFieldContainer(int index, std::string& name, std::vector& container, double outputMissingIndicator); @@ -171,12 +182,13 @@ std::vector& tokens); // reads the next line and splits into tokens void splitLine(char* line, std::vector& tokens); // splits a line into tokens based on the current settings void splitLineConsecutiveDelimiters( - char* line, std::vector& tokens); // splits a line into tokens based on the current settings + char* line, std::vector& tokens); // splits a line into tokens based on the current settings bool readUserMetaData(char* line, size_t sizeOfLine, std::string& errorMessage); // reads user meta-data into a map - int indexOfField(std::string& name); // returns the index of the field with a given name (or -1) - void setError(std::string msg) { + int indexOfField(std::string& name); // returns the index of the field with a given name (or -1) + void setError(std::string msg) + { errorCode_ = 1; - errorMsg_ = msg; + errorMsg_ = msg; } // set an error message to be used later void clearError() { errorCode_ = 0; } // clear error message and code to be used later void ensureHaveMetaData(); // loads the meta-data if not already there diff -Nru metview-5.17.4/metview/src/libMetview/Tokenizer.cc metview-5.19.2/metview/src/libMetview/Tokenizer.cc --- metview-5.17.4/metview/src/libMetview/Tokenizer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/Tokenizer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,8 @@ void Tokenizer::operator()(const std::string& raw, std::vector& v) { - int index = 0; - int length = raw.length(); + int index = 0; + int length = raw.length(); std::string token = ""; while (index < length) { diff -Nru metview-5.17.4/metview/src/libMetview/UtilitiesC.c metview-5.19.2/metview/src/libMetview/UtilitiesC.c --- metview-5.17.4/metview/src/libMetview/UtilitiesC.c 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/UtilitiesC.c 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ char* UtRandomName(const char* path, const char* name) { static int count = 0; - char* fname = (char*)malloc(strlen(path) + strlen(name) + ENSIZE); + char* fname = (char*)malloc(strlen(path) + strlen(name) + ENSIZE); sprintf(fname, "%s/%d%s%d", path, getpid(), name, ++count); return fname; } @@ -140,16 +140,16 @@ /************************************************** -* FUNCTION putenv: putenv_ from FORTRAN -***************************************************** -* -* Purpose: Set environment variable -* safely (not destroing) string -* -* -* Function returns: N0n-zero if failing; -* Zero if set; -*/ + * FUNCTION putenv: putenv_ from FORTRAN + ***************************************************** + * + * Purpose: Set environment variable + * safely (not destroing) string + * + * + * Function returns: N0n-zero if failing; + * Zero if set; + */ #ifdef FORTRAN_NO_UNDERSCORE #define cputenv_ cputenv @@ -238,7 +238,7 @@ j = strlen(cmd) - 1; } else { - cmd[++j] = user_cmd[i]; + cmd[++j] = user_cmd[i]; cmd[j + 1] = '\0'; } } diff -Nru metview-5.17.4/metview/src/libMetview/VectorUtils.c metview-5.19.2/metview/src/libMetview/VectorUtils.c --- metview-5.17.4/metview/src/libMetview/VectorUtils.c 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMetview/VectorUtils.c 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ #include "VectorUtils.h" -/* read_vector_from_request +/* read_vector_from_request Reads the given request and reads in the associated vector file. Memory is allocated here for the vector, so it is then the responsibility of the called to handle it. @@ -19,19 +19,18 @@ */ int read_vector_from_request(request* r, double** vec, int* length) { - int size, i; - const char* c; - const char* path; - double* v; + int size = 0; + const char* path = NULL; + double* v = NULL; + FILE* f = NULL; char buf[20] = ""; - FILE* f; - int read; + int readSize = 0; path = get_value(r, "PATH", 0); /* get the path to the storage file */ f = fopen(path, "r"); - if (!f) { + if (f == NULL) { marslog(LOG_EXIT, "read_vector_from_request: unable to load file %s", path); return MV_VECTOR_READ_ERROR; } @@ -39,40 +38,42 @@ fread(buf, sizeof(char), 14, f); buf[14] = '\0'; - if (strcmp(buf, "METVIEW_VECTOR")) { + if (strcmp(buf, "METVIEW_VECTOR") != 0) { + fclose(f); marslog(LOG_EXIT, "read_vector_from_request: start of vector file should be METVIEW_VECTOR. Is: %s", buf); return MV_VECTOR_READ_ERROR; } fread(buf, sizeof(char), 10, f); /* read the data type */ buf[10] = '\0'; - if (strncmp(buf, "float64", 7)) /* we only allow this for now */ + if (strncmp(buf, "float64", 7) != 0) /* we only allow this for now */ { + fclose(f); marslog(LOG_EXIT, "read_vector_from_request: only allow float64 values just now. Is: '%s'", buf); return MV_VECTOR_READ_ERROR; } - fread(&size, sizeof(int), 1, f); /* read the number of values */ - /*-- vector to be returned, must be free'd by the calling pgm --*/ v = malloc(size * sizeof(double)); if (!v) { + fclose(f); marslog(LOG_EXIT, "read_vector_from_request: unable to get memory for %d elements", size); return MV_VECTOR_READ_ERROR; } - read = fread(v, sizeof(double), size, f); /* read the values */ + readSize = fread(v, sizeof(double), size, f); /* read the values */ fclose(f); - if (read != size) { - marslog(LOG_EXIT, "read_vector_from_request: tried to write %d elements - managed %d.", size, read); + if (readSize != size) { + free(v); + marslog(LOG_EXIT, "read_vector_from_request: tried to write %d elements - managed %d.", size, readSize); return MV_VECTOR_READ_ERROR; } - *vec = v; + *vec = v; *length = size; } return MV_VECTOR_READ_OK; diff -Nru metview-5.17.4/metview/src/libMvMacroApi/macro_api.c metview-5.19.2/metview/src/libMvMacroApi/macro_api.c --- metview-5.17.4/metview/src/libMvMacroApi/macro_api.c 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvMacroApi/macro_api.c 2023-07-15 08:28:47.000000000 +0000 @@ -71,12 +71,12 @@ #endif -static int argc = 0; -static int argn = 0; -static arg* args = NULL; +static int argc = 0; +static int argn = 0; +static arg* args = NULL; static boolean sFirst = true; -static char* sName = NULL; -static char* sFile = NULL; +static char* sName = NULL; +static char* sFile = NULL; /* To avoid sending pointers back to the user program, we maintain a list of all @@ -84,13 +84,13 @@ */ static fortint num_gribargs = 0; -static void** gribargs = NULL; +static void** gribargs = NULL; static fortint add_new_gribarg_pointer(void* new_gribarg_ptr) { num_gribargs++; - gribargs = realloc(gribargs, num_gribargs * sizeof(void*)); + gribargs = realloc(gribargs, num_gribargs * sizeof(void*)); gribargs[num_gribargs - 1] = new_gribarg_ptr; return num_gribargs - 1; } @@ -164,7 +164,7 @@ return; args = NEW_ARRAY(arg, argc); - i = 0; + i = 0; while (r) { const char* t = r->name; @@ -173,27 +173,27 @@ if (t == NULL) marslog(LOG_EXIT, "No data type"); else if (EQ(t, "NUMBER")) { - args[i].kind = 'N'; + args[i].kind = 'N'; args[i].u.dval = v ? atof(v) : 0.0; } else if (EQ(t, "STRING")) { - args[i].kind = 'S'; + args[i].kind = 'S'; args[i].u.sval = strcache(v ? v : ""); } else if (EQ(t, "GRIB")) { - args[i].kind = 'G'; + args[i].kind = 'G'; args[i].u.rval = r; } else if (EQ(t, "BUFR")) { - args[i].kind = 'B'; + args[i].kind = 'B'; args[i].u.rval = r; } else if (EQ(t, "IMAGE")) { - args[i].kind = 'I'; + args[i].kind = 'I'; args[i].u.rval = r; } else if (EQ(t, "VECTOR")) { - args[i].kind = 'V'; + args[i].kind = 'V'; args[i].u.rval = r; } else @@ -329,8 +329,8 @@ if (!v) return 1; - *g = NEW_CLEAR(gribarg); - *c = v->count; + *g = NEW_CLEAR(gribarg); + *c = v->count; (*g)->v = v; return 0; } @@ -339,13 +339,13 @@ { fortint newga; gribarg* gc = NULL; - int err = mgetg_C(&gc, (int*)c); + int err = mgetg_C(&gc, (int*)c); if (err) marslog(LOG_EXIT, "MGETG, Cannot load grib file"); newga = add_new_gribarg_pointer(gc); - *g = newga; + *g = newga; } static fieldset* geti(fortint n) @@ -390,23 +390,23 @@ { fortint newga; fieldset* v = geti(0); - gribarg* a = NEW_CLEAR(gribarg); + gribarg* a = NEW_CLEAR(gribarg); if (!v) { marslog(LOG_EXIT, "MGETI, Cannot load image file"); } else { - *c = v->count; - a->v = v; + *c = v->count; + a->v = v; newga = add_new_gribarg_pointer(a); - *g = newga; + *g = newga; } } void mloadg_(fortint* g, char* p, fortint* c) { - gribarg* a = (gribarg*)(get_gribarg_ptr_from_index(*g)); - fieldset* v = a->v; - int i = a->cnt++; + gribarg* a = (gribarg*)(get_gribarg_ptr_from_index(*g)); + fieldset* v = a->v; + int i = a->cnt++; long int msg_len = (*c) * sizeof(fortint); minit(); @@ -424,7 +424,7 @@ fclose(a->f); strfree(a->file); a->file = strcache(v->fields[i]->file->fname); - a->f = fopen(a->file, "r"); + a->f = fopen(a->file, "r"); if (a->f == NULL) marslog(LOG_EXIT | LOG_PERR, "MLOADG, cannot open %s", a->file); } @@ -443,15 +443,15 @@ fortint newga; gribarg* a; minit(); - a = NEW_CLEAR(gribarg); + a = NEW_CLEAR(gribarg); newga = add_new_gribarg_pointer(a); - *g = newga; + *g = newga; } void mrewg_(fortint* g) /*-- mrewg: rewind fieldset (warning: no checks done!) --*/ { gribarg* a = (gribarg*)(get_gribarg_ptr_from_index(*g)); - a->cnt = 0; + a->cnt = 0; } /* here *c gives the length of GRIB msg in Fortran integers */ @@ -471,13 +471,13 @@ if (a->f == NULL) { a->file = strcache(marstmp()); - a->f = fopen(a->file, "w"); + a->f = fopen(a->file, "w"); if (a->f == NULL) marslog(LOG_EXIT | LOG_PERR, "MSAVEG: Cannot open %s", a->file); } length = *c; - pad = ((length + 119) / 120) * 120 - length; + pad = ((length + 119) / 120) * 120 - length; if (fwrite(p, 1, length, a->f) != length) marslog(LOG_EXIT | LOG_PERR, "MSAVEG: Error while writing to disk"); @@ -763,8 +763,8 @@ mci_get_string() { static char* strbuf = 0; - static int sbuflen = 0; - fortint n = 0; + static int sbuflen = 0; + fortint n = 0; char* p; mcheck(&n, 'S', "string"); @@ -774,7 +774,7 @@ if ((n + 1) > sbuflen) { free(strbuf); sbuflen = n + 1; - strbuf = (char*)malloc(sbuflen); + strbuf = (char*)malloc(sbuflen); } if (strbuf) { @@ -823,7 +823,7 @@ f = fopen(sFile, "a+"); /* append to the return request file */ path = marstmp(); - fv = fopen(path, "w"); + fv = fopen(path, "w"); if (fv) { write_vector_to_file(fv, length, vec); @@ -842,7 +842,6 @@ */ void* mci_get_fieldset(int* field_count) { - fortint newga; gribarg* ga = (gribarg*)malloc(sizeof(gribarg)); if (mgetg_C(&ga, field_count) != 0) { field_count = 0; @@ -873,9 +872,9 @@ grib_handle* mci_load_one_grib(void* fieldset_ptr) { - gribarg* ga = (gribarg*)fieldset_ptr; - char* grib_msg = NULL; - field* cur_msg = NULL; + gribarg* ga = (gribarg*)fieldset_ptr; + char* grib_msg = NULL; + field* cur_msg = NULL; long int msg_len = 0; grib_handle* gh; fieldset* fs; @@ -964,9 +963,9 @@ { /* writes a GRIB msg into fieldset created by 'mci_new_fieldset' */ const void* buffer = NULL; - size_t size = 0; - int err = 0; - fortint sizeint = 0; + size_t size = 0; + int err = 0; + fortint sizeint = 0; /* get the coded message in a buffer */ err = grib_get_message(gh, &buffer, &size); @@ -1033,7 +1032,7 @@ /*------------------------------------- m f i _ ---------------------------------*/ /*-------------------------------------------------------- mfi-number -*/ + */ void mfi_get_number_(fortfloat* d) { *d = mci_get_number(); @@ -1045,19 +1044,19 @@ } /*-------------------------------------------------------- mfi-string -*/ + */ void mfi_get_string_(char* s, fortint s_len) { - int i = 0; + int i = 0; const char* c_str = mci_get_string(); /* get a C string + memory! */ strncpy(s, c_str, s_len); /* use strncpy for safety */ /* Fortran strings do not use the terminating null - * character, so we need to remove it and fill the - * rest with spaces (if 's' longer than 'str'), i.e. - * we need to convert the C string to a Fortran string: - */ + * character, so we need to remove it and fill the + * rest with spaces (if 's' longer than 'str'), i.e. + * we need to convert the C string to a Fortran string: + */ if (strlen(c_str) < s_len) /* append spaces... */ { for (i = s_len; i > strlen(c_str); --i) @@ -1073,9 +1072,9 @@ void mfi_return_string_(char* s, fortint s_len) { /* Fortran string 's' does not contain the terminating - * null character, so we need to add it, i.e. - * we need to convert the Fortran string to a C string: - */ + * null character, so we need to add it, i.e. + * we need to convert the Fortran string to a C string: + */ char* str = (char*)malloc(s_len + 1); /* temporary only */ strncpy(str, s, s_len); /* need to use 'strncpy' */ str[s_len] = '\0'; /* add the terminator */ @@ -1086,7 +1085,7 @@ } /*-------------------------------------------------------- mfi-vector -*/ + */ void mfi_get_vector_(double* vec, int* length) { double* v; @@ -1114,7 +1113,7 @@ } /*-------------------------------------------------------- mfi-fieldset -*/ + */ /* To avoid sending pointers back to the user program, we maintain a list of all @@ -1122,12 +1121,12 @@ */ static int num_fieldsets = 0; -static void** fieldsets = NULL; +static void** fieldsets = NULL; static int add_new_mfi_fieldset_pointer(void* new_fieldset_id) { num_fieldsets++; - fieldsets = realloc(fieldsets, num_fieldsets * sizeof(void*)); + fieldsets = realloc(fieldsets, num_fieldsets * sizeof(void*)); fieldsets[num_fieldsets - 1] = new_fieldset_id; return num_fieldsets - 1; } @@ -1140,11 +1139,11 @@ void mfi_get_fieldset_(fortint* fieldset_id, fortint* field_count) { - int fc = 0; + int fc = 0; void* new_id_ptr = mci_get_fieldset(&fc); - int new_id = add_new_mfi_fieldset_pointer(new_id_ptr); - *fieldset_id = new_id; - *field_count = fc; + int new_id = add_new_mfi_fieldset_pointer(new_id_ptr); + *fieldset_id = new_id; + *field_count = fc; } void mfi_rewind_fieldset_(fortint* fieldset_id_index) @@ -1156,7 +1155,7 @@ void mfi_new_fieldset_(fortint* fieldset_id) { void* new_id_ptr = mci_new_fieldset(); - *fieldset_id = add_new_mfi_fieldset_pointer(new_id_ptr); + *fieldset_id = add_new_mfi_fieldset_pointer(new_id_ptr); } void mfi_return_fieldset_(fortint* fieldset_id_index) @@ -1166,15 +1165,15 @@ /*-------------------------------------------------------- mfi-misc -*/ + */ void mfi_args_(fortint* c, char* a, fortint s_len) { /* about Fortran strings: see mfi_get_string_ and mfi_return_string_ */ - int i = 0; - const char* c_str = mci_args(); /* get args as C string */ - *c = mci_arg_count(); /* equal to strlen(c_str) */ + int i = 0; + const char* c_str = mci_args(); /* get args as C string */ + *c = mci_arg_count(); /* equal to strlen(c_str) */ strncpy(a, c_str, s_len); /* copy to Fortran string */ @@ -1210,7 +1209,7 @@ { int current; void* fieldset_id = get_fieldset_id_ptr_from_index(*fieldset_id_index); - gribarg* ga = (gribarg*)(fieldset_id); + gribarg* ga = (gribarg*)(fieldset_id); if (!ga) /* ensure fieldset exists */ { marslog(LOG_EROR, "mfi_load_one_grib: fieldset_id is NULL"); @@ -1234,9 +1233,9 @@ void mifi_load_one_grib_to_memory_(fortint* fieldset_id_index, char* grib_in_memory) { void* fieldset_id = get_fieldset_id_ptr_from_index(*fieldset_id_index); - gribarg* ga = (gribarg*)(fieldset_id); - field* cur_msg = NULL; - long int msg_len = 0; + gribarg* ga = (gribarg*)(fieldset_id); + field* cur_msg = NULL; + long int msg_len = 0; grib_handle* gh; fieldset* fs; int fi; @@ -1282,7 +1281,7 @@ void mifi_save_one_grib_to_file_(fortint* fieldset_id_index, char* grib_data, fortint* bytecount) { void* fieldset_id = get_fieldset_id_ptr_from_index(*fieldset_id_index); - fortint ga_index = get_gribarg_index_from_ptr(fieldset_id); + fortint ga_index = get_gribarg_index_from_ptr(fieldset_id); msavebyteg_(&ga_index, grib_data, bytecount); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/AbstractSearchLine.cc metview-5.19.2/metview/src/libMvQtGui/AbstractSearchLine.cc --- metview-5.17.4/metview/src/libMvQtGui/AbstractSearchLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/AbstractSearchLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -73,16 +73,16 @@ // set the menu on the Options toolbutton caseSensitive_ = false; - wholeWords_ = false; - highlightAll_ = false; - auto* menu = new QMenu(this); + wholeWords_ = false; + highlightAll_ = false; + auto* menu = new QMenu(this); menu->addAction(actionCaseSensitive_); menu->addAction(actionWholeWords_); menu->addAction(actionHighlightAll_); optionsTb_->setMenu(menu); matchModeCb_->setMatchMode(StringMatchMode::ContainsMatch); // set the default match mode - //matchModeChanged(1); // dummy call to initialise the 'whole words' option state + // matchModeChanged(1); // dummy call to initialise the 'whole words' option state setConfirmSearch(false); } @@ -92,13 +92,13 @@ void AbstractSearchLine::setColours() { QString group = "searchline"; - notFoundSh_ = MvQTheme::styleSheet(group, "not_found"); - oriSh_ = MvQTheme::styleSheet(group, "normal"); + notFoundSh_ = MvQTheme::styleSheet(group, "not_found"); + oriSh_ = MvQTheme::styleSheet(group, "normal"); } void AbstractSearchLine::clear() { - //clearRequested(); + // clearRequested(); searchLine_->clear(); } @@ -156,10 +156,10 @@ void AbstractSearchLine::setConfirmSearch(bool confirmSearch) { confirmSearch_ = confirmSearch; - //confirmSearchLabel_->setVisible(confirmSearch_); + // confirmSearchLabel_->setVisible(confirmSearch_); if (confirmSearch_) { - //confirmSearchLabel_->showWarning("Large file mode"); + // confirmSearchLabel_->showWarning("Large file mode"); if (searchLine_->text().isEmpty()) { status_ = false; toDefaultState(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/AbstractSearchLine.h metview-5.19.2/metview/src/libMvQtGui/AbstractSearchLine.h --- metview-5.17.4/metview/src/libMvQtGui/AbstractSearchLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/AbstractSearchLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,8 @@ Q_OBJECT public: - explicit AbstractSearchLine(QWidget* parent = 0); - virtual ~AbstractSearchLine(); + explicit AbstractSearchLine(QWidget* parent = nullptr); + ~AbstractSearchLine() override; virtual void clear(); virtual bool isEmpty(); void selectAll(); @@ -39,8 +39,8 @@ public Q_SLOTS: virtual void slotFind(QString) = 0; - virtual void slotFindNext() = 0; - virtual void slotFindPrev() = 0; + virtual void slotFindNext() = 0; + virtual void slotFindPrev() = 0; virtual void slotClose(); virtual void on_actionCaseSensitive__toggled(bool); virtual void on_actionWholeWords__toggled(bool); @@ -53,9 +53,9 @@ void setColours(); void updateButtons(bool); void toDefaultState(); - void hideEvent(QHideEvent* event); - void showEvent(QShowEvent* event); - void paintEvent(QPaintEvent*); + void hideEvent(QHideEvent* event) override; + void showEvent(QShowEvent* event) override; + void paintEvent(QPaintEvent*) override; bool status_; bool caseSensitive_; diff -Nru metview-5.17.4/metview/src/libMvQtGui/AbstractTextEditSearchInterface.cc metview-5.19.2/metview/src/libMvQtGui/AbstractTextEditSearchInterface.cc --- metview-5.17.4/metview/src/libMvQtGui/AbstractTextEditSearchInterface.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/AbstractTextEditSearchInterface.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,6 +18,6 @@ void AbstractTextEditSearchInterface::setColours() { - QString group = "textedit"; + QString group = "textedit"; highlightColour_ = MvQTheme::colour(group, "highlight_all"); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/AbstractTextEditSearchInterface.h metview-5.19.2/metview/src/libMvQtGui/AbstractTextEditSearchInterface.h --- metview-5.17.4/metview/src/libMvQtGui/AbstractTextEditSearchInterface.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/AbstractTextEditSearchInterface.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,25 +20,25 @@ { public: AbstractTextEditSearchInterface(); - virtual ~AbstractTextEditSearchInterface() {} + virtual ~AbstractTextEditSearchInterface() = default; virtual bool findString(QString str, bool highlightAll, QTextDocument::FindFlags findFlags, QTextCursor::MoveOperation move, int iteration, StringMatchMode::Mode matchMode) = 0; - virtual void automaticSearchForKeywords(bool) = 0; - virtual void refreshSearch() = 0; - virtual void clearHighlights() = 0; - virtual void disableHighlights() = 0; - virtual void enableHighlights() = 0; - virtual bool highlightsNeedSearch() = 0; - virtual void gotoLastLine() = 0; + virtual void automaticSearchForKeywords(bool) = 0; + virtual void refreshSearch() = 0; + virtual void clearHighlights() = 0; + virtual void disableHighlights() = 0; + virtual void enableHighlights() = 0; + virtual bool highlightsNeedSearch() = 0; + virtual void gotoLastLine() = 0; protected: void setColours(); QColor highlightColour_; - MvQProperty* vpPerformAutomaticSearch_; - MvQProperty* vpAutomaticSearchMode_; - MvQProperty* vpAutomaticSearchText_; - MvQProperty* vpAutomaticSearchFrom_; - MvQProperty* vpAutomaticSearchCase_; + MvQProperty* vpPerformAutomaticSearch_{nullptr}; + MvQProperty* vpAutomaticSearchMode_{nullptr}; + MvQProperty* vpAutomaticSearchText_{nullptr}; + MvQProperty* vpAutomaticSearchFrom_{nullptr}; + MvQProperty* vpAutomaticSearchCase_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/CalendarDialog.h metview-5.19.2/metview/src/libMvQtGui/CalendarDialog.h --- metview-5.17.4/metview/src/libMvQtGui/CalendarDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/CalendarDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ Q_OBJECT public: - CalendarDialog(QWidget* parent = 0); + CalendarDialog(QWidget* parent = nullptr); void setSelectedDate(QDate); Q_SIGNALS: diff -Nru metview-5.17.4/metview/src/libMvQtGui/CMakeLists.txt metview-5.19.2/metview/src/libMvQtGui/CMakeLists.txt --- metview-5.17.4/metview/src/libMvQtGui/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -71,7 +71,6 @@ MvQTreeExpandState.cc MvQTreeView.cc MvQTreeViewSearchLine.cc - MvQMemoryWidget.cc ) @@ -90,6 +89,7 @@ LocationView.h LocationWidget.h MessageControlPanel.h + MessageLabel.h PlainTextEdit.h PlainTextWidget.h PropertyLineEditor.h @@ -114,7 +114,6 @@ MvQLogBrowser.h MvQLogPanel.h MvQMailDialog.h - MvQMemoryWidget.h MvQProfileView.h MvQProfileWidget.h MvQRangeWidget.h @@ -195,7 +194,6 @@ # MvQTabManager.moc.cpp MvQTextEditSearchLine.moc.cpp MvQWebViewSearchLine.moc.cpp # MvQTreeView.moc.cpp # MvQTreeViewSearchLine.moc.cpp -# MvQMemoryWidget.moc.cpp # edit.qrc.cpp examiner.qrc.cpp find.qrc.cpp keyDialog.qrc.cpp mail.qrc.cpp window.qrc.cpp #) @@ -218,7 +216,7 @@ TEMPLATES ${common_templates} PRIVATE_LIBS marsclient ${METVIEW_EXTRA_LIBRARIES} PUBLIC_INCLUDES ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} - ${METVIEW_QT_INCLUDE_DIRS} ../uPlot ${METVIEW_STANDARD_INCLUDES} + ${METVIEW_QT_INCLUDE_DIRS} ../uPlot ${METVIEW_STANDARD_INCLUDES} ${GDBM_INCLUDE} PRIVATE_DEFINITIONS ${METVIEW_EXTRA_DEFINITIONS} DEPENDS ) diff -Nru metview-5.17.4/metview/src/libMvQtGui/CustomLabel.cc metview-5.19.2/metview/src/libMvQtGui/CustomLabel.cc --- metview-5.17.4/metview/src/libMvQtGui/CustomLabel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/CustomLabel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ void CustomLabel::clear() { - pix_ = QPixmap(); + pix_ = QPixmap(); pixOri_ = QPixmap(); if (doc_) { doc_->clear(); @@ -25,7 +25,7 @@ void CustomLabel::setPixmap(QPixmap pix) { - mode_ = PixmapMode; + mode_ = PixmapMode; pixOri_ = pix; makePix(); update(); @@ -47,7 +47,7 @@ void CustomLabel::setText(QString txt) { mode_ = TextMode; - txt_ = txt; + txt_ = txt; makeDoc(); doc_->setHtml(txt_); update(); @@ -55,9 +55,9 @@ void CustomLabel::setTextAndPixmap(QString txt, QPixmap pix) { - mode_ = TextAndPixmapMode; + mode_ = TextAndPixmapMode; pixOri_ = pix; - txt_ = txt; + txt_ = txt; makeDoc(); doc_->setHtml(txt_); makePix(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/DateEditWidget.cc metview-5.19.2/metview/src/libMvQtGui/DateEditWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/DateEditWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/DateEditWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,5 +35,5 @@ void DateEditWidget::slotClear() { dateEdit_->setDate(dateEdit_->minimumDate()); - //dateEdit_->calendarWidget()->setSelectedDate(QDate::currentDate()); + // dateEdit_->calendarWidget()->setSelectedDate(QDate::currentDate()); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/DateEditWidget.h metview-5.19.2/metview/src/libMvQtGui/DateEditWidget.h --- metview-5.17.4/metview/src/libMvQtGui/DateEditWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/DateEditWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ Q_OBJECT public: - DateEditWidget(QWidget* parent = 0); + DateEditWidget(QWidget* parent = nullptr); protected Q_SLOTS: void slotClear(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/GLWidget.cc metview-5.19.2/metview/src/libMvQtGui/GLWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/GLWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/GLWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,18 +16,18 @@ #include "MtInputEvent.h" #include "MagPlusService.h" -//We need it beacuse somewehere in X, which is coming through MagPlusService.h, -//CursorShape is defined! +// We need it beacuse somewehere in X, which is coming through MagPlusService.h, +// CursorShape is defined! #undef CursorShape Mt::Key getMtKey(int qtKey) { static std::map key; if (key.empty()) { - key[Qt::Key_Left] = Mt::Key_Left; - key[Qt::Key_Up] = Mt::Key_Up; + key[Qt::Key_Left] = Mt::Key_Left; + key[Qt::Key_Up] = Mt::Key_Up; key[Qt::Key_Right] = Mt::Key_Right; - key[Qt::Key_Down] = Mt::Key_Down; + key[Qt::Key_Down] = Mt::Key_Down; } if (key.find(qtKey) == key.end()) { key[qtKey] = Mt::Key_Unknown; @@ -40,12 +40,12 @@ { static std::map cursor; if (cursor.empty()) { - cursor["Arrow"] = Qt::ArrowCursor; - cursor["Cross"] = Qt::CrossCursor; - cursor["OpenHand"] = Qt::OpenHandCursor; + cursor["Arrow"] = Qt::ArrowCursor; + cursor["Cross"] = Qt::CrossCursor; + cursor["OpenHand"] = Qt::OpenHandCursor; cursor["ClosedHand"] = Qt::ClosedHandCursor; - cursor["SizeVer"] = Qt::SizeVerCursor; - cursor["SizeHor"] = Qt::SizeHorCursor; + cursor["SizeVer"] = Qt::SizeVerCursor; + cursor["SizeHor"] = Qt::SizeHorCursor; } if (cursor.find(cursorName) == cursor.end()) { cursor[cursorName] = Qt::ArrowCursor; @@ -58,7 +58,7 @@ GLWidget::GLWidget(const QGLFormat& format, QWidget* parent) : QGLWidget(format, parent) { - setAutoFillBackground(false); //empty + setAutoFillBackground(false); // empty } GLWidget::~GLWidget() @@ -95,57 +95,57 @@ std::cout << "OpenGL alha: " << format().alphaBufferSize() << " bits" << std::endl; /*GLint ival[0]; - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT,ival); + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT,ival); - std::cout << "OpenGL fbo color attachments: " << ival[0] << std::endl; + std::cout << "OpenGL fbo color attachments: " << ival[0] << std::endl; - glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT,ival); - std::cout << "OpenGL max renderbuffer size: " << ival[0] << std::endl; + glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT,ival); + std::cout << "OpenGL max renderbuffer size: " << ival[0] << std::endl; - const GLubyte* extstr=glGetString(GL_EXTENSIONS); - std::cout << "Available OpenGL extensions:" << std::endl << extstr << std::endl;*/ + const GLubyte* extstr=glGetString(GL_EXTENSIONS); + std::cout << "Available OpenGL extensions:" << std::endl << extstr << std::endl;*/ /*if(gluCheckExtension(reinterpret_cast("GL_EXT_framebuffer_object") - ,extstr) == GL_TRUE) - { - std::cout << "Extension: GL_EXT_framebuffer_object found!!!" << std::endl; - }*/ + ,extstr) == GL_TRUE) + { + std::cout << "Extension: GL_EXT_framebuffer_object found!!!" << std::endl; + }*/ - //glClearColor(1.0, 1.0, 1.0, 1.0); - //glClear(GL_COLOR_BUFFER_BIT); + // glClearColor(1.0, 1.0, 1.0, 1.0); + // glClear(GL_COLOR_BUFFER_BIT); } void GLWidget::resizeGL(int w, int h) { - //We suppose we are in MODELVIEW mode + // We suppose we are in MODELVIEW mode /*glMatrixMode(GL_MODELVIEW); - glViewport(0,0,w/2,h/2); + glViewport(0,0,w/2,h/2); - GLdouble modelMatrix[16],projMatrix[16]; - GLint viewport[4]; - GLdouble rx_min,ry_min,rx_max,ry_max,rz; + GLdouble modelMatrix[16],projMatrix[16]; + GLint viewport[4]; + GLdouble rx_min,ry_min,rx_max,ry_max,rz; glGetDoublev(GL_MODELVIEW_MATRIX,modelMatrix); - glGetDoublev(GL_PROJECTION_MATRIX,projMatrix); - glGetIntegerv(GL_VIEWPORT,viewport);*/ + glGetDoublev(GL_PROJECTION_MATRIX,projMatrix); + glGetIntegerv(GL_VIEWPORT,viewport);*/ } void GLWidget::paintGL() { std::cout << "paintGL" << std::endl; - //GLint ival[0]; - //glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT,ival); + // GLint ival[0]; + // glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT,ival); - //std::cout << "OpenGL fbo color attachments: " << ival[0] << std::endl; + // std::cout << "OpenGL fbo color attachments: " << ival[0] << std::endl; - //glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT,ival); - //std::cout << "OpenGL max renderbuffer size: " << ival[0] << std::endl; + // glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT,ival); + // std::cout << "OpenGL max renderbuffer size: " << ival[0] << std::endl; - //const GLubyte* extstr=glGetString(GL_EXTENSIONS); - //std::cout << "Available OpenGL extensions:" << std::endl << extstr << std::endl; + // const GLubyte* extstr=glGetString(GL_EXTENSIONS); + // std::cout << "Available OpenGL extensions:" << std::endl << extstr << std::endl; MagPlusService::Instance().restoreFb(); swapBuffers(); @@ -242,29 +242,29 @@ QWidget::setCursor(QCursor(getQtCursorShape(cursorName))); } -/*void GLWidget::paintEvent(QPaintEvent *event) +/*void GLWidget::paintEvent(QPaintEvent *event) { - - std::cout << "paintEvent" << std::endl; - - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - glPushAttrib(GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT | GL_VIEWPORT_BIT); - QPainter painter(this); + std::cout << "paintEvent" << std::endl; - MagPlusService::Instance().restoreFb(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glPushAttrib(GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT | GL_VIEWPORT_BIT); - glPolygonMode(GL_FRONT,GL_FILL); + QPainter painter(this); - painter.fillRect(QRect(0, 0, 300, 300), + MagPlusService::Instance().restoreFb(); + + glPolygonMode(GL_FRONT,GL_FILL); + + painter.fillRect(QRect(0, 0, 300, 300), QColor(220, 0, 0, 127)); painter.end(); - glPopMatrix(); - - glPopAttrib(); + glPopMatrix(); - swapBuffers(); + glPopAttrib(); + + swapBuffers(); }*/ diff -Nru metview-5.17.4/metview/src/libMvQtGui/GotoLineDialog.h metview-5.19.2/metview/src/libMvQtGui/GotoLineDialog.h --- metview-5.17.4/metview/src/libMvQtGui/GotoLineDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/GotoLineDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ public: explicit GotoLineDialog(QWidget* parent = nullptr); - ~GotoLineDialog(); + ~GotoLineDialog() override; void setupUIBeforeShow(); Q_SIGNALS: diff -Nru metview-5.17.4/metview/src/libMvQtGui/IconProvider.cc metview-5.19.2/metview/src/libMvQtGui/IconProvider.cc --- metview-5.17.4/metview/src/libMvQtGui/IconProvider.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/IconProvider.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,8 @@ std::map IconProvider::iconsById_; //"complex" Qt objects such as QPixmap cannot be ststicly initialised! So we -//need to use a pointer. -static QPixmap* failedPix = 0; +// need to use a pointer. +static QPixmap* failedPix = nullptr; static int idCnt = 0; @@ -55,7 +55,7 @@ if (imgR.canRead()) { imgR.setScaledSize(QSize(size, size)); QImage img = imgR.read(); - pix = QPixmap::fromImage(img); + pix = QPixmap::fromImage(img); } else { pix = unknown(size); @@ -64,7 +64,7 @@ pixmaps_[size] = pix; return pix; } - return QPixmap(); + return {}; } QPixmap IconItem::unknown(int size) @@ -96,15 +96,15 @@ if (it != iconsById_.end()) return it->second->path(); - return QString(); + return {}; } int IconProvider::add(QString path, QString name) { auto it = icons_.find(name); if (it == icons_.end()) { - auto* p = new IconItem(path); - icons_[name] = p; + auto* p = new IconItem(path); + icons_[name] = p; iconsById_[p->id()] = p; return p->id(); } @@ -153,8 +153,8 @@ f.setPointSize(f.pointSize() - 2); f.setBold(true); QFontMetrics fm(f); - int w = MvQ::textWidth(fm, txt); - int h = fm.height(); + int w = MvQ::textWidth(fm, txt); + int h = fm.height(); failedPix = new QPixmap(w + 4, h); failedPix->fill(Qt::transparent); QPainter p(failedPix); diff -Nru metview-5.17.4/metview/src/libMvQtGui/IconProvider.h metview-5.19.2/metview/src/libMvQtGui/IconProvider.h --- metview-5.17.4/metview/src/libMvQtGui/IconProvider.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/IconProvider.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ { public: explicit IconItem(QString); - virtual ~IconItem() {} + virtual ~IconItem() = default; QPixmap pixmap(int); int id() const { return id_; } @@ -38,7 +38,7 @@ explicit UnknownIconItem(QString); protected: - QPixmap unknown(int); + QPixmap unknown(int) override; }; class FailedIconItem : public IconItem @@ -47,7 +47,7 @@ explicit FailedIconItem(QString); protected: - QPixmap unknown(int); + QPixmap unknown(int) override; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/LocationMap.cc metview-5.19.2/metview/src/libMvQtGui/LocationMap.cc --- metview-5.17.4/metview/src/libMvQtGui/LocationMap.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/LocationMap.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ zoomSlider_->setMaximum(view_->maxZoomLevel()); zoomSlider_->setSingleStep(1); - //init + // init zoomLevelChangedInView(view_->zoomLevel()); connect(view_, SIGNAL(zoomLevelChanged(int)), diff -Nru metview-5.17.4/metview/src/libMvQtGui/LocationMap.h metview-5.19.2/metview/src/libMvQtGui/LocationMap.h --- metview-5.17.4/metview/src/libMvQtGui/LocationMap.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/LocationMap.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,8 @@ Q_OBJECT public: - explicit LocationMap(QWidget* parent = 0); - virtual ~LocationMap() {} + explicit LocationMap(QWidget* parent = nullptr); + ~LocationMap() override = default; LocationView* view(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/LocationView.cc metview-5.19.2/metview/src/libMvQtGui/LocationView.cc --- metview-5.17.4/metview/src/libMvQtGui/LocationView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/LocationView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,8 @@ static bool initialSizeAdjsuted = false; MapMarkerItem::Symbol MapMarkerItem::symbol_ = MapMarkerItem::CircleSymbol; -float MapMarkerItem::symbolSize_ = 10.; -QRectF MapMarkerItem::bRect_ = QRectF(-4, -4, 8, 8); +float MapMarkerItem::symbolSize_ = 10.; +QRectF MapMarkerItem::bRect_ = QRectF(-4, -4, 8, 8); QBrush MapMarkerItem::brush_(QColor(255, 57, 57)); QBrush MapMarkerItem::selectBrush_(QColor(0, 255, 0)); QPen MapMarkerItem::pen_(QPen(QColor(40, 40, 40))); @@ -46,8 +46,8 @@ MapLayerItem::MapLayerItem() { std::string svgFile = metview::appDefDirFile("world_map_low.svg"); - svg_ = new QSvgRenderer(QString::fromStdString(svgFile)); - bRect_ = QRectF(-180, -90., 360., 180); + svg_ = new QSvgRenderer(QString::fromStdString(svgFile)); + bRect_ = QRectF(-180, -90., 360., 180); } QRectF MapLayerItem::boundingRect() const @@ -97,7 +97,7 @@ void MapMarkerItem::setSymbol(Symbol sym, float size) { - symbol_ = sym; + symbol_ = sym; symbolSize_ = size; MapMarkerItem::bRect_ = QRectF(-size / 2., -size / 2., size, size); @@ -117,17 +117,11 @@ //============================================ LocationView::LocationView(QWidget* parent) : - QGraphicsView(parent), - minZoomLevel_(0), - maxZoomLevel_(28), - zoomLevel_(0), - zoomDelta_(0.18), - selectedItem_(0), - inDrag_(false) + QGraphicsView(parent) { setProperty("mvStyle", "LocationView"); - //No scrollbars + // No scrollbars setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -135,14 +129,14 @@ scene_->setSceneRect(QRect(-180, -90, 360, 180)); setScene(scene_); - //The background map + // The background map svg_ = new MapLayerItem(); scene_->addItem(svg_); - //marker_=new MarkerLayerItem(this); - //scene_->addItem(marker_); + // marker_=new MarkerLayerItem(this); + // scene_->addItem(marker_); - //Center the view on the map + // Center the view on the map centerOn(svg_); #ifdef _MV_MAPVIEW_DEBUG @@ -180,7 +174,7 @@ { QGraphicsItem* item = itemAt(event->pos()); - //We clciked on an item + // We clciked on an item if (item && item->type() == MapMarkerItem::Type) { if (selectedItem_) { Q_ASSERT(selectedItem_->type() == MapMarkerItem::Type); @@ -193,9 +187,9 @@ Q_EMIT currentChanged(selectedItem_->id()); } - //We start a pan + // We start a pan else if (event->button() == Qt::LeftButton) { - inDrag_ = true; + inDrag_ = true; dragPos_ = event->pos(); QGuiApplication::setOverrideCursor(QCursor(Qt::ClosedHandCursor)); } @@ -206,7 +200,7 @@ void LocationView::mouseMoveEvent(QMouseEvent* event) { if (inDrag_) { - //It is more accurate than using the delta in view coordinates (pixels) + // It is more accurate than using the delta in view coordinates (pixels) QPointF delta = mapToScene(event->pos()) - mapToScene(dragPos_); pan(delta); } @@ -245,9 +239,9 @@ { if (level >= minZoomLevel_ && level <= maxZoomLevel_) { float actScale = scaleFromLevel(zoomLevel_); - zoomLevel_ = level; + zoomLevel_ = level; float newScale = scaleFromLevel(level); - float factor = newScale / actScale; + float factor = newScale / actScale; scale(factor, factor); } } @@ -278,7 +272,7 @@ qDebug() << "delta" << delta; #endif - //scale the pan delta + // scale the pan delta delta *= currentScale(); QSize size = maximumViewportSize(); @@ -291,7 +285,7 @@ qDebug() << "BEFORE center in scene old=" << mapToScene(oldCenter) << "new=" << mapToScene(newCenter); #endif - //This method does not work when the scollbars are visible + // This method does not work when the scollbars are visible centerOn(mapToScene(newCenter)); @@ -302,7 +296,7 @@ void LocationView::showFullMap() { - QRectF sr = scene_->sceneRect(); + QRectF sr = scene_->sceneRect(); QSize size = maximumViewportSize(); if (sr.width() > 0 && sr.height() > 0) { @@ -318,12 +312,12 @@ void LocationView::zoomToData() { - QRectF sr = scene_->sceneRect(); + QRectF sr = scene_->sceneRect(); QSize size = maximumViewportSize(); if (sr.width() > 0 && sr.height() > 0 && dataRect_.isValid()) { float halo = 2; - QRectF dr = dataRect_.adjusted(-halo, -halo, halo, halo); + QRectF dr = dataRect_.adjusted(-halo, -halo, halo, halo); if (dr.left() < -180.) dr.setLeft(-180.); if (dr.right() > 180.) @@ -342,7 +336,7 @@ int level = zoomLevelFromScale(qMin(rw, rh) - 0.1); setZoomLevel(level); - //This method does not work when the scollbars are visible + // This method does not work when the scollbars are visible centerOn(dr.center()); Q_EMIT zoomLevelChanged(zoomLevel()); @@ -351,26 +345,26 @@ void LocationView::clearPoints() { - dataRect_ = QRectF(); + dataRect_ = QRectF(); std::size_t num = markers_.size(); for (std::size_t i = 0; i < num; i++) { delete markers_[i]; } - markers_ = std::vector(); - selectedItem_ = 0; + markers_ = std::vector(); + selectedItem_ = nullptr; } void LocationView::addPoints(const std::vector& lat, const std::vector& lon) { - //marker_->addPoints(lat,lon); + // marker_->addPoints(lat,lon); if (!initialSizeAdjsuted) { initialSizeAdjsuted = true; showFullMap(); } clearPoints(); - std::size_t num = lat.size(); - MapMarkerItem* nullItem = 0; + std::size_t num = lat.size(); + MapMarkerItem* nullItem = nullptr; markers_.resize(num, nullItem); float latMin = 1000; @@ -386,13 +380,13 @@ latVal = -lat[i]; lonVal = lon[i]; - markers_[i] = 0; + markers_[i] = nullptr; if (lonVal <= 180. && lonVal >= -180. && latVal >= -90. && latVal <= 90.) { hasValidPoint = true; - auto* item = new MapMarkerItem(i); - markers_[i] = item; + auto* item = new MapMarkerItem(i); + markers_[i] = item; item->setPos(QPointF(lonVal, latVal)); scene_->addItem(item); diff -Nru metview-5.17.4/metview/src/libMvQtGui/LocationView.h metview-5.19.2/metview/src/libMvQtGui/LocationView.h --- metview-5.17.4/metview/src/libMvQtGui/LocationView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/LocationView.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,9 @@ Type = UserType + 1 }; MapLayerItem(); - QRectF boundingRect() const; - void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*); - int type() const { return Type; } + QRectF boundingRect() const override; + void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) override; + int type() const override { return Type; } protected: QPixmap pix_; @@ -53,10 +53,10 @@ MapMarkerItem(int id); - QRectF boundingRect() const; - void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*); + QRectF boundingRect() const override; + void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) override; void setCurrent(bool); - int type() const { return Type; } + int type() const override { return Type; } int id() const { return id_; } static void setSymbol(Symbol sym, float size); @@ -79,7 +79,7 @@ Q_OBJECT public: - LocationView(QWidget* parent = 0); + LocationView(QWidget* parent = nullptr); void addPoints(const std::vector& lat, const std::vector& lon); void setCurrentPoint(int); @@ -101,28 +101,28 @@ void zoomLevelChanged(int); protected: - void keyPressEvent(QKeyEvent* event); - void wheelEvent(QWheelEvent* e); - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); + void keyPressEvent(QKeyEvent* event) override; + void wheelEvent(QWheelEvent* e) override; + void mousePressEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent* event) override; + void mouseReleaseEvent(QMouseEvent* event) override; void zoom(int level); void pan(QPointF delta); float scaleFromLevel(int level) const; int zoomLevelFromScale(float) const; void adjustMarkers(int); - QGraphicsScene* scene_; - MapLayerItem* layer_; - MapLayerItem* svg_; + QGraphicsScene* scene_{nullptr}; + MapLayerItem* layer_{nullptr}; + MapLayerItem* svg_{nullptr}; std::vector markers_; - int minZoomLevel_; - int maxZoomLevel_; - int zoomLevel_; - float zoomDelta_; + int minZoomLevel_{0}; + int maxZoomLevel_{28}; + int zoomLevel_{0}; + float zoomDelta_{0.18}; QRectF dataRect_; - MapMarkerItem* selectedItem_; + MapMarkerItem* selectedItem_{nullptr}; QPoint dragPos_; - bool inDrag_; + bool inDrag_{false}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/LocationWidget.cc metview-5.19.2/metview/src/libMvQtGui/LocationWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/LocationWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/LocationWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,12 +14,7 @@ #include "MvQKeyProfileModel.h" LocationWidget::LocationWidget(QWidget* parent) : - QWidget(parent), - mode_(LocationMode), - maxNum_(500000), - inChangeFromMap_(false), - inChangeFromTree_(false), - inUpdateMessage_(false) + QWidget(parent) { setupUi(this); @@ -28,7 +23,7 @@ maxSpin_->setMinimum(1); maxSpin_->setValue(100000); - //numLabel_->setProperty("panelStyle", "2"); + // numLabel_->setProperty("panelStyle", "2"); numLabel_->setText(""); model_ = new MvQKeyProfileModel(this); @@ -112,7 +107,7 @@ } } else { - //in this case num=totalNum + // in this case num=totalNum if (num < 0) { s = "No extracted data is available!"; } @@ -159,7 +154,7 @@ mode_ = DataMode; Q_ASSERT(prof); - model_->setKeyProfile(prof); //the model takes ownership of the profile + model_->setKeyProfile(prof); // the model takes ownership of the profile MvKey* lat = prof->key(MvKey::LatitudeRole); MvKey* lon = prof->key(MvKey::LongitudeRole); @@ -168,20 +163,20 @@ map_->view()->addPoints(lat->doubleValue(), lon->doubleValue()); } - //Q_ASSERT(lat); - //Q_ASSERT(lon); - //Q_ASSERT(collector->maxNum() == maxNum_); + // Q_ASSERT(lat); + // Q_ASSERT(lon); + // Q_ASSERT(collector->maxNum() == maxNum_); int num = prof->valueNum(); updateNumLabel(num, num); - //map_->view()->addPoints(lat->doubleValue(),lon->doubleValue());} + // map_->view()->addPoints(lat->doubleValue(),lon->doubleValue());} } void LocationWidget::updateMessage(int msg) { - //TODO - //return; + // TODO + // return; if (MvKeyProfile* prof = model_->keyProfile()) { MvKey* mk = prof->key(MvKey::MessageIndexRole); @@ -190,7 +185,7 @@ for (std::size_t i = 0; i < num; i++) { if (mk->intValue()[i] == msg) { inUpdateMessage_ = true; - tree_->setCurrentIndex(sortModel_->mapFromSource(model_->index(i, 0))); + tree_->setCurrentIndex(sortModel_->mapFromSource(model_->index(static_cast(i), 0))); tree_->scrollTo(tree_->currentIndex()); inUpdateMessage_ = false; return; @@ -210,7 +205,7 @@ MvKey* msg = prof->key(MvKey::MessageIndexRole); Q_ASSERT(msg); - int msgIndex = msg->intValue()[index]; + int msgIndex = msg->intValue()[index]; inChangeFromMap_ = true; tree_->setCurrentIndex(sortModel_->mapFromSource(model_->index(index, 0))); tree_->scrollTo(tree_->currentIndex()); @@ -230,7 +225,7 @@ MvKey* msg = prof->key(MvKey::MessageIndexRole); Q_ASSERT(msg); - int msgIndex = msg->intValue()[index.row()]; + int msgIndex = msg->intValue()[index.row()]; inChangeFromTree_ = true; map_->view()->setCurrentPoint(index.row()); diff -Nru metview-5.17.4/metview/src/libMvQtGui/LocationWidget.h metview-5.19.2/metview/src/libMvQtGui/LocationWidget.h --- metview-5.17.4/metview/src/libMvQtGui/LocationWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/LocationWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,8 @@ Q_OBJECT public: - explicit LocationWidget(QWidget* parent = 0); - virtual ~LocationWidget() {} + explicit LocationWidget(QWidget* parent = nullptr); + ~LocationWidget() override = default; BufrLocationCollector* makeCollector(); void update(BufrLocationCollector*); @@ -47,15 +47,15 @@ Q_SIGNALS: void messageSelected(int); -protected: +private: void updateNumLabel(int, int); - Mode mode_; - MvQKeyProfileModel* model_; - MvQKeyProfileSortFilterModel* sortModel_; - MvKeyProfile* prof_; - int maxNum_; - bool inChangeFromMap_; - bool inChangeFromTree_; - bool inUpdateMessage_; + Mode mode_{LocationMode}; + MvQKeyProfileModel* model_{nullptr}; + MvQKeyProfileSortFilterModel* sortModel_{nullptr}; + MvKeyProfile* prof_{nullptr}; + int maxNum_{500000}; + bool inChangeFromMap_{false}; + bool inChangeFromTree_{false}; + bool inUpdateMessage_{false}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MessageControlPanel.cc metview-5.19.2/metview/src/libMvQtGui/MessageControlPanel.cc --- metview-5.17.4/metview/src/libMvQtGui/MessageControlPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MessageControlPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,7 @@ #include "MvQTheme.h" MessageControlPanel::MessageControlPanel(bool hasSubset, bool /*hasFilter*/, QWidget* parent) : - MvQPanel(parent), - subsetSpin_(nullptr), - subsetLabel_(nullptr) + MvQPanel(parent) { QString styleId = "2"; @@ -46,7 +44,7 @@ subsetTitleLabel_ = new QLabel(tr("&Subset:"), this); subsetTitleLabel_->setProperty("panelStyle", styleId); subsetTitleLabel_->setObjectName("subsetTitleLabel"); - subsetSpin_ = new MvQArrowSpinWidget(this); + subsetSpin_ = new MvQArrowSpinWidget(this); subsetLabel_ = new QLabel(""); subsetLabel_->setProperty("panelStyle", styleId); subsetTitleLabel_->setBuddy(subsetSpin_->spin()); @@ -71,7 +69,7 @@ layout_->addStretch(1); - //Options button with menu + // Options button with menu optionsTb_ = new QToolButton(this); optionsTb_->setProperty("panelStyle", styleId); optionsTb_->setIcon(QPixmap(":/examiner/cogwheel.svg")); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MessageControlPanel.h metview-5.19.2/metview/src/libMvQtGui/MessageControlPanel.h --- metview-5.17.4/metview/src/libMvQtGui/MessageControlPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MessageControlPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ Q_OBJECT public: - MessageControlPanel(bool hasSubset, bool hasFilter, QWidget* parent = 0); + MessageControlPanel(bool hasSubset, bool hasFilter, QWidget* parent = nullptr); void setMessageValue(int num, bool b); void resetMessageNum(int num, bool b); void resetSubsetNum(int num, bool b); @@ -41,14 +41,14 @@ void subsetChanged(int); private: - QHBoxLayout* layout_; - MvQArrowSpinWidget* messageSpin_; - QLabel* messageLabel_; - MvQArrowSpinWidget* subsetSpin_; - QLabel* subsetLabel_; - QLabel* subsetTitleLabel_; - QLabel* totalLabel_; - QToolButton* optionsTb_; + QHBoxLayout* layout_{nullptr}; + MvQArrowSpinWidget* messageSpin_{nullptr}; + QLabel* messageLabel_{nullptr}; + MvQArrowSpinWidget* subsetSpin_{nullptr}; + QLabel* subsetLabel_{nullptr}; + QLabel* subsetTitleLabel_{nullptr}; + QLabel* totalLabel_{nullptr}; + QToolButton* optionsTb_{nullptr}; QList optionsActions_; QList buttonActions_; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MessageLabel.cc metview-5.19.2/metview/src/libMvQtGui/MessageLabel.cc --- metview-5.17.4/metview/src/libMvQtGui/MessageLabel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MessageLabel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,15 +13,20 @@ #include #include #include +#include #include +#include +#include #include #include #include "IconProvider.h" +#include "MvLog.h" #include "MvQTheme.h" +#include "MvQStreamOper.h" #include -#include +#include class MessageLabelData { @@ -31,8 +36,8 @@ bg_(bg.name()), border_(border.name()) { - int id = IconProvider::add(iconPath, iconPath); - pix_ = IconProvider::pixmap(id, 16); + int id = IconProvider::add(iconPath, iconPath); + pix_ = IconProvider::pixmap(id, 16); pixSmall_ = IconProvider::pixmap(id, 12); } @@ -83,10 +88,10 @@ loadLabel_ = new QLabel(this); - //progress widget - progLabel_ = new QLabel(this); - progBar_ = new QProgressBar(this); - progWidget_ = new QWidget(this); + // progress widget + progLabel_ = new QLabel(this); + progBar_ = new QProgressBar(this); + progWidget_ = new QWidget(this); auto* progLayout = new QHBoxLayout(progWidget_); progLayout->addWidget(progBar_); progLayout->addWidget(progLabel_); @@ -104,14 +109,12 @@ pixLayout->addStretch(1); layout_->addLayout(pixLayout); - auto* rightVb = new QVBoxLayout; + auto rightVb = new QVBoxLayout; rightVb->addWidget(msgLabel_); rightVb->addWidget(progWidget_); rightVb->addStretch(1); layout_->addLayout(rightVb, 1); - //layout_->addWidget(msgLabel_,1); - stopLoadLabel(); stopProgress(); @@ -163,6 +166,8 @@ setStyleSheet(sh); + MvLog().dbg() <<"STYLESHEET=" << sh; + pixLabel_->setPixmap(((!narrowMode_) ? it->second.pix_ : it->second.pixSmall_)); currentType_ = type; @@ -222,7 +227,7 @@ progBar_->setValue(value); progLabel_->setText(text); - //UserMessage::debug("MessageLabel::progress --> " + QString::number(value).toStdString() + "%"); + // UserMessage::debug("MessageLabel::progress --> " + QString::number(value).toStdString() + "%"); } void MessageLabel::setShowTypeTitle(bool b) @@ -248,3 +253,33 @@ layout_->setContentsMargins(2,0,2,0); }*/ } + + +void MessageLabel::showCustomButton(QString text) +{ + if (customButton_ == nullptr) { + customButton_ = new QToolButton(this); + layout_->addWidget(customButton_); + connect(customButton_, SIGNAL(clicked()), + this, SIGNAL(customButtonClicked())); + + } + customButton_->setText(text); + customButton_->show(); +} + +void MessageLabel::hideCustomButton() +{ + if (customButton_ != nullptr) { + customButton_->hide(); + } +} + + +void MessageLabel::paintEvent(QPaintEvent*) +{ + QStyleOption opt; + opt.initFrom(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} diff -Nru metview-5.17.4/metview/src/libMvQtGui/MessageLabel.h metview-5.19.2/metview/src/libMvQtGui/MessageLabel.h --- metview-5.17.4/metview/src/libMvQtGui/MessageLabel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MessageLabel.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,12 +14,16 @@ class QHBoxLayout; class QLabel; +class QPaintEvent; class QProgressBar; +class QToolButton; +class QVBoxLayout; class MessageLabel : public QWidget { + Q_OBJECT public: - explicit MessageLabel(QWidget* parent = 0); + explicit MessageLabel(QWidget* parent = nullptr); enum Type { @@ -42,6 +46,14 @@ void setShowTypeTitle(bool); void clear(); void setNarrowMode(bool); + void showCustomButton(QString); + void hideCustomButton(); + +signals: + void customButtonClicked(); + +protected: + void paintEvent(QPaintEvent*); private: void showMessage(const Type&, QString); @@ -56,4 +68,6 @@ QWidget* progWidget_; QLabel* progLabel_; QProgressBar* progBar_; + QToolButton* customButton_{nullptr}; + QVBoxLayout* rightVb_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQAbout.cc metview-5.19.2/metview/src/libMvQtGui/MvQAbout.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQAbout.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQAbout.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ MvQAbout::MvQAbout(QString title, QString description, Versions version, QMap text) : - QDialog(0) + QDialog(nullptr) { setWindowTitle(tr("About ") + title); @@ -128,15 +128,15 @@ auto* vb = new QVBoxLayout(this); setLayout(vb); - //Logo + text + // Logo + text auto* logo = new QLabel(this); logo->setProperty("type", "title"); - //logo->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); - //logo->setAutoFillBackground(true); - // QPalette pal = logo->palette(); - // pal.setBrush(QPalette::Window, Qt::white); - // logo->setPalette(pal); + // logo->setFrameStyle(QFrame::StyledPanel | QFrame::Plain); + // logo->setAutoFillBackground(true); + // QPalette pal = logo->palette(); + // pal.setBrush(QPalette::Window, Qt::white); + // logo->setPalette(pal); QString logoTxt; logoTxt = ""; @@ -180,17 +180,17 @@ vb->addWidget(logo); - //tab + // tab auto* tw = new QTabWidget(this); - //Version + // Version auto* versionLabel = new QLabel(this); versionLabel->setIndent(10); versionLabel->setText(versionTxt); versionLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); tw->addTab(versionLabel, tr("Versions")); - //Licence + // Licence auto* licenceTe = new QPlainTextEdit(this); licenceTe->setReadOnly(true); licenceTe->setWordWrapMode(QTextOption::NoWrap); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQAbout.h metview-5.19.2/metview/src/libMvQtGui/MvQAbout.h --- metview-5.17.4/metview/src/libMvQtGui/MvQAbout.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQAbout.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,18 +18,18 @@ public: enum Version { - NoVersion = 0x0, - MetviewVersion = 0x1, - GribApiVersion = 0x2, - EmosVersion = 0x4, - MagicsVersion = 0x8, - NetcdfVersion = 0x10, - OdcVersion = 0x20, + NoVersion = 0x0, + MetviewVersion = 0x1, + GribApiVersion = 0x2, + EmosVersion = 0x4, + MagicsVersion = 0x8, + NetcdfVersion = 0x10, + OdcVersion = 0x20, InterpolationPackage = 0x40 }; Q_DECLARE_FLAGS(Versions, Version); - typedef QMap VersionTextMap; + using VersionTextMap = QMap; MvQAbout(QString, QString, Versions, VersionTextMap text = VersionTextMap()); }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQAbstractMessageExaminer.cc metview-5.19.2/metview/src/libMvQtGui/MvQAbstractMessageExaminer.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQAbstractMessageExaminer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQAbstractMessageExaminer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -45,8 +45,8 @@ #include #include #include -#include -#include +#include +#include #include "MvQAbstractMessageExaminer.h" @@ -89,8 +89,8 @@ MvQMessagePanel::MvQMessagePanel(QWidget* parent) : QWidget(parent), - data_(0), - loader_(0) + data_(nullptr), + loader_(nullptr) { //-------------------------------- // Message tree (key profile) @@ -100,7 +100,7 @@ layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(1); - //Message tree + // Message tree model_ = new MvQKeyProfileModel(this); model_->setShadeFirstColumn(true); @@ -111,8 +111,8 @@ sortModel_->setFilterFixedString("1"); sortModel_->setFilterKeyColumn(0); - //progress bar - progWidget_ = new QWidget(this); + // progress bar + progWidget_ = new QWidget(this); auto* progHb = new QHBoxLayout(progWidget_); progHb->setContentsMargins(0, 1, 0, 0); @@ -130,30 +130,30 @@ layout->addWidget(progWidget_); progWidget_->hide(); - //tree + // tree tree_ = new MvQKeyProfileTree(this); tree_->setModels(model_, sortModel_); tree_->setUniformRowHeights(true); layout->addWidget(tree_); - //Message list selection - //connect(tree_,SIGNAL(clicked(QModelIndex)), - // this,SLOT(selectMessage(QModelIndex))); + // Message list selection + // connect(tree_,SIGNAL(clicked(QModelIndex)), + // this,SLOT(selectMessage(QModelIndex))); - //connect(tree_,SIGNAL(activated(QModelIndex)), - // this,SLOT(selectMessage(QModelIndex))); + // connect(tree_,SIGNAL(activated(QModelIndex)), + // this,SLOT(selectMessage(QModelIndex))); connect(tree_, SIGNAL(selectionChanged(QModelIndex)), this, SLOT(selectMessage(QModelIndex))); - //The profile was altered via the treeview headings + // The profile was altered via the treeview headings connect(tree_, SIGNAL(profileChanged(bool, int)), this, SLOT(adjustProfile(bool, int))); - //The profile was altered via drag and drop - // connect(model_,SIGNAL(keyInserted()), - // this,SLOT(reloadProfileFromModel())); + // The profile was altered via drag and drop + // connect(model_,SIGNAL(keyInserted()), + // this,SLOT(reloadProfileFromModel())); } void MvQMessagePanel::init(MvMessageMetaData* data) @@ -170,25 +170,25 @@ void MvQMessagePanel::loadKeyProfile(MvKeyProfile* profDef) { - //Clone the profile + // Clone the profile MvKeyProfile* prof = profDef->clone(); - //Load data into the profile - loadKeyProfileCore(prof); //can be threaded!!! + // Load data into the profile + loadKeyProfileCore(prof); // can be threaded!!! - //Will be finished in slotKeyProfileReady()!!! + // Will be finished in slotKeyProfileReady()!!! } void MvQMessagePanel::loadKeyProfileCore(MvKeyProfile* prof) { Q_ASSERT(data_); - //int num; - //num=data_->messageNum(); - //if(num == 0) + // int num; + // num=data_->messageNum(); + // if(num == 0) //{ - // num=data_->getEstimatedMessageNum(); - //} + // num=data_->getEstimatedMessageNum(); + // } if (!loader_) { if (data_->type() == MvMessageMetaData::BufrType) @@ -219,7 +219,7 @@ this, SLOT(slotKeyProfileLoadProgress(int))); } - //This can be run in a separate thread! + // This can be run in a separate thread! loader_->startScan(prof); } @@ -253,15 +253,15 @@ } if (selectedRow == -1) { - int oriRow = sortModel_->mapToSource(tree_->currentIndex()).row(); - bool firstLoad = (model_->keyProfile() == 0); + int oriRow = sortModel_->mapToSource(tree_->currentIndex()).row(); + bool firstLoad = (model_->keyProfile() == nullptr); - //Update message tree + // Update message tree model_->setKeyProfile(prof); tree_->setCurrentIndex(QModelIndex()); - //Restore selection + // Restore selection if (oriRow >= 0 && oriRow < sortModel_->rowCount()) { tree_->setCurrentIndex(sortModel_->mapFromSource(model_->index(oriRow, 0))); } @@ -279,7 +279,7 @@ else { model_->setKeyProfile(prof); - //model_->keyProfileChangeFinished(); + // model_->keyProfileChangeFinished(); if (selectedRow >= model_->rowCount() || selectedRow == -1) selectedRow = 0; @@ -325,14 +325,14 @@ MvKeyProfile* profDef = model_->keyProfile(); Q_ASSERT(profDef); - MvKeyProfile* prof = profDef->clone(); //this does not copy the data!!! + MvKeyProfile* prof = profDef->clone(); // this does not copy the data!!! model_->setKeyProfile(prof); } -//The profile was modified via the treeview headings +// The profile was modified via the treeview headings void MvQMessagePanel::adjustProfile(bool reload, int selectedRow) { - //emit statusMessage(tr("Reload key profile ...")); + // emit statusMessage(tr("Reload key profile ...")); if (reload) { if (loader_) { @@ -342,19 +342,19 @@ if (selectedRow == -1) selectedRow = sortModel_->mapToSource(tree_->currentIndex()).row(); - //model_->keyProfileIsAboutToChange(); + // model_->keyProfileIsAboutToChange(); - //Get the current profile from the model. + // Get the current profile from the model. MvKeyProfile* profDef = model_->keyProfile(); Q_ASSERT(profDef); - //Clear the data + // Clear the data MvKeyProfile* prof = profDef->clone(); prof->setMetaData("selectedRow", std::to_string(selectedRow)); - //Update grib metadata with the new key profile - loadKeyProfileCore(prof); //can be threaded!!!! + // Update grib metadata with the new key profile + loadKeyProfileCore(prof); // can be threaded!!!! - //Will be finished in slotKeyProfileReady()!!! + // Will be finished in slotKeyProfileReady()!!! #if 0 model_->setKeyProfile(prof); @@ -371,13 +371,13 @@ emit keyProfileChanged(); } - //for(int i=0;i < model_->columnCount()-1; i++) + // for(int i=0;i < model_->columnCount()-1; i++) //{ - // tree_->resizeColumnToContents(i); - //} + // tree_->resizeColumnToContents(i); + // } - //tree_->setCurrentIndex(sortModel_->index(0,0)); - //selectMessage(tree_->currentIndex()); + // tree_->setCurrentIndex(sortModel_->index(0,0)); + // selectMessage(tree_->currentIndex()); } void MvQMessagePanel::slotMessageDataInvalid(int msg) @@ -386,7 +386,7 @@ if (msg >= 0 && msg < static_cast(prof->valueNum())) { if (!prof->isErrorRow(msg)) { prof->markErrorRow(msg); - //We update the row in the tree + // We update the row in the tree QModelIndex idx1 = sortModel_->mapFromSource(model_->index(msg, 0)); QModelIndex idx2 = sortModel_->mapFromSource(model_->index(msg, model_->columnCount() - 1)); tree_->dataChanged(idx1, idx2); @@ -397,17 +397,12 @@ MvQAbstractMessageExaminer::MvQAbstractMessageExaminer(QString appName, Type type, QWidget* parent) : MvQMainWindow(parent), appName_(appName), - type_(type), - data_(0), - currentMessageNo_(-1), - filePanel_(0), - actionFilePanel_(0), - fileList_(0) + type_(type) { - //File info label + // File info label fileInfoLabel_ = new MvQFileInfoLabel(this); - //Set up the panels + // Set up the panels logPanel_ = new MvQLogPanel(this); #ifdef ECCODES_UI @@ -505,7 +500,7 @@ this, SLOT(slotKeyProfileChanged())); #ifdef ECCODES_UI - //Creat a socket based server to listen to incoming commands/messages + // Creat a socket based server to listen to incoming commands/messages QString typeString; if (type_ == GribType) typeString = "grib"; @@ -522,13 +517,13 @@ MvQAbstractMessageExaminer::~MvQAbstractMessageExaminer() { - //Cannot call saveKeyProfiles() here beacuse it depends on a pure - //virtual method. So it must be called in the subclass destructors. + // Cannot call saveKeyProfiles() here beacuse it depends on a pure + // virtual method. So it must be called in the subclass destructors. } void MvQAbstractMessageExaminer::closeEvent(QCloseEvent* event) { - //saveKeyProfiles(true); + // saveKeyProfiles(true); event->accept(); } @@ -603,7 +598,7 @@ icon.addPixmap(QPixmap(QString::fromUtf8(":/examiner/info_light.svg")), QIcon::Normal, QIcon::Off); actionFileInfo_->setIcon(icon); - //Define routines + // Define routines connect(actionFileInfo_, SIGNAL(toggled(bool)), fileInfoLabel_, SLOT(setVisible(bool))); @@ -619,14 +614,14 @@ icon1.addPixmap(QPixmap(QString::fromUtf8(":/examiner/log.svg")), QIcon::Normal, QIcon::Off); actionLog_->setIcon(icon1); - //logPanel connects up logAction and manages it + // logPanel connects up logAction and manages it logPanel_->setViewAction(actionLog_); - //Log is hidden by default!!! + // Log is hidden by default!!! actionLog_->setChecked(false); #ifdef ECCODES_UI - //File panel is hidden by default + // File panel is hidden by default actionFilePanel_ = new QAction(this); actionFilePanel_->setObjectName(QString::fromUtf8("actionFilePanel")); actionFilePanel_->setText(tr("&File list")); @@ -635,9 +630,9 @@ actionFilePanel_->setToolTip(tr("View file list")); actionFilePanel_->setIcon(QPixmap(":/examiner/fileList.svg")); - //actionFilePanel_->setEnabled(false); + // actionFilePanel_->setEnabled(false); - //Define routines + // Define routines connect(actionFilePanel_, SIGNAL(toggled(bool)), filePanel_, SLOT(setVisible(bool))); @@ -663,7 +658,7 @@ void MvQAbstractMessageExaminer::setupEditMenu() { -//TODO: reimplement find +// TODO: reimplement find #if 0 actionFind_=MvQMainWindow::createAction(MvQMainWindow::FindAction,this); connect(actionFind_,SIGNAL(triggered(bool)), @@ -690,7 +685,7 @@ #ifdef ECCODES_UI QMenu* styleMenu = new QMenu(tr("UI Theme"), this); - styleAg_ = new QActionGroup(this); + styleAg_ = new QActionGroup(this); QAction* actionLightStyle_ = new QAction(this); actionLightStyle_->setText(tr("Light")); actionLightStyle_->setData("light"); @@ -744,16 +739,16 @@ /*QAction* actionExport = new QAction(this); actionExport->setObjectName(QString::fromUtf8("actionProfileExport")); - actionExport->setText(tr("&Export")); - actionExport->setToolTip(tr("Export key profiles")); + actionExport->setText(tr("&Export")); + actionExport->setToolTip(tr("Export key profiles")); - QAction* actionImport = new QAction(this); + QAction* actionImport = new QAction(this); actionImport->setObjectName(QString::fromUtf8("actionProfileImport")); - actionImport->setText(tr("&Import")); - actionImport->setToolTip(tr("Import key profiles"));*/ + actionImport->setText(tr("&Import")); + actionImport->setToolTip(tr("Import key profiles"));*/ - //Key profile management + // Key profile management connect(actionNew, SIGNAL(triggered()), this, SLOT(slotCreateNewProfile())); @@ -769,26 +764,26 @@ auto* hb = new QHBoxLayout(wh); hb->setContentsMargins(1, 1, 1, 1); - //Combo box - //We will add items + signal/slots later in "init"! - //Combo box for key profile selection + // Combo box + // We will add items + signal/slots later in "init"! + // Combo box for key profile selection auto* keyLabel = new QLabel(tr("Key profile:"), wh); - keyCombo_ = new QComboBox(wh); + keyCombo_ = new QComboBox(wh); keyLabel->setBuddy(keyCombo_); hb->addWidget(keyLabel); hb->addWidget(keyCombo_); - //MvQMenuItem::MenuTarget + // MvQMenuItem::MenuTarget MvQMainWindow::MenuType menuType = MvQMainWindow::ProfilesMenu; menuItems_[menuType].push_back(new MvQMenuItem(actionNew, MvQMenuItem::MenuTarget)); menuItems_[menuType].push_back(new MvQMenuItem(actionSaveAs, MvQMenuItem::MenuTarget)); - //menuItems_["profiles"].push_back(new MvQMenuItem(actionExport,MvQMenuItem::MenuTarget)); - //menuItems_["profiles"].push_back(new MvQMenuItem(actionImport,MvQMenuItem::MenuTarget)); + // menuItems_["profiles"].push_back(new MvQMenuItem(actionExport,MvQMenuItem::MenuTarget)); + // menuItems_["profiles"].push_back(new MvQMenuItem(actionImport,MvQMenuItem::MenuTarget)); menuItems_[menuType].push_back(new MvQMenuItem(actionProfileManager, MvQMenuItem::MenuTarget)); - //menuItems_["profiles"].push_back(new MvQMenuItem(actionKeyManager,MvQMenuItem::MenuTarget)); + // menuItems_["profiles"].push_back(new MvQMenuItem(actionKeyManager,MvQMenuItem::MenuTarget)); menuItems_[menuType].push_back(new MvQMenuItem(wh)); } @@ -808,26 +803,26 @@ void MvQAbstractMessageExaminer::init(MvMessageMetaData* data, MvQKeyManager* manager, MvQFileList* fileList) { - data_ = data; + data_ = data; keyManager_ = manager; #ifdef ECCODES_UI Q_ASSERT(fileList); #endif - //Files are specified + // Files are specified if (fileList) { - //The specified list is not empty + // The specified list is not empty if (fileList->count() > 0) { - //We delete the file list loaded from the settings + // We delete the file list loaded from the settings if (fileList_) { delete fileList_; } - //and use the specified list instead + // and use the specified list instead fileList_ = fileList; } - //otherwise if nothing was read from the settings we - //initialise the filelist with the empty one + // otherwise if nothing was read from the settings we + // initialise the filelist with the empty one else if (!fileList_) { fileList_ = fileList; } @@ -838,22 +833,22 @@ Q_ASSERT(keyManager_); #ifdef ECCODES_UI - //Init file list + // Init file list Q_ASSERT(fileList_); - //The filename is set in data - it must have been set externally + // The filename is set in data - it must have been set externally if (!data_->fileName().empty()) { QString err; - //This is the only file in the list + // This is the only file in the list if (fileList_->count() == 1) { sourceFileName_ = QString::fromStdString(data_->fileName()); if (!fileList_->isPresent(sourceFileName_)) fileList_->add(sourceFileName_, err, false); } - //There are other files and there is a saved filename + // There are other files and there is a saved filename else if (!sourceFileName_.isEmpty()) { - //The saved filename is valid, we set it in the data + // The saved filename is valid, we set it in the data if (fileList_->isPresent(sourceFileName_)) { data_->setFileName(sourceFileName_.toStdString()); } @@ -861,27 +856,27 @@ sourceFileName_ = QString::fromStdString(data_->fileName()); } } - //No filename was set externally - we must use now the saved filelist + // No filename was set externally - we must use now the saved filelist else { QString err; - //There is a saved filename + // There is a saved filename if (!sourceFileName_.isEmpty()) { bool valid = fileList_->isPresent(sourceFileName_); if (!valid) { valid = fileList_->add(sourceFileName_, err, false); } - //The saved filename is valid, we set it in the data + // The saved filename is valid, we set it in the data if (valid) { data_->setFileName(sourceFileName_.toStdString()); } - //otherwise the take first from the list + // otherwise the take first from the list else if (fileList_->count() > 0) { sourceFileName_ = fileList_->path(0); data_->setFileName(sourceFileName_.toStdString()); } } - //otherwise the take first from the list + // otherwise the take first from the list else if (fileList_->count() > 0) { sourceFileName_ = fileList_->path(0); data_->setFileName(sourceFileName_.toStdString()); @@ -895,14 +890,14 @@ sourceFileName_ = QString::fromStdString(data_->fileName()); #endif - //Init dump panel + // Init dump panel initMain(data_); //---------------------------------- // Initilaize the key profile list //--------------------------------- - //Init key combo + // Init key combo int currentIndex = -1; for (unsigned int i = 0; i < keyManager_->data().size(); i++) { QString str(keyManager_->data().at(i)->name().c_str()); @@ -915,29 +910,29 @@ } } - //If we do not find a matching a item will select the last one! + // If we do not find a matching a item will select the last one! if (currentIndex == -1) currentIndex = keyCombo_->count() - 1; - //Set the keyCombo_'s current index to -1 and define the signal-slot for the keyCombo_ + // Set the keyCombo_'s current index to -1 and define the signal-slot for the keyCombo_ keyCombo_->setCurrentIndex(-1); connect(keyCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLoadKeyProfile(int))); - //Now the currentIndex in keyCombo_ is set to -1, but the currentIndex local variable stores - //a non-negativ value. So by setting the current index in the keyCombo_ the slot - //above will be called and the right key profile will be loaded. + // Now the currentIndex in keyCombo_ is set to -1, but the currentIndex local variable stores + // a non-negativ value. So by setting the current index in the keyCombo_ the slot + // above will be called and the right key profile will be loaded. keyCombo_->setCurrentIndex(currentIndex); #if 0 messageTree_->setPredefinedKeysOnly(keyManager_->predefinedKeysOnly()); #endif - //Fileinfo label + // Fileinfo label updateFileInfoLabel(); - //Get all keys + // Get all keys initAllKeys(); } @@ -970,8 +965,8 @@ void MvQAbstractMessageExaminer::slotCreateNewProfile() { - bool ok; - QString text = QInputDialog::getText(0, tr("New profile"), + bool ok = false; + QString text = QInputDialog::getText(nullptr, tr("New profile"), tr("New profile name:"), QLineEdit::Normal, "", &ok); @@ -980,7 +975,7 @@ keyManager_->addProfile(text.toStdString()); keyCombo_->addItem(text); keyCombo_->setCurrentIndex(keyCombo_->count() - 1); - keyManager_->saveProfiles(); //save it to disk + keyManager_->saveProfiles(); // save it to disk } } @@ -991,8 +986,8 @@ if (!prof) return; - bool ok; - QString text = QInputDialog::getText(0, tr("Duplicate profile"), + bool ok = false; + QString text = QInputDialog::getText(nullptr, tr("Duplicate profile"), tr("New profile name:"), QLineEdit::Normal, "", &ok); if (ok && !text.isEmpty()) { @@ -1032,14 +1027,14 @@ return; } - //Create a tmp copy of the whole manager (no data - //values, just key descriptions) + // Create a tmp copy of the whole manager (no data + // values, just key descriptions) MvQKeyManager* tmpManager = keyManager_->clone(); MvQKeyDialog profDialog(dialogTitle + " - " + messageType_ + tr(" Key Profile Manager"), type, tmpManager, keyCombo_->currentIndex(), allKeys_); if (profDialog.exec() == QDialog::Accepted) { - //Save the current profile name + // Save the current profile name std::string currentProfName = keyCombo_->currentText().toStdString(); #if 0 messageModel_->keyProfileIsAboutToChange(); @@ -1048,14 +1043,14 @@ keyManager_->update(tmpManager); keyManager_->saveProfiles(); - disconnect(keyCombo_, SIGNAL(currentIndexChanged(int)), 0, 0); + disconnect(keyCombo_, SIGNAL(currentIndexChanged(int)), nullptr, nullptr); - //Clear the profile list + // Clear the profile list keyCombo_->clear(); - //resetMessageHeader(); + // resetMessageHeader(); - int i = 0; + int i = 0; int index = -1; for (auto it = keyManager_->data().begin(); it != keyManager_->data().end(); it++) { keyCombo_->addItem(QString((*it)->name().c_str())); @@ -1079,7 +1074,7 @@ Q_ASSERT(keyCombo_->currentIndex() >= 0 && keyCombo_->currentIndex() < static_cast(keyManager_->data().size())); - //We load the profile directly + // We load the profile directly loadKeyProfile(keyManager_->data().at(keyCombo_->currentIndex())); connect(keyCombo_, SIGNAL(currentIndexChanged(int)), @@ -1121,13 +1116,13 @@ void MvQAbstractMessageExaminer::slotCloseFilePanel(bool) { #ifdef ECCODES_UI - //if(ignoreSidebarAction_==true) - // return; + // if(ignoreSidebarAction_==true) + // return; filePanel_->hide(); actionFilePanel_->setChecked(false); - //ignoreSidebarAction_=false; + // ignoreSidebarAction_=false; #endif } @@ -1244,7 +1239,7 @@ } else { #ifdef ECCODES_UI - //Set a proper initial size for the splitter widgets + // Set a proper initial size for the splitter widgets Q_ASSERT(centralSplitter_->count() == 2); int len = width() - 20; QList sizes; @@ -1255,7 +1250,7 @@ } mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); - //settings.endGroup(); + // settings.endGroup(); if (settings.value("actionFileInfoStatus").isNull()) { actionFileInfo_->setChecked(true); @@ -1265,7 +1260,7 @@ } if (settings.value("actionLogStatus").isNull()) { - //Hidden by default + // Hidden by default actionLog_->setChecked(false); } else { @@ -1280,15 +1275,15 @@ actionFilePanel_->setChecked(settings.value("actionFilePanel").toBool()); } #endif - //Init key combo - //It is empty at this stage!! + // Init key combo + // It is empty at this stage!! savedKeyProfileName_ = settings.value("keyProfileName").toString(); - //The last loaded file + // The last loaded file sourceFileName_ = settings.value("sourceFileName").toString(); #ifdef ECCODES_UI - //The last loaded file list + // The last loaded file list if (!fileList_) { if (type_ == GribType) fileList_ = new MvQFileList(MvQFileList::GribFile); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQAbstractMessageExaminer.h metview-5.19.2/metview/src/libMvQtGui/MvQAbstractMessageExaminer.h --- metview-5.17.4/metview/src/libMvQtGui/MvQAbstractMessageExaminer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQAbstractMessageExaminer.h 2023-07-15 08:28:47.000000000 +0000 @@ -55,7 +55,7 @@ { Q_OBJECT public: - explicit MvQMessagePanel(QWidget* parent = 0); + explicit MvQMessagePanel(QWidget* parent = nullptr); void init(MvMessageMetaData*); void loadKeyProfile(MvKeyProfile* prof); @@ -86,7 +86,7 @@ void messageNumDetermined(); protected: - void messageScanStepChanged(int); + void messageScanStepChanged(int) override; private: void loadKeyProfileCore(MvKeyProfile* prof); @@ -112,8 +112,8 @@ BufrType }; - MvQAbstractMessageExaminer(QString, Type, QWidget* parent = 0); - ~MvQAbstractMessageExaminer(); + MvQAbstractMessageExaminer(QString, Type, QWidget* parent = nullptr); + ~MvQAbstractMessageExaminer() override; void init(MvMessageMetaData*, MvQKeyManager*, MvQFileList*); QString currentKeyProfileName(); @@ -140,7 +140,7 @@ void keyProfileChanged(); protected: - void closeEvent(QCloseEvent*); + void closeEvent(QCloseEvent*) override; virtual void setupFileMenu(); virtual void setupEditMenu(); @@ -156,8 +156,8 @@ void saveKeyProfiles(bool); virtual void initMain(MvMessageMetaData*) = 0; - virtual void initDumps() = 0; - virtual void initAllKeys() = 0; + virtual void initDumps() = 0; + virtual void initAllKeys() = 0; void updateWinTitle(QString); @@ -173,39 +173,39 @@ Type type_; - MvMessageMetaData* data_; - int currentMessageNo_; + MvMessageMetaData* data_{nullptr}; + int currentMessageNo_{-1}; QString sourceFileName_; MvQMainWindow::MenuItemMap menuItems_; - QComboBox* keyCombo_; - MvQKeyManager* keyManager_; + QComboBox* keyCombo_{nullptr}; + MvQKeyManager* keyManager_{nullptr}; QString savedKeyProfileName_; - //Main layout components - QSplitter* centralSplitter_; - QSplitter* mainSplitter_; - MvQFileInfoLabel* fileInfoLabel_; - QLabel* statusMessageLabel_; - - //File panel - MvQFileListWidget* filePanel_; - QAction* actionFilePanel_; - QAction* actionAddFile_; - MvQFileList* fileList_; + // Main layout components + QSplitter* centralSplitter_{nullptr}; + QSplitter* mainSplitter_{nullptr}; + MvQFileInfoLabel* fileInfoLabel_{nullptr}; + QLabel* statusMessageLabel_{nullptr}; + + // File panel + MvQFileListWidget* filePanel_{nullptr}; + QAction* actionFilePanel_{nullptr}; + QAction* actionAddFile_{nullptr}; + MvQFileList* fileList_{nullptr}; QList allKeys_; - qint64 fileSize_; + qint64 fileSize_{0}; - QAction* actionFileInfo_; - MvQLogPanel* logPanel_; + QAction* actionFileInfo_{nullptr}; + MvQLogPanel* logPanel_{nullptr}; #ifdef ECCODES_UI - QActionGroup* styleAg_; + QActionGroup* styleAg_{nullptr}; #endif private: - QAction* actionLog_; + QAction* actionLog_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQApplication.cc metview-5.19.2/metview/src/libMvQtGui/MvQApplication.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQApplication.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQApplication.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,38 +36,38 @@ // The dataReceived function will be called everytime // there is data available in the socket int sockfd = getService()->soc; - sn_ = new QSocketNotifier(sockfd, QSocketNotifier::Read); + sn_ = new QSocketNotifier(sockfd, QSocketNotifier::Read); QObject::connect(sn_, SIGNAL(activated(int)), this, SLOT(slotDataReceived(int))); - //Get desktop name + // Get desktop name char* desktop = getenv("MV_DESKTOP_NAME"); - if (desktop == 0) { + if (desktop == nullptr) { std::cout << "Error: MV_DESKTOP_NAME is not defined! MvQApplication exits" << std::endl; exit(1); } std::string dn(desktop); - desktopName_ = new char[dn.size() + 1]; + desktopName_ = new char[dn.size() + 1]; desktopName_[dn.size()] = '\0'; std::memcpy(desktopName_, dn.c_str(), dn.size()); - //Get qt style + // Get qt style char* styleCh = getenv("METVIEW_QT_STYLE"); - if (styleCh == 0) { + if (styleCh == nullptr) { marslog(LOG_EROR, " Error: METVIEW_QT_STYLE is not defined! MvQApplication exits"); exit(1); } std::string style(styleCh); QStringList styleLst = QStyleFactory::keys(); - QString styleQs = QString::fromStdString(style); + QString styleQs = QString::fromStdString(style); if (styleLst.contains(styleQs)) { marslog(LOG_INFO, "Setting qt style to: %s", style.c_str()); setStyle(styleQs); } - //Set fontsize if defined in env var + // Set fontsize if defined in env var if (const char* fontSizeCh = getenv("MV_FONT_SIZE")) { int fontSize = atoi(fontSizeCh); if (fontSize < 8) @@ -83,7 +83,7 @@ // Set QSettings location //--------------------------- - //Set a custom location inside the metview home directory for qsettings + // Set a custom location inside the metview home directory for qsettings if (char* spCh = getenv("METVIEW_USER_DIRECTORY")) { std::string sp(spCh); sp += "/System/Preferences/._mv_desktop_config_"; @@ -105,9 +105,9 @@ void MvQApplication::slotDataReceived(int) { - //Disable the notifier - //Process data from the socket - //Re-enable the notifier if you are interested in more data + // Disable the notifier + // Process data from the socket + // Re-enable the notifier if you are interested in more data // const QMetaObject *tt = metaObject (); // sn_->setEnabled(false); @@ -121,7 +121,7 @@ send_drop_info(getService(), desktopName_, *req, 0); } -//static callback function for message +// static callback function for message void MvQApplication::messageCallbackCore(svcid* id, request* r, void* obj) { #ifdef MVQSERVICE_DEBUG__ @@ -132,7 +132,7 @@ s->messageCallback(id, r); } -//the apps own callback function for message +// the apps own callback function for message void MvQApplication::messageCallback(svcid* /*id*/, request* r) { if (strcmp(r->name, "RAISE_WINDOW") == 0 && win_) { diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQArrowSpinWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQArrowSpinWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQArrowSpinWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQArrowSpinWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include MvQArrowSpinWidget::MvQArrowSpinWidget(QWidget* parent) : - QWidget(parent), - broadcast_(true) + QWidget(parent) { auto* hb = new QHBoxLayout(); hb->setContentsMargins(4, 0, 4, 0); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQArrowSpinWidget.h metview-5.19.2/metview/src/libMvQtGui/MvQArrowSpinWidget.h --- metview-5.17.4/metview/src/libMvQtGui/MvQArrowSpinWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQArrowSpinWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,10 @@ { Q_OBJECT - //Indexing starts from 1 + // Indexing starts from 1 public: - explicit MvQArrowSpinWidget(QWidget* parent = 0); + explicit MvQArrowSpinWidget(QWidget* parent = nullptr); void clear(bool broadcast); void reset(int maxVal, bool broadcast); int value() const; @@ -37,11 +37,11 @@ signals: void valueChanged(int); -protected: +private: void checkState(); - QToolButton* nextTb_; - QToolButton* prevTb_; - QSpinBox* spin_; - bool broadcast_; + QToolButton* nextTb_{nullptr}; + QToolButton* prevTb_{nullptr}; + QSpinBox* spin_{nullptr}; + bool broadcast_{true}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQCheckBoxCombo.cc metview-5.19.2/metview/src/libMvQtGui/MvQCheckBoxCombo.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQCheckBoxCombo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQCheckBoxCombo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,13 +31,13 @@ if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); - //Get item status + // Get item status bool status = index.data(Qt::UserRole).toBool(); - //Get item label + // Get item label QString text = index.data(Qt::DisplayRole).toString(); - //Fill style options with item data + // Fill style options with item data const QStyle* style = QApplication::style(); QStyleOptionButton opt; @@ -47,7 +47,7 @@ opt.text = text; opt.rect = option.rect; - //Draw item data as CheckBox + // Draw item data as CheckBox style->drawControl(QStyle::CE_CheckBox, &opt, painter); } @@ -55,7 +55,7 @@ const QStyleOptionViewItem&, const QModelIndex&) const { - //Create check box as our editor + // Create check box as our editor auto* editor = new QCheckBox(parent); editor->setFocusPolicy(Qt::StrongFocus); @@ -82,13 +82,13 @@ void MvQCheckBoxComboDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { // qDebug() << "setModelData"; - //get the value from the editor (CheckBox) + // get the value from the editor (CheckBox) auto* myEditor = static_cast(editor); bool value = myEditor->isChecked(); - //set model data + // set model data QMap data; @@ -113,7 +113,7 @@ // qDebug() << "commitdata"; emit commitData(editor); - //emit closeEditor(slider); + // emit closeEditor(slider); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQCheckBoxCombo.h metview-5.19.2/metview/src/libMvQtGui/MvQCheckBoxCombo.h --- metview-5.17.4/metview/src/libMvQtGui/MvQCheckBoxCombo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQCheckBoxCombo.h 2023-07-15 08:28:47.000000000 +0000 @@ -53,7 +53,7 @@ bool eventFilter(QObject* object, QEvent* event); virtual void paintEvent(QPaintEvent*); - //Get selected values + // Get selected values QStringList getSelectedValues(); signals: diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQColourWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQColourWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQColourWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQColourWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ #include #endif -#include +#include #include #include "MvMiscellaneous.h" @@ -70,28 +70,31 @@ highlightCol_ = MvQTheme::colour("coloureditor", "compact_grid_highlight"); if (layoutMode_ == SingleRowMode) { - items_ = items; + items_ = items; rowNum_ = 1; - } else { + } + else { makeItems(items); } if (layoutMode_ == SingleRowMode || layoutMode_ == ColumnMode) { - minSize_ = cellsPerRow_ * minCellSize_ + (cellsPerRow_ + 1) * cellGap_; + minSize_ = cellsPerRow_ * minCellSize_ + (cellsPerRow_ + 1) * cellGap_; int minYSize = rowNum_ * minCellSize_ + 2 * cellGap_; - cellSize_ = minCellSize_; - gridSizeX_ = minSize_; - gridSizeY_ = minYSize; - } else { - gridSizeX_ = minSize; - cellSize_ = (gridSizeX_ - 2 * cellGap_)/cellsPerRow_; - int minYSize = rowNum_ * cellSize_ + (rowNum_+1) * cellGap_; + cellSize_ = minCellSize_; + gridSizeX_ = minSize_; + gridSizeY_ = minYSize; + } + else { + gridSizeX_ = minSize; + cellSize_ = (gridSizeX_ - 2 * cellGap_) / cellsPerRow_; + int minYSize = rowNum_ * cellSize_ + (rowNum_ + 1) * cellGap_; if (minYSize > minSize) { - cellSize_ = (minSize - (rowNum_+1) * cellGap_)/rowNum_; + cellSize_ = (minSize - (rowNum_ + 1) * cellGap_) / rowNum_; gridSizeY_ = minSize; - gridSizeX_ = cellsPerRow_*cellSize_ + 2*cellGap_; - } else { - gridSizeY_ = minYSize; + gridSizeX_ = cellsPerRow_ * cellSize_ + 2 * cellGap_; + } + else { + gridSizeY_ = minYSize; } } @@ -102,7 +105,7 @@ setMouseTracking(true); setStyleSheet("QWidget {background-color: transparent;}"); - //setAutoFillBackground(true); + // setAutoFillBackground(true); createGrid(); } @@ -167,7 +170,8 @@ items_ << MvQColourItem(c, baseItems[i].name_); } } - } else if (layoutMode_ == RowMode) { + } + else if (layoutMode_ == RowMode) { rowNum_ = baseItems.count(); cellsPerRow_ = baseItems[0].shades_.size(); for (int j = 0; j < rowNum_; j++) { @@ -210,17 +214,9 @@ void MvQCompactColourGrid::createGrid() { - QPalette pal = palette(); - pix_ = QPixmap(gridSizeX_, gridSizeY_); pix_.fill(Qt::transparent); QPainter painter(&pix_); - //painter.setRenderHint(QPainter::Antialiasing); - //pal.window().color() - - //pix_.fill(pal.window().color()); - //pix_.fill(Qt::transparent); - painter.setPen(QPen(gridCol_)); if (layoutMode_ == SingleRowMode || layoutMode_ == ColumnMode) { @@ -235,12 +231,13 @@ // cellGap_ + row * cellSize_, // cellSize_, cellSize_, items_[i].col_); } - } else { + } + else { for (int i = 0; i < items_.count(); i++) { int row = i / cellsPerRow_; int col = i - row * cellsPerRow_; painter.setBrush(QBrush(items_[i].col_)); - painter.drawRect(cellGap_ + col * cellSize_, + painter.drawRect(cellGap_ + col * cellSize_, row * cellSize_ + (row + 1) * cellGap_, cellSize_, cellSize_); // painter.fillRect(col * cellSize_ + (col+1)*cellGap_, @@ -325,14 +322,14 @@ this, SLOT(slotContextMenu(const QPoint&))); } -//Sorting the colours +// Sorting the colours void MvQColourGrid::sort() { QMultiMap sm; foreach (MvQColourItem item, items_) { float sv = item.col_.hueF(); - //float sv=item.col_.lightnessF() * 5. + item.col_.hslSaturationF() * 2 + item.col_.hueF(); - //float sv=sqrt(0.299 * pow(item.col_.redF(),2.0) + 0.587 * pow(item.col_.greenF(),2.0) + 0.114 * pow(item.col_.blueF(),2.)); + // float sv=item.col_.lightnessF() * 5. + item.col_.hslSaturationF() * 2 + item.col_.hueF(); + // float sv=sqrt(0.299 * pow(item.col_.redF(),2.0) + 0.587 * pow(item.col_.greenF(),2.0) + 0.114 * pow(item.col_.blueF(),2.)); sm.insert(sv, item); } @@ -352,12 +349,12 @@ void MvQColourGrid::resizeEvent(QResizeEvent* /*event*/) { - int w = width(); - int h = height(); + int w = width(); + int h = height(); gridSize_ = std::min((w < h) ? w : h, maxGridSize_); cellSize_ = gridSize_ / cellsPerRow_; - marginX_ = (w - gridSize_)/2; - marginY_ = (h - gridSize_)/2; + marginX_ = (w - gridSize_) / 2; + marginY_ = (h - gridSize_) / 2; createGrid(); } @@ -367,7 +364,7 @@ QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); - //Render ring pixmap + // Render ring pixmap painter.drawPixmap(marginX_, marginY_, pix_); if (highlightIndex_ != -1) { @@ -388,8 +385,8 @@ pix_ = QPixmap(gridSize_, gridSize_); QPainter painter(&pix_); - //painter.setRenderHint(QPainter::Antialiasing); - //pal.window().color() + // painter.setRenderHint(QPainter::Antialiasing); + // pal.window().color() pix_.fill(pal.window().color()); @@ -427,7 +424,8 @@ highlightIndex_ = idx; update(); } - } else if (highlightIndex_ != -1) { + } + else if (highlightIndex_ != -1) { highlightIndex_ = -1; update(); } @@ -455,9 +453,8 @@ if (idx < 0 || idx >= items_.count()) return; - QList lst; auto* menu = new QMenu(this); - QAction* ac; + QAction* ac = nullptr; ac = new QAction(this); ac->setText(tr("&Copy colour")); @@ -466,7 +463,7 @@ ac->setData("copy"); menu->addAction(ac); - //Show the context menu and check selected action + // Show the context menu and check selected action ac = menu->exec(mapToGlobal(pos)); if (ac && !ac->isSeparator()) { if (ac->data().toString() == "copy") { @@ -492,7 +489,7 @@ huePenWhite_ = QPen(Qt::white, 2., Qt::SolidLine); setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); - //setMinimumSize(QSize(150 + 2 * margin_, 150)); + // setMinimumSize(QSize(150 + 2 * margin_, 150)); setMinimumSize(QSize(minSize_ + 2 * margin_, minSize_ + margin_)); setMouseTracking(true); @@ -500,17 +497,17 @@ void MvQColourWheel::resizeEvent(QResizeEvent* /*event*/) { - int w = width() - 2 * margin_; - int h = height(); + int w = width() - 2 * margin_; + int h = height(); outerRadius_ = (w < h) ? w : h; outerRadius_ /= 2; innerRadius_ = outerRadius_ - ringWidth_; - centre_ = QPoint(margin_ + w / 2, h / 2); + centre_ = QPoint(margin_ + w / 2, h / 2); - //Create a hue ring pixmap + // Create a hue ring pixmap createRing(); - //Create the triangle/rect pixmap + // Create the triangle/rect pixmap createShape(); } @@ -520,28 +517,26 @@ opt.initFrom(this); QPainter painter(this); - //style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); + // style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); painter.setRenderHint(QPainter::Antialiasing); - //Render ring pixmap + // Render ring pixmap painter.drawPixmap(centre_.x() - outerRadius_, centre_.y() - outerRadius_, ringPix_); - //Render the hue selector onto the ring + // Render the hue selector onto the ring renderRingSelector(&painter); - //Render triangle/rect + // Render triangle/rect painter.drawPixmap(centre_.x() - innerRadius_, centre_.y() - innerRadius_, shapePix_); - //Render the selector onto the triangle/rect + // Render the selector onto the triangle/rect renderShapeSelector(&painter); } -//Render the ring into a pixmap +// Render the ring into a pixmap void MvQColourWheel::createRing() { - QPalette pal = palette(); - ringPix_ = QPixmap(2 * outerRadius_, 2 * outerRadius_); ringPix_.fill(Qt::transparent); @@ -551,11 +546,11 @@ auto cg = makeRingGradient(); painter.translate(outerRadius_, outerRadius_); - QPainterPath pp; + QPainterPath pp; pp.addEllipse(QPoint(0, 0), outerRadius_, outerRadius_); pp.addEllipse(QPoint(0, 0), innerRadius_, innerRadius_); - //Coloured circle + // Coloured circle QBrush brush(cg); painter.setPen(Qt::NoPen); painter.setBrush(brush); @@ -565,10 +560,10 @@ void MvQColourWheel::renderRingSelector(QPainter* painter) { float alpha = MvSci::degToRad(-hue_); - float x = innerRadius_ * cos(alpha); - float y = innerRadius_ * sin(alpha); - float x1 = outerRadius_ * cos(alpha); - float y1 = outerRadius_ * sin(alpha); + float x = innerRadius_ * cos(alpha); + float y = innerRadius_ * sin(alpha); + float x1 = outerRadius_ * cos(alpha); + float y1 = outerRadius_ * sin(alpha); painter->translate(centre_.x(), centre_.y()); @@ -588,7 +583,8 @@ if (!isDark()) { painter->setPen(huePenBlack_); - } else { + } + else { painter->setPen(huePenWhite_); } painter->drawEllipse(centre_ + pos, shapeSelectorRadius_, shapeSelectorRadius_); @@ -601,11 +597,11 @@ if (delta.x() * delta.x() + delta.y() * delta.y() <= shapeSelectorRadius_ * shapeSelectorRadius_) { shapeOffset_ = delta; - dragType_ = ShapeDrag; + dragType_ = ShapeDrag; } else { shapeOffset_ = QPoint(); - dragType_ = checkPoint(event->pos()); + dragType_ = checkPoint(event->pos()); } } @@ -621,12 +617,12 @@ void MvQColourWheel::mouseReleaseEvent(QMouseEvent* /*event*/) { - //Drag happened + // Drag happened bool dragHappened = (dragType_ != NoDrag); - dragType_ = NoDrag; + dragType_ = NoDrag; shapeOffset_ = QPoint(0, 0); - dragPos_ = QPoint(); + dragPos_ = QPoint(); if (dragHappened) emit dragFinished(); @@ -639,7 +635,7 @@ return; QPoint dp = pos - centre_; - int hue = MvSci::radToDeg(atan2(dp.x(), dp.y())) - 90.; + int hue = MvSci::radToDeg(atan2(dp.x(), dp.y())) - 90.; if (hue < 0) hue += 360; @@ -653,7 +649,7 @@ QPoint dp = pos - shapeOffset_ - centre_; - int cls1, cls2; + int cls1 = 0, cls2 = 0; if (projectPosToCls(dp, cls1, cls2)) { setCls(cls1, cls2); } @@ -686,8 +682,8 @@ void MvQHslWheel::createShape() { - int nx = 256; - int ny = 256; + int nx = 256; + int ny = 256; float tFactor = sqrt(3) / 2.; QImage img(nx, ny, QImage::Format_ARGB32_Premultiplied); @@ -699,7 +695,7 @@ int lgt = i; if (abs(nx / 2 - i) < j / 2) { int sat = saturation(chroma, lgt); - col = QColor::fromHsl(hue_, sat, lgt); + col = QColor::fromHsl(hue_, sat, lgt); img.setPixel(i, j, col.rgb()); } else { @@ -710,7 +706,7 @@ float h = innerRadius_ * 1.5; float w = h / tFactor; - img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); shapePix_ = QPixmap(innerRadius_ * 2, innerRadius_ * 2); shapePix_.fill(Qt::transparent); @@ -726,11 +722,11 @@ MvQHslWheel::DragType MvQHslWheel::checkPoint(QPoint pos) { - //int fullRad=(width()-2*margin_)/2; - int rad = width() / 2 - margin_ - ringWidth_; - int dx = pos.x() - width() / 2; - int dy = pos.y() - height() / 2; - int d = sqrt(dx * dx + dy * dy); + // int fullRad=(width()-2*margin_)/2; + int rad = width() / 2 - margin_ - ringWidth_; + int dx = pos.x() - width() / 2; + int dy = pos.y() - height() / 2; + int d = sqrt(dx * dx + dy * dy); int ringTolerance = 10; if (d > rad && d < rad + ringWidth_ + ringTolerance && dragType_ != ShapeDrag) { @@ -744,9 +740,9 @@ else if (d <= rad && dragType_ != RingDrag) { QPointF pp(dx, dy); - int lgt, sat; + int lgt = 0, sat = 0; if (posToCls(pp, lgt, sat)) { - //MvLog().info() << "ShapeDrag"; + // MvLog().info() << "ShapeDrag"; setCls(lgt, sat); return ShapeDrag; } @@ -770,13 +766,13 @@ float yt = innerRadius_ - (255. - chromaVal) * (1.5 * static_cast(innerRadius_)) / 255.; float xt = static_cast(innerRadius_) * sqrt(3.) * (lgt_ - 128) / 255.; - float alpha =MvSci::degToRad((hue_ - 90)); - float x = cos(alpha) * xt - sin(alpha) * yt; - float y = sin(alpha) * xt + cos(alpha) * yt; + float alpha = MvSci::degToRad((hue_ - 90)); + float x = cos(alpha) * xt - sin(alpha) * yt; + float y = sin(alpha) * xt + cos(alpha) * yt; pos = QPointF(x, -y); - //qDebug() << "lgtSat" << sat_ << lgt_ << pos; + // qDebug() << "lgtSat" << sat_ << lgt_ << pos; return true; } @@ -784,16 +780,16 @@ bool MvQHslWheel::posToCls(QPointF pos, int& lgt, int& sat) { - //Transform coordinate system + // Transform coordinate system float alpha = MvSci::degToRad(-(hue_ - 90)); - float xt = cos(alpha) * pos.x() + sin(alpha) * pos.y(); - float yt = sin(alpha) * pos.x() - cos(alpha) * pos.y(); + float xt = cos(alpha) * pos.x() + sin(alpha) * pos.y(); + float yt = sin(alpha) * pos.x() - cos(alpha) * pos.y(); if (yt < innerRadius_ && yt > -innerRadius_ / 2. && fabs(xt) <= (innerRadius_ - yt) / 2) { int chroma = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); - lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); - sat = saturation(chroma, lgt); + lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); + sat = saturation(chroma, lgt); return true; } @@ -803,16 +799,16 @@ bool MvQHslWheel::projectPosToCls(QPointF pos, int& lgt, int& sat) { - //Transform coordinate system + // Transform coordinate system float alpha = MvSci::degToRad(-(hue_ - 90)); - float xt = cos(alpha) * pos.x() + sin(alpha) * pos.y(); - float yt = sin(alpha) * pos.x() - cos(alpha) * pos.y(); + float xt = cos(alpha) * pos.x() + sin(alpha) * pos.y(); + float yt = sin(alpha) * pos.x() - cos(alpha) * pos.y(); if (yt < innerRadius_ && yt > -innerRadius_ / 2. && fabs(xt) <= (innerRadius_ - yt) / 2) { int chroma = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); - lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); - sat = saturation(chroma, lgt); + lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); + sat = saturation(chroma, lgt); return true; } @@ -826,8 +822,8 @@ } else if (fabs(xt) <= (innerRadius_ - yt) / 2) { int chromaVal = chroma(sat_, lgt_); - lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); - sat = saturation(chromaVal, lgt); + lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); + sat = saturation(chromaVal, lgt); return true; } @@ -857,8 +853,8 @@ void MvQHslWheel::slotSetColour(QColor col) { - //MvLog().info() << MV_FN_INFO << "hue=" << col.hslHue() << " col=" << col; - hue_ = std::max(col.hslHue(),0); + // MvLog().info() << MV_FN_INFO << "hue=" << col.hslHue() << " col=" << col; + hue_ = std::max(col.hslHue(), 0); lgt_ = col.lightness(); sat_ = col.hslSaturation(); @@ -868,21 +864,21 @@ void MvQHslWheel::initColour(QColor col) { -// int hue = std::min(col.hslHue(), 0); -// int lgt = col.lightness(); -// int sat = col.hslSaturation(); + // int hue = std::min(col.hslHue(), 0); + // int lgt = col.lightness(); + // int sat = col.hslSaturation(); slotSetColour(col); - //The problem is that several RGB values can be mapped to the same - //HSL value. So what we emit here is the original colour! - //emit hslSelected(hue_,sat_,lgt_); + // The problem is that several RGB values can be mapped to the same + // HSL value. So what we emit here is the original colour! + // emit hslSelected(hue_,sat_,lgt_); emit colourSelected(col); } int MvQHslWheel::saturation(int chroma, int lgt) { float chromaNorm = static_cast(chroma) / 255.; - float lgtNorm = static_cast(lgt) / 255.; + float lgtNorm = static_cast(lgt) / 255.; return (chroma == 0) ? 0 : 255. * chromaNorm / (1 - fabs(2. * lgtNorm - 1)); } @@ -914,8 +910,8 @@ QConicalGradient MvQHclWheel::makeRingGradient() { QConicalGradient cg(0, 0, 0); - for (int i=0; i < 360; i+=5) { - cg.setColorAt(static_cast(i)/360., MvQPalette::fromHclLuv(i, ringChroma_, ringLum_)); + for (int i = 0; i < 360; i += 5) { + cg.setColorAt(static_cast(i) / 360., MvQPalette::fromHclLuv(i, ringChroma_, ringLum_)); } cg.setColorAt(1, MvQPalette::fromHclLuv(359, ringChroma_, ringLum_)); return cg; @@ -923,22 +919,22 @@ void MvQHclWheel::createShape() { - int nx = 256; - int ny = 256; + int nx = 256; + int ny = 256; float tFactor = sqrt(3) / 2.; QImage img(nx, ny, QImage::Format_ARGB32_Premultiplied); QColor col; - float chromaFactor = static_cast(maxShapeChroma_)/255.; - float lumFactor = static_cast(maxShapeLum_)/255.; + float chromaFactor = static_cast(maxShapeChroma_) / 255.; + float lumFactor = static_cast(maxShapeLum_) / 255.; for (int j = 0; j < ny; j++) { - int chroma = static_cast(static_cast(255 - j)*chromaFactor); + int chroma = static_cast(static_cast(255 - j) * chromaFactor); for (int i = 0; i < nx; i++) { - int lum = static_cast(static_cast(i)*lumFactor); + int lum = static_cast(static_cast(i) * lumFactor); if (abs(nx / 2 - i) < j / 2) { -// int sat = saturation(chroma, lgt); -// col = QColor::fromHsl(hue_, sat, lgt); + // int sat = saturation(chroma, lgt); + // col = QColor::fromHsl(hue_, sat, lgt); col = MvQPalette::fromHclLuv(hue_, chroma, lum); img.setPixel(i, j, col.rgb()); @@ -951,7 +947,7 @@ float h = innerRadius_ * 1.5; float w = h / tFactor; - img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + img = img.scaled(w, h, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); shapePix_ = QPixmap(innerRadius_ * 2, innerRadius_ * 2); shapePix_.fill(Qt::transparent); @@ -967,11 +963,11 @@ MvQColourWheel::DragType MvQHclWheel::checkPoint(QPoint pos) { - //int fullRad=(width()-2*margin_)/2; - int rad = width() / 2 - margin_ - ringWidth_; - int dx = pos.x() - width() / 2; - int dy = pos.y() - height() / 2; - int d = sqrt(dx * dx + dy * dy); + // int fullRad=(width()-2*margin_)/2; + int rad = width() / 2 - margin_ - ringWidth_; + int dx = pos.x() - width() / 2; + int dy = pos.y() - height() / 2; + int d = sqrt(dx * dx + dy * dy); int ringTolerance = 10; if (d > rad && d < rad + ringWidth_ + ringTolerance && dragType_ != ShapeDrag) { @@ -985,7 +981,7 @@ else if (d <= rad && dragType_ != RingDrag) { QPointF pp(dx, dy); - int chroma, lum; + int chroma = 0, lum = 0; if (posToCls(pp, chroma, lum)) { setCls(chroma, lum); return ShapeDrag; @@ -1005,46 +1001,45 @@ bool MvQHclWheel::clsToPos(QPointF& pos) { int chroma = clipTo(chroma_, 0, maxShapeChroma_); - float chroma255 = 255.*static_cast(chroma)/static_cast(maxShapeChroma_) ; + float chroma255 = 255. * static_cast(chroma) / static_cast(maxShapeChroma_); float yt = innerRadius_ - (255. - chroma255) * (1.5 * static_cast(innerRadius_)) / 255.; int lum = clipTo(lum_, 0, maxShapeLum_); - float lum255 = 255.*static_cast(lum)/static_cast(maxShapeLum_) ; + float lum255 = 255. * static_cast(lum) / static_cast(maxShapeLum_); float xt = static_cast(innerRadius_) * sqrt(3.) * (lum255 - 128) / 255.; if (yt < innerRadius_ && yt > -innerRadius_ / 2. && fabs(xt) <= (innerRadius_ - yt) / 2) { - -// float yt = innerRadius_ - (255. - chromaVal) * (1.5 * static_cast(innerRadius_)) / 255.; -// float xt = static_cast(innerRadius_) * sqrt(3.) * (lgt_ - 128) / 255.; + // float yt = innerRadius_ - (255. - chromaVal) * (1.5 * static_cast(innerRadius_)) / 255.; + // float xt = static_cast(innerRadius_) * sqrt(3.) * (lgt_ - 128) / 255.; float alpha = MvSci::degToRad(hue_ - 90); - float x = cos(alpha) * xt - sin(alpha) * yt; - float y = sin(alpha) * xt + cos(alpha) * yt; + float x = cos(alpha) * xt - sin(alpha) * yt; + float y = sin(alpha) * xt + cos(alpha) * yt; pos = QPointF(x, -y); return true; - } + } return false; - //qDebug() << "lgtSat" << sat_ << lgt_ << pos; + // qDebug() << "lgtSat" << sat_ << lgt_ << pos; } bool MvQHclWheel::posToCls(QPointF pos, int& chroma, int& lum) { - //Transform coordinate system + // Transform coordinate system float alpha = MvSci::degToRad(-(hue_ - 90)); - float xt = cos(alpha) * pos.x() + sin(alpha) * pos.y(); - float yt = sin(alpha) * pos.x() - cos(alpha) * pos.y(); + float xt = cos(alpha) * pos.x() + sin(alpha) * pos.y(); + float yt = sin(alpha) * pos.x() - cos(alpha) * pos.y(); if (yt < innerRadius_ && yt > -innerRadius_ / 2. && fabs(xt) <= (innerRadius_ - yt) / 2) { float chroma255 = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); - //MvLog().info() << MV_FN_INFO << "chroma255=" << chroma255; + // MvLog().info() << MV_FN_INFO << "chroma255=" << chroma255; chroma = scaleChromaFrom255(chroma255); - //MvLog().info() << MV_FN_INFO << " chroma=" << chroma; - //chroma = std::max(std::min(static_cast(static_cast(maxShapeChroma_) * (chroma255/255.)), maxShapeChroma_),0); - float lum255 = 128. + 128. * xt / (static_cast(innerRadius_) * std::sqrt(3.)); + // MvLog().info() << MV_FN_INFO << " chroma=" << chroma; + // chroma = std::max(std::min(static_cast(static_cast(maxShapeChroma_) * (chroma255/255.)), maxShapeChroma_),0); + float lum255 = 128. + 128. * xt / (static_cast(innerRadius_) * std::sqrt(3.)); lum = scaleLumFrom255(lum255); return true; } @@ -1053,54 +1048,54 @@ bool MvQHclWheel::projectPosToCls(QPointF pos, int& chroma, int& lum) { - //Transform coordinate system + // Transform coordinate system float alpha = MvSci::degToRad(-(hue_ - 90)); - float xt = cos(alpha) * pos.x() + sin(alpha) * pos.y(); - float yt = sin(alpha) * pos.x() - cos(alpha) * pos.y(); + float xt = cos(alpha) * pos.x() + sin(alpha) * pos.y(); + float yt = sin(alpha) * pos.x() - cos(alpha) * pos.y(); if (yt < innerRadius_ && yt > -innerRadius_ / 2. && fabs(xt) <= (innerRadius_ - yt) / 2) { -// int chroma = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); -// lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); -// sat = saturation(chroma, lgt); + // int chroma = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); + // lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); + // sat = saturation(chroma, lgt); float chroma255 = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); - //MvLog().info() << MV_FN_INFO << "chroma255=" << chroma255; + // MvLog().info() << MV_FN_INFO << "chroma255=" << chroma255; chroma = scaleChromaFrom255(chroma255); - //MvLog().info() << MV_FN_INFO << " chroma=" << chroma; - //chroma = std::max(std::min(static_cast(static_cast(maxShapeChroma_) * (chroma255/255.)), maxShapeChroma_),0); - float lum255 = 128. + 128. * xt / (static_cast(innerRadius_) * std::sqrt(3.)); + // MvLog().info() << MV_FN_INFO << " chroma=" << chroma; + // chroma = std::max(std::min(static_cast(static_cast(maxShapeChroma_) * (chroma255/255.)), maxShapeChroma_),0); + float lum255 = 128. + 128. * xt / (static_cast(innerRadius_) * std::sqrt(3.)); lum = scaleLumFrom255(lum255); -// lum = std::max(std::min(static_cast(static_cast(maxShapeLum_) * (lum255/255.)), maxShapeLum_),0); + // lum = std::max(std::min(static_cast(static_cast(maxShapeLum_) * (lum255/255.)), maxShapeLum_),0); return true; } else if (yt < innerRadius_ && yt > -innerRadius_ / 2.) { - float chroma255 = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); - chroma = std::max(std::min(static_cast(static_cast(maxShapeChroma_) * (chroma255/255.)), maxShapeChroma_),0); - //lum = ((xt >0)?1:-1)* + float chroma255 = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); + chroma = std::max(std::min(static_cast(static_cast(maxShapeChroma_) * (chroma255 / 255.)), maxShapeChroma_), 0); + // lum = ((xt >0)?1:-1)* - float lum255 = 128. + ((xt > 0) ? 1 : -1) * (static_cast((innerRadius_ - yt) / 2) * std::sqrt(3.)); + float lum255 = 128. + ((xt > 0) ? 1 : -1) * (static_cast((innerRadius_ - yt) / 2) * std::sqrt(3.)); -// float lum255 = 128. + 255. * ((xt > 0) ? 1 : -1) / (static_cast((innerRadius_ - yt) / 2) * std::sqrt(3.)); + // float lum255 = 128. + 255. * ((xt > 0) ? 1 : -1) / (static_cast((innerRadius_ - yt) / 2) * std::sqrt(3.)); lum = scaleLumFrom255(lum255); - //MvLog().info() << "Size lum255=" << lum255 << " lum=" << lum; + // MvLog().info() << "Size lum255=" << lum255 << " lum=" << lum; -// int chroma = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); + // int chroma = 255. - 255. * (innerRadius_ - yt) / (1.5 * static_cast(innerRadius_)); -// lgt = 128. + 255. * ((xt > 0) ? 1 : -1) * ((innerRadius_ - yt) / 2) / (static_cast(innerRadius_) * sqrt(3.)); + // lgt = 128. + 255. * ((xt > 0) ? 1 : -1) * ((innerRadius_ - yt) / 2) / (static_cast(innerRadius_) * sqrt(3.)); -// sat = saturation(chroma, lgt); + // sat = saturation(chroma, lgt); return true; } else if (fabs(xt) <= (innerRadius_ - yt) / 2) { - float lum255 = 128. + 255. * xt / (static_cast(innerRadius_) * std::sqrt(3.)); - lum = std::max(std::min(static_cast(static_cast(maxShapeLum_) * (lum255/255.)), maxShapeLum_),0); + float lum255 = 128. + 255. * xt / (static_cast(innerRadius_) * std::sqrt(3.)); + lum = std::max(std::min(static_cast(static_cast(maxShapeLum_) * (lum255 / 255.)), maxShapeLum_), 0); -// int chromaVal = chroma(sat_, lgt_); -// lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); -// sat = saturation(chromaVal, lgt); + // int chromaVal = chroma(sat_, lgt_); + // lgt = 128. + 255. * xt / (static_cast(innerRadius_) * sqrt(3.)); + // sat = saturation(chromaVal, lgt); return true; } @@ -1127,7 +1122,7 @@ { MvQPalette::toHclLuv(col, hue_, chroma_, lum_); hue_ = std::max(0, std::min(hue_, 359)); - //MvLog().info() << MV_FN_INFO << hue_ << " " << chroma_ << " " << lum_; + // MvLog().info() << MV_FN_INFO << hue_ << " " << chroma_ << " " << lum_; createShape(); update(); } @@ -1135,9 +1130,9 @@ void MvQHclWheel::initColour(QColor col) { slotSetColour(col); - //The problem is that several RGB values can be mapped to the same - //HSL value. So what we emit here is the original colour! - //emit hslSelected(hue_,sat_,lgt_); + // The problem is that several RGB values can be mapped to the same + // HSL value. So what we emit here is the original colour! + // emit hslSelected(hue_,sat_,lgt_); emit colourSelected(col); } @@ -1148,12 +1143,12 @@ int MvQHclWheel::scaleChromaFrom255(float v) const { - return clipTo(static_cast(maxShapeChroma_) * (v/255.), 0, maxShapeChroma_); + return clipTo(static_cast(maxShapeChroma_) * (v / 255.), 0, maxShapeChroma_); } int MvQHclWheel::scaleLumFrom255(float v) const { - return clipTo(static_cast(maxShapeLum_) * (v/255.),0, maxShapeLum_); + return clipTo(static_cast(maxShapeLum_) * (v / 255.), 0, maxShapeLum_); } int MvQHclWheel::clipTo(int v, int minVal, int maxVal) const @@ -1180,7 +1175,6 @@ #endif - //============================== // // ColourSpaceSliderWidget @@ -1189,7 +1183,7 @@ void ColourSpaceSliderWidget::adjustGrooves(int ignoreIndex) { - for (int i=0; i < 3; i++) { + for (int i = 0; i < 3; i++) { if (i != ignoreIndex) { adjustGroove(i); } @@ -1200,10 +1194,10 @@ void ColourSpaceSliderWidget::sliderChanged(int val) { if (!ignoreSlider_) { - auto w = static_cast(QObject::sender()); + auto w = dynamic_cast(QObject::sender()); if (w) { auto idx = sliders_.indexOf(w); - if (idx >=0 ) { + if (idx >= 0) { ignoreSpin_ = true; spins_[idx]->setValue(val); ignoreSpin_ = false; @@ -1217,10 +1211,10 @@ void ColourSpaceSliderWidget::spinChanged(int val) { if (!ignoreSpin_) { - auto w = static_cast(QObject::sender()); - if(w) { + auto w = dynamic_cast(QObject::sender()); + if (w) { auto idx = spins_.indexOf(w); - if (idx >=0) { + if (idx >= 0) { ignoreSlider_ = true; sliders_[idx]->setValue(val); ignoreSlider_ = false; @@ -1237,17 +1231,18 @@ // //=============================== -RGBWidget::RGBWidget(QWidget* parent) : ColourSpaceSliderWidget(parent) +RGBWidget::RGBWidget(QWidget* parent) : + ColourSpaceSliderWidget(parent) { auto grid = new QGridLayout(this); grid->setVerticalSpacing(2); QStringList rgbNames = {tr("R:"), tr("G:"), tr("B:")}; - for (int i=0; i < rgbNames.size(); i++) { + for (int i = 0; i < rgbNames.size(); i++) { auto label = new QLabel(rgbNames[i], this); grid->addWidget(label, i, 0); - auto slider =new QSlider(this); + auto slider = new QSlider(this); slider->setOrientation(Qt::Horizontal); slider->setRange(0, 255); @@ -1261,7 +1256,7 @@ grid->addWidget(spin, i, 2); connect(spin, SIGNAL(valueChanged(int)), - this,SLOT(spinChanged(int))); + this, SLOT(spinChanged(int))); grid->setColumnStretch(1, 1); spins_ << spin; } @@ -1277,21 +1272,24 @@ if (index == 0) { c1 = QColor(0, c.green(), c.blue()); c2 = QColor(255, c.green(), c.blue()); - } else if (index == 1) { + } + else if (index == 1) { c1 = QColor(c.red(), 0, c.blue()); c2 = QColor(c.red(), 255, c.blue()); - } else if (index == 2) { + } + else if (index == 2) { c1 = QColor(c.red(), c.green(), 0); - c2 = QColor(c.red(), c.green(), 255); + c2 = QColor(c.red(), c.green(), 255); } - QString sh("QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 %1, stop:1 %2);}" - "QSlider::handle:horizontal { " - "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " - "border: 1px solid #5c5c5c; " - "width: 18px;" - "margin: -2px 0;" - "border-radius: 3px;}"); + QString sh( + "QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 %1, stop:1 %2);}" + "QSlider::handle:horizontal { " + "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " + "border: 1px solid #5c5c5c; " + "width: 18px;" + "margin: -2px 0;" + "border-radius: 3px;}"); sh = sh.arg(c1.name()).arg(c2.name()); @@ -1323,7 +1321,7 @@ QColor RGBWidget::currentColour() const { - return QColor(spins_[0]->value(), spins_[1]->value(), spins_[2]->value()); + return {spins_[0]->value(), spins_[1]->value(), spins_[2]->value()}; } //============================== @@ -1332,19 +1330,21 @@ // //=============================== -HSLWidget::HSLWidget(QWidget* parent) : ColourSpaceSliderWidget(parent) +HSLWidget::HSLWidget(QWidget* parent) : + ColourSpaceSliderWidget(parent) { auto grid = new QGridLayout(this); QStringList rgbNames = {tr("H:"), tr("S:"), tr("L:")}; - for (int i=0; i < rgbNames.size(); i++) { + for (int i = 0; i < rgbNames.size(); i++) { auto label = new QLabel(rgbNames[i], this); grid->addWidget(label, i, 0); - auto slider =new QSlider(this); + auto slider = new QSlider(this); slider->setOrientation(Qt::Horizontal); if (i == 0) { slider->setRange(0, 359); - } else { + } + else { slider->setRange(0, 255); } connect(slider, SIGNAL(valueChanged(int)), @@ -1355,12 +1355,13 @@ auto spin = new QSpinBox(this); if (i == 0) { spin->setRange(0, 359); - } else { + } + else { spin->setRange(0, 255); } grid->addWidget(spin, i, 2); connect(spin, SIGNAL(valueChanged(int)), - this,SLOT(spinChanged(int))); + this, SLOT(spinChanged(int))); grid->setColumnStretch(1, 1); spins_ << spin; } @@ -1373,34 +1374,36 @@ QList cols; if (index == 0) { // hue range=0-359 - for (int i=0; i < 360; i+=30) { + for (int i = 0; i < 360; i += 30) { cols << QColor::fromHsl(i, c.hslSaturation(), c.lightness()); } cols << QColor::fromHsl(359, c.hslSaturation(), c.lightness()); - } else if (index == 1) { - for (int i=0; i <= 255; i+=15) { + } + else if (index == 1) { + for (int i = 0; i <= 255; i += 15) { cols << QColor::fromHsl(c.hslHue(), i, c.lightness()); } - } else if (index == 2) { - for (int i=0; i <= 255; i+=15) { + } + else if (index == 2) { + for (int i = 0; i <= 255; i += 15) { cols << QColor::fromHsl(c.hslHue(), c.hslSaturation(), i); } } - QString sh("QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, %1);}" - "QSlider::handle:horizontal { " - "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " - "border: 1px solid #5c5c5c; " - "width: 18px;" - "margin: -2px 0;" - "border-radius: 3px;}"); + QString sh( + "QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, %1);}" + "QSlider::handle:horizontal { " + "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " + "border: 1px solid #5c5c5c; " + "width: 18px;" + "margin: -2px 0;" + "border-radius: 3px;}"); QString gr; QString t = "stop:%1 %2"; - for (int i=0; i < cols.size(); i++) { - gr += t.arg(static_cast(i) / static_cast(cols.size() - 1), 0, 'f', 3). - arg(cols[i].name()); - if (i != cols.size()-1) { + for (int i = 0; i < cols.size(); i++) { + gr += t.arg(static_cast(i) / static_cast(cols.size() - 1), 0, 'f', 3).arg(cols[i].name()); + if (i != cols.size() - 1) { gr += ","; } } @@ -1444,21 +1447,24 @@ // //=============================== -HCLabWidget::HCLabWidget(QWidget* parent) : ColourSpaceSliderWidget(parent) +HCLabWidget::HCLabWidget(QWidget* parent) : + ColourSpaceSliderWidget(parent) { auto grid = new QGridLayout(this); QStringList rgbNames = {tr("H:"), tr("C:"), tr("L:")}; - for (int i=0; i < rgbNames.size(); i++) { + for (int i = 0; i < rgbNames.size(); i++) { auto label = new QLabel(rgbNames[i], this); grid->addWidget(label, i, 0); - auto slider =new QSlider(this); + auto slider = new QSlider(this); slider->setOrientation(Qt::Horizontal); if (i == 0) { slider->setRange(0, 359); - } else if (i == 1) { + } + else if (i == 1) { slider->setRange(0, 149); - } else if (i == 2) { + } + else if (i == 2) { slider->setRange(0, 99); } connect(slider, SIGNAL(valueChanged(int)), @@ -1469,15 +1475,17 @@ auto spin = new QSpinBox(this); if (i == 0) { spin->setRange(0, 359); - } else if (i == 1) { + } + else if (i == 1) { spin->setRange(0, 149); - } else if (i == 2) { + } + else if (i == 2) { spin->setRange(0, 99); } grid->addWidget(spin, i, 2); connect(spin, SIGNAL(valueChanged(int)), - this,SLOT(spinChanged(int))); + this, SLOT(spinChanged(int))); grid->setColumnStretch(1, 1); spins_ << spin; } @@ -1489,37 +1497,39 @@ auto col = currentColour(); QList cols; - int h, c, l; + int h = 0, c = 0, l = 0; MvQPalette::toHclLab(col, h, c, l); if (index == 0) { - for (int i=0; i <= 360; i+=5) { + for (int i = 0; i <= 360; i += 5) { cols << MvQPalette::fromHclLab(i, c, l); } - } else if (index == 1) { - for (int i=0; i <=150; i+=5) { - cols << MvQPalette::fromHclLab(h, i, l); - } - } else if (index == 2) { - for (int i=0; i <= 100; i+=5) { - cols << MvQPalette::fromHclLab(h, c, i); + } + else if (index == 1) { + for (int i = 0; i <= 150; i += 5) { + cols << MvQPalette::fromHclLab(h, i, l); + } + } + else if (index == 2) { + for (int i = 0; i <= 100; i += 5) { + cols << MvQPalette::fromHclLab(h, c, i); } } - QString sh("QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, %1);}" - "QSlider::handle:horizontal { " - "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " - "border: 1px solid #5c5c5c; " - "width: 18px;" - "margin: -2px 0;" - "border-radius: 3px;}"); + QString sh( + "QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, %1);}" + "QSlider::handle:horizontal { " + "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " + "border: 1px solid #5c5c5c; " + "width: 18px;" + "margin: -2px 0;" + "border-radius: 3px;}"); QString gr; QString t = "stop:%1 %2"; - for (int i=0; i < cols.size(); i++) { - gr += t.arg(static_cast(i) / static_cast(cols.size() - 1), 0, 'f', 3). - arg(cols[i].name()); - if (i != cols.size()-1) { + for (int i = 0; i < cols.size(); i++) { + gr += t.arg(static_cast(i) / static_cast(cols.size() - 1), 0, 'f', 3).arg(cols[i].name()); + if (i != cols.size() - 1) { gr += ","; } } @@ -1531,7 +1541,7 @@ { ignoreSpin_ = true; ignoreSlider_ = true; - int h, ch, l; + int h = 0, ch = 0, l = 0; MvQPalette::toHclLab(col, h, ch, l); qDebug() << "HCL=" << h << ch << l; @@ -1560,21 +1570,24 @@ // //=============================== -HCLuvWidget::HCLuvWidget(QWidget* parent) : ColourSpaceSliderWidget(parent) +HCLuvWidget::HCLuvWidget(QWidget* parent) : + ColourSpaceSliderWidget(parent) { auto grid = new QGridLayout(this); QStringList rgbNames = {tr("H:"), tr("C:"), tr("L:")}; - for (int i=0; i < rgbNames.size(); i++) { + for (int i = 0; i < rgbNames.size(); i++) { auto label = new QLabel(rgbNames[i], this); grid->addWidget(label, i, 0); - auto slider =new QSlider(this); + auto slider = new QSlider(this); slider->setOrientation(Qt::Horizontal); if (i == 0) { slider->setRange(0, 359); - } else if (i == 1) { + } + else if (i == 1) { slider->setRange(0, 149); - } else if (i == 2) { + } + else if (i == 2) { slider->setRange(0, 99); } connect(slider, SIGNAL(valueChanged(int)), @@ -1585,15 +1598,17 @@ auto spin = new QSpinBox(this); if (i == 0) { spin->setRange(0, 359); - } else if (i == 1) { + } + else if (i == 1) { spin->setRange(0, 149); - } else if (i == 2) { + } + else if (i == 2) { spin->setRange(0, 99); } grid->addWidget(spin, i, 2); connect(spin, SIGNAL(valueChanged(int)), - this,SLOT(spinChanged(int))); + this, SLOT(spinChanged(int))); grid->setColumnStretch(1, 1); spins_ << spin; } @@ -1605,37 +1620,39 @@ auto col = currentColour(); QList cols; - int h, c, l; + int h = 0, c = 0, l = 0; MvQPalette::toHclLuv(col, h, c, l); if (index == 0) { - for (int i=0; i <= 360; i+=5) { + for (int i = 0; i <= 360; i += 5) { cols << MvQPalette::fromHclLuv(i, c, l); } - } else if (index == 1) { - for (int i=0; i <=150; i+=5) { - cols << MvQPalette::fromHclLuv(h, i, l); - } - } else if (index == 2) { - for (int i=0; i <= 100; i+=5) { - cols << MvQPalette::fromHclLuv(h, c, i); + } + else if (index == 1) { + for (int i = 0; i <= 150; i += 5) { + cols << MvQPalette::fromHclLuv(h, i, l); + } + } + else if (index == 2) { + for (int i = 0; i <= 100; i += 5) { + cols << MvQPalette::fromHclLuv(h, c, i); } } - QString sh("QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, %1);}" - "QSlider::handle:horizontal { " - "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " - "border: 1px solid #5c5c5c; " - "width: 18px;" - "margin: -2px 0;" - "border-radius: 3px;}"); + QString sh( + "QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, %1);}" + "QSlider::handle:horizontal { " + "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " + "border: 1px solid #5c5c5c; " + "width: 18px;" + "margin: -2px 0;" + "border-radius: 3px;}"); QString gr; QString t = "stop:%1 %2"; - for (int i=0; i < cols.size(); i++) { - gr += t.arg(static_cast(i) / static_cast(cols.size() - 1), 0, 'f', 3). - arg(cols[i].name()); - if (i != cols.size()-1) { + for (int i = 0; i < cols.size(); i++) { + gr += t.arg(static_cast(i) / static_cast(cols.size() - 1), 0, 'f', 3).arg(cols[i].name()); + if (i != cols.size() - 1) { gr += ","; } } @@ -1647,7 +1664,7 @@ { ignoreSpin_ = true; ignoreSlider_ = true; - int h, ch, l; + int h = 0, ch = 0, l = 0; MvQPalette::toHclLuv(col, h, ch, l); qDebug() << "HCL=" << h << ch << l; @@ -1676,17 +1693,18 @@ // //=============================== -GreyScaleWidget::GreyScaleWidget(QWidget* parent) : ColourSpaceSliderWidget(parent) +GreyScaleWidget::GreyScaleWidget(QWidget* parent) : + ColourSpaceSliderWidget(parent) { auto grid = new QGridLayout(this); grid->setVerticalSpacing(2); QStringList rgbNames = {tr("Grey:")}; - for (int i=0; i < rgbNames.size(); i++) { + for (int i = 0; i < rgbNames.size(); i++) { auto label = new QLabel(rgbNames[i], this); grid->addWidget(label, i, 0); - auto slider =new QSlider(this); + auto slider = new QSlider(this); slider->setOrientation(Qt::Horizontal); slider->setRange(0, 255); @@ -1700,7 +1718,7 @@ grid->addWidget(spin, i, 2); connect(spin, SIGNAL(valueChanged(int)), - this,SLOT(spinChanged(int))); + this, SLOT(spinChanged(int))); grid->setColumnStretch(1, 1); spins_ << spin; } @@ -1715,13 +1733,14 @@ c1 = QColor(0, 0, 0); c2 = QColor(255, 255, 255); - QString sh("QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 %1, stop:1 %2);}" - "QSlider::handle:horizontal { " - "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " - "border: 1px solid #5c5c5c; " - "width: 18px;" - "margin: -2px 0;" - "border-radius: 3px;}"); + QString sh( + "QSlider::groove:horizontal {background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 %1, stop:1 %2);}" + "QSlider::handle:horizontal { " + "background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); " + "border: 1px solid #5c5c5c; " + "width: 18px;" + "margin: -2px 0;" + "border-radius: 3px;}"); sh = sh.arg(c1.name()).arg(c2.name()); @@ -1740,13 +1759,13 @@ ignoreSpin_ = false; ignoreSlider_ = false; - //adjustGrooves(-1); + // adjustGrooves(-1); } QColor GreyScaleWidget::currentColour() const { auto v = spins_[0]->value(); - return QColor(v,v,v); + return {v, v, v}; } @@ -1756,11 +1775,12 @@ // //=============================== -AlphaSlider::AlphaSlider(QWidget *parent) : QWidget(parent) +AlphaSlider::AlphaSlider(QWidget* parent) : + QWidget(parent) { setMouseTracking(true); setFixedWidth(grooveRect_.width() + 4); - setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); + setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); } void AlphaSlider::paintEvent(QPaintEvent*) @@ -1816,9 +1836,10 @@ auto pos = event->pos(); if (handlerRect_.contains(pos)) { dragStartPos_ = pos; - dragStartAlpha_= colour_.alpha(); + dragStartAlpha_ = colour_.alpha(); inDrag_ = true; - } else { + } + else { inDrag_ = false; } } @@ -1854,18 +1875,16 @@ void AlphaSlider::adjustHandler() { auto alpha = colour_.alpha(); - if (alpha >= 0 && alpha <= 255) { - auto y = grooveRect_.y() - + grooveRect_.height() - - int(grooveRect_.height() * alpha / 255.0); + if (alpha >= 0 && alpha <= 255) { + auto y = grooveRect_.y() + grooveRect_.height() - int(grooveRect_.height() * alpha / 255.0); handlerRect_.moveTop(y - handlerRect_.height() / 2); if (handlerRect_.y() < grooveRect_.y()) { handlerRect_.moveTop(grooveRect_.y()); - } else if (handlerRect_.y() + handlerRect_.height() - > grooveRect_.y() + grooveRect_.height()) { + } + else if (handlerRect_.y() + handlerRect_.height() > grooveRect_.y() + grooveRect_.height()) { handlerRect_.moveTop(grooveRect_.y() + grooveRect_.height() - handlerRect_.height()); - } + } } } @@ -1894,12 +1913,14 @@ // //=============================== -AlphaWidget::AlphaWidget(QWidget* parent, QVBoxLayout *layout) : QWidget(parent) +AlphaWidget::AlphaWidget(QWidget* parent, QVBoxLayout* layout) : + QWidget(parent) { - QVBoxLayout *grid = nullptr; + QVBoxLayout* grid = nullptr; if (layout) { grid = layout; - } else { + } + else { grid = new QVBoxLayout(this); grid->setAlignment(grid, Qt::AlignHCenter); } @@ -1964,7 +1985,7 @@ slider_->setValue(value); spin_->setValue(value); ignoreSpin_ = false; - ignoreSlider_= false; + ignoreSlider_ = false; } int AlphaWidget::currentValue() const @@ -1978,7 +1999,8 @@ // //=============================== -ColourTextWidget::ColourTextWidget(QWidget *parent) : QWidget(parent) +ColourTextWidget::ColourTextWidget(QWidget* parent) : + QWidget(parent) { auto grid = new QGridLayout(this); grid->setVerticalSpacing(2); @@ -1993,8 +2015,7 @@ auto font = QFont(); font.setPointSize(font.pointSize() - 2); - QMap labelDef = {{RgbInt, "RGB int"}, {RgbFloat, "RGB float"}, - {HslInt, "HSL int"}, {HslFloat, "HSL float"}}; + QMap labelDef = {{RgbInt, "RGB int"}, {RgbFloat, "RGB float"}, {HslInt, "HSL int"}, {HslFloat, "HSL float"}}; QMapIterator it(labelDef); while (it.hasNext()) { it.next(); @@ -2048,7 +2069,8 @@ // //====================================== -MvQColourTextControl::MvQColourTextControl(QGridLayout *grid, QWidget* parent) : QObject(parent) +MvQColourTextControl::MvQColourTextControl(QGridLayout* grid, QWidget* parent) : + QObject(parent) { // html auto label = new QLabel("HTML:", parent); @@ -2059,11 +2081,11 @@ copyTb->setIcon(QPixmap(":/editor/copy_to_clipboard.svg")); copyTb->setAutoRaise(true); connect(copyTb, SIGNAL(clicked()), - this, SLOT(copyHtml())); + this, SLOT(copyHtml())); grid->addWidget(label, 0, 0); - grid->addWidget(htmlEdit_, 0,1); - grid->addWidget(copyTb, 0,2); + grid->addWidget(htmlEdit_, 0, 1); + grid->addWidget(copyTb, 0, 2); // metview label = new QLabel("Metview:", parent); @@ -2074,17 +2096,17 @@ copyTb->setIcon(QPixmap(":/editor/copy_to_clipboard.svg")); copyTb->setAutoRaise(true); connect(copyTb, SIGNAL(clicked()), - this, SLOT(copyMv())); + this, SLOT(copyMv())); grid->addWidget(label, 1, 0); grid->addWidget(mvEdit_, 1, 1); - grid->addWidget(copyTb, 1,2); + grid->addWidget(copyTb, 1, 2); connect(htmlEdit_, SIGNAL(textChanged(QString)), - this, SLOT(htmlChanged(QString))); + this, SLOT(htmlChanged(QString))); connect(mvEdit_, SIGNAL(textChanged(QString)), - this, SLOT(mvChanged(QString))); + this, SLOT(mvChanged(QString))); } void MvQColourTextControl::copyHtml() @@ -2140,7 +2162,8 @@ } -MvQColourWheelControl::MvQColourWheelControl(QWidget* parent) : QWidget(parent) +MvQColourWheelControl::MvQColourWheelControl(QWidget* parent) : + QWidget(parent) { auto tbFont = QFont(); tbFont.setPointSize(tbFont.pointSize() - 3); @@ -2155,8 +2178,8 @@ hb->addStretch(1); #ifdef MV_UI_USE_HCL_ - QStringList names = {"HSL", "HCL"}; - for (int i=0; i < names.size(); i++) { + QStringList names = {"HSL", "HCL"}; + for (int i = 0; i < names.size(); i++) { auto tb = new QToolButton(this); tb->setText(names[i]); tb->setFont(tbFont); @@ -2181,19 +2204,19 @@ #ifdef MV_UI_USE_HCL_ connect(bGroup_, SIGNAL(buttonClicked(QAbstractButton*)), - this, SLOT(buttonSelection(QAbstractButton*))) ; + this, SLOT(buttonSelection(QAbstractButton*))); bGroup_->button(0)->setChecked(true); #else stacked_->setCurrentIndex(0); #endif - for (auto w: wheels_) { - connect(w, SIGNAL(hslSelected(int,int,int)), - this, SIGNAL(hslSelected(int,int,int))); + for (auto w : wheels_) { + connect(w, SIGNAL(hslSelected(int, int, int)), + this, SIGNAL(hslSelected(int, int, int))); connect(w, SIGNAL(colourSelected(QColor)), - this, SIGNAL(colourSelected(QColor))); + this, SIGNAL(colourSelected(QColor))); connect(w, SIGNAL(dragFinished()), this, SIGNAL(dragFinished())); @@ -2225,10 +2248,10 @@ void MvQColourWheelControl::buttonSelection(QAbstractButton* b) { - int id = bGroup_->id(b); - if (id != -1) { - stacked_->setCurrentIndex(id); - } + int id = bGroup_->id(b); + if (id != -1) { + stacked_->setCurrentIndex(id); + } } //============================== @@ -2237,10 +2260,11 @@ // //=============================== -MvQColourSelectionWidget::MvQColourSelectionWidget(QWidget* parent, bool embedded) : QWidget(parent) -{ +MvQColourSelectionWidget::MvQColourSelectionWidget(QWidget* parent, bool embedded) : + QWidget(parent) +{ auto font = QFont(); - //font.setPointSize(font.pointSize() - 1); + // font.setPointSize(font.pointSize() - 1); auto fm = QFontMetrics(font); auto hb = new QHBoxLayout(this); @@ -2254,20 +2278,20 @@ } auto spinTab = new QTabWidget(this); - spinTab->setIconSize({16,16}); + spinTab->setIconSize({16, 16}); wheel_ = new MvQColourWheelControl(this); - spinTab->addTab(wheel_, QIcon(QPixmap(":/editor/colour_wheel.svg")), ""); - spinTab->setTabToolTip(spinTab->count()-1, tr("Colour wheel")); + spinTab->addTab(wheel_, QIcon(QPixmap(":/editor/colour_wheel.svg")), ""); + spinTab->setTabToolTip(spinTab->count() - 1, tr("Colour wheel")); grid_ = new MvQColourGrid(128, this); auto gridHolderW = new QWidget(this); auto gridHolderLayout = new QVBoxLayout(gridHolderW); - gridHolderLayout->setContentsMargins(3,3,3,3); + gridHolderLayout->setContentsMargins(3, 3, 3, 3); gridHolderLayout->setSpacing(2); - gridHolderLayout->addWidget(grid_,1); - spinTab->addTab(gridHolderW, QIcon(QPixmap(":/editor/colour_grid.svg")), ""); - spinTab->setTabToolTip(spinTab->count()-1, tr("Grid of named Magics colours")); + gridHolderLayout->addWidget(grid_, 1); + spinTab->addTab(gridHolderW, QIcon(QPixmap(":/editor/colour_grid.svg")), ""); + spinTab->setTabToolTip(spinTab->count() - 1, tr("Grid of named Magics colours")); #if 0 // grid @@ -2303,7 +2327,7 @@ tab_ = new QTabWidget(this); vb->addWidget(tab_); QString t; - for(int i=0; i < 32; i++) { + for (int i = 0; i < 32; i++) { t += "A"; } tab_->setFixedWidth(MvQ::textWidth(fm, t)); @@ -2341,9 +2365,9 @@ hb->addStretch(1); - //Wheel - connect(wheel_, SIGNAL(hslSelected(int,int,int)), - this, SLOT(slotWheelChangedHsl(int,int,int))); + // Wheel + connect(wheel_, SIGNAL(hslSelected(int, int, int)), + this, SLOT(slotWheelChangedHsl(int, int, int))); connect(wheel_, SIGNAL(colourSelected(QColor)), this, SLOT(slotWheelChangedColour(QColor))); @@ -2357,8 +2381,8 @@ connect(hsl_, SIGNAL(colourChanged(QColor)), this, SLOT(hslChanged(QColor))); -// connect(hclAb_, SIGNAL(colourChanged(QColor)), -// this, SLOT(hclAbChanged(QColor))); + // connect(hclAb_, SIGNAL(colourChanged(QColor)), + // this, SLOT(hclAbChanged(QColor))); #ifdef MV_UI_USE_HCL_ connect(hclUv_, SIGNAL(colourChanged(QColor)), @@ -2368,13 +2392,13 @@ connect(greyW_, SIGNAL(colourChanged(QColor)), this, SLOT(greyChanged(QColor))); - connect(alphaW_,SIGNAL(valueChanged(int)), + connect(alphaW_, SIGNAL(valueChanged(int)), this, SLOT(alphaChanged(int))); - connect(textControl_,SIGNAL(colourChanged(QColor)), + connect(textControl_, SIGNAL(colourChanged(QColor)), this, SLOT(textChanged(QColor))); - //Notify about drag finished + // Notify about drag finished connect(wheel_, SIGNAL(dragFinished()), this, SIGNAL(dragFinished())); @@ -2383,11 +2407,11 @@ } void MvQColourSelectionWidget::setColour(QColor col) -{ +{ alphaW_->setColour(col); - //This will set all the editors in the end - //through the signal/slot mechanism + // This will set all the editors in the end + // through the signal/slot mechanism wheel_->initColour(col); } @@ -2399,15 +2423,15 @@ void MvQColourSelectionWidget::buttonSelection(QAbstractButton* b) { - int id = bGroup_->id(b); - if (id != -1) { - stacked_->setCurrentIndex(id); - } + int id = bGroup_->id(b); + if (id != -1) { + stacked_->setCurrentIndex(id); + } } void MvQColourSelectionWidget::tabIndexChanged(int /*index*/) { - //adjustWheel(currentColour_); + // adjustWheel(currentColour_); adjustRgb(currentColour_); adjustHsl(currentColour_); adjustHclUv(currentColour_); @@ -2609,7 +2633,7 @@ auto* acCopyCol = new QAction(this); acCopyCol->setText(tr("&Copy colour")); acCopyCol->setShortcut(QKeySequence(tr("Ctrl+C"))); - //acCopyCol->setIcon(QPixmap(":/desktop/editcopy.svg")); + // acCopyCol->setIcon(QPixmap(":/desktop/editcopy.svg")); addAction(acCopyCol); connect(acCopyCol, SIGNAL(triggered()), @@ -2618,17 +2642,17 @@ auto* acPasteCol = new QAction(this); acPasteCol->setText(tr("&Paste colour")); acPasteCol->setShortcut(QKeySequence(tr("Ctrl+V"))); - //acPasteCol->setIcon(QPixmap(":/desktop/editpaste.svg")); + // acPasteCol->setIcon(QPixmap(":/desktop/editpaste.svg")); addAction(acPasteCol); connect(acPasteCol, SIGNAL(triggered()), this, SLOT(slotPasteColour())); } -//void MvQColourLine::next(const Parameter&, const char* first, const char* /*second*/) +// void MvQColourLine::next(const Parameter&, const char* first, const char* /*second*/) //{ -// addColour(MvQPalette::magics(first), QString::fromStdString(param_.beautifiedName(first)), QString(first)); -//} +// addColour(MvQPalette::magics(first), QString::fromStdString(param_.beautifiedName(first)), QString(first)); +// } void MvQColourCombo::next(const std::string& name, QColor col, bool pseudo) { @@ -2646,14 +2670,14 @@ if (pix_.isNull()) { int w = iconSize().width(); int h = iconSize().height(); - pix_ = QPixmap(w, h); + pix_ = QPixmap(w, h); pix_.fill(Qt::transparent); } QPainter painter(&pix_); if (col.isValid()) { - //paint the chequered background when alpha is set + // paint the chequered background when alpha is set if (col.alpha() != 255) { MvQPalette::paintAlphaBg(&painter, QRect(0, 0, pix_.width(), pix_.height())); #if 0 @@ -2691,7 +2715,7 @@ } else { pix_.fill(Qt::transparent); - //painter.setBrush(Qt::white); + // painter.setBrush(Qt::white); painter.setPen(QPen(Qt::gray, 0., Qt::DashLine)); painter.drawRect(1, 1, pix_.width() - 2, pix_.height() - 3); } @@ -2739,7 +2763,7 @@ } } -//There can be only one custom colour +// There can be only one custom colour void MvQColourCombo::setCustomColour(QColor color, QString name, QString realName, bool setCurrent) { if (!color.isValid()) @@ -2791,17 +2815,17 @@ { if (index >= 0 && index < count()) { QString name = itemData(index).toString(); - //owner_.set(param_.name(), name.toStdString()); + // owner_.set(param_.name(), name.toStdString()); if (!MvQPalette::isPseudo(name.toStdString())) { - //if (helper_ && helper_->widget()) - // helper_->widget()->setEnabled(true); - //updateHelper(); + // if (helper_ && helper_->widget()) + // helper_->widget()->setEnabled(true); + // updateHelper(); if (broadcastChange_) emit colourSelected(name); } else { - //if (helper_ && helper_->widget()) - // helper_->widget()->setEnabled(false); + // if (helper_ && helper_->widget()) + // helper_->widget()->setEnabled(false); } } } @@ -2818,17 +2842,17 @@ } } - //This sets the current index as well + // This sets the current index as well broadcastChange_ = false; setCustomColour(MvQPalette::magics(val.toStdString()), val, val, true); broadcastChange_ = true; - //If the current index did not change the slotCurrentChanged() was - //not called, so here we need to notify the owner about the change!! - //if(colCb_->currentIndex() == currentPrev) + // If the current index did not change the slotCurrentChanged() was + // not called, so here we need to notify the owner about the change!! + // if(colCb_->currentIndex() == currentPrev) //{ // owner_.set(param_.name(),name.toStdString()); - //} + // } } #if 0 @@ -2859,7 +2883,7 @@ int index = currentIndex(); if (index != -1) { QString name = itemData(index).toString(); - QColor col = MvQPalette::magics(name.toStdString()); + QColor col = MvQPalette::magics(name.toStdString()); MvQ::toClipboard("\"" + QString::fromStdString(MvQPalette::toString(col)) + "\""); } } @@ -2900,8 +2924,8 @@ connect(colCb_, SIGNAL(colourSelected(QString)), this, SLOT(slotComboEdited(QString))); - //connect(selector_, SIGNAL(dragFinished()), - // this, SIGNAL(editConfirmed())); + // connect(selector_, SIGNAL(dragFinished()), + // this, SIGNAL(editConfirmed())); } void MvQColourWidget::initColour(QString colStr) diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQColourWidget.h metview-5.19.2/metview/src/libMvQtGui/MvQColourWidget.h --- metview-5.17.4/metview/src/libMvQtGui/MvQColourWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQColourWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -48,7 +48,13 @@ Q_OBJECT public: - enum LayoutMode {RowMode, SingleRowMode, ColumnMode, SingleColumnMode}; + enum LayoutMode + { + RowMode, + SingleRowMode, + ColumnMode, + SingleColumnMode + }; MvQCompactColourGrid(int minSize, QList items, LayoutMode layoutMode, QWidget* parent = 0); void replace(QList); int itemCount() const { return items_.count(); } @@ -129,10 +135,10 @@ public: MvQColourWheel(int minSize, QWidget* parent = 0); - virtual void initColour(QColor)=0; + virtual void initColour(QColor) = 0; public slots: - virtual void slotSetColour(QColor)=0; + virtual void slotSetColour(QColor) = 0; signals: void colourSelected(QColor colour); @@ -154,20 +160,20 @@ void mouseReleaseEvent(QMouseEvent* event); void createRing(); - virtual QConicalGradient makeRingGradient()=0; - virtual void createShape()=0; + virtual QConicalGradient makeRingGradient() = 0; + virtual void createShape() = 0; void renderRingSelector(QPainter*); void renderShapeSelector(QPainter*); - virtual DragType checkPoint(QPoint)=0; + virtual DragType checkPoint(QPoint) = 0; void dragRingSelector(QPoint); void dragShapeSelector(QPoint); virtual bool isDark() const = 0; - virtual void setHue(int)=0; - virtual void setCls(int, int)=0; - virtual bool clsToPos(QPointF&)=0; - virtual bool posToCls(QPointF, int&, int&)=0; - virtual bool projectPosToCls(QPointF, int&, int&)=0; + virtual void setHue(int) = 0; + virtual void setCls(int, int) = 0; + virtual bool clsToPos(QPointF&) = 0; + virtual bool posToCls(QPointF, int&, int&) = 0; + virtual bool projectPosToCls(QPointF, int&, int&) = 0; protected: int minSize_; @@ -263,7 +269,7 @@ void buttonSelection(QAbstractButton* b); signals: - void hslSelected(int,int,int); + void hslSelected(int, int, int); void colourSelected(QColor); void dragFinished(); @@ -347,9 +353,10 @@ { Q_OBJECT public: - ColourSpaceSliderWidget(QWidget* parent) : QWidget(parent) {} + ColourSpaceSliderWidget(QWidget* parent) : + QWidget(parent) {} virtual ~ColourSpaceSliderWidget() {} - virtual void setColour(QColor col)=0; + virtual void setColour(QColor col) = 0; protected slots: void sliderChanged(int); @@ -360,8 +367,8 @@ protected: void adjustGrooves(int ignoreIndex); - virtual void adjustGroove(int index)=0; - virtual QColor currentColour() const=0; + virtual void adjustGroove(int index) = 0; + virtual QColor currentColour() const = 0; QList spins_; QList sliders_; @@ -428,12 +435,11 @@ }; - -class AlphaSlider :public QWidget +class AlphaSlider : public QWidget { Q_OBJECT public: - AlphaSlider(QWidget *parent); + AlphaSlider(QWidget* parent); int value() const; void setColour(QColor col); @@ -469,7 +475,7 @@ { Q_OBJECT public: - AlphaWidget(QWidget* parent, QVBoxLayout *layout=nullptr); + AlphaWidget(QWidget* parent, QVBoxLayout* layout = nullptr); void setColour(QColor col); void setValue(int value); @@ -492,7 +498,7 @@ class ColourTextWidget : public QWidget { - Q_OBJECT + Q_OBJECT public: ColourTextWidget(QWidget* parent); void setColour(QColor col); @@ -504,7 +510,13 @@ void colourChanged(QColor); private: - enum LabelType {RgbInt, RgbFloat, HslInt, HslFloat}; + enum LabelType + { + RgbInt, + RgbFloat, + HslInt, + HslFloat + }; void setLabels(QColor col); bool ignoreHtmlEdit_{false}; @@ -517,8 +529,8 @@ Q_OBJECT public: MvQColourTextControl(QGridLayout*, QWidget*); - QLineEdit* htmlEdit() const {return htmlEdit_;} - QLineEdit* mvEdit() const {return mvEdit_;} + QLineEdit* htmlEdit() const { return htmlEdit_; } + QLineEdit* mvEdit() const { return mvEdit_; } void setColour(QColor); protected slots: @@ -599,12 +611,12 @@ MvQColourTextControl* textControl_{nullptr}; ColourTextWidget* text_{nullptr}; - //int wheelTabIndex_{0}; + // int wheelTabIndex_{0}; int rgbTabIndex_{0}; int hslTabIndex_{0}; int hclUvTabIndex_{0}; int greyTabIndex_{0}; - //int textTabIndex_{0}; + // int textTabIndex_{0}; }; class MvQColourCombo : public QComboBox, public PaletteScanner @@ -618,11 +630,11 @@ QString currentValue() { return QString(); } void addValue(QString) {} - //void refresh(const std::vector&); + // void refresh(const std::vector&); public slots: void changeSelection(QString); - //void slotHelperEditConfirmed(); + // void slotHelperEditConfirmed(); protected slots: void slotCurrentChanged(int); @@ -636,7 +648,7 @@ void next(const std::string&, QColor, bool); void addColour(QColor, QString, QString, bool setCurrent = false); void setCustomColour(QColor, QString, QString, bool setCurrent = false); - //void updateHelper(); + // void updateHelper(); void setColour(int, QColor); QPixmap pix_; @@ -649,7 +661,7 @@ Q_OBJECT public: - MvQColourWidget(QWidget* parent); + MvQColourWidget(QWidget* parent=nullptr); ~MvQColourWidget() {} void initColour(QString); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQComboLine.cc metview-5.19.2/metview/src/libMvQtGui/MvQComboLine.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQComboLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQComboLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ MvQComboLine::MvQComboLine(QStringList lst, QWidget* parent) : QWidget(parent), - validator_(0) + validator_(nullptr) { auto* layout = new QHBoxLayout(this); layout->setSpacing(0); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQComboLine.h metview-5.19.2/metview/src/libMvQtGui/MvQComboLine.h --- metview-5.17.4/metview/src/libMvQtGui/MvQComboLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQComboLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -50,7 +50,7 @@ void slotCurrentIndexChanged(int); protected: - //void resizeEvent(QResizeEvent*); + // void resizeEvent(QResizeEvent*); QComboBox* combo_; QLineEdit* line_; #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQConfigDialog.cc metview-5.19.2/metview/src/libMvQtGui/MvQConfigDialog.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQConfigDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQConfigDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,18 +23,18 @@ list_->setFlow(QListView::LeftToRight); list_->setViewMode(QListView::IconMode); list_->setIconSize(QSize(32, 32)); - //list_->setGridSize(QSize(48, 48)); + // list_->setGridSize(QSize(48, 48)); list_->setMovement(QListView::Static); list_->setMaximumHeight(70); list_->setSpacing(5); page_ = new QStackedWidget; /*foreach(MvQPageDefinition* p,pageLst) - { - addPage(p->widget,p->icon,p->title); - } + { + addPage(p->widget,p->icon,p->title); + } - list_->setCurrentRow(0);*/ + list_->setCurrentRow(0);*/ // Buttonbox @@ -43,22 +43,22 @@ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - //QPushButton *closePb = new QPushButton(tr("Close")); - //connect(closePb, SIGNAL(clicked()), this, SLOT(close())); + // QPushButton *closePb = new QPushButton(tr("Close")); + // connect(closePb, SIGNAL(clicked()), this, SLOT(close())); - //QHBoxLayout *horizontalLayout = new QHBoxLayout; - //horizontalLayout->addWidget(list_); - //horizontalLayout->addWidget(page_, 1); + // QHBoxLayout *horizontalLayout = new QHBoxLayout; + // horizontalLayout->addWidget(list_); + // horizontalLayout->addWidget(page_, 1); /*QHBoxLayout *buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch(1); - buttonsLayout->addWidget(closePb);*/ + buttonsLayout->addStretch(1); + buttonsLayout->addWidget(closePb);*/ auto* mainLayout = new QVBoxLayout; mainLayout->addWidget(list_); mainLayout->addWidget(page_, 1); - //mainLayout->addStretch(1); - //mainLayout->addSpacing(12); + // mainLayout->addStretch(1); + // mainLayout->addSpacing(12); mainLayout->addWidget(buttonBox); setLayout(mainLayout); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQConfigDialog.h metview-5.19.2/metview/src/libMvQtGui/MvQConfigDialog.h --- metview-5.17.4/metview/src/libMvQtGui/MvQConfigDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQConfigDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ Q_OBJECT public: - MvQConfigDialog(QString, QWidget* parent = 0); + MvQConfigDialog(QString, QWidget* parent = nullptr); public slots: void slotChangePage(QListWidgetItem* current, QListWidgetItem* previous); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQDropTarget.cc metview-5.19.2/metview/src/libMvQtGui/MvQDropTarget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQDropTarget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQDropTarget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,11 +39,11 @@ hoverGrad.setColorAt(0, QColor(254, 254, 254)); hoverGrad.setColorAt(1, QColor(240, 240, 240)); bgBrush_ = QBrush(hoverGrad); - bgPen_ = QPen(QColor(127, 154, 191)); + bgPen_ = QPen(QColor(127, 154, 191)); QFontMetrics fm(font_); - int size = fm.height(); + int size = fm.height(); decorPix_ = QPixmap::fromImage(QPixmap(":/desktop/arrow_drop_target.svg").toImage().scaled(QSize(size, size), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } @@ -51,8 +51,8 @@ { if (pix_.isNull() || target_ != target || move_ != move) { target_ = target; - move_ = move; - text_ = (move_) ? "Move to " : "Copy to "; + move_ = move; + text_ = (move_) ? "Move to " : "Copy to "; createPixmap(prefix); setPixmap(pix_); } @@ -64,7 +64,7 @@ { if (pix_.isNull() || target_ != target || text_ != text) { target_ = target; - text_ = text; + text_ = text; createPixmap(prefix); setPixmap(pix_); } @@ -92,7 +92,7 @@ painter.setPen(bgPen_); painter.setBrush(bgBrush_); - //painter.drawRoundedRect(rect,2,2); + // painter.drawRoundedRect(rect,2,2); painter.drawRect(rect.adjusted(0, 0, -1, -1)); painter.setBrush(Qt::NoBrush); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFileDialog.cc metview-5.19.2/metview/src/libMvQtGui/MvQFileDialog.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQFileDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFileDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -84,7 +84,7 @@ bool MvQFileDialogFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); - auto* fsModel = qobject_cast(sourceModel()); + auto* fsModel = qobject_cast(sourceModel()); if (!fsModel) return false; @@ -136,18 +136,18 @@ setOptions(QFileDialog::DontUseNativeDialog); - //url sidebar + // url sidebar MvQFileDialog::updateSidebar(this, startDir); - //Filter model + // Filter model auto* proxy = new MvQFileDialogFilterModel(this); setProxyModel(proxy); - //Dir + // Dir MvQFileDialog::initTargetDir(this, startDir); #ifdef METVIEW - //Icons + // Icons auto* iconProvider = new MvQFileIconProvider; setIconProvider(iconProvider); #endif @@ -174,7 +174,6 @@ #ifdef METVIEW if (char* mvDir = getenv("METVIEW_USER_DIRECTORY")) { urlLst << QUrl::fromLocalFile(QString(mvDir)); - } #endif if (char* scratchDir = getenv("SCRATCH")) { @@ -185,7 +184,7 @@ auto startUrl = QUrl::fromLocalFile(startDir); auto prevFile = MvQFileDialog::readLastGlobalSavedFile(); QFileInfo fInfo(prevFile); - auto prevUrl = QUrl::fromLocalFile((fInfo.isDir()?prevFile:fInfo.absoluteDir().path())); + auto prevUrl = QUrl::fromLocalFile((fInfo.isDir() ? prevFile : fInfo.absoluteDir().path())); if (!urlLst.contains(startUrl)) { urlLst << startUrl; @@ -239,21 +238,23 @@ if (MvQFileDialog::useTargetDirFromConfig()) { lastFile = MvQFileDialog::readLastGlobalSavedFile(); } -// MvLog().info() << MV_FN_INFO << "lastFile=" << lastFile; + // MvLog().info() << MV_FN_INFO << "lastFile=" << lastFile; if (!lastFile.isEmpty()) { QFileInfo fInfo(lastFile); if (fInfo.isDir()) { dg->setDirectory(lastFile); - } else { + } + else { dg->selectFile(lastFile); } - } else { + } + else { QString rDir; #ifdef METVIEW rDir = QString::fromStdString(metview::metviewRootDir()); #endif -// MvLog().info() << " dir=" << ((!startDir.isEmpty())?startDir:rDir); - dg->setDirectory((!startDir.isEmpty())?startDir:rDir); + // MvLog().info() << " dir=" << ((!startDir.isEmpty())?startDir:rDir); + dg->setDirectory((!startDir.isEmpty()) ? startDir : rDir); } } @@ -266,13 +267,14 @@ } if (!lastFile.isEmpty()) { QFileInfo fInfo(lastFile); - dg->setDirectory((fInfo.isDir()?lastFile:fInfo.absoluteDir().path())); - } else { + dg->setDirectory((fInfo.isDir() ? lastFile : fInfo.absoluteDir().path())); + } + else { QString rDir; #ifdef METVIEW rDir = QString::fromStdString(metview::metviewRootDir()); #endif - dg->setDirectory((!startDir.isEmpty())?startDir:rDir); + dg->setDirectory((!startDir.isEmpty()) ? startDir : rDir); } } @@ -280,7 +282,7 @@ { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV-lastSavedFileInDialog"); auto f = settings.value("fileName").toString(); -// MvLog().info() << MV_FN_INFO << "fileName=" << f; + // MvLog().info() << MV_FN_INFO << "fileName=" << f; return f; } @@ -288,8 +290,8 @@ { Q_ASSERT(dg); QStringList lst = dg->selectedFiles(); -// MvLog().info() << MV_FN_INFO << "fileName=" << lst; - if (lst.size()>0 && !lst[0].isEmpty()) { + // MvLog().info() << MV_FN_INFO << "fileName=" << lst; + if (lst.size() > 0 && !lst[0].isEmpty()) { QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "MV-lastSavedFileInDialog"); settings.clear(); settings.setValue("fileName", lst[0]); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFileDialog.h metview-5.19.2/metview/src/libMvQtGui/MvQFileDialog.h --- metview-5.17.4/metview/src/libMvQtGui/MvQFileDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFileDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ { public: MvQFileIconProvider(); - QIcon icon(const QFileInfo&) const; + QIcon icon(const QFileInfo&) const override; private: QString path_; @@ -37,15 +37,15 @@ { public: MvQFileDialogFilterModel(QObject* parent = nullptr); - bool filterAcceptsRow(int, const QModelIndex&) const; - bool lessThan(const QModelIndex&, const QModelIndex&) const; + bool filterAcceptsRow(int, const QModelIndex&) const override; + bool lessThan(const QModelIndex&, const QModelIndex&) const override; }; class MvQFileDialog : public QFileDialog { public: MvQFileDialog(QString, QString, QWidget* parent = nullptr); - ~MvQFileDialog(); + ~MvQFileDialog() override; static void updateSidebar(QFileDialog* dg, QString startDir); static void initTargetFile(QFileDialog*, QString startDir); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFileInfoLabel.cc metview-5.19.2/metview/src/libMvQtGui/MvQFileInfoLabel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQFileInfoLabel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFileInfoLabel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ { setProperty("type", "info"); - //Set size policy + // Set size policy QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); @@ -27,7 +27,7 @@ setMargin(4); setAlignment(Qt::AlignLeft | Qt::AlignVCenter); - //Other settings + // Other settings setAutoFillBackground(true); setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); } @@ -38,8 +38,8 @@ MvQFileInfo info(fileName); auto subCol = MvQTheme::subText(); - auto bold = MvQTheme::boldFileInfoTitle(); - s = MvQ::formatText("File: ", subCol, bold) + info.absoluteFilePath(); + auto bold = MvQTheme::boldFileInfoTitle(); + s = MvQ::formatText("File: ", subCol, bold) + info.absoluteFilePath(); if (!fileExtraText.isEmpty()) { s += " " + fileExtraText; @@ -70,9 +70,9 @@ QString s = buildTextLabel(fileName); s += "
"; - auto subCol = MvQTheme::subText(); + auto subCol = MvQTheme::subText(); auto accentCol = MvQTheme::accentText(); - auto bold = MvQTheme::boldFileInfoTitle(); + auto bold = MvQTheme::boldFileInfoTitle(); if (filtered) { s += MvQ::formatText("Number of filtered messages: ", subCol, bold) + @@ -95,9 +95,9 @@ QString s = buildTextLabel(fileName); s += "
"; - auto subCol = MvQTheme::subText(); + auto subCol = MvQTheme::subText(); auto accentCol = MvQTheme::accentText(); - auto bold = MvQTheme::boldFileInfoTitle(); + auto bold = MvQTheme::boldFileInfoTitle(); if (filtered) { s += MvQ::formatText("Number of filtered messages: ", subCol, bold) + @@ -125,8 +125,8 @@ void MvQFileInfoLabel::setGeopTextLabel(QString fileName, QString format, long itemNum) { auto subCol = MvQTheme::subText(); - auto bold = MvQTheme::boldFileInfoTitle(); - QString s = buildTextLabel(fileName); + auto bold = MvQTheme::boldFileInfoTitle(); + QString s = buildTextLabel(fileName); s += "
"; s += MvQ::formatText("Format: ", subCol, bold) + format + "
" + MvQ::formatText(" Total number of points: ", subCol, bold) + QString::number(itemNum); @@ -136,7 +136,7 @@ void MvQFileInfoLabel::setFlextraTextLabel(QString fileName, QString iconName, int itemNum) { auto subCol = MvQTheme::subText(); - auto bold = MvQTheme::boldFileInfoTitle(); + auto bold = MvQTheme::boldFileInfoTitle(); QString s; if (!iconName.isEmpty()) { s = MvQ::formatText("Icon: ", subCol, bold) + iconName + "
"; @@ -149,8 +149,8 @@ void MvQFileInfoLabel::setProfileTextLabel(QString fileName, int stepNum, int levNum, QString id) { auto subCol = MvQTheme::subText(); - auto bold = MvQTheme::boldFileInfoTitle(); - QString s = buildTextLabel(fileName); + auto bold = MvQTheme::boldFileInfoTitle(); + QString s = buildTextLabel(fileName); s += "
"; s += MvQ::formatText("Steps: ", subCol, bold) + QString::number(stepNum) + MvQ::formatText(" Model levels: ", subCol, bold) + QString::number(levNum) + diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFileInfoLabel.h metview-5.19.2/metview/src/libMvQtGui/MvQFileInfoLabel.h --- metview-5.17.4/metview/src/libMvQtGui/MvQFileInfoLabel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFileInfoLabel.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ class MvQFileInfoLabel : public QLabel { public: - MvQFileInfoLabel(QWidget* parent = 0); + MvQFileInfoLabel(QWidget* parent = nullptr); void setTextLabel(QString); void setGribTextLabel(QString, int, bool, int, bool); void setBufrTextLabel(QString, int, bool, int, bool); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFileListModel.cc metview-5.19.2/metview/src/libMvQtGui/MvQFileListModel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQFileListModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFileListModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,8 +14,7 @@ #include "MvQFileList.h" MvQFileListModel::MvQFileListModel(QObject* parent) : - QAbstractItemModel(parent), - data_(nullptr) + QAbstractItemModel(parent) { } @@ -56,10 +55,10 @@ QVariant MvQFileListModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || !data_) - return QVariant(); + return {}; if (index.row() < 0 || index.row() >= data_->count()) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { return data_->name(index.row()); @@ -68,18 +67,18 @@ return data_->path(index.row()); } - return QVariant(); + return {}; } QVariant MvQFileListModel::headerData(const int /*section*/, const Qt::Orientation /*orient*/, const int /*role*/) const { - return QVariant(); + return {}; } QModelIndex MvQFileListModel::index(int row, int column, const QModelIndex& parent) const { if (parent.isValid()) - return QModelIndex(); + return {}; return createIndex(row, column, (void*)nullptr); } @@ -87,7 +86,7 @@ QModelIndex MvQFileListModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } QString MvQFileListModel::indexToPath(const QModelIndex& idx) const @@ -95,7 +94,7 @@ if (data_ && idx.row() >= 0 && idx.row() < data_->count()) return data_->path(idx.row()); - return QString(); + return {}; } QModelIndex MvQFileListModel::pathToIndex(QString f) const @@ -104,7 +103,7 @@ if (f == data_->path(i)) return createIndex(i, 0); } - return QModelIndex(); + return {}; } void MvQFileListModel::slotDataAddRemoveBegin() diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFileListModel.h metview-5.19.2/metview/src/libMvQtGui/MvQFileListModel.h --- metview-5.17.4/metview/src/libMvQtGui/MvQFileListModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFileListModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,17 +18,17 @@ Q_OBJECT public: - MvQFileListModel(QObject* parent = 0); + MvQFileListModel(QObject* parent = nullptr); - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - virtual QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; - Qt::ItemFlags flags(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; + Qt::ItemFlags flags(const QModelIndex&) const override; void setFileList(MvQFileList*); @@ -39,6 +39,6 @@ void slotDataAddRemoveBegin(); void slotDataAddRemoveEnd(); -protected: - MvQFileList* data_; +private: + MvQFileList* data_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFileListWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQFileListWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQFileListWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFileListWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,9 +34,9 @@ class MvQFsFilterModel : public QSortFilterProxyModel { public: - MvQFsFilterModel(QObject* parent = 0); - bool filterAcceptsRow(int, const QModelIndex&) const; - bool lessThan(const QModelIndex&, const QModelIndex&) const; + MvQFsFilterModel(QObject* parent = nullptr); + bool filterAcceptsRow(int, const QModelIndex&) const override; + bool lessThan(const QModelIndex&, const QModelIndex&) const override; }; MvQFsFilterModel::MvQFsFilterModel(QObject* parent) : @@ -47,7 +47,7 @@ bool MvQFsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); - auto* fsModel = qobject_cast(sourceModel()); + auto* fsModel = qobject_cast(sourceModel()); if (!fsModel) return false; @@ -90,8 +90,7 @@ MvQFileListWidget::MvQFileListWidget(QWidget* parent) : - QWidget(parent), - fileLst_(0) + QWidget(parent) { auto* vb = new QVBoxLayout(this); vb->setContentsMargins(0, 0, 0, 0); @@ -103,8 +102,8 @@ auto* titleHb = new QHBoxLayout(titleBar); titleHb->setContentsMargins(0, 0, 0, 0); titleHb->addSpacing(4); - //hb->setSpacing(0); - //QLabel* titleLabel=new QLabel("" + tr("Files") + "",this); + // hb->setSpacing(0); + // QLabel* titleLabel=new QLabel("" + tr("Files") + "",this); auto* titleLabel = new QLabel(tr("Files"), this); titleLabel->setProperty("panelStyle", "2"); titleHb->addWidget(titleLabel); @@ -121,7 +120,7 @@ auto* closeTb = new QToolButton(this); closeTb->setAutoRaise(true); - //closeTb->setIcon(QPixmap(":/find/close.svg")); + // closeTb->setIcon(QPixmap(":/find/close.svg")); closeTb->setIcon(QPixmap(":/examiner/panel_close.svg")); closeTb->setToolTip(tr("Close files panel")); closeTb->setProperty("panelStyle", "1"); @@ -160,7 +159,7 @@ #endif lstModel_ = new MvQFileListModel(this); - lstView_ = new QListView(this); + lstView_ = new QListView(this); lstView_->setModel(lstModel_); vb->addWidget(lstView_); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFileListWidget.h metview-5.19.2/metview/src/libMvQtGui/MvQFileListWidget.h --- metview-5.17.4/metview/src/libMvQtGui/MvQFileListWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFileListWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,7 @@ Q_OBJECT public: - MvQFileListWidget(QWidget* parent = 0); + MvQFileListWidget(QWidget* parent = nullptr); void setFileList(MvQFileList*); void selectFile(QString, bool broadcast = true); @@ -37,12 +37,12 @@ void closePanel(bool); void clearPanel(bool); -protected: - QSplitter* splitter_; - MvQFileList* fileLst_; - MvQFileListModel* lstModel_; - QListView* lstView_; - QFileSystemModel* fsModel_; - MvQFsFilterModel* fsFilterModel_; - QTreeView* fsView_; +private: + QSplitter* splitter_{nullptr}; + MvQFileList* fileLst_{nullptr}; + MvQFileListModel* lstModel_{nullptr}; + QListView* lstView_{nullptr}; + QFileSystemModel* fsModel_{nullptr}; + MvQFsFilterModel* fsFilterModel_{nullptr}; + QTreeView* fsView_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQFilterTreeWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQFilterTreeWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQFilterTreeWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQFilterTreeWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,9 +30,9 @@ void MvQFilterTreeModel::load(QStringList headerData, QVector valueData, bool multi, int valueColumnIndex) { beginResetModel(); - multi_ = multi; - headerData_ = headerData; - valueData_ = valueData; + multi_ = multi; + headerData_ = headerData; + valueData_ = valueData; valueColumnIndex_ = valueColumnIndex; checked_.clear(); Q_ASSERT(headerData_.count() == valueData_.count()); @@ -60,7 +60,7 @@ QVariant MvQFilterTreeModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || !hasData() || index.row() >= valueData_[0].count()) { - return QVariant(); + return {}; } if (role == Qt::DisplayRole) { @@ -70,17 +70,17 @@ return (checked_[index.row()]) ? QVariant(Qt::Checked) : QVariant(Qt::Unchecked); } - return QVariant(); + return {}; } bool MvQFilterTreeModel::setData(const QModelIndex& idx, const QVariant& value, int role) { if (multi_ && hasData() && idx.column() == 0 && role == Qt::CheckStateRole) { - bool checked = (value.toInt() == Qt::Checked) ? true : false; + bool checked = (value.toInt() == Qt::Checked) ? true : false; checked_[idx.row()] = checked; Q_EMIT valueCheckedChanged(valueData_[valueColumnIndex_][idx.row()], checked); QModelIndex startIdx = index(idx.row(), 0); - QModelIndex endIdx = index(idx.row(), 0); + QModelIndex endIdx = index(idx.row(), 0); Q_EMIT dataChanged(startIdx, endIdx); return true; } @@ -97,21 +97,21 @@ return headerData_[section]; } } - return QVariant(); + return {}; } QModelIndex MvQFilterTreeModel::index(int row, int column, const QModelIndex& /*parent*/) const { if (valueData_.count() == 0 || column < 0) { - return QModelIndex(); + return {}; } - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } QModelIndex MvQFilterTreeModel::parent(const QModelIndex& /*index */) const { - return QModelIndex(); + return {}; } Qt::ItemFlags MvQFilterTreeModel::flags(const QModelIndex& index) const @@ -140,7 +140,7 @@ void MvQFilterTreeModel::queryValueChecked(QStringList& v, QVector& st) const { if (multi_ && hasData()) { - v = valueData_[valueColumnIndex_]; + v = valueData_[valueColumnIndex_]; st = checked_; } } @@ -190,7 +190,6 @@ return true; QModelIndex index; - QStringList lst; index = sourceModel()->index(sourceRow, filterColumn_, sourceParent); return sourceModel()->data(index).toString().contains(filterText_, Qt::CaseInsensitive); @@ -214,7 +213,7 @@ tree_ = new MvQTreeView(this, false); vb->addWidget(tree_); - model_ = new MvQFilterTreeModel(this); + model_ = new MvQFilterTreeModel(this); sortModel_ = new MvQFilterTreeProxyModel(this); sortModel_->setSourceModel(model_); sortModel_->setDynamicSortFilter(true); @@ -284,11 +283,11 @@ void MvQFilterTreeWidget::adjustHeight() { - //Try to set the optimal widget height to approximartely 10 rows + // Try to set the optimal widget height to approximartely 10 rows if (model_->rowCount() > 0) { QFont f; QFontMetrics fm(f); - int itemHeight = (fm.height() + 2); + int itemHeight = (fm.height() + 2); int totalHeight = itemHeight * ((model_->rowCount() >= 10) ? 10 : model_->rowCount() + 1); if (tree_->horizontalScrollBar()) { totalHeight += tree_->horizontalScrollBar()->height(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQHighlighter.cc metview-5.19.2/metview/src/libMvQtGui/MvQHighlighter.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQHighlighter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQHighlighter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -47,7 +47,7 @@ { HighlightingRule rule; - //Keywords + // Keywords QTextCharFormat keywordFormat; keywordFormat.setForeground(Qt::darkBlue); @@ -68,13 +68,13 @@ #else rule.pattern = QRegExp(pattern, Qt::CaseInsensitive); #endif - //QString s=pattern + "(?==)"; - //rule.pattern = QRegExp(s,Qt::CaseInsensitive); + // QString s=pattern + "(?==)"; + // rule.pattern = QRegExp(s,Qt::CaseInsensitive); rule.format = keywordFormat; highlightingRules.append(rule); } - //Columns + // Columns setColumns(columns); } @@ -83,7 +83,7 @@ if (columns.count() == 0) return; - //Here we should remove the previous settings!!!!!! + // Here we should remove the previous settings!!!!!! HighlightingRule rule; @@ -101,8 +101,8 @@ #else rule.pattern = QRegExp(pattern, Qt::CaseInsensitive); #endif - //QString s=pattern + "(?==)"; - //rule.pattern = QRegExp(s,Qt::CaseInsensitive); + // QString s=pattern + "(?==)"; + // rule.pattern = QRegExp(s,Qt::CaseInsensitive); rule.format = columnFormat; highlightingRules.append(rule); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyDialog.cc metview-5.19.2/metview/src/libMvQtGui/MvQKeyDialog.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -53,7 +53,7 @@ layout->addLayout(hb); profList_ = new QListWidget(this); - //profList_->setAlternatingRowColors(true); + // profList_->setAlternatingRowColors(true); hb->addWidget(profList_); auto* vb = new QVBoxLayout; @@ -103,7 +103,7 @@ { for (auto it : manager_->data()) { MvKeyProfile* prof = it; - auto* item = new QListWidgetItem(QString(prof->name().c_str())); + auto* item = new QListWidgetItem(QString(prof->name().c_str())); if (it->systemProfile()) { item->setIcon(MvQTheme::logo()); @@ -118,7 +118,7 @@ void MvQKeyProfileDialog::slotUpdate() { - disconnect(profList_, SIGNAL(currentRowChanged(int)), this, 0); + disconnect(profList_, SIGNAL(currentRowChanged(int)), this, nullptr); int row = profList_->currentRow(); profList_->clear(); init(row); @@ -146,7 +146,7 @@ void MvQKeyProfileDialog::slotAddProfile() { - bool ok; + bool ok = false; QString text = QInputDialog::getText(this, tr("Add profile"), tr("New profile name:"), QLineEdit::Normal, "", &ok); @@ -181,8 +181,8 @@ int ret = msgBox.exec(); switch (ret) { - case QMessageBox::Yes: { //keyModel_->profileIsAboutToChange(); - //keyModel_->setKeyProfile(0); + case QMessageBox::Yes: { // keyModel_->profileIsAboutToChange(); + // keyModel_->setKeyProfile(0); manager_->deleteProfile(index); @@ -195,13 +195,9 @@ profList_->setCurrentRow(index); else profList_->setCurrentRow(profList_->count() - 1); - //slotSelectProfile(0); + // slotSelectProfile(0); } break; - case QMessageBox::Cancel: - // Cancel was clicked - break; default: - // should never be reached break; } } @@ -212,7 +208,7 @@ if (index < 0 || index >= static_cast(manager_->data().size()) || manager_->data().size() == 0) return; - bool ok; + bool ok = false; QString text = QInputDialog::getText(this, tr("Duplicate profile"), tr("New profile name:"), QLineEdit::Normal, "", &ok); @@ -235,7 +231,7 @@ if (manager_->data().at(index)->systemProfile()) return; - bool ok; + bool ok = false; QString text = QInputDialog::getText(this, tr("Rename profile"), tr("Profile name:"), QLineEdit::Normal, "", &ok); @@ -260,18 +256,18 @@ manager_(manager), allKey_(allKeys) { - //setWindowTitle(title); + // setWindowTitle(title); auto* layout = new QVBoxLayout; setLayout(layout); - //Profiles + // Profiles auto* profHb = new QHBoxLayout; layout->addLayout(profHb); auto* label = new QLabel(tr("Profile:"), this); - profCombo_ = new QComboBox(this); + profCombo_ = new QComboBox(this); label->setBuddy(profCombo_); profHb->addWidget(label); profHb->addWidget(profCombo_); @@ -339,7 +335,7 @@ keyTree_ = new QTreeView(this); keyTree_->setRootIsDecorated(false); keyTree_->setObjectName("keyTree"); - //keyTree_->setAlternatingRowColors(true); + // keyTree_->setAlternatingRowColors(true); keyTree_->setAllColumnsShowFocus(true); keyTree_->setDragEnabled(true); keyTree_->setAcceptDrops(true); @@ -363,7 +359,7 @@ auto* comboLayout = new QHBoxLayout; auto* comboLabel = new QLabel(tr(" Available keys in category: "), this); - allKeyCombo_ = new QComboBox(this); + allKeyCombo_ = new QComboBox(this); comboLabel->setBuddy(allKeyCombo_); comboLayout->addWidget(comboLabel); @@ -381,7 +377,7 @@ allKeyModel_ = new MvQKeyModel(MvQKeyModel::AllKeysMode, this); allKeyTree_->setModel(allKeyModel_); - //button to add key to profile + // button to add key to profile addKeyToProfTb_ = new QPushButton(this); addKeyToProfTb_->setText(tr(" Add selected key to profile")); @@ -396,7 +392,7 @@ QColor col(10, 150, 10); pal.setColor(QPalette::Active, QPalette::Button, col); pal.setColor(QPalette::Active, QPalette::ButtonText, QColor(Qt::white)); - //addKeyToProfTb_->setPalette(pal); + // addKeyToProfTb_->setPalette(pal); vbAllKey->addWidget(addKeyToProfTb_); @@ -462,12 +458,12 @@ { QString currentProfName = profCombo_->currentText(); - disconnect(profCombo_, SIGNAL(currentIndexChanged(int)), 0, 0); + disconnect(profCombo_, SIGNAL(currentIndexChanged(int)), nullptr, nullptr); - //Clear the profile list + // Clear the profile list profCombo_->clear(); - int i = 0; + int i = 0; int index = -1; for (auto it : manager_->data()) { profCombo_->addItem(QString(it->name().c_str())); @@ -510,8 +506,8 @@ if (prof->systemProfile()) { keyTree_->setEnabled(false); - //keyTree_->setDragEnabled(false); - //keyTree_->setAcceptDrops(false); + // keyTree_->setDragEnabled(false); + // keyTree_->setAcceptDrops(false); addKeyTb_->setEnabled(false); deleteKeyTb_->setEnabled(false); moveUpKeyTb_->setEnabled(false); @@ -521,8 +517,8 @@ } else { keyTree_->setEnabled(true); - //keyTree_->setDragEnabled(true); - //keyTree_->setAcceptDrops(true); + // keyTree_->setDragEnabled(true); + // keyTree_->setAcceptDrops(true); if (!manager_->predefinedKeysOnly()) { addKeyTb_->setEnabled(true); } @@ -538,7 +534,7 @@ { MvKeyProfile* prof = keyModel_->profile(); - if (prof == 0) //|| !index.isValid()) + if (prof == nullptr) //|| !index.isValid()) return; auto* key = new MvKey; @@ -557,9 +553,9 @@ void MvQKeyListPage::slotDeleteKey() { MvKeyProfile* prof = keyModel_->profile(); - QModelIndex index = keyTree_->currentIndex(); + QModelIndex index = keyTree_->currentIndex(); - if (prof == 0 || !index.isValid()) + if (prof == nullptr || !index.isValid()) return; QString str = tr("Are you sure that you want to delete key: "); @@ -580,11 +576,7 @@ prof->deleteKey(index.row()); keyModel_->setKeyProfile(prof); } break; - case QMessageBox::Cancel: - // Cancel was clicked - break; default: - // should never be reached break; } } @@ -592,9 +584,9 @@ void MvQKeyListPage::slotMoveUpKey() { MvKeyProfile* prof = keyModel_->profile(); - QModelIndex index = keyTree_->currentIndex(); + QModelIndex index = keyTree_->currentIndex(); - if (prof == 0 || !index.isValid()) + if (prof == nullptr || !index.isValid()) return; if (index.row() > 0) { @@ -608,9 +600,9 @@ void MvQKeyListPage::slotMoveDownKey() { MvKeyProfile* prof = keyModel_->profile(); - QModelIndex index = keyTree_->currentIndex(); + QModelIndex index = keyTree_->currentIndex(); - if (prof == 0 || !index.isValid()) + if (prof == nullptr || !index.isValid()) return; if (index.row() < static_cast(prof->size()) - 1) { @@ -624,15 +616,15 @@ void MvQKeyListPage::slotEditKey() { MvKeyProfile* prof = keyModel_->profile(); - QModelIndex index = keyTree_->currentIndex(); + QModelIndex index = keyTree_->currentIndex(); - if (prof == 0 || !index.isValid()) + if (prof == nullptr || !index.isValid()) return; if (index.row() <= static_cast(prof->size()) - 1) { MvQKeyEditDialog edit(prof->at(index.row())); if (edit.exec() == QDialog::Accepted) { - //Not too efficient + // Not too efficient keyModel_->profileIsAboutToChange(); keyModel_->setKeyProfile(prof); } @@ -647,9 +639,9 @@ void MvQKeyListPage::slotAddKeyToProf() { MvKeyProfile* allProf = allKeyModel_->profile(); - QModelIndex index = allKeyTree_->currentIndex(); + QModelIndex index = allKeyTree_->currentIndex(); - if (allProf == 0 || !index.isValid()) + if (allProf == nullptr || !index.isValid()) return; MvKeyProfile* prof = keyModel_->profile(); @@ -717,7 +709,7 @@ inManager_ = new MvQKeyManager(type); inManager_->loadProfiles(); - QLabel* label; + QLabel* label = nullptr; auto* layout = new QVBoxLayout; setLayout(layout); @@ -771,7 +763,7 @@ void MvQKeyImportPage::init() { - //QStringList items; + // QStringList items; for (auto prof : inManager_->data()) { auto* item = new QListWidgetItem(profList_); item->setText(QString(prof->name().c_str())); @@ -813,7 +805,7 @@ if (profList_->item(i)->flags() & Qt::ItemIsUserCheckable && profList_->item(i)->checkState() == Qt::Checked) { MvKeyProfile* prof = inManager_->data().at(i); - std::string name = prof->name(); + std::string name = prof->name(); QString qsName(name.c_str()); qsName = manager_->findUniqueProfileName(qsName); @@ -864,22 +856,22 @@ grid->addWidget(descLe_, row, 1); row++; - //colourCb_=0; + // colourCb_=0; for (auto it = key->metaData().begin(); it != key->metaData().end(); it++) { - QWidget* w; + QWidget* w = nullptr; grid->addWidget(new QLabel(QString::fromStdString(it->first) + ":", this), row, 0); /*if(it->first == "colour" && !colourCb_) - { - colourCb_ = new QComboBox; - colourCb_->setStandardColors(); - colourCb_->setColorDialogEnabled(true); - colourCb_->setCurrentColor(QColor(QString::fromStdString(it->second))); - w=colourCb_; - } - else - {*/ + { + colourCb_ = new QComboBox; + colourCb_->setStandardColors(); + colourCb_->setColorDialogEnabled(true); + colourCb_->setCurrentColor(QColor(QString::fromStdString(it->second))); + w=colourCb_; + } + else + {*/ metaLe_[it->first] = new QLineEdit(QString::fromStdString(it->second), this); if (!key->editable()) { metaLe_[it->first]->setReadOnly(true); @@ -914,9 +906,9 @@ } /*if(colourCb_) - { - key_->setMetaData("colour",colourCb_->currentColor().name().toStdString()); - }*/ + { + key_->setMetaData("colour",colourCb_->currentColor().name().toStdString()); + }*/ QDialog::accept(); } @@ -1015,7 +1007,7 @@ resize(QSize(750, 540)); } - int ival; + int ival = 0; if (settings.value("currentRow").isNull()) { ival = 1; } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyDialog.h metview-5.19.2/metview/src/libMvQtGui/MvQKeyDialog.h --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -40,8 +40,8 @@ Q_OBJECT public: - MvQKeyProfileDialog(QString title, MvQKeyManager*, int, QWidget* parent = 0); - virtual ~MvQKeyProfileDialog() {} + MvQKeyProfileDialog(QString title, MvQKeyManager*, int, QWidget* parent = nullptr); + ~MvQKeyProfileDialog() override = default; public slots: void slotUpdate(); @@ -55,13 +55,13 @@ void dataChanged(); void currentProfileChanged(int); -protected: +private: void init(int); - QListWidget* profList_; - MvQKeyManager* manager_; - QPushButton* deletePb_; - QPushButton* renamePb_; + QListWidget* profList_{nullptr}; + MvQKeyManager* manager_{nullptr}; + QPushButton* deletePb_{nullptr}; + QPushButton* renamePb_{nullptr}; }; class MvQKeyListPage : public QWidget @@ -69,8 +69,8 @@ Q_OBJECT public: - MvQKeyListPage(QString title, MvQKeyManager*, QList, QWidget* parent = 0); - virtual ~MvQKeyListPage() {} + MvQKeyListPage(QString title, MvQKeyManager*, QList, QWidget* parent = nullptr); + ~MvQKeyListPage() override = default; void init(); void setAllKeyList(QList); @@ -90,27 +90,27 @@ void slotAddKeyToProf(); void slotSelectAllKeyGroup(int); -protected: - QTreeView* keyTree_; - MvQKeyModel* keyModel_; +private: + QTreeView* keyTree_{nullptr}; + MvQKeyModel* keyModel_{nullptr}; - MvQKeyManager* manager_; + MvQKeyManager* manager_{nullptr}; - QSplitter* splitter_; - QWidget* allKeyWidget_; + QSplitter* splitter_{nullptr}; + QWidget* allKeyWidget_{nullptr}; QList allKey_; - MvQKeyModel* allKeyModel_; - QTreeView* allKeyTree_; - QComboBox* allKeyCombo_; - - QComboBox* profCombo_; - - QToolButton* addKeyTb_; - QToolButton* deleteKeyTb_; - QToolButton* moveUpKeyTb_; - QToolButton* moveDownKeyTb_; - QToolButton* editKeyTb_; - QPushButton* addKeyToProfTb_; + MvQKeyModel* allKeyModel_{nullptr}; + QTreeView* allKeyTree_{nullptr}; + QComboBox* allKeyCombo_{nullptr}; + + QComboBox* profCombo_{nullptr}; + + QToolButton* addKeyTb_{nullptr}; + QToolButton* deleteKeyTb_{nullptr}; + QToolButton* moveUpKeyTb_{nullptr}; + QToolButton* moveDownKeyTb_{nullptr}; + QToolButton* editKeyTb_{nullptr}; + QPushButton* addKeyToProfTb_{nullptr}; }; class MvQKeyEditDialog : public QDialog @@ -118,18 +118,18 @@ Q_OBJECT public: - MvQKeyEditDialog(MvKey*, QWidget* parent = 0); - ~MvQKeyEditDialog(); + MvQKeyEditDialog(MvKey*, QWidget* parent = nullptr); + ~MvQKeyEditDialog() override; public slots: - void accept(); - void reject(); + void accept() override; + void reject() override; -protected: - MvKey* key_; - QLineEdit* nameLe_; - QLineEdit* shortLe_; - QLineEdit* descLe_; +private: + MvKey* key_{nullptr}; + QLineEdit* nameLe_{nullptr}; + QLineEdit* shortLe_{nullptr}; + QLineEdit* descLe_{nullptr}; QMap metaLe_; }; @@ -139,8 +139,8 @@ Q_OBJECT public: - MvQKeyImportPage(QString title, MvQKeyManager*, QWidget* parent = 0); - virtual ~MvQKeyImportPage(); + MvQKeyImportPage(QString title, MvQKeyManager*, QWidget* parent = nullptr); + ~MvQKeyImportPage() override; public slots: void slotSelectAll(); @@ -150,12 +150,12 @@ signals: void dataChanged(); -protected: +private: void init(); - QListWidget* profList_; - MvQKeyManager* manager_; - MvQKeyManager* inManager_; + QListWidget* profList_{nullptr}; + MvQKeyManager* manager_{nullptr}; + MvQKeyManager* inManager_{nullptr}; }; @@ -165,19 +165,19 @@ public: MvQKeyDialog(QString title, MvQKeyManager::KeyType, - MvQKeyManager*, int, QList, QWidget* parent = 0); - virtual ~MvQKeyDialog(); + MvQKeyManager*, int, QList, QWidget* parent = nullptr); + ~MvQKeyDialog() override; public slots: - void accept(); - void reject(); + void accept() override; + void reject() override; -protected: +private: void writeSettings(); void readSettings(); - MvQKeyManager* manager_; - MvQKeyProfileDialog* profPage_; - MvQKeyListPage* keyPage_; + MvQKeyManager* manager_{nullptr}; + MvQKeyProfileDialog* profPage_{nullptr}; + MvQKeyListPage* keyPage_{nullptr}; QString settingsName_; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyFilterModel.cc metview-5.19.2/metview/src/libMvQtGui/MvQKeyFilterModel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyFilterModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyFilterModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,9 +34,9 @@ if (index.column() == 2) { MvQCheckBoxCombo* combo = new MvQCheckBoxCombo(parent); - //connect(combo,SIGNAL(toggled(bool)),this,SLOT(setFilter(bool))); - //connect(bAdvd_,SIGNAL(toggled(bool)), wt, SLOT(setVisible(bool))); - //connect(bAdvd_,SIGNAL(clicked(bool)), this, SLOT(slotAdvancedButton(bool))); + // connect(combo,SIGNAL(toggled(bool)),this,SLOT(setFilter(bool))); + // connect(bAdvd_,SIGNAL(toggled(bool)), wt, SLOT(setVisible(bool))); + // connect(bAdvd_,SIGNAL(clicked(bool)), this, SLOT(slotAdvancedButton(bool))); connect(combo, SIGNAL(editingFinished()), this, SLOT(commmitAndCloseEditor())); @@ -53,8 +53,8 @@ if (index.column() == 2) { MvQCheckBoxCombo* combo = static_cast(editor); - //Get current value from model - QStringList values = index.data(Qt::UserRole).toStringList(); + // Get current value from model + QStringList values = index.data(Qt::UserRole).toStringList(); QStringList filters = index.data(Qt::DisplayRole).toString().split("/", QString::SkipEmptyParts); if (filters.contains(tr("Any"))) { @@ -97,7 +97,7 @@ if (index.column() == 2) { MvQCheckBoxCombo* combo = static_cast(editor); - //Get filters + // Get filters QStringList filters = combo->getSelectedValues(); if (filters.size() == combo->count()) { QString value("Any"); @@ -136,8 +136,8 @@ setupKeyFilter(); - //Reset the model (views will be notified) - //reset(); NOT in Qt 5 + // Reset the model (views will be notified) + // reset(); NOT in Qt 5 beginResetModel(); endResetModel(); } @@ -171,7 +171,7 @@ if (!isDataSet()) return 0; - //Non-root + // Non-root if (!parent.isValid()) { return profile_->size(); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyMimeData.cc metview-5.19.2/metview/src/libMvQtGui/MvQKeyMimeData.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyMimeData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyMimeData.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,5 +21,5 @@ QStringList MvQKeyMimeData::formats() const { - return QStringList("metview/mvkey"); //QMimeData::formats(); + return QStringList("metview/mvkey"); // QMimeData::formats(); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyMimeData.h metview-5.19.2/metview/src/libMvQtGui/MvQKeyMimeData.h --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyMimeData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyMimeData.h 2023-07-15 08:28:47.000000000 +0000 @@ -44,6 +44,7 @@ return {}; } #endif - const QAbstractItemModel* model_; +private: + const QAbstractItemModel* model_{nullptr}; QMap keys_; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyModel.cc metview-5.19.2/metview/src/libMvQtGui/MvQKeyModel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,18 +20,13 @@ MvQKeyModel::MvQKeyModel(MvKeyProfile* profile, DisplayMode mode, QObject* parent) : QAbstractItemModel(parent), profile_(profile), - mode_(mode), - editable_(false), - pixmaps_(0) + mode_(mode) { } MvQKeyModel::MvQKeyModel(DisplayMode mode, QObject* parent) : QAbstractItemModel(parent), - profile_(0), - mode_(mode), - editable_(false), - pixmaps_(0) + mode_(mode) { } @@ -63,7 +58,7 @@ int MvQKeyModel::rowCount(const QModelIndex& index) const { - if (!index.isValid() && profile_ != 0) { + if (!index.isValid() && profile_ != nullptr) { return profile_->size(); } else { @@ -106,7 +101,7 @@ QVariant MvQKeyModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { - return QVariant(); + return {}; } if (role == Qt::DisplayRole || role == Qt::ToolTipRole) { @@ -114,12 +109,12 @@ return label(key, index.row(), index.column(), role); } else if (role == Qt::DecorationRole && index.column() == 0 && pixmaps_) { - MvKey* key = profile_->at(index.row()); + MvKey* key = profile_->at(index.row()); QString name = QString::fromStdString(key->name()); return pixmaps_->pixmap(name).toImage().scaled(QSize(24, 24), Qt::KeepAspectRatio, Qt::SmoothTransformation); } - return QVariant(); + return {}; } bool MvQKeyModel::setData(const QModelIndex& index, const QVariant& value, int role) @@ -135,7 +130,7 @@ if (index.column() == 1) { MvKey* key = profile_->at(index.row()); - QString s = value.toString(); + QString s = value.toString(); if (s.isEmpty() == false) { key->setName(s.toStdString()); emit dataChanged(index, index); @@ -144,7 +139,7 @@ } else if (index.column() == 2) { MvKey* key = profile_->at(index.row()); - QString s = value.toString(); + QString s = value.toString(); if (s.isEmpty() == false) { key->setShortName(s.toStdString()); emit dataChanged(index, index); @@ -168,7 +163,7 @@ case 2: return tr("Header name"); default: - return QVariant(); + return {}; } } else if (mode_ == AllKeysMode) { @@ -178,11 +173,11 @@ case 1: return tr("Description"); default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } QString MvQKeyModel::label(MvKey* key, const int row, const int column, int role) const @@ -196,7 +191,7 @@ case 2: return QString::fromStdString(key->shortName()); default: - return QString(); + return {}; } } else if (mode_ == AllKeysMode) { @@ -205,8 +200,8 @@ return QString::fromStdString(key->name()); case 1: { QString desc = QString::fromStdString(key->description()); - QString sec = QString::fromStdString(key->metaData("section")); - QString s = desc; + QString sec = QString::fromStdString(key->metaData("section")); + QString s = desc; if (!sec.isEmpty()) { QString centre = QString::fromStdString(key->metaData("centre")); s += " (Section: " + sec; @@ -218,7 +213,7 @@ return s; } default: - return QString(); + return {}; } } else if (mode_ == ShortNameMode) { @@ -226,7 +221,7 @@ if (role == Qt::ToolTipRole) { std::string cntStr = key->metaData("path_count"); if (!cntStr.empty()) - return QString(); + return {}; else return QString::fromStdString(key->name()); } @@ -234,23 +229,23 @@ return QString::fromStdString(key->shortName()); } else { - return QString(); + return {}; } } - return QString(); + return {}; } QModelIndex MvQKeyModel::index(int row, int column, const QModelIndex& /*parent*/) const { - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } QModelIndex MvQKeyModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } @@ -289,9 +284,9 @@ Qt::DropActions MvQKeyModel::supportedDropActions() const { /*if(!editable_) - return Qt::IgnoreAction; - else - return Qt::CopyAction;*/ + return Qt::IgnoreAction; + else + return Qt::CopyAction;*/ return Qt::CopyAction; } @@ -324,7 +319,7 @@ bool MvQKeyModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int /*column*/, const QModelIndex& parent) { - //if(!editable_) + // if(!editable_) // return false; if (!profile_) @@ -341,7 +336,7 @@ if (!keyData || keyData->keys().isEmpty()) return false; - //Dnd from self --> move rows + // Dnd from self --> move rows if (keyData->model() == this) { int targetRow = row; if (row != -1) @@ -363,7 +358,7 @@ endResetModel(); } - //Dnd from another model --> insert new row + // Dnd from another model --> insert new row else { beginResetModel(); QMapIterator it(keyData->keys()); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyModel.h metview-5.19.2/metview/src/libMvQtGui/MvQKeyModel.h --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,15 +34,15 @@ MvQKeyModel(DisplayMode mode, QObject* parent); MvQKeyModel(MvKeyProfile*, DisplayMode mode, QObject* parent); - virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; - virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - virtual bool setData(const QModelIndex&, const QVariant&, int role = Qt::EditRole); - virtual QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex&, const QVariant&, int role = Qt::EditRole) override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void profileIsAboutToChange(); MvKeyProfile* profile() { return profile_; } @@ -50,14 +50,14 @@ void moveUp(const QModelIndex& index); void moveDown(const QModelIndex& index); - Qt::ItemFlags flags(const QModelIndex&) const; + Qt::ItemFlags flags(const QModelIndex&) const override; - Qt::DropActions supportedDropActions() const; - QStringList mimeTypes() const; - QMimeData* mimeData(const QModelIndexList&) const; + Qt::DropActions supportedDropActions() const override; + QStringList mimeTypes() const override; + QMimeData* mimeData(const QModelIndexList&) const override; bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, - const QModelIndex& parent); + const QModelIndex& parent) override; void setEditable(bool b) { editable_ = b; } bool editable() { return editable_; } @@ -69,8 +69,8 @@ virtual QString label(MvKey*, const int, const int, int) const; void moveRow(int, int); - MvKeyProfile* profile_; - DisplayMode mode_; - bool editable_; - MvQPixmapCache* pixmaps_; + MvKeyProfile* profile_{nullptr}; + DisplayMode mode_{ProfileContentsMode}; + bool editable_{false}; + MvQPixmapCache* pixmaps_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyProfileModel.cc metview-5.19.2/metview/src/libMvQtGui/MvQKeyProfileModel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyProfileModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyProfileModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "MvKeyProfile.h" MvQKeyProfileSortFilterModel::MvQKeyProfileSortFilterModel(QObject* parent) : - QSortFilterProxyModel(parent), - filterMode_(StringFilter) + QSortFilterProxyModel(parent) { } @@ -78,7 +77,7 @@ void MvQKeyProfileSortFilterModel::setColumnFilter(QStringList lst) { filterMode_ = StringFilter; - filterStr_ = lst; + filterStr_ = lst; filterPos_.clear(); invalidate(); } @@ -93,9 +92,7 @@ MvQKeyProfileModel::MvQKeyProfileModel(QObject* parent) : - QAbstractItemModel(parent), - profile_(nullptr), - shadeFirstColumn_(false) + QAbstractItemModel(parent) { possibleStringKeys_ << "shortName" << "name" @@ -216,7 +213,7 @@ if (!isDataSet()) return 0; - return profile_->size(); + return static_cast(profile_->size()); } int MvQKeyProfileModel::rowCount(const QModelIndex& index) const @@ -235,7 +232,7 @@ QVariant MvQKeyProfileModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { - return QVariant(); + return {}; } else if (role == Qt::UserRole) { if (messageFilterStatus_[index.row()] == true) @@ -248,15 +245,15 @@ return Qt::AlignRight; else - return QVariant(); + return {}; } else if (role == Qt::DisplayRole) { - int row = index.row(); + int row = index.row(); int column = index.column(); if (!isDataSet() || row < 0 || row >= profile_->valueNum() || column < 0 || column >= static_cast(profile_->size())) { - return QVariant(); + return {}; } MvKey* key = profile_->at(column); @@ -276,7 +273,7 @@ return kVal; } else { - int v; + int v = 0; if (key->isConstant()) v = key->intConstantValue(); else @@ -293,7 +290,7 @@ } } else if (key->valueType() == MvKey::LongType) { - long long v; + long long v = 0; if (key->isConstant()) v = static_cast(key->longConstantValue()); else @@ -329,7 +326,7 @@ } else if (role == Qt::BackgroundRole) { - return QVariant(); + return {}; } else if (role == SubTextRole) { @@ -337,12 +334,12 @@ } else if (role == SortRole) { - int row = index.row(); + int row = index.row(); int column = index.column(); if (!isDataSet() || row < 0 || row >= profile_->valueNum() || column < 0 || column >= static_cast(profile_->size())) { - return QVariant(); + return {}; } MvKey* key = profile_->at(column); @@ -389,14 +386,14 @@ return key->doubleValue()[row]; } - return QVariant(); + return {}; } else if (role == ErrorRole) { return profile_->isErrorRow(index.row()); } - return QVariant(); + return {}; } @@ -409,7 +406,7 @@ } if (section < 0 || section >= static_cast(profile_->size())) { - return QVariant(); + return {}; } if (role == Qt::DisplayRole) { @@ -444,7 +441,7 @@ return "ecCodes key: \n" + QString::fromStdString(profile_->at(section)->name()); } - //BUFR + // BUFR QString sec(profile_->at(section)->metaData("section").c_str()); if (!sec.isEmpty()) { QString centre(profile_->at(section)->metaData("centre").c_str()); @@ -459,65 +456,17 @@ return desc; } } - return desc; -#if 0 - if(profile_->at(section)->name().find("MV_") !=std::string::npos) - { - //QString str="MV key: " + QString(profile_->at(section)->name().c_str()) + "\n"; - //str += desc; - return desc; - } - - //GRIB - if(desc.isEmpty()) - { - QString str("ecCodes key: \n"); - str.append(profile_->at(section)->name().c_str()); - return str; - } - - //BUFR - QString sec(profile_->at(section)->metaData("section").c_str()); - if(!sec.isEmpty()) - { - QString centre(profile_->at(section)->metaData("centre").c_str()); - QString s=desc + "\n(Section: " + sec; - if(!centre.isEmpty()) - { - s+=" Centre: " + centre; - } - s+=")"; - return s; - } - else - { - return desc; - } -#endif } -#if 0 - else if(role == Qt::DecorationRole) - { - QString str(profile_->at(section)->name().c_str()); - if(filter_.contains(str)) - { - return QIcon(QString::fromUtf8(":/examiner/keyFilter")); - } - else - return QVariant(); - } -#endif - - return QVariant(); + return {}; } QString MvQKeyProfileModel::label(const int row, const int column) const { if (!isDataSet() || row < 0 || row >= profile_->valueNum() || column < 0 || column >= static_cast(profile_->size())) { - return QString(); + return {}; } MvKey* key = profile_->at(column); @@ -542,16 +491,16 @@ return QString::number(key->doubleValue()[row]); } - return QString(); + return {}; } QModelIndex MvQKeyProfileModel::index(int row, int column, const QModelIndex& /*parent*/) const { if (!isDataSet()) { - return QModelIndex(); + return {}; } - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } @@ -652,7 +601,7 @@ emit keysInserted(keyData->keys().values(), parent.column()); - //Dnd from a key model --> insert new column + // Dnd from a key model --> insert new column if (keyData->model() != this) { #if 0 QMapIterator it(keyData->keys()); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyProfileModel.h metview-5.19.2/metview/src/libMvQtGui/MvQKeyProfileModel.h --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyProfileModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyProfileModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,26 +19,26 @@ #include "MvKeyProfile.h" -typedef QMap MvQKeyFilter; +using MvQKeyFilter = QMap; class MvQKeyProfileSortFilterModel : public QSortFilterProxyModel { public: - MvQKeyProfileSortFilterModel(QObject* parent = 0); + MvQKeyProfileSortFilterModel(QObject* parent = nullptr); void setColumnFilter(QStringList); void setColumnFilter(QList); - //bool hasColumnFilter() const; + // bool hasColumnFilter() const; -protected: +private: enum FilterMode { StringFilter, PositionFilter }; - //bool lessThan ( const QModelIndex &, const QModelIndex &) const; - bool filterAcceptsColumn(int source_column, const QModelIndex& source_parent) const; + // bool lessThan ( const QModelIndex &, const QModelIndex &) const; + bool filterAcceptsColumn(int source_column, const QModelIndex& source_parent) const override; - FilterMode filterMode_; + FilterMode filterMode_{StringFilter}; QStringList filterStr_; QList filterPos_; }; @@ -49,23 +49,23 @@ public: MvQKeyProfileModel(QObject* parent); - ~MvQKeyProfileModel(); + ~MvQKeyProfileModel() override; enum CustomItemRole { - SortRole = Qt::UserRole + 1, - ErrorRole = Qt::UserRole + 2, + SortRole = Qt::UserRole + 1, + ErrorRole = Qt::UserRole + 2, SubTextRole = Qt::UserRole + 3 }; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void keyProfileIsAboutToChange(); void keyProfileChangeFinished(); @@ -78,13 +78,13 @@ MvQKeyFilter keyFilter() const { return filter_; } void setKeyFilter(MvQKeyFilter); - Qt::ItemFlags flags(const QModelIndex&) const; - Qt::DropActions supportedDropActions() const; - QStringList mimeTypes() const; - QMimeData* mimeData(const QModelIndexList&) const; + Qt::ItemFlags flags(const QModelIndex&) const override; + Qt::DropActions supportedDropActions() const override; + QStringList mimeTypes() const override; + QMimeData* mimeData(const QModelIndexList&) const override; bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, - const QModelIndex& parent); + const QModelIndex& parent) override; void setShadeFirstColumn(bool b) { shadeFirstColumn_ = b; } signals: @@ -96,9 +96,9 @@ void loadKeyFilter(); bool isDataSet() const; - MvKeyProfile* profile_; + MvKeyProfile* profile_{nullptr}; MvQKeyFilter filter_; QList messageFilterStatus_; - bool shadeFirstColumn_; + bool shadeFirstColumn_{false}; QStringList possibleStringKeys_; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyProfileTree.cc metview-5.19.2/metview/src/libMvQtGui/MvQKeyProfileTree.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyProfileTree.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyProfileTree.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,25 +23,21 @@ MvQKeyProfileTree::MvQKeyProfileTree(QWidget* parent) : - MvQTreeView(parent, true), - messageModel_(0), - messageSortModel_(0), - editable_(false), - predefinedKeysOnly_(false) + MvQTreeView(parent, true) { setObjectName("messageTree"); setSortingEnabled(true); sortByColumn(0, Qt::AscendingOrder); setAlternatingRowColors(true); setAllColumnsShowFocus(true); - //setActvatedByKeyNavigation(true); + // setActvatedByKeyNavigation(true); setAcceptDrops(true); setDragDropMode(QAbstractItemView::DropOnly); setRootIsDecorated(false); setStyleId(0); - //Set header ContextMenuPolicy + // Set header ContextMenuPolicy header()->setContextMenuPolicy(Qt::CustomContextMenu); connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), @@ -54,10 +50,10 @@ void MvQKeyProfileTree::setModels(MvQKeyProfileModel* messageModel, MvQKeyProfileSortFilterModel* sortModel) { - Q_ASSERT(messageModel_ == 0); - Q_ASSERT(messageSortModel_ == 0); + Q_ASSERT(messageModel_ == nullptr); + Q_ASSERT(messageSortModel_ == nullptr); - messageModel_ = messageModel; + messageModel_ = messageModel; messageSortModel_ = sortModel; Q_ASSERT(messageModel_); @@ -96,19 +92,19 @@ return; MvKeyProfile* prof = messageModel_->keyProfile(); - if (prof == 0 || section >= static_cast(prof->size())) + if (prof == nullptr || section >= static_cast(prof->size())) return; QList actions; - //Inser new key + // Inser new key auto* actionInsertBefore = new QAction(this); actionInsertBefore->setObjectName(QString::fromUtf8("actionInsertBefore")); actionInsertBefore->setText(tr("Insert key before")); actions.append(actionInsertBefore); - //Check if users can define keys + // Check if users can define keys if (predefinedKeysOnly_) { actionInsertBefore->setEnabled(false); } @@ -118,12 +114,12 @@ actionInsertAfter->setText(tr("Insert key after")); actions.append(actionInsertAfter); - //Check if users can define keys + // Check if users can define keys if (predefinedKeysOnly_) { actionInsertAfter->setEnabled(false); } - //Edit + // Edit #ifdef METVIEW_EXPERIMENTAL bool keyEditable = prof->at(section)->editable(); @@ -132,7 +128,7 @@ actionEdit = new QAction(this); actionEdit->setObjectName(QString::fromUtf8("actionEdit")); actionEdit->setText(tr("Edit key")); - //actionRename->setShortcut(tr("Ctrl+L")); + // actionRename->setShortcut(tr("Ctrl+L")); actions.append(actionEdit); } #endif @@ -140,14 +136,14 @@ auto* actionDelete = new QAction(this); actionDelete->setObjectName(QString::fromUtf8("actionDelete")); actionDelete->setText(tr("Delete key")); - //actionDelete->setShortcut(tr("Ctrl+D")); + // actionDelete->setShortcut(tr("Ctrl+D")); actions.append(actionDelete); - //Rename + // Rename auto* actionRename = new QAction(this); actionRename->setObjectName(QString::fromUtf8("actionRename")); actionRename->setText(tr("Rename header")); - //actionRename->setShortcut(tr("Ctrl+L")); + // actionRename->setShortcut(tr("Ctrl+L")); actions.append(actionRename); if (actions.count() > 0) { @@ -185,13 +181,13 @@ int oriRow = messageSortModel_->mapToSource(currentIndex()).row(); if (keyDialog.exec() == QDialog::Accepted) { - //Get the current profile from the model. + // Get the current profile from the model. MvKeyProfile* prof = messageModel_->keyProfile(); if (column >= 0 && column < static_cast(prof->size())) { messageModel_->keyProfileIsAboutToChange(); - //insertKey always inserts before + // insertKey always inserts before if (before) prof->insertKey(column, key); else @@ -215,7 +211,7 @@ messageModel_->keyProfileIsAboutToChange(); - //Get the current profile from the model. + // Get the current profile from the model. MvKeyProfile* prof = messageModel_->keyProfile(); foreach (MvKey* k, keyLst) { @@ -235,11 +231,11 @@ return; MvKeyProfile* prof = messageModel_->keyProfile(); - if (prof == 0 || column < 0 || column >= static_cast(prof->size())) + if (prof == nullptr || column < 0 || column >= static_cast(prof->size())) return; MvKeyProfile* nProf = prof->clone(); - std::string name = prof->at(column)->name(); + std::string name = prof->at(column)->name(); MvQKeyEditDialog edit(nProf->at(column)); if (edit.exec() == QDialog::Accepted) { @@ -266,8 +262,8 @@ if (column < 0 || column >= static_cast(prof->size())) return; - bool ok; - QString text = QInputDialog::getText(0, + bool ok = false; + QString text = QInputDialog::getText(nullptr, tr("Rename header"), tr("New name:"), QLineEdit::Normal, prof->at(column)->shortName().c_str(), &ok); @@ -311,11 +307,7 @@ messageModel_->keyProfileChangeFinished(); emit profileChanged(false, oriRow); } break; - case QMessageBox::Cancel: - // Cancel was clicked - break; default: - // should never be reached break; } } @@ -330,27 +322,27 @@ if (oldVisualIndex >= 0 && oldVisualIndex < static_cast(prof->size()) && newVisualIndex >= 0 && newVisualIndex < static_cast(prof->size()) && oldVisualIndex != newVisualIndex) { - //for(int i=0; i < messageTree_->header()->count(); i++) + // for(int i=0; i < messageTree_->header()->count(); i++) // qDebug() << "header: (" << i << ") " << messageTree_->header()->logicalIndex(i); prof->reposition(oldVisualIndex, newVisualIndex); - //We need it because + // We need it because // - QHeaderView::reset() does not initialize the - // the logicalindeces - // - But if the column count changes the - // logicalIndeces are reinitialized + // the logicalindeces + // - But if the column count changes the + // logicalIndeces are reinitialized int oriRow = messageSortModel_->mapToSource(currentIndex()).row(); messageModel_->reloadKeyProfile(); - //messageModel_->keyProfileIsAboutToChange(); - //messageModel_->setKeyProfile(0); + // messageModel_->keyProfileIsAboutToChange(); + // messageModel_->setKeyProfile(0); - //messageModel_->keyProfileIsAboutToChange(); - //messageModel_->setKeyProfile(prof); + // messageModel_->keyProfileIsAboutToChange(); + // messageModel_->setKeyProfile(prof); for (int i = 0; i < messageModel_->columnCount() - 1; i++) { resizeColumnToContents(i); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQKeyProfileTree.h metview-5.19.2/metview/src/libMvQtGui/MvQKeyProfileTree.h --- metview-5.17.4/metview/src/libMvQtGui/MvQKeyProfileTree.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQKeyProfileTree.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,9 @@ public: MvQKeyProfileTree(QWidget* parent); - ~MvQKeyProfileTree() {} + ~MvQKeyProfileTree() override = default; void setEditable(bool); - bool editable() { return editable_; } + bool editable() const { return editable_; } void setPredefinedKeysOnly(bool b) { predefinedKeysOnly_ = b; } void setModels(MvQKeyProfileModel* messageModel, MvQKeyProfileSortFilterModel* sortModel); @@ -36,21 +36,21 @@ void slotMessageTreeColumnMoved(int, int, int); protected slots: - void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); + void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override; void insertKeys(QList, int); signals: void profileChanged(bool reaload, int selectedRow); void selectionChanged(const QModelIndex&); -protected: +private: void insertMessageTreeColumn(int, bool before); void renameMessageTreeHeader(int); void deleteMessageTreeColumn(int); void editMessageTreeHeader(int); - MvQKeyProfileModel* messageModel_; - MvQKeyProfileSortFilterModel* messageSortModel_; - bool editable_; - bool predefinedKeysOnly_; + MvQKeyProfileModel* messageModel_{nullptr}; + MvQKeyProfileSortFilterModel* messageSortModel_{nullptr}; + bool editable_{false}; + bool predefinedKeysOnly_{false}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQLineEdit.cc metview-5.19.2/metview/src/libMvQtGui/MvQLineEdit.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQLineEdit.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQLineEdit.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include MvQLineEdit::MvQLineEdit(QWidget* parent) : - QLineEdit(parent), - iconLabel_(nullptr) + QLineEdit(parent) { #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) setClearButtonEnabled(true); @@ -30,7 +29,7 @@ void MvQLineEdit::adjustSize() { - int frame = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); + int frame = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); QSize tbSize = clearTb_->sizeHint(); setStyleSheet(QString("QLineEdit { padding-right: %1px; } ").arg(tbSize.width() + frame + 1)); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQLineEdit.h metview-5.19.2/metview/src/libMvQtGui/MvQLineEdit.h --- metview-5.17.4/metview/src/libMvQtGui/MvQLineEdit.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQLineEdit.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,6 +33,6 @@ void adjustSize(); void resizeEvent(QResizeEvent*); - QToolButton* clearTb_; - QLabel* iconLabel_; + QToolButton* clearTb_{nullptr}; + QLabel* iconLabel_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQLogBrowser.cc metview-5.19.2/metview/src/libMvQtGui/MvQLogBrowser.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQLogBrowser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQLogBrowser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,19 +27,19 @@ setProperty("mvStyle", "log"); if (!okBg.isValid()) { - okBg = MvQTheme::colour("log", "ok_bg"); + okBg = MvQTheme::colour("log", "ok_bg"); titleFg = MvQTheme::colour("log", "title"); errorFg = MvQTheme::colour("log", "error"); } if (keys_.isEmpty()) { keys_[QString::fromStdString(GuiLog::commandKey())] = "Command"; - keys_[QString::fromStdString(GuiLog::methodKey())] = "Method"; + keys_[QString::fromStdString(GuiLog::methodKey())] = "Method"; keys_[QString::fromStdString(GuiLog::requestKey())] = "Request"; } OutputToGui::setObserver(this); - //Set css for the text formatting + // Set css for the text formatting QString cssDoc = "table {margin-top: 1px; margin-bottom: 1px; background-color: " + okBg.name() + ";} \ td {padding-left: 4px; padding-top: 2px; padding-bottom: 2px;} div {width: 50px; background-color: " + @@ -76,7 +76,7 @@ else if (t == metview::ErrorType) { QString p; if (!hasOutput_) { - p = "
" + creTitle("Output") + " "; + p = "
" + creTitle("Output") + " "; hasOutput_ = true; } txt = p + "
= 2); - desc = lst[0]; - cmd = lst[1]; + desc = lst[0]; + cmd = lst[1]; cmdTitle = it.value(); return; } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQLogBrowser.h metview-5.19.2/metview/src/libMvQtGui/MvQLogBrowser.h --- metview-5.17.4/metview/src/libMvQtGui/MvQLogBrowser.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQLogBrowser.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,11 +20,11 @@ Q_OBJECT public: - MvQLogBrowser(QWidget* parent = 0); - ~MvQLogBrowser(); + MvQLogBrowser(QWidget* parent = nullptr); + ~MvQLogBrowser() override; void update(); - void update(const std::string&, metview::Type); + void update(const std::string&, metview::Type) override; protected slots: void slotTextChanged(); @@ -32,8 +32,8 @@ private: void parseTask(QString, QString&, QString&, QString&); QString creTitle(QString); - //QString creIconCell(int iconSize,QString iconPath); - //QString creError(); + // QString creIconCell(int iconSize,QString iconPath); + // QString creError(); bool hasOutput_; static QMap keys_; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQLogPanel.cc metview-5.19.2/metview/src/libMvQtGui/MvQLogPanel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQLogPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQLogPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,29 +27,29 @@ logLayout->setContentsMargins(0, 0, 0, 0); logLayout->setSpacing(1); - //logPanel_=new QWidget(this); + // logPanel_=new QWidget(this); setMinimumHeight(110); setLayout(logLayout); auto headerW = new MvQPanel(this); - auto* hb = new QHBoxLayout(headerW); + auto* hb = new QHBoxLayout(headerW); hb->setContentsMargins(0, 0, 0, 0); logLayout->addWidget(headerW); - //Label + // Label auto* label = new QLabel(tr("Log"), this); label->setProperty("panelStyle", "2"); hb->addSpacing(4); hb->addWidget(label, 1); - //Clear if new message button + // Clear if new message button clearMsgCb_ = new QCheckBox(tr("Clear log on new message")); clearMsgCb_->setCheckState(Qt::Checked); clearMsgCb_->setProperty("panelStyle", "2"); hb->addWidget(clearMsgCb_); - //Clear button + // Clear button auto* clearTb = new QToolButton(this); clearTb->setAutoRaise(true); clearTb->setIcon(QPixmap(":/examiner/wastebasket_orange.svg")); @@ -64,7 +64,7 @@ closeTb->setProperty("panelStyle", "2"); hb->addWidget(closeTb); - //Log browser + // Log browser logBrowser_ = new MvQLogBrowser(this); logLayout->addWidget(logBrowser_); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQLogPanel.h metview-5.19.2/metview/src/libMvQtGui/MvQLogPanel.h --- metview-5.17.4/metview/src/libMvQtGui/MvQLogPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQLogPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ { Q_OBJECT public: - explicit MvQLogPanel(QWidget* parent = 0); + explicit MvQLogPanel(QWidget* parent = nullptr); void setClearOptionButtonText(QString txt); void setViewAction(QAction*); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQMailDialog.cc metview-5.19.2/metview/src/libMvQtGui/MvQMailDialog.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQMailDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQMailDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ vb->addLayout(grid); auto* label = new QLabel(tr("To:"), this); - toLe_ = new QLineEdit(this); + toLe_ = new QLineEdit(this); grid->addWidget(label, 0, 0); grid->addWidget(toLe_, 0, 1); @@ -49,7 +49,7 @@ grid->addWidget(label, 1, 0); grid->addWidget(ccLe_, 1, 1); - label = new QLabel(tr("Subject:"), this); + label = new QLabel(tr("Subject:"), this); subjLe_ = new QLineEdit(tr("Metview icons"), this); grid->addWidget(label, 2, 0); grid->addWidget(subjLe_, 2, 1); @@ -102,7 +102,7 @@ bb->addButton(new QPushButton(QPixmap(":/mail/mail_send.svg"), tr("Send"), this), QDialogButtonBox::AcceptRole); - //bb->addButton(QDialogButtonBox::Ok); + // bb->addButton(QDialogButtonBox::Ok); bb->addButton(QDialogButtonBox::Cancel); vb->addWidget(bb); @@ -199,7 +199,7 @@ toLe_->setText(settings.value("to").toString()); ccLe_->setText(settings.value("cc").toString()); toLst_ = settings.value("toLst").toStringList(); - if (toLe_->completer() == 0) { + if (toLe_->completer() == nullptr) { if (toLst_.count() > 0) toLe_->setCompleter(new QCompleter(toLst_, this)); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQMainWindow.cc metview-5.19.2/metview/src/libMvQtGui/MvQMainWindow.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQMainWindow.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQMainWindow.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,27 +38,27 @@ // menuBar()->setNativeMenuBar(false); //#endif - menuName_[FileMenu] = "&File"; - menuName_[ShareMenu] = "Sha&re"; - menuName_[ViewMenu] = "&View"; - menuName_[NavigateMenu] = "&Go"; + menuName_[FileMenu] = "&File"; + menuName_[ShareMenu] = "Sha&re"; + menuName_[ViewMenu] = "&View"; + menuName_[NavigateMenu] = "&Go"; menuName_[BookmarksMenu] = "&Bookmarks"; - menuName_[HistoryMenu] = "&History"; - menuName_[SettingsMenu] = "&Settings"; - menuName_[ToolsMenu] = "&Tools"; + menuName_[HistoryMenu] = "&History"; + menuName_[SettingsMenu] = "&Settings"; + menuName_[ToolsMenu] = "&Tools"; menuName_[AnimationMenu] = "&Animation"; - menuName_[ZoomMenu] = "&Zoom"; - menuName_[ProfilesMenu] = "&Profiles"; + menuName_[ZoomMenu] = "&Zoom"; + menuName_[ProfilesMenu] = "&Profiles"; menuName_[SelectionMenu] = "&Selection"; - menuName_[HelpMenu] = "&Help"; - menuName_[EditMenu] = "&Edit"; - menuName_[StepMenu] = "&Steps"; - menuName_[FilterMenu] = "Fi<er"; - menuName_[EditorMenu] = "&Editors"; + menuName_[HelpMenu] = "&Help"; + menuName_[EditMenu] = "&Edit"; + menuName_[StepMenu] = "&Steps"; + menuName_[FilterMenu] = "Fi<er"; + menuName_[EditorMenu] = "&Editors"; menuOrder_ << FileMenu << ShareMenu << EditMenu << ViewMenu << NavigateMenu << BookmarksMenu << HistoryMenu << EditorMenu << ProfilesMenu << FilterMenu << AnimationMenu << StepMenu << ZoomMenu << SelectionMenu << ToolsMenu << SettingsMenu << HelpMenu << ProgressBarMenu; - //setIconSize(QSize(20,20)); + // setIconSize(QSize(20,20)); } void MvQMainWindow::setupMenus(MenuItemMap items, MenuOption option) @@ -67,10 +67,10 @@ QMap menus; foreach (MenuType type, menuOrder_) { - QMenu* menu = 0; - QToolBar* toolBar = 0; + QMenu* menu = 0; + QToolBar* toolBar = nullptr; - QString menuName = menuName_[type]; + QString menuName = menuName_[type]; QString menuObjName = menuName; menuObjName.remove("&"); menuObjName += " Menu"; @@ -98,10 +98,10 @@ if (toolBar) toolBars[type] = toolBar; - //Add further actions + // Add further actions if (type == FileMenu && menu && isActionPresent(items[type], "actionQuit") == false) { - //Quit + // Quit auto* actionQuit = new QAction(this); actionQuit->setObjectName(QString::fromUtf8("actionQuit")); actionQuit->setText(tr("&Quit")); @@ -110,23 +110,23 @@ menu->addSeparator(); menu->addAction(actionQuit); - //Exit slot + // Exit slot connect(actionQuit, SIGNAL(triggered()), this, SLOT(close())); } else if (type == HelpMenu && menu) { - //About Qt + // About Qt /*QAction* actionQt = new QAction(this); - actionQt->setObjectName(QString::fromUtf8("About Qt")); - actionQt->setText(tr("About &Qt")); + actionQt->setObjectName(QString::fromUtf8("About Qt")); + actionQt->setText(tr("About &Qt")); - menu->addAction(actionQt); + menu->addAction(actionQt); - connect(actionQt,SIGNAL(triggered()),qApp,SLOT(aboutQt()));*/ + connect(actionQt,SIGNAL(triggered()),qApp,SLOT(aboutQt()));*/ } } - //toolBarViewActions + // toolBarViewActions if (menus.contains(ViewMenu)) { QMenu* vm = menus[ViewMenu]; @@ -147,7 +147,7 @@ QMenu* MvQMainWindow::createMenu(QString name, QString objectName, QList items) { if (isMenuNeeded(items) == false) - return 0; + return nullptr; return createMenu(name, objectName); } @@ -164,7 +164,7 @@ Qt::ToolBarAreas allowedAreas) { if (isToolBarNeeded(items) == false) - return 0; + return nullptr; return createToolBar(name, objectName, allowedAreas); } @@ -217,7 +217,7 @@ subMenu->addAction(action); } else if (item->targets().testFlag(MvQMenuItem::MenuTarget)) { - subMenu = nullptr; + subMenu = nullptr; auto* action = static_cast(item->object()); if (menu) menu->addAction(action); @@ -242,15 +242,15 @@ toolBar->addWidget(w); } /*else if(type == "QWidget" || type == "QPushButton" || type == "QToolButton" || - type == "MvQZoomStackWidget" || type == "QComboBox" || - type == "QLabel" || type == "QLineEdit" || type == "MvQSceneComboBox") - { - if(item->targets().testFlag(MvQMenuItem::ToolBarTarget)) - { - QWidget* w=static_cast(item->object()); - if(toolBar) toolBar->addWidget(w); - } - }*/ + type == "MvQZoomStackWidget" || type == "QComboBox" || + type == "QLabel" || type == "QLineEdit" || type == "MvQSceneComboBox") + { + if(item->targets().testFlag(MvQMenuItem::ToolBarTarget)) + { + QWidget* w=static_cast(item->object()); + if(toolBar) toolBar->addWidget(w); + } + }*/ } } bool MvQMainWindow::isToolBarItemPresent(QList items) @@ -270,7 +270,7 @@ return item; } } - return 0; + return nullptr; } bool MvQMainWindow::isActionPresent(QList items, QString name) @@ -312,7 +312,7 @@ } } - return 0; + return nullptr; } bool MvQMainWindow::isToolBarNeeded(QList items) @@ -337,7 +337,7 @@ } } - return 0; + return nullptr; } QRect MvQMainWindow::screenGeometry() @@ -412,7 +412,7 @@ break; case QuitAction: action->setObjectName(QString::fromUtf8("actionQuit")); - //icon.addPixmap(QPixmap(QString::fromUtf8(":/window/exit.svg")), QIcon::Normal, QIcon::Off); + // icon.addPixmap(QPixmap(QString::fromUtf8(":/window/exit.svg")), QIcon::Normal, QIcon::Off); action->setText("&Quit"); action->setShortcut(tr("Ctrl+Q")); break; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQMainWindow.h metview-5.19.2/metview/src/libMvQtGui/MvQMainWindow.h --- metview-5.17.4/metview/src/libMvQtGui/MvQMainWindow.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQMainWindow.h 2023-07-15 08:28:47.000000000 +0000 @@ -61,14 +61,14 @@ ToolBarOnlyOption }; - typedef QMap > MenuItemMap; + using MenuItemMap = QMap>; - MvQMainWindow(QWidget* parent = 0); + MvQMainWindow(QWidget* parent = nullptr); QRect screenGeometry(); void setInitialSize(int, int); static QAction* createAction(ActionType, QObject*); - static QAction* createAction(QString, QString, QString, QObject* parent = 0); - static QAction* createSeparator(QObject* parent = 0); + static QAction* createAction(QString, QString, QString, QObject* parent = nullptr); + static QAction* createSeparator(QObject* parent = nullptr); void setMovableToolBars(bool b) { movableToolBars_ = b; } void setAppIcon(QString name); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQMemoryWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQMemoryWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQMemoryWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQMemoryWidget.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -/***************************** LICENSE START *********************************** - - Copyright 2012 ECMWF and INPE. This software is distributed under the terms - of the Apache License version 2.0. In applying this license, ECMWF does not - waive the privileges and immunities granted to it by virtue of its status as - an Intergovernmental Organization or submit itself to any jurisdiction. - - ***************************** LICENSE END *************************************/ - -#include "MvQMemoryWidget.h" - -#include -#include -#include - -#include -#include -//#include -//#include - -MvQMemoryWidget::MvQMemoryWidget(QWidget* parent) : - QLabel(parent) -{ - //memInfoFile_= new QFile("/proc/meminfo"); - pid_ = getpid(); -} - -void MvQMemoryWidget::slotRefresh() -{ - //struct rusage usage; - - //getrusage(RUSAGE_SELF,&usage); - - //maxrss_=usage.ru_maxrss; - - QFile memInfoFile("/proc/meminfo"); - - if (memInfoFile.open(QIODevice::ReadOnly | QIODevice::Text) == false) { - return; - } - - int findItems = 0; - - QTextStream in(&memInfoFile); - QString line = in.readLine(); - while (!line.isNull() && findItems < 2) { - if (parseMemInfoLine("MemTotal", line, memTotal_, memTotalUnit_)) { - findItems++; - } - else if (parseMemInfoLine("MemFree", line, memFree_, memFreeUnit_)) { - findItems++; - } - line = in.readLine(); - } - - memInfoFile.close(); - - - QFile procFile("/proc/" + QString::number(pid_) + "/statm"); - - if (procFile.open(QIODevice::ReadOnly | QIODevice::Text) == false) { - return; - } - - QTextStream inProc(&procFile); - QStringList lst = inProc.readLine().split(" ", -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - Qt::SkipEmptyParts); -#else - QString::SkipEmptyParts); -#endif - - maxrss_ = lst[1].toLong(); - - procFile.close(); - - - QString txt = QString::number(maxrss_) + " " + QString::number(memTotal_) + " " + - QString::number(memFree_); - - - setText(txt); -} - -bool MvQMemoryWidget::parseMemInfoLine(QString key, QString line, long& value, QString& unit) -{ - QStringList lst = line.split(":"); - if (lst.count() == 2 && lst[0].compare(key) == 0) { - QStringList nLst = lst[1].simplified().split(" "); - if (nLst.count() == 2) { - value = nLst[0].toLong(); - unit = nLst[1]; - return true; - } - } - return false; -} - -long MvQMemoryWidget::memTotal() -{ - return memTotal_; -} - -long MvQMemoryWidget::memFree() -{ - return memFree_; -} - -long MvQMemoryWidget::maxrss() -{ - return maxrss_; -} - - -#if 0 -struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ - long ru_maxrss; /* maximum resident set size */ - long ru_ixrss; /* integral shared memory size */ - long ru_idrss; /* integral unshared data size */ - long ru_isrss; /* integral unshared stack size */ - long ru_minflt; /* page reclaims */ - long ru_majflt; /* page faults */ - long ru_nswap; /* swaps */ - long ru_inblock; /* block input operations */ - long ru_oublock; /* block output operations */ - long ru_msgsnd; /* messages sent */ - long ru_msgrcv; /* messages received */ - long ru_nsignals; /* signals received */ - long ru_nvcsw; /* voluntary context switches */ - long ru_nivcsw; /* involuntary context switches */ -}; - -#endif diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQMemoryWidget.h metview-5.19.2/metview/src/libMvQtGui/MvQMemoryWidget.h --- metview-5.17.4/metview/src/libMvQtGui/MvQMemoryWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQMemoryWidget.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/***************************** LICENSE START *********************************** - - Copyright 2012 ECMWF and INPE. This software is distributed under the terms - of the Apache License version 2.0. In applying this license, ECMWF does not - waive the privileges and immunities granted to it by virtue of its status as - an Intergovernmental Organization or submit itself to any jurisdiction. - - ***************************** LICENSE END *************************************/ - -#pragma once - -#include -#include - - -class MvQMemoryWidget : public QLabel -{ - Q_OBJECT - -public: - MvQMemoryWidget(QWidget* parent = 0); - - long memTotal(); - long memFree(); - long maxrss(); - -public slots: - void slotRefresh(); - -protected: - bool parseMemInfoLine(QString, QString, long&, QString&); - - int pid_; - QFile memInfoFile_; - long memTotal_; - long memFree_; - QString memTotalUnit_; - QString memFreeUnit_; - long maxrss_; -}; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQMenuItem.h metview-5.19.2/metview/src/libMvQtGui/MvQMenuItem.h --- metview-5.17.4/metview/src/libMvQtGui/MvQMenuItem.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQMenuItem.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,8 @@ public: enum Target { - NoTarget = 0x0, - MenuTarget = 0x1, + NoTarget = 0x0, + MenuTarget = 0x1, ToolBarTarget = 0x2, SubMenuTarget = 0x4 }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQOdbDataWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQOdbDataWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQOdbDataWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQOdbDataWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ #include #include -#include +#include #include "MvOdb.h" @@ -36,16 +36,16 @@ data_ = 0; maxChunkSizeInMb_ = 60; - chunkSize_ = 0; - chunkNum_ = 0; - currentChunk_ = -1; - dataInitialised_ = false; + chunkSize_ = 0; + chunkNum_ = 0; + currentChunk_ = -1; + dataInitialised_ = false; auto* dataLayout = new QVBoxLayout; dataLayout->setContentsMargins(0, 0, 0, 0); setLayout(dataLayout); - //Data tree + // Data tree dataModel_ = new MvQOdbDataModel(); dataSortModel_ = new QSortFilterProxyModel; @@ -60,7 +60,7 @@ dataTree_->setRootIsDecorated(false); dataTree_->setSortingEnabled(false); //! - //Set header ContextMenuPolicy + // Set header ContextMenuPolicy dataTree_->header()->setContextMenuPolicy(Qt::CustomContextMenu); connect(dataTree_->header(), SIGNAL(customContextMenuRequested(const QPoint&)), @@ -72,7 +72,7 @@ dataLayout->addWidget(dataTree_); - //Control at the bottom + // Control at the bottom auto* hb = new QHBoxLayout; dataLayout->addLayout(hb); @@ -137,7 +137,7 @@ delete data_; } -//Should be called only once +// Should be called only once bool MvQOdbDataWidget::init(QString path) { std::vector v; @@ -154,22 +154,22 @@ } else { delete data_; - data_ = 0; + data_ = nullptr; } } dataInitialised_ = true; - //Create a data object!! + // Create a data object!! data_ = MvOdbFactory::make(path.toStdString()); if (data_ && data_->version() != MvAbstractOdb::VersionNew) { delete data_; - data_ = 0; + data_ = nullptr; return false; } if (!data_) { - //metaTab_->setTabEnabled(4,false); + // metaTab_->setTabEnabled(4,false); return false; } else { @@ -187,21 +187,21 @@ return; loadStarted(); - //statusMessageLabel_->setText(tr("Counting number of rows in ODB data ...")); + // statusMessageLabel_->setText(tr("Counting number of rows in ODB data ...")); - int rowNum = data_->rowNum(); + int rowNum = data_->rowNum(); int totSizeInMb = -1; if (maxChunkSizeInMb_ > 0) { totSizeInMb = data_->totalSizeInMb(); } - //statusMessageLabel_->clear(); + // statusMessageLabel_->clear(); chunkSize_ = 0; - chunkNum_ = 0; + chunkNum_ = 0; if (totSizeInMb > maxChunkSizeInMb_ && maxChunkSizeInMb_ > 0) { int r = static_cast(rowNum) * (static_cast(maxChunkSizeInMb_) / static_cast(totSizeInMb)); - int chunk; + int chunk = 0; if (r < 1000) chunk = 500; @@ -221,13 +221,13 @@ chunk = 200000; chunkSize_ = chunk; - chunkNum_ = rowNum / chunkSize_ + ((rowNum % chunkSize_ == 0) ? 0 : 1); + chunkNum_ = rowNum / chunkSize_ + ((rowNum % chunkSize_ == 0) ? 0 : 1); - //Disable sorting in tree + // Disable sorting in tree dataTree_->setSortingEnabled(false); dataModel_->dataIsAboutToChange(); - initCurrentChunk(); //set currentChunk_ to 0 + initCurrentChunk(); // set currentChunk_ to 0 data_->setChunkSize(chunkSize_); data_->setCurrentChunk(currentChunk_); dataModel_->setBaseData(data_); @@ -314,7 +314,7 @@ if (oriVal != currentChunk_) { loadStarted(); - //statusMessageLabel_->setText(tr("Reading ODB data ...")); + // statusMessageLabel_->setText(tr("Reading ODB data ...")); dataModel_->dataIsAboutToChange(); data_->setCurrentChunk(currentChunk_); @@ -325,8 +325,8 @@ } loadFinished(); - //statusMessageLabel_->setText(tr("Reading ODB data ...")); - //statusMessageLabel_->clear(); + // statusMessageLabel_->setText(tr("Reading ODB data ...")); + // statusMessageLabel_->clear(); } } @@ -384,7 +384,7 @@ { QModelIndex index = dataSortModel_->mapFromSource(dataModel_->index(row, 0)); dataTree_->setCurrentIndex(index); - //dataTree_->scrollTo() + // dataTree_->scrollTo() } void MvQOdbDataWidget::slotRowSelected(const QModelIndex& index) @@ -436,9 +436,9 @@ } } - QAction* actionHide = 0; + QAction* actionHide = nullptr; - //Thic column can be hidden only if there are other visible columns as well + // Thic column can be hidden only if there are other visible columns as well if (!dataTree_->isColumnHidden(section) && numOfShown > 1) { actionHide = new QAction(this); actionHide->setText(tr("Hide ") + "\'" + dataModel_->headerData(section, Qt::Horizontal, Qt::DisplayRole).toString() + "\'"); @@ -447,16 +447,16 @@ menu.addSeparator(); } - //Show columns + // Show columns QMap actionShow; for (int i = 0; i < dataModel_->columnCount(); i++) { if (dataTree_->isColumnHidden(i)) { - //SubMenu if there are too amny items + // SubMenu if there are too amny items if (actionShow.count() == 6) { menu.addMenu(&subMenu); } - auto* ac = new QAction(this); + auto* ac = new QAction(this); QString acText = dataModel_->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(); if (actionShow.count() >= 6) { ac->setText(acText); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQOdbDataWidget.h metview-5.19.2/metview/src/libMvQtGui/MvQOdbDataWidget.h --- metview-5.17.4/metview/src/libMvQtGui/MvQOdbDataWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQOdbDataWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -71,9 +71,9 @@ MvAbstractOdb* data_; bool useChunks_; - int maxChunkSizeInMb_; //max size in Mb of one chunk - int chunkSize_; //current number of row in a chunk - int chunkNum_; //nuber of chunks + int maxChunkSizeInMb_; // max size in Mb of one chunk + int chunkSize_; // current number of row in a chunk + int chunkNum_; // nuber of chunks int currentChunk_; QLabel* rowNumLabel_; QLabel* chunkSizeLabel_; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQOdbModel.cc metview-5.19.2/metview/src/libMvQtGui/MvQOdbModel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQOdbModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQOdbModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ { data_ = data; - //Reset the model (views will be notified) + // Reset the model (views will be notified) beginResetModel(); endResetModel(); } @@ -32,11 +32,11 @@ int MvQOdbVarModel::rowCount(const QModelIndex& parent) const { - //Non-root + // Non-root if (parent.isValid()) { return 0; } - //Root + // Root else { return data_.count(); } @@ -46,7 +46,7 @@ QVariant MvQOdbVarModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || role != Qt::DisplayRole) { - return QVariant(); + return {}; } MvQOdbVar* var = data_[index.row()]; @@ -75,14 +75,14 @@ } default: - return QString(); + return {}; } } QModelIndex MvQOdbVarModel::index(int row, int column, const QModelIndex&) const { if (data_.count() == 0 || row < 0 || column < 0) { - return QModelIndex(); + return {}; } return createIndex(row, column, static_cast(nullptr)); @@ -91,7 +91,7 @@ QModelIndex MvQOdbVarModel::parent(const QModelIndex&) const { - return QModelIndex(); + return {}; } //========================================= @@ -103,18 +103,18 @@ MvQOdbColumnModel::MvQOdbColumnModel(bool showTableColumn) : showTableColumn_(showTableColumn) { - typeMap_[MvQOdbColumn::None] = "none"; - typeMap_[MvQOdbColumn::Int] = "int"; - typeMap_[MvQOdbColumn::Float] = "float"; - typeMap_[MvQOdbColumn::Double] = "double"; - typeMap_[MvQOdbColumn::String] = "string"; + typeMap_[MvQOdbColumn::None] = "none"; + typeMap_[MvQOdbColumn::Int] = "int"; + typeMap_[MvQOdbColumn::Float] = "float"; + typeMap_[MvQOdbColumn::Double] = "double"; + typeMap_[MvQOdbColumn::String] = "string"; typeMap_[MvQOdbColumn::Bitfield] = "bitfield"; } void MvQOdbColumnModel::setBaseData(const QList& data, MvQOdbMetaData::OdbVersion version) { beginResetModel(); - data_ = data; + data_ = data; odbVersion_ = version; endResetModel(); } @@ -140,7 +140,7 @@ int MvQOdbColumnModel::rowCount(const QModelIndex& parent) const { - //Non-root + // Non-root if (parent.isValid()) { int id = parent.internalId(); if (idToLevel(id) == 0) { @@ -150,7 +150,7 @@ return 0; } } - //Root + // Root else { return data_.count(); } @@ -160,7 +160,7 @@ QVariant MvQOdbColumnModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || role != Qt::DisplayRole) { - return QVariant(); + return {}; } int id = index.internalId(); @@ -169,13 +169,13 @@ return label(col, index.column()); } else if (idToLevel(id) == 1) { - int parentRow = idToParentRow(id); - MvQOdbColumn* col = data_.at(parentRow); + int parentRow = idToParentRow(id); + MvQOdbColumn* col = data_.at(parentRow); MvQOdbBitfieldMember* bit = col->bitfield().at(index.row()); return label(bit, index.column()); } - return QVariant(); + return {}; } @@ -193,7 +193,7 @@ case 2: return (showTableColumn_) ? tr("Table") : QVariant(); default: - return QVariant(); + return {}; } } else if (odbVersion_ == MvQOdbMetaData::Version2) { @@ -208,16 +208,16 @@ return tr("Min"); case 4: return tr("Max"); - //case 5: + // case 5: // return tr("Missing value"); case 5: return (showTableColumn_) ? tr("Table") : QVariant(); default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } @@ -266,10 +266,10 @@ else return QString("N/A"); } - //case 5: + // case 5: //{ // return ((col->type() =="float" || col->type() == "int") && col->hasMissingValue())?QString::number(col->missingValue()):QString("N/A"); - //} + // } case 5: { return (showTableColumn_) ? col->table() : QString(); } @@ -289,7 +289,7 @@ return bitfield->name(); } case 1: { - QString s1 = QString("%1").arg(bitfield->pos(), 2, 10, QChar('0')); + QString s1 = QString("%1").arg(bitfield->pos(), 2, 10, QChar('0')); QString str = "Pos: "; str += s1; str += " Width: "; @@ -298,22 +298,22 @@ return str; } default: - return QString(); + return {}; } } QModelIndex MvQOdbColumnModel::index(int row, int column, const QModelIndex& parent) const { if (data_.count() == 0 || row < 0 || column < 0 || parent.column() > 3) { - return QModelIndex(); + return {}; } - //Parent is non-root -> level-1 items: id is the parent row (number+1)*10000 + // Parent is non-root -> level-1 items: id is the parent row (number+1)*10000 if (parent.isValid()) { int id = (parent.row() + 1) * 10000; return createIndex(row, column, id); } - //Parent is root -> level-0 items: id is the row number + // Parent is root -> level-0 items: id is the row number else { return createIndex(row, column, row); } @@ -323,19 +323,19 @@ QModelIndex MvQOdbColumnModel::parent(const QModelIndex& index) const { if (!index.isValid()) { - return QModelIndex(); + return {}; } int id = index.internalId(); if (idToLevel(id) == 0) { - return QModelIndex(); + return {}; } else { int parentRow = idToParentRow(id); return createIndex(parentRow, 0, parentRow); } - return QModelIndex(); + return {}; } int MvQOdbColumnModel::idToLevel(int id) const @@ -377,12 +377,12 @@ data_ = data; data_->loadAllColumns(); - //sorting + // sorting columnOrder_.clear(); QMap cOrd; for (unsigned int i = 0; i < data_->columns().size(); i++) { QString str = QString::fromStdString(data_->columns().at(i)->name()); - cOrd[str] = i; + cOrd[str] = i; } QMapIterator it(cOrd); @@ -393,8 +393,8 @@ hasTmpFilter_ = false; - //qDebug() << "model size:" << data_.count(); - //Reset the model (views will be notified) + // qDebug() << "model size:" << data_.count(); + // Reset the model (views will be notified) endResetModel(); } @@ -408,11 +408,11 @@ int MvQOdbDataModel::rowCount(const QModelIndex& parent) const { - //Non-root + // Non-root if (parent.isValid()) { return 0; } - //Root + // Root if (data_ != nullptr) { if (data_->chunkSize() == 0) { @@ -437,11 +437,11 @@ QVariant MvQOdbDataModel::data(const QModelIndex& index, int role) const { if (role != Qt::DisplayRole) { - return QVariant(); + return {}; } if (!index.isValid() || index.column() < 0 || index.column() >= data_->columnNum() + 1) { - return QVariant(); + return {}; } if (index.column() == 0) { @@ -459,7 +459,7 @@ const MvOdbColumn* col = data_->loadColumn(dataColumn); if (!col || col->isLoaded() == false) - return QVariant(); + return {}; int dataRow = index.row(); @@ -490,7 +490,7 @@ return QString::number(col->floatData().at(dataRow)); } else { - return QVariant(); + return {}; } } @@ -500,7 +500,7 @@ return QAbstractItemModel::headerData(section, orient, role); if (section < 0 || !data_ || (data_ && section >= static_cast(data_->columns().size()) + 1)) - return QVariant(); + return {}; if (section == 0) return QString(tr("Row")); @@ -524,7 +524,7 @@ QModelIndex MvQOdbDataModel::index(int row, int column, const QModelIndex& /*parent*/) const { if (data_ == nullptr || data_->rowNum() <= 0 || column < 0) { - return QModelIndex(); + return {}; } return createIndex(row, column, static_cast(nullptr)); @@ -533,7 +533,7 @@ QModelIndex MvQOdbDataModel::parent(const QModelIndex& /*index */) const { - return QModelIndex(); + return {}; } void MvQOdbDataModel::setFilter(const std::vector& filter) @@ -542,14 +542,14 @@ return; if (!data_) { - filter_ = filter; + filter_ = filter; hasTmpFilter_ = false; tmpFilter_.clear(); } else if (data_->chunkSize() == 0 && data_->rowNum() >= static_cast(filter.size())) { beginResetModel(); - filter_ = filter; + filter_ = filter; hasTmpFilter_ = false; tmpFilter_.clear(); endResetModel(); @@ -563,12 +563,12 @@ if (!data_) { hasTmpFilter_ = true; - tmpFilter_ = tmpFilter; + tmpFilter_ = tmpFilter; } else if (data_->chunkSize() == 0 && data_->rowNum() >= static_cast(tmpFilter_.size())) { beginResetModel(); hasTmpFilter_ = true; - tmpFilter_ = tmpFilter; + tmpFilter_ = tmpFilter; endResetModel(); } } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQOdbModel.h metview-5.19.2/metview/src/libMvQtGui/MvQOdbModel.h --- metview-5.17.4/metview/src/libMvQtGui/MvQOdbModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQOdbModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,14 +21,14 @@ public: MvQOdbVarModel(); - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void setBaseData(QList&); @@ -44,14 +44,14 @@ public: MvQOdbColumnModel(bool); - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void setBaseData(const QList&, MvQOdbMetaData::OdbVersion); @@ -74,14 +74,14 @@ public: MvQOdbDataModel(); - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void dataIsAboutToChange(); void setBaseData(MvAbstractOdb*); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQPanel.h metview-5.19.2/metview/src/libMvQtGui/MvQPanel.h --- metview-5.17.4/metview/src/libMvQtGui/MvQPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,5 +16,5 @@ explicit MvQPanel(QWidget* parent = nullptr); protected: - void paintEvent(QPaintEvent*); + void paintEvent(QPaintEvent*) override; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQPixmapCache.cc metview-5.19.2/metview/src/libMvQtGui/MvQPixmapCache.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQPixmapCache.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQPixmapCache.cc 2023-07-15 08:28:47.000000000 +0000 @@ -56,13 +56,13 @@ { #ifdef METVIEW Path p(def.toStdString()); - std::string fname = p.name(); + std::string fname = p.name(); std::string::size_type pos = fname.rfind(".icon"); if (pos != std::string::npos) { fname = fname.substr(0, pos); } - std::string s = getenv("METVIEW_DIR_SHARE"); + std::string s = getenv("METVIEW_DIR_SHARE"); std::string svgName = s + "/icons_mv5/" + fname + ".svg"; Path psvg(s + "/icons_mv5/" + fname + ".svg"); @@ -76,7 +76,7 @@ } } - return QString(); + return {}; #endif - return QString(); + return {}; } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQPlainTextEditSearchLine.cc metview-5.19.2/metview/src/libMvQtGui/MvQPlainTextEditSearchLine.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQPlainTextEditSearchLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQPlainTextEditSearchLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,13 +43,13 @@ updateButtons(true); } - //QTextDocument::FindFlags flags; + // QTextDocument::FindFlags flags; /*if(checkBox_backward->checkState() == Qt::Checked) { flags = QTextDocument::FindBackward; } - if(checkBox_case->checkState() == Qt::Checked) + if(checkBox_case->checkState() == Qt::Checked) { flags = flags | QTextDocument::FindCaseSensitively; } @@ -59,11 +59,11 @@ }*/ /*if(editor_->find(txt)) - { - //statusMessage("", 0); - } - else - { + { + //statusMessage("", 0); + } + else + { if (flags & QTextDocument::FindBackward) statusMessage(tr("Reached top of file"), 5000); else diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQProfileView.cc metview-5.19.2/metview/src/libMvQtGui/MvQProfileView.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQProfileView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQProfileView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ #include "MvQMethods.h" #include "MvQTheme.h" -#include +#include //==================================== // MvQNodetem @@ -37,32 +37,32 @@ setZValue(-1); if (editable_) { - idleBrush_ = MvQTheme::brush("scmview", "editable_curve"); + idleBrush_ = MvQTheme::brush("scmview", "editable_curve"); hoverBrush_ = MvQTheme::brush("scmview", "editable_curve_hover"); - moveBrush_ = hoverBrush_; - brush_ = idleBrush_; + moveBrush_ = hoverBrush_; + brush_ = idleBrush_; - idlePen_ = QPen(Qt::NoPen); + idlePen_ = QPen(Qt::NoPen); hoverPen_ = pen_; - movePen_ = pen_; - pen_ = idlePen_; + movePen_ = pen_; + pen_ = idlePen_; } else { - idleBrush_ = MvQTheme::brush("scmview", "curve"); + idleBrush_ = MvQTheme::brush("scmview", "curve"); hoverBrush_ = MvQTheme::brush("scmview", "curve_hover"); - moveBrush_ = hoverBrush_; - brush_ = idleBrush_; + moveBrush_ = hoverBrush_; + brush_ = idleBrush_; - idlePen_ = QPen(Qt::NoPen); + idlePen_ = QPen(Qt::NoPen); hoverPen_ = pen_; - movePen_ = pen_; - pen_ = idlePen_; + movePen_ = pen_; + pen_ = idlePen_; } - idleSize_ = 6; - moveSize_ = 10; + idleSize_ = 6; + moveSize_ = 10; hoverSize_ = 10; - size_ = idleSize_; + size_ = idleSize_; } MvQNodeItem::~MvQNodeItem() = default; @@ -76,8 +76,8 @@ QRectF MvQNodeItem::boundingRect() const { qreal adjust = 2; - return QRectF(-size_ / 2. - adjust, -size_ / 2. - adjust, - size_ + adjust, size_ + adjust); + return {-size_ / 2. - adjust, -size_ / 2. - adjust, + size_ + adjust, size_ + adjust}; } void MvQNodeItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*option*/, QWidget*) @@ -97,7 +97,7 @@ case ItemPositionHasChanged: foreach (MvQEdgeItem* edge, edges_) edge->adjust(); - //prof_->nodeMoved(this); + // prof_->nodeMoved(this); break; default: break; @@ -109,45 +109,45 @@ void MvQNodeItem::mousePressEvent(QGraphicsSceneMouseEvent* /*event*/) { if (editable_) { - pen_ = movePen_; + pen_ = movePen_; brush_ = moveBrush_; prepareGeometryChange(); size_ = moveSize_; } - //QGraphicsItem::mousePressEvent(event); + // QGraphicsItem::mousePressEvent(event); } void MvQNodeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* /*event*/) { if (editable_) { prof_->nodeMoved(this); - pen_ = idlePen_; + pen_ = idlePen_; brush_ = idleBrush_; prepareGeometryChange(); size_ = idleSize_; } - //QGraphicsItem::mouseReleaseEvent(event); + // QGraphicsItem::mouseReleaseEvent(event); } void MvQNodeItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (editable_) { - //We keep the node on a fixed level! + // We keep the node on a fixed level! QPointF pp = mapToParent(event->pos()); setPos(QPointF(pp.x(), yPos_)); - pen_ = movePen_; + pen_ = movePen_; brush_ = moveBrush_; update(); } - //QGraphicsItem::mouseMoveEvent(event); + // QGraphicsItem::mouseMoveEvent(event); } void MvQNodeItem::hoverEnterEvent(QGraphicsSceneHoverEvent* /*event*/) { - pen_ = hoverPen_; + pen_ = hoverPen_; brush_ = hoverBrush_; prepareGeometryChange(); @@ -156,7 +156,7 @@ void MvQNodeItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* /*event*/) { - pen_ = idlePen_; + pen_ = idlePen_; brush_ = idleBrush_; prepareGeometryChange(); @@ -202,7 +202,7 @@ if (length > qreal(6.)) { fromPoint_ = line.p1(); - toPoint_ = line.p2(); + toPoint_ = line.p2(); } else { fromPoint_ = toPoint_ = line.p1(); @@ -212,10 +212,10 @@ QRectF MvQEdgeItem::boundingRect() const { if (!fromNode_ || !toNode_) - return QRectF(); + return {}; qreal penWidth = 1; - qreal extra = penWidth; + qreal extra = penWidth; return QRectF(fromPoint_, QSizeF(toPoint_.x() - fromPoint_.x(), toPoint_.y() - fromPoint_.y())) @@ -278,8 +278,8 @@ adjustFrame(); for (int i = 0; i < data_->count(); i++) { - float val = data_->value(i); - float yp = (i - firstIndex_) * yRatio_; + float val = data_->value(i); + float yp = (i - firstIndex_) * yRatio_; auto* node = new MvQNodeItem(this, editable, yp); node->setParentItem(this); node->setPos((val - frameXMin_) * xRatio_, yp); @@ -322,7 +322,7 @@ void MvQProfileItem::adjustFrame() { - //Min max + // Min max float valMin, valMax; if (presetMinMax_) { @@ -338,7 +338,7 @@ data_->valueRange(firstIndex_, lastIndex_, valMin, valMax); } - //Find a nice plot range + // Find a nice plot range float valRange = valMax - valMin; if (valMin < 0 && valMax > 0) { @@ -350,8 +350,8 @@ QFont font; QFontMetrics fm(font); - int twMax = MvQ::textWidth(fm, QString::number(valMax)); - int twMin = MvQ::textWidth(fm, QString::number(valMin)); + int twMax = MvQ::textWidth(fm, QString::number(valMax)); + int twMin = MvQ::textWidth(fm, QString::number(valMin)); int textWidth = (twMin < twMax) ? twMax : twMin; if (valRange > 0) { @@ -373,21 +373,21 @@ tickXStep_ = 1; } - //We need to ensure that tickXStep_ is greater than 0!!! + // We need to ensure that tickXStep_ is greater than 0!!! if (tickXStep_ <= 0) tickXStep_ = 1.; - tickXLabelStep_ = tickXStep_; + tickXLabelStep_ = tickXStep_; tickXLabelStepOffset_ = 0; - //Because tickXStep_ alwasy greater than 0 these two values will always be different!!! + // Because tickXStep_ alwasy greater than 0 these two values will always be different!!! frameXMin_ = static_cast((valMin - tickXStep_ - tickXStep_ / 1000.) / tickXStep_) * tickXStep_; frameXMax_ = static_cast((valMax + tickXStep_ + tickXStep_ / 1000.) / tickXStep_) * tickXStep_; - //So this division can always be made!!! + // So this division can always be made!!! xRatio_ = frameRect_.width() / (frameXMax_ - frameXMin_); - //Adjustment + // Adjustment if (xRatio_ * tickXStep_ < textWidth) { tickXLabelStep_ *= 2; int labelFactor = static_cast(round(frameXMin_ / tickXStep_)); @@ -418,7 +418,7 @@ painter->setPen(pen_); - //Title + // Title if (!subPlot_) { QRectF titleRect(frameRect_.width() / 2. - 150, frameRect_.top() - 70, 300, 40); QString editableText = (editable_ == true) ? "Editable" : ""; @@ -429,15 +429,15 @@ "\n" + editableText); } /*else - { - QRectF titleRect(frameRect_.width()/2.-150,frameRect_.top()-50,300,40); - painter->drawText(titleRect,Qt::AlignCenter, - "Parameter: " + QString::fromStdString(data_->name()) + - " [" + QString::fromStdString(data_->units()) + "]"); - } */ + { + QRectF titleRect(frameRect_.width()/2.-150,frameRect_.top()-50,300,40); + painter->drawText(titleRect,Qt::AlignCenter, + "Parameter: " + QString::fromStdString(data_->name()) + + " [" + QString::fromStdString(data_->units()) + "]"); + } */ - //Render out of normal range + // Render out of normal range if (data_->isRangeSet()) { float valMin = data_->rangeMin(); float valMax = data_->rangeMax(); @@ -447,45 +447,45 @@ painter->fillRect(0, frameRect_.top(), xp, frameRect_.bottom(), outsideBrush_); } if (frameXMax_ > valMax) { - float xp = (valMax - frameXMin_) * xRatio_; + float xp = (valMax - frameXMin_) * xRatio_; float xp1 = (frameXMax_ - frameXMin_) * xRatio_; painter->fillRect(xp, frameRect_.top(), xp1 - xp, frameRect_.bottom(), outsideBrush_); } } - //Dash pattern for the grid - //QVector dashes; - //dashes << 1 << 8; - //gridPen.setDashPattern(dashes); + // Dash pattern for the grid + // QVector dashes; + // dashes << 1 << 8; + // gridPen.setDashPattern(dashes); - //Lines - //X axis - top + bottom + // Lines + // X axis - top + bottom for (float xv = frameXMin_; xv <= frameXMax_; xv += tickXStep_) { float xp = (xv - frameXMin_) * xRatio_; painter->drawLine(xp, frameRect_.top(), xp, frameRect_.top() - 6.); painter->drawLine(xp, frameRect_.bottom(), xp, frameRect_.bottom() + 6.); - //grid + // grid if (firstIndex_ != lastIndex_ && xv != frameXMin_ && xv != frameXMax_) { painter->setPen(gridPen_); painter->drawLine(xp, frameRect_.top(), xp, frameRect_.bottom()); painter->setPen(pen_); } - //text - //int xpText=xp-fm.width(QString::number(xv))/2; - //painter->drawText(QPointF(xpText,frameRect_.bottom()+10+fm.ascent()),QString::number(xv)); + // text + // int xpText=xp-fm.width(QString::number(xv))/2; + // painter->drawText(QPointF(xpText,frameRect_.bottom()+10+fm.ascent()),QString::number(xv)); - //if(!subPlot_) + // if(!subPlot_) // painter->drawText(QPointF(xpText,frameRect_.top()-10-fm.descent()),QString::number(xv)); } - //Text - //X axis - top + bottom + // Text + // X axis - top + bottom for (float xv = frameXMin_ + tickXLabelStepOffset_ * tickXStep_; xv <= frameXMax_; xv += tickXLabelStep_) { float xp = (xv - frameXMin_) * xRatio_; - //text + // text int xpText = xp - MvQ::textWidth(fm, QString::number(xv)) / 2; painter->drawText(QPointF(xpText, frameRect_.bottom() + 10 + fm.ascent()), QString::number(xv)); @@ -494,7 +494,7 @@ } - float dy = frameRect_.height() / (1 + lastIndex_ - firstIndex_); + float dy = frameRect_.height() / (1 + lastIndex_ - firstIndex_); int stepY = 10; if (dy > 15) stepY = 1; @@ -508,7 +508,7 @@ if (lastIndex_ - firstIndex_ + 1 < 6) stepY = 1; - //Right axis + // Right axis if (data_->auxLevelDefined()) { for (int i = lastIndex_; i >= firstIndex_; i -= stepY) { auto xv = static_cast(floor(data_->auxLevel(i) / 100.)); @@ -517,12 +517,12 @@ float yp = frameRect_.top() + (i - firstIndex_) * yRatio_; painter->drawLine(xp, yp, xp + 6., yp); - //Label + // Label int ypText = yp + fm.ascent() / 2; painter->drawText(QPointF(xp + 10, ypText), QString::number(xv)); } - //Right axis title + // Right axis title painter->save(); painter->translate(frameRect_.width() + 10 + MvQ::textWidth(fm, "1000") + 10 + fm.ascent(), frameRect_.center().y()); painter->rotate(-90); @@ -533,14 +533,14 @@ } if (lastIndex_ != firstIndex_) { - //Left axis + // Left axis for (int i = lastIndex_; i >= firstIndex_; i -= stepY) { float xv = data_->level(i); float xp = 0; float yp = frameRect_.top() + (i - firstIndex_) * yRatio_; painter->drawLine(xp, yp, xp - 6., yp); - //grid + // grid painter->setPen(gridPen_); painter->drawLine(xp, yp, xp + frameRect_.width(), yp); painter->setPen(pen_); @@ -552,7 +552,7 @@ } } - //Left axis title + // Left axis title painter->save(); painter->translate(-10 - MvQ::textWidth(fm, "100") - 10, frameRect_.center().y()); painter->rotate(-90); @@ -574,7 +574,7 @@ painter->drawLine(xp, frameRect_.top(), xp, frameRect_.bottom()); } - //Frame + // Frame if (firstIndex_ != lastIndex_) painter->drawRect(frameRect_); @@ -592,7 +592,7 @@ float val = data_->value(index); nodes_.at(index)->setPos((val - frameXMin_) * xRatio_, frameRect_.top() + (index - firstIndex_) * yRatio_); - //See if the coordinate system needs to be adjusted to the data value range + // See if the coordinate system needs to be adjusted to the data value range if (val < frameXMin_ || val > frameXMax_) view_->adjustValueRange(); else @@ -618,12 +618,12 @@ float val = data_->value(index); if (fabs((val - frameXMin_) * xRatio_ - node->pos().x()) > 0.1) { float f = frameXMin_ + node->pos().x() / xRatio_; - //if(!data_->fitToRange(f)) + // if(!data_->fitToRange(f)) //{ // data_->setValue(index,f); // nodes_.at(index)->setPos((f-frameXMin_)*xRatio_,(index-firstIndex_)*yRatio_); - //} - //else + // } + // else //{ data_->setValue(index, f); //} @@ -646,7 +646,7 @@ h = minYSize_; frameRect_ = QRectF(0, 0, w - 150, h - 120); - bRect_ = frameRect_.adjusted(-60, -80, 90, 30); + bRect_ = frameRect_.adjusted(-60, -80, 90, 30); } void MvQProfileItem::initFrame(QRectF r) @@ -664,63 +664,63 @@ if (data_) { for (int i = 0; i < data_->count(); i++) { float val = data_->value(i); - float yp = frameRect_.top() + (i - firstIndex_) * yRatio_; + float yp = frameRect_.top() + (i - firstIndex_) * yRatio_; if (i < firstIndex_) { - if (nodes_.at(i)->scene() != 0) { + if (nodes_.at(i)->scene() != nullptr) { scene()->removeItem(nodes_.at(i)); nodes_.at(i)->setVisible(false); - //qDebug() << "remove node" << i << nodes_.at(i)->scene(); + // qDebug() << "remove node" << i << nodes_.at(i)->scene(); } if (i < edges_.count() && edges_.at(i)->scene()) { scene()->removeItem(edges_.at(i)); edges_.at(i)->setVisible(false); - //qDebug() << " remove edge " << i << edges_.at(i)->scene(); + // qDebug() << " remove edge " << i << edges_.at(i)->scene(); } if (i > 0 && edges_.at(i - 1)->scene()) { scene()->removeItem(edges_.at(i - 1)); edges_.at(i - 1)->setVisible(false); - //qDebug() << " remove edge " << i-1 << edges_.at(i-1)->scene(); + // qDebug() << " remove edge " << i-1 << edges_.at(i-1)->scene(); } } else if (i > lastIndex_) { - if (nodes_.at(i)->scene() != 0) { + if (nodes_.at(i)->scene() != nullptr) { scene()->removeItem(nodes_.at(i)); nodes_.at(i)->setVisible(false); - //qDebug() << "remove node" << i << nodes_.at(i)->scene(); + // qDebug() << "remove node" << i << nodes_.at(i)->scene(); } if (i > 0 && edges_.at(i - 1)->scene()) { scene()->removeItem(edges_.at(i - 1)); edges_.at(i - 1)->setVisible(false); - //qDebug() << " remove edge " << i-1 << edges_.at(i-1)->scene(); + // qDebug() << " remove edge " << i-1 << edges_.at(i-1)->scene(); } /*if(i < edges_.count() && edges_.at(i)->scene()) - { - scene()->removeItem(edges_.at(i)); - edges_.at(i)->setVisible(false); - qDebug() << " remove edge " << i << edges_.at(i)->scene(); - }*/ + { + scene()->removeItem(edges_.at(i)); + edges_.at(i)->setVisible(false); + qDebug() << " remove edge " << i << edges_.at(i)->scene(); + }*/ } - else if (nodes_.at(i)->scene() == 0) { - //qDebug() << "add node" << i << nodes_.at(i)->scene();; + else if (nodes_.at(i)->scene() == nullptr) { + // qDebug() << "add node" << i << nodes_.at(i)->scene();; nodes_.at(i)->setParentItem(this); nodes_.at(i)->setVisible(true); - if (i < edges_.count() && !edges_.at(i)->scene() && nodes_.at(i + 1)->scene() != 0) { + if (i < edges_.count() && !edges_.at(i)->scene() && nodes_.at(i + 1)->scene() != nullptr) { edges_.at(i)->setParentItem(this); edges_.at(i)->setVisible(true); - //qDebug() << " add edge" << i << edges_.at(i)->scene();; + // qDebug() << " add edge" << i << edges_.at(i)->scene();; } - if (i > 1 && !edges_.at(i - 1)->scene() && nodes_.at(i - 1)->scene() != 0) { + if (i > 1 && !edges_.at(i - 1)->scene() && nodes_.at(i - 1)->scene() != nullptr) { edges_.at(i - 1)->setParentItem(this); edges_.at(i - 1)->setVisible(true); - //qDebug() << " add edge" << i << edges_.at(i-1)->scene();; + // qDebug() << " add edge" << i << edges_.at(i-1)->scene();; } } @@ -752,7 +752,7 @@ void MvQProfileItem::setLevelRange(int firstIndex, int lastIndex) { firstIndex_ = firstIndex; - lastIndex_ = lastIndex; + lastIndex_ = lastIndex; if (firstIndex_ < 0 || firstIndex_ >= data_->count()) firstIndex_ = 0; @@ -821,11 +821,11 @@ void MvQProfileItem::checkValueRange() { - //See if the coordinate system needs to be adjusted to the data value range + // See if the coordinate system needs to be adjusted to the data value range if (!presetMinMax_ && !data_->isRangeSet()) { float valMin, valMax; data_->valueRange(firstIndex_, lastIndex_, valMin, valMax); - valMax = (fabs(valMax) > fabs(valMin)) ? fabs(valMax) : fabs(valMin); + valMax = (fabs(valMax) > fabs(valMin)) ? fabs(valMax) : fabs(valMin); float frameMax = (fabs(frameXMax_) > fabs(frameXMin_)) ? fabs(frameXMax_) : fabs(frameXMin_); if (valMax > 0.0000000001 && valMax < frameMax / 100.) @@ -886,12 +886,12 @@ itemsToBeDeleted << item; } prof_.clear(); - //profWeight_.clear(); + // profWeight_.clear(); QSize size = maximumViewportSize(); size -= QSize(10, 10); - ///Min max + /// Min max bool setMinMax = false; float valMin = 999999, valMax = -9999999; if (profData.count() > 1) { @@ -913,7 +913,7 @@ } } - //Create plot items + // Create plot items if (profData.count() > 0) { prof_ << new MvQProfileItem(this, profData[0], editable, 0, startIndex, endIndex, size, setMinMax, valMin, valMax); @@ -972,7 +972,7 @@ QSize size = maximumViewportSize(); size -= QSize(10, 10); - //Needs to be improved + // Needs to be improved if (prof_.count() > 1) { int h = 0; for (int i = 1; i < prof_.count(); i++) { @@ -1007,7 +1007,7 @@ prof_[0]->adjustSize(size); } - //Set the scenerect + // Set the scenerect if (prof_.count() > 0) { QRectF bb = prof_[0]->boundingRect(); for (int i = 1; i < prof_.count(); i++) { diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQProfileWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQProfileWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQProfileWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQProfileWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -47,24 +47,24 @@ profileLabel_, SLOT(setText(QString))); /*QHBoxLayout* levHb=new QHBoxLayout; - profLayout->addLayout(levHb); - - QLabel *label; - label=new QLabel(tr("Edit radius:")); - levHb->addWidget(label); - editRadiusSpin_=new QSpinBox(this); + profLayout->addLayout(levHb); + + QLabel *label; + label=new QLabel(tr("Edit radius:")); + levHb->addWidget(label); + editRadiusSpin_=new QSpinBox(this); editRadiusSpin_->setSuffix(" level"); - levHb->addWidget(editRadiusSpin_); - - //Edit radius spinbox - editRadiusSpin_->setRange(1,5); - editRadiusSpin_->setValue(3); - - connect(editRadiusSpin_,SIGNAL(valueChanged(int)), - this, SLOT(slotEditRadius(int))); - - //Range widget - levHb->addStretch(1);*/ + levHb->addWidget(editRadiusSpin_); + + //Edit radius spinbox + editRadiusSpin_->setRange(1,5); + editRadiusSpin_->setValue(3); + + connect(editRadiusSpin_,SIGNAL(valueChanged(int)), + this, SLOT(slotEditRadius(int))); + + //Range widget + levHb->addStretch(1);*/ rangeWidget_ = new MvQRangeWidget(this); mainHb->addWidget(rangeWidget_); @@ -101,7 +101,7 @@ void MvQProfileWidget::slotLevelRange(int startIndex, int endIndex) { startLevelIndex_ = startIndex; - endLevelIndex_ = endIndex; + endLevelIndex_ = endIndex; profileView_->setLevelRange(startIndex, endIndex); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQRangeWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQRangeWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQRangeWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQRangeWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,10 +22,7 @@ #include "MvQTheme.h" MvQRangeWidget::MvQRangeWidget(QWidget* parent) : - QWidget(parent), - rangeStartIndex_(-1), - rangeEndIndex_(-1), - ignoreSpinChange_(false) + QWidget(parent) { auto* layout = new QVBoxLayout(this); @@ -65,7 +62,7 @@ void MvQRangeWidget::setRange(int start, int end) { rangeStartIndex_ = start; - rangeEndIndex_ = end; + rangeEndIndex_ = end; if (values_.count() > 0) { if (rangeEndIndex_ > values_.count() - 1) @@ -87,7 +84,7 @@ values_ = d; if (rangeStartIndex_ == -1) { rangeStartIndex_ = 0; - rangeEndIndex_ = values_.count() - 1; + rangeEndIndex_ = values_.count() - 1; } else { if (rangeStartIndex_ > values_.count() - 1) @@ -134,7 +131,7 @@ return; else { rangeStartIndex_ = startV + delta; - rangeEndIndex_ = endV + delta; + rangeEndIndex_ = endV + delta; updateSpins(); emit valueChanged(rangeStartIndex_, rangeEndIndex_); } @@ -242,10 +239,6 @@ MvQRangePlotWidget::MvQRangePlotWidget(MvQRangeWidget* parent) : QWidget(parent), parent_(parent), - action_(NoAction), - hover_(NoHover), - offset_(15), - dragRadius_(10), bgBrush_(MvQTheme::colour("rangeselector", "bg")), pen_(MvQTheme::colour("rangeselector", "pen")), selectorBrush_(MvQTheme::colour("rangeselector", "selector_bg")), @@ -284,13 +277,13 @@ { QPainter painter(this); - //bg + // bg painter.fillRect(rect(), bgBrush_); - //axis + // axis QRect r = rect().adjusted(0, offset_, 0, -offset_); - int xp = r.center().x(); + int xp = r.center().x(); int tickWidth = 12; QFont font; QFontMetrics fm(font); @@ -298,28 +291,28 @@ painter.setPen(pen_); painter.drawLine(xp, r.y(), xp, r.bottomLeft().y()); - //Min tick + text + // Min tick + text painter.drawLine(xp - tickWidth / 2, r.y(), xp + tickWidth / 2, r.y()); painter.drawText(QPointF(xp + tickWidth / 2 + 6, r.y() + fm.ascent() / 2), QString::number(parent_->startValue())); - //Max tick + text + // Max tick + text painter.drawLine(xp - tickWidth / 2, r.bottomLeft().y(), xp + tickWidth / 2, r.bottomLeft().y()); painter.drawText(QPointF(xp + tickWidth / 2 + 6, r.bottomLeft().y() + fm.ascent() / 2), QString::number(parent_->endValue())); - //othert ticks + text + // othert ticks + text for (int i = 9; i > 5 && i < parent_->valueCount() - 5; i += 10) { int yp = r.y() + static_cast(parent_->indexPercent(i)) * static_cast(r.height()); painter.drawLine(xp - tickWidth / 2, yp, xp + tickWidth / 2, yp); painter.drawText(QPointF(xp + tickWidth / 2 + 6, yp + fm.ascent() / 2), QString::number(parent_->value(i))); } - //Small ticks + // Small ticks for (int i = 4; i > 3 && i < parent_->valueCount() - 4; i += 10) { int yp = r.y() + static_cast(parent_->indexPercent(i)) * static_cast(r.height()); painter.drawLine(xp - tickWidth / 4, yp, xp + tickWidth / 4, yp); } - //range + // range painter.fillRect(rangeRect(), selectorBrush_); painter.setPen(selectorPen_); painter.drawRect(rangeRect()); @@ -327,14 +320,14 @@ painter.setRenderHint(QPainter::Antialiasing, true); if (action_ == MinDragAction) { - //QRect minRect=minDragRect(); - //painter.fillRect(minRect,QColor(220,220,220,80)); - //painter.drawRect(minRect); + // QRect minRect=minDragRect(); + // painter.fillRect(minRect,QColor(220,220,220,80)); + // painter.drawRect(minRect); } else if (action_ == MaxDragAction) { - //QRect maxRect=maxDragRect(); - //painter.fillRect(maxRect,QColor(220,220,220,80)); - //painter.drawRect(maxRect); + // QRect maxRect=maxDragRect(); + // painter.fillRect(maxRect,QColor(220,220,220,80)); + // painter.drawRect(maxRect); } else if (hover_ == MinDragHover) { QPolygon minPoly = minDragShape(); @@ -353,26 +346,26 @@ { if (minDragShape().containsPoint(event->pos(), Qt::OddEvenFill)) { dragPos_ = event->pos(); - action_ = MinDragAction; + action_ = MinDragAction; dragMin_ = parent_->rangeStartIndex(); dragMax_ = parent_->rangeEndIndex(); - hover_ = NoHover; + hover_ = NoHover; setCursor(QCursor(Qt::SizeVerCursor)); } else if (maxDragShape().containsPoint(event->pos(), Qt::OddEvenFill)) { dragPos_ = event->pos(); - action_ = MaxDragAction; + action_ = MaxDragAction; dragMin_ = parent_->rangeStartIndex(); dragMax_ = parent_->rangeEndIndex(); - hover_ = NoHover; + hover_ = NoHover; setCursor(QCursor(Qt::SizeVerCursor)); } else if (rangeRect().contains(event->pos())) { dragPos_ = event->pos(); - action_ = MoveAction; + action_ = MoveAction; dragMin_ = parent_->rangeStartIndex(); dragMax_ = parent_->rangeEndIndex(); - hover_ = NoHover; + hover_ = NoHover; setCursor(QCursor(Qt::SizeAllCursor)); } } @@ -381,19 +374,19 @@ { if (action_ == MinDragAction) { int delta = event->pos().y() - dragPos_.y(); - float h = static_cast(rect().height()) - 2 * offset_; + float h = static_cast(rect().height()) - 2 * offset_; parent_->adjustRangeStart(dragMin_, delta / h); update(); } else if (action_ == MaxDragAction) { int delta = event->pos().y() - dragPos_.y(); - float h = static_cast(rect().height()) - 2 * offset_; + float h = static_cast(rect().height()) - 2 * offset_; parent_->adjustRangeEnd(dragMax_, delta / h); update(); } else if (action_ == MoveAction) { int delta = event->pos().y() - dragPos_.y(); - float h = static_cast(rect().height()) - 2 * offset_; + float h = static_cast(rect().height()) - 2 * offset_; parent_->adjustRange(dragMin_, dragMax_, delta / h); update(); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQRangeWidget.h metview-5.19.2/metview/src/libMvQtGui/MvQRangeWidget.h --- metview-5.17.4/metview/src/libMvQtGui/MvQRangeWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQRangeWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -45,14 +45,14 @@ MoveHover }; - MvQRangeWidget* parent_; + MvQRangeWidget* parent_{nullptr}; QPoint dragPos_; - UserAction action_; - HoverMode hover_; - int offset_; - int dragRadius_; - int dragMin_; - int dragMax_; + UserAction action_{NoAction}; + HoverMode hover_{NoHover}; + int offset_{15}; + int dragRadius_{10}; + int dragMin_{0}; + int dragMax_{0}; QBrush bgBrush_; QPen pen_; QBrush selectorBrush_; @@ -95,10 +95,10 @@ void updateSpins(); QVector values_; - int rangeStartIndex_; - int rangeEndIndex_; - QSpinBox* startSpin_; - QSpinBox* endSpin_; - MvQRangePlotWidget* plot_; - bool ignoreSpinChange_; + int rangeStartIndex_{-1}; + int rangeEndIndex_{-1}; + QSpinBox* startSpin_{nullptr}; + QSpinBox* endSpin_{nullptr}; + MvQRangePlotWidget* plot_{nullptr}; + bool ignoreSpinChange_{false}; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQScmDataWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQScmDataWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQScmDataWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQScmDataWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,7 +36,7 @@ MvQScmDataPanel::MvQScmDataPanel(QWidget* parent) : QWidget(parent), - model_(0), + model_(nullptr), master_(false) { auto* layout = new QVBoxLayout; @@ -48,7 +48,7 @@ view_ = new QTableView(this); view_->setObjectName("paramMlView"); - //view_->setProperty("mvStyle", 3); + // view_->setProperty("mvStyle", 3); view_->setAlternatingRowColors(true); view_->setModel(filterModel_); layout->addWidget(view_); @@ -103,7 +103,7 @@ { if (index >= 0 && index < static_cast(vars_.size())) { MvScmVar* var = vars_.at(index); - int step = model_->step(); + int step = model_->step(); auto it = masterParams_.find(var); if (it != masterParams_.end()) { @@ -130,7 +130,7 @@ if (!var) return false; - int row = 0; + int row = 0; QModelIndex current = view_->currentIndex(); if (current.isValid()) row = current.row(); @@ -180,9 +180,9 @@ MvQScmProfileDataPanel::MvQScmProfileDataPanel(QWidget* parent) : MvQScmDataPanel(parent), - header_(0) + header_(nullptr) { - //Column tree + // Column tree model_ = new MvQScmProfileModel(); filterModel_->setSourceModel(model_); @@ -198,14 +198,14 @@ connect(header_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotHeaderContextMenu(const QPoint&))); - //Dymanic filter did not work somehow, so we need to update the filter model in this way + // Dymanic filter did not work somehow, so we need to update the filter model in this way filterModel_->setShowEditableOnly(filterModel_->showEditableOnly()); } void MvQScmProfileDataPanel::init(const std::vector& vars, int step, const std::vector& levels, const std::string& levelName, const std::vector& editableVars) { - vars_ = vars; + vars_ = vars; editableVars_ = editableVars; model_->setData(vars, step, levels, levelName); model_->setEditableVars(editableVars); @@ -225,7 +225,7 @@ return; QList actions; - QAction* action; + QAction* action = nullptr; action = new QAction(this); action->setObjectName(QString::fromUtf8("actionAssign")); @@ -241,8 +241,8 @@ actions << action; if (actions.count() > 0 && - (action = QMenu::exec(actions, header_->mapToGlobal(position))) != 0) { - QString key = action->data().toString(); + (action = QMenu::exec(actions, header_->mapToGlobal(position))) != nullptr) { + QString key = action->data().toString(); MvScmVar* var = vars_.at(section); if (key == "assign") { assignValue(var); @@ -261,7 +261,7 @@ void MvQScmProfileDataPanel::assignValue(MvScmVar* var) { bool ok; - double val = QInputDialog::getDouble(0, + double val = QInputDialog::getDouble(nullptr, tr("Assign value"), tr("New value:"), 0., -10000000, 10000000, 10, &ok); @@ -290,7 +290,7 @@ MvQScmSurfaceDataPanel::MvQScmSurfaceDataPanel(QWidget* parent) : MvQScmDataPanel(parent) { - //Column tree + // Column tree model_ = new MvQScmSurfaceModel(); filterModel_->setSourceModel(model_); @@ -302,7 +302,7 @@ connect(header, SIGNAL(sectionClicked(int)), this, SLOT(slotParamSelected(int))); - //Dymanic filter did not work somehow, so we need to update the filter model in this way + // Dymanic filter did not work somehow, so we need to update the filter model in this way filterModel_->setShowEditableOnly(filterModel_->showEditableOnly()); } @@ -327,8 +327,8 @@ MvQScmDataWidget::MvQScmDataWidget(QWidget* parent) : QWidget(parent), - data_(0), - masterPanel_(0) + data_(nullptr), + masterPanel_(nullptr) { //----------------------- // The main layout @@ -364,7 +364,7 @@ delete panel.second; } - masterPanel_ = 0; + masterPanel_ = nullptr; tabToPanel_.clear(); panelToTab_.clear(); } @@ -372,14 +372,14 @@ void MvQScmDataWidget::addPanelToTab(MvQScmDataPanel* panel, PanelType type, QString title) { tab_->addTab(panel, title); - int tabIndex = tab_->count() - 1; - panelToTab_[type] = tabIndex; + int tabIndex = tab_->count() - 1; + panelToTab_[type] = tabIndex; tabToPanel_[tabIndex] = type; } void MvQScmDataWidget::init(MvScm* data, QList editVars) { - //Delete all the panels + // Delete all the panels clearPanels(); if (data->stepNum() <= 0) { @@ -389,7 +389,7 @@ data_ = data; - //Get editable variables + // Get editable variables #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) auto qv = editVars.toVector(); std::vector editVec(qv.begin(), qv.end()); @@ -398,25 +398,25 @@ #endif int step = 0; - MvQScmDataPanel* panel; + MvQScmDataPanel* panel = nullptr; //------------------------- // Model levels //------------------------- - //At the moment masterPanel_ has to be the model level panel !!! + // At the moment masterPanel_ has to be the model level panel !!! if (!data->modelLevelDim().isEmpty()) { - panel = new MvQScmProfileDataPanel(this); + panel = new MvQScmProfileDataPanel(this); panels_[ModelLevPanel] = panel; - //This will be the master panel + // This will be the master panel masterPanel_ = panel; - //Add to tab + // Add to tab addPanelToTab(panel, ModelLevPanel, tr("Model levels")); - //init + // init panel->init(data_->modelLevel(), step, data_->modelLevelDim().values(), data_->modelLevelDim().longName(), editVec); } @@ -424,27 +424,27 @@ // Pressure levels //------------------------- - //if(!data->pressureLevelDim().isEmpty()) - if (0) { - panel = new MvQScmProfileDataPanel(this); + // if(!data->pressureLevelDim().isEmpty()) + if (false) { + panel = new MvQScmProfileDataPanel(this); panels_[PressureLevPanel] = panel; - //Add to tab + // Add to tab addPanelToTab(panel, PressureLevPanel, tr("Pressure levels")); - //init + // init panel->init(data_->pressureLevel(), step, data_->pressureLevelDim().values(), data_->pressureLevelDim().longName(), editVec); } //------------------------- - //Soil levels + // Soil levels //------------------------- if (!data->soilLevelDim().isEmpty()) { - panel = new MvQScmProfileDataPanel(this); + panel = new MvQScmProfileDataPanel(this); panels_[SoilLevPanel] = panel; - //Add to tab + // Add to tab addPanelToTab(panel, SoilLevPanel, tr("Soil levels")); panel->init(data_->soilLevel(), step, data_->soilLevelDim().values(), data_->soilLevelDim().longName(), editVec); @@ -458,13 +458,13 @@ } //------------------------- - //Surface - always exists + // Surface - always exists //------------------------ - panel = new MvQScmSurfaceDataPanel(this); + panel = new MvQScmSurfaceDataPanel(this); panels_[SurfaceLevPanel] = panel; - //Add to tab + // Add to tab addPanelToTab(panel, SurfaceLevPanel, tr("Surface and other 2D")); panel->init(data_->surfaceLevel(), step, editVec); @@ -477,7 +477,7 @@ } //----------------------------------- - //Relaying signals from the panels + // Relaying signals from the panels //----------------------------------- for (auto& panel : panels_) { @@ -491,7 +491,7 @@ this, SIGNAL(stepChanged(int))); } - //Initial profile + // Initial profile if (masterPanel_) { //!!!!!!!!!!!!!!!!!! masterPanel_->slotParamSelected(data_->mlVarIndex(MvScm::TempML)); @@ -502,31 +502,31 @@ { int step = value; - //Save and set steps + // Save and set steps for (auto& panel : panels_) { panel.second->setStep(step); } - //Update profile view + // Update profile view int actTab = tab_->currentIndex(); - //Model levels + // Model levels if (panels_.find(ModelLevPanel) != panels_.end()) { panels_[ModelLevPanel]->reselectIndex(tabToPanel_[actTab] == ModelLevPanel || tabToPanel_[actTab] == PressureLevPanel); } - //Pressure + // Pressure if (panels_.find(PressureLevPanel) != panels_.end()) { panels_[PressureLevPanel]->reselectIndex(tabToPanel_[actTab] == PressureLevPanel); } - //Soil + // Soil if (panels_.find(SoilLevPanel) != panels_.end()) { panels_[SoilLevPanel]->reselectIndex(tabToPanel_[actTab] == SoilLevPanel); } - //Surf + // Surf panels_[SurfaceLevPanel]->reselectIndex(tabToPanel_[actTab] == SurfaceLevPanel); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQScmDataWidget.h metview-5.19.2/metview/src/libMvQtGui/MvQScmDataWidget.h --- metview-5.17.4/metview/src/libMvQtGui/MvQScmDataWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQScmDataWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -129,10 +129,10 @@ protected: enum PanelType { - ModelLevPanel = 0, + ModelLevPanel = 0, PressureLevPanel = 1, - SoilLevPanel = 2, - SurfaceLevPanel = 3 + SoilLevPanel = 2, + SurfaceLevPanel = 3 }; void clearPanels(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQScmModel.cc metview-5.19.2/metview/src/libMvQtGui/MvQScmModel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQScmModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQScmModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ void MvQScmTableViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - //Paint the rest + // Paint the rest QStyledItemDelegate::paint(painter, option, index); painter->save(); @@ -49,7 +49,7 @@ MvQScmDataModel::MvQScmDataModel(QObject* parent) : QAbstractItemModel(parent) { - step_ = -1; + step_ = -1; editCol_ = MvQTheme::colour("scmview", "edited_cell"); } @@ -74,7 +74,7 @@ QModelIndex MvQScmDataModel::index(int row, int column, const QModelIndex& /*parent*/) const { if (data_.size() == 0 || column < 0) { - return QModelIndex(); + return {}; } return createIndex(row, column, (void*)nullptr); @@ -87,12 +87,12 @@ QModelIndex MvQScmDataModel::parent(const QModelIndex& /*index */) const { - return QModelIndex(); + return {}; } void MvQScmDataModel::reload() { - //reset(); + // reset(); beginResetModel(); endResetModel(); } @@ -116,11 +116,11 @@ int MvQScmSurfaceModel::rowCount(const QModelIndex& parent) const { - //Non-root + // Non-root if (parent.isValid()) { return 0; } - //Root + // Root return static_cast(data_.size()); } @@ -128,14 +128,14 @@ { if (role != Qt::DisplayRole && role != Qt::BackgroundRole && role != Qt::EditRole && role != Qt::UserRole) { - return QVariant(); + return {}; } if (index.column() != 0 && index.column() != 1) - return QVariant(); + return {}; if (step_ == -1 || !index.isValid() || index.row() < 0 || index.row() >= static_cast(data_.size())) { - return QVariant(); + return {}; } if (role == Qt::DisplayRole || role == Qt::EditRole) { @@ -152,9 +152,9 @@ return editCol_; } } - return QVariant(); + return {}; } - return QVariant(); + return {}; } bool MvQScmSurfaceModel::setData(const QModelIndex& index, const QVariant& value, int role) @@ -194,7 +194,7 @@ if (orient == Qt::Vertical) { if (section < 0 || section >= static_cast(data_.size())) - return QVariant(); + return {}; QString str = QString::fromStdString(data_.at(section)->name()); //+ @@ -225,7 +225,7 @@ } } - return QModelIndex(); + return {}; } @@ -262,11 +262,11 @@ int MvQScmProfileModel::rowCount(const QModelIndex& parent) const { - //Non-root + // Non-root if (parent.isValid()) { return 0; } - //Root + // Root if (data_.size() > 0) { return static_cast(data_.at(0)->levelNum()); } @@ -278,11 +278,11 @@ { if (role != Qt::DisplayRole && role != Qt::BackgroundRole && role != Qt::EditRole && role != Qt::UserRole) { - return QVariant(); + return {}; } if (step_ == -1 || !index.isValid() || index.column() < 0 || index.column() >= static_cast(data_.size())) { - return QVariant(); + return {}; } if (role == Qt::DisplayRole || role == Qt::EditRole) { @@ -297,9 +297,9 @@ return editCol_; } } - return QVariant(); + return {}; } - return QVariant(); + return {}; } bool MvQScmProfileModel::setData(const QModelIndex& index, const QVariant& value, int role) @@ -322,8 +322,8 @@ { beginResetModel(); - data_ = data; - levels_ = levels; + data_ = data; + levels_ = levels; levelName_ = QString::fromStdString(levelName); if (step >= 0 && data_.size() > 0 && step < data_.at(0)->stepNum()) @@ -341,25 +341,25 @@ if (orient == Qt::Horizontal) { if (section < 0 || section >= static_cast(data_.size())) - return QVariant(); + return {}; QString str = QString::fromStdString(data_.at(section)->name()) + "\n" + "[" + QString::fromStdString(data_.at(section)->units()) + "]"; - //bool editable=(std::find(editableVars_.begin(),editableVars_.end(),data_.at(section)) != editableVars_.end())?true:false; + // bool editable=(std::find(editableVars_.begin(),editableVars_.end(),data_.at(section)) != editableVars_.end())?true:false; if (role == Qt::DisplayRole) return str; else if (role == Qt::ToolTipRole) return QString::fromStdString(data_.at(section)->longName()); - //else if(role == Qt::BackgroundRole && editable) + // else if(role == Qt::BackgroundRole && editable) // return QColor(Qt::red); - //else if(role == Qt::DecorationRole && editable) + // else if(role == Qt::DecorationRole && editable) // return QPixmap(QString::fromUtf8(":/scmEditor/edit.svg")); } else if (orient == Qt::Vertical) { if (section < 0 || section >= static_cast(levels_.size())) - return QVariant(); + return {}; QString str = QString::number(levels_.at(section)); @@ -369,7 +369,7 @@ return levelName_ + " = " + str; } - return QVariant(); + return {}; } QModelIndex MvQScmProfileModel::indexForVar(MvScmVar* var, int step, int level) const @@ -382,7 +382,7 @@ } } - return QModelIndex(); + return {}; } Qt::ItemFlags MvQScmProfileModel::flags(const QModelIndex& index) const @@ -410,7 +410,7 @@ void MvQScmProfileFilterModel::setShowEditableOnly(bool b) { showEditableOnly_ = b; - //reset(); + // reset(); beginResetModel(); endResetModel(); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQSearchLinePanel.cc metview-5.19.2/metview/src/libMvQtGui/MvQSearchLinePanel.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQSearchLinePanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQSearchLinePanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ MvQSearchLinePanel::MvQSearchLinePanel() { auto* layout = new QHBoxLayout; - //layout->setContentsMargins(0,0,0,0); + // layout->setContentsMargins(0,0,0,0); setLayout(layout); auto* closeTb = new QToolButton(this); @@ -61,7 +61,7 @@ QWidget* w = itemLayout_->currentWidget(); if (w) { - auto* item = static_cast(w); + auto* item = dynamic_cast(w); if (item) { item->slotFindNext(); } @@ -75,7 +75,7 @@ QWidget* w = itemLayout_->currentWidget(); if (w) { - auto* item = static_cast(w); + auto* item = dynamic_cast(w); if (item) { item->slotFindPrev(); } @@ -104,11 +104,11 @@ //============================================= MvQDualSearchLinePanel::MvQDualSearchLinePanel() : - currentLeftItem_(0), - currentRightItem_(0) + currentLeftItem_(nullptr), + currentRightItem_(nullptr) { auto* layout = new QHBoxLayout; - //layout->setContentsMargins(0,0,0,0); + // layout->setContentsMargins(0,0,0,0); setLayout(layout); auto* closeTb = new QToolButton(this); @@ -121,7 +121,7 @@ itemLayout_ = new QStackedLayout; - auto* label = new QLabel(tr("&Scope: "), this); + auto* label = new QLabel(tr("&Scope: "), this); searchModeCb_ = new QComboBox; label->setBuddy(searchModeCb_); @@ -146,7 +146,7 @@ layout->addWidget(searchModeCb_); layout->addSpacing(10); layout->addLayout(itemLayout_); - //layout->addSpacing(20); + // layout->addSpacing(20); connect(searchModeCb_, SIGNAL(activated(int)), this, SLOT(slotSearchModeChanged(int))); @@ -177,7 +177,7 @@ QWidget* w = itemLayout_->currentWidget(); if (w) { - auto* item = static_cast(w); + auto* item = dynamic_cast(w); if (item) { item->slotFindNext(); } @@ -191,7 +191,7 @@ QWidget* w = itemLayout_->currentWidget(); if (w) { - auto* item = static_cast(w); + auto* item = dynamic_cast(w); if (item) { item->slotFindPrev(); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQSearchLinePanel.h metview-5.19.2/metview/src/libMvQtGui/MvQSearchLinePanel.h --- metview-5.17.4/metview/src/libMvQtGui/MvQSearchLinePanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQSearchLinePanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -54,7 +54,7 @@ protected: enum SearchMode { - SearchLeftItems = 0, + SearchLeftItems = 0, SearchRightItems = 1 }; QStackedLayout* itemLayout_; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQSimpleApplication.cc metview-5.19.2/metview/src/libMvQtGui/MvQSimpleApplication.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQSimpleApplication.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQSimpleApplication.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,6 +10,7 @@ #include "MvQSimpleApplication.h" #include +#include #include #include @@ -23,10 +24,10 @@ QApplication(ac, av), MvAbstractApplication(name) { - //Init the style + // Init the style QStringList styleLst = QStyleFactory::keys(); - //Set the style + // Set the style QString style = "Plastique"; if (styleLst.contains(style)) { setStyle(style); @@ -38,7 +39,7 @@ } } - //Set fontsize if defined in env var + // Set fontsize if defined in env var if (const char* fontSizeCh = getenv("CODES_UI_FONT_SIZE")) { int fontSize = atoi(fontSizeCh); if (fontSize < 8) @@ -73,14 +74,23 @@ return false; } -void MvQSimpleApplication::writeToLog(const std::string& /*msg*/, MvLogLevel /*level*/) +void MvQSimpleApplication::writeToLog(const std::string& msg, MvLogLevel level) { + if (level != MvLogLevel::ERROR) { + std::cout << msg << std::endl; + } else { + std::cerr << msg << std::endl; + } } -void MvQSimpleApplication::writeToUiLog(const std::string& /*msg*/, MvLogLevel /*level*/, bool /*popup*/) +void MvQSimpleApplication::writeToUiLog(const std::string& msg, MvLogLevel level, bool popup) { + if (popup) { + MvQ::showMessageBox(msg, level); + } } void MvQSimpleApplication::exitWithError() { + exit(1); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQSlider.cc metview-5.19.2/metview/src/libMvQtGui/MvQSlider.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQSlider.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQSlider.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,17 +20,17 @@ } -//There is a bug in QSlider: if we click into -//the slider it does not jump into the right position but either jumps to the -//min or to the max position of the slider. It only works if we keep the mouse pressed down -//at least for 1-2 seconds!!! +// There is a bug in QSlider: if we click into +// the slider it does not jump into the right position but either jumps to the +// min or to the max position of the slider. It only works if we keep the mouse pressed down +// at least for 1-2 seconds!!! // -//To overcome this problem we needed this custom implementation of mousePressEvent! +// To overcome this problem we needed this custom implementation of mousePressEvent! void MvQSlider::mousePressEvent(QMouseEvent* event) { if (event->button() == Qt::LeftButton) { - int v; + int v = 0; if (orientation() == Qt::Vertical) { #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) v = QStyle::sliderValueFromPosition(minimum(), maximum(), height() - event->position().y(), height()); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQStackedEditor.cc metview-5.19.2/metview/src/libMvQtGui/MvQStackedEditor.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQStackedEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQStackedEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,21 +20,21 @@ QDialog(parent) { list_ = new QListWidget(this); - //list_->setFlow(QListView::LeftToRight); - //list_->setViewMode(QListView::IconMode); - //list_->setIconSize(QSize(32, 32)); - //list_->setGridSize(QSize(48, 48)); + // list_->setFlow(QListView::LeftToRight); + // list_->setViewMode(QListView::IconMode); + // list_->setIconSize(QSize(32, 32)); + // list_->setGridSize(QSize(48, 48)); list_->setMovement(QListView::Static); list_->setMaximumWidth(150); - //list_->setSpacing(5); + // list_->setSpacing(5); page_ = new QStackedWidget; /*foreach(MvQPageDefinition* p,pageLst) - { - addPage(p->widget,p->icon,p->title); - } + { + addPage(p->widget,p->icon,p->title); + } - list_->setCurrentRow(0);*/ + list_->setCurrentRow(0);*/ // Buttonbox @@ -43,24 +43,24 @@ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - //QPushButton *closePb = new QPushButton(tr("Close")); - //connect(closePb, SIGNAL(clicked()), this, SLOT(close())); + // QPushButton *closePb = new QPushButton(tr("Close")); + // connect(closePb, SIGNAL(clicked()), this, SLOT(close())); - //QHBoxLayout *horizontalLayout = new QHBoxLayout; - //horizontalLayout->addWidget(list_); - //horizontalLayout->addWidget(page_, 1); + // QHBoxLayout *horizontalLayout = new QHBoxLayout; + // horizontalLayout->addWidget(list_); + // horizontalLayout->addWidget(page_, 1); /*QHBoxLayout *buttonsLayout = new QHBoxLayout; - buttonsLayout->addStretch(1); - buttonsLayout->addWidget(closePb);*/ + buttonsLayout->addStretch(1); + buttonsLayout->addWidget(closePb);*/ auto* mainLayout = new QVBoxLayout; - auto* hb = new QHBoxLayout; + auto* hb = new QHBoxLayout; hb->addWidget(list_); hb->addWidget(page_, 1); - //mainLayout->addStretch(1); - //mainLayout->addSpacing(12); + // mainLayout->addStretch(1); + // mainLayout->addSpacing(12); mainLayout->addLayout(hb); mainLayout->addWidget(buttonBox); @@ -75,9 +75,9 @@ void MvQStackedEditor::addPage(QWidget* w, QIcon /*icon*/, QString txt) { auto* item = new QListWidgetItem(list_); - //item->setIcon(icon); + // item->setIcon(icon); item->setText(txt); - //item->setTextAlignment(Qt::AlignHCenter); + // item->setTextAlignment(Qt::AlignHCenter); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); page_->addWidget(w); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQStackedEditor.h metview-5.19.2/metview/src/libMvQtGui/MvQStackedEditor.h --- metview-5.17.4/metview/src/libMvQtGui/MvQStackedEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQStackedEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ Q_OBJECT public: - MvQStackedEditor(QString, QWidget* parent = 0); + MvQStackedEditor(QString, QWidget* parent = nullptr); public slots: void slotChangePage(QListWidgetItem* current, QListWidgetItem* previous); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQStationsWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQStationsWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQStationsWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQStationsWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ #include "MvQComboLine.h" -#include +#include #include extern "C" { @@ -49,7 +49,7 @@ char database[1024]; int blocksize = 0; /* less than 512 forces the system default */ sprintf(database, "%s-%c.db", getenv("METVIEW_STATIONS"), mode); - db = gdbm_open(database, blocksize, GDBM_READER, 0777, 0); + db = gdbm_open(database, blocksize, GDBM_READER, 0777, nullptr); if (db == nullptr) { qDebug() << "Cannot open WMO station database"; @@ -59,7 +59,7 @@ datum key = gdbm_firstkey(db); while (key.dptr != nullptr) { datum content = gdbm_fetch(db, key); - auto* sdata = new MvStationData; + auto* sdata = new MvStationData; std::memcpy(sdata, content.dptr, qMin(content.dsize, static_cast(sizeof(MvStationData)))); data_ << sdata; key = gdbm_nextkey(db, key); @@ -88,7 +88,7 @@ { if (!index.isValid() || (role != Qt::DisplayRole)) { - return QVariant(); + return {}; } MvStationData* v = data_.at(index.row()); @@ -110,7 +110,7 @@ } } - return QVariant(); + return {}; } @@ -132,7 +132,7 @@ case 4: return QObject::tr("Name"); default: - return QVariant(); + return {}; } } else if (role == Qt::ToolTipRole) { @@ -148,25 +148,25 @@ case 4: return QObject::tr("Name"); default: - return QVariant(); + return {}; } } - return QVariant(); + return {}; } QModelIndex MvQStationsModel::index(int row, int column, const QModelIndex& /*parent*/) const { if (data_.count() == 0 || column < 0) { - return QModelIndex(); + return {}; } - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } QModelIndex MvQStationsModel::parent(const QModelIndex& /*index */) const { - return QModelIndex(); + return {}; } //======================================================== @@ -179,7 +179,7 @@ QSortFilterProxyModel(parent) { #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) - filters_ << FilterDef("Name", NameMode, "", QRegularExpression(".*")) << FilterDef("Id", IdMode, "", QRegularExpression("[0-9]{1,5}")) << FilterDef("Wmo block", WmoMode, "", QRegularExpression("[0-9]{1,2}")) << FilterDef("Position", PositionMode, "Format: lat/lon/tolerance (in degrees)", QRegularExpression("\\-?[0-9]+\\.?[0-9]*/\\-?[0-9]+\\.?[0-9]*/[0-9]+\\.?[0-9]*")) << FilterDef("Area", AreaMode, "Format: N/W/S/E (in degrees)", QRegularExpression("\\-?[0-9]+\\.?[0-9]*/\\-?[0-9]+\\.?[0-9]*/\\-?[0-9]+\\.?[0-9]*/\\-?[0-9]+\\.?[0-9]*")); + filters_ << FilterDef("Name", NameMode, "", QRegularExpression(".*")) << FilterDef("Id", IdMode, "", QRegularExpression("[0-9]{1,5}")) << FilterDef("Wmo block", WmoMode, "", QRegularExpression("[0-9]{1,2}")) << FilterDef("Position", PositionMode, "Format: lat/lon/tolerance (in degrees)", QRegularExpression(R"(\-?[0-9]+\.?[0-9]*/\-?[0-9]+\.?[0-9]*/[0-9]+\.?[0-9]*)")) << FilterDef("Area", AreaMode, "Format: N/W/S/E (in degrees)", QRegularExpression(R"(\-?[0-9]+\.?[0-9]*/\-?[0-9]+\.?[0-9]*/\-?[0-9]+\.?[0-9]*/\-?[0-9]+\.?[0-9]*)")); #else filters_ << FilterDef("Name", NameMode, "", QRegExp(".*")) << FilterDef("Id", IdMode, "", QRegExp("[0-9]{1,5}")) << FilterDef("Wmo block", WmoMode, "", QRegExp("[0-9]{1,2}")) << FilterDef("Position", PositionMode, "Format: lat/lon/tolerance (in degrees)", QRegExp("\\-?[0-9]+\\.?[0-9]*/\\-?[0-9]+\\.?[0-9]*/[0-9]+\\.?[0-9]*")) << FilterDef("Area", AreaMode, "Format: N/W/S/E (in degrees)", QRegExp("\\-?[0-9]+\\.?[0-9]*/\\-?[0-9]+\\.?[0-9]*/\\-?[0-9]+\\.?[0-9]*/\\-?[0-9]+\\.?[0-9]*")); #endif @@ -317,7 +317,7 @@ tree_ = new QTreeView(this); vb->addWidget(tree_); - model_ = new MvQStationsModel(this); + model_ = new MvQStationsModel(this); sortModel_ = new MvQStationsFilterModel(this); sortModel_->setSourceModel(model_); sortModel_->setDynamicSortFilter(true); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQStyleTreeWidget.cc metview-5.19.2/metview/src/libMvQtGui/MvQStyleTreeWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQStyleTreeWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQStyleTreeWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ QFont f; QFontMetrics fm(f); textHeight_ = fm.height(); - pixHeight_ = qMax(textHeight_ + 2, 24); + pixHeight_ = qMax(textHeight_ + 2, 24); } void MvQStyleDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, @@ -47,14 +47,14 @@ painter->save(); if (index.column() == 0) { - //Background + // Background QStyleOptionViewItem vopt(option); initStyleOption(&vopt, index); - const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); + const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); const QWidget* widget = vopt.widget; - //We render everything with the default method + // We render everything with the default method style->drawControl(QStyle::CE_ItemViewItem, &vopt, painter, widget); int row = index.data(Qt::DisplayRole).toInt(); @@ -66,23 +66,23 @@ MvQStyleDbItem* item = MvQStyleDb::instance()->items()[row]; Q_ASSERT(item); - if (item) + if (item) { item->paint(painter, rect); - - QString name = item->name(); - QRect textRect = rect; - textRect.setX(rect.x() + rect.width()); - textRect.setRight(option.rect.right()); - painter->setPen(MvQTheme::text()); - painter->drawText(textRect, name, Qt::AlignLeft | Qt::AlignVCenter); + QString name = item->name(); + QRect textRect = rect; + textRect.setX(rect.x() + rect.width()); + textRect.setRight(option.rect.right()); + painter->setPen(MvQTheme::text()); + painter->drawText(textRect, name, Qt::AlignLeft | Qt::AlignVCenter); + } } else { QStyledItemDelegate::paint(painter, option, index); } - //Render the horizontal border for rows. We only render the top border line. - //With this technique we miss the bottom border line of the last row!!! - //QRect fullRect=QRect(0,option.rect.y(),painter->device()->width(),option.rect.height()); + // Render the horizontal border for rows. We only render the top border line. + // With this technique we miss the bottom border line of the last row!!! + // QRect fullRect=QRect(0,option.rect.y(),painter->device()->width(),option.rect.height()); QRect bgRect = option.rect; painter->setPen(borderCol_); painter->drawLine(bgRect.topLeft(), bgRect.topRight()); @@ -93,7 +93,7 @@ QSize MvQStyleDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { QSize s = QStyledItemDelegate::sizeHint(option, index); - return QSize(s.width(), pixHeight_); + return {s.width(), pixHeight_}; } //===================================================== @@ -105,7 +105,7 @@ MvQStyleTreeWidget::MvQStyleTreeWidget(QWidget* parent) : QWidget(parent) { - //Layout to hold tree and sidebar + // Layout to hold tree and sidebar auto* vb = new QVBoxLayout(this); vb->setContentsMargins(0, 0, 0, 0); @@ -115,7 +115,7 @@ splitter_->setChildrenCollapsible(false); vb->addWidget(splitter_); - //tree view and model + // tree view and model tree_ = new QTreeView(this); tree_->setRootIsDecorated(false); tree_->setUniformRowHeights(true); @@ -126,9 +126,9 @@ tree_->setSortingEnabled(true); tree_->sortByColumn(1, Qt::AscendingOrder); - //tree_->setModel(sortModel_); + // tree_->setModel(sortModel_); - //Tree context menu + // Tree context menu tree_->setContextMenuPolicy(Qt::ActionsContextMenu); auto* acCopyName = new QAction(this); @@ -139,7 +139,7 @@ connect(acCopyName, SIGNAL(triggered()), this, SLOT(slotCopyStyleName())); - //Tree sidebar + // Tree sidebar te_ = new QTextEdit(this); splitter_->addWidget(te_); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQTabManager.cc metview-5.19.2/metview/src/libMvQtGui/MvQTabManager.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQTabManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQTabManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,15 +42,15 @@ /*QAction* MvQTabManager::action(QWidget* w) { - int index=widget_.indexOf(w); - return action_[index]; + int index=widget_.indexOf(w); + return action_[index]; }*/ void MvQTabManager::slotChangeViewStatus(bool state) { QObject* obj = sender(); - auto* action = static_cast(obj); - int index = action_.indexOf(action); + auto* action = dynamic_cast(obj); + int index = action_.indexOf(action); if (state) { tab_->addTab(widget_[index], tr(name_[index].toStdString().c_str())); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQTextEditSearchLine.cc metview-5.19.2/metview/src/libMvQtGui/MvQTextEditSearchLine.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQTextEditSearchLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQTextEditSearchLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,13 +43,13 @@ updateButtons(true); } - //QTextDocument::FindFlags flags; + // QTextDocument::FindFlags flags; /*if(checkBox_backward->checkState() == Qt::Checked) { flags = QTextDocument::FindBackward; } - if(checkBox_case->checkState() == Qt::Checked) + if(checkBox_case->checkState() == Qt::Checked) { flags = flags | QTextDocument::FindCaseSensitively; } @@ -59,11 +59,11 @@ }*/ /*if(editor_->find(txt)) - { - //statusMessage("", 0); - } - else - { + { + //statusMessage("", 0); + } + else + { if (flags & QTextDocument::FindBackward) statusMessage(tr("Reached top of file"), 5000); else diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQTreeExpandState.cc metview-5.19.2/metview/src/libMvQtGui/MvQTreeExpandState.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQTreeExpandState.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQTreeExpandState.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,7 +41,6 @@ //========================================================== MvQTreeExpandState::MvQTreeExpandState(QTreeView* view) : - root_(nullptr), view_(view) { } @@ -56,7 +55,7 @@ if (root_) delete root_; - root_ = nullptr; + root_ = nullptr; selectionParent_ = nullptr; selectionName_.clear(); } @@ -97,9 +96,9 @@ } #endif - //If the root cannot be expanded + // If the root cannot be expanded if (view_->rootIsDecorated()) { - QModelIndex idx; //root + QModelIndex idx; // root setRoot(""); #ifdef _MVQTREEEXPANDSTATE_DEBUG qDebug() << "MvQTreeExpandState::save --> root"; @@ -107,7 +106,7 @@ saveExpand(root_, idx, selIdx); } - //TODO: implement the case when the root can be expanded + // TODO: implement the case when the root can be expanded } void MvQTreeExpandState::saveExpand(ExpandNode* parentExpand, const QModelIndex& idx, const QModelIndex& selIdx) @@ -131,7 +130,7 @@ } } -//Save the expand state for the given node (it can be a server as well) +// Save the expand state for the given node (it can be a server as well) void MvQTreeExpandState::restore() { if (!root_) diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQTreeExpandState.h metview-5.19.2/metview/src/libMvQtGui/MvQTreeExpandState.h --- metview-5.17.4/metview/src/libMvQtGui/MvQTreeExpandState.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQTreeExpandState.h 2023-07-15 08:28:47.000000000 +0000 @@ -56,8 +56,8 @@ ExpandNode* setRoot(QString); ExpandNode* root() const { return root_; } - ExpandNode* root_; - QTreeView* view_; - ExpandNode* selectionParent_; + ExpandNode* root_{nullptr}; + QTreeView* view_{nullptr}; + ExpandNode* selectionParent_{nullptr}; QString selectionName_; }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQTreeView.cc metview-5.19.2/metview/src/libMvQtGui/MvQTreeView.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQTreeView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQTreeView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,21 +43,21 @@ QString group = "treeview"; // "block" here means and item with children - textPen_ = MvQTheme::pen(group, "text"); + textPen_ = MvQTheme::pen(group, "text"); subTextPen_ = MvQTheme::pen(group, "subtext"); - selectTextPen_ = MvQTheme::pen(group, "select_text"); + selectTextPen_ = MvQTheme::pen(group, "select_text"); selectSubTextPen_ = MvQTheme::pen(group, "select_text"); - selectBrush_ = MvQTheme::brush(group, "select_brush"); + selectBrush_ = MvQTheme::brush(group, "select_brush"); selectBrushBlock_ = selectBrush_; - blockBrush_ = MvQTheme::brush(group, "block_brush"); + blockBrush_ = MvQTheme::brush(group, "block_brush"); blockTextPen_ = MvQTheme::pen(group, "block_text"); - errorSelectPen_ = MvQTheme::pen(group, "error_select_pen"); + errorSelectPen_ = MvQTheme::pen(group, "error_select_pen"); errorSelectBrush_ = MvQTheme::brush(group, "error_select_brush"); - errorBrush_ = MvQTheme::brush(group, "error_brush"); - borderPen_ = MvQTheme::pen(group, "border_pen"); + errorBrush_ = MvQTheme::brush(group, "error_brush"); + borderPen_ = MvQTheme::pen(group, "border_pen"); } void MvQTreeViewDelegate::setStyleId(int /*id*/) @@ -70,11 +70,11 @@ QStyleOptionViewItem vopt(option); initStyleOption(&vopt, index); - const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); + const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); const QWidget* widget = vopt.widget; - //This indicates that the item is a parent item, - // hence it has branch controls. + // This indicates that the item is a parent item, + // hence it has branch controls. bool hasChild = index.model()->hasChildren(index); if (!hasChild && index.column() > 0) { hasChild = index.model()->hasChildren(index.model()->index(index.row(), 0, index.parent())); @@ -83,19 +83,19 @@ bool selected = option.state & QStyle::State_Selected; bool hasError = index.data(MvQKeyProfileModel::ErrorRole).toBool(); - //Save painter state + // Save painter state painter->save(); - //The background rect + // The background rect QRect bgRect = option.rect; - //For normal items in the first column we want to extend the item - //rect to the left for the background painting. + // For normal items in the first column we want to extend the item + // rect to the left for the background painting. if (index.column() == 0 && !hasChild) { bgRect.setX(0); } - //Bg and border + // Bg and border if (hasChild) { if (selected) { QRect selectRect; @@ -107,9 +107,9 @@ } else { QRect fullRect = bgRect; - //painter->fillRect(fullRect, blockBrush_); - // painter->setPen(selectPen_); - // painter->setPen(blockBorderPen_); + // painter->fillRect(fullRect, blockBrush_); + // painter->setPen(selectPen_); + // painter->setPen(blockBorderPen_); fullRect.adjust(0, 1, 0, 0); // painter->drawLine(fullRect.topLeft(), fullRect.topRight()); // painter->drawLine(fullRect.bottomLeft(), fullRect.bottomRight()); @@ -119,23 +119,23 @@ } else { if (selected) { - //The selection rect + // The selection rect QRect selectRect; selectRect = bgRect.adjusted(0, 1, 0, 0); - //For the first column we extend the selection - //rect to left edge. + // For the first column we extend the selection + // rect to left edge. if (index.column() == 0) { selectRect.setX(0); } if (hasError) { painter->fillRect(selectRect, errorSelectBrush_); - //painter->setPen(errorSelectPen_); + // painter->setPen(errorSelectPen_); } else { painter->fillRect(selectRect, selectBrush_); - //painter->setPen(selectPen_); + // painter->setPen(selectPen_); } // painter->drawLine(selectRect.topLeft(), selectRect.topRight()); // painter->drawLine(selectRect.bottomLeft(), selectRect.bottomRight()); @@ -153,8 +153,8 @@ } } - //Render the horizontal border for rows. We only render the top border line. - //With this technique we miss the bottom border line of the last row!!! + // Render the horizontal border for rows. We only render the top border line. + // With this technique we miss the bottom border line of the last row!!! painter->setPen(borderPen_); if (index.column() != 0) painter->drawLine(bgRect.topLeft(), bgRect.topRight()); @@ -162,8 +162,8 @@ painter->drawLine(QPoint(0, bgRect.y()), bgRect.topRight()); } - //Display text - QString text = index.data(Qt::DisplayRole).toString(); + // Display text + QString text = index.data(Qt::DisplayRole).toString(); bool useSubText = index.data(MvQKeyProfileModel::SubTextRole).toBool(); if (text.isEmpty() == false) { QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &vopt, widget); @@ -200,7 +200,7 @@ painter->drawText(textRect.adjusted(2, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, text); } - //Restore painter state + // Restore painter state painter->restore(); } @@ -215,16 +215,16 @@ QTreeView(parent) { activatedByKeyNavigation_ = false; - columnToDrag_ = 0; + columnToDrag_ = 0; if (useDelegate) { //!!!!We need to do it because: - //The background colour between the view's left border and the nodes cannot be - //controlled by delegates or stylesheets. It always takes the QPalette::Highlight - //colour from the palette. Here we set this to transparent so that Qt could leave - //this area empty and we will fill it appropriately in our delegate. + // The background colour between the view's left border and the nodes cannot be + // controlled by delegates or stylesheets. It always takes the QPalette::Highlight + // colour from the palette. Here we set this to transparent so that Qt could leave + // this area empty and we will fill it appropriately in our delegate. QPalette pal = palette(); - pal.setColor(QPalette::Highlight, QColor(128, 128, 128, 0)); //Qt::transparent); + pal.setColor(QPalette::Highlight, QColor(128, 128, 128, 0)); // Qt::transparent); setPalette(pal); delegate_ = new MvQTreeViewDelegate(this); @@ -279,24 +279,24 @@ return (dragDropMode() != DragOnly && dragDropMode() != NoDragDrop); } -//We do not want to render the branches for the variable items. We only -//render the branch for the group items (nodes or server). +// We do not want to render the branches for the variable items. We only +// render the branch for the group items (nodes or server). void MvQTreeView::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const { if (delegate_) { if (index.model()->hasChildren(index) && index.column() == 0) { - //We need to fill the branch area here. We cannot do it in the delegate - //because when the delegate is called the branch control is already + // We need to fill the branch area here. We cannot do it in the delegate + // because when the delegate is called the branch control is already if (selectionModel()->rowIntersectsSelection(index.row(), index.parent())) { painter->fillRect(rect.adjusted(0, 1, 0, -1), delegate_->selectBrushBlock_); } else { - //painter->fillRect(rect.adjusted(0,1,0,0),index.data(Qt::BackgroundRole).value()); - //painter->fillRect(rect.adjusted(0,1,0,0) + // painter->fillRect(rect.adjusted(0,1,0,0),index.data(Qt::BackgroundRole).value()); + // painter->fillRect(rect.adjusted(0,1,0,0) } - //Draw the branch with the default method + // Draw the branch with the default method QTreeView::drawBranches(painter, rect, index); } } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQTreeView.h metview-5.19.2/metview/src/libMvQtGui/MvQTreeView.h --- metview-5.17.4/metview/src/libMvQtGui/MvQTreeView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQTreeView.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,10 +24,10 @@ explicit MvQTreeViewDelegate(QTreeView* parent); void setStyleId(int id); void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; + const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; -protected: +private: void setColours(); QPen textPen_; @@ -52,7 +52,7 @@ public: MvQTreeView(QWidget* parent = nullptr, bool useDelegate = false); void setStyleId(int); - void keyboardSearch(const QString&); + void keyboardSearch(const QString&) override; void setActvatedByKeyNavigation(bool b) { activatedByKeyNavigation_ = b; } void setColumnToDrag(int i) { columnToDrag_ = i; } @@ -60,9 +60,9 @@ void selectionChanged(const QModelIndex&); protected: - void keyReleaseEvent(QKeyEvent*); - void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected); - void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const; + void keyReleaseEvent(QKeyEvent*) override; + void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override; + void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const override; bool dragEnabled(); bool dropEnabled(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQTreeViewSearchLine.cc metview-5.19.2/metview/src/libMvQtGui/MvQTreeViewSearchLine.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQTreeViewSearchLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQTreeViewSearchLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,9 @@ AbstractSearchLine(parent) { label_->hide(); - //closeTb_->hide(); + // closeTb_->hide(); - //It makes no sense for a tree + // It makes no sense for a tree actionHighlightAll_->setEnabled(false); collector_ = new TreeModelMatchCollector; @@ -40,24 +40,24 @@ delete collector_; } -//This should only be called once!! +// This should only be called once!! void TreeViewSearchLine::setView(QTreeView* view) { - //We should disconnect from the previous view ... + // We should disconnect from the previous view ... view_ = view; - //We detect when the sorting changes in the view + // We detect when the sorting changes in the view connect(view_->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(slotSortHappened(int, Qt::SortOrder))); - //At this point the model has to be set on the view!!! + // At this point the model has to be set on the view!!! assert(view_->model() != nullptr); - //We detect when the model is reset + // We detect when the model is reset connect(view_->model(), SIGNAL(modelReset()), this, SLOT(slotUpdate())); - //We should detect when the model changes!!!! + // We should detect when the model changes!!!! connect(view_->model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(slotUpdate(QModelIndex, QModelIndex))); @@ -82,7 +82,7 @@ if (!view_) return; - //If the search term is empty we just clear everything + // If the search term is empty we just clear everything if (txt.simplified().isEmpty()) { collector_->clear(); currentResultItem_ = 0; @@ -92,7 +92,7 @@ QModelIndex current = view_->currentIndex(); - //Set the match flags + // Set the match flags Qt::MatchFlags flags = Qt::MatchRecursive; if (caseSensitive()) flags = flags | Qt::MatchCaseSensitive; @@ -111,12 +111,12 @@ #endif } - //Get the matching indexes. - //QAbstractItemModel::match() does not work properly. Even if MatchRecursive - //is set it only searches in the current branch!! + // Get the matching indexes. + // QAbstractItemModel::match() does not work properly. Even if MatchRecursive + // is set it only searches in the current branch!! collector_->match(txt, columns_, flags, current); - //The view needs to be rerendered! + // The view needs to be rerendered! view_->dataChanged(QModelIndex(), QModelIndex()); if (collector_->itemCount() > 0) { @@ -140,8 +140,8 @@ if (status_ == true && collector_->items().count() > 0) { if (currentResultItem_ >= 0 && collector_->items()[currentResultItem_] != view_->currentIndex()) { - //This will find the one after the currentIdex! So we can - //return here. + // This will find the one after the currentIdex! So we can + // return here. currentResultItem_ = -1; collector_->clear(); slotFind(searchLine_->text()); @@ -164,8 +164,8 @@ if (status_ == true && collector_->items().count() > 0) { if (currentResultItem_ >= 0 && collector_->items()[currentResultItem_] != view_->currentIndex()) { - //This will find the one after the currentIdex! - //So we need to step back. + // This will find the one after the currentIdex! + // So we need to step back. currentResultItem_ = -1; collector_->clear(); slotFind(searchLine_->text()); @@ -186,10 +186,10 @@ view_->setCurrentIndex(index); view_->scrollTo(index); - //emit indexSelected(index); + // emit indexSelected(index); } -//Called when sorting changed in the view +// Called when sorting changed in the view void TreeViewSearchLine::slotSortHappened(int, Qt::SortOrder) { slotUpdate(); @@ -239,5 +239,5 @@ clear(); collector_->clear(); currentResultItem_ = -1; - //clearHighlights(); + // clearHighlights(); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQTreeViewSearchLine.h metview-5.19.2/metview/src/libMvQtGui/MvQTreeViewSearchLine.h --- metview-5.17.4/metview/src/libMvQtGui/MvQTreeViewSearchLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQTreeViewSearchLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,23 +22,23 @@ public: explicit TreeViewSearchLine(QWidget* parent); - ~TreeViewSearchLine(); + ~TreeViewSearchLine() override; void setView(QTreeView* view); void setColumns(QVector columns); public Q_SLOTS: - void slotFind(QString); - void slotFindNext(); - void slotFindPrev(); + void slotFind(QString) override; + void slotFindNext() override; + void slotFindPrev() override; void slotFindNext(bool) { slotFindNext(); } void slotFindPrev(bool) { slotFindPrev(); } void slotSortHappened(int, Qt::SortOrder); void slotUpdate(); void slotUpdate(const QModelIndex&, const QModelIndex&); void matchModeChanged(int newIndex); - void on_actionCaseSensitive__toggled(bool); - void on_actionWholeWords__toggled(bool); - void slotClose(); + void on_actionCaseSensitive__toggled(bool) override; + void on_actionWholeWords__toggled(bool) override; + void slotClose() override; protected: void refreshSearch(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/MvQWebViewSearchLine.cc metview-5.19.2/metview/src/libMvQtGui/MvQWebViewSearchLine.cc --- metview-5.17.4/metview/src/libMvQtGui/MvQWebViewSearchLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/MvQWebViewSearchLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ { QWebPage::FindFlags flags = QWebPage::FindWrapsAroundDocument; updateButtons(view_->findText(txt, flags)); - //keep the search term + // keep the search term txt_ = txt; } diff -Nru metview-5.17.4/metview/src/libMvQtGui/OutputBrowser.cc metview-5.19.2/metview/src/libMvQtGui/OutputBrowser.cc --- metview-5.17.4/metview/src/libMvQtGui/OutputBrowser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/OutputBrowser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,8 @@ #include "TextPagerSearchInterface.hpp" #include "TextPagerWidget.hpp" -int OutputBrowser::minPagerTextSize_ = 1 * 1024 * 1024; -int OutputBrowser::minPagerSparseSize_ = 30 * 1024 * 1024; +int OutputBrowser::minPagerTextSize_ = 1 * 1024 * 1024; +int OutputBrowser::minPagerSparseSize_ = 30 * 1024 * 1024; int OutputBrowser::minConfirmSearchSize_ = 5 * 1024 * 1024; OutputBrowser::OutputBrowser(QWidget* parent) : @@ -42,7 +42,7 @@ searchLine_ = new TextEditSearchLine(this); vb->addWidget(searchLine_); - //Basic textedit + // Basic textedit textEdit_ = new PlainTextEdit(this); textEdit_->setReadOnly(true); textEdit_->setWordWrapMode(QTextOption::NoWrap); @@ -50,14 +50,14 @@ textEditSearchInterface_ = new PlainTextSearchInterface(); textEditSearchInterface_->setEditor(textEdit_); - //This highlighter only works for jobs + // This highlighter only works for jobs #if 0 jobHighlighter_=new Highlighter(textEdit_->document(),"job"); jobHighlighter_->setDocument(nullptr); #endif - //Pager for very large files + // Pager for very large files textPager_ = new TextPagerWidget(this); - //textEdit_->setReadOnly(true); + // textEdit_->setReadOnly(true); textPagerSearchInterface_ = new TextPagerSearchInterface(); textPagerSearchInterface_->setEditor(textPager_->textEditor()); @@ -107,8 +107,8 @@ stacked_->setCurrentIndex(indexType); searchLine_->setConfirmSearch(false); searchLine_->setSearchInterface(textEditSearchInterface_); - //confirmSearchLabel_->clear(); - //confirmSearchLabel_->hide(); + // confirmSearchLabel_->clear(); + // confirmSearchLabel_->hide(); textPager_->clear(); } @@ -116,8 +116,8 @@ stacked_->setCurrentIndex(indexType); searchLine_->setConfirmSearch(fileSize >= minConfirmSearchSize_); searchLine_->setSearchInterface(textPagerSearchInterface_); - //confirmSearchLabel_->show(); - //confirmSearchLabel_->showWarning(searchLine_->confirmSearchText()); + // confirmSearchLabel_->show(); + // confirmSearchLabel_->showWarning(searchLine_->confirmSearchText()); textEdit_->clear(); } @@ -179,7 +179,7 @@ file_.reset(); #endif - //We estimate the size in bytes + // We estimate the size in bytes qint64 txtSize = txt.size() * 2; if (!isJobFile(fileName) && txtSize > minPagerTextSize_) { @@ -192,7 +192,7 @@ textEdit_->document()->setPlainText(txt); } - //Set the cursor position from the cache + // Set the cursor position from the cache updateCursorFromCache(fileName.toStdString()); } @@ -283,7 +283,7 @@ { if (searchLine_->isVisible() && searchLine_->confirmSearch()) { confirmSearchLabel_->showWarning(searchLine_->confirmSearchText()); - //confirmSearchLabel_->show(); + // confirmSearchLabel_->show(); } else { confirmSearchLabel_->hide(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/OutputBrowser.h metview-5.19.2/metview/src/libMvQtGui/OutputBrowser.h --- metview-5.17.4/metview/src/libMvQtGui/OutputBrowser.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/OutputBrowser.h 2023-07-15 08:28:47.000000000 +0000 @@ -48,10 +48,10 @@ public: explicit OutputBrowser(QWidget* parent); - ~OutputBrowser(); + ~OutputBrowser() override; void clear(); - //void loadFile(VFile_ptr file); + // void loadFile(VFile_ptr file); void loadText(QString text, QString fileName, bool resetFile = true); void adjustHighlighter(QString fileName); void setFontProperty(MvQProperty* p); @@ -89,8 +89,8 @@ TextPagerSearchInterface* textPagerSearchInterface_; MessageLabel* confirmSearchLabel_; - //we keep a reference to it to make sure that it does not get deleted while - //it is being displayed + // we keep a reference to it to make sure that it does not get deleted while + // it is being displayed #if 0 VFile_ptr file_; #endif diff -Nru metview-5.17.4/metview/src/libMvQtGui/PlainTextEdit.cc metview-5.19.2/metview/src/libMvQtGui/PlainTextEdit.cc --- metview-5.17.4/metview/src/libMvQtGui/PlainTextEdit.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PlainTextEdit.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ showLineNum_(true), rightMargin_(2), hyperlinkEnabled_(false), - gotoLineDialog_(0), + gotoLineDialog_(nullptr), fontProp_(nullptr) { setColours(); @@ -75,11 +75,11 @@ void PlainTextEdit::setColours() { - QString group = "textedit"; - numAreaBgCol_ = MvQTheme::colour(group, "linenum_bg"); - numAreaFontCol_ = MvQTheme::colour(group, "linenum_text"); + QString group = "textedit"; + numAreaBgCol_ = MvQTheme::colour(group, "linenum_bg"); + numAreaFontCol_ = MvQTheme::colour(group, "linenum_text"); numAreaSeparatorCol_ = MvQTheme::colour(group, "linenum_separator"); - numAreaCurrentCol_ = MvQTheme::colour(group, "linenum_current_text"); + numAreaCurrentCol_ = MvQTheme::colour(group, "linenum_current_text"); } void PlainTextEdit::setHyperlinkEnabled(bool h) @@ -107,8 +107,8 @@ const QTextCursor cursor = textCursor(); QTextBlock cb, b; - int column, line = 1; - cb = cursor.block(); + int column = 0, line = 1; + cb = cursor.block(); column = (cursor.position() - cb.position()) + 1; // find the line number - is there a better way than this? @@ -132,7 +132,7 @@ QChar PlainTextEdit::characterBehindCursor(QTextCursor* cursor) { QTextCursor docTextCursor = textCursor(); - QTextCursor* theCursor = (cursor == 0) ? &docTextCursor : cursor; + QTextCursor* theCursor = (cursor == nullptr) ? &docTextCursor : cursor; return document()->characterAt(theCursor->position() - 1); } @@ -145,13 +145,13 @@ int PlainTextEdit::numLinesSelected() { QTextCursor cursor = textCursor(); // get the document's cursor - int selStart = cursor.selectionStart(); - int selEnd = cursor.selectionEnd(); - QTextBlock bStart = document()->findBlock(selStart); - QTextBlock bEnd = document()->findBlock(selEnd); - int lineStart = bStart.firstLineNumber(); - int lineEnd = bEnd.firstLineNumber(); - int numLines = (lineEnd - lineStart) + 1; + int selStart = cursor.selectionStart(); + int selEnd = cursor.selectionEnd(); + QTextBlock bStart = document()->findBlock(selStart); + QTextBlock bEnd = document()->findBlock(selEnd); + int lineStart = bStart.firstLineNumber(); + int lineEnd = bEnd.firstLineNumber(); + int numLines = (lineEnd - lineStart) + 1; return numLines; } @@ -166,7 +166,7 @@ { if (showLineNumbers()) { int digits = 1; - int max = qMax(1, blockCount()); + int max = qMax(1, blockCount()); while (max >= 10) { max /= 10; ++digits; @@ -257,7 +257,7 @@ void PlainTextEdit::lineNumberAreaPaintEvent(QPaintEvent* event) { - int currentRow, currentCol; + int currentRow = 0, currentCol = 0; cursorRowCol(¤tRow, ¤tCol); // get the current line number so we can highlight it @@ -268,13 +268,13 @@ painter.drawLine(event->rect().topRight(), event->rect().bottomRight()); QTextBlock block = firstVisibleBlock(); - int blockNumber = block.blockNumber(); - int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top(); - int bottom = top + (int)blockBoundingRect(block).height(); + int blockNumber = block.blockNumber(); + int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top(); + int bottom = top + (int)blockBoundingRect(block).height(); QFont fontNormal(font()); // the font to use for most line numbers QFont fontBold(fontNormal); // the font to use for the current line number fontBold.setBold(true); - //painter.setPen(Qt::blue); + // painter.setPen(Qt::blue); painter.setPen(numAreaFontCol_); painter.setFont(fontNormal); @@ -286,7 +286,7 @@ if (blockNumber == currentRow - 1) // is this the current line? { // painter.setFont(fontBold); - //painter.fillRect(0, top, lineNumArea_->width() - rightMargin_, fontMetrics().height(), numAreaCurrentCol_); // highlight the background + // painter.fillRect(0, top, lineNumArea_->width() - rightMargin_, fontMetrics().height(), numAreaCurrentCol_); // highlight the background painter.setPen(numAreaCurrentCol_); } @@ -300,8 +300,8 @@ } } - block = block.next(); - top = bottom; + block = block.next(); + top = bottom; bottom = top + (int)blockBoundingRect(block).height(); ++blockNumber; } @@ -312,18 +312,18 @@ bool PlainTextEdit::findString(const QString& s, QTextDocument::FindFlags flags, bool replace, const QString& r) { - lastFindString_ = s; // store for repeat searches - lastFindFlags_ = flags; // store for repeat searches - bool found = false; + lastFindString_ = s; // store for repeat searches + lastFindFlags_ = flags; // store for repeat searches + bool found = false; if (find(s, flags)) // find and select the string - were we successful? { - //statusMessage("", 0); + // statusMessage("", 0); found = true; } else // did not find the string { - if (1) // 'wraparound' search - on by default, we can add a user option if it might be useful to turn it off + if (true) // 'wraparound' search - on by default, we can add a user option if it might be useful to turn it off { QTextCursor original_cursor = textCursor(); // get the document's cursor QTextCursor cursor(original_cursor); @@ -337,7 +337,7 @@ if (find(s, flags)) // search again, from the new position { - //statusMessage("", 0); + // statusMessage("", 0); found = true; } else { @@ -363,7 +363,7 @@ } else { - //statusMessage(tr("Searched whole file, string not found"), 5000); + // statusMessage(tr("Searched whole file, string not found"), 5000); } return found; @@ -445,8 +445,8 @@ if (font().pointSize() != fps) fontSizeChangedByZoom(); } - //For readOnly document the zoom does not work so we - //need this custom code! + // For readOnly document the zoom does not work so we + // need this custom code! else { if (event->modifiers() & Qt::ControlModifier) { auto delta = event->angleDelta(); @@ -541,7 +541,7 @@ if ((e->button() & Qt::LeftButton) && !currentLink_.isEmpty()) { if (currentLink_ == anchorAt(e->pos())) { Q_EMIT hyperlinkActivated(currentLink_); - //UserMessage::debug(std::string("clicked:") + currentLink_.toStdString()); + // UserMessage::debug(std::string("clicked:") + currentLink_.toStdString()); } } } diff -Nru metview-5.17.4/metview/src/libMvQtGui/PlainTextEdit.h metview-5.19.2/metview/src/libMvQtGui/PlainTextEdit.h --- metview-5.17.4/metview/src/libMvQtGui/PlainTextEdit.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PlainTextEdit.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,8 @@ Q_OBJECT public: - explicit PlainTextEdit(QWidget* parent = 0); - ~PlainTextEdit(); + explicit PlainTextEdit(QWidget* parent = nullptr); + ~PlainTextEdit() override; void lineNumberAreaPaintEvent(QPaintEvent* event); int lineNumberAreaWidth(); @@ -31,14 +31,14 @@ void setShowLineNumbers(bool b); void cursorRowCol(int* row, int* col); - QChar characterBehindCursor(QTextCursor* cursor = 0); + QChar characterBehindCursor(QTextCursor* cursor = nullptr); int numLinesSelected(); bool findString(const QString&, QTextDocument::FindFlags, bool replace = false, const QString& r = emptyString_); void setFontProperty(MvQProperty* p); void updateFont(); - void notifyChange(MvQProperty* p); + void notifyChange(MvQProperty* p) override; bool isHyperlinkEnabled() { return hyperlinkEnabled_; } void setHyperlinkEnabled(bool h); @@ -59,13 +59,13 @@ void hyperlinkActivated(QString link); protected: - void resizeEvent(QResizeEvent* event); - void focusInEvent(QFocusEvent* event); - void focusOutEvent(QFocusEvent* event); - void wheelEvent(QWheelEvent* event); - void mousePressEvent(QMouseEvent* e); - void mouseReleaseEvent(QMouseEvent* e); - void mouseMoveEvent(QMouseEvent* e); + void resizeEvent(QResizeEvent* event) override; + void focusInEvent(QFocusEvent* event) override; + void focusOutEvent(QFocusEvent* event) override; + void wheelEvent(QWheelEvent* event) override; + void mousePressEvent(QMouseEvent* e) override; + void mouseReleaseEvent(QMouseEvent* e) override; + void mouseMoveEvent(QMouseEvent* e) override; private: void fontSizeChangedByZoom(); @@ -94,10 +94,10 @@ public: explicit LineNumberArea(PlainTextEdit* editor) : QWidget(editor) { textEditor = editor; } - QSize sizeHint() const { return QSize(textEditor->lineNumberAreaWidth(), 0); } + QSize sizeHint() const override { return {textEditor->lineNumberAreaWidth(), 0}; } protected: - void paintEvent(QPaintEvent* event) { textEditor->lineNumberAreaPaintEvent(event); } + void paintEvent(QPaintEvent* event) override { textEditor->lineNumberAreaPaintEvent(event); } private: PlainTextEdit* textEditor; diff -Nru metview-5.17.4/metview/src/libMvQtGui/PlainTextSearchInterface.cc metview-5.19.2/metview/src/libMvQtGui/PlainTextSearchInterface.cc --- metview-5.17.4/metview/src/libMvQtGui/PlainTextSearchInterface.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PlainTextSearchInterface.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,7 +41,7 @@ QList extraSelections; - bool found = false; + bool found = false; bool keepGoing = true; int numMatches = 0; @@ -51,7 +51,7 @@ switch (matchMode) { case StringMatchMode::ContainsMatch: { cursor = editor_->document()->find(str, cursor, flags); // perform the search - found = (!cursor.isNull()); + found = (!cursor.isNull()); break; } case StringMatchMode::WildcardMatch: { @@ -66,7 +66,7 @@ regexp.setCaseSensitivity(cs); #endif cursor = editor_->document()->find(regexp, cursor, flags); // perform the search - found = (!cursor.isNull()); + found = (!cursor.isNull()); break; } case StringMatchMode::RegexpMatch: { @@ -79,7 +79,7 @@ regexp.setCaseSensitivity(cs); #endif cursor = editor_->document()->find(regexp, cursor, flags); // perform the search - found = (!cursor.isNull()); + found = (!cursor.isNull()); break; } @@ -128,9 +128,9 @@ if (highlightAll) { - //char num[64]; - //sprintf(num, "%d", numMatches); - //UserMessage::message(UserMessage::DBG, false," highlighting : " + std::string(num)); + // char num[64]; + // sprintf(num, "%d", numMatches); + // UserMessage::message(UserMessage::DBG, false," highlighting : " + std::string(num)); editor_->setExtraSelections(extraSelections); } @@ -153,7 +153,7 @@ QTextCursor::MoveOperation move; if (searchFrom == "bottom") { findFlags = QTextDocument::FindBackward; - move = QTextCursor::End; + move = QTextCursor::End; } else { move = QTextCursor::Start; diff -Nru metview-5.17.4/metview/src/libMvQtGui/PlainTextSearchInterface.h metview-5.19.2/metview/src/libMvQtGui/PlainTextSearchInterface.h --- metview-5.17.4/metview/src/libMvQtGui/PlainTextSearchInterface.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PlainTextSearchInterface.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,15 +21,15 @@ void setEditor(QPlainTextEdit* e) { editor_ = e; } bool findString(QString str, bool highlightAll, QTextDocument::FindFlags findFlags, - QTextCursor::MoveOperation move, int iteration, StringMatchMode::Mode matchMode); + QTextCursor::MoveOperation move, int iteration, StringMatchMode::Mode matchMode) override; - void automaticSearchForKeywords(bool); - void refreshSearch(); - void clearHighlights(); - void disableHighlights(); - void enableHighlights() {} - bool highlightsNeedSearch() { return true; } - void gotoLastLine(); + void automaticSearchForKeywords(bool) override; + void refreshSearch() override; + void clearHighlights() override; + void disableHighlights() override; + void enableHighlights() override {} + bool highlightsNeedSearch() override { return true; } + void gotoLastLine() override; protected: QPlainTextEdit* editor_; diff -Nru metview-5.17.4/metview/src/libMvQtGui/PlainTextSearchLine.cc metview-5.19.2/metview/src/libMvQtGui/PlainTextSearchLine.cc --- metview-5.17.4/metview/src/libMvQtGui/PlainTextSearchLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PlainTextSearchLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,7 +10,7 @@ #include "PlainTextSearchLine.h" #include "PlainTextSearchInterface.h" -#include +#include PlainTextSearchLine::PlainTextSearchLine(QWidget* parent) : TextEditSearchLine(parent) diff -Nru metview-5.17.4/metview/src/libMvQtGui/PlainTextSearchLine.h metview-5.19.2/metview/src/libMvQtGui/PlainTextSearchLine.h --- metview-5.17.4/metview/src/libMvQtGui/PlainTextSearchLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PlainTextSearchLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,11 +19,11 @@ class PlainTextSearchLine : public TextEditSearchLine { public: - explicit PlainTextSearchLine(QWidget* parent = 0); - ~PlainTextSearchLine(); + explicit PlainTextSearchLine(QWidget* parent = nullptr); + ~PlainTextSearchLine() override; void setEditor(QPlainTextEdit*); private: - //The interface is set internally + // The interface is set internally void setSearchInterface(AbstractTextSearchInterface*) {} }; diff -Nru metview-5.17.4/metview/src/libMvQtGui/PlainTextWidget.cc metview-5.19.2/metview/src/libMvQtGui/PlainTextWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/PlainTextWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PlainTextWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -50,7 +50,7 @@ void PlainTextWidget::removeSpacer() { - //Remove the first spcer item!! + // Remove the first spcer item!! for (int i = 0; horizontalLayout->count(); i++) { if (QSpacerItem* sp = horizontalLayout->itemAt(i)->spacerItem()) { horizontalLayout->takeAt(i); @@ -74,13 +74,13 @@ void PlainTextWidget::on_fontSizeUpTb__clicked() { - //We need to call a custom slot here instead of "zoomIn"!!! + // We need to call a custom slot here instead of "zoomIn"!!! textEdit_->slotZoomIn(); } void PlainTextWidget::on_fontSizeDownTb__clicked() { - //We need to call a custom slot here instead of "zoomOut"!!! + // We need to call a custom slot here instead of "zoomOut"!!! textEdit_->slotZoomOut(); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/PlainTextWidget.h metview-5.19.2/metview/src/libMvQtGui/PlainTextWidget.h --- metview-5.17.4/metview/src/libMvQtGui/PlainTextWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PlainTextWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,8 @@ Q_OBJECT public: - explicit PlainTextWidget(QWidget* parent = 0); - ~PlainTextWidget(); + explicit PlainTextWidget(QWidget* parent = nullptr); + ~PlainTextWidget() override; PlainTextEdit* editor() const; MessageLabel* messageLabel() const; diff -Nru metview-5.17.4/metview/src/libMvQtGui/PropertyLineEditor.cc metview-5.19.2/metview/src/libMvQtGui/PropertyLineEditor.cc --- metview-5.17.4/metview/src/libMvQtGui/PropertyLineEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PropertyLineEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -54,10 +54,10 @@ case MvQProperty::LabelGui: return new EditLabelLine(prop, grid_, hdr, parent_); default: - return 0; + return nullptr; } - return 0; + return nullptr; } @@ -65,7 +65,7 @@ QWidget(parent), expanded_(true), needRepaint_(true), - groupProp_(0), + groupProp_(nullptr), title_(name) { Q_ASSERT(parent); @@ -89,9 +89,9 @@ expandTb_->setProperty("lineEditHeader", "1"); closeIcon_ = QPixmap(":/examiner/block_close.svg"); - openIcon_ = QPixmap(":/examiner/block_open.svg"); + openIcon_ = QPixmap(":/examiner/block_open.svg"); - //by default everything is open + // by default everything is open expandTb_->setIcon(closeIcon_); connect(expandTb_, SIGNAL(clicked()), @@ -115,7 +115,7 @@ QFont f; QFontMetrics fm(f); - int h = 10; //fm.height()-2; + int h = 10; // fm.height()-2; expandTb_->setIconSize(QSize(h, h)); clearTb_->setIconSize(QSize(h, h)); @@ -127,12 +127,12 @@ connect(this, SIGNAL(needRepaint()), parent, SLOT(delayedForceRepaint())); - //label_->setFixedHeight(fm.height()+4); + // label_->setFixedHeight(fm.height()+4); } void EditLineHeader::init() { - //slotExpand(); + // slotExpand(); } void EditLineHeader::addLine(EditLine* line) @@ -255,10 +255,10 @@ EditLine::EditLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent) : prop_(prop), parentWidget_(parent), - resetTb_(0), - nameLabel_(0), - helpTb_(0), - suffixLabel_(0), + resetTb_(nullptr), + nameLabel_(nullptr), + helpTb_(nullptr), + suffixLabel_(nullptr), row_(-1), visible_(true), hiddenByRule_(false) @@ -266,7 +266,7 @@ Q_ASSERT(prop_); QString tooltip = prop->param("tooltip"); - name_ = prop->param("label"); + name_ = prop->param("label"); if (!name_.isEmpty()) { nameLabel_ = new QLabel(name_, parent); nameLabel_->setProperty("lineEdit", "1"); @@ -285,9 +285,9 @@ } row_ = grid->rowCount(); - //QSpacerItem *spItem=new QSpacerItem(2,0, - // QSizePolicy::Fixed,QSizePolicy::Preferred); - //grid->addItem(spItem,row_,SpacerColumn); + // QSpacerItem *spItem=new QSpacerItem(2,0, + // QSizePolicy::Fixed,QSizePolicy::Preferred); + // grid->addItem(spItem,row_,SpacerColumn); if (resetTb_) grid->addWidget(resetTb_, row_, ResetColumn); @@ -345,17 +345,17 @@ void EditLine::setLabelBold(bool b) { - //return; + // return; if (!nameLabel_) return; if (b) { nameLabel_->setText("" + name_ + ""); - //nameLabel_->setStyleSheet(boldNameLabelSh_); + // nameLabel_->setStyleSheet(boldNameLabelSh_); } else { nameLabel_->setText(name_); - //nameLabel_->setStyleSheet(normalNameLabelSh_); + // nameLabel_->setStyleSheet(normalNameLabelSh_); } } @@ -392,7 +392,7 @@ for (const auto& coVal : coVals) { lst << QString::fromStdString(coVal); } - le->setCompleter(0); + le->setCompleter(nullptr); le->setCompleter(new QCompleter(lst, le)); } @@ -416,7 +416,7 @@ } } - le->setCompleter(0); + le->setCompleter(nullptr); le->setCompleter(new QCompleter(lst, le)); } @@ -527,7 +527,7 @@ EditDateLine::EditDateLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent) : EditLine(prop, grid, header, parent), - cal_(0) + cal_(nullptr) { helpTb_ = new QToolButton(parent); helpTb_->setToolTip("Choose date from calendar"); @@ -553,7 +553,7 @@ QString tooltip = prop->param("tooltip"); le_->setToolTip(tooltip); - //le_->setPlaceholderText("ANY (format YYYYMMDD)"); + // le_->setPlaceholderText("ANY (format YYYYMMDD)"); #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) le_->setClearButtonEnabled(true); #endif @@ -593,8 +593,8 @@ { if (!cal_) { cal_ = new CalendarDialog(parentWidget_); - //cal_->move(helpTb_->pos()+QPoint(helpTb_->size().width(),helpTb_->size().height())); - //cal_->resize(QSize(300,300)); + // cal_->move(helpTb_->pos()+QPoint(helpTb_->size().width(),helpTb_->size().height())); + // cal_->resize(QSize(300,300)); cal_->setModal(true); connect(cal_, SIGNAL(dateSelected(QDate)), this, SLOT(slotDateSelected(QDate))); @@ -637,7 +637,7 @@ EditLine(prop, grid, header, parent) { le_ = new QLineEdit(parent); - //le_->setPlaceholderText("ANY (format hh[:mm[:ss])"); + // le_->setPlaceholderText("ANY (format hh[:mm[:ss])"); #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) le_->setClearButtonEnabled(true); #endif @@ -678,7 +678,7 @@ EditAreaLine::EditAreaLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent) : EditLine(prop, grid, header, parent) { - w_ = new QWidget(parent); + w_ = new QWidget(parent); nLe_ = new QLineEdit(w_); wLe_ = new QLineEdit(w_); sLe_ = new QLineEdit(w_); @@ -779,7 +779,7 @@ Q_ASSERT(row_ > -1); grid->addWidget(cb_, row_, WidgetColumn); - QStringList lst = prop_->param("values_label").split("/"); + QStringList lst = prop_->param("values_label").split("/"); QStringList lstData = prop_->param("values").split("/"); if (prop_->param("values_label").simplified().isEmpty()) lst = lstData; @@ -789,7 +789,7 @@ cb_->addItem(lst[i], lstData[i]); } - //Add separators + // Add separators QStringList sepLst = prop_->param("separator").split("/"); for (int i = 0; i < sepLst.count(); i++) { QString sepKey = sepLst[i].simplified(); @@ -801,7 +801,7 @@ } } - //Set combo to default value + // Set combo to default value if (prop_->defaultValue().isValid()) { int idx = cb_->findData(prop_->defaultValue().toString()); if (idx >= 0) { @@ -810,7 +810,7 @@ } } - //le_->setPlaceholderText(prop_->defaultValue().toString()); + // le_->setPlaceholderText(prop_->defaultValue().toString()); connect(cb_, SIGNAL(currentTextChanged(QString)), this, SLOT(currentChanged(QString))); @@ -832,7 +832,7 @@ if (idx != -1) { return cb_->itemData(idx).toString(); } - return QString(); + return {}; } void EditComboLine::currentChanged(QString) @@ -870,7 +870,7 @@ { Q_ASSERT(prop_); - //Minimum + // Minimum QString sval = prop_->param("minimum").simplified(); if (!sval.isEmpty()) { int ival = sval.toInt(); @@ -878,7 +878,7 @@ minimum_ = ival; } - //Maximum + // Maximum sval = prop_->param("maximum").simplified(); if (!sval.isEmpty()) { int ival = sval.toInt(); @@ -888,7 +888,7 @@ Q_ASSERT(minimum_ <= maximum_); - //Default + // Default sval = prop_->defaultValue().toString(); if (!sval.isEmpty()) { int ival = sval.toInt(); @@ -898,29 +898,29 @@ oriVal_ = QString::number(current_); - w_ = new QWidget(parent); + w_ = new QWidget(parent); auto* hb = new QHBoxLayout(w_); hb->setContentsMargins(0, 0, 0, 0); hb->setSpacing(0); - //label + // label cntLabel_ = new QLabel(w_); cntLabel_->setText(oriVal_); - //Buttons + // Buttons addTb_ = new QToolButton(w_); addTb_->setAutoRaise(true); - //addTb_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + // addTb_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); addTb_->setIcon(QPixmap(":/examiner/plus_black.svg")); addTb_->setIconSize(QSize(16, 16)); - //addTb_->setText(tr("Add")); + // addTb_->setText(tr("Add")); removeTb_ = new QToolButton(w_); removeTb_->setAutoRaise(true); // removeTb_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); removeTb_->setIcon(QPixmap(":/examiner/minus_black.svg")); removeTb_->setIconSize(QSize(16, 16)); - //removeTb_->setText(tr("Remove")); + // removeTb_->setText(tr("Remove")); connect(addTb_, SIGNAL(clicked()), this, SLOT(slotAdd())); @@ -930,12 +930,12 @@ checkButtonStatus(); - //Layout + // Layout hb->addSpacing(4); hb->addWidget(cntLabel_); hb->addSpacing(6); hb->addWidget(addTb_); - //hb->addSpacing(2); + // hb->addSpacing(2); hb->addWidget(removeTb_); hb->addStretch(1); @@ -979,7 +979,7 @@ void EditAddRemoveLine::checkButtonStatus() { - bool addSt = true; + bool addSt = true; bool removeSt = true; if (current_ == minimum_) { removeSt = false; @@ -1016,11 +1016,11 @@ { Q_ASSERT(prop_); - //Default + // Default oriVal_ = prop_->defaultValue().toString(); Q_ASSERT(!oriVal_.isEmpty()); - w_ = new QWidget(parent); + w_ = new QWidget(parent); auto* hb = new QHBoxLayout(w_); hb->setContentsMargins(0, 0, 0, 0); hb->setSpacing(0); @@ -1028,13 +1028,13 @@ QString strOnVal; QString strOffVal; if (prop_->type() == MvQProperty::BoolType) { - strOnVal = "True"; - strOffVal = "False"; - strOnData_ = "true"; + strOnVal = "True"; + strOffVal = "False"; + strOnData_ = "true"; strOffData_ = "false"; } else { - QStringList lst = prop_->param("values_label").split("/"); + QStringList lst = prop_->param("values_label").split("/"); QStringList lstData = prop_->param("values").split("/"); if (prop_->param("values_label").simplified().isEmpty()) lst = lstData; @@ -1042,14 +1042,14 @@ Q_ASSERT(lst.count() == lstData.count()); Q_ASSERT(lst.count() == 2); - strOnVal = lst[0]; - strOffVal = lst[1]; - strOnData_ = lstData[0]; + strOnVal = lst[0]; + strOffVal = lst[1]; + strOnData_ = lstData[0]; strOffData_ = lstData[1]; } - //Radio buttons - radioOn_ = new QRadioButton(strOnVal, w_); + // Radio buttons + radioOn_ = new QRadioButton(strOnVal, w_); radioOff_ = new QRadioButton(strOffVal, w_); radioOn_->setProperty("data", strOnData_); radioOff_->setProperty("data", strOffData_); @@ -1106,9 +1106,9 @@ EditConditionLine::EditConditionLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent) : EditLine(prop, grid, header, parent), - condOperCb_(0), - condValueLe_(0), - condOperProp_(0), + condOperCb_(nullptr), + condValueLe_(nullptr), + condOperProp_(nullptr), broadcastChange_(true) { Q_ASSERT(prop_); @@ -1116,12 +1116,12 @@ MvQProperty* grProp = header->groupProp(); Q_ASSERT(grProp); - //The holder widget + // The holder widget w_ = new QWidget(parent); - //Q_ASSERT(prop_->guiType() == MvQProperty::StringGui); + // Q_ASSERT(prop_->guiType() == MvQProperty::StringGui); - //The main editor + // The main editor condValueLe_ = new QLineEdit(w_); if (prop_->defaultValue().isValid()) { QString v = prop_->defaultValue().toString(); @@ -1139,8 +1139,8 @@ connect(condValueLe_, SIGNAL(textChanged(QString)), this, SLOT(condValueChanged(QString))); - //The additonal editors - //First, check if the properties are available + // The additonal editors + // First, check if the properties are available QStringList wLst = prop_->param("with").simplified().split("/"); Q_FOREACH (QString t, wLst) { QStringList opLst = t.simplified().split("="); @@ -1161,7 +1161,7 @@ Q_ASSERT(condOperProp_->guiType() == MvQProperty::StringComboGui); condOperCb_ = new QComboBox(w_); - QStringList lst = condOperProp_->param("values_label").split("/"); + QStringList lst = condOperProp_->param("values_label").split("/"); QStringList lstData = condOperProp_->param("values").split("/"); if (condOperProp_->param("values_label").simplified().isEmpty()) lst = lstData; @@ -1170,7 +1170,7 @@ for (int i = 0; i < lst.count(); i++) condOperCb_->addItem(lst[i], lstData[i]); - //Set combo to default value + // Set combo to default value if (condOperProp_->defaultValue().isValid()) { int idx = lstData.indexOf(condOperProp_->defaultValue().toString()); if (idx >= 0) { @@ -1183,7 +1183,7 @@ this, SLOT(condOperChanged(int))); } - //The layout + // The layout auto* hb = new QHBoxLayout(w_); hb->setContentsMargins(0, 0, 0, 0); hb->setSpacing(0); @@ -1263,16 +1263,16 @@ EditMultiConditionLine::EditMultiConditionLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent) : EditLine(prop, grid, header, parent), - condRankTb_(0), - condRankLabel_(0), - condRankLe_(0), - condControlTb_(0), - condControlLabel_(0), - condOperCb_(0), - condValueLe_(0), - condRankProp_(0), - condOperProp_(0), - condValueProp_(0), + condRankTb_(nullptr), + condRankLabel_(nullptr), + condRankLe_(nullptr), + condControlTb_(nullptr), + condControlLabel_(nullptr), + condOperCb_(nullptr), + condValueLe_(nullptr), + condRankProp_(nullptr), + condOperProp_(nullptr), + condValueProp_(nullptr), broadcastChange_(true) { Q_ASSERT(prop_); @@ -1280,10 +1280,10 @@ MvQProperty* grProp = header->groupProp(); Q_ASSERT(grProp); - //The holder widget + // The holder widget w_ = new QWidget(parent); - //The main editor + // The main editor paramLe_ = new QLineEdit(w_); if (prop_->defaultValue().isValid()) { QString v = prop_->defaultValue().toString(); @@ -1301,8 +1301,8 @@ connect(paramLe_, SIGNAL(textChanged(QString)), this, SLOT(paramChanged(QString))); - //The additonal editors - //First, check if the properties are available + // The additonal editors + // First, check if the properties are available QStringList wLst = prop_->param("with").simplified().split("/"); Q_FOREACH (QString t, wLst) { QStringList opLst = t.simplified().split("="); @@ -1326,7 +1326,7 @@ } } } - //Next, create the editors + // Next, create the editors QFont smallFont; smallFont.setPointSize(smallFont.pointSize() - 1); @@ -1338,7 +1338,7 @@ Q_ASSERT(condRankProp_->guiType() == MvQProperty::StringGui || condRankProp_->guiType() == MvQProperty::IntGui); - //Linedit for rank + // Linedit for rank condRankLe_ = new QLineEdit(w_); QFont f; QFontMetrics fm(f); @@ -1354,14 +1354,14 @@ condRankLe_->setToolTip(tooltip); #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) - //condRankLe_->setClearButtonEnabled(true); + // condRankLe_->setClearButtonEnabled(true); #endif connect(condRankLe_, SIGNAL(textChanged(QString)), this, SLOT(condRankChanged(QString))); QStringList condCnt = prop_->param("control").split("/"); - //If rank can be enabled/disabled + // If rank can be enabled/disabled if (condCnt.contains("rank")) { condRankTb_ = new QToolButton(w_); condRankTb_->setAutoRaise(false); @@ -1374,10 +1374,10 @@ connect(condRankTb_, SIGNAL(clicked(bool)), this, SLOT(condRankTbChanged(bool))); - //off by default + // off by default condRankTbChanged(false); } - //rank is always visible + // rank is always visible else { condRankLabel_ = new QLabel(w_); condRankLabel_->setText(" Rank:"); @@ -1390,12 +1390,12 @@ //--------------------- if (condOperProp_ && condValueProp_) { //--------------------- - //operator + // operator //--------------------- Q_ASSERT(condOperProp_->guiType() == MvQProperty::StringComboGui); condOperCb_ = new QComboBox(w_); - QStringList lst = condOperProp_->param("values_label").split("/"); + QStringList lst = condOperProp_->param("values_label").split("/"); QStringList lstData = condOperProp_->param("values").split("/"); if (condOperProp_->param("values_label").simplified().isEmpty()) lst = lstData; @@ -1404,7 +1404,7 @@ for (int i = 0; i < lst.count(); i++) condOperCb_->addItem(lst[i], lstData[i]); - //Set combo to default value + // Set combo to default value if (condOperProp_->defaultValue().isValid()) { int idx = lstData.indexOf(condOperProp_->defaultValue().toString()); if (idx >= 0) { @@ -1417,7 +1417,7 @@ this, SLOT(condOperChanged(int))); //--------------------- - //value + // value //--------------------- Q_ASSERT(condValueProp_->guiType() == MvQProperty::StringGui); @@ -1441,11 +1441,11 @@ QStringList condCnt = prop_->param("control").split("/"); - //If value filter can be enabled/disabled + // If value filter can be enabled/disabled if (condCnt.contains("value")) { condControlTb_ = new QToolButton(w_); condControlTb_->setAutoRaise(false); - //condControlTb_->setIcon(QPixmap(":/examiner/filter.svg")); + // condControlTb_->setIcon(QPixmap(":/examiner/filter.svg")); condControlTb_->setText(tr("Value")); condControlTb_->setCheckable(true); condControlTb_->setChecked(false); @@ -1455,10 +1455,10 @@ connect(condControlTb_, SIGNAL(clicked(bool)), this, SLOT(condControlChanged(bool))); - //Disabled by defaut + // Disabled by defaut condControlChanged(false); } - //value filter is always visible + // value filter is always visible else { condControlLabel_ = new QLabel(w_); condControlLabel_->setText(" Value:"); @@ -1466,14 +1466,14 @@ } } else { - condOperProp_ = 0; - condValueProp_ = 0; + condOperProp_ = nullptr; + condValueProp_ = nullptr; condOperOriVal_.clear(); condValueOriVal_.clear(); } - //The layout + // The layout auto* hb = new QHBoxLayout(w_); hb->setContentsMargins(0, 0, 0, 0); hb->setSpacing(0); @@ -1481,7 +1481,7 @@ if (condRankLe_) { if (condRankTb_) { - Q_ASSERT(condRankLabel_ == 0); + Q_ASSERT(condRankLabel_ == nullptr); hb->addWidget(condRankTb_); } else if (condRankLabel_) { @@ -1493,7 +1493,7 @@ if (condOperCb_ && condValueLe_) { if (condControlTb_) { - Q_ASSERT(condControlLabel_ == 0); + Q_ASSERT(condControlLabel_ == nullptr); hb->addWidget(condControlTb_); } else if (condControlLabel_) diff -Nru metview-5.17.4/metview/src/libMvQtGui/PropertyLineEditor.h metview-5.19.2/metview/src/libMvQtGui/PropertyLineEditor.h --- metview-5.17.4/metview/src/libMvQtGui/PropertyLineEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/PropertyLineEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ { Q_OBJECT public: - EditLineHeader(QString name, QGridLayout* grid, QWidget* parent = 0); + EditLineHeader(QString name, QGridLayout* grid, QWidget* parent = nullptr); void addLine(EditLine*); void init(); void expand(); @@ -52,8 +52,8 @@ void needRepaint(); protected: - void paintEvent(QPaintEvent*); - void mousePressEvent(QMouseEvent*); + void paintEvent(QPaintEvent*) override; + void mousePressEvent(QMouseEvent*) override; void adjustLabel(bool hasEdited); void setChangeStatus(bool b); void forceRepaint(); @@ -94,7 +94,7 @@ void setVisible(bool b); void setHiddenByRule(bool b); virtual QString value() const = 0; - virtual void clear() = 0; + virtual void clear() = 0; bool isSet() const; MvQProperty* property() const { return prop_; } void setHelper(QString s) { helper_ = s; } @@ -111,8 +111,8 @@ protected: enum ColumnPos { - ResetColumn = 0, - NameColumn = 1, + ResetColumn = 0, + NameColumn = 1, HelperColumn = 2, WidgetColumn = 3, SuffixColumn = 4 @@ -145,17 +145,17 @@ Q_OBJECT public: EditStringLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const; - void clear(); - void applyChange(); - void setCompleter(const std::set&); - void updateCompleter(const std::set&); + QString value() const override; + void clear() override; + void applyChange() override; + void setCompleter(const std::set&) override; + void updateCompleter(const std::set&) override; protected Q_SLOTS: void currentChanged(QString s); protected: - QWidget* widget(); + QWidget* widget() override; QLineEdit* le_; }; @@ -165,12 +165,12 @@ public: EditLabelLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const { return QString(); } - void clear() {} - void applyChange() {} + QString value() const override { return {}; } + void clear() override {} + void applyChange() override {} protected: - QWidget* widget(); + QWidget* widget() override; QLabel* label_; }; @@ -180,15 +180,15 @@ public: EditComboLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); void init(QStringList); - QString value() const; - void clear(); - void applyChange(); + QString value() const override; + void clear() override; + void applyChange() override; protected Q_SLOTS: void currentChanged(QString s); protected: - QWidget* widget(); + QWidget* widget() override; QComboBox* cb_; }; @@ -197,9 +197,9 @@ Q_OBJECT public: EditDateLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const; - void clear(); - void applyChange(); + QString value() const override; + void clear() override; + void applyChange() override; protected Q_SLOTS: void slotHelp(); @@ -209,7 +209,7 @@ protected: void hideCalendar(); - QWidget* widget(); + QWidget* widget() override; QLineEdit* le_; CalendarDialog* cal_; }; @@ -218,12 +218,12 @@ { public: EditTimeLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const; - void clear(); - void applyChange(); + QString value() const override; + void clear() override; + void applyChange() override; protected: - QWidget* widget(); + QWidget* widget() override; QLineEdit* le_; }; @@ -232,15 +232,15 @@ Q_OBJECT public: EditAreaLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const; - void clear(); - void applyChange(); + QString value() const override; + void clear() override; + void applyChange() override; protected Q_SLOTS: void currentChanged(QString s); protected: - QWidget* widget(); + QWidget* widget() override; QLineEdit* nLe_; QLineEdit* sLe_; QLineEdit* wLe_; @@ -253,9 +253,9 @@ Q_OBJECT public: EditAddRemoveLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const; - void clear(); - void applyChange(); + QString value() const override; + void clear() override; + void applyChange() override; protected Q_SLOTS: void slotAdd(); @@ -263,7 +263,7 @@ protected: void currentChanged(); - QWidget* widget(); + QWidget* widget() override; void checkButtonStatus(); QWidget* w_; @@ -280,15 +280,15 @@ Q_OBJECT public: EditBoolLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const; - void clear(); - void applyChange(); + QString value() const override; + void clear() override; + void applyChange() override; protected Q_SLOTS: void slotStatusChanged(bool); protected: - QWidget* widget(); + QWidget* widget() override; QWidget* w_; QRadioButton* radioOn_; @@ -302,9 +302,9 @@ Q_OBJECT public: EditConditionLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const; - void clear(); - void applyChange(); + QString value() const override; + void clear() override; + void applyChange() override; protected Q_SLOTS: void condOperChanged(int); @@ -312,7 +312,7 @@ protected: void currentChanged(); - QWidget* widget(); + QWidget* widget() override; void checkButtonStatus(); QWidget* w_; @@ -328,11 +328,11 @@ Q_OBJECT public: EditMultiConditionLine(MvQProperty* prop, QGridLayout* grid, EditLineHeader* header, QWidget* parent); - QString value() const; - void clear(); - void applyChange(); - void setCompleter(const std::set&); - virtual void updateCompleter(const std::set&); + QString value() const override; + void clear() override; + void applyChange() override; + void setCompleter(const std::set&) override; + void updateCompleter(const std::set&) override; protected Q_SLOTS: void paramChanged(QString); @@ -344,7 +344,7 @@ protected: void currentChanged(); - QWidget* widget(); + QWidget* widget() override; void checkButtonStatus(); QWidget* w_; diff -Nru metview-5.17.4/metview/src/libMvQtGui/StatusMsgHandler.cc metview-5.19.2/metview/src/libMvQtGui/StatusMsgHandler.cc --- metview-5.17.4/metview/src/libMvQtGui/StatusMsgHandler.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/StatusMsgHandler.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ { if (!errorCol.isValid()) { errorCol = MvQTheme::colour("status", "error"); - okCol = MvQTheme::colour("status", "ok"); + okCol = MvQTheme::colour("status", "ok"); } } diff -Nru metview-5.17.4/metview/src/libMvQtGui/StatusProgBarHandler.h metview-5.19.2/metview/src/libMvQtGui/StatusProgBarHandler.h --- metview-5.17.4/metview/src/libMvQtGui/StatusProgBarHandler.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/StatusProgBarHandler.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ class StatusProgBarHandler { public: - ~StatusProgBarHandler() {} + ~StatusProgBarHandler() = default; static StatusProgBarHandler* instance(); void init(QProgressBar*); @@ -28,7 +28,7 @@ protected: StatusProgBarHandler() : - progBar_(0) {} + progBar_(nullptr) {} private: static StatusProgBarHandler* instance_; diff -Nru metview-5.17.4/metview/src/libMvQtGui/StringMatchCombo.h metview-5.19.2/metview/src/libMvQtGui/StringMatchCombo.h --- metview-5.17.4/metview/src/libMvQtGui/StringMatchCombo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/StringMatchCombo.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,13 +17,13 @@ class StringMatchTb : public QToolButton { public: - StringMatchTb(QWidget* parent = 0); + StringMatchTb(QWidget* parent = nullptr); }; class StringMatchCombo : public QComboBox { public: - explicit StringMatchCombo(QWidget* parent = 0); + explicit StringMatchCombo(QWidget* parent = nullptr); StringMatchMode::Mode matchMode(int) const; StringMatchMode::Mode currentMatchMode() const; diff -Nru metview-5.17.4/metview/src/libMvQtGui/StringMatchMode.cc metview-5.19.2/metview/src/libMvQtGui/StringMatchMode.cc --- metview-5.17.4/metview/src/libMvQtGui/StringMatchMode.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/StringMatchMode.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ if (matchOper_.empty()) { matchOper_[ContainsMatch] = "~"; matchOper_[WildcardMatch] = "="; - matchOper_[RegexpMatch] = "=~"; + matchOper_[RegexpMatch] = "=~"; } } @@ -44,9 +44,9 @@ StringMatchMode::Mode StringMatchMode::operToMode(const std::string& op) { - for (auto it = matchOper_.begin(); it != matchOper_.end(); ++it) { - if (op == it->second) - return it->first; + for (auto& it : matchOper_) { + if (op == it.second) + return it.first; } return InvalidMatch; } diff -Nru metview-5.17.4/metview/src/libMvQtGui/StringMatchMode.h metview-5.19.2/metview/src/libMvQtGui/StringMatchMode.h --- metview-5.17.4/metview/src/libMvQtGui/StringMatchMode.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/StringMatchMode.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,10 +17,10 @@ public: enum Mode { - InvalidMatch = -1, + InvalidMatch = -1, ContainsMatch = 0, WildcardMatch = 1, - RegexpMatch = 2 + RegexpMatch = 2 }; StringMatchMode(); diff -Nru metview-5.17.4/metview/src/libMvQtGui/TextEditSearchLine.cc metview-5.19.2/metview/src/libMvQtGui/TextEditSearchLine.cc --- metview-5.17.4/metview/src/libMvQtGui/TextEditSearchLine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/TextEditSearchLine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ bool TextEditSearchLine::findString(QString str, bool highlightAll, QTextDocument::FindFlags extraFlags, QTextCursor::MoveOperation move, int iteration) { QTextDocument::FindFlags flags = findFlags() | extraFlags; - lastFindSuccessful_ = interface_->findString(str, highlightAll, flags, move, iteration, matchModeCb_->currentMatchMode()); + lastFindSuccessful_ = interface_->findString(str, highlightAll, flags, move, iteration, matchModeCb_->currentMatchMode()); return lastFindSuccessful_; } @@ -62,7 +62,7 @@ void TextEditSearchLine::slotHighlight() { - //UserMessage::message(UserMessage::DBG, false," highlight: " + searchLine_->text().toStdString()); + // UserMessage::message(UserMessage::DBG, false," highlight: " + searchLine_->text().toStdString()); highlightAllTimer_.stop(); @@ -70,13 +70,13 @@ highlightMatches(searchLine_->text()); } -//This slot is called as we type in the search string +// This slot is called as we type in the search string void TextEditSearchLine::slotFind(QString txt) { if (!interface_) return; - //In confirmSearch mode we do not start the search + // In confirmSearch mode we do not start the search if (confirmSearch_) { toDefaultState(); return; diff -Nru metview-5.17.4/metview/src/libMvQtGui/TextEditSearchLine.h metview-5.19.2/metview/src/libMvQtGui/TextEditSearchLine.h --- metview-5.17.4/metview/src/libMvQtGui/TextEditSearchLine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/TextEditSearchLine.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,21 +22,21 @@ public: explicit TextEditSearchLine(QWidget* parent); - ~TextEditSearchLine(); + ~TextEditSearchLine() override; void setSearchInterface(AbstractTextEditSearchInterface*); void searchOnReload(bool userClickedReload); public Q_SLOTS: - void slotFind(QString); - void slotFindNext(); - void slotFindPrev(); + void slotFind(QString) override; + void slotFindNext() override; + void slotFindPrev() override; void slotFindNext(bool) { slotFindNext(); } void slotFindPrev(bool) { slotFindPrev(); } void matchModeChanged(int newIndex); - void on_actionCaseSensitive__toggled(bool); - void on_actionWholeWords__toggled(bool); - void on_actionHighlightAll__toggled(bool); - void slotClose(); + void on_actionCaseSensitive__toggled(bool) override; + void on_actionWholeWords__toggled(bool) override; + void on_actionHighlightAll__toggled(bool) override; + void slotClose() override; void slotHighlight(); protected: diff -Nru metview-5.17.4/metview/src/libMvQtGui/TransparencyWidget.cc metview-5.19.2/metview/src/libMvQtGui/TransparencyWidget.cc --- metview-5.17.4/metview/src/libMvQtGui/TransparencyWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/TransparencyWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -102,7 +102,7 @@ void TransparencyWidget::resetValue() { ignoreChange_ = true; - int value = 0; + int value = 0; sp_->setValue(value); slider_->setValue(value); label_->setText(QString::number(value)); @@ -118,7 +118,7 @@ int TransparencyWidget::alphaValue() const { auto v = static_cast(100 - slider_->value()); - int r = static_cast(v * 2.55); + int r = static_cast(v * 2.55); if (r < 0) { r = 0; } @@ -131,7 +131,7 @@ int TransparencyWidget::trToAlpha(int tr) const { auto v = static_cast(100 - tr); - int r = static_cast(v * 2.55); + int r = static_cast(v * 2.55); if (r < 0) { r = 0; } @@ -144,7 +144,7 @@ int TransparencyWidget::alphaToTr(int a) const { float v = static_cast(a) / 2.55; - int r = static_cast(v); + int r = static_cast(v); if (r < 0) { r = 0; } diff -Nru metview-5.17.4/metview/src/libMvQtGui/TreeModelMatchCollector.cc metview-5.19.2/metview/src/libMvQtGui/TreeModelMatchCollector.cc --- metview-5.17.4/metview/src/libMvQtGui/TreeModelMatchCollector.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/TreeModelMatchCollector.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,9 @@ void TreeModelMatchCollector::clear() { - startIndex_ = QModelIndex(); - startItemPos_ = -1; - startItemFound_ = false; + startIndex_ = QModelIndex(); + startItemPos_ = -1; + startItemFound_ = false; startIndexPassed_ = false; value_.clear(); columns_.clear(); @@ -44,14 +44,14 @@ if (value_ == value && columns_ == columns && flags_ == flags) return; - startIndex_ = startIndex; - startItemPos_ = -1; - startItemFound_ = false; + startIndex_ = startIndex; + startItemPos_ = -1; + startItemFound_ = false; startIndexPassed_ = false; - value_ = value; + value_ = value; columns_ = columns; - flags_ = flags; + flags_ = flags; items_.clear(); buildRx(); @@ -94,7 +94,7 @@ { bool found = false; for (auto column : columns_) { - auto idx = model_->index(row, column, parentIdx); + auto idx = model_->index(row, column, parentIdx); QString s = idx.data(Qt::DisplayRole).toString(); if (flags_.testFlag(Qt::MatchWildcard)) { if (s.contains(wildcardRx_)) { @@ -128,13 +128,13 @@ } if (refIdx == startIndex_) { - startItemPos_ = items_.count() - 1; + startItemPos_ = items_.count() - 1; startIndexPassed_ = true; if (found) startItemFound_ = true; } else if (startIndexPassed_ && !startItemFound_ && found) { - startItemPos_ = items_.count() - 1; + startItemPos_ = items_.count() - 1; startItemFound_ = true; } @@ -158,7 +158,7 @@ } auto refIdx = model_->index(row, 0, parentIdx); - int chNum = model_->rowCount(refIdx); + int chNum = model_->rowCount(refIdx); for (int i = 0; i < chNum; i++) allValues(i, refIdx, vals); } diff -Nru metview-5.17.4/metview/src/libMvQtGui/TreeModelMatchCollector.h metview-5.19.2/metview/src/libMvQtGui/TreeModelMatchCollector.h --- metview-5.17.4/metview/src/libMvQtGui/TreeModelMatchCollector.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtGui/TreeModelMatchCollector.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ class TreeModelMatchCollector { public: - TreeModelMatchCollector() {} + TreeModelMatchCollector() = default; void match(QString value, QVector columns, Qt::MatchFlags flags, const QModelIndex& startIndex); @@ -35,7 +35,7 @@ bool isSameAsStartIndex(const QModelIndex&) const; void allValues(QSet& vals) const; -protected: +private: void buildRx(); void findMatch(int row, const QModelIndex& parentIdx); void allValues(int row, const QModelIndex& parentIdx, QSet& vals) const; diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/syntaxhighlighter.cpp metview-5.19.2/metview/src/libMvQtTextPager/syntaxhighlighter.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/syntaxhighlighter.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/syntaxhighlighter.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -70,9 +70,9 @@ Q_ASSERT(start + count <= d->currentBlock.size()); d->formatRanges.append(QTextLayout::FormatRange()); QTextLayout::FormatRange& range = d->formatRanges.last(); - range.start = start; - range.length = count; - range.format = format; + range.start = start; + range.length = count; + range.format = format; } void SyntaxHighlighter::setFormat(int start, int count, const QColor& color) @@ -117,7 +117,7 @@ void SyntaxHighlighter::setCurrentBlockState(int s) { d->previousBlockState = d->currentBlockState; - d->currentBlockState = s; // ### These don't entirely follow QSyntaxHighlighter's behavior + d->currentBlockState = s; // ### These don't entirely follow QSyntaxHighlighter's behavior } int SyntaxHighlighter::currentBlockPosition() const diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerCursor.cpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerCursor.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerCursor.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerCursor.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ { if (textEdit) { selectionStart = textEdit->textCursor().selectionStart(); - selectionEnd = textEdit->textCursor().selectionEnd(); + selectionEnd = textEdit->textCursor().selectionEnd(); } } @@ -69,10 +69,10 @@ #endif return; } - d = new TextCursorSharedPrivate; + d = new TextCursorSharedPrivate; d->document = const_cast(document); d->position = pos; - d->anchor = anc == -1 ? pos : anc; + d->anchor = anc == -1 ? pos : anc; d->document->d->textCursors.insert(d); } } @@ -83,7 +83,7 @@ { if (edit) { TextPagerDocument* document = edit->document(); - const int documentSize = document->d->documentSize; + const int documentSize = document->d->documentSize; if (pos < 0 || pos > documentSize || anc < -1 || anc > documentSize) { #ifndef LAZYTEXTEDIT_AUTOTEST qWarning("Invalid cursor data %d %d - %d\n", @@ -92,10 +92,10 @@ #endif return; } - d = new TextCursorSharedPrivate; + d = new TextCursorSharedPrivate; d->document = const_cast(document); d->position = pos; - d->anchor = anc == -1 ? pos : anc; + d->anchor = anc == -1 ? pos : anc; d->document->d->textCursors.insert(d); } } @@ -110,7 +110,7 @@ TextPagerCursor& TextPagerCursor::operator=(const TextPagerCursor& other) { deref(); - d = other.d; + d = other.d; textEdit = 0; ref(); return *this; @@ -281,7 +281,7 @@ int gotoCol = qMax(d->overrideColumn, col); if (gotoCol > targetLine.textLength()) { d->overrideColumn = qMax(d->overrideColumn, gotoCol); - gotoCol = targetLine.textLength(); + gotoCol = targetLine.textLength(); } const int overrideColumn = d->overrideColumn; setPosition(targetLinePos + gotoCol, mode); @@ -294,7 +294,7 @@ int offset; bool lastLine; TextPagerLayout* textLayout = TextLayoutCacheManager::requestLayout(*this, 1); - QTextLine line = textLayout->lineForPosition(position(), &offset, + QTextLine line = textLayout->lineForPosition(position(), &offset, 0, &lastLine); if (!line.isValid()) return false; @@ -567,10 +567,10 @@ if (d->ref > 1) { d->ref.deref(); TextCursorSharedPrivate* p = new TextCursorSharedPrivate; - p->position = d->position; - p->overrideColumn = d->overrideColumn; - p->anchor = d->anchor; - p->document = d->document; + p->position = d->position; + p->overrideColumn = d->overrideColumn; + p->anchor = d->anchor; + p->document = d->document; d->document->d->textCursors.insert(p); d = p; } @@ -584,7 +584,7 @@ bool TextPagerCursor::deref() { TextCursorSharedPrivate* dd = d; - d = 0; + d = 0; if (dd && !dd->ref.deref()) { if (dd->document) { const bool removed = dd->document->d->textCursors.remove(dd); @@ -615,7 +615,7 @@ bool TextPagerCursor::cursorMoveKeyEvent(QKeyEvent* e) { - MoveMode mode = MoveAnchor; + MoveMode mode = MoveAnchor; MoveOperation op = NoMove; if (e == QKeySequence::MoveToNextChar) { @@ -625,51 +625,51 @@ op = Left; } else if (e == QKeySequence::SelectNextChar) { - op = Right; + op = Right; mode = KeepAnchor; } else if (e == QKeySequence::SelectPreviousChar) { - op = Left; + op = Left; mode = KeepAnchor; } else if (e == QKeySequence::SelectNextWord) { - op = WordRight; + op = WordRight; mode = KeepAnchor; } else if (e == QKeySequence::SelectPreviousWord) { - op = WordLeft; + op = WordLeft; mode = KeepAnchor; } else if (e == QKeySequence::SelectStartOfLine) { - op = StartOfLine; + op = StartOfLine; mode = KeepAnchor; } else if (e == QKeySequence::SelectEndOfLine) { - op = EndOfLine; + op = EndOfLine; mode = KeepAnchor; } else if (e == QKeySequence::SelectStartOfBlock) { - op = StartOfBlock; + op = StartOfBlock; mode = KeepAnchor; } else if (e == QKeySequence::SelectEndOfBlock) { - op = EndOfBlock; + op = EndOfBlock; mode = KeepAnchor; } else if (e == QKeySequence::SelectStartOfDocument) { - op = Start; + op = Start; mode = KeepAnchor; } else if (e == QKeySequence::SelectEndOfDocument) { - op = End; + op = End; mode = KeepAnchor; } else if (e == QKeySequence::SelectPreviousLine) { - op = Up; + op = Up; mode = KeepAnchor; } else if (e == QKeySequence::SelectNextLine) { - op = Down; + op = Down; mode = KeepAnchor; #if 0 { @@ -713,13 +713,13 @@ op = End; } else if (e == QKeySequence::MoveToNextPage || e == QKeySequence::MoveToPreviousPage || e == QKeySequence::SelectNextPage || e == QKeySequence::SelectPreviousPage) { - const MoveMode mode = (e == QKeySequence::MoveToNextPage || e == QKeySequence::MoveToPreviousPage - ? MoveAnchor - : KeepAnchor); + const MoveMode mode = (e == QKeySequence::MoveToNextPage || e == QKeySequence::MoveToPreviousPage + ? MoveAnchor + : KeepAnchor); const MoveOperation operation = (e == QKeySequence::MoveToNextPage || e == QKeySequence::SelectNextPage ? Down : Up); - int visibleLines = 10; + int visibleLines = 10; if (textEdit) visibleLines = textEdit->d->visibleLines; for (int i = 0; i < visibleLines; ++i) { @@ -757,7 +757,7 @@ QString TextPagerCursor::cursorLine() const { Q_ASSERT(d && d->document); - int layoutIndex = -1; + int layoutIndex = -1; TextPagerLayout* textLayout = TextLayoutCacheManager::requestLayout(*this, 2); // should I use 1? QTextLine line = textLayout->lineForPosition(position(), 0, &layoutIndex); @@ -772,9 +772,9 @@ { int res = -1; Q_ASSERT(d && d->document); - int layoutIndex = -1; + int layoutIndex = -1; TextPagerLayout* textLayout = TextLayoutCacheManager::requestLayout(*this, 2); - QTextLine line = textLayout->lineForPosition(position(), 0, &layoutIndex); + QTextLine line = textLayout->lineForPosition(position(), 0, &layoutIndex); if (line.isValid()) res = line.height(); return res; diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerCursor_p.hpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerCursor_p.hpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerCursor_p.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerCursor_p.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -91,16 +91,16 @@ layouts.append(new TextPagerLayout(doc)); } TextPagerLayout* l = layouts.last(); - l->viewport = cursor.viewportWidth(); + l->viewport = cursor.viewportWidth(); if (l->viewport == -1) l->viewport = INT_MAX - 1024; // prevent overflow in comparisons. if (cursor.textEdit) { - l->textEdit = cursor.textEdit; + l->textEdit = cursor.textEdit; l->suppressTextEditUpdates = true; - l->lineBreaking = cursor.textEdit->lineBreaking(); - l->sections = cursor.textEdit->d->sections; - l->font = cursor.textEdit->font(); - l->syntaxHighlighters = cursor.textEdit->syntaxHighlighters(); + l->lineBreaking = cursor.textEdit->lineBreaking(); + l->sections = cursor.textEdit->d->sections; + l->font = cursor.textEdit->font(); + l->syntaxHighlighters = cursor.textEdit->syntaxHighlighters(); // l->extraSelections = cursor.textEdit->extraSelections(); // ### can the extra selections impact layout? If so they // ### need to be in the actual textLayout shouldn't need @@ -128,7 +128,7 @@ } int linesBelow = margin; - int endPos = cursor.position(); + int endPos = cursor.position(); if (endPos < doc->documentSize()) { while (linesBelow > 0) { const TextPagerCursor c = doc->find(QLatin1Char('\n'), endPos + 1); @@ -143,7 +143,7 @@ if (startPos > 0) ++startPos; // in this case startPos points to the newline before it l->viewportPosition = startPos; - l->layoutDirty = true; + l->layoutDirty = true; ASSUME(l->viewportPosition == 0 || doc->readCharacter(l->viewportPosition - 1) == QLatin1Char('\n')); l->relayoutByPosition(endPos - startPos + 100); // ### fudged a couple of lines likely ASSUME(l->viewportPosition < l->layoutEnd || (l->viewportPosition == l->layoutEnd && l->viewportPosition == doc->documentSize())); diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerDocument.cpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerDocument.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerDocument.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerDocument.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -62,7 +62,7 @@ if (!(d->options & KeepTemporaryFiles) && !c->swap.isEmpty()) QFile::remove(c->swap); Chunk* tmp = c; - c = c->next; + c = c->next; delete tmp; } Q_FOREACH (TextPagerSection* section, d->sections) { @@ -106,11 +106,11 @@ Chunk* c = d->first; while (c) { Chunk* tmp = c; - c = c->next; + c = c->next; delete tmp; } - d->textCodec = codec; + d->textCodec = codec; d->documentSize = device->size(); if (d->documentSize <= d->chunkSize && mode == Sparse && !(options & NoImplicitLoadAll)) mode = LoadAll; @@ -127,11 +127,11 @@ delete d->device.data(); } - d->ownDevice = false; - d->device = device; + d->ownDevice = false; + d->device = device; d->deviceMode = mode; #ifndef NO_TEXTDOCUMENT_CHUNK_CACHE - d->cachedChunk = 0; + d->cachedChunk = 0; d->cachedChunkPos = -1; d->cachedChunkData.clear(); #endif @@ -146,11 +146,11 @@ QTextStream ts(device); if (d->textCodec) ts.setCodec(d->textCodec); - Chunk* current = 0; + Chunk* current = 0; d->documentSize = 0; // in case of unicode do { Chunk* c = new Chunk; - c->data = ts.read(d->chunkSize); + c->data = ts.read(d->chunkSize); if (options & AutoDetectCarriageReturns) { if (c->data.contains(QLatin1Char('\n'))) { options |= ConvertCarriageReturns; @@ -162,7 +162,7 @@ d->documentSize += c->data.size(); if (current) { current->next = c; - c->previous = current; + c->previous = current; } else { d->first = c; @@ -175,18 +175,18 @@ } case Sparse: { - int index = 0; + int index = 0; Chunk* current = 0; do { - Chunk* chunk = new Chunk; - chunk->from = index; + Chunk* chunk = new Chunk; + chunk->from = index; chunk->length = qMin(d->documentSize - index, d->chunkSize); if (!current) { d->first = chunk; } else { chunk->previous = current; - current->next = chunk; + current->next = chunk; } current = chunk; index += chunk->length; @@ -241,7 +241,7 @@ #ifndef NO_TEXTDOCUMENT_READ_CACHE #ifdef DEBUG_CACHE_HITS - static int hits = 0; + static int hits = 0; static int misses = 0; #endif if (d->cachePos != -1 && pos >= d->cachePos && d->cache.size() - (pos - d->cachePos) >= size) { @@ -263,13 +263,13 @@ int chunkPos = pos - offset; while (written < size && c) { - const int max = qMin(size - written, c->size() - offset); + const int max = qMin(size - written, c->size() - offset); const QString data = d->chunkData(c, chunkPos); chunkPos += data.size(); ret.replace(written, max, data.constData() + offset, max); written += max; offset = 0; - c = c->next; + c = c->next; } if (written < size) { @@ -278,7 +278,7 @@ Q_ASSERT(!c || written == size); #ifndef NO_TEXTDOCUMENT_READ_CACHE d->cachePos = pos; - d->cache = ret; + d->cache = ret; #endif return ret; } @@ -316,7 +316,7 @@ int TextPagerDocument::chunkCount() const { QReadLocker locker(d->readWriteLock); - Chunk* c = d->first; + Chunk* c = d->first; int count = 0; while (c) { ++count; @@ -328,7 +328,7 @@ int TextPagerDocument::instantiatedChunkCount() const { QReadLocker locker(d->readWriteLock); - Chunk* c = d->first; + Chunk* c = d->first; int count = 0; while (c) { if (!c->data.isEmpty()) @@ -341,7 +341,7 @@ int TextPagerDocument::swappedChunkCount() const { QReadLocker locker(d->readWriteLock); - Chunk* c = d->first; + Chunk* c = d->first; int count = 0; while (c) { if (!c->swap.isEmpty()) @@ -406,8 +406,8 @@ << "pos:" << *start << "anchor:" << cursor.anchor(); #endif - //Change the search position according to the selection and search - //direction + // Change the search position according to the selection and search + // direction if (cursor.anchor() >= 0) { int ca = cursor.anchor(); @@ -487,19 +487,19 @@ it.setMaxBoundary(limit); } const QLatin1Char newline('\n'); - int last = pos; - bool ok = true; + int last = pos; + bool ok = true; int progressInterval = 0; - int lastProgress = pos; + int lastProgress = pos; const int initialPos = pos; - int maxFindLength = 0; + int maxFindLength = 0; const FindScope scope(flags & FindAllowInterrupt ? &d->findState : 0); QTime lastProgressTime; if (flags & FindAllowInterrupt) { progressInterval = qMax(1, (reverse ? (static_cast(pos) / static_cast(TEXTDOCUMENT_FIND_INTERVAL_PERCENTAGE)) : (static_cast(d->documentSize) - static_cast(pos)) / 100.0)); - maxFindLength = (reverse ? pos : d->documentSize - pos); + maxFindLength = (reverse ? pos : d->documentSize - pos); lastProgressTime.start(); } @@ -511,14 +511,14 @@ lap.start(); #endif - //Loop over the lines in the document. Since we can have millions of lines it has to be - //extremely fast. + // Loop over the lines in the document. Since we can have millions of lines it has to be + // extremely fast. do { #ifdef TEXTDOCUMENT_FIND_SLEEP findSleep(this); #endif - //This clears the string without reallocation + // This clears the string without reallocation line.resize(0); if (((reverse) ? it.prevLine(line) : it.nextLine(line)) == 0) { @@ -527,10 +527,10 @@ break; } - //We only search for the first occurrence. So the FindAll flag is ignored. + // We only search for the first occurrence. So the FindAll flag is ignored. - //QRegExp::lastIndexIn() is 3 times slower than QRegExp::indexIn()!! So we always call - //indexIn() first the lastIndexIn() if we need the reverse order. + // QRegExp::lastIndexIn() is 3 times slower than QRegExp::indexIn()!! So we always call + // indexIn() first the lastIndexIn() if we need the reverse order. if ((index = regexp.indexIn(line, 0)) != -1) { #ifdef TEXTDOCUMENT_FIND_DEBUG @@ -539,7 +539,7 @@ if (reverse) { index = regexp.lastIndexIn(line, line.size()); - from = it.position(); //-line.size(); + from = it.position(); //-line.size(); if (from + index < limit) { ok = false; @@ -561,7 +561,7 @@ ok = false; } else { - //we need to remove the newline char from the end of the matching text + // we need to remove the newline char from the end of the matching text QString captured = regexp.capturedTexts().first(); if (index + regexp.matchedLength() == line.size() && line.endsWith(newline)) { captured.chop(1); @@ -610,7 +610,7 @@ #ifdef TEXTDOCUMENT_FIND_DEBUG qDebug() << "---> end of doc reached. FindWrap will start."; #endif - //Q_ASSERT(!cursor.hasSelection()); + // Q_ASSERT(!cursor.hasSelection()); if (reverse) { if (cursor.position() + 1 < d->documentSize) { return find(regexp, TextPagerCursor(this, d->documentSize), flags & ~FindWrap, cursor.position()); @@ -637,9 +637,9 @@ QReadLocker locker(d->readWriteLock); - const bool reverse = flags & FindBackward; + const bool reverse = flags & FindBackward; const bool caseSensitive = flags & FindCaseSensitively; - const bool wholeWords = flags & FindWholeWords; + const bool wholeWords = flags & FindWholeWords; /* if (flags & FindWrap && cursor.hasSelection()) { qWarning("It makes no sense to pass FindWrap and set a selection for the cursor. The entire selection will be searched"); @@ -650,7 +650,7 @@ int pos; ::initFindForLines(cursor, reverse, &pos, &limit); - //Sanity check!! + // Sanity check!! Q_ASSERT(pos >= 0 && pos <= d->documentSize); Q_ASSERT(limit >= 0 && limit <= d->documentSize); @@ -674,7 +674,7 @@ // ### what if one searches for a string with non-word characters in it and FindWholeWords? const TextDocumentIterator::Direction direction = (reverse ? TextDocumentIterator::Left : TextDocumentIterator::Right); - QString word = caseSensitive ? in : in.toLower(); + QString word = caseSensitive ? in : in.toLower(); TextDocumentIterator it(d, pos); if (reverse) { @@ -691,20 +691,20 @@ if (!caseSensitive) it.setConvertToLowerCase(true); - bool ok = true; - QChar ch = it.current(); - int wordIndex = 0; + bool ok = true; + QChar ch = it.current(); + int wordIndex = 0; int progressInterval = 0; - int lastProgress = pos; + int lastProgress = pos; const int initialPos = pos; - int maxFindLength = 0; + int maxFindLength = 0; const FindScope scope(flags & FindAllowInterrupt ? &d->findState : 0); QTime lastProgressTime; if (flags & FindAllowInterrupt) { progressInterval = qMax(1, (reverse ? (static_cast(pos) / static_cast(TEXTDOCUMENT_FIND_INTERVAL_PERCENTAGE)) : (static_cast(d->documentSize) - static_cast(pos)) / 100.0)); - maxFindLength = (reverse ? pos : d->documentSize - pos); + maxFindLength = (reverse ? pos : d->documentSize - pos); lastProgressTime.start(); } @@ -734,7 +734,7 @@ } }*/ - //This clears the string without reallocation + // This clears the string without reallocation line.resize(0); if (((reverse) ? it.prevLine(line) : it.nextLine(line)) == 0) { @@ -747,27 +747,27 @@ line = line.toLower(); #ifdef TEXTDOCUMENT_FIND_DEBUG - //qDebug() << line; + // qDebug() << line; #endif if ((index = line.indexOf(word)) != -1) { - //Backward: - //The iterator is positioned at the linebreak character of the previous line, or at - //the start of the document + // Backward: + // The iterator is positioned at the linebreak character of the previous line, or at + // the start of the document if (reverse) { - from = it.position(); + from = it.position(); index = line.lastIndexOf(word); } - //Forward: - //The iterator is positioned at the linebreak character at the end of the line or at - //the end of the document + // Forward: + // The iterator is positioned at the linebreak character at the end of the line or at + // the end of the document else { from = it.position() - line.size() + 1; } while (ok && index != -1) { const int startPos = from + index; - const int endPos = from + index + word.size(); + const int endPos = from + index + word.size(); if (!reverse && endPos > limit) { ok = false; @@ -790,7 +790,7 @@ #ifdef TEXTDOCUMENT_FIND_DEBUG qDebug() << line; #endif - //Backward + // Backward if (reverse) { TextPagerCursor ret(this, startPos, endPos); #ifdef TEXTDOCUMENT_FIND_DEBUG @@ -800,7 +800,7 @@ << "pos:" << ret.position() << "anchor:" << ret.anchor(); #endif return ret; - //Forward + // Forward } else { TextPagerCursor ret(this, endPos, startPos); @@ -813,7 +813,7 @@ return ret; } - //If it is not a wholeword we try to match every other match int he same line + // If it is not a wholeword we try to match every other match int he same line } else { if (reverse) { @@ -823,7 +823,7 @@ index = line.indexOf(word, index + word.size()); } } - } //while + } // while } #if 0 @@ -867,7 +867,7 @@ #endif if (flags & FindWrap) { - //Q_ASSERT(!cursor.hasSelection()); + // Q_ASSERT(!cursor.hasSelection()); if (reverse) { if (cursor.position() + 1 < d->documentSize) { return find(in, TextPagerCursor(this, d->documentSize), flags & ~FindWrap, cursor.position()); @@ -904,8 +904,8 @@ Q_ASSERT(pos >= 0 && pos <= d->documentSize); const bool caseSensitive = flags & FindCaseSensitively; - const bool wholeWords = flags & FindWholeWords; - const QChar ch = (caseSensitive ? chIn : chIn.toLower()); + const bool wholeWords = flags & FindWholeWords; + const QChar ch = (caseSensitive ? chIn : chIn.toLower()); TextDocumentIterator it(d, pos); if (reverse) { it.setMinBoundary(limit); @@ -916,17 +916,17 @@ const TextDocumentIterator::Direction dir = (reverse ? TextDocumentIterator::Left : TextDocumentIterator::Right); - int lastProgress = pos; - const int initialPos = pos; - int maxFindLength = 0; - int progressInterval = 0; + int lastProgress = pos; + const int initialPos = pos; + int maxFindLength = 0; + int progressInterval = 0; const FindScope scope(flags & FindAllowInterrupt ? &d->findState : 0); QTime lastProgressTime; if (flags & FindAllowInterrupt) { progressInterval = qMax(1, (reverse ? (static_cast(pos) / static_cast(TEXTDOCUMENT_FIND_INTERVAL_PERCENTAGE)) : (static_cast(d->documentSize) - static_cast(pos)) / 100.0)); - maxFindLength = (reverse ? pos : d->documentSize - pos); + maxFindLength = (reverse ? pos : d->documentSize - pos); lastProgressTime.start(); } @@ -982,9 +982,9 @@ static inline int count(const QString& string, int from, int size, const QChar& ch) { Q_ASSERT(from + size <= string.size()); - const ushort needle = ch.unicode(); + const ushort needle = ch.unicode(); const ushort* haystack = string.utf16() + from; - int num = 0; + int num = 0; for (int i = 0; i < size; ++i) { if (*haystack++ == needle) ++num; @@ -1042,7 +1042,7 @@ Q_ASSERT(size >= 0); Q_ASSERT(pos < d->documentSize); - TextPagerSection* l = new TextPagerSection(pos, size, this, format, data); + TextPagerSection* l = new TextPagerSection(pos, size, this, format, data); QList::iterator it = qLowerBound::iterator>(d->sections.begin(), d->sections.end(), l, compareTextSection); d->sections.insert(it, l); Q_EMIT sectionAdded(l); @@ -1076,7 +1076,7 @@ Q_ASSERT(pos >= 0 && pos < d->documentSize); #ifndef NO_TEXTDOCUMENT_READ_CACHE #ifdef DEBUG_CACHE_HITS - static int hits = 0; + static int hits = 0; static int misses = 0; #endif if (pos >= d->cachePos && pos < d->cachePos + d->cache.size()) { @@ -1211,7 +1211,7 @@ Q_ASSERT(c != nullptr); - int pos = cursor.position() - offset; //points to the chunks beginning + int pos = cursor.position() - offset; // points to the chunks beginning d->updateChunkLineNumbers(c, pos); #ifdef TEXTDOCUMENT_FIND_DEBUG @@ -1224,7 +1224,7 @@ c = c->previous; d->updateChunkLineNumbers(c, pos); #ifdef TEXTDOCUMENT_FIND_DEBUG - //qDebug() << "chunk - first line:" << c->firstLineIndex << "pos:" << pos; + // qDebug() << "chunk - first line:" << c->firstLineIndex << "pos:" << pos; #endif } } @@ -1234,7 +1234,7 @@ c = c->next; d->updateChunkLineNumbers(c, pos); #ifdef TEXTDOCUMENT_FIND_DEBUG - //qDebug() << "chunk - first line:" << c->firstLineIndex << "pos:" << pos; + // qDebug() << "chunk - first line:" << c->firstLineIndex << "pos:" << pos; #endif } @@ -1256,11 +1256,11 @@ return TextPagerCursor(this, pos); QChar newline('\n'); - int index = 0; + int index = 0; QString data = d->chunkData(c, -1); while ((index = data.indexOf(newline, index)) != -1) { #ifdef TEXTDOCUMENT_FIND_DEBUG - //qDebug() << "chunk found - line:" << current << "index:" << index; + // qDebug() << "chunk found - line:" << current << "index:" << index; #endif if (current == lineNum) { TextPagerCursor ret(this, pos + index); @@ -1338,7 +1338,7 @@ return cachedChunk; } #endif - int pos = p; + int pos = p; Chunk* c = first; Q_FOREVER @@ -1365,7 +1365,7 @@ { #ifndef NO_TEXTDOCUMENT_CHUNK_CACHE #ifdef DEBUG_CACHE_HITS - static int hits = 0; + static int hits = 0; static int misses = 0; #endif if (chunk == cachedChunk) { @@ -1398,11 +1398,11 @@ } #endif QTextStream ts(dev); - //if (textCodec) - // ts.setCodec(textCodec); - // if (!chunk->swap.isEmpty()) { - // qDebug() << "reading stuff from swap" << chunk << chunk->from << chunk->size() << chunk->swap; - // } + // if (textCodec) + // ts.setCodec(textCodec); + // if (!chunk->swap.isEmpty()) { + // qDebug() << "reading stuff from swap" << chunk << chunk->from << chunk->size() << chunk->swap; + // } ts.seek(chunk->from); #ifndef NO_TEXTDOCUMENT_CHUNK_CACHE @@ -1412,15 +1412,15 @@ Q_ASSERT(cachedChunkData.size() == chunk->size()); - cachedChunk = const_cast(chunk); + cachedChunk = const_cast(chunk); cachedChunkPos = chunkPos; return cachedChunkData; /*#ifdef QT_DEBUG - if (chunkPos != chunk->pos()) { - qWarning() << chunkPos << chunk->pos(); - } - Q_ASSERT(chunkPos == chunk->pos()); + if (chunkPos != chunk->pos()) { + qWarning() << chunkPos << chunk->pos(); + } + Q_ASSERT(chunkPos == chunk->pos()); #endif*/ } else { @@ -1433,7 +1433,7 @@ return data; #endif } - //Q_ASSERT(data.size() == chunk->size()); + // Q_ASSERT(data.size() == chunk->size()); #ifndef NO_TEXTDOCUMENT_CHUNK_CACHE #ifdef DEBUG_CACHE_HITS qWarning() << "chunkData hits" << hits << "misses" << ++misses; @@ -1480,7 +1480,7 @@ // Don't want to cache this chunk since it's going away. If it // already was cached then sure, but otherwise don't if (chunk == cachedChunk) { - cachedChunk = 0; + cachedChunk = 0; cachedChunkPos = -1; cachedChunkData.clear(); } @@ -1505,7 +1505,7 @@ } #ifndef NO_TEXTDOCUMENT_CHUNK_CACHE if (c == cachedChunk) { - cachedChunk = 0; + cachedChunk = 0; cachedChunkPos = -1; cachedChunkData.clear(); } @@ -1579,11 +1579,11 @@ Q_ASSERT(c); if (c->firstLineIndex == -1) { Chunk* cc = c; - int pos = chunkPos; + int pos = chunkPos; while (cc->previous && cc->previous->firstLineIndex == -1) { - //pos -= cc->size(); - //Here chunkPos points to the position (the beginning) of the chunk so - //the line above was incorrect had to be changed like this: + // pos -= cc->size(); + // Here chunkPos points to the position (the beginning) of the chunk so + // the line above was incorrect had to be changed like this: pos -= cc->previous->size(); cc = cc->previous; } @@ -1597,7 +1597,7 @@ cc->firstLineIndex = 0; } else { - const int prevSize = cc->previous->size(); + const int prevSize = cc->previous->size(); const int lineCount = countNewLines(cc->previous, pos - prevSize, prevSize); Q_ASSERT(cc->previous->firstLineIndex != -1); cc->firstLineIndex = cc->previous->firstLineIndex + lineCount; @@ -1688,9 +1688,9 @@ if (!c->swap.isEmpty()) return; Q_ASSERT(!c->data.isEmpty()); - c->from = 0; + c->from = 0; c->length = c->data.size(); - c->swap = q->swapFileName(c); + c->swap = q->swapFileName(c); QFile file(c->swap); if (!file.open(QIODevice::WriteOnly)) { qWarning("TextDocumentPrivate::chunkData() Can't open file for writing '%s'", qPrintable(c->swap)); @@ -1705,7 +1705,7 @@ #ifndef NO_TEXTDOCUMENT_CHUNK_CACHE // ### do I want to do this? if (cachedChunk == c) { - cachedChunk = 0; + cachedChunk = 0; cachedChunkPos = -1; cachedChunkData.clear(); } @@ -1719,7 +1719,7 @@ static inline bool match(int pos, int size, const TextPagerSection* section, TextPagerSection::TextSectionOptions flags) { - const int sectionPos = section->position(); + const int sectionPos = section->position(); const int sectionSize = section->size(); if (::match(sectionPos, pos, size) && ::match(sectionPos + sectionSize - 1, pos, size)) { diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerDocument.hpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerDocument.hpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerDocument.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerDocument.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -60,14 +60,14 @@ enum Option { - NoOptions = 0x0000, - SwapChunks = 0x0001, - KeepTemporaryFiles = 0x0002, - ConvertCarriageReturns = 0x0004, // incompatible with Sparse and must be set before loading + NoOptions = 0x0000, + SwapChunks = 0x0001, + KeepTemporaryFiles = 0x0002, + ConvertCarriageReturns = 0x0004, // incompatible with Sparse and must be set before loading AutoDetectCarriageReturns = 0x0010, - NoImplicitLoadAll = 0x0020, - Locking = 0x0040, - DefaultOptions = AutoDetectCarriageReturns + NoImplicitLoadAll = 0x0020, + Locking = 0x0040, + DefaultOptions = AutoDetectCarriageReturns }; Q_DECLARE_FLAGS(Options, Option); @@ -109,13 +109,13 @@ enum FindModeFlag { - FindNone = 0x00000, - FindBackward = 0x00001, + FindNone = 0x00000, + FindBackward = 0x00001, FindCaseSensitively = 0x00002, - FindWholeWords = 0x00004, - FindAllowInterrupt = 0x00008, - FindWrap = 0x00010, - FindAll = 0x00020 + FindWholeWords = 0x00004, + FindAllowInterrupt = 0x00008, + FindWrap = 0x00010, + FindAll = 0x00020 }; Q_DECLARE_FLAGS(FindMode, FindModeFlag); diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerDocument_p.hpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerDocument_p.hpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerDocument_p.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerDocument_p.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -92,11 +92,14 @@ mutable QString data; Chunk *previous, *next; - int size() const { return data.isEmpty() ? length : data.size(); } + int size() const + { + return data.isEmpty() ? length : data.size(); + } #ifdef QT_DEBUG int pos() const { - int p = 0; + int p = 0; Chunk* c = previous; while (c) { p += c->size(); @@ -124,9 +127,9 @@ static inline QPair intersection(int index1, int size1, int index2, int size2) { QPair ret; - ret.first = qMax(index1, index2); + ret.first = qMax(index1, index2); const int right = qMin(index1 + size1, index2 + size2); - ret.second = right - ret.first; + ret.second = right - ret.first; if (ret.second <= 0) return qMakePair(-1, 0); return ret; @@ -191,9 +194,9 @@ ownDevice(false), modified(false), deviceMode(TextPagerDocument::Sparse), - chunkSize(64 * 1024), //chunkSize(1024*64), //chunkSize(16384), - //undoRedoStackCurrent(0), modifiedIndex(-1), undoRedoEnabled(true), ignoreUndoRedo(false), - //collapseInsertUndo(false), + chunkSize(64 * 1024), // chunkSize(1024*64), //chunkSize(16384), + // undoRedoStackCurrent(0), modifiedIndex(-1), undoRedoEnabled(true), ignoreUndoRedo(false), + // collapseInsertUndo(false), hasChunksWithLineNumbers(false), textCodec(0), options(TextPagerDocument::DefaultOptions), @@ -281,7 +284,10 @@ friend class TextPagerDocument; void swapOutChunk(Chunk* c); QList getSections(int from, int size, TextPagerSection::TextSectionOptions opt, const TextPagerEdit* filter) const; - inline TextPagerSection* sectionAt(int pos, const TextPagerEdit* filter) const { return getSections(pos, 1, TextPagerSection::IncludePartial, filter).value(0); } + inline TextPagerSection* sectionAt(int pos, const TextPagerEdit* filter) const + { + return getSections(pos, 1, TextPagerSection::IncludePartial, filter).value(0); + } void textEditDestroyed(TextPagerEdit* edit); Q_SIGNALS: void sectionFormatChanged(TextPagerSection* section); @@ -318,14 +324,14 @@ chunk = doc->chunkAt(p, &offset); Q_ASSERT(chunk); const int chunkPos = p - offset; - chunkData = doc->chunkData(chunk, chunkPos); - //chunkLines = chunkData.split('\n'); + chunkData = doc->chunkData(chunk, chunkPos); + // chunkLines = chunkData.split('\n'); Q_COMPARE_ASSERT(chunkData.size(), chunk->size()); #ifdef QT_DEBUG if (p != d->documentSize) { if (doc->q->readCharacter(p) != chunkData.at(offset)) { - //qDebug() << "got" << chunkData.at(offset) << "at" << offset << "in" << chunk << "of size" << chunkData.size() - // << "expected" << doc->q->readCharacter(p) << "at document pos" << pos; + // qDebug() << "got" << chunkData.at(offset) << "at" << offset << "in" << chunk << "of size" << chunkData.size() + // << "expected" << doc->q->readCharacter(p) << "at document pos" << pos; } Q_ASSERT(chunkData.at(offset) == doc->q->readCharacter(p)); } @@ -362,7 +368,7 @@ max = bound; Q_ASSERT(pos <= max); - //We suppose that the document size does not change + // We suppose that the document size does not change end_ = end(); } @@ -391,7 +397,7 @@ if (pos == end()) return QChar(); -//Calling readCharacter is very expensive during find!!! So we try not to call it!!! +// Calling readCharacter is very expensive during find!!! So we try not to call it!!! #if 0 #ifdef QT_DEBUG if (doc->q->readCharacter(pos) != chunkData.at(offset)) { @@ -404,7 +410,7 @@ ASSUME(doc->q->readCharacter(pos) == chunkData.at(offset)); #endif return convert ? chunkData.at(offset).toLower() : chunkData.at(offset); - //return convert ? chunkData[offset].toLower() : chunkData[offset]; + // return convert ? chunkData[offset].toLower() : chunkData[offset]; #else return convert ? doc->q->readCharacter(pos).toLower() : doc->q->readCharacter(pos); #endif @@ -418,7 +424,7 @@ Q_ASSERT(chunk); if (++offset >= chunkData.size() && chunk->next) { // special case for offset == chunkData.size() and !chunk->next offset = 0; - chunk = chunk->next; + chunk = chunk->next; Q_ASSERT(chunk); chunkData = doc->chunkData(chunk, pos); Q_COMPARE_ASSERT(chunkData.size(), chunk->size()); @@ -449,10 +455,10 @@ enum Direction { - None = 0x0, - Left = 0x1, + None = 0x0, + Left = 0x1, Right = 0x2, - Both = Left | Right + Both = Left | Right }; inline QChar nextPrev(Direction dir, bool& ok) { @@ -484,29 +490,29 @@ Q_ASSERT(doc); #ifdef _UI_TEXTPAGER_ITERATOR_DEBUG - //qDebug() << "prevLine --->" << pos << offset; //<< chunkData; + // qDebug() << "prevLine --->" << pos << offset; //<< chunkData; #endif - //If we are at the start + // If we are at the start if (pos <= min) return 0; - //Get the QString in the chunk as a const pointer. It is faster to iterate through it than - //calling QString::at() + // Get the QString in the chunk as a const pointer. It is faster to iterate through it than + // calling QString::at() const QChar* data = chunkData.constData(); data += offset; Q_ASSERT(*data == chunkData.at(offset)); - //The current character is probably a newline (the - //result of the previous call) so we need to take a step back + // The current character is probably a newline (the + // result of the previous call) so we need to take a step back if (*data == newline) { --pos; --offset; - //See if we need the previous chunk + // See if we need the previous chunk if (offset < 0) { - //The previous chunk must exist + // The previous chunk must exist bool b = loadPrevChunk(); Q_ASSERT(b == true); data = chunkData.constData(); @@ -520,14 +526,14 @@ return 0; } - //Mark the line end position within the chunk + // Mark the line end position within the chunk int to = offset; - //We will go backwards until we find a newline + // We will go backwards until we find a newline while (*data != newline) { - //Q_ASSERT(*data == chunkData.at(offset)); + // Q_ASSERT(*data == chunkData.at(offset)); #ifdef _UI_TEXTPAGER_ITERATOR_DEBUG - //qDebug() << pos << offset << chunkData.at(offset) << to; + // qDebug() << pos << offset << chunkData.at(offset) << to; #endif if (pos <= min) { if (to != offset) { @@ -543,25 +549,25 @@ --pos; - //If we need the previous chunk + // If we need the previous chunk if (--offset < 0) { - //Copy the line portion from this chunk to the result + // Copy the line portion from this chunk to the result if (str.size() == 0) str = chunkData.mid(0, to); else str.prepend(chunkData.mid(0, to)); - //Get previous chunk + // Get previous chunk bool b = loadPrevChunk(); Q_ASSERT(b == true); - //Initialise the search positions + // Initialise the search positions data = chunkData.constData(); data += offset; to = offset; #ifdef _UI_TEXTPAGER_ITERATOR_DEBUG - //qDebug() << "change" << pos << offset << *data << chunkData.at(offset); + // qDebug() << "change" << pos << offset << *data << chunkData.at(offset); #endif } else { @@ -570,10 +576,10 @@ } #ifdef _UI_TEXTPAGER_ITERATOR_DEBUG - //qDebug() << pos << offset << to; + // qDebug() << pos << offset << to; #endif - //offset is either a newline charter or 0 (the start of the document) + // offset is either a newline charter or 0 (the start of the document) if (to != offset) { if (str.size() == 0) { @@ -586,7 +592,7 @@ #endif #ifdef _UI_TEXTPAGER_ITERATOR_DEBUG - //qDebug() << "line:" << str; + // qDebug() << "line:" << str; #endif return 1; @@ -602,28 +608,28 @@ Q_ASSERT(doc); #ifdef _UI_TEXTPAGER_ITERATOR_DEBUG - //qDebug() << "nextLine --->" << pos << offset << chunkData.size() << chunkData.at(offset); + // qDebug() << "nextLine --->" << pos << offset << chunkData.size() << chunkData.at(offset); #endif int posEnd = end(); if (pos >= posEnd) return 0; - //Get the QString in the chunk as a const pointer. It is faster to iterate through it than - //calling QString::at() + // Get the QString in the chunk as a const pointer. It is faster to iterate through it than + // calling QString::at() const QChar* data = chunkData.constData(); data += offset; Q_ASSERT(*data == chunkData.at(offset)); - //The current character is probably a newline (the - //result of the previous call) so we need to take a step forward + // The current character is probably a newline (the + // result of the previous call) so we need to take a step forward if (*data == newline) { ++pos; ++offset; - //See if we need the next chunk + // See if we need the next chunk if (offset >= chunkData.size()) { - //Has next chunk + // Has next chunk if (loadNextChunk()) { data = chunkData.constData(); Q_ASSERT(offset == 0); @@ -642,13 +648,13 @@ return 0; } - //Mark the line start position within the chunk + // Mark the line start position within the chunk int from = offset; - //We will go forward until we find a newline + // We will go forward until we find a newline while (*data != newline) { #ifdef _UI_TEXTPAGER_ITERATOR_DEBUG - //qDebug() << pos << offset << chunkData.at(offset); + // qDebug() << pos << offset << chunkData.at(offset); #endif if (pos >= posEnd) { if (str.size() == 0) @@ -661,17 +667,17 @@ ++pos; - //If we need the next chunk + // If we need the next chunk if (++offset >= chunkData.size()) { - //Copy the line portion from this chunk to the result + // Copy the line portion from this chunk to the result if (str.size() == 0) str = chunkData.mid(from, offset - from); else str.append(chunkData.mid(from, offset - from)); - //Get next chunk + // Get next chunk if (loadNextChunk()) { - //Initialise the search positions + // Initialise the search positions data = chunkData.constData(); from = 0; } @@ -697,7 +703,7 @@ #endif #ifdef _UI_TEXTPAGER_ITERATOR_DEBUG - //qDebug() << "line:" << str; + // qDebug() << "line:" << str; #endif return 1; diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerEdit.cpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerEdit.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerEdit.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerEdit.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -78,12 +78,12 @@ connect(d->actions[i], SIGNAL(triggered(bool)), this, shortcuts[i].member); addAction(d->actions[i]); } - //connect(this, SIGNAL(undoAvailableChanged(bool)), d->actions[UndoAction], SLOT(setEnabled(bool))); - //connect(this, SIGNAL(redoAvailableChanged(bool)), d->actions[RedoAction], SLOT(setEnabled(bool))); - //d->actions[UndoAction]->setEnabled(false); - //d->actions[RedoAction]->setEnabled(false); + // connect(this, SIGNAL(undoAvailableChanged(bool)), d->actions[UndoAction], SLOT(setEnabled(bool))); + // connect(this, SIGNAL(redoAvailableChanged(bool)), d->actions[RedoAction], SLOT(setEnabled(bool))); + // d->actions[UndoAction]->setEnabled(false); + // d->actions[RedoAction]->setEnabled(false); setContextMenuPolicy(Qt::ActionsContextMenu); - //setCursorVisible(true); // starts blinking + // setCursorVisible(true); // starts blinking connect(this, SIGNAL(selectionChanged()), d, SLOT(onSelectionChanged())); @@ -154,7 +154,7 @@ Q_FOREACH (SyntaxHighlighter* syntaxHighlighter, d->syntaxHighlighters) { if (syntaxHighlighter->parent() == this) disconnect(syntaxHighlighter, 0, d, 0); - syntaxHighlighter->d->textEdit = 0; + syntaxHighlighter->d->textEdit = 0; syntaxHighlighter->d->textLayout = 0; } disconnect(d->document, 0, this, 0); @@ -215,10 +215,10 @@ d->sections.clear(); d->buffer.clear(); - d->sectionsDirty = true; - d->document = doc; + d->sectionsDirty = true; + d->document = doc; d->sectionPressed = 0; - d->layoutDirty = true; + d->layoutDirty = true; qDeleteAll(d->unusedTextLayouts); d->unusedTextLayouts.clear(); qDeleteAll(d->textLayouts); @@ -227,7 +227,7 @@ viewport()->setMouseTracking(true); d->sectionCount = 0; - d->textCursor = TextPagerCursor(doc); + d->textCursor = TextPagerCursor(doc); d->textCursor.textEdit = this; /*connect(d->document->d, SIGNAL(undoRedoCommandInserted(DocumentCommand *)), @@ -327,17 +327,17 @@ } #endif - //UserMessage::message(UserMessage::DBG,false,"TextPagerEdit::load fileName" + file.toStdString()); - //we have to check to font here because the initial setting in setFontProperty doe not have any effect + // UserMessage::message(UserMessage::DBG,false,"TextPagerEdit::load fileName" + file.toStdString()); + // we have to check to font here because the initial setting in setFontProperty doe not have any effect updateFont(); bool ret = d->document->load(file, mode, codec); - //UserMessage::message(UserMessage::DBG,false," cursor: " + QString::number(textCursor().position()).toStdString()); + // UserMessage::message(UserMessage::DBG,false," cursor: " + QString::number(textCursor().position()).toStdString()); return ret; } void TextPagerEdit::setText(const QString& txt) { - //we have to check to font here because the initial setting in setFontProperty doe not have any effect + // we have to check to font here because the initial setting in setFontProperty doe not have any effect updateFont(); d->document->setText(txt); } @@ -362,7 +362,7 @@ if (cursor.selectionStart() > layoutStart + layoutLength) return After; - format->start = qMax(0, cursor.selectionStart() - layoutStart); + format->start = qMax(0, cursor.selectionStart() - layoutStart); format->length = qMin(layoutLength - format->start, cursor.selectionEnd() - layoutStart - format->start); return Success; @@ -387,12 +387,12 @@ int textLayoutOffset = d->viewportPosition; const QTextLayout* cursorLayout = d->cursorVisible ? d->layoutForPosition(d->textCursor.position()) : 0; - int extraSelectionIndex = 0; + int extraSelectionIndex = 0; QTextLayout::FormatRange selectionRange; selectionRange.start = -1; Q_FOREACH (QTextLayout* l, d->textLayouts) { const int textSize = l->text().size(); - const QRect r = l->boundingRect().toRect(); + const QRect r = l->boundingRect().toRect(); if (r.intersects(er)) { const QBrush background = d->blockFormats.value(l).background(); if (background.style() != Qt::NoBrush) { @@ -412,7 +412,7 @@ selections.append(range); const TextPagerCursor& cursor = d->extraSelections.at(extraSelectionIndex).cursor; - int lastPos = cursor.position() + cursor.selectionSize(); + int lastPos = cursor.position() + cursor.selectionSize(); if (lastPos > textLayoutOffset + textSize && lowestIncompleteSelection < 0) { lowestIncompleteSelection = extraSelectionIndex; } @@ -455,7 +455,7 @@ } - //paintLineNumberArea(e); + // paintLineNumberArea(e); } void TextPagerEdit::scrollContentsBy(int dx, int dy) @@ -502,7 +502,7 @@ e->accept(); - //The cursor changed so wee need to update the selected line number + // The cursor changed so wee need to update the selected line number lineNumArea_->update(); } else { @@ -550,7 +550,7 @@ ds << int(e->type()) << e->pos() << e->button() << e->buttons() << e->modifiers(); } #endif - const QRect r = viewport()->rect(); + const QRect r = viewport()->rect(); d->lastMouseMove = e->pos(); e->accept(); if (e->y() < r.top()) { @@ -574,7 +574,7 @@ d->autoScrollTimer.stop(); setCursorPosition(pos, TextPagerCursor::KeepAnchor); - //The cursor changed so wee need to update the selected line number + // The cursor changed so wee need to update the selected line number lineNumArea_->update(); return; @@ -646,7 +646,7 @@ if (e->oldSize().height() != e->size().height()) d->adjustVerticalScrollBar(); d->updateScrollBarPageStepPending = true; - d->layoutDirty = true; + d->layoutDirty = true; } int TextPagerEdit::textPositionAt(const QPoint& pos) const @@ -657,7 +657,7 @@ QPoint realPos = pos; realPos += QPoint(horizontalScrollBar()->value(), 0); - //Adjust the horizontal position + // Adjust the horizontal position /* if(pos.x() > horizontalScrollBar()->value()+viewport()->rect().width()) { int hval=realCrect.left()-r.width()/2; @@ -719,7 +719,7 @@ { if (d->lineBreaking != lineBreaking) { d->lineBreaking = lineBreaking; - d->layoutDirty = true; + d->layoutDirty = true; viewport()->update(); } } @@ -751,7 +751,7 @@ ASSUME(offset != -1); QTextLine line = d->lineForPosition(textCursor.position()); - //if line is empty line.cursorToX() crashes. A qt bug? + // if line is empty line.cursorToX() crashes. A qt bug? if (line.isValid()) { qreal x = line.cursorToX(offset); return QRect(x, line.y(), d->cursorWidth, line.height()); @@ -937,15 +937,15 @@ adjustVerticalScrollBar(); /*int s=findLastPageSize(); - + qDebug() << "lat page position" << s; - + if(s != -1) - textEdit->verticalScrollBar()->setRange(0, s); + textEdit->verticalScrollBar()->setRange(0, s); else - textEdit->verticalScrollBar()->setRange(0, qMax(0, size)); - - + textEdit->verticalScrollBar()->setRange(0, qMax(0, size)); + + //textEdit->verticalScrollBar()->setRange(0, qMax(0, size)); // qDebug() << findLastPageSize(); maxViewportPosition = textEdit->verticalScrollBar()->maximum(); @@ -976,18 +976,18 @@ textEdit->verticalScrollBar()->setRange(0, qMax(0, size)); } - //textEdit->verticalScrollBar()->setRange(0, qMax(0, size)); - // qDebug() << findLastPageSize(); - maxViewportPosition = textEdit->verticalScrollBar()->maximum(); + // textEdit->verticalScrollBar()->setRange(0, qMax(0, size)); + // qDebug() << findLastPageSize(); + maxViewportPosition = textEdit->verticalScrollBar()->maximum(); updateScrollBarPageStepPending = true; } void TextEditPrivate::updateCopyAndCutEnabled() { const bool wasEnabled = actions[TextPagerEdit::CopyAction]->isEnabled(); - const bool enable = qAbs(textCursor.position() - textCursor.anchor()) <= maximumSizeCopy; + const bool enable = qAbs(textCursor.position() - textCursor.anchor()) <= maximumSizeCopy; actions[TextPagerEdit::CopyAction]->setEnabled(enable); - //actions[TextPagerEdit::CutAction]->setEnabled(enable); + // actions[TextPagerEdit::CutAction]->setEnabled(enable); if (wasEnabled != enable) { Q_EMIT textEdit->copyAvailable(enable); } @@ -999,7 +999,7 @@ const bool found = d->syntaxHighlighters.removeOne(highlighter); Q_ASSERT(found); Q_UNUSED(found); - highlighter->d->textEdit = 0; + highlighter->d->textEdit = 0; highlighter->d->textLayout = 0; disconnect(highlighter, 0, d, 0); } @@ -1023,9 +1023,9 @@ } d->syntaxHighlighters.append(highlighter); connect(highlighter, SIGNAL(destroyed(QObject*)), d, SLOT(onSyntaxHighlighterDestroyed(QObject*))); - highlighter->d->textEdit = this; + highlighter->d->textEdit = this; highlighter->d->textLayout = d; - d->layoutDirty = true; + d->layoutDirty = true; viewport()->update(); } } @@ -1103,7 +1103,7 @@ if (blockScrollBarUpdate || value == requestedScrollBarPosition || value == viewportPosition) return; requestedScrollBarPosition = value; - layoutDirty = true; + layoutDirty = true; textEdit->viewport()->update(); Q_EMIT scrollBarChanged(); @@ -1145,10 +1145,10 @@ { Q_ASSERT(!textEdit->verticalScrollBar()->isSliderDown()); if (pendingScrollBarUpdate) { - const bool old = blockScrollBarUpdate; + const bool old = blockScrollBarUpdate; blockScrollBarUpdate = true; textEdit->verticalScrollBar()->setValue(viewportPosition); - blockScrollBarUpdate = old; + blockScrollBarUpdate = old; pendingScrollBarUpdate = false; Q_EMIT scrollBarChanged(); @@ -1165,8 +1165,8 @@ if (textCursor.position() > document->documentSize()) textCursor.setPosition(0); - //UserMessage::message(UserMessage::DBG,false, - // "TextEditPrivate::onCharactersAddedOrRemoved --> textCursor: " + QString::number(textCursor.position()).toStdString()); + // UserMessage::message(UserMessage::DBG,false, + // "TextEditPrivate::onCharactersAddedOrRemoved --> textCursor: " + QString::number(textCursor.position()).toStdString()); /*if (from > qMin(bufferPosition + buffer.size(), layoutEnd)) { return; @@ -1186,14 +1186,14 @@ viewport()->update(); } else { - const QRect r = viewport()->rect(); + const QRect r = viewport()->rect(); QRect realCrect = cursorRect(d->textCursor); - QRect crect = realCrect; + QRect crect = realCrect; crect.setLeft(r.left()); crect.setRight(r.right()); // ### what if the cursor is out of bounds horizontally? - //qDebug() << "ensureCursorVisible" << r << crect << cursorRect(d->textCursor) << horizontalScrollBar()->value() << horizontalScrollBar()->maximum() << d->widest; + // qDebug() << "ensureCursorVisible" << r << crect << cursorRect(d->textCursor) << horizontalScrollBar()->value() << horizontalScrollBar()->maximum() << d->widest; if (!r.contains(crect)) { if (r.intersects(crect)) { int scroll; @@ -1211,7 +1211,7 @@ viewport()->update(); } - //Adjust the horizontal position + // Adjust the horizontal position if (realCrect.left() > horizontalScrollBar()->value() + r.width()) { int hval = realCrect.left() - r.width() / 2; horizontalScrollBar()->setValue((hval < horizontalScrollBar()->maximum()) ? hval : horizontalScrollBar()->maximum()); @@ -1223,8 +1223,8 @@ } } -//textEdit->horizontalScrollBar()->setPageStep(s.width()); -//textEdit->horizontalScrollBar()->setMaximum(qMax(0, widest - s.width())); +// textEdit->horizontalScrollBar()->setPageStep(s.width()); +// textEdit->horizontalScrollBar()->setMaximum(qMax(0, widest - s.width())); TextPagerCursor& TextPagerEdit::textCursor() @@ -1239,8 +1239,8 @@ void TextPagerEdit::setTextCursor(const TextPagerCursor& textCursor) { - const bool doEmit = (d->textCursor != textCursor); - d->textCursor = textCursor; + const bool doEmit = (d->textCursor != textCursor); + d->textCursor = textCursor; d->textCursor.textEdit = this; if (doEmit) { ensureCursorVisible(); @@ -1305,7 +1305,7 @@ return; } - const int req = requestedScrollBarPosition; + const int req = requestedScrollBarPosition; requestedScrollBarPosition = -1; Direction direction = Forward; @@ -1343,9 +1343,9 @@ { // IR: see comment at the top of cursorMoveKeyEventReadOnly(). - int pos = viewportPosition; + int pos = viewportPosition; const Direction d = (lines < 0 ? Backward : Forward); - const int add = lines < 0 ? -1 : 1; + const int add = lines < 0 ? -1 : 1; while (pos + add >= 0 && pos + add < document->documentSize()) { if (d == Forward && @@ -1429,7 +1429,7 @@ void TextEditPrivate::updateCursorPosition(const QPoint& pos) { - lastHoverPos = pos; + lastHoverPos = pos; const int textPos = textPositionAt(pos); if (textPos != -1) { QList hovered = textEdit->sections(textPos, 1, TextPagerSection::IncludePartial); @@ -1450,7 +1450,7 @@ sectionCursor = 0; } - //To notify the line num area widge! + // To notify the line num area widge! Q_EMIT scrollBarChanged(); } @@ -1567,8 +1567,8 @@ } -//Find the viewport position for the end of the document supposing the the last line -//is exactly located at the bottom of the viewport. +// Find the viewport position for the end of the document supposing the the last line +// is exactly located at the bottom of the viewport. int TextEditPrivate::findLastPageSize() const { if (!document || document->documentSize() == 0) @@ -1578,19 +1578,19 @@ qDebug() << "TextEditPrivate::findLastPageSize -->"; #endif TextEditPrivate p(textEdit); - p.font = textEdit->font(); - p.viewportPosition = 0; - p.document = document; + p.font = textEdit->font(); + p.viewportPosition = 0; + p.document = document; const int documentSize = document->documentSize(); - p.maxViewportPosition = documentSize; + p.maxViewportPosition = documentSize; - //The viewport height (including the height of the horizontal slider) + // The viewport height (including the height of the horizontal slider) int vh = p.textEdit->viewport()->height(); //-p.textEdit->horizontalScrollBar()->height(); - //Max 1.5*MinimumBufferSize can be kept in the buffer after the viewportPosition + // Max 1.5*MinimumBufferSize can be kept in the buffer after the viewportPosition int maxCharNum = p.MinimumBufferSize * 1.5 - 200; - //We use the lastpage cache to find a better start position + // We use the lastpage cache to find a better start position #ifdef DEBUG_TEXTPAGER_LASTPAGESIZE qDebug() << " lastPageCache height:" << lastPage.height << "position:" << lastPage.position << "documentSize:" << lastPage.documentSize << "widest:" << lastPage.widest; @@ -1604,11 +1604,11 @@ Direction sizeChangeDir = Forward; if (lastPage.height != -1) { if (lastPage.height > vh) { - maxCharNum = documentSize - lastPage.position + 1; + maxCharNum = documentSize - lastPage.position + 1; sizeChangeDir = Backward; } else if (lastPage.height < vh) { - maxCharNum = documentSize - lastPage.position + 1000; + maxCharNum = documentSize - lastPage.position + 1000; sizeChangeDir = Backward; } else { @@ -1629,27 +1629,27 @@ tm.start(); #endif - //Try to find the last page by iteration - int step = 0; + // Try to find the last page by iteration + int step = 0; const int maxStep = 10; - bool reachedTop = (start == 0); + bool reachedTop = (start == 0); while (step < maxStep) { #ifdef DEBUG_TEXTPAGER_LASTPAGESIZE qDebug() << " ITERATION STEP:" << step; qDebug() << " start:" << start << "maxCharNum:" << maxCharNum; #endif - //We get the viewportPosition closest to start + // We get the viewportPosition closest to start p.updateViewportPosition(start, sizeChangeDir, false); #ifdef DEBUG_TEXTPAGER_LASTPAGESIZE qDebug() << " after updateviewport> start-viewportPos:" << start - p.viewportPosition; #endif - //adjust the max number of characters + // adjust the max number of characters if (start > p.viewportPosition) maxCharNum += (start - p.viewportPosition) + 1; - //Relayout using the max number of characters + // Relayout using the max number of characters p.relayoutByPosition(maxCharNum); #ifdef DEBUG_TEXTPAGER_LASTPAGESIZE @@ -1659,7 +1659,7 @@ qDebug() << " bottom:" << p.textLayouts.last()->boundingRect().bottom(); #endif - //The end of the layout should be the end of the document + // The end of the layout should be the end of the document if (p.layoutEnd == documentSize && p.textLayouts.count() > 0) { int top = p.textLayouts.last()->boundingRect().bottom() + 4 - vh; int pos = documentSize - p.textLayouts.last()->text().size(); @@ -1674,14 +1674,14 @@ qDebug() << " viewPortPosition:" << p.viewportPosition << "time:" << tm.elapsed(); // << "line:" << p.document->lineNumber(p.viewportPosition); #endif lastPage.position = p.viewportPosition; - lastPage.widest = p.widest; + lastPage.widest = p.widest; return p.viewportPosition; } pos -= p.textLayouts.at(i)->text().size(); } } - //We could not find the last page. We try again from a larger number of characters from the - //end of the document + // We could not find the last page. We try again from a larger number of characters from the + // end of the document step++; maxCharNum += 1000; start = documentSize - maxCharNum; @@ -1691,19 +1691,19 @@ if (start < 0) { reachedTop = true; - start = 0; + start = 0; } } lastPage.clear(); - //the whole text is in the viewport, no vertical scrollbar is needed + // the whole text is in the viewport, no vertical scrollbar is needed if (reachedTop) return -1; - //If we are here we the last page position will be the end of the document and there will be - //a white space block after the last row in the editor. - //TODO: improve it! + // If we are here we the last page position will be the end of the document and there will be + // a white space block after the last row in the editor. + // TODO: improve it! return documentSize; } @@ -1728,14 +1728,14 @@ setSyntaxHighlighter(searchHighlight_); } else { - //searchHighlight_ can only be deleted when the editor is deleted. - //Because clearSyntaxHighlighters() deletes the highlighters we need to use - //takeSyntaxHighlighter() instead. + // searchHighlight_ can only be deleted when the editor is deleted. + // Because clearSyntaxHighlighters() deletes the highlighters we need to use + // takeSyntaxHighlighter() instead. if (d->syntaxHighlighters.contains(searchHighlight_)) { takeSyntaxHighlighter(searchHighlight_); d->layoutDirty = true; viewport()->update(); - //clearSyntaxHighlighters(); + // clearSyntaxHighlighters(); } } } @@ -1826,7 +1826,7 @@ connect(d, SIGNAL(scrollBarChanged()), lineNumArea_, SLOT(update())); - //Initialise the width + // Initialise the width lineNumArea_->updateWidth(); } @@ -1837,8 +1837,8 @@ QPainter painter(lineNumArea_); const QRect er = e->rect(); - //painter.translate(-horizontalScrollBar()->value(), 0); - //painter.setFont(font()); + // painter.translate(-horizontalScrollBar()->value(), 0); + // painter.setFont(font()); QVector selections; selections.reserve(d->extraSelections.size() + 1); @@ -1846,7 +1846,7 @@ QRect numRect = er; - //Background and border + // Background and border painter.fillRect(numRect, lineNumArea_->bgColour()); painter.setPen(QPen(lineNumArea_->separatorColour())); painter.drawLine(lineNumArea_->width() - 1, er.y(), lineNumArea_->width() - 1, er.bottom()); @@ -1861,17 +1861,17 @@ int cursorPos = d->textCursor.position(); - //const QTextLayout *cursorLayout = d->cursorVisible ? d->layoutForPosition(d->textCursor.position()) : 0; - //int extraSelectionIndex = 0; + // const QTextLayout *cursorLayout = d->cursorVisible ? d->layoutForPosition(d->textCursor.position()) : 0; + // int extraSelectionIndex = 0; QTextLayout::FormatRange selectionRange; selectionRange.start = -1; - int maxLineNum = -1; + int maxLineNum = -1; Q_FOREACH (QTextLayout* l, d->textLayouts) { const int textSize = l->text().size(); - const QRect r = l->boundingRect().toRect(); + const QRect r = l->boundingRect().toRect(); if (r.intersects(er)) { const int lineNum = lineNumber(textLayoutOffset) + 1; - maxLineNum = lineNum; + maxLineNum = lineNum; QRect lRect(0, r.y(), numWidth, r.height()); // is this the current line? @@ -1940,7 +1940,7 @@ { if (maxLineNum > 0) { int maxDigits = 1; - int mx = maxLineNum; + int mx = maxLineNum; while (mx >= 10) { mx /= 10; ++maxDigits; diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerEdit.hpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerEdit.hpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerEdit.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerEdit.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -68,7 +68,7 @@ void removeSyntaxHighlighter(SyntaxHighlighter* highlighter); void clearSyntaxHighlighters(); - //bool load(QIODevice *device, TextPagerDocument::DeviceMode mode = TextPagerDocument::Sparse, QTextCodec *codec = 0); + // bool load(QIODevice *device, TextPagerDocument::DeviceMode mode = TextPagerDocument::Sparse, QTextCodec *codec = 0); bool load(const QString& fileName, TextPagerDocument::DeviceMode mode = TextPagerDocument::Sparse, QTextCodec* codec = 0); @@ -162,7 +162,7 @@ void sectionClicked(TextPagerSection* section, const QPoint& pos); protected: - //virtual void paste(int position, QClipboard::Mode mode); + // virtual void paste(int position, QClipboard::Mode mode); virtual void changeEvent(QEvent* e); virtual void keyPressEvent(QKeyEvent* e); virtual void keyReleaseEvent(QKeyEvent* e); diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerEdit_p.hpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerEdit_p.hpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerEdit_p.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerEdit_p.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -39,9 +39,9 @@ documentSize(-1) {} void clear() { - position = -1; - height = -1; - widest = -1; + position = -1; + height = -1; + widest = -1; documentSize = -1; } int position; diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerLayout_p.cpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerLayout_p.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerLayout_p.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerLayout_p.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -45,7 +45,7 @@ << bufferReadCharacter(index - 1); } Q_ASSERT(index == 0 || bufferReadCharacter(index - 1) == '\n'); - const int max = bufferPosition + buffer.size(); + const int max = bufferPosition + buffer.size(); const int lineStart = index; while (index < max && bufferReadCharacter(index) != '\n') ++index; @@ -69,7 +69,7 @@ } // section is in this QTextLayout QTextLayout::FormatRange range; - range.start = qMax(0, l->position() - lineStart); // offset in QTextLayout + range.start = qMax(0, l->position() - lineStart); // offset in QTextLayout range.length = qMin(l->position() + l->size(), index) - lineStart - range.start; range.format = l->format(); formatMap.insertMulti(l->priority(), range); @@ -82,9 +82,9 @@ } QList formats = formatMap.values(); - int leftMargin = LeftMargin; - int rightMargin = 0; - int topMargin = 0; + int leftMargin = LeftMargin; + int rightMargin = 0; + int topMargin = 0; int bottomMargin = 0; Q_FOREACH (SyntaxHighlighter* syntaxHighlighter, syntaxHighlighters) { syntaxHighlighter->d->currentBlockPosition = lineStart; @@ -132,7 +132,7 @@ lines.append(qMakePair(lineStart + line.textStart(), line)); } - widest = qMax(widest, localWidest); + widest = qMax(widest, localWidest); lastBottomMargin = bottomMargin; textLayout->endLayout(); @@ -153,7 +153,7 @@ Q_FOREACH (SyntaxHighlighter* syntaxHighlighter, syntaxHighlighters) { syntaxHighlighter->d->formatRanges.clear(); - syntaxHighlighter->d->blockFormat = QTextBlockFormat(); + syntaxHighlighter->d->blockFormat = QTextBlockFormat(); syntaxHighlighter->d->currentBlockPosition = -1; } @@ -169,7 +169,7 @@ int textLayoutOffset = viewportPosition; Q_FOREACH (const QTextLayout* l, textLayouts) { if (l->boundingRect().y() <= pos.y() && l->boundingRect().bottom() >= pos.y()) { - //if (l->boundingRect().toRect().contains(pos)) { + // if (l->boundingRect().toRect().contains(pos)) { const int lineCount = l->lineCount(); for (int i = 0; i < lineCount; ++i) { const QTextLine line = l->lineAt(i); @@ -197,7 +197,7 @@ lines.clear(); unusedTextLayouts = textLayouts; textLayouts.clear(); - contentRect = QRect(); + contentRect = QRect(); visibleLines = lastVisibleCharacter = -1; Q_FOREACH (SyntaxHighlighter* syntaxHighlighter, syntaxHighlighters) { @@ -206,13 +206,13 @@ if (viewportPosition < bufferPosition || (bufferPosition + buffer.size() < document->documentSize() && buffer.size() - bufferOffset() < MinimumBufferSize)) { bufferPosition = qMax(0, viewportPosition - MinimumBufferSize); - buffer = document->read(bufferPosition, int(MinimumBufferSize * 2.5)); - sections = document->d->getSections(bufferPosition, buffer.size(), TextPagerSection::IncludePartial, textEdit); + buffer = document->read(bufferPosition, int(MinimumBufferSize * 2.5)); + sections = document->d->getSections(bufferPosition, buffer.size(), TextPagerSection::IncludePartial, textEdit); } else if (sectionsDirty) { sections = document->d->getSections(bufferPosition, buffer.size(), TextPagerSection::IncludePartial, textEdit); } - sectionsDirty = false; + sectionsDirty = false; QList l = sections; while (!l.isEmpty() && l.first()->position() + l.first()->size() < viewportPosition) l.takeFirst(); // could cache these as well @@ -230,7 +230,7 @@ ASSUME(viewportPosition == 0 || bufferReadCharacter(viewportPosition - 1) == '\n'); static const int extraLines = qMax(2, qgetenv("LAZYTEXTEDIT_EXTRA_LINES").toInt()); - int index = viewportPosition; + int index = viewportPosition; while (index < max) { index = doLayout(index, l.isEmpty() ? 0 : &l); Q_ASSERT(index == max || document->readCharacter(index - 1) == '\n'); @@ -238,7 +238,7 @@ const int y = int(textLayouts.last()->boundingRect().bottom()); if (y >= height) { if (visibleLines == -1) { - visibleLines = lines.size(); + visibleLines = lines.size(); lastVisibleCharacter = index; } else if (lines.size() >= visibleLines + extraLines) { @@ -247,7 +247,7 @@ } } if (visibleLines == -1) { - visibleLines = lines.size(); + visibleLines = lines.size(); lastVisibleCharacter = index; } @@ -283,7 +283,7 @@ void TextPagerLayout::relayout() { - //relayoutByPosition(2000); // ### totally arbitrary number + // relayoutByPosition(2000); // ### totally arbitrary number relayoutByPosition(1.5 * MinimumBufferSize); } @@ -299,7 +299,7 @@ } int textLayoutOffset = viewportPosition; - int i = 0; + int i = 0; Q_FOREACH (QTextLayout* l, textLayouts) { if (pos >= textLayoutOffset && pos <= l->text().size() + textLayoutOffset) { @@ -327,13 +327,13 @@ if (pos < viewportPosition || pos >= layoutEnd || textLayouts.isEmpty() || lines.isEmpty()) { return QTextLine(); } - int layoutIndex = 0; + int layoutIndex = 0; QTextLayout* layout = textLayouts.value(layoutIndex); Q_ASSERT(layout); for (int i = 0; i < lines.size(); ++i) { const QPair& line = lines.at(i); - int lineEnd = line.first + line.second.textLength(); - const bool last = line.second.lineNumber() + 1 == layout->lineCount(); + int lineEnd = line.first + line.second.textLength(); + const bool last = line.second.lineNumber() + 1 == layout->lineCount(); if (last) { ++lineEnd; // 1 is for newline characters @@ -407,7 +407,7 @@ if (applyIt) { if (textEdit && !suppressTextEditUpdates) { textEdit->viewport()->update(); - TextEditPrivate* p = static_cast(this); + TextEditPrivate* p = static_cast(this); p->pendingScrollBarUpdate = true; p->updateCursorPosition(p->lastHoverPos); if (!textEdit->verticalScrollBar()->isSliderDown()) { diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerLayout_p.hpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerLayout_p.hpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerLayout_p.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerLayout_p.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -73,7 +73,7 @@ enum { MinimumBufferSize = 90000, - LeftMargin = 3 + LeftMargin = 3 }; TextPagerLayout(TextPagerDocument* doc = 0) : TextDocumentBuffer(doc), @@ -132,7 +132,7 @@ enum Direction { - Forward = 0, + Forward = 0, Backward = TextPagerDocument::FindBackward }; void updateViewportPosition(int pos, Direction direction, bool applyIt = true); diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerSearchHighlighter.cpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerSearchHighlighter.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerSearchHighlighter.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerSearchHighlighter.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -33,7 +33,7 @@ rx_ = QRegExp("(server)"); } -//from QRegExp +// from QRegExp bool TextPagerSearchHighlighter::isWordCharacter(const QChar& ch) const { return ch.isLetterOrNumber() || ch.isMark() || ch == QLatin1Char('_'); @@ -80,26 +80,26 @@ { bool changed = false; if (mode_ != TextMode) { - mode_ = TextMode; - rx_ = QRegExp(); + mode_ = TextMode; + rx_ = QRegExp(); changed = true; } if (txt != text_) { - text_ = txt; + text_ = txt; changed = true; } bool cs = mode & TextPagerDocument::FindCaseSensitively; if (cs != caseSensitive_) { caseSensitive_ = cs; - changed = true; + changed = true; } bool ww = mode & TextPagerDocument::FindWholeWords; if (ww != wholeWords_) { wholeWords_ = ww; - changed = true; + changed = true; } if (changed && apply) @@ -117,7 +117,7 @@ if (rx_.pattern() != rx.pattern() || rx_.caseSensitivity() != rx.caseSensitivity() || rx_.patternSyntax() != rx.patternSyntax()) { - rx_ = rx; + rx_ = rx; changed = true; } diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerSearchInterface.cpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerSearchInterface.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerSearchInterface.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerSearchInterface.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -85,7 +85,7 @@ if (doSearch) { cursor = editor_->document()->find(str, cursor, mode); // perform the search - found = (!cursor.isNull()); + found = (!cursor.isNull()); } break; } @@ -98,7 +98,7 @@ if (doSearch) { cursor = editor_->document()->find(regexp, cursor, mode); // perform the search } - found = (!cursor.isNull()); + found = (!cursor.isNull()); } break; } @@ -110,7 +110,7 @@ if (doSearch) { cursor = editor_->document()->find(regexp, cursor, mode); // perform the search - found = (!cursor.isNull()); + found = (!cursor.isNull()); } break; } @@ -154,7 +154,7 @@ if (searchFrom == "bottom") { findFlags = QTextDocument::FindBackward; - move = QTextCursor::End; + move = QTextCursor::End; } else { move = QTextCursor::Start; diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerSection.cpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerSection.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerSection.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerSection.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -42,7 +42,7 @@ void TextPagerSection::setCursor(const QCursor& cursor) { - d.cursor = cursor; + d.cursor = cursor; d.hasCursor = true; Q_EMIT d.document->d->sectionCursorChanged(this); } @@ -50,7 +50,7 @@ void TextPagerSection::resetCursor() { d.hasCursor = false; - d.cursor = QCursor(); + d.cursor = QCursor(); Q_EMIT d.document->d->sectionCursorChanged(this); } diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerWidget.cpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerWidget.cpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerWidget.cpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerWidget.cpp 2023-07-15 08:28:47.000000000 +0000 @@ -34,7 +34,7 @@ bool add = false; TextPagerWidget::TextPagerWidget(QWidget* parent) : - //TextPagerEdit(parent), + // TextPagerEdit(parent), doLineNumbers(true), gotoLineDialog_(nullptr) { @@ -42,7 +42,7 @@ hb->setContentsMargins(0, 0, 0, 0); hb->setSpacing(0); - textEditor_ = new TextPagerEdit(this); + textEditor_ = new TextPagerEdit(this); lineNumArea_ = new TextPagerLineNumberArea(textEditor_); hb->addWidget(lineNumArea_); diff -Nru metview-5.17.4/metview/src/libMvQtTextPager/TextPagerWidget.hpp metview-5.19.2/metview/src/libMvQtTextPager/TextPagerWidget.hpp --- metview-5.17.4/metview/src/libMvQtTextPager/TextPagerWidget.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtTextPager/TextPagerWidget.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ class GotoLineDialog; -class TextPagerWidget : public QWidget //TextPagerEdit +class TextPagerWidget : public QWidget // TextPagerEdit { Q_OBJECT public: @@ -30,8 +30,8 @@ void zoomOut(); void gotoLine(); - //void mouseMoveEvent(QMouseEvent *e); - //void timerEvent(QTimerEvent *e); + // void mouseMoveEvent(QMouseEvent *e); + // void timerEvent(QTimerEvent *e); protected Q_SLOTS: void gotoLine(int); diff -Nru metview-5.17.4/metview/src/libMvQtUtil/DocHighlighter.cc metview-5.19.2/metview/src/libMvQtUtil/DocHighlighter.cc --- metview-5.17.4/metview/src/libMvQtUtil/DocHighlighter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/DocHighlighter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -81,7 +81,7 @@ startIndex = text.indexOf(commentStartRule_.pattern, 0, &rmatch); while (startIndex >= 0) { int endIndex = text.indexOf(commentEndRule_.pattern, startIndex, &rmatch); - int commentLength; + int commentLength = 0; if (endIndex == -1) { setCurrentBlockState(1); commentLength = text.length() - startIndex; @@ -125,17 +125,17 @@ { QFile fIn(parFile_); if (!fIn.open(QIODevice::ReadOnly | QIODevice::Text)) { - //marslog(LOG_WARN, "DocHughlighter::load() --> Could not open json config file: %s", fName.c_str()); + // marslog(LOG_WARN, "DocHughlighter::load() --> Could not open json config file: %s", fName.c_str()); return; } - QByteArray json = fIn.readAll(); + QByteArray json = fIn.readAll(); QJsonDocument doc = QJsonDocument::fromJson(json); - //This document is an array of groups + // This document is an array of groups Q_ASSERT(doc.isObject()); - //Iterate through the ojects in a group + // Iterate through the ojects in a group const QJsonObject& jsonob = doc.object(); for (QJsonObject::const_iterator it = jsonob.constBegin(); it != jsonob.constEnd(); it++) { QString name = it.key(); @@ -184,7 +184,7 @@ } else { commentStartRule_ = makeRule(startPattern, format, false); - commentEndRule_ = makeRule(endPattern, format, false); + commentEndRule_ = makeRule(endPattern, format, false); } } return; @@ -205,29 +205,27 @@ tmpCursor.select(QTextCursor::Document); // Set the default foreground for the inserted characters. - //QTextCharFormat textfmt = tmpCursor.charFormat(); - //textfmt.setForeground(Qt::black); - //tmpCursor.setCharFormat(textfmt); + // QTextCharFormat textfmt = tmpCursor.charFormat(); + // textfmt.setForeground(Qt::black); + // tmpCursor.setCharFormat(textfmt); // Apply the additional formats set by the syntax highlighter QTextBlock start = document()->findBlock(cursor.selectionStart()); - QTextBlock end = document()->findBlock(cursor.selectionEnd()); - end = end.next(); + QTextBlock end = document()->findBlock(cursor.selectionEnd()); + end = end.next(); const int selectionStart = cursor.selectionStart(); - const int endOfDocument = tmpDoc->characterCount() - 1; + const int endOfDocument = tmpDoc->characterCount() - 1; for (QTextBlock current = start; current.isValid() and current not_eq end; current = current.next()) { const QTextLayout* layout(current.layout()); - Q_FOREACH (const QTextLayout::FormatRange& range, #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) - layout->formats()) + Q_FOREACH (const QTextLayout::FormatRange& range, layout->formats()) { #else - layout->additionalFormats()) + Q_FOREACH (const QTextLayout::FormatRange& range, layout->additionalFormats()) { #endif - { const int start = current.position() + range.start - selectionStart; - const int end = start + range.length; + const int end = start + range.length; if (end <= 0 or start >= endOfDocument) continue; tmpCursor.setPosition(qMax(start, 0)); @@ -256,7 +254,7 @@ { QColor col; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) - QRegularExpression rx("rgb\\((\\d+),(\\d+),(\\d+),?(\\d+)?"); + QRegularExpression rx(R"(rgb\((\d+),(\d+),(\d+),?(\d+)?)"); auto match = rx.match(name); if (match.hasMatch()) { col = QColor(match.captured(1).toInt(), diff -Nru metview-5.17.4/metview/src/libMvQtUtil/FontMetrics.cc metview-5.19.2/metview/src/libMvQtUtil/FontMetrics.cc --- metview-5.17.4/metview/src/libMvQtUtil/FontMetrics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/FontMetrics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,7 +13,7 @@ #include #include "MvQMethods.h" -FontMetrics::FontMetrics(const QFont &font) : +FontMetrics::FontMetrics(const QFont& font) : QFontMetrics(font), font_(font), realHeight_(height()) @@ -24,72 +24,64 @@ void FontMetrics::computeRealHeight(QFont f) { QFontMetrics fm(f); - QString txt="Ayfgl"; - QImage img(MvQ::textWidth(fm,txt)+6,fm.height(),QImage::Format_ARGB32_Premultiplied); + QString txt = "Ayfgl"; + QImage img(MvQ::textWidth(fm, txt) + 6, fm.height(), QImage::Format_ARGB32_Premultiplied); img.fill(Qt::white); QPainter p(&img); p.setPen(Qt::black); f.setBold(true); p.setFont(f); - p.drawText(QRect(0,0,img.width(),img.height()),Qt::AlignCenter,txt); + p.drawText(QRect(0, 0, img.width(), img.height()), Qt::AlignCenter, txt); - int minRow=img.height()+100; - int maxRow=-1; - for(int i=0; i < img.height(); i++) - for(int j=0; j < img.width(); j++) - { - QRgb c=img.pixel(j,i); - if(qRed(c) != 255 || qGreen(c) != 255 || qBlue(c) != 255) - { - if(i > maxRow) - maxRow=i; - if(i < minRow) - minRow=i; + int minRow = img.height() + 100; + int maxRow = -1; + for (int i = 0; i < img.height(); i++) + for (int j = 0; j < img.width(); j++) { + QRgb c = img.pixel(j, i); + if (qRed(c) != 255 || qGreen(c) != 255 || qBlue(c) != 255) { + if (i > maxRow) + maxRow = i; + if (i < minRow) + minRow = i; } } - if(minRow >=0 && maxRow < img.height()) - { - realHeight_=maxRow-minRow+1; - topPadding_=minRow; - bottomPadding_=img.height()-1-maxRow; + if (minRow >= 0 && maxRow < img.height()) { + realHeight_ = maxRow - minRow + 1; + topPadding_ = minRow; + bottomPadding_ = img.height() - 1 - maxRow; } } -int FontMetrics::realWidth(QString txt, int &leftPadding, int &rightPadding) const +int FontMetrics::realWidth(QString txt, int& leftPadding, int& rightPadding) const { leftPadding = 0; rightPadding = 0; - QImage img(MvQ::textWidth(*this, txt)+6, height(),QImage::Format_ARGB32_Premultiplied); + QImage img(MvQ::textWidth(*this, txt) + 6, height(), QImage::Format_ARGB32_Premultiplied); img.fill(Qt::white); QPainter p(&img); p.setPen(Qt::black); QFont f = font_; -// f.setBold(true); + // f.setBold(true); p.setFont(f); - p.drawText(QRect(0,0,img.width(),img.height()),Qt::AlignCenter,txt); + p.drawText(QRect(0, 0, img.width(), img.height()), Qt::AlignCenter, txt); - int minCol=img.width()+100; - int maxCol=-1; - for(int i=0; i < img.height(); i++) - for(int j=0; j < img.width(); j++) - { - QRgb c=img.pixel(j,i); - if(qRed(c) != 255 || qGreen(c) != 255 || qBlue(c) != 255) - { - if(j > maxCol) - maxCol=j; - if(j < minCol) - minCol=j; + int minCol = img.width() + 100; + int maxCol = -1; + for (int i = 0; i < img.height(); i++) + for (int j = 0; j < img.width(); j++) { + QRgb c = img.pixel(j, i); + if (qRed(c) != 255 || qGreen(c) != 255 || qBlue(c) != 255) { + if (j > maxCol) + maxCol = j; + if (j < minCol) + minCol = j; } } - if(minCol >=0 && maxCol < img.width()) - { + if (minCol >= 0 && maxCol < img.width()) { leftPadding = minCol; - rightPadding = img.width()-1-maxCol; - + rightPadding = img.width() - 1 - maxCol; } - return maxCol-minCol+1; + return maxCol - minCol + 1; } - diff -Nru metview-5.17.4/metview/src/libMvQtUtil/FontMetrics.h metview-5.19.2/metview/src/libMvQtUtil/FontMetrics.h --- metview-5.17.4/metview/src/libMvQtUtil/FontMetrics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/FontMetrics.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,11 +14,11 @@ class FontMetrics : public QFontMetrics { public: - FontMetrics(const QFont &font); - int realHeight() const {return realHeight_;} - int realWidth(QString txt, int &leftPadding, int &rightPadding) const; - int topPaddingForCentre() const {return topPadding_;} - int bottomPaddingForCentre() const {return bottomPadding_;} + FontMetrics(const QFont& font); + int realHeight() const { return realHeight_; } + int realWidth(QString txt, int& leftPadding, int& rightPadding) const; + int topPaddingForCentre() const { return topPadding_; } + int bottomPaddingForCentre() const { return bottomPadding_; } protected: QFont font_; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQAbstractMessageScanner.cc metview-5.19.2/metview/src/libMvQtUtil/MvQAbstractMessageScanner.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQAbstractMessageScanner.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQAbstractMessageScanner.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,9 +11,8 @@ #include #include #include -#include -#include +#include #include #include "eccodes.h" @@ -21,6 +20,7 @@ #include "LogHandler.h" #include "MvMessageMetaData.h" #include "MvMiscellaneous.h" +#include "MvLog.h" #define UI_THREAD @@ -45,8 +45,8 @@ { Q_ASSERT(data_); - //We will need to pass various non-Qt types via signals and slots for error messages. - //So we need to register these types. + // We will need to pass various non-Qt types via signals and slots for error messages. + // So we need to register these types. static bool reg = false; if (!reg) { qRegisterMetaType("std::string"); @@ -67,7 +67,7 @@ this, SLOT(slotTotalMessageNumComputed())); timer_ = new QTimer(this); - //timer_->setInterval(1); + // timer_->setInterval(1); connect(timer_, SIGNAL(timeout()), this, SLOT(timeout())); } @@ -82,21 +82,21 @@ void MvQAbstractMessageScanner::startScan(MvKeyProfile* prof) { - //We need to stop the running thread - if there is any + // We need to stop the running thread - if there is any stopLoad(); - //At this point we still cannot be sure that all the signals - //emitted from the thread have reached the slots!!! + // At this point we still cannot be sure that all the signals + // emitted from the thread have reached the slots!!! - //So we need to check! + // So we need to check! if (hasFinished()) { - //All the signals reached the slots + // All the signals reached the slots runScan(prof); } else { - //Not all the signals reached the slots! - //We start the timer - this will check periodically if the slots were called - //and we can start the new task + // Not all the signals reached the slots! + // We start the timer - this will check periodically if the slots were called + // and we can start the new task profToProcess_ = prof; timer_->start(1); } @@ -116,7 +116,7 @@ profToProcess_ = nullptr; } -//we are in the main thread! +// we are in the main thread! void MvQAbstractMessageScanner::runScan(MvKeyProfile* prof) { Q_ASSERT(data_); @@ -126,27 +126,27 @@ // we cannot access data_ in the thread!!!! - //it is possible that totalmessageNum_ > 0 but - //firstScan_ == true. It can happen when an initial scan was interrupted!! + // it is possible that totalmessageNum_ > 0 but + // firstScan_ == true. It can happen when an initial scan was interrupted!! if (data_->totalMessageNum() > 0 && data_->firstScan()) { data_->clearData(); } readyEmitted_ = false; - needToStop_ = false; - fileName_ = data_->fileName(); + needToStop_ = false; + fileName_ = data_->fileName(); QFileInfo fInfo(QString::fromStdString(fileName_)); qint64 fSize = fInfo.size(); totalMessageNum_ = data_->totalMessageNum(); - messageNum_ = data_->messageNum(); - firstScan_ = data_->firstScan(); + messageNum_ = data_->messageNum(); + firstScan_ = data_->firstScan(); - //The profile we need to load (will be used outside the class) + // The profile we need to load (will be used outside the class) prof_ = prof; prof_->clearKeyData(); - //It is a profile reload!!! + // It is a profile reload!!! if (!firstScan_) { if (totalMessageNum_ == 0) { Q_EMIT profileReady(prof_); @@ -156,12 +156,12 @@ filterEnabled_ = data_->isFilterEnabled(); if (filterEnabled_) { filterOffset_ = data_->filterOffset(); - filterLen_ = data_->filterLen(); - filterCnt_ = data_->filterCnt(); + filterLen_ = data_->filterLen(); + filterCnt_ = data_->filterCnt(); } } else { - //The data must be empty at this point!!!! + // The data must be empty at this point!!!! Q_ASSERT(totalMessageNum_ == 0); filterEnabled_ = data_->isFilterEnabled(); @@ -170,10 +170,10 @@ } else { filterOffset_ = data_->filterOffset(); - filterLen_ = data_->filterLen(); - filterCnt_ = data_->filterCnt(); + filterLen_ = data_->filterLen(); + filterCnt_ = data_->filterCnt(); - //If the there is a filter the messageNum equals the filter size + // If the there is a filter the messageNum equals the filter size Q_ASSERT(messageNum_ == static_cast(filterOffset_.size())); } @@ -183,10 +183,10 @@ } } - //Main thread!!! - //If the file size is small enough (or the format is BUFR when we have - //a fast scan method) we do everything in the main thread. - //Otherwise we use the threaded profile load! + // Main thread!!! + // If the file size is small enough (or the format is BUFR when we have + // a fast scan method) we do everything in the main thread. + // Otherwise we use the threaded profile load! if ((!firstScan_ && messageNum_ < 1000) || (firstScan_ && !useThreadForScanning(fSize))) { if (firstScan_ && precomputeMessageNum()) { @@ -194,21 +194,21 @@ slotTotalMessageNumComputed(); } - //Load the profile + // Load the profile loadKeyProfile(prof_); - //Finish the load + // Finish the load finishScan(); } else { - //Real thread! + // Real thread! if (isRunning()) { if (!wait(5000)) { exit(1); } } - //The profile we use in the thread!!! + // The profile we use in the thread!!! profLocal_ = prof_->clone(); start(); @@ -217,19 +217,19 @@ void MvQAbstractMessageScanner::clear() { - messageNum_ = 0; + messageNum_ = 0; totalMessageNum_ = 0; - broadcastStep_ = 0; - firstScan_ = true; - filterEnabled_ = false; - prof_ = nullptr; + broadcastStep_ = 0; + firstScan_ = true; + filterEnabled_ = false; + prof_ = nullptr; if (profLocal_) { delete profLocal_; profLocal_ = nullptr; } - readyEmitted_ = false; - needToStop_ = false; - startedReceived_ = false; + readyEmitted_ = false; + needToStop_ = false; + startedReceived_ = false; finishedReceived_ = false; } @@ -238,12 +238,21 @@ if (!isRunning()) return; + if (needToStop_) { + return; + } + mutex_.lock(); needToStop_ = true; mutex_.unlock(); - if (!wait(2000)) { - Q_ASSERT(0); - exit(1); + + // the timeout has to be long since determining the number of messages can + // be very slow + const int timeout=30000; + // exit if timeout has passed + if (!wait(timeout)) { + MvLog().popup().err() << MV_FN_INFO << "\nCannot stop the thread parsing the current message. Timeout=" << + timeout/1000 << "s has exceeded!"; } } @@ -266,7 +275,7 @@ } if (!readyEmitted_) { - //This can only be emitted from the main thread!!!! + // This can only be emitted from the main thread!!!! Q_EMIT profileReady(prof_); readyEmitted_ = true; } @@ -280,7 +289,7 @@ emit loadFinished(); } -//We are inside the thread +// We are inside the thread void MvQAbstractMessageScanner::run() { if (firstScan_ && precomputeMessageNum()) { @@ -292,7 +301,7 @@ loadKeyProfile(profLocal_); } -//This executes ouside the thread (in the main GUI thread!!!) +// This executes ouside the thread (in the main GUI thread!!!) void MvQAbstractMessageScanner::slotGuiLog(int type, std::string msg) { switch (type) { @@ -311,10 +320,10 @@ { Q_ASSERT(messageNum_ > 0); - //Pre allocate the profile + // Pre allocate the profile prof_->preAllocate(messageNum_); - //Set the proper keytypes in the profile + // Set the proper keytypes in the profile MvKey* indexKey = prof_->key("MV_Index"); for (unsigned int i = 0; i < prof_->size(); i++) { if (prof_->at(i) != indexKey) { @@ -322,7 +331,7 @@ } } - //Fill index key + // Fill index key if (indexKey) { assert(indexKey->valueType() == MvKey::IntType); for (int i = 0; i < indexKey->valueNum(); i++) { @@ -353,10 +362,10 @@ int MvQAbstractMessageScanner::computeTotalMessageNum() { - FILE* fp; + FILE* fp = nullptr; fp = fopen(fileName_.c_str(), "rb"); if (!fp) { - //log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); + // log->error("GribMetaData::readMessages() ---> Cannot open grib file: \n " + fileName_ + "\n"); return 0; } @@ -410,7 +419,7 @@ int MvQAbstractMessageScanner::percentage(int current, int total) { - return 100 * static_cast(current) / static_cast(total); + return 100 * static_cast(static_cast(current) / static_cast(total)); } void MvQAbstractMessageScanner::readMessageFailed(MvKeyProfile* prof, int msgCnt, int profIndex) @@ -428,7 +437,7 @@ void MvQAbstractMessageScanner::formatKeyCount(MvKeyProfile* /*prof*/, int num) { char c[20]; - int n, c_format_id; + int n = 0, c_format_id = 0; const char c_format[4][5] = {"%02d", "%03d", "%04d", "%05d"}; if (num < 100) { diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQAbstractMessageScanner.h metview-5.19.2/metview/src/libMvQtUtil/MvQAbstractMessageScanner.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQAbstractMessageScanner.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQAbstractMessageScanner.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,8 @@ Q_OBJECT public: - MvQAbstractMessageScanner(MvMessageMetaData* data, QObject* parent = 0); - ~MvQAbstractMessageScanner(); + MvQAbstractMessageScanner(MvMessageMetaData* data, QObject* parent = nullptr); + ~MvQAbstractMessageScanner() override; void startScan(MvKeyProfile* prof); void stopLoad(); @@ -49,8 +49,8 @@ protected: virtual bool useThreadForScanning(qint64 fSize) const = 0; - virtual bool precomputeMessageNum() const = 0; - void run(); + virtual bool precomputeMessageNum() const = 0; + void run() override; void runScan(MvKeyProfile* prof); void finishScan(); bool hasFinished() const; @@ -60,14 +60,14 @@ void prepareKeyProfile(); virtual void loadKeyProfile(MvKeyProfile* prof); virtual void readMessages(MvKeyProfile* prof) = 0; - //virtual void readMessage(MvKeyProfile* prof, codes_handle* ch, int msgCnt, int profIndex) = 0; + // virtual void readMessage(MvKeyProfile* prof, codes_handle* ch, int msgCnt, int profIndex) = 0; void readMessageFailed(MvKeyProfile* prof, int msgCnt, int profIndex); void formatKeyCount(MvKeyProfile* prof, int num); int percentage(int, int); enum LogType { - TaskLogType = 0, + TaskLogType = 0, ErrorLogType = 1 }; @@ -79,7 +79,7 @@ NoType }; MessageType messageType_; - int messageNum_; //when there is a filter this can be different than totalMessageNum_ + int messageNum_; // when there is a filter this can be different than totalMessageNum_ int totalMessageNum_; int broadcastStep_; bool firstScan_; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQBufrMessageScanner.cc metview-5.19.2/metview/src/libMvQtUtil/MvQBufrMessageScanner.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQBufrMessageScanner.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQBufrMessageScanner.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include "BufrMetaData.h" @@ -26,14 +26,14 @@ BufrMessageScanner::BufrMessageScanner(MvMessageMetaData* data, QObject* parent) : MvQAbstractMessageScanner(data, parent), - bufrData_(static_cast(data)) + bufrData_(dynamic_cast(data)) { Q_ASSERT(bufrData_); messageType_ = BufrType; - //We will need to pass various non-Qt types via signals and slots for error messages. - //So we need to register these types. + // We will need to pass various non-Qt types via signals and slots for error messages. + // So we need to register these types. static bool reg = false; if (!reg) { qRegisterMetaType >("std::vector"); @@ -56,7 +56,7 @@ return false; } -//We are inside the thread +// We are inside the thread void BufrMessageScanner::run() { readMessages(profLocal_); @@ -72,11 +72,11 @@ void BufrMessageScanner::readMessages(MvKeyProfile* profOri) { - int err = 0; + int err = 0; int bufrCount = 0; int profIndex = 0; std::vector msgVec; - int num_messages = 0; + int num_messages = 0; codes_bufr_header* header_array = nullptr; // we use non strict mode @@ -109,7 +109,7 @@ if (broadcastStep_ == 0) broadcastStep_ = 1; - //At this point we must know the total message num!!! + // At this point we must know the total message num!!! assert(totalMessageNum_ > 0); assert(profOri); MvKeyProfile* prof = profOri->clone(); @@ -136,14 +136,14 @@ bufrCount++; if (bufrCount % broadcastStep_ == 0) { - //The slot (outside the thread will take ownership of the - //prof! + // The slot (outside the thread will take ownership of the + // prof! int chunkStart = bufrCount - profIndex; - int chunkSize = profIndex; + int chunkSize = profIndex; Q_EMIT progress(percentage(bufrCount, totalMessageNum_), prof, chunkStart, chunkSize, msgVec); - //We allocate a new profile + // We allocate a new profile prof = profOri->clone(); prof->preAllocate(broadcastStep_); profIndex = 0; @@ -153,7 +153,7 @@ if (profIndex > 0) { int chunkStart = bufrCount - profIndex; - int chunkSize = profIndex; + int chunkSize = profIndex; Q_EMIT progress(percentage(bufrCount, totalMessageNum_), prof, chunkStart, chunkSize, msgVec); } @@ -163,9 +163,9 @@ void BufrMessageScanner::readMessage(MvKeyProfile* prof, codes_bufr_header* bh, int profIndex) { - long centre = bh->bufrHeaderCentre; - bool hasLocal2 = (centre == 98 && bh->ecmwfLocalSectionPresent != 0); - size_t vlen = 0; + long centre = bh->bufrHeaderCentre; + bool hasLocal2 = (centre == 98 && bh->ecmwfLocalSectionPresent != 0); + size_t vlen = 0; char value[512] = { 0, }; @@ -173,7 +173,7 @@ for (std::size_t i = 0; i < prof->size(); i++) { std::string strName = prof->at(i)->name(); - std::size_t pos; + std::size_t pos = 0; if ((pos = strName.find(":98")) == strName.size() - 3) { if (hasLocal2) { strName = strName.substr(0, strName.size() - 3); @@ -189,7 +189,7 @@ } if (prof->at(i)->name() != "MV_Index" && prof->at(i)->name() != "MV_Frame") { - vlen = 0; + vlen = 0; value[0] = '\n'; if (codes_bufr_header_get_string(bh, strName.c_str(), value, &vlen) == CODES_SUCCESS) { if (strName != "localSectionPresent") { @@ -212,18 +212,18 @@ } -//This executes ouside the thread (in the main GUI thread!!!) -//It takes ownership of the prof pointer!!!! +// This executes ouside the thread (in the main GUI thread!!!) +// It takes ownership of the prof pointer!!!! void BufrMessageScanner::slotProgress(int percent, MvKeyProfile* prof, int chunkStart, int chunkSize, std::vector msgVec) { - //If stop was already requested we ignore the progress + // If stop was already requested we ignore the progress if (needToStop_) return; Q_ASSERT(prof); Q_ASSERT(prof->valueNum() >= chunkSize); - //We initialise the data structures when slotProgress is called for the first time + // We initialise the data structures when slotProgress is called for the first time if (chunkStart == 0) { Q_ASSERT(!filterEnabled_); @@ -234,10 +234,10 @@ } Q_ASSERT(messageNum_ == totalMessageNum_); - //Pre allocate the profile + // Pre allocate the profile prepareKeyProfile(); - //Pre allocate the message vector in the data + // Pre allocate the message vector in the data if (firstScan_) { bufrData_->setTotalMessageNum(totalMessageNum_); } @@ -260,11 +260,11 @@ } } -//This slot is called when totalMessageNum_ is determined! +// This slot is called when totalMessageNum_ is determined! void BufrMessageScanner::slotTotalMessageNumComputed() { - //We handle this when the first chunk of data is ready in - //slotProgress() + // We handle this when the first chunk of data is ready in + // slotProgress() } diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQBufrMessageScanner.h metview-5.19.2/metview/src/libMvQtUtil/MvQBufrMessageScanner.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQBufrMessageScanner.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQBufrMessageScanner.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,23 +23,23 @@ Q_OBJECT public: - BufrMessageScanner(MvMessageMetaData* data, QObject* parent = 0); - ~BufrMessageScanner(); + BufrMessageScanner(MvMessageMetaData* data, QObject* parent = nullptr); + ~BufrMessageScanner() override; protected slots: void slotProgress(int, MvKeyProfile*, int, int, std::vector); - void slotTotalMessageNumComputed(); + void slotTotalMessageNumComputed() override; signals: void progress(int, MvKeyProfile*, int, int, std::vector); protected: - bool useThreadForScanning(qint64 fSize) const; - bool precomputeMessageNum() const; - void run(); - void loadKeyProfile(MvKeyProfile* prof); - void readMessages(MvKeyProfile* prof); - //void readMessage(MvKeyProfile* prof, codes_handle* ch, int msgCnt, int profIndex); + bool useThreadForScanning(qint64 fSize) const override; + bool precomputeMessageNum() const override; + void run() override; + void loadKeyProfile(MvKeyProfile* prof) override; + void readMessages(MvKeyProfile* prof) override; + // void readMessage(MvKeyProfile* prof, codes_handle* ch, int msgCnt, int profIndex); void readMessage(MvKeyProfile* prof, codes_bufr_header* bh, int profIndex); BufrMetaData* bufrData_; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQFileInfo.cc metview-5.19.2/metview/src/libMvQtUtil/MvQFileInfo.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQFileInfo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQFileInfo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -48,7 +48,7 @@ else return handleSizePrecision(((double)size) / (1024 * 1024 * 1024), "GB"); - return QString(); + return {}; } QString MvQFileInfo::handleSizePrecision(double sizeInUnits, QString unitsString) diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQFileList.cc metview-5.19.2/metview/src/libMvQtUtil/MvQFileList.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQFileList.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQFileList.cc 2023-07-15 08:28:47.000000000 +0000 @@ -67,10 +67,10 @@ void MvQFileList::init() { if (typeNames_.isEmpty()) { - typeNames_[BufrFile] = "BUFR"; - typeNames_[GribFile] = "GRIB"; + typeNames_[BufrFile] = "BUFR"; + typeNames_[GribFile] = "GRIB"; typeNames_[OtherFile] = "OTHER"; - typeNames_[BadFile] = "BAD"; + typeNames_[BadFile] = "BAD"; } } diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQFileUtil.h metview-5.19.2/metview/src/libMvQtUtil/MvQFileUtil.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQFileUtil.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQFileUtil.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,6 +14,6 @@ class MvQFileUtil { public: - MvQFileUtil() {} + MvQFileUtil() = default; static bool copy(QString srcPath, QString targetPath, QString& err); }; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQGribMessageScanner.cc metview-5.19.2/metview/src/libMvQtUtil/MvQGribMessageScanner.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQGribMessageScanner.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQGribMessageScanner.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,7 +10,7 @@ #include "MvQGribMessageScanner.h" #include -#include +#include #include #include "MvEccBufr.h" @@ -51,10 +51,10 @@ return true; } -//This executes ouside the thread (in the main GUI thread!!!) +// This executes ouside the thread (in the main GUI thread!!!) void GribMessageScanner::slotProgress(int percent, MvKeyProfile* chunkProf, int chunkStart, int chunkSize) { - //If stop was already requested we ignore the progress + // If stop was already requested we ignore the progress if (needToStop_) return; @@ -65,7 +65,7 @@ Q_ASSERT(chunkProf); Q_ASSERT(chunkProf->valueNum() >= chunkSize); - //We initialise the data structures when slotProgress is called for the first time + // We initialise the data structures when slotProgress is called for the first time if (chunkStart == 0) { if (firstScan_) { Q_ASSERT(data_->totalMessageNum() == 0); @@ -82,7 +82,7 @@ } } - //Pre allocate the profile + // Pre allocate the profile prepareKeyProfile(); if (!readyEmitted_) { @@ -103,11 +103,11 @@ } } -//This slot is called when totalMessageNum_ is computed in the thread! +// This slot is called when totalMessageNum_ is computed in the thread! void GribMessageScanner::slotTotalMessageNumComputed() { - //We handle this when the first chunk of data is ready in - //slotProgress() + // We handle this when the first chunk of data is ready in + // slotProgress() #if 0 Q_ASSERT(data_->totalMessageNum() == 0); @@ -139,28 +139,28 @@ name_space.push_back("time"); name_space.push_back("vertical");*/ - FILE* fp; + FILE* fp = nullptr; codes_handle* ch = nullptr; - int err = 0; - int grib_count = 0; - int profIndex = 0; - long longValue; + int err = 0; + int grib_count = 0; + int profIndex = 0; + long longValue = 0; - //At this point we must know the total message num!!! + // At this point we must know the total message num!!! assert(totalMessageNum_ > 0); assert(profOri); MvKeyProfile* prof = profOri->clone(); prof->preAllocate(broadcastStep_); - //hasMultiMessage_=false; - //bool firstScan_=true; - //int messageNum_=0; + // hasMultiMessage_=false; + // bool firstScan_=true; + // int messageNum_=0; Q_EMIT guiLog(TaskLogType, "Generating GRIB key list for all the messages" + GuiLog::methodKey() + " ecCodes C interface"); - //open grib file for reading + // open grib file for reading fp = fopen(fileName_.c_str(), "rb"); if (!fp) { Q_EMIT guiLog(ErrorLogType, "GribMessageScanner::readMessages() ---> Cannot open GRIB file: \n " + @@ -168,15 +168,15 @@ return; } - //For filtered datasets + // For filtered datasets if (filterEnabled_ == true) { int totalScanNum = filterOffset_.size() + totalMessageNum_; - int totalCnt = 0; + int totalCnt = 0; - //At the first scan we need to find the message cnt for each filtered message. - //The goal is to fill up the filterCnt_ vector. + // At the first scan we need to find the message cnt for each filtered message. + // The goal is to fill up the filterCnt_ vector. if (firstScan_) { - //initialise filterCnt_ + // initialise filterCnt_ size_t foundCnt = 0; for (int& i : filterCnt_) { i = -1; @@ -217,7 +217,7 @@ if (filterCnt_[i] == -1) { off_t offset_diff = longValue - filterOffset_[i]; if (ABS(offset_diff) < 120) { - filterCnt_[i] = msgCnt; + filterCnt_[i] = msgCnt; filterOffset_[i] = longValue; foundCnt++; break; @@ -234,7 +234,7 @@ return; } - //currentOffset+=longValue; + // currentOffset+=longValue; codes_handle_delete(ch); if (foundCnt == filterOffset_.size()) @@ -243,11 +243,11 @@ } } - //Read the filtered messages + // Read the filtered messages for (long i : filterOffset_) { fseek(fp, i, SEEK_SET); - int err; + int err = 0; ch = codes_handle_new_from_file(nullptr, fp, PRODUCT_GRIB, &err); if (!ch) { Q_EMIT guiLog(ErrorLogType, @@ -262,10 +262,10 @@ if (totalCnt % broadcastStep_ == 0) { int chunkStart = grib_count - profIndex; - int chunkSize = profIndex; + int chunkSize = profIndex; Q_EMIT progress(percentage(totalCnt, totalScanNum), prof, chunkStart, chunkSize); - //We allocate a new profile + // We allocate a new profile prof = profOri->clone(); prof->preAllocate(broadcastStep_); profIndex = 0; @@ -291,13 +291,13 @@ if (profIndex > 0) { int chunkStart = grib_count - profIndex; - int chunkSize = profIndex; + int chunkSize = profIndex; Q_EMIT progress(percentage(totalCnt, totalScanNum), prof, chunkStart, chunkSize); } } else { - //Get messages form the file + // Get messages form the file while ((ch = codes_handle_new_from_file(nullptr, fp, PRODUCT_GRIB, &err)) != nullptr || err != CODES_SUCCESS) { if (!ch) { Q_EMIT guiLog(ErrorLogType, @@ -311,11 +311,11 @@ if (grib_count % broadcastStep_ == 0) { int chunkStart = grib_count - profIndex; - int chunkSize = profIndex; + int chunkSize = profIndex; Q_EMIT progress(percentage(grib_count, totalMessageNum_), prof, chunkStart, chunkSize); - //We allocate a new profile + // We allocate a new profile prof = profOri->clone(); prof->preAllocate(broadcastStep_); profIndex = 0; @@ -341,7 +341,7 @@ if (profIndex > 0) { int chunkStart = grib_count - profIndex; - int chunkSize = profIndex; + int chunkSize = profIndex; Q_EMIT progress(percentage(grib_count, totalMessageNum_), prof, chunkStart, chunkSize); } @@ -371,16 +371,16 @@ } const int MAX_VAL_LEN = 1024; - long longValue; + long longValue = 0; char value[MAX_VAL_LEN]; std::string svalue; size_t vlen = MAX_VAL_LEN; for (unsigned int i = 0; i < prof->size(); i++) { - size_t len; - int keyType; + size_t len = 0; + int keyType = 0; const std::string& name = prof->at(i)->name(); - bool foundValue = false; + bool foundValue = false; if (grib_get_native_type(ch, name.c_str(), &keyType) == CODES_SUCCESS && grib_get_size(ch, name.c_str(), &len) == CODES_SUCCESS && diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQGribMessageScanner.h metview-5.19.2/metview/src/libMvQtUtil/MvQGribMessageScanner.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQGribMessageScanner.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQGribMessageScanner.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,20 +16,20 @@ Q_OBJECT public: - GribMessageScanner(MvMessageMetaData*, QObject* parent = 0); - ~GribMessageScanner(); + GribMessageScanner(MvMessageMetaData*, QObject* parent = nullptr); + ~GribMessageScanner() override; protected slots: void slotProgress(int percent, MvKeyProfile* chunkProf, int chunkStart, int chunkSize); - void slotTotalMessageNumComputed(); + void slotTotalMessageNumComputed() override; signals: void progress(int percent, MvKeyProfile* chunkProf, int chunkStart, int chunkSize); protected: - bool useThreadForScanning(qint64 fSize) const; - bool precomputeMessageNum() const; - void readMessages(MvKeyProfile* prof); + bool useThreadForScanning(qint64 fSize) const override; + bool precomputeMessageNum() const override; + void readMessages(MvKeyProfile* prof) override; void readMessage(MvKeyProfile* prof, codes_handle* ch, int msgCnt, int profIndex); bool hasMultiMessage_; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQJson.cc metview-5.19.2/metview/src/libMvQtUtil/MvQJson.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQJson.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQJson.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ QJsonObject p; MvRequest r = inR.justOneRequest(); - int numP = r.countParameters(); + int numP = r.countParameters(); for (int i = 0; i < numP; i++) { if (const char* pch = r.getParameter(i)) { if (pch[0] != '_') { @@ -56,12 +56,12 @@ return; auto verb = o["verb"].toString(); - r = MvRequest(verb.toStdString().c_str()); - auto p = o["params"].toObject(); + r = MvRequest(verb.toStdString().c_str()); + auto p = o["params"].toObject(); for (auto it = p.constBegin(); it != p.constEnd(); ++it) { - auto kStr = it.key().toStdString(); + auto kStr = it.key().toStdString(); const char* kCh = kStr.c_str(); - auto v = it.value(); + auto v = it.value(); if (!v.isArray()) { setRequestValue(r, kCh, v); } @@ -100,7 +100,7 @@ QPointF MvQJson::toPointF(const QJsonArray& a) { if (a.count() == 2) { - return QPointF(a[0].toDouble(), a[1].toDouble()); + return {a[0].toDouble(), a[1].toDouble()}; } return {}; } @@ -169,7 +169,7 @@ QRectF MvQJson::toRectF(const QJsonArray& a) { if (a.count() == 4) { - return QRectF(a[0].toDouble(), a[1].toDouble(), a[2].toDouble(), a[3].toDouble()); + return {a[0].toDouble(), a[1].toDouble(), a[2].toDouble(), a[3].toDouble()}; } return {}; } diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQKeyManager.cc metview-5.19.2/metview/src/libMvQtUtil/MvQKeyManager.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQKeyManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQKeyManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -46,46 +46,46 @@ predefinedKeysOnly_ = true; } if (keyTypeName_.isEmpty() == true) { - keyTypeName_[GribType] = "GRIB"; - keyTypeName_[BufrType] = "BUFR"; - keyTypeName_[FrameType] = "Frame"; + keyTypeName_[GribType] = "GRIB"; + keyTypeName_[BufrType] = "BUFR"; + keyTypeName_[FrameType] = "Frame"; keyTypeName_[PlaceMarkType] = "PlaceMark"; - keyTypeName_[LayerType] = "Layer"; - keyTypeName_[BookmarkType] = "Bookmark"; + keyTypeName_[LayerType] = "Layer"; + keyTypeName_[BookmarkType] = "Bookmark"; } if (fProfUser_.empty()) { QMap keyFileName; - //System defaults - keyFileName[GribType] = "GribKeyProfile_default.xml"; - keyFileName[BufrType] = "BufrKeyProfile_default.xml"; + // System defaults + keyFileName[GribType] = "GribKeyProfile_default.xml"; + keyFileName[BufrType] = "BufrKeyProfile_default.xml"; keyFileName[FrameType] = "FrameKeyProfile_default.xml"; keyFileName[LayerType] = "LayerKeyProfile_default.xml"; - //keyFileName[PlaceMarkType]="PlaceMarkKeyProfile_default.xml"; + // keyFileName[PlaceMarkType]="PlaceMarkKeyProfile_default.xml"; if (keyFileName.contains(keyType_)) { fProfDefault_ = metview::appDefDirFile(keyFileName[keyType_].toStdString()); } if (!systemProfOnly_) { - //All keys + // All keys keyFileName.clear(); - keyFileName[GribType] = "GribKeyProfile_all.xml"; - keyFileName[BufrType] = "BufrKeyProfile_all.xml"; + keyFileName[GribType] = "GribKeyProfile_all.xml"; + keyFileName[BufrType] = "BufrKeyProfile_all.xml"; keyFileName[FrameType] = "FrameKeyProfile_all.xml"; if (keyFileName.contains(keyType_)) { fProfAll_ = metview::appDefDirFile(keyFileName[keyType_].toStdString()); } - //User settings + // User settings keyFileName.clear(); - keyFileName[GribType] = "GribKeyProfile.xml"; - keyFileName[BufrType] = "BufrKeyProfile.xml"; - keyFileName[FrameType] = "FrameKeyProfile.xml"; + keyFileName[GribType] = "GribKeyProfile.xml"; + keyFileName[BufrType] = "BufrKeyProfile.xml"; + keyFileName[FrameType] = "FrameKeyProfile.xml"; keyFileName[PlaceMarkType] = "PlaceMarkKeyProfile.xml"; - keyFileName[BookmarkType] = "Bookmarks.xml"; + keyFileName[BookmarkType] = "Bookmarks.xml"; if (keyFileName.contains(keyType_)) { fProfUser_ = metview::preferenceDirFile(keyFileName[keyType_].toStdString()); @@ -96,11 +96,11 @@ MvQKeyManager::MvQKeyManager(const MvQKeyManager& copy) { - fProfUser_ = copy.fProfUser_; - fProfDefault_ = copy.fProfDefault_; - fProfAll_ = copy.fProfAll_; - keyType_ = copy.keyType_; - systemProfOnly_ = copy.systemProfOnly_; + fProfUser_ = copy.fProfUser_; + fProfDefault_ = copy.fProfDefault_; + fProfAll_ = copy.fProfAll_; + keyType_ = copy.keyType_; + systemProfOnly_ = copy.systemProfOnly_; predefinedKeysOnly_ = copy.predefinedKeysOnly_; for (auto it : copy.data()) { data_.push_back(it->clone()); @@ -127,7 +127,7 @@ { for (auto& it : data_) { delete it; - it = 0; + it = nullptr; } data_.clear(); @@ -177,7 +177,7 @@ for (unsigned int i = 0; i < newProf->size(); i++) { MvKey* key = newProf->at(i); if (keyType_ == FrameType) { - //Need a better solution!!! + // Need a better solution!!! if (key->name() == "MV_Index") { key->setName("MV_Frame"); key->setDescription("Frame index"); @@ -220,13 +220,13 @@ } } - return 0; + return nullptr; } void MvQKeyManager::loadProfiles() { - MvKeyProfile* firstSysProf = 0; + MvKeyProfile* firstSysProf = nullptr; loadProfiles(fProfDefault_, data_); for (auto& it : data_) { it->setSystemProfile(true); @@ -242,16 +242,16 @@ } } - //If there are no user profiles + // If there are no user profiles if (!systemProfOnly_ && loadProfiles(fProfUser_, data_) == false) { - //If there are no system profiles + // If there are no system profiles if (data_.size() == 0) { addProfile("Default"); - //createDefaultProfile(prof); + // createDefaultProfile(prof); } - //If there is at least one system profile we create a - //copy of it and add it to the profile list as "Default" and - //make it editable + // If there is at least one system profile we create a + // copy of it and add it to the profile list as "Default" and + // make it editable else if (firstSysProf) { MvKeyProfile* p = firstSysProf->clone(); p->setSystemProfile(false); @@ -277,7 +277,7 @@ QFile file(QString::fromStdString(fileName)); - //For bufr we corrently do not load/save profiles!!! + // For bufr we corrently do not load/save profiles!!! if (file.open(QFile::ReadOnly | QFile::Text) == false) { #ifdef METVIEW marslog(LOG_WARN, "MvQKeyManager::loadProfiles --> Cannot find profile file: %s ", fileName.c_str()); @@ -298,22 +298,22 @@ QDomNode n = docElem.firstChild(); while (!n.isNull()) { if (n.nodeName() == "Profile" && n.isElement()) { - auto attr = n.attributes(); + auto attr = n.attributes(); QString name = attr.namedItem("name").toAttr().value(); - name = name.simplified(); + name = name.simplified(); if (!name.isEmpty()) { - //Create new profile + // Create new profile auto* prof = new MvKeyProfile(name.toStdString()); target.push_back(prof); auto item = n.firstChild(); while (!item.isNull()) { // qDebug() << "item:" << item.nodeName(); - auto itemAttr = item.attributes(); - QString keyName = itemAttr.namedItem("name").toAttr().value(); + auto itemAttr = item.attributes(); + QString keyName = itemAttr.namedItem("name").toAttr().value(); QString keyShortName = itemAttr.namedItem("shortName").toAttr().value(); - QString keyDesc = itemAttr.namedItem("desc").toAttr().value(); - QString keyEditable = itemAttr.namedItem("editable").toAttr().value(); + QString keyDesc = itemAttr.namedItem("desc").toAttr().value(); + QString keyEditable = itemAttr.namedItem("editable").toAttr().value(); if (keyEditable.isEmpty()) { keyEditable = "true"; } @@ -337,11 +337,11 @@ auto dataItem = item.firstChild(); while (!dataItem.isNull()) { auto dataAttr = dataItem.attributes(); - //qDebug() << "key:" << keyName; + // qDebug() << "key:" << keyName; for (int i = 0; i < dataAttr.size(); i++) { auto da = dataAttr.item(i).toAttr(); if (!da.isNull()) { - //qDebug() << " " << da.name() << da.value(); + // qDebug() << " " << da.name() << da.value(); key->setMetaData(da.name().toStdString(), da.value().toStdString()); } @@ -362,7 +362,7 @@ void MvQKeyManager::saveProfiles() { - //Open file for writing + // Open file for writing QFile out(fProfUser_.c_str()); if (out.open(QFile::WriteOnly | QFile::Text) == false) { #ifdef METVIEW @@ -377,7 +377,7 @@ out.write(s.toUtf8()); for (auto prof : data_) { - //We do not save system profiles into the user profile file + // We do not save system profiles into the user profile file if (prof->systemProfile()) continue; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQKeyManager.h metview-5.19.2/metview/src/libMvQtUtil/MvQKeyManager.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQKeyManager.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQKeyManager.h 2023-07-15 08:28:47.000000000 +0000 @@ -62,7 +62,7 @@ void saveProfiles(); void clear(); QString findUniqueProfileName(QString); - //void getAttributes(QXmlQuery &,QXmlItem &,QMap&); + // void getAttributes(QXmlQuery &,QXmlItem &,QMap&); bool predefinedKeysOnly() { return predefinedKeysOnly_; } private: diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQLocalSocketServer.cc metview-5.19.2/metview/src/libMvQtUtil/MvQLocalSocketServer.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQLocalSocketServer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQLocalSocketServer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,20 +25,20 @@ { QString name = generateServerName(); - //remove existings sockets with the same name + // remove existings sockets with the same name QLocalServer::removeServer(name); - //Create the server + // Create the server server_ = new QLocalServer(parent); - //Restrict access to the socket + // Restrict access to the socket server_->setSocketOptions(QLocalServer::UserAccessOption); - //Start listening + // Start listening server_->listen(name); - //qDebug() << "b" << b << server_->serverError() << server_->errorString(); - //qDebug() << "full" << server_->fullServerName(); + // qDebug() << "b" << b << server_->serverError() << server_->errorString(); + // qDebug() << "full" << server_->fullServerName(); connect(server_, SIGNAL(newConnection()), this, SLOT(slotMessageReceived())); @@ -50,11 +50,11 @@ { QLocalSocket* localSocket = server_->nextPendingConnection(); if (!localSocket->waitForReadyRead(5000)) { - //qDebug(localSocket->errorString().toLatin1()); + // qDebug(localSocket->errorString().toLatin1()); return; } QByteArray byteArray = localSocket->readAll(); - QString message = QString::fromUtf8(byteArray.constData()); + QString message = QString::fromUtf8(byteArray.constData()); Q_EMIT messageReceived(message); } @@ -64,5 +64,5 @@ return QString(tmpPath) + "/" + serverId_ + "_" + QString::number(qApp->applicationPid()); } - return QString(); + return {}; } diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQLocalSocketServer.h metview-5.19.2/metview/src/libMvQtUtil/MvQLocalSocketServer.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQLocalSocketServer.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQLocalSocketServer.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ public: MvQLocalSocketServer(QString serverId, QObject* parent); - ~MvQLocalSocketServer(); + ~MvQLocalSocketServer() override; protected Q_SLOTS: void slotMessageReceived(); diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQMethods.cc metview-5.19.2/metview/src/libMvQtUtil/MvQMethods.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQMethods.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQMethods.cc 2023-07-15 08:28:47.000000000 +0000 @@ -153,10 +153,10 @@ void showTabLabel(QTabWidget* tab, int index, QPixmap pix) { Q_ASSERT(tab); - QWidget* w = tab->tabBar()->tabButton(index, QTabBar::RightSide); + QWidget* w = tab->tabBar()->tabButton(index, QTabBar::RightSide); QLabel* label = nullptr; if (w) { - //qDebug() << QString(w->metaObject()->className()); + // qDebug() << QString(w->metaObject()->className()); Q_ASSERT(QString(w->metaObject()->className()) == "QLabel"); } else { @@ -283,9 +283,9 @@ QList attributes; foreach (const QTextLayout::FormatRange& fr, formats) { QInputMethodEvent::AttributeType type = QInputMethodEvent::TextFormat; - int start = fr.start - lineEdit->cursorPosition(); - int length = fr.length; - QVariant value = fr.format; + int start = fr.start - lineEdit->cursorPosition(); + int length = fr.length; + QVariant value = fr.format; attributes.append(QInputMethodEvent::Attribute(type, start, length, value)); } QInputMethodEvent event(QString(), attributes); @@ -310,7 +310,7 @@ void changeFontSize(QWidget* w, int delta) { QFont f = w->font(); - int fs = f.pointSize(); + int fs = f.pointSize(); if (delta > 0) { if (fs >= 100) @@ -337,7 +337,7 @@ void setFontSize(QWidget* w, int fsNew) { QFont f = w->font(); - int fs = f.pointSize(); + int fs = f.pointSize(); if (fsNew <= 0) return; @@ -442,7 +442,7 @@ return QPixmap::fromImage(img); } - return QPixmap(width, height); + return {width, height}; } QPixmap makePixmapFromSvgTemplate(QString path, int width, int height, QColor col, QString templateCol, @@ -450,7 +450,7 @@ { QFile file(path); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - return QPixmap(width, height); + return {width, height}; } QString t = file.readAll(); @@ -479,7 +479,7 @@ float w = p.width(); float h = p.height(); - //We copy the image into a pixmap with the maximum size + // We copy the image into a pixmap with the maximum size float hMax = targetSize.height() - 6; float wMax = 2 * hMax; QPixmap pix; @@ -490,19 +490,19 @@ pix = p.scaledToHeight(hMax, Qt::SmoothTransformation); } - //Define the pixmap rectangle - int pw = pix.width(); - int ph = pix.height(); + // Define the pixmap rectangle + int pw = pix.width(); + int ph = pix.height(); int pdy = (targetSize.height() - ph) / 2; - //int pdx = (pixSize_.width() - pw) / 2; + // int pdx = (pixSize_.width() - pw) / 2; int pdx = 3; QRect pixRect(pdx, pdy, pw, ph); - //We create a pixmap with a given background + // We create a pixmap with a given background QPixmap pixRes = QPixmap(targetSize); pixRes.fill(bg); - //Paint the image pixmap into the middle + // Paint the image pixmap into the middle QPainter painter(&pixRes); painter.drawPixmap(pixRect, pix); @@ -614,12 +614,12 @@ QFont font = QFont(); font.setPointSize(font.pointSize() - 1); - //auto labelHolder = new MvQPanel(parent); + // auto labelHolder = new MvQPanel(parent); auto labelHolder = new QWidget(parent); auto labelLayout = new QHBoxLayout(labelHolder); labelLayout->setContentsMargins(1, 1, 1, 1); auto label = new QLabel(name, labelHolder); - //label->setProperty("panelStyle", "2"); + // label->setProperty("panelStyle", "2"); if (fontSizeDelta != 0) { QFont font = QFont(); font.setPointSize(font.pointSize() + fontSizeDelta); @@ -630,7 +630,7 @@ } #endif -QFont findMonospaceFont() +QFont findMonospaceFont(bool keepDefaultSize) { QStringList lst{"Menlo", "Monospace", "Courier", "Courier New", "Monaco"}; @@ -638,21 +638,26 @@ auto fLst = QFontDatabase::families(); #else QFontDatabase db = QFontDatabase(); - auto fLst = db.families(); + auto fLst = db.families(); #endif for (auto s : lst) { for (auto fMem : fLst) { if (fMem == s || fMem.startsWith(s + "[")) { QFont f(fMem); f.setFixedPitch(true); - f.setPointSize(10); + if (!keepDefaultSize) { + f.setPointSize(10); + } return f; } } } QFont fr; - fr.setPointSize(10); + if (!keepDefaultSize) { + fr.setPointSize(10); + } + return fr; } @@ -694,23 +699,23 @@ QString title; switch (level) { case MvLogLevel::INFO: - icon = QMessageBox::Information; + icon = QMessageBox::Information; title = "Info"; break; case MvLogLevel::WARN: - icon = QMessageBox::Warning; + icon = QMessageBox::Warning; title = "Warning"; break; case MvLogLevel::ERROR: - icon = QMessageBox::Critical; + icon = QMessageBox::Critical; title = "Error"; break; case MvLogLevel::DBG: - icon = QMessageBox::NoIcon; + icon = QMessageBox::NoIcon; title = "Debug"; break; default: - icon = QMessageBox::NoIcon; + icon = QMessageBox::NoIcon; title = "Info"; break; } @@ -719,4 +724,4 @@ box.exec(); } -} //namespace MvQ +} // namespace MvQ diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQMethods.h metview-5.19.2/metview/src/libMvQtUtil/MvQMethods.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQMethods.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQMethods.h 2023-07-15 08:28:47.000000000 +0000 @@ -80,7 +80,7 @@ QPixmap fitPixmapToSize(QSize targetSize, QPixmap p, QColor bg); #ifdef METVIEW QPen makePen(const char* style, int width, const char* colour, - Qt::PenCapStyle cap = Qt::SquareCap, + Qt::PenCapStyle cap = Qt::SquareCap, Qt::PenJoinStyle join = Qt::BevelJoin); QBrush makeBrush(const char* style, const char* colour); #endif @@ -89,7 +89,7 @@ #ifdef METVIEW QWidget* makeLabelPanel(QString name, QWidget* parent, int fontSizeDelta = 0); #endif -QFont findMonospaceFont(); +QFont findMonospaceFont(bool keepDefaultSize=false); void safeDrawLine(const QPointF& p1, const QPointF& p2, QPainter* painter); void safeDrawLine(const QPoint& p1, const QPoint& p2, QPainter* painter); void drawPolyline(const QVector& pp, QPainter* painter); @@ -97,7 +97,8 @@ void showMessageBox(const std::string& msg, MvLogLevel level); template -QPoint eventPos(T* event) { +QPoint eventPos(T* event) +{ #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return event->position().toPoint(); #else diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQNetworkAccessManager.cc metview-5.19.2/metview/src/libMvQtUtil/MvQNetworkAccessManager.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQNetworkAccessManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQNetworkAccessManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ MvQNetworkAccessManager::MvQNetworkAccessManager(QObject* parent) : QNetworkAccessManager(parent) { - //network_ = new QNetworkAccessManager(this); + // network_ = new QNetworkAccessManager(this); connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotReplyFinished(QNetworkReply*))); @@ -25,35 +25,35 @@ auto* proxyFactory = new MvQNetworkProxyFactory; setProxyFactory(proxyFactory); - //Set proxy + // Set proxy /* QNetworkProxy proxy; - proxy.setType(QNetworkProxy::HttpProxy); - proxy.setHostName("proxy.ecmwf.int"); - proxy.setPort(3333); + proxy.setType(QNetworkProxy::HttpProxy); + proxy.setHostName("proxy.ecmwf.int"); + proxy.setPort(3333); - setProxy(proxy);*/ + setProxy(proxy);*/ } void MvQNetworkAccessManager::slotReplyFinished(QNetworkReply* reply) { - //Reply is finished! - //We'll ask for the reply about the Redirection attribute + // Reply is finished! + // We'll ask for the reply about the Redirection attribute QVariant possibleRedirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); QVariant v = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute); - //qDebug() << "Reason: " << v.toInt(); + // qDebug() << "Reason: " << v.toInt(); v = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); - //qDebug() << "Status: " << v.toByteArray(); + // qDebug() << "Status: " << v.toByteArray(); - //We'll deduct if the redirection is valid in the redirectUrl function + // We'll deduct if the redirection is valid in the redirectUrl function urlRedirectedTo_ = redirectUrl(possibleRedirectUrl.toUrl(), urlRedirectedTo_); - //If the URL is not empty, we're being redirected. + // If the URL is not empty, we're being redirected. if (!urlRedirectedTo_.isEmpty()) { - //qDebug() << "Redirection to: " << urlRedirectedTo_; + // qDebug() << "Redirection to: " << urlRedirectedTo_; get(QNetworkRequest(urlRedirectedTo_)); reply->deleteLater(); } diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQNetworkProxyFactory.cc metview-5.19.2/metview/src/libMvQtUtil/MvQNetworkProxyFactory.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQNetworkProxyFactory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQNetworkProxyFactory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,7 +27,7 @@ noProxyLst_.clear(); MvRequest myPref = MvApplication::getExpandedPreferences(); - //myPref=ObjectList::ExpandRequest(myPref,EXPAND_DEFAULTS); + // myPref=ObjectList::ExpandRequest(myPref,EXPAND_DEFAULTS); const char* useProxy = myPref("USE_NETWORK_PROXY"); if ((useProxy != nullptr)) diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQObstatScatterData.cc metview-5.19.2/metview/src/libMvQtUtil/MvQObstatScatterData.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQObstatScatterData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQObstatScatterData.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,499 +0,0 @@ -/***************************** LICENSE START *********************************** - - Copyright 2012 ECMWF and INPE. This software is distributed under the terms - of the Apache License version 2.0. In applying this license, ECMWF does not - waive the privileges and immunities granted to it by virtue of its status as - an Intergovernmental Organization or submit itself to any jurisdiction. - - ***************************** LICENSE END *************************************/ - -#include "netcdfcpp.h" - -#include - -#include -#include -#include - -#include "MvQObstatScatterData.h" - -#include "MvKeyProfile.h" - -MvQScatterItem::MvQScatterItem() -{ - nX_ = 0; - nY_ = 0; - data_ = 0; -} - -MvQScatterItem::~MvQScatterItem() -{ - if (!data_) { - delete data_; - } -} - -void MvQScatterItem::computeMeanForRows(QVector& meanX, QVector& meanY) -{ - for (int j = 0; j < nY_; j++) { - float sumX = 0; - float sumXWeigh = 0.; - for (int i = 0; i < nX_; i++) { - sumX += data_[j + i * nY_]; - sumXWeigh += (startX_ + i * dX_) * data_[j + i * nY_]; - } - - if (fabs(sumX) > 0.0001) { - meanX << startY_ + j * dY_; - meanY << sumXWeigh / sumX; - } - } -} - -void MvQScatterItem::computeMeanForColumns(QVector& meanX, QVector& meanY) -{ - for (int i = 0; i < nX_; i++) { - float sumY = 0; - float sumYWeigh = 0.; - for (int j = 0; j < nY_; j++) { - sumY += data_[j + i * nY_]; - sumYWeigh += (startY_ + j * dY_) * data_[j + i * nY_]; - } - - if (fabs(sumY) > 0.0001) { - meanX << startX_ + i * dX_; - meanY << sumYWeigh / sumY; - } - } -} - -void MvQScatterItem::writeDataMatrixToNc(QString outFile, bool swapAxes) -{ - std::vector x, y, value; - - /*for(int j=0; j < nY_; j++) - { - for(int i=0; i < nX_; i++) - { - value.push_back(data_[i+j*nX_]); - } - }*/ - - if (swapAxes == false) { - for (int j = 0; j < nY_; j++) { - for (int i = 0; i < nX_; i++) { - value.push_back(data_[j + i * nY_]); - } - } - - for (int i = 0; i < nX_; i++) { - x.push_back(startX_ + (i + 0.5) * dX_); - } - - for (int j = 0; j < nY_; j++) { - y.push_back(startY_ + (j + 0.5) * dY_); - } - } - else { - for (int i = 0; i < nX_; i++) { - for (int j = 0; j < nY_; j++) { - value.push_back(data_[j + i * nY_]); - } - } - - for (int i = 0; i < nX_; i++) { - y.push_back(startX_ + (i + 0.5) * dX_); - } - - for (int j = 0; j < nY_; j++) { - x.push_back(startY_ + (j + 0.5) * dY_); - } - } - - writeDataMatrixToNc(outFile.toStdString(), x, y, value); -} - -void MvQScatterItem::writeDataMatrixToNc(string outFile, std::vector& x, std::vector& y, std::vector& value) -{ - int num, nx, ny; - - //Checking - if (x.size() * y.size() != value.size()) { - return; - } - - - //------------------------- - // Netcdf output - //------------------------- - - nx = x.size(); - ny = y.size(); - num = value.size(); - - - std::cout << "num: " << num << std::endl; - - // Now we build the Netcdf file! - NcFile netcdf = NcFile(outFile.c_str(), NcFile::Replace); - - //Adding global attributes - netcdf.add_att("Conventions", "Metview"); - netcdf.add_att("institution", "ECMWF, Reading, U.K."); - netcdf.add_att("source", "Metview 4"); - - //Define dimensions (each column has the same number of rows!) - NcDim* dim_nx = netcdf.add_dim("nx", nx); - NcDim* dim_ny = netcdf.add_dim("ny", ny); - - //Define the netcdf vars - std::map nc_vars; - nc_vars[0] = netcdf.add_var("x", ncFloat, dim_nx); - nc_vars[1] = netcdf.add_var("y", ncFloat, dim_ny); - nc_vars[2] = netcdf.add_var("val", ncFloat, dim_nx, dim_ny); - - //Write data into the netcdf file - nc_vars[0]->put(&(x[0]), nx); - nc_vars[1]->put(&(y[0]), ny); - nc_vars[2]->put(&(value[0]), nx, ny); - - netcdf.close(); -} - -MvQScatterBlock::MvQScatterBlock() -{ -} - -MvQScatterBlock::~MvQScatterBlock() -{ - foreach (MvQScatterItem* item, items_) { - delete item; - } -} - -MvQObstatScatterData::MvQObstatScatterData() -{ - itemNum_ = 0; - //filePath_="/var/tmp/user/metview/Local/OBSTAT/scat_0001_DCDA_synop_pressure.200809"; -} - -MvQObstatScatterData::~MvQObstatScatterData() -{ - clearData(); -} - -void MvQObstatScatterData::clearData() -{ - foreach (MvQScatterBlock* block, blocks_) { - delete block; - } - blocks_.clear(); - itemNum_ = 0; -} - -MvQScatterItem* MvQObstatScatterData::item(int index) -{ - int cnt = 0; - foreach (MvQScatterBlock* block, blocks_) { - if (cnt + block->itemNum() > index) { - int itemIndex = index - cnt; - return block->items().at(itemIndex); - } - - cnt += block->itemNum(); - } - - return 0; -} - -MvQScatterBlock* MvQObstatScatterData::blockOfItem(int index) -{ - int cnt = 0; - foreach (MvQScatterBlock* block, blocks_) { - if (cnt + block->itemNum() > index) { - return block; - } - - cnt += block->itemNum(); - } - - return 0; -} - -MvQScatterBlock* MvQObstatScatterData::block(int index) -{ - if (index >= 0 && index < blocks_.count()) - return blocks_[index]; - - return 0; -} - -void MvQObstatScatterData::setFileName(QString fileName) -{ - fileName_ = fileName; - clearData(); - loadData(); - - //QString nc="/var/tmp/user/metview/Local/OBSTAT/scat.nc"; - //blocks_[0]->items().at(0)->writeMatrixToNc(nc); -} - -void MvQObstatScatterData::loadData() -{ - QFile file(fileName_); - - if (file.open(QFile::ReadOnly | QFile::Text) == false) { - return; - } - - QTextStream in(&file); - - itemNum_ = 0; - - while (!in.atEnd()) { - QString line = in.readLine(); - - if (line.contains("#obstat scatter")) { - line = in.readLine(); - } - - QStringList lst = line.split(" ", QString::SkipEmptyParts); - if (!lst.contains("HEADER=") || lst.count() != 11) { - return; - } - - MvQScatterBlock* block = new MvQScatterBlock; - - //Start date - QString dstr = lst[1]; - dstr += lst[2]; - block->setStartDate(QDateTime::fromString(dstr, "yyyyMMddHHmm")); - - //End date - dstr = lst[3]; - dstr += lst[4]; - block->setEndDate(QDateTime::fromString(dstr, "yyyyMMddHHmm")); - - // - block->setSatId(lst[5].toInt()); - block->setSensorId(lst[6].toInt()); - int itemNum = lst[7].toInt(); - int channelNum = lst[8].toInt(); - int flagNum = lst[9].toInt(); - int areaNum = lst[10].toInt(); - //block->setItemNum(lst[7].toInt()); - //block->setChannelNum(lst[8].toInt()); - //block->setFlagNum(lst[9].toInt()); - //block->setAreaNum(lst[10].toInt()); - - - line = in.readLine(); - if (!line.contains("title=")) { - return; - } - - lst = line.split("title=", QString::SkipEmptyParts); - if (lst.count() > 0) { - block->setTitle(lst.last().simplified()); - } - - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - if (!lst.contains("press=")) { - return; - } - - if (lst[1] == "yes") { - } - - //X params - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - if (lst.count() != itemNum) { - return; - } - - QStringList paramsX = lst; - - //Y params - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - if (lst.count() != itemNum) { - return; - } - - QStringList paramsY = lst; - - //Flags - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - if (lst.count() != flagNum) { - return; - } - - QStringList flags = lst; - - //Areas - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - if (lst.count() != areaNum) { - return; - } - - block->setAreaNames(lst); - - //read titles - QMap titles; - - for (int i = 0; i < itemNum; i++) { - line = in.readLine(); - titles[paramsX[i].toInt()] = line.simplified(); - - line = in.readLine(); - titles[paramsY[i].toInt()] = line.simplified(); - } - - block->setParams(titles); - - int totalItemNum = itemNum * flagNum * areaNum * channelNum; - - for (int i = 0; i < totalItemNum; i++) { - //BEGIN SCATITEM - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - if (lst[0] != "BEGIN" && lst[1] != "SCATITEM" && lst.count() != 13) { - return; - } - - MvQScatterItem* item = new MvQScatterItem; - - item->setArea(lst[2].toInt()); - item->setLevel(lst[3].toInt()); - item->setFlag(lst[4].toInt()); - item->setParamX(lst[5].toInt()); - item->setParamY(lst[6].toInt()); - item->setStartX(lst[7].toFloat()); - item->setStartY(lst[8].toFloat()); - item->setDX(lst[9].toFloat()); - item->setDY(lst[10].toFloat()); - item->setNX(lst[11].toInt()); - item->setNY(lst[12].toInt()); - - item->setTitleX(titles[item->paramX()]); - item->setTitleY(titles[item->paramY()]); - - - //GLOBAL STATS - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - if (lst[0] != "GLOBAL" && lst[1] != "STATS" && lst.count() != 13) { - return; - } - - item->setMaxX(lst[2].toFloat()); - item->setMinX(lst[3].toFloat()); - item->setMaxY(lst[4].toFloat()); - item->setMinY(lst[5].toFloat()); - item->setSumX(lst[6].toFloat()); - item->setSumY(lst[7].toFloat()); - item->setSumXX(lst[8].toFloat()); - item->setSumYY(lst[9].toFloat()); - item->setSumXY(lst[10].toFloat()); - item->setSumDiffSqr(lst[11].toFloat()); - item->setSourceDataNum(lst[12].toInt()); - - int num = 0; - int totalNum = item->nX() * item->nY(); - float* data = new float[totalNum]; - - while (num != totalNum) { - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - foreach (QString s, lst) { - data[num] = s.toFloat(); - num++; - } - } - - item->setData(data); - - block->addItem(item); - - line = in.readLine(); - lst = line.split(" ", QString::SkipEmptyParts); - if (!line.contains("END SCATITEM")) { - return; - } - itemNum_++; - } - - blocks_ << block; - } - - file.close(); -} - -void MvQObstatScatterData::loadKeyProfile(MvKeyProfile* prof) -{ - //prof->addKey(new MvKey("Index","Index")); - //prof->addKey(new MvKey("Satellite","Satellite")); - //prof->addKey(new MvKey("Sensor","Sensor")); - //prof->addKey(new MvKey("Area","Area")); - //prof->addKey(new MvKey("Level","Level")); - //prof->addKey(new MvKey("Flag","Flag")); - //prof->addKey(new MvKey("ParX","ParX")); - //prof->addKey(new MvKey("ParY","ParY")); - prof->addKey(new MvKey("Start date", "Start date")); - prof->addKey(new MvKey("End date", "End date")); - prof->addKey(new MvKey("Satellite", "Satellite")); - prof->addKey(new MvKey("Sensor", "Sensor")); - prof->addKey(new MvKey("Title", "Title")); - - int i = 0; - foreach (MvQScatterBlock* block, blocks_) { - //foreach(MvQScatterItem* item, block->items()) - //{ - //prof->key("Index")->addValue(QString::number(i).toStdString()); - // prof->key("Area")->addValue(QString::number(item->area()).toStdString()); - // prof->key("Level")->addValue(QString::number(item->level()).toStdString()); - // prof->key("Flag")->addValue(QString::number(item->flag()).toStdString()); - // prof->key("ParX")->addValue(QString::number(item->paramX()).toStdString()); - // prof->key("ParY")->addValue(QString::number(item->paramY()).toStdString()); - prof->key("Start date")->addValue(block->startDate().toString("yyyy-MM-dd hh:mm ").toStdString()); - prof->key("End date")->addValue(block->endDate().toString("yyyy-MM-dd hh:mm ").toStdString()); - prof->key("Satellite")->addValue(QString::number(block->satId()).toStdString()); - prof->key("Sensor")->addValue(QString::number(block->sensorId()).toStdString()); - prof->key("Title")->addValue(block->title().toStdString()); - i++; - //} - } -} - -void MvQScatterBlock::loadKeyProfile(MvKeyProfile* prof) -{ - //prof->addKey(new MvKey("Index","Index")); - //prof->addKey(new MvKey("Satellite","Satellite")); - //prof->addKey(new MvKey("Sensor","Sensor")); - prof->addKey(new MvKey("Area", "Area")); - prof->addKey(new MvKey("Level", " Channel/Level")); - prof->addKey(new MvKey("Flag", "Flag")); - prof->addKey(new MvKey("ParamX", "ParamX")); - prof->addKey(new MvKey("ParamY", "ParamY")); - //prof->addKey(new MvKey("Start date","Start date")); - //prof->addKey(new MvKey("End date","End date")); - - int i = 0; - foreach (MvQScatterItem* item, items_) { - //prof->key("Index")->addValue(QString::number(i).toStdString()); - prof->key("Area")->addValue(areaNames_[item->area() - 1].toStdString()); - prof->key("Level")->addValue(QString::number(item->level()).toStdString()); - prof->key("Flag")->addValue(QString::number(item->flag()).toStdString()); - prof->key("ParamX")->addValue(params_[item->paramX()].toStdString()); - prof->key("ParamY")->addValue(params_[item->paramY()].toStdString()); - //prof->key("Start date")->addValue(block->startDate().toString("yyyyMMdd-hh:mm").toStdString()); - //prof->key("End date")->addValue(block->endDate().toString("yyyyMMdd-hh:mm").toStdString()); - //prof->key("Satellite")->addValue(QString::number(satId_).toStdString()); - //prof->key("Sensor")->addValue(QString::number(sensorId_).toStdString()); - i++; - } -} diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQObstatScatterData.h metview-5.19.2/metview/src/libMvQtUtil/MvQObstatScatterData.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQObstatScatterData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQObstatScatterData.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,187 +0,0 @@ -/***************************** LICENSE START *********************************** - - Copyright 2012 ECMWF and INPE. This software is distributed under the terms - of the Apache License version 2.0. In applying this license, ECMWF does not - waive the privileges and immunities granted to it by virtue of its status as - an Intergovernmental Organization or submit itself to any jurisdiction. - - ***************************** LICENSE END *************************************/ - -#pragma once - -#include -#include - -#include -#include - -class MvKeyProfile; - -class MvQScatterItem -{ -public: - MvQScatterItem(); - ~MvQScatterItem(); - - void setArea(int area) { area_ = area; } - void setLevel(int level) { level_ = level; } - void setFlag(int flag) { flag_ = flag; } - void setParamX(int paramX) { paramX_ = paramX; } - void setParamY(int paramY) { paramY_ = paramY; } - void setStartX(float startX) { startX_ = startX; } - void setStartY(float startY) { startY_ = startY; } - void setDX(float dX) { dX_ = dX; } - void setDY(float dY) { dY_ = dY; } - void setNX(int nX) { nX_ = nX; } - void setNY(int nY) { nY_ = nY; } - void setData(float* data) { data_ = data; } - void setTitleX(QString titleX) { titleX_ = titleX; } - void setTitleY(QString titleY) { titleY_ = titleY; } - - void setMinX(float f) { minX_ = f; } - void setMaxX(float f) { maxX_ = f; } - void setMinY(float f) { minY_ = f; } - void setMaxY(float f) { maxY_ = f; } - void setSumX(float f) { sumX_ = f; } - void setSumY(float f) { sumY_ = f; } - void setSumXX(float f) { sumXX_ = f; } - void setSumYY(float f) { sumYY_ = f; } - void setSumXY(float f) { sumXY_ = f; } - void setSumDiffSqr(float f) { sumDiffSqr_ = f; } - void setSourceDataNum(int n) { sourceDataNum_ = n; } - - int area() { return area_; } - int level() { return level_; } - int flag() { return flag_; } - int paramX() { return paramX_; } - int paramY() { return paramY_; } - float startX() { return startX_; } - float startY() { return startY_; } - float endX() { return startX_ + dX_ * (nX_ + 1); } - float endY() { return startY_ + dY_ * (nY_ + 1); } - float dX() { return dX_; } - float dY() { return dY_; } - int nX() { return nX_; } - int nY() { return nY_; } - float* data() { return data_; } - QString titleX() { return titleX_; } - QString titleY() { return titleY_; } - - float minX() { return minX_; } - float maxX() { return maxX_; } - float minY() { return minY_; } - float maxY() { return maxY_; } - float sumX() { return sumX_; } - float sumY() { return sumY_; } - float sumXX() { return sumXX_; } - float sumYY() { return sumYY_; } - float sumXY() { return sumXY_; } - float sumDiffSqr() { return sumDiffSqr_; } - int sourceDataNum() { return sourceDataNum_; } - - void writeDataMatrixToNc(QString, bool); - void computeMeanForRows(QVector&, QVector&); - void computeMeanForColumns(QVector&, QVector&); - -protected: - void writeDataMatrixToNc(std::string, std::vector&, std::vector&, std::vector&); - - float* data_; - - int area_; - int level_; - int flag_; - int paramX_; - int paramY_; - float startX_; - float startY_; - float dX_; - float dY_; - int nX_; - int nY_; - - QString titleX_; - QString titleY_; - QString areaName_; - - float maxX_; - float minX_; - float maxY_; - float minY_; - float sumX_; - float sumY_; - float sumXX_; - float sumYY_; - float sumXY_; - float sumDiffSqr_; - int sourceDataNum_; -}; - - -class MvQScatterBlock -{ -public: - MvQScatterBlock(); - ~MvQScatterBlock(); - void addItem(MvQScatterItem* item) { items_ << item; } - - void setStartDate(QDateTime d) { startDate_ = d; } - void setEndDate(QDateTime d) { endDate_ = d; } - void setParams(QMap& params) { params_ = params; } - void setSatId(int id) { satId_ = id; } - void setSensorId(int id) { sensorId_ = id; } - void setAreaNames(QStringList lst) { areaNames_ = lst; } - void setTitle(QString t) { title_ = t; } - QList items() { return items_; } - int itemNum() { return items_.count(); } - - - QDateTime startDate() { return startDate_; } - QDateTime endDate() { return endDate_; } - int satId() { return satId_; } - int sensorId() { return sensorId_; } - QStringList areaNames() { return areaNames_; } - QString title() { return title_; } - void loadKeyProfile(MvKeyProfile*); - -protected: - QDateTime startDate_; - QDateTime endDate_; - int satId_; - int sensorId_; - //int itemNum_; - //int channelNum_; - //int flagNum_; - //int areaNum_; - QString title_; - QStringList areaNames_; - QMap params_; - - - QList items_; -}; - - -class MvQObstatScatterData -{ -public: - MvQObstatScatterData(); - ~MvQObstatScatterData(); - - void loadData(); - void loadKeyProfile(MvKeyProfile*); - void setFileName(QString); - QString fileName() { return fileName_; } - int itemNum() { return itemNum_; } - MvQScatterItem* item(int); - MvQScatterBlock* blockOfItem(int); - MvQScatterBlock* block(int); - - -protected: - void clearData(); - - QString fileName_; - QList blocks_; - int itemNum_; -}; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQOdbMetaData.cc metview-5.19.2/metview/src/libMvQtUtil/MvQOdbMetaData.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQOdbMetaData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQOdbMetaData.cc 2023-07-15 08:28:47.000000000 +0000 @@ -59,19 +59,19 @@ } if (typeIdMap.isEmpty()) { - typeIdMap[odc::api::IGNORE] = MvQOdbColumn::None; - typeIdMap[odc::api::INTEGER] = MvQOdbColumn::Int; - typeIdMap[odc::api::REAL] = MvQOdbColumn::Float; - typeIdMap[odc::api::STRING] = MvQOdbColumn::String; + typeIdMap[odc::api::IGNORE] = MvQOdbColumn::None; + typeIdMap[odc::api::INTEGER] = MvQOdbColumn::Int; + typeIdMap[odc::api::REAL] = MvQOdbColumn::Float; + typeIdMap[odc::api::STRING] = MvQOdbColumn::String; typeIdMap[odc::api::BITFIELD] = MvQOdbColumn::Bitfield; - typeIdMap[odc::api::DOUBLE] = MvQOdbColumn::Double; + typeIdMap[odc::api::DOUBLE] = MvQOdbColumn::Double; - typeIdNameMap[odc::api::IGNORE] = "none"; - typeIdNameMap[odc::api::INTEGER] = "int"; - typeIdNameMap[odc::api::REAL] = "float"; - typeIdNameMap[odc::api::STRING] = "string"; + typeIdNameMap[odc::api::IGNORE] = "none"; + typeIdNameMap[odc::api::INTEGER] = "int"; + typeIdNameMap[odc::api::REAL] = "float"; + typeIdNameMap[odc::api::STRING] = "string"; typeIdNameMap[odc::api::BITFIELD] = "bitfield"; - typeIdNameMap[odc::api::DOUBLE] = "double"; + typeIdNameMap[odc::api::DOUBLE] = "double"; } if (odbVersion_ == Version1) { @@ -148,7 +148,7 @@ while (!in.atEnd()) { QString line = in.readLine(); - //Vars + // Vars if (line.startsWith("SET")) { QStringList lst = line.split(" ", #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) @@ -173,7 +173,7 @@ } } - //Bitfield + // Bitfield if (line.startsWith("CREATE TYPE")) { QString name, bitLen, bitPos; int bitPosInt = 0, bitLenInt = 0; @@ -206,7 +206,7 @@ bitLen = lst[i + 1].remove(lst[i + 1].size() - 1, 1); bitLen.remove("bit"); bitLenInt = bitLen.toInt(); - bitPos = QString::number(bitPosInt); + bitPos = QString::number(bitPosInt); bf.push_back(new MvQOdbBitfieldMember(name, bitPosInt, bitLenInt)); bitPosInt += bitLenInt; } @@ -214,7 +214,7 @@ bitfields[bfName] = bf; } - //Table + // Table if (line.startsWith("CREATE TABLE")) { removeCommentFromLine(line); @@ -237,15 +237,15 @@ break; } - //qDebug() << lst; + // qDebug() << lst; QString tableName = lst[2]; - auto* table = new MvQOdbTable(tableName); + auto* table = new MvQOdbTable(tableName); for (int i = 5; i < lst.size(); i += 2) { name = lst[i] + "@" + tableName; - //qDebug() << "table: " << name; + // qDebug() << "table: " << name; if (i + 1 < lst.size() && lst[i + 1].endsWith(",")) { - type = lst[i + 1].remove(lst[i + 1].size() - 1, 1); + type = lst[i + 1].remove(lst[i + 1].size() - 1, 1); auto* col = new MvQOdbColumn(name, type, tableName); columns_.push_back(col); table->addColumn(col); @@ -256,7 +256,7 @@ tables_[tableName] = table; - //qDebug() << "table:" << tableName << table->linksTo() ; + // qDebug() << "table:" << tableName << table->linksTo() ; } } @@ -267,12 +267,12 @@ foreach (MvQOdbBitfieldMember* bf, bitfields[col->type()]) { col->addBitfieldMember(new MvQOdbBitfieldMember(*bf)); } - //qDebug() << "num:" << bitfields[col->type()].size() << col->bitfieldNum(); + // qDebug() << "num:" << bitfields[col->type()].size() << col->bitfieldNum(); } - //qDebug() << col->name(); + // qDebug() << col->name(); } - //Delete tmp bitfields + // Delete tmp bitfields QMapIterator > it(bitfields); while (it.hasNext()) { it.next(); @@ -285,8 +285,6 @@ void MvQOdbMetaData::getTableTree() { - QMap tblMap; - QMapIterator it(tables_); while (it.hasNext()) { it.next(); @@ -297,8 +295,8 @@ } } - //Find the root in the ODB table tree - //It has only "to" links!! + // Find the root in the ODB table tree + // It has only "to" links!! int currentYPosMax = 0; @@ -310,7 +308,7 @@ rt->setTreePosX(0); rt->setTreePosY(currentYPosMax); - //qDebug() << "root" << rt->name(); + // qDebug() << "root" << rt->name(); int posy = currentYPosMax; computeTreePos(rt, posy); @@ -327,107 +325,107 @@ } /*int posy=0; - if(rootTables_.count() > 0) - computeTreePos(rootTables_[0],posy);*/ + if(rootTables_.count() > 0) + computeTreePos(rootTables_[0],posy);*/ /*QMapIterator it(tables_); - while (it.hasNext()) - { - it.next(); - if(it.value()->treePosX() > xr) - { - xr=it.value()->treePosX(); - } - - if(it.value()->treePosY() > yr) - { - yr=it.value()->treePosY(); - } - - }*/ + while (it.hasNext()) + { + it.next(); + if(it.value()->treePosX() > xr) + { + xr=it.value()->treePosX(); + } + + if(it.value()->treePosY() > yr) + { + yr=it.value()->treePosY(); + } + + }*/ it.toFront(); while (it.hasNext()) { it.next(); - //qDebug() << it.value()->name() << it.value()->treePosX() << it.value()->treePosY(); + // qDebug() << it.value()->name() << it.value()->treePosX() << it.value()->treePosY(); } /* - xp=parent->treePosX()+1; - yp=parent->treePosY(); - int i=0; - foreach(MvQOdbTable* t,parent->linksFrom()) - { - t->setTreePosX(xp); - t->setTreePosY(yp); - yp++; - } - - - - //For each table find the position (x,y) in the tree! - int posX=1; - std::vector posY(100,0); - QStack::iterator> itActStack, itEndStack; - std::list::iterator itAct=root_->linksTo().begin(); - std::list::iterator itEnd=root_->linksTo().end(); - - while(itAct != itEnd) - { - (*itAct)->treePosX(posX); - (*itAct)->treePosY(posY[posX]); - - //std::cout << "table: " << (*itAct)->name_ << " x: " << (*itAct)->treePosX_ << " y: " << (*itAct)->treePosY_ << std::endl; - - posY[posX]=posY[posX]++; - - if(!(*itAct)->linksTo().empty()) - { - itActStack.push(itAct); - itEndStack.push(itEnd); - - //std::cout << " to stack: " << (*itAct)->name_ << std::endl; - - std::list::iterator itTmp=itAct; - itAct=(*itTmp)->linksTo().begin(); - itEnd=(*itTmp)->linksTo().end(); - posX++; - - posY[posX]=posY[posX-1]-1; - - continue; - } - - itAct++; - - while (itAct == itEnd && itActStack.empty() == false) - { - itAct=itActStack.top(); - itEnd=itEndStack.top(); - - itActStack.pop(); - itEndStack.pop(); - - //std::cout << " rom stack: " << (*itAct)->name_ << std::endl; - - itAct++; - posX--; - - posY[posX]=posY[posX+1]; - - } - } */ + xp=parent->treePosX()+1; + yp=parent->treePosY(); + int i=0; + foreach(MvQOdbTable* t,parent->linksFrom()) + { + t->setTreePosX(xp); + t->setTreePosY(yp); + yp++; + } + + + + //For each table find the position (x,y) in the tree! + int posX=1; + std::vector posY(100,0); + QStack::iterator> itActStack, itEndStack; + std::list::iterator itAct=root_->linksTo().begin(); + std::list::iterator itEnd=root_->linksTo().end(); + + while(itAct != itEnd) + { + (*itAct)->treePosX(posX); + (*itAct)->treePosY(posY[posX]); + + //std::cout << "table: " << (*itAct)->name_ << " x: " << (*itAct)->treePosX_ << " y: " << (*itAct)->treePosY_ << std::endl; + + posY[posX]=posY[posX]++; + + if(!(*itAct)->linksTo().empty()) + { + itActStack.push(itAct); + itEndStack.push(itEnd); + + //std::cout << " to stack: " << (*itAct)->name_ << std::endl; + + std::list::iterator itTmp=itAct; + itAct=(*itTmp)->linksTo().begin(); + itEnd=(*itTmp)->linksTo().end(); + posX++; + + posY[posX]=posY[posX-1]-1; + + continue; + } + + itAct++; + + while (itAct == itEnd && itActStack.empty() == false) + { + itAct=itActStack.top(); + itEnd=itEndStack.top(); + + itActStack.pop(); + itEndStack.pop(); + + //std::cout << " rom stack: " << (*itAct)->name_ << std::endl; + + itAct++; + posX--; + + posY[posX]=posY[posX+1]; + + } + } */ } void MvQOdbMetaData::computeTreePos(MvQOdbTable* parent, int& yp) { - //qDebug() << parent->name() << parent->treePosX() << parent->treePosY(); + // qDebug() << parent->name() << parent->treePosX() << parent->treePosY(); int xp = parent->treePosX() + 1; - //int yp=parent->treePosY(); - //qDebug() << " " << xp << yp; - //qDebug() << " " << parent->linksTo(); + // int yp=parent->treePosY(); + // qDebug() << " " << xp << yp; + // qDebug() << " " << parent->linksTo(); foreach (QString tblName, parent->linksTo()) { MvQOdbTable* t = tables_[tblName]; @@ -458,7 +456,7 @@ void MvQOdbMetaData::loadOdbHeader() { - //odb_start(); + // odb_start(); odc::Reader oda(path_.toStdString()); odc::Reader::iterator it = oda.begin(); @@ -494,7 +492,7 @@ int pos = 0; for (unsigned int i = 0; i < itc->bitfieldDef().first.size(); i++) { std::string name = itc->bitfieldDef().first.at(i); - int size = itc->bitfieldDef().second.at(i); + int size = itc->bitfieldDef().second.at(i); acol->addBitfieldMember(new MvQOdbBitfieldMember(QString(name.c_str()), pos, size)); pos += size; } @@ -503,5 +501,5 @@ columns_.push_back(acol); } - //qDebug() << "odb columns" << columns_.size() << columns_.size() << columnNum(); + // qDebug() << "odb columns" << columns_.size() << columns_.size() << columnNum(); } diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQOdbMetaData.h metview-5.19.2/metview/src/libMvQtUtil/MvQOdbMetaData.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQOdbMetaData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQOdbMetaData.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ #include #include #include -#include +#include class MvQOdbVar @@ -136,9 +136,7 @@ { public: MvQOdbTable(QString name) : - name_(name), - treePosX_(0), - treePosY_(0) {} + name_(name) {} QString name() { return name_; } void addColumn(MvQOdbColumn* col) { columns_.push_back(col); } @@ -158,8 +156,8 @@ QList columns_; QStringList linksTo_; QStringList linksFrom_; - int treePosX_; - int treePosY_; + int treePosX_{0}; + int treePosY_{0}; }; class MvQOdbMetaData @@ -171,9 +169,9 @@ Version2, InvalidVersion }; - //MvQOdbMetaData(QString); + // MvQOdbMetaData(QString); MvQOdbMetaData(std::string, std::string); - //MvQOdbMetaData(QString,QString,QString); + // MvQOdbMetaData(QString,QString,QString); ~MvQOdbMetaData(); void init(); @@ -194,7 +192,7 @@ void getTreePosRange(int&, int&); protected: - //void readMetaData(); + // void readMetaData(); void removeCommentFromLine(QString&); void loadSchemaFile(); void getTableTree(); diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQPalette.cc metview-5.19.2/metview/src/libMvQtUtil/MvQPalette.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQPalette.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQPalette.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include "ConfigLoader.h" #include "Tokenizer.h" @@ -35,36 +35,35 @@ //#define DEBUG_MV_MVQPALETTE__ -namespace { +namespace +{ // CIE contants const float CIE_EPS = 0.008856451679035631; const float CIE_KAPPA = 903.2962962962963; -//reference values for the XYZ colour model. Observer=2 deg, illuminant=d65 +// reference values for the XYZ colour model. Observer=2 deg, illuminant=d65 const float D65_X = 95.047; const float D65_Y = 100.000; const float D65_Z = 108.883; -//reference values for the XYZ colour model. Observer=2 deg, illuminant=d50 -//const float D50_X = 0.96422; +// reference values for the XYZ colour model. Observer=2 deg, illuminant=d50 +// const float D50_X = 0.96422; const float D50_Y = 1; -//const float D50_Z = 0.82521; +// const float D50_Z = 0.82521; const float D50_U = 0.20916005282038627; const float D50_V = 0.48807338454488514; // conversion matrix for srgb (d65) to xyz (d50) const std::array matrixLrgbToXyzd50 = { - 0.4360747, 0.3850649, 0.1430804, - 0.2225045, 0.7168786, 0.0606169, - 0.0139322, 0.0971045, 0.7141733 -}; + 0.4360747, 0.3850649, 0.1430804, + 0.2225045, 0.7168786, 0.0606169, + 0.0139322, 0.0971045, 0.7141733}; // conversion matrix for xyz (d50) to srgb (d65) const std::array matrixXyzd50ToLrgb = { - 3.1338561, -1.6168667, -0.4906146, - -0.9787684, 1.9161415, 0.0334540, - 0.0719453, -0.2289914, 1.4052427 -}; + 3.1338561, -1.6168667, -0.4906146, + -0.9787684, 1.9161415, 0.0334540, + 0.0719453, -0.2289914, 1.4052427}; void rgbToXyz(float r, float g, float b, float& x, float& y, float& z); void xyzToRgb(float x, float y, float z, float& r, float& g, float& b); @@ -110,9 +109,9 @@ // r,g,b : 0-1 void 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 + 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; @@ -151,12 +150,12 @@ float rgbToLinearLightRgb(float v) { - return (v > 0.04045)?std::pow((v + 0.055) / 1.055, 2.4):(v / 12.92); + return (v > 0.04045) ? std::pow((v + 0.055) / 1.055, 2.4) : (v / 12.92); } float linearLightRgbToRgb(float v) { - return (v > 0.0031308)?(1.055 * std::pow(v, 1. / 2.4) - 0.055):(12.92 * v); + return (v > 0.0031308) ? (1.055 * std::pow(v, 1. / 2.4) - 0.055) : (12.92 * v); } // Convert normalised sRGB (illuminant=d65) to CIE XYZ (illuminant=d50) @@ -176,9 +175,9 @@ // Apply the conversion matrix. Since sRGB uses d65 and the target XYZ uses d50 // a chromatic adaptation must also be performed on the result. This operation // is already incorporated into the conversion matrix. - x = r * matrixLrgbToXyzd50[0] + g * matrixLrgbToXyzd50[1] + b * matrixLrgbToXyzd50[2]; - y = r * matrixLrgbToXyzd50[3] + g * matrixLrgbToXyzd50[4] + b * matrixLrgbToXyzd50[5]; - z = r * matrixLrgbToXyzd50[6] + g * matrixLrgbToXyzd50[7] + b * matrixLrgbToXyzd50[8]; + x = r * matrixLrgbToXyzd50[0] + g * matrixLrgbToXyzd50[1] + b * matrixLrgbToXyzd50[2]; + y = r * matrixLrgbToXyzd50[3] + g * matrixLrgbToXyzd50[4] + b * matrixLrgbToXyzd50[5]; + z = r * matrixLrgbToXyzd50[6] + g * matrixLrgbToXyzd50[7] + b * matrixLrgbToXyzd50[8]; } // Convert CIE XYZ (illuminant=d50) to normalised sRGB (illuminant=d65) @@ -186,16 +185,16 @@ // r,g,b : 0-1 void xyzd50ToRgb(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 + 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 // Apply the conversion matrix. Since the source XYZ uses d50 and sRGB uses // d65 the chromatic adaptation must also be performed on the result. This operation // is already incorporated into the conversion matrix. - r = x * matrixXyzd50ToLrgb[0] + y * matrixXyzd50ToLrgb[1] + z * matrixXyzd50ToLrgb[2]; - g = x * matrixXyzd50ToLrgb[3] + y * matrixXyzd50ToLrgb[4] + z * matrixXyzd50ToLrgb[5]; - b = x * matrixXyzd50ToLrgb[6] + y * matrixXyzd50ToLrgb[7] + z * matrixXyzd50ToLrgb[8]; + r = x * matrixXyzd50ToLrgb[0] + y * matrixXyzd50ToLrgb[1] + z * matrixXyzd50ToLrgb[2]; + g = x * matrixXyzd50ToLrgb[3] + y * matrixXyzd50ToLrgb[4] + z * matrixXyzd50ToLrgb[5]; + b = x * matrixXyzd50ToLrgb[6] + y * matrixXyzd50ToLrgb[7] + z * matrixXyzd50ToLrgb[8]; // convert linear-light RGB to gamma encoded sRGB (companding) r = linearLightRgbToRgb(r); @@ -230,7 +229,7 @@ else z = (7.787 * z) + (16. / 116.); - l = (116. * y) - 16.; + l = (116. * y) - 16.; float a = 500. * (x - y); float b = 200. * (y - z); #ifdef DEBUG_MV_MVQPALETTE__ @@ -294,39 +293,40 @@ float u = 0.; float v = 0.; if (d != 0) { - u = 4.0 * x/ d; - v = 9.0 * y/ d; + u = 4.0 * x / d; + v = 9.0 * y / d; } y /= D50_Y; - y = (y > CIE_EPS) ? std::cbrt(y) : ((7.787 * y) + 16./116.); + y = (y > CIE_EPS) ? std::cbrt(y) : ((7.787 * y) + 16. / 116.); - //D50_U = (4.0 * D50_X) / (D50_X + (15.0 * D50_Y) + (3.0 * D50_Z)); - //D50_V = (9.0 * D50_Y) / (D50_X + (15.0 * D50_Y) + (3.0 * D50_Z)); + // D50_U = (4.0 * D50_X) / (D50_X + (15.0 * D50_Y) + (3.0 * D50_Z)); + // D50_V = (9.0 * D50_Y) / (D50_X + (15.0 * D50_Y) + (3.0 * D50_Z)); l = (116.0 * y) - 16.0; u = 13.0 * l * (u - D50_U); v = 13.0 * l * (v - D50_V); -//#ifdef DEBUG_MV_MVQPALETTE__ - //qDebug() << " uvl" << u << v << l; -//#endif + //#ifdef DEBUG_MV_MVQPALETTE__ + // qDebug() << " uvl" << u << v << l; + //#endif h = atan2(v, u); -//#ifdef DEBUG_MV_MVQPALETTE__ - //qDebug() << " h1" << h; -//#endif + //#ifdef DEBUG_MV_MVQPALETTE__ + // qDebug() << " h1" << h; + //#endif if (h > 0) { h = h * toDegFactor; - } else { + } + else { h = 360. + h * toDegFactor; } -//#ifdef DEBUG_MV_MVQPALETTE__ - //qDebug() << " h2" << h; -//#endif + //#ifdef DEBUG_MV_MVQPALETTE__ + // qDebug() << " h2" << h; + //#endif h = h / 360.; c = sqrt(u * u + v * v); - qDebug() << "xyzToHclLuv: (" << x << y << z << ") ->" << h << c << l; + qDebug() << "xyzToHclLuv: (" << x << y << z << ") ->" << h << c << l; } // h,c,l : 0-1 @@ -334,9 +334,9 @@ void hclLuvToXyz(float h, float c, float l, float& x, float& y, float& z) { if (l <= 0) { - x =0.; - y =0.; - z =0.; + x = 0.; + y = 0.; + z = 0.; return; } float u = cos(360 * h * toRadFactor) * c; @@ -345,33 +345,31 @@ const float up = u / (13 * l) + D50_U; const float vp = v / (13 * l) + D50_V; - if (l > l / CIE_KAPPA*CIE_EPS) { + if (l > l / CIE_KAPPA * CIE_EPS) { y = std::pow((l + 16) / 116., 3.); - } else { + } + else { y = l / CIE_KAPPA; } const float d = 4 * vp; x = y * 9 * up / d; - z = y * (12 - 3 * up - 20 * vp)/d; + z = y * (12 - 3 * up - 20 * vp) / d; //#ifdef DEBUG_MV_MVQPALETTE__ - //qDebug() << "hclLuvToXyz: " << x << y << z; + // qDebug() << "hclLuvToXyz: " << x << y << z; //#endif x *= 100; y *= 100; z *= 100; } -} +} // namespace void MvQPalette::load(request* r) { // populate our list of 'special'/'pseudo' colour names if (pseudoColourNames_.empty()) { - pseudoColourNames_.push_back("AUTOMATIC"); - pseudoColourNames_.push_back("CONTOUR_LINE_COLOUR"); - pseudoColourNames_.push_back("BACKGROUND"); - pseudoColourNames_.push_back("FOREGROUND"); + pseudoColourNames_ = {"AUTOMATIC", "CONTOUR_LINE_COLOUR", "BACKGROUND", "FOREGROUND"}; } const char* fname = get_value(r, "colour_file", 0); @@ -389,9 +387,9 @@ while (fgets(line, sizeof(line), f)) { char* p = line; - int i = 0; + int i = 0; - sscanf(p, "%s ; %s", color, name); + sscanf(p, "%79s ; %79s", color, name); while (*p && !i) { if (*p == '#') { color[i++] = *p++; @@ -405,7 +403,7 @@ } if (i) { bool pseudo = MvQPalette::isPseudo(name); - names_.push_back(name); + names_.emplace_back(name); items_[name] = MvQPaletteItem(name, (pseudo) ? QColor() : MvQPalette::hexaCharToColour(color), pseudo); } @@ -426,7 +424,7 @@ QColor MvQPalette::hexaCharToColour(const char* hexaChar) { if (strlen(hexaChar) == 13) { - unsigned int r, g, b; + unsigned int r = 0, g = 0, b = 0; char cval[5]; strncpy(cval, hexaChar + 1, 4); @@ -444,7 +442,7 @@ return QColor(r / 256, g / 256, b / 256); } - return QColor(); + return {}; } @@ -462,9 +460,9 @@ std::string MvQPalette::toString(QColor col) { - for (auto it = items_.begin(); it != items_.end(); it++) { - if (it->second.pseudo_ == false && it->second.col_ == col) - return it->first; + for (auto& item : items_) { + if (item.second.pseudo_ == false && item.second.col_ == col) + return item.first; } return toRgbString(col).toStdString(); @@ -576,14 +574,14 @@ QList cLst; - //strip off the closing and ending brackets + // strip off the closing and ending brackets txt = txt.simplified(); if (!txt.startsWith("[") || !txt.endsWith("]")) return cLst; txt = txt.mid(1, txt.size() - 2); - QRegExp rx("(\".*\")(?=\\s*,|\\s*$)"); + QRegExp rx(R"((".*")(?=\s*,|\s*$))"); rx.setMinimal(true); int pos = 0; @@ -603,7 +601,7 @@ std::string name = nameIn; std::transform(name.begin(), name.end(), name.begin(), ::toupper); - //remove quotes + // remove quotes if (name.empty()) return col; @@ -645,7 +643,7 @@ case 'r': case 'R': if (x1 > 255.5) - x1 = 255.; //to handle values like r=256 !!! + x1 = 255.; // to handle values like r=256 !!! if (x2 > 255.5) x2 = 255.; if (x3 > 255.5) @@ -663,14 +661,14 @@ break; } - //Alpha + // Alpha if (v.size() == 5) { double x4 = atof(v[4].c_str()); col.setAlphaF(x4); } if (col.isValid()) { - //colors[name] = col; + // colors[name] = col; } } else if (name.empty()) { @@ -682,15 +680,15 @@ } } - //colors[name] = c; - //return PaletteRGBColor(palette,&c); + // colors[name] = c; + // return PaletteRGBColor(palette,&c); return col; } void MvQPalette::toHclLabF(QColor c, float& hue, float& chroma, float& luminance) { - float x, y, z; + float x = 0., y = 0., z = 0.; rgbToXyz(c.redF(), c.greenF(), c.blueF(), x, y, z); #ifdef DEBUG_MV_MVQPALETTE__ qDebug() << "xyz" << x << y << z; @@ -702,25 +700,25 @@ void MvQPalette::toHclLab(QColor c, int& hue, int& chroma, int& luminance) { - float h, ch, l; + float h = 0., ch = 0., l = 0.; toHclLabF(c, h, ch, l); - //qDebug() << "toHcl=" << h << ch << l; - hue = static_cast(h*360); + // qDebug() << "toHcl=" << h << ch << l; + hue = static_cast(h * 360); chroma = static_cast(ch); luminance = static_cast(l); } -QColor MvQPalette::fromHclLab(int hue,int chroma, int luminance) +QColor MvQPalette::fromHclLab(int hue, int chroma, int luminance) { - float h = static_cast(hue)/359.; - float ch = static_cast(chroma); - float l = static_cast(luminance); + float h = static_cast(hue) / 359.; + auto ch = static_cast(chroma); + auto l = static_cast(luminance); return fromHclLabF(h, ch, l); } QColor MvQPalette::fromHclLabF(float hue, float chroma, float luminance) { - float x, y, z, r, g, b; + float x = 0., y = 0., z = 0., r = 0., g = 0., b = 0.; hclLabToXyz(hue, chroma, luminance, x, y, z); xyzToRgb(x, y, z, r, g, b); return QColor::fromRgbF(r, g, b); @@ -729,11 +727,11 @@ void MvQPalette::toHclLuvF(QColor c, float& hue, float& chroma, float& luminance) { - float x, y, z; + float x = 0., y = 0., z = 0.; rgbToXyzd50(c.redF(), c.greenF(), c.blueF(), x, y, z); -//#ifdef DEBUG_MV_MVQPALETTE__ - //qDebug() << "xyz" << x << y << z; -//#endif + //#ifdef DEBUG_MV_MVQPALETTE__ + // qDebug() << "xyz" << x << y << z; + //#endif xyzToHclLuv(x, y, z, hue, chroma, luminance); if (c.red() == 255 && c.green() == 255 && c.blue() == 255) hue = 40. / 360.; @@ -741,34 +739,34 @@ void MvQPalette::toHclLuv(QColor c, int& hue, int& chroma, int& luminance) { - float h, ch, l; + float h = 0., ch = 0., l = 0.; toHclLuvF(c, h, ch, l); qDebug() << "toHclLuv:" << c << "->" << h << ch << l; - hue = static_cast(h*360); + hue = static_cast(h * 360); chroma = static_cast(ch); luminance = static_cast(l); qDebug() << "->" << hue << chroma << luminance; } -QColor MvQPalette::fromHclLuv(int hue,int chroma, int luminance) +QColor MvQPalette::fromHclLuv(int hue, int chroma, int luminance) { - float h = static_cast(hue)/355.; - float ch = static_cast(chroma); - float l = static_cast(luminance); + float h = static_cast(hue) / 355.; + auto ch = static_cast(chroma); + auto l = static_cast(luminance); auto col = fromHclLuvF(h, ch, l); - //qDebug() << "toHclLuv:" << h << ch << l << "->" << col; + // qDebug() << "toHclLuv:" << h << ch << l << "->" << col; return col; } QColor MvQPalette::fromHclLuvF(float hue, float chroma, float luminance) { - float x, y, z, r, g, b; + float x = 0., y = 0., z = 0., r = 0., g = 0., b = 0.; hclLuvToXyz(hue, chroma, luminance, x, y, z); xyzd50ToRgb(x, y, z, r, g, b); return QColor::fromRgbF(r, g, b); } -//paint the chequered background when alpha is set +// paint the chequered background when alpha is set void MvQPalette::paintAlphaBg(QPainter* painter, QRect area) { painter->save(); @@ -776,9 +774,9 @@ QColor c1(170, 170, 170); QColor c2(190, 190, 190); - int rs = 8; - int nx = area.width() / rs; - int ny = area.height() / rs; + int rs = 8; + int nx = area.width() / rs; + int ny = area.height() / rs; QColor cAct = c1; for (int i = 0; i <= nx; i++) for (int j = 0; j <= ny; j++) { diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQPaletteDb.cc metview-5.19.2/metview/src/libMvQtUtil/MvQPaletteDb.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQPaletteDb.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQPaletteDb.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ #include "MvQPalette.h" #include "MvMiscellaneous.h" -MvQPaletteDb* MvQPaletteDb::instance_ = 0; +MvQPaletteDb* MvQPaletteDb::instance_ = nullptr; //========================================== // @@ -59,7 +59,7 @@ painter.fillRect(r, QBrush(colLst_[i])); } - //border + // border painter.setPen(QColor(100, 100, 100)); painter.drawRect(rect.adjusted(0, 0, -1, -1)); } @@ -82,7 +82,7 @@ painter->fillRect(r, QBrush(colLst_[i])); } - //border + // border painter->setPen(QColor(100, 100, 100)); painter->drawRect(rect); } @@ -123,17 +123,17 @@ return; } - QByteArray json = fIn.readAll(); + QByteArray json = fIn.readAll(); QJsonDocument doc = QJsonDocument::fromJson(json); - //This document is an array of groups + // This document is an array of groups Q_ASSERT(doc.isObject()); - //Iterate through the ojects in a group + // Iterate through the ojects in a group const QJsonObject& jsonob = doc.object(); for (QJsonObject::const_iterator it = jsonob.constBegin(); it != jsonob.constEnd(); it++) { QString name = it.key(); - auto* item = new MvQPaletteDbItem(name); + auto* item = new MvQPaletteDbItem(name); Q_ASSERT(it.value().isObject()); @@ -142,7 +142,6 @@ itOb != ob.constEnd(); itOb++) { QString obName = itOb.key(); if (obName == "contour_shade_colour_list") { - QStringList lst; toStringList(itOb.value().toArray(), item->colNameLst_); item->generateColLst(); } diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQPalette.h metview-5.19.2/metview/src/libMvQtUtil/MvQPalette.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQPalette.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQPalette.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,11 +25,11 @@ virtual void next(const std::string&, QColor, bool) = 0; }; -//class PaletteLoader +// class PaletteLoader //{ -//public: -// static void load(request*); -//}; +// public: +// static void load(request*); +// }; struct MvQPaletteItem { @@ -65,12 +65,12 @@ static void toHclLabF(QColor c, float& hue, float& chroma, float& luminance); static void toHclLab(QColor c, int& hue, int& chroma, int& luminance); static QColor fromHclLabF(float hue, float chroma, float luminance); - static QColor fromHclLab(int hue,int chroma, int luminance); + static QColor fromHclLab(int hue, int chroma, int luminance); static void toHclLuvF(QColor c, float& hue, float& chroma, float& luminance); static void toHclLuv(QColor c, int& hue, int& chroma, int& luminance); static QColor fromHclLuvF(float hue, float chroma, float luminance); - static QColor fromHclLuv(int hue,int chroma, int luminance); + static QColor fromHclLuv(int hue, int chroma, int luminance); static void paintAlphaBg(QPainter* painter, QRect area); diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQProperty.cc metview-5.19.2/metview/src/libMvQtUtil/MvQProperty.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQProperty.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQProperty.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,17 +17,17 @@ #include #endif -#include +#include MvQProperty::MvQProperty(const std::string& name) : strName_(name), name_(QString::fromStdString(name)), - parent_(0), - master_(0), + parent_(nullptr), + master_(nullptr), useMaster_(false), type_(StringType), guiType_(StringGui), - link_(0) + link_(nullptr) { } @@ -54,59 +54,59 @@ void MvQProperty::setDefaultValue(const std::string& val) { - //Colour + // Colour if (isColour(val)) { defaultValue_ = toColour(val); - type_ = ColourType; - guiType_ = ColourGui; + type_ = ColourType; + guiType_ = ColourGui; } - //Font + // Font else if (isFont(val)) { defaultValue_ = toFont(val); - type_ = FontType; - guiType_ = FontGui; + type_ = FontType; + guiType_ = FontGui; } - //Sound + // Sound else if (isSound(val)) { defaultValue_ = QString::fromStdString(val); - type_ = SoundType; - guiType_ = SoundGui; + type_ = SoundType; + guiType_ = SoundGui; } - //date + // date else if (isDate(val)) { defaultValue_ = QString::fromStdString(val); - type_ = DateType; - guiType_ = DateGui; + type_ = DateType; + guiType_ = DateGui; } - //area + // area else if (isArea(val)) { defaultValue_ = QString::fromStdString(val); - type_ = AreaType; - guiType_ = AreaGui; + type_ = AreaType; + guiType_ = AreaGui; } - //int + // int else if (isNumber(val)) { defaultValue_ = toNumber(val); - type_ = IntType; - guiType_ = IntGui; + type_ = IntType; + guiType_ = IntGui; } - //bool + // bool else if (isBool(val)) { defaultValue_ = toBool(val); - type_ = BoolType; - guiType_ = BoolGui; + type_ = BoolType; + guiType_ = BoolGui; } - //text + // text else { defaultValue_ = QString::fromStdString(val); - type_ = StringType; - guiType_ = StringGui; + type_ = StringType; + guiType_ = StringGui; } if (value_.isNull()) value_ = defaultValue_; - //qDebug() << "Prop:" << name_ << defaultValue_ << value_.value(); + // qDebug() << "Prop:" << name_ << defaultValue_ << value_.value(); } void MvQProperty::setValue(const std::string& val) @@ -118,30 +118,30 @@ if (isColour(val)) { QColor col = toColour(val); - changed = (value_.value() != col); - value_ = col; + changed = (value_.value() != col); + value_ = col; } else if (isFont(val)) { QFont font = toFont(val); - changed = (value_.value() != font); - value_ = font; + changed = (value_.value() != font); + value_ = font; } else if (isNumber(val)) { int num = toNumber(val); changed = (value_.toInt() != num); - value_ = num; + value_ = num; } else if (isBool(val)) { - bool b = toBool(val); + bool b = toBool(val); changed = (value_.toBool() != b); - value_ = b; + value_ = b; } - //Sound or string + // Sound or string else { QString str = QString::fromStdString(val); - changed = (value_ != str); - value_ = str; + changed = (value_ != str); + value_ = str; } if (!defaultValue_.isNull() && @@ -151,8 +151,8 @@ defaultValue_.type() != value_.type()) { #endif changed = true; - value_ = defaultValue_; - //An error message should be shown! + value_ = defaultValue_; + // An error message should be shown! } if (changed) @@ -220,18 +220,18 @@ void MvQProperty::setParam(QString name, QString value) { /*if(name == "values") - { - if(type_ == SoundType) - guiType_=SoundComboGui; - else - guiType_=StringComboGui; - } + { + if(type_ == SoundType) + guiType_=SoundComboGui; + else + guiType_=StringComboGui; + } - if(name == "multi" && value == "true") - { - if(type_ == StringType || guiType_ == StringComboGui) - guiType_ == MultiStringComboGui; - }*/ + if(name == "multi" && value == "true") + { + if(type_ == StringType || guiType_ == StringComboGui) + guiType_ == MultiStringComboGui; + }*/ params_[name] = value; } @@ -242,12 +242,12 @@ if (it != params_.end()) return it.value(); - return QString(); + return {}; } void MvQProperty::adjustAfterLoad() { - QString vals = param("values"); + QString vals = param("values"); QString multi = param("multi"); if (!vals.isEmpty()) { @@ -310,12 +310,12 @@ return p; } - return 0; + return nullptr; } MvQProperty* MvQProperty::find(const std::string& /*fullPath*/) { - //TODO: implement it without using boost + // TODO: implement it without using boost return nullptr; #if 0 if(fullPath.empty()) @@ -347,7 +347,7 @@ return this; } - //The vec size >=2 + // The vec size >=2 std::vector rest(pathVec.begin() + 1, pathVec.end()); MvQProperty* n = findChild(QString::fromStdString(pathVec.at(1))); @@ -414,10 +414,10 @@ { auto* cp = new MvQProperty(strName_); - cp->value_ = value_; + cp->value_ = value_; cp->defaultValue_ = defaultValue_; - cp->type_ = type_; - cp->guiType_ = guiType_; + cp->type_ = type_; + cp->guiType_ = guiType_; if (addLink) { cp->link_ = link_; @@ -463,7 +463,7 @@ bool MvQProperty::isSound(const std::string& /*val*/) { - //TODO: implement it + // TODO: implement it return false; #if 0 return Sound::instance()->isSoundFile(val); @@ -496,7 +496,7 @@ { QString qn = QString::fromStdString(name); QColor col; - QRegExp rx("rgb\\((\\d+),(\\d+),(\\d+)"); + QRegExp rx(R"(rgb\((\d+),(\d+),(\d+))"); if (rx.indexIn(qn) > -1 && rx.captureCount() == 3) { col = QColor(rx.cap(1).toInt(), @@ -513,7 +513,7 @@ QRegExp rx("font\\((.*),(.*)\\)"); if (rx.indexIn(qn) > -1 && rx.captureCount() == 2) { QString family = rx.cap(1); - int size = rx.cap(2).toInt(); + int size = rx.cap(2).toInt(); if (!family.isEmpty()) f.setFamily(family); @@ -521,8 +521,8 @@ if (size >= 1 && size < 200) f.setPointSize(size); - //qDebug() << family << size - //f.fromString(rx.cap(1)); + // qDebug() << family << size + // f.fromString(rx.cap(1)); } return f; @@ -559,7 +559,7 @@ void MvQProperty::parseArea(QString area, QString& w, QString& n, QString& e, QString& s) { - QRegExp rx("area\\((\\S+),(\\S+),(\\S+),(\\S+)\\)"); + QRegExp rx(R"(area\((\S+),(\S+),(\S+),(\S+)\))"); if (rx.indexIn(area) > -1 && rx.captureCount() == 4) { w = rx.cap(1); n = rx.cap(2); diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQProperty.h metview-5.19.2/metview/src/libMvQtUtil/MvQProperty.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQProperty.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQProperty.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,22 +22,22 @@ class MvQPropertyObserver { public: - MvQPropertyObserver() {} - virtual ~MvQPropertyObserver() {} + MvQPropertyObserver() = default; + virtual ~MvQPropertyObserver() = default; virtual void notifyChange(MvQProperty*) = 0; }; -//This class defines a property storing its value as a QVariant. -//Properties are used to store the viewer's configuration. Editable properties -//store all the information needed to display them in a property editor. -//Properties can have children so trees can be built up from them. +// This class defines a property storing its value as a QVariant. +// Properties are used to store the viewer's configuration. Editable properties +// store all the information needed to display them in a property editor. +// Properties can have children so trees can be built up from them. class MvQProperty : public MvQPropertyObserver { public: explicit MvQProperty(const std::string& name); - ~MvQProperty(); + ~MvQProperty() override; enum Type { @@ -112,7 +112,7 @@ void addObserver(MvQPropertyObserver*); void removeObserver(MvQPropertyObserver*); - void notifyChange(MvQProperty*); + void notifyChange(MvQProperty*) override; static bool isColour(const std::string&); static bool isFont(const std::string&); @@ -137,10 +137,10 @@ void dispatchChange(); MvQProperty* find(const std::vector& pathVec); - std::string strName_; //The name of the property as an std::string - QString name_; //The name of the property. Used as an id. - QVariant defaultValue_; //The default value - QVariant value_; //The current value + std::string strName_; // The name of the property as an std::string + QString name_; // The name of the property. Used as an id. + QVariant defaultValue_; // The default value + QVariant value_; // The current value MvQProperty* parent_; QList children_; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQStreamOper.h metview-5.19.2/metview/src/libMvQtUtil/MvQStreamOper.h --- metview-5.17.4/metview/src/libMvQtUtil/MvQStreamOper.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQStreamOper.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,7 @@ class QVariant; class QColor; -//Overload ostringstream for qt objects +// Overload ostringstream for qt objects std::ostream& operator<<(std::ostream&, const QString&); std::ostream& operator<<(std::ostream&, const QModelIndex&); std::ostream& operator<<(std::ostream&, const QVariant&); diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQStyleDb.cc metview-5.19.2/metview/src/libMvQtUtil/MvQStyleDb.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQStyleDb.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQStyleDb.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ #include "MvQPaletteDb.h" #include "MvMiscellaneous.h" -MvQStyleDb* MvQStyleDb::instance_ = 0; +MvQStyleDb* MvQStyleDb::instance_ = nullptr; //========================================== // @@ -70,7 +70,7 @@ QPixmap p(previewFile()); p = p.scaledToWidth(pixSize.width(), Qt::SmoothTransformation); - //p=p.scaled(pixSize,Qt::KeepAspectRatio,Qt::SmoothTransformation); + // p=p.scaled(pixSize,Qt::KeepAspectRatio,Qt::SmoothTransformation); QRect rect(0, 0, p.width() - 1, p.height() - 1); QPainter painter(&p); @@ -85,7 +85,7 @@ QPixmap p(previewFile()); p = p.scaledToHeight(pixSize.height(), Qt::SmoothTransformation); - //p=p.scaled(pixSize,Qt::KeepAspectRatio,Qt::SmoothTransformation); + // p=p.scaled(pixSize,Qt::KeepAspectRatio,Qt::SmoothTransformation); QRect rect(0, 0, p.width() - 1, p.height() - 1); QPainter painter(&p); @@ -98,13 +98,13 @@ void MvQStyleDbItem::paint(QPainter* painter, QRect rect) { - //Keep the height + // Keep the height QPixmap p(previewFile()); if (!p.isNull()) { p = p.scaledToHeight(rect.height(), Qt::SmoothTransformation); } - //p=p.scaled(pixSize,Qt::KeepAspectRatio,Qt::SmoothTransformation); + // p=p.scaled(pixSize,Qt::KeepAspectRatio,Qt::SmoothTransformation); painter->drawPixmap(rect.topLeft(), p); painter->drawRect(QRect(rect.topLeft(), p.size())); @@ -145,17 +145,17 @@ return; } - QByteArray json = fIn.readAll(); + QByteArray json = fIn.readAll(); QJsonDocument doc = QJsonDocument::fromJson(json); - //This document is an array of groups + // This document is an array of groups Q_ASSERT(doc.isObject()); - //Iterate through the ojects in a group + // Iterate through the ojects in a group const QJsonObject& jsonob = doc.object(); for (QJsonObject::const_iterator it = jsonob.constBegin(); it != jsonob.constEnd(); it++) { QString name = it.key(); - //qDebug() << name; + // qDebug() << name; auto* item = new MvQStyleDbItem(name); Q_ASSERT(it.value().isObject()); @@ -190,13 +190,13 @@ return; } - QByteArray json = fIn.readAll(); + QByteArray json = fIn.readAll(); QJsonDocument doc = QJsonDocument::fromJson(json); - //This document is an array of groups + // This document is an array of groups Q_ASSERT(doc.isObject()); - //Iterate through the ojects in a group + // Iterate through the ojects in a group const QJsonObject& jsonob = doc.object(); for (QJsonObject::const_iterator it = jsonob.constBegin(); it != jsonob.constEnd(); it++) { QString name = it.key(); diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQTheme.cc metview-5.19.2/metview/src/libMvQtUtil/MvQTheme.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQTheme.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQTheme.cc 2023-07-15 08:28:47.000000000 +0000 @@ -73,18 +73,18 @@ { int w = img.width(); int h = img.height(); - QRgb c; - int g; - //int gBase = MvQTheme::colour("folderview", "faded_base").red(); - int gBase = 40; - int gTop = 130; + QRgb c = 0; + int g = 0; + // int gBase = MvQTheme::colour("folderview", "faded_base").red(); + int gBase = 40; + int gTop = 130; float gFactor = static_cast(gTop - gBase) / 255.; for (int i = 0; i < w; i++) for (int j = 0; j < h; j++) { c = img.pixel(i, j); if (qAlpha(c) != 0) { - //g=qGray(c); + // g=qGray(c); g = (qRed(c) + qGreen(c) + qBlue(c)) / 3; g = gBase + gFactor * static_cast(g); img.setPixel(i, j, qRgb(g, g, g)); @@ -160,25 +160,25 @@ id_(id) { if (paletteId.isEmpty()) { - paletteId["window"] = QPalette::Window; - paletteId["windowtext"] = QPalette::WindowText; - paletteId["base"] = QPalette::Base; - paletteId["alternatebase"] = QPalette::AlternateBase; - paletteId["tooltipbase"] = QPalette::ToolTipBase; - paletteId["tooltiptext"] = QPalette::ToolTipText; - paletteId["text"] = QPalette::Text; - paletteId["button"] = QPalette::Button; - paletteId["buttontext"] = QPalette::ButtonText; - paletteId["brighttext"] = QPalette::BrightText; - paletteId["light"] = QPalette::Light; - paletteId["midlight"] = QPalette::Midlight; - paletteId["dark"] = QPalette::Dark; - paletteId["mid"] = QPalette::Mid; - paletteId["shadow"] = QPalette::Shadow; - paletteId["higlight"] = QPalette::Highlight; + paletteId["window"] = QPalette::Window; + paletteId["windowtext"] = QPalette::WindowText; + paletteId["base"] = QPalette::Base; + paletteId["alternatebase"] = QPalette::AlternateBase; + paletteId["tooltipbase"] = QPalette::ToolTipBase; + paletteId["tooltiptext"] = QPalette::ToolTipText; + paletteId["text"] = QPalette::Text; + paletteId["button"] = QPalette::Button; + paletteId["buttontext"] = QPalette::ButtonText; + paletteId["brighttext"] = QPalette::BrightText; + paletteId["light"] = QPalette::Light; + paletteId["midlight"] = QPalette::Midlight; + paletteId["dark"] = QPalette::Dark; + paletteId["mid"] = QPalette::Mid; + paletteId["shadow"] = QPalette::Shadow; + paletteId["higlight"] = QPalette::Highlight; paletteId["highlightedtext"] = QPalette::HighlightedText; - paletteId["link"] = QPalette::Link; - paletteId["linkvisited"] = QPalette::LinkVisited; + paletteId["link"] = QPalette::Link; + paletteId["linkvisited"] = QPalette::LinkVisited; #if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) paletteId["placeholdertext"] = QPalette::PlaceholderText; #endif @@ -188,9 +188,9 @@ MvQTheme* MvQTheme::add(QApplication* app, QString id) { - auto theme = new MvQTheme(app, id); + auto theme = new MvQTheme(app, id); themes_[id] = theme; - current_ = theme; + current_ = theme; return theme; } @@ -207,7 +207,7 @@ for (auto resId : resources_) { auto resName = resId + "_" + id + ".rcc"; - auto fName = QString::fromStdString(metview::qtResourceDirFile(resName.toStdString())); + auto fName = QString::fromStdString(metview::qtResourceDirFile(resName.toStdString())); #ifdef METVIEW marslog(LOG_INFO, "Load rcc file: %s", fName.toStdString().c_str()); #else @@ -235,20 +235,21 @@ QFile fIn(inFile.c_str()); if (!fIn.open(QIODevice::ReadOnly | QIODevice::Text)) { - //marslog(LOG_WARN, "DocHughlighter::load() --> Could not open json config file: %s", fName.c_str()); + // marslog(LOG_WARN, "DocHughlighter::load() --> Could not open json config file: %s", fName.c_str()); return; } - QByteArray json = fIn.readAll(); + QByteArray json = fIn.readAll(); QJsonDocument doc = QJsonDocument::fromJson(json); - //This document is an array of groups + // This document is an array of groups Q_ASSERT(doc.isArray()); QJsonArray arr = doc.array(); for (int i = 0; i < arr.count(); i++) { - QJsonObject obj = arr[i].toObject(); - QString group = obj.keys().front(); + QJsonObject obj = arr[i].toObject(); + auto keys = obj.keys(); + QString group = (!keys.isEmpty()) ? (keys.front()) : QString(); QJsonObject vals = obj.value(group).toObject(); QMap m; for (QJsonObject::const_iterator it = vals.constBegin(); it != vals.constEnd(); it++) { @@ -321,7 +322,7 @@ while (it.hasNext()) { it.next(); auto par = it.key(); - auto v = it.value(); + auto v = it.value(); if (!par.isEmpty()) { if (v.startsWith("Q") && v.endsWith("}")) { item->sh_[par] = v; @@ -347,7 +348,7 @@ while (it.hasNext()) { it.next(); auto par = it.key(); - auto v = it.value().toLower(); + auto v = it.value().toLower(); if (par == "boldhtmltabletitle") { boldHtmlTableTitle_ = (v.toLower() == "true") ? true : false; } @@ -360,7 +361,7 @@ QColor MvQTheme::makeColour(QString name) { QColor col; - QRegExp rx("rgb\\((\\d+),(\\d+),(\\d+),?(\\d+)?"); + QRegExp rx(R"(rgb\((\d+),(\d+),(\d+),?(\d+)?)"); if (rx.indexIn(name) > -1) { if (rx.captureCount() >= 3) { @@ -376,36 +377,36 @@ QBrush MvQTheme::makeBrush(QString name) { if (name.startsWith("rgb")) { - return QBrush(makeColour(name)); + return {makeColour(name)}; } else if (name.startsWith("p:")) { auto p = palette_; - return QBrush(p.color(paletteId[name.mid(2)])); + return {p.color(paletteId[name.mid(2)])}; } - else if (cols_.keys().contains(name)) { - return QBrush(cols_[name]); + else if (cols_.contains(name)) { + return {cols_[name]}; } QColor col1, col2; - float x1, y1, x2, y2; + float x1 = 0., y1 = 0., x2 = 0., y2 = 0.; - QRegExp rx("p1\\((\\d+),(\\d+)"); + QRegExp rx(R"(p1\((\d+),(\d+))"); if (rx.indexIn(name) > -1 && rx.captureCount() == 2) { x1 = rx.cap(1).toFloat(); y1 = rx.cap(2).toFloat(); } else - return QBrush(); + return {}; - rx = QRegExp("p2\\((\\d+),(\\d+)"); + rx = QRegExp(R"(p2\((\d+),(\d+))"); if (rx.indexIn(name) > -1 && rx.captureCount() == 2) { x2 = rx.cap(1).toFloat(); y2 = rx.cap(2).toFloat(); } else - return QBrush(); + return {}; - rx = QRegExp("rgb\\((\\d+),(\\d+),(\\d+),?(\\d+)?\\),rgb\\((\\d+),(\\d+),(\\d+),?(\\d+)?"); + rx = QRegExp(R"(rgb\((\d+),(\d+),(\d+),?(\d+)?\),rgb\((\d+),(\d+),(\d+),?(\d+)?)"); if (rx.indexIn(name) > -1 && rx.captureCount() == 8) { col1 = QColor(rx.cap(1).toInt(), rx.cap(2).toInt(), @@ -418,7 +419,7 @@ rx.cap(8).isEmpty() ? 255 : rx.cap(8).toInt()); } else - return QBrush(); + return {}; QLinearGradient grad; @@ -428,7 +429,7 @@ grad.setColorAt(0, col1); grad.setColorAt(1, col2); - return QBrush(grad); + return {grad}; } QBrush MvQTheme::brush(QString group, QString item) @@ -446,7 +447,7 @@ QPen MvQTheme::pen(QString group, QString item, float width, Qt::PenStyle style) { if (MvQTheme::current_) - return QPen(MvQTheme::current_->brush(group, item).color(), width, style); + return {MvQTheme::current_->brush(group, item).color(), width, style}; return {}; } @@ -461,7 +462,7 @@ { if (MvQTheme::current_) return MvQTheme::current_->cols_[item]; - return QColor(); + return {}; } @@ -483,49 +484,49 @@ { if (MvQTheme::current_) return MvQTheme::current_->cols_["text"]; - return QColor(); + return {}; } QColor MvQTheme::subText() { if (MvQTheme::current_) return MvQTheme::current_->cols_["subtext"]; - return QColor(); + return {}; } QColor MvQTheme::accentText() { if (MvQTheme::current_) return MvQTheme::current_->cols_["accenttext"]; - return QColor(); + return {}; } QColor MvQTheme::imageBorder() { if (MvQTheme::current_) return MvQTheme::current_->cols_["imageborder"]; - return QColor(); + return {}; } QColor MvQTheme::treeItemBorder() { if (MvQTheme::current_) return MvQTheme::current_->cols_["treeitemborder"]; - return QColor(); + return {}; } QColor MvQTheme::htmlTableText() { if (MvQTheme::current_) return MvQTheme::current_->cols_["htmltable_text"]; - return QColor(); + return {}; } QColor MvQTheme::htmlTableBg() { if (MvQTheme::current_) return MvQTheme::current_->cols_["htmltable_bg"]; - return QColor(); + return {}; } QString MvQTheme::highlighterFile() @@ -547,7 +548,7 @@ // QFont f; // int fs = f.pointSize(); // fs -= 1; - //QString s = "* {font-size: " + QString::number(fs) + " pt;} div {color: " + MvQTheme::subText().name() + + // QString s = "* {font-size: " + QString::number(fs) + " pt;} div {color: " + MvQTheme::subText().name() + //";} td {font-size: " + QString::number(fs) + "pt; background: "+ MvQTheme::htmlTableBg().name() + QString s( "div {color: %1;} " @@ -578,7 +579,7 @@ psvg = QString::fromStdString(metview::iconDirFile( MvQTheme::current_->id_.toStdString(), fname.toStdString() + ".svg")); - f = QFileInfo(psvg); + f = QFileInfo(psvg); if (f.exists()) { return psvg; } @@ -586,13 +587,13 @@ // try with the default style psvg = QString::fromStdString(metview::iconDirFile(fname.toStdString() + ".svg")); - f = QFileInfo(psvg); + f = QFileInfo(psvg); if (f.exists()) { return psvg; } else { QString pxpm = QString::fromStdString(metview::iconDirFile(fname.toStdString() + ".xpm")); - f = QFileInfo(pxpm); + f = QFileInfo(pxpm); if (f.exists()) { return pxpm; } @@ -621,7 +622,7 @@ QPixmap MvQTheme::logo() { - return QPixmap(":/window/metview.svg"); + return {":/window/metview.svg"}; } #ifdef ECCODES_UI diff -Nru metview-5.17.4/metview/src/libMvQtUtil/MvQXmlQuery.cc metview-5.19.2/metview/src/libMvQtUtil/MvQXmlQuery.cc --- metview-5.17.4/metview/src/libMvQtUtil/MvQXmlQuery.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/MvQXmlQuery.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,7 @@ { QXmlItem item(result.next()); while (!item.isNull()) { - //qDebug() << item.isNode() << item.isAtomicValue() << item.toAtomicValue(); + // qDebug() << item.isNode() << item.isAtomicValue() << item.toAtomicValue(); if (item.isAtomicValue()) { QVariant v = item.toAtomicValue(); @@ -54,13 +54,13 @@ evaluateTo(&name); name = name.simplified(); - //qDebug() << "name:" << name; + // qDebug() << "name:" << name; setQuery("string()"); evaluateTo(&value); value = value.simplified(); - //qDebug() << "value:" << value; + // qDebug() << "value:" << value; if (name.isEmpty() == false) { att[name] = value; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/WmoWeatherSymbol.cc metview-5.19.2/metview/src/libMvQtUtil/WmoWeatherSymbol.cc --- metview-5.17.4/metview/src/libMvQtUtil/WmoWeatherSymbol.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/WmoWeatherSymbol.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ QString name; QString title; WmoWeatherSymbolGroup* group = nullptr; - bool groups = true; + bool groups = true; while (!line.isNull()) { line = line.simplified(); if (!line.isEmpty()) { @@ -52,7 +52,7 @@ auto gr = line.split("="); if (gr.count() == 2) { groups_.push_back(new WmoWeatherSymbolGroup(gr[0].toStdString(), gr[1].toStdString())); - //qDebug() << "group" << gr[0] << gr[1]; + // qDebug() << "group" << gr[0] << gr[1]; } } } @@ -78,7 +78,7 @@ } else if (line.startsWith("G=")) { int idx = line.mid(2).toInt(); - group = nullptr; + group = nullptr; if (idx >= 0 && idx < static_cast(groups_.size())) { group = groups_[idx]; } @@ -111,8 +111,8 @@ QPixmap WmoWeatherSymbol::pixmap(int w, int h, QColor fgCol, QPen boxPen, QBrush boxBrush) { - QString hd = ""; - auto t = QString::fromStdString(xmlHeader + "\n" + body_); + // QString hd = ""; + auto t = QString::fromStdString(xmlHeader + "\n" + body_); if (fgCol.isValid() && fgCol != QColor(Qt::black)) { t = t.replace("#000000", fgCol.name()); diff -Nru metview-5.17.4/metview/src/libMvQtUtil/WsDecoder.cc metview-5.19.2/metview/src/libMvQtUtil/WsDecoder.cc --- metview-5.17.4/metview/src/libMvQtUtil/WsDecoder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/WsDecoder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,16 +39,16 @@ const MvRequest& styleReq, QJsonDocument& doc) { QJsonObject d; - d["type"] = "Feature"; + d["type"] = "Feature"; d["convention"] = "metview-ws"; - d["class_ws"] = wst->reqVerb(); - d["type_ws"] = name; + d["class_ws"] = wst->reqVerb(); + d["type_ws"] = name; // geometry QJsonObject geom; - geom["type"] = wst->geojsonType(); + geom["type"] = wst->geojsonType(); geom["coordinates"] = MvQJson::fromPointFList(coord, wst->geojsonType()); - d["geometry"] = geom; + d["geometry"] = geom; // properties QJsonObject p; @@ -75,7 +75,7 @@ void setCoord(MvRequest& r, QList arr) { for (auto& i : arr) { - //MvLog().dbg() << "[" << i << "]" << arr[i]; + // MvLog().dbg() << "[" << i << "]" << arr[i]; r.addValue("X", i.x()); r.addValue("Y", i.y()); } @@ -88,7 +88,7 @@ int numX = r.iterInit("X"); for (int i = 0; i < numX; i++) { - double d; + double d = 0.; if (!r.iterGetNextValue(d)) { return {}; } @@ -100,7 +100,7 @@ return {}; } for (int i = 0; i < numY; i++) { - double d; + double d = 0.; if (!r.iterGetNextValue(d)) { return {}; } @@ -128,14 +128,14 @@ { auto p = obj["properties"].toObject(); if (!p.isEmpty()) { - auto s = p["style"].toObject(); - if (!s.isEmpty()) { - auto pObj = s["params"].toObject(); - pObj[param] = v; - s["params"] = pObj; - p["style"] = s; - obj["properties"] = p; - } + auto s = p["style"].toObject(); + if (!s.isEmpty()) { + auto pObj = s["params"].toObject(); + pObj[param] = v; + s["params"] = pObj; + p["style"] = s; + obj["properties"] = p; + } } } @@ -149,11 +149,11 @@ void WsDecoder::toJson(const MvRequest& rIn, QJsonDocument& doc) { - if(const char* chVerb = rIn.getVerb()) { + if (const char* chVerb = rIn.getVerb()) { // The request must alway be expanded! auto r = WsType::expandRequest(rIn); -// MvLog().dbg() << MV_FN_INFO << "r="; -// r.print(); + // MvLog().dbg() << MV_FN_INFO << "r="; + // r.print(); auto wst = WsType::findByReq(r); if (!wst) { const char* chVerb = r.getVerb(); @@ -180,16 +180,16 @@ void WsDecoder::toJsonCollection(const QJsonArray& a, QJsonDocument& doc) { QJsonObject d; - d["type"] = "FeatureCollection"; - d["class_ws"] = "WS_COLLECTION"; + d["type"] = "FeatureCollection"; + d["class_ws"] = "WS_COLLECTION"; d["convention"] = "metview-ws"; - d["features"] = a; + d["features"] = a; doc.setObject(d); } void WsDecoder::readCollection(QString fPath, QJsonArray& a) { -// MvLog().dbg() << MV_FN_INFO << fPath; + // MvLog().dbg() << MV_FN_INFO << fPath; if (!fPath.isEmpty()) { QFile f(fPath); if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { @@ -218,14 +218,14 @@ auto obj = doc.object(); if (!obj.empty() && obj["convention"] == "metview-ws") { QString cls = obj["class_ws"].toString(); - //MvLog().dbg() << "CLS=" << cls; + // MvLog().dbg() << "CLS=" << cls; if (!cls.isEmpty()) { auto prop = obj["properties"].toObject(); if (!prop.isEmpty()) { MvQJson::toRequest(prop["style"].toObject(), r); if (r) { const char* verb = r.getVerb(); - //MvLog().dbg() << "verb=" << verb; + // MvLog().dbg() << "verb=" << verb; if (!verb || cls != verb) { r = MvRequest(); return; @@ -236,11 +236,11 @@ } QJsonObject g = obj["geometry"].toObject(); - auto coord = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); + auto coord = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); setCoord(r, coord); QString name = obj["type_ws"].toString(); - if (WsType *wst = WsType::find(cls, name)) { + if (WsType* wst = WsType::find(cls, name)) { wst->updateTypeInReq(r); } @@ -359,23 +359,23 @@ QString WsDecoder::toolTip(const QJsonDocument& doc) { auto obj = doc.object(); - auto p = obj["properties"].toObject(); + auto p = obj["properties"].toObject(); MvRequest r; MvQJson::toRequest(p["style"].toObject(), r); const char* ch = r("TOOLTIP"); - return (ch)?QString(ch):QString(); + return (ch) ? QString(ch) : QString(); } void WsDecoder::setToolTip(QJsonDocument& doc, QString toolTip) { auto obj = doc.object(); - auto p = obj["properties"].toObject(); - auto s = p["style"].toObject(); + auto p = obj["properties"].toObject(); + auto s = p["style"].toObject(); MvRequest r; MvQJson::toRequest(s, r); - r("TOOLTIP") = toolTip.toStdString().c_str(); - s = MvQJson::fromRequest(r); - p["style"] = s; + r("TOOLTIP") = toolTip.toStdString().c_str(); + s = MvQJson::fromRequest(r); + p["style"] = s; obj["properties"] = p; doc.setObject(obj); } @@ -383,7 +383,7 @@ bool WsDecoder::geoLocked(const QJsonDocument& doc) { auto obj = doc.object(); - auto p = obj["properties"].toObject(); + auto p = obj["properties"].toObject(); MvRequest r; MvQJson::toRequest(p["style"].toObject(), r); const char* ch = r("GEOLOCK"); @@ -393,13 +393,13 @@ void WsDecoder::setGeoLocked(QJsonDocument& doc, bool geoLocked) { auto obj = doc.object(); - auto p = obj["properties"].toObject(); - auto s = p["style"].toObject(); + auto p = obj["properties"].toObject(); + auto s = p["style"].toObject(); MvRequest r; MvQJson::toRequest(s, r); - r("GEOLOCK") = ((geoLocked) ? "ON" : "OFF"); - s = MvQJson::fromRequest(r); - p["style"] = s; + r("GEOLOCK") = ((geoLocked) ? "ON" : "OFF"); + s = MvQJson::fromRequest(r); + p["style"] = s; obj["properties"] = p; doc.setObject(obj); } diff -Nru metview-5.17.4/metview/src/libMvQtUtil/WsDecoder.h metview-5.19.2/metview/src/libMvQtUtil/WsDecoder.h --- metview-5.17.4/metview/src/libMvQtUtil/WsDecoder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/WsDecoder.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,8 +33,8 @@ static void readCollection(QString fPath, QJsonArray& a); static WsType* getWsType(const QJsonDocument&); - static void toRequest(const QJsonDocument&, MvRequest&, long flags=EXPAND_DEFAULTS); - static void toRequest(const std::string& fPath, MvRequest& r, long flags=EXPAND_DEFAULTS); + static void toRequest(const QJsonDocument&, MvRequest&, long flags = EXPAND_DEFAULTS); + static void toRequest(const std::string& fPath, MvRequest& r, long flags = EXPAND_DEFAULTS); static void toStyleRequest(const QJsonDocument& doc, MvRequest& style); static void styleValue(const QJsonObject& obj, QString param, double& v); static void styleValue(const QJsonObject& obj, QString param, std::vector& vec); @@ -48,5 +48,4 @@ static void setToolTip(QJsonDocument& doc, QString toolTip); static bool geoLocked(const QJsonDocument& doc); static void setGeoLocked(QJsonDocument& doc, bool geoLocked); - }; diff -Nru metview-5.17.4/metview/src/libMvQtUtil/WsType.cc metview-5.19.2/metview/src/libMvQtUtil/WsType.cc --- metview-5.17.4/metview/src/libMvQtUtil/WsType.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/WsType.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,9 +28,9 @@ std::vector WsType::items_; std::map WsType::cls_; WsType* WsType::userImageAllItem_ = nullptr; -WsType* WsType::wmoAllItem_ = nullptr; -WsType::Mode WsType::mode_ = WsType::NoMode; -int WsType::defaultPixSize_ = 20; +WsType* WsType::wmoAllItem_ = nullptr; +WsType::Mode WsType::mode_ = WsType::NoMode; +int WsType::defaultPixSize_ = 20; static QColor defaultPixBgColor(Qt::transparent); //================================================================= @@ -139,14 +139,18 @@ if (mode_ == DesktopMode) { items_.push_back(wmoAllItem_); } - } else if(strcmp(req, "WS_HIGH") == 0 || strcmp(req, "WS_LOW") == 0) { + } + else if (strcmp(req, "WS_HIGH") == 0 || strcmp(req, "WS_LOW") == 0) { items_.push_back(new WsCharImageType(r)); - } else if(strcmp(req, "WS_STORM") == 0 ) { + } + else if (strcmp(req, "WS_STORM") == 0) { items_.push_back(new WsSvgImageType(r)); - } else if(strcmp(req, "WS_IMAGE") == 0 || strcmp(req, "WS_MARKER") == 0 || - strcmp(req, "WS_SHAPE") == 0) { + } + else if (strcmp(req, "WS_IMAGE") == 0 || strcmp(req, "WS_MARKER") == 0 || + strcmp(req, "WS_SHAPE") == 0) { items_.push_back(new WsStandardMultiType(r)); - } else { + } + else { items_.push_back(new WsStandardType(r)); } } @@ -172,7 +176,6 @@ QList added; for (auto items_dir : dirs) { - // Search directory to get all items (svg and png) if (items_dir.isEmpty()) { continue; @@ -195,7 +198,7 @@ } else { if (!added.contains(fileName)) { -// MvLog().dbg() << MV_FN_INFO << " name=" << name; + // MvLog().dbg() << MV_FN_INFO << " name=" << name; items_.push_back(new WsUserImageSingleType(fileName, items_dir)); added << fileName; } @@ -245,10 +248,10 @@ } } -// MvLog().dbg() << MV_FN_INFO << " verb=" << verb << " rType=" << rType << " uType=" << uType; + // MvLog().dbg() << MV_FN_INFO << " verb=" << verb << " rType=" << rType << " uType=" << uType; for (auto it : items_) { - if (it->matchReq(verb, rType, uType)) { -// MvLog().dbg() << " it=" << it->name() << " " << it->reqVerb(); + if (it->matchReq(verb, rType, uType)) { + // MvLog().dbg() << " it=" << it->name() << " " << it->reqVerb(); return it; } } @@ -258,7 +261,7 @@ MvRequest WsType::expandRequest(const MvRequest& r, long flags) { - if(const char* ch = r.getVerb()) { + if (const char* ch = r.getVerb()) { std::string verb(ch); auto it = cls_.find(verb); if (it != cls_.end()) { @@ -348,7 +351,8 @@ // //================================================================= -WsSvgImageType::WsSvgImageType(const MvRequest& r) : WsStandardMultiType(r) +WsSvgImageType::WsSvgImageType(const MvRequest& r) : + WsStandardMultiType(r) { const char* verb = r.getVerb(); assert(verb); @@ -365,7 +369,7 @@ if (!svgTemplateColour_.isEmpty() && fg.isValid()) { return MvQ::makePixmapFromSvgTemplate(iconPath(), width, height, fg, svgTemplateColour_, {}, {}); - } + } return MvQ::makePixmap(iconPath(), width, height, col); } @@ -375,7 +379,8 @@ // //================================================================= -WsCharImageType::WsCharImageType(const MvRequest& r) : WsStandardType(r) +WsCharImageType::WsCharImageType(const MvRequest& r) : + WsStandardType(r) { const char* verb = r.getVerb(); assert(verb); @@ -394,8 +399,8 @@ auto col = QColor(Qt::transparent); QString templateTxt = ">" + QString(svgTemplateChar_) + ""; QString txt = ">" + QString(ch) + ""; -// MvLog().dbg() << MV_FN_INFO << "svgTemplateColour=" << svgTemplateColour_ << -// " svgTemplateChar=" << QString(svgTemplateChar_) << " fg=" << fg <<" txt=" << txt; + // MvLog().dbg() << MV_FN_INFO << "svgTemplateColour=" << svgTemplateColour_ << + // " svgTemplateChar=" << QString(svgTemplateChar_) << " fg=" << fg <<" txt=" << txt; if (!svgTemplateColour_.isEmpty() && fg.isValid()) { return MvQ::makePixmapFromSvgTemplate(iconPath(), width, height, @@ -433,7 +438,7 @@ rType = rType.toLower(); if (rType == "user") { if (const char* u = req("NAME")) { - return QString(u); + return {u}; } } } @@ -461,7 +466,7 @@ // //================================================================= -WsUserImageSingleType::WsUserImageSingleType(QString iconName, QString iconDir): +WsUserImageSingleType::WsUserImageSingleType(QString iconName, QString iconDir) : iconName_(iconName), iconDir_(iconDir) { @@ -613,7 +618,7 @@ if (symbol_) { return symbol_->pixmap(width, height, fg, boxPen, boxBrush); } - return QPixmap(width, height); + return {width, height}; } void WsWmoSingleType::updateTypeInReq(MvRequest& r) diff -Nru metview-5.17.4/metview/src/libMvQtUtil/WsType.h metview-5.19.2/metview/src/libMvQtUtil/WsType.h --- metview-5.17.4/metview/src/libMvQtUtil/WsType.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/libMvQtUtil/WsType.h 2023-07-15 08:28:47.000000000 +0000 @@ -55,30 +55,30 @@ PlotWindowMode, CodeGenerateMode }; - WsType() = default; + WsType() = default; WsType(const WsType&) = delete; WsType& operator=(const WsType&) = delete; - virtual ~WsType() = default; + virtual ~WsType() = default; - virtual QString name() const = 0; + virtual QString name() const = 0; virtual QString nameFromRequest(const MvRequest&) const = 0; - virtual QString label() const = 0; - virtual QString description() const = 0; - virtual QString grItemType() const = 0; - virtual QString reqVerb() const = 0; - virtual QString geojsonType() const = 0; - virtual QString group() const = 0; - virtual QString subGroup() const = 0; + virtual QString label() const = 0; + virtual QString description() const = 0; + virtual QString grItemType() const = 0; + virtual QString reqVerb() const = 0; + virtual QString geojsonType() const = 0; + virtual QString group() const = 0; + virtual QString subGroup() const = 0; virtual QPixmap defaultPixmap() const; virtual QPixmap pixmap(int width, int height, QColor fgCol = QColor(Qt::black), QPen boxPen = QPen(Qt::NoPen), QBrush boxBrush = QBrush(Qt::NoBrush)) const = 0; - virtual QPixmap pixmapWithChar(int width, int height, QColor fg, QChar /*ch*/) const {return pixmap(width, height, fg);} - virtual QSize sizeInPx() const {return {};} + virtual QPixmap pixmapWithChar(int width, int height, QColor fg, QChar /*ch*/) const { return pixmap(width, height, fg); } + virtual QSize sizeInPx() const { return {}; } virtual void updateTypeInReq(MvRequest&) = 0; static const std::vector& items() { return items_; } static WsType* find(QString reqVerb, QString name); static WsType* findByReq(const MvRequest&); - static MvRequest expandRequest(const MvRequest&, long flags=EXPAND_DEFAULTS); + static MvRequest expandRequest(const MvRequest&, long flags = EXPAND_DEFAULTS); static void init(Mode); static int defaultPixSize() { return defaultPixSize_; } @@ -185,6 +185,7 @@ class WsUserImageSingleType : public WsType { friend class WsType; + public: WsUserImageSingleType(const WsUserImageSingleType&) = delete; WsUserImageSingleType& operator=(const WsUserImageSingleType&) = delete; @@ -231,7 +232,7 @@ QString group() const override; QString subGroup() const override; QPixmap defaultPixmap() const override; - QPixmap pixmap(int width, int height, QColor fg, QPen boxPen, QBrush boxBrush) const override; + QPixmap pixmap(int width, int height, QColor fg, QPen boxPen, QBrush boxBrush) const override; void updateTypeInReq(MvRequest&) override; protected: diff -Nru metview-5.17.4/metview/src/Macro/beautify.c metview-5.19.2/metview/src/Macro/beautify.c --- metview-5.17.4/metview/src/Macro/beautify.c 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/beautify.c 2023-07-15 08:28:47.000000000 +0000 @@ -15,17 +15,17 @@ /* #endif */ #include -static int beau = 0; /* Beautify of ps_ output */ -static int margin = 25; -static int size = 9; -static int count = 0; -static int tab = 4; +static int beau = 0; /* Beautify of ps_ output */ +static int margin = 25; +static int size = 9; +static int count = 0; +static int tab = 4; static int landscape = 0; -static int twopages = 0; +static int twopages = 0; static int braket = 0; static int ketbra = 0; -static int force = 0; +static int force = 0; #define MAXBUF 1024 @@ -120,7 +120,7 @@ ps_string(buffer); printf("S\n"); *buffer = 0; - bufidx = 0; + bufidx = 0; } void ps_space(const char* w) @@ -408,7 +408,7 @@ case 'b': beau = 1; - tab = 0; + tab = 0; break; case '2': diff -Nru metview-5.17.4/metview/src/Macro/bufr.cc metview-5.19.2/metview/src/Macro/bufr.cc --- metview-5.17.4/metview/src/Macro/bufr.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/bufr.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ #include "MvException.h" // should include MvFieldSet.h, but it requires other header files... -//double interpolateValue( field* Grib, double lat, double lon ); +// double interpolateValue( field* Grib, double lat, double lon ); // To do : filter(geo,area) @@ -164,7 +164,7 @@ InPool(tbufr) { r = empty_request("BUFR"); - //set_value(r,"PATH","%s",p); + // set_value(r,"PATH","%s",p); set_value(r, "PATH", "%s", FullPathName(p).c_str()); set_value(r, "TEMPORARY", "%d", temp); } @@ -237,8 +237,8 @@ const char* path = get_value(r, "PATH", 0); gpts_.load(path); } - //else - // is probably a geopoints structure in memory, or with zero count! + // else + // is probably a geopoints structure in memory, or with zero count! } void CGeopts::unload(bool doFree) @@ -276,7 +276,7 @@ InPool(tgeopts) { r = empty_request("GEOPOINTS"); - //set_value(r,"PATH","%s",p); + // set_value(r,"PATH","%s",p); set_value(r, "PATH", "%s", FullPathName(p).c_str()); set_value(r, "TEMPORARY", "%d", temp); } @@ -307,7 +307,7 @@ CGeopts::CGeopts(MvGeoPoints& gptsIn) : InPool(tgeopts) { - r = nullptr; + r = nullptr; gpts_ = gptsIn; // makes a copy, we should make this more efficient } @@ -317,9 +317,9 @@ { r = nullptr; p->load(); - eGeoFormat fmt = (storeLocs) - ? eGeoNCols - : p->gpts_.format(); + eGeoFormat fmt = (storeLocs) + ? eGeoNCols + : p->gpts_.format(); eGeoCopyMode copyMode = (fmt == eGeoNCols) ? eGeoCopyCoordinatesOnly : eGeoCopyAll; @@ -345,15 +345,15 @@ //-- get date/time/level metadata from the GRIB field MvDate base(fld->yyyymmddFoh()); //-- base (analysis) date - double step = fld->stepFoh(); //-- forecast step + double step = fld->stepFoh(); //-- forecast step MvDate valid = base + step; //-- valid date - long dat = valid.YyyyMmDd(); - long tim = valid.Hour() * 100 + valid.Minute(); + long dat = valid.YyyyMmDd(); + long tim = valid.Hour() * 100 + valid.Minute(); double level = fld->level(); n = 0; for (size_t i = 0; i < p->gpts_.count(); i++) { - double x = DBL_MAX; + double x = DBL_MAX; double near_lat = DBL_MAX; double near_lon = DBL_MAX; gpts_.set_rowIndex(i); // all row-based ops will operate on this row @@ -362,9 +362,9 @@ if (nearest) { if (storeLocs) { MvGridPoint gridp = fld->nearestGridpointInfo(gpts_.lon_x(), gpts_.lat_y(), nearestValid); - near_lat = gridp.loc_.latitude(); - near_lon = gridp.loc_.longitude(); - x = gridp.value_; + near_lat = gridp.loc_.latitude(); + near_lon = gridp.loc_.longitude(); + x = gridp.value_; } else x = fld->nearestGridpoint(gpts_.lon_x(), gpts_.lat_y(), nearestValid); @@ -412,7 +412,7 @@ } } } - //if(count) delete[] pts; + // if(count) delete[] pts; free_all_requests(r); } @@ -454,15 +454,15 @@ // and its value matches MvGeoPoints::metadata_t& md = gpts_.metadata(); - parameter* p = r->params; + parameter* p = r->params; while (p) { const char* key = p->name; - value* v = p->values; + value* v = p->values; if (key) { // loop through all the given values for this key - succeed if any match bool doesThisKeyMatch = false; - auto it = md.find(key); + auto it = md.find(key); if (it == md.end()) // key not found return false; @@ -495,7 +495,7 @@ CVector* vector; int inputCount; int valColIndex = 0; - double val = GEOPOINTS_MISSING_VALUE; //-- used if list contains non-numbers + double val = GEOPOINTS_MISSING_VALUE; //-- used if list contains non-numbers if (col == eGeoColStnId && (!isList)) { return std::string("set_stnids: must supply a list of strings"); @@ -540,7 +540,7 @@ for (int i = 0; i < cnt; ++i) { - double cur = val; //-- if list then cur is initialised as missing_value + double cur = val; //-- if list then cur is initialised as missing_value const char* id = ""; Date d; bool isDate = false; @@ -548,9 +548,9 @@ if (isList) { vtype listElementType = (*lst)[i].GetType(); if (listElementType == tnumber) { - (*lst)[i].GetValue(cur); //-- if list and current list element is number + (*lst)[i].GetValue(cur); //-- if list and current list element is number if (is_number_nan_d(cur)) // nans can come from Python - cur = val; // missing + cur = val; // missing } else if (listElementType == tnil) { } // id remains "" @@ -626,11 +626,11 @@ const char* indexName; arg[0].GetValue(indexName); - eGeoColType coltype = eGeoColValue; - bool isList = v.GetType() == tlist; - bool isVector = v.GetType() == tvector; + eGeoColType coltype = eGeoColValue; + bool isList = v.GetType() == tlist; + bool isVector = v.GetType() == tvector; bool valueIndexProvided = false; - Value* valueIndex = nullptr; + Value* valueIndex = nullptr; // standard column names @@ -654,9 +654,9 @@ coltype = eGeoColElevation; else { // e.g. 't2' or some other value heading in the NCOLS format - coltype = eGeoColValue; + coltype = eGeoColValue; valueIndexProvided = true; - valueIndex = new Value(strcache(indexName)); + valueIndex = new Value(strcache(indexName)); } std::string errmsg = SetColumnValues(coltype, v, isList, isVector, valueIndexProvided, valueIndex); @@ -710,7 +710,7 @@ size_t ncols = g->gpts().nValColsForCompute(); - bool multi = (ncols > 1); + bool multi = (ncols > 1); if (multi) { returnValue = Value(new CVector(ncols)); } @@ -1071,7 +1071,7 @@ CGeopts* g; int i; - double d[4]; + double d[4] = {0., 0., 0., 0.}; double& n = d[0]; double& w = d[1]; @@ -1152,7 +1152,8 @@ // build polygons try { metview::buildPolygons(&arg[1], &arg[2], polygons); - } catch (MvException &e) { + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } @@ -1165,7 +1166,7 @@ eckit::geometry::Point2 p(g->gpts().lon_x(), g->gpts().lat_y()); bool inside = false; - for (auto const& poly: polygons) { + for (auto const& poly : polygons) { if (poly.contains(p)) { inside = true; break; @@ -1174,10 +1175,12 @@ if (setMissing_) { if (!inside) { x->gpts().set_value_missing(m++, 0); - } else { + } + else { x->gpts().set_ivalue(g->gpts().value(), m++, 0); } - } else { + } + else { x->gpts().set_ivalue((inside) ? 1 : 0, m++, 0); } } @@ -1351,7 +1354,7 @@ Value GeoIntBits::Execute(int arity, Value* arg) { int value, bitindex; - //int integervalue; + // int integervalue; int bitmask = 0; int bits; int num_bits = 1; @@ -1407,7 +1410,7 @@ geo->gpts().set_rowIndex(r); geonew->gpts().set_rowIndex(r); value = (int)geo->gpts().value(); // take input value as an integer - bits = value & bitmask; // mask off the bits we want + bits = value & bitmask; // mask off the bits we want // shift the result down. For instance, if the 5th bit is set, we // just want the result to be 1 when checking for that bit. If @@ -1958,7 +1961,7 @@ set_value(r, "value_missing", "%d", g.value_missing() ? 1 : 0); //-- valid only for geovectors - double direc = (g.nValCols() > 1) ? g.direc() : 0; + double direc = (g.nValCols() > 1) ? g.direc() : 0; bool direc_missing = (g.nValCols() > 1) ? g.direc_missing() : false; set_value(r, "value2", "%g", direc); set_value(r, "value2_missing", "%d", direc_missing ? 1 : 0); @@ -2289,37 +2292,37 @@ class GeoMulOp : public Function { - typedef double (*binproc)(double,double); - binproc F_; + typedef double (*binproc)(double,double); + binproc F_; public: - GeoMulOp(char *n,binproc f) : Function(n) { F_ = f; } - virtual Value Execute(int arity,Value *arg); - virtual int ValidArguments(int arity,Value *arg); + GeoMulOp(char *n,binproc f) : Function(n) { F_ = f; } + virtual Value Execute(int arity,Value *arg); + virtual int ValidArguments(int arity,Value *arg); }; int GeoMulOp::ValidArguments(int arity,Value *arg) { - if(arity < 1) return false; - for(int i = 0;iload(); size_t ncols = g->gpts().nValColsForCompute(); - bool multi = (ncols > 1); + bool multi = (ncols > 1); if (multi) { returnValue = Value(new CVector(ncols)); } for (size_t c = 0; c < ncols; c++) { - dSum = 0.0; + dSum = 0.0; nNumValid = 0; for (size_t i = 0; i < g->Count(); i++) { g->gpts().set_rowIndex(i); @@ -2422,8 +2425,8 @@ auto* x = new CGeopts(g); for (size_t i = 0; i < g->Count(); i++) { - lat = g->gpts().lat_y(i); - lon = g->gpts().lon_x(i); + lat = g->gpts().lat_y(i); + lon = g->gpts().lon_x(i); double dist = GEOPOINTS_MISSING_VALUE; if (lat != GEOPOINTS_MISSING_VALUE && lon != GEOPOINTS_MISSING_VALUE) { point.set(lat, lon); @@ -2590,11 +2593,11 @@ { CGeopts* gnew = nullptr; int n; - int nv = 1; - int numUserCols = 0; + int nv = 1; + int numUserCols = 0; const char* type = ""; - eGeoFormat efmt = eGeoTraditional; - bool setNames = false; + eGeoFormat efmt = eGeoTraditional; + bool setNames = false; // function signature: create_geo(nrows [,type [,list-of-colnames]]) @@ -2708,11 +2711,11 @@ // check the column name and prepare to set its values std::string colName(param); - eGeoColType colType = MvGeoPoints::colTypeFromName(removeTrailingS(colName), true); - bool isList = (value.GetType() == tlist); - bool isVector = (value.GetType() == tvector); - bool valueIndexProvided = false; - Value* indexValue = nullptr; + eGeoColType colType = MvGeoPoints::colTypeFromName(removeTrailingS(colName), true); + bool isList = (value.GetType() == tlist); + bool isVector = (value.GetType() == tvector); + bool valueIndexProvided = false; + Value* indexValue = nullptr; eGeoColType colTypeToSet = colType; // column name not one of our standard ones, e.g. latitude? @@ -2720,7 +2723,7 @@ // user-defined column? if (efmt == eGeoNCols) { valueIndexProvided = true; - indexValue = &arg[i]; + indexValue = &arg[i]; gnew->gpts().addColName(colName); colTypeToSet = eGeoColValue; } @@ -2882,10 +2885,10 @@ MvGeoPoints& gp1 = g1->gpts(); MvGeoPoints& gp2 = g2->gpts(); MvGeoPoints& gpx = gx->gpts(); - size_t count_g1 = g1->Count(); - size_t count_g2 = g2->Count(); - size_t rx = 0; - size_t rg1 = 0; + size_t count_g1 = g1->Count(); + size_t count_g2 = g2->Count(); + size_t rx = 0; + size_t rg1 = 0; for (size_t rg2 = 0; rg2 < count_g2; ++rg2) { // both sets of gpts are sorted geographically, so we can immediately // discard any points that are outside the bounds of our source points @@ -2917,7 +2920,8 @@ // class GeoOffsetFunction : public Function { - double dlat, dlon; + double dlat{0.}; + double dlon{0.}; public: GeoOffsetFunction(const char* n) : @@ -2932,7 +2936,7 @@ int GeoOffsetFunction::ValidArguments(int arity, Value* arg) { int i; - //CList *l; + // CList *l; if (arity < 2) return false; @@ -3031,12 +3035,12 @@ class GeoSetFunction : public Function { eGeoColType col; - bool isList; - bool isVector; - bool deprecated; - bool valueIndexProvided; - bool valueIndexIsString; - int indexOfValueArg; + bool isList{false}; + bool isVector{false}; + bool deprecated{false}; + bool valueIndexProvided{false}; + bool valueIndexIsString{false}; + int indexOfValueArg{0}; const char* fieldName; const char* newName; char expandedInfo[100]; @@ -3065,19 +3069,19 @@ return false; // check for syntax set_values(gpt, |5, 6, 8, 8, 1|) vs set_values(gpt, index, |5, 6, 8, 8, 1|) - indexOfValueArg = 1; + indexOfValueArg = 1; valueIndexProvided = false; valueIndexIsString = false; if (arity == 3) { valueIndexProvided = true; - indexOfValueArg = 2; + indexOfValueArg = 2; if (arg[1].GetType() == tstring) valueIndexIsString = true; else if (arg[1].GetType() != tnumber) return false; } - isList = false; + isList = false; isVector = false; if (arg[indexOfValueArg].GetType() == tnumber) // second argument can be a number, a list or a vector @@ -3202,9 +3206,9 @@ parameter* p = r->params; while (p) { const char* key = p->name; - value* v = p->values; - md[key] = MvVariant(v->name); - p = p->next; + value* v = p->values; + md[key] = MvVariant(v->name); + p = p->next; } g->unload(); diff -Nru metview-5.17.4/metview/src/Macro/codb.cc metview-5.19.2/metview/src/Macro/codb.cc --- metview-5.17.4/metview/src/Macro/codb.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/codb.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,11 +28,11 @@ InPool(todb, s) { odb_ = 0; - r = clone_all_requests(s); + r = clone_all_requests(s); if (r) { const char* path = get_value(r, "PATH", 0); - odb_ = MvOdbFactory::make(path); + odb_ = MvOdbFactory::make(path); } IsIcon(true); // so that InPool won't touch the data - we control its deletion in Macro @@ -44,23 +44,23 @@ odb_ = 0; r = empty_request("ODB_DB"); - //set_value(r,"PATH","%s",p); + // set_value(r,"PATH","%s",p); set_value(r, "PATH", "%s", FullPathName(p).c_str()); set_value(r, "TEMPORARY", "%d", temp); if (r) { const char* path = get_value(r, "PATH", 0); - odb_ = MvOdbFactory::make(path); + odb_ = MvOdbFactory::make(path); } } /*COdb::COdb(const char *p,int temp) : InPool(tgeopts) { - odb_=0; - r = empty_request("ODB_DB"); - //set_value(r,"PATH","%s",p); - set_value(r,"PATH","%s",FullPathName(p).c_str()); - set_value(r,"TEMPORARY","%d",temp); + odb_=0; + r = empty_request("ODB_DB"); + //set_value(r,"PATH","%s",p); + set_value(r,"PATH","%s",FullPathName(p).c_str()); + set_value(r,"TEMPORARY","%d",temp); }*/ @@ -81,10 +81,10 @@ if (r) { const char* path = get_value(r, "PATH", 0); - odb_ = MvOdbFactory::make(path); + odb_ = MvOdbFactory::make(path); } - //else - // is probably a geopoints structure in memory, or with zero count! + // else + // is probably a geopoints structure in memory, or with zero count! } void COdb::unload(void) @@ -92,16 +92,16 @@ // if( gpts.count() > 0 || (r == nullptr)) // { /* if(r == nullptr) - { - char* path = marstmp(); - gpts.write( path ); - - r = empty_request("GEOPOINTS"); - set_value(r,"TEMPORARY","1"); - set_value(r,"PATH","%s",path); - } + { + char* path = marstmp(); + gpts.write( path ); + + r = empty_request("GEOPOINTS"); + set_value(r,"TEMPORARY","1"); + set_value(r,"PATH","%s",path); + } - gpts.unload(); + gpts.unload(); // }*/ if (odb_) { @@ -118,16 +118,16 @@ /*CGeopts::CGeopts(long count) : InPool(tgeopts) { - r = nullptr; - gpts.newReservedSize (count); + r = nullptr; + gpts.newReservedSize (count); }*/ /*CGeopts::CGeopts(CGeopts *p) : InPool(tgeopts) { - r = nullptr; - p->load(); - gpts = p->gpts; + r = nullptr; + p->load(); + gpts = p->gpts; }*/ @@ -142,7 +142,7 @@ } } } - //if(count) delete[] pts; + // if(count) delete[] pts; free_all_requests(r); if (odb_) @@ -168,7 +168,7 @@ { COdb* g; arg[0].GetValue(g); - //g->load(); + // g->load(); return Value(g->Count()); } @@ -203,7 +203,7 @@ arg[1].GetValue(cval); std::string columnName(cval); - //codb->load(); + // codb->load(); MvAbstractOdb* odb = codb->odb(); @@ -224,14 +224,14 @@ if (col->type() == MvOdbColumn::Float || col->type() == MvOdbColumn::Bitfield) { auto* v = new CVector(col->rowNum()); // vectors can only hold numbers - c = v; + c = v; for (int i = 0; i < col->rowNum(); i++) { v->setIndexedValue(i, col->floatData().at(i)); } } if (col->type() == MvOdbColumn::Int) { auto* v = new CVector(col->rowNum()); // vectors can only hold numbers - c = v; + c = v; for (int i = 0; i < col->rowNum(); i++) { v->setIndexedValue(i, col->intData().at(i)); } @@ -239,14 +239,14 @@ else if (col->type() == MvOdbColumn::String) { auto* v = new CList(col->rowNum()); // we need a list to hold strings - c = v; + c = v; for (int i = 0; i < col->rowNum(); i++) { (*v)[i] = col->stringData().at(i).c_str(); } } else if (col->type() == MvOdbColumn::Double) { auto* v = new CVector(col->rowNum()); // vectors can only hold numbers - c = v; + c = v; for (int i = 0; i < col->rowNum(); i++) { v->setIndexedValue(i, col->doubleData().at(i)); } @@ -285,8 +285,8 @@ return Value(); Content* c = 0; - auto* v = new CList(colNum); - c = v; + auto* v = new CList(colNum); + c = v; for (int i = 0; i < colNum; i++) { (*v)[i] = odb->columns()[i]->name().c_str(); diff -Nru metview-5.17.4/metview/src/Macro/code.cc metview-5.19.2/metview/src/Macro/code.cc --- metview-5.17.4/metview/src/Macro/code.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/code.cc 2023-07-15 08:28:47.000000000 +0000 @@ -94,7 +94,7 @@ v.GetValue(list); if (list->Count()) { bool all_pass = true; - int count = list->Count(); + int count = list->Count(); for (int i = 0; i < count; i++) { all_pass = all_pass && Pass((*list)[i]); // recursive call to test the element @@ -152,8 +152,8 @@ marslog(LOG_DBUG, "Param %s", Name); // Make sure argument masks global variables - //s->AddLocal(new Variable(Name,Value(0.0))); - //s->Store(Name,s->NextParameter(),0); + // s->AddLocal(new Variable(Name,Value(0.0))); + // s->Store(Name,s->NextParameter(),0); s->AddParameter(Name); return Next(); } @@ -329,7 +329,7 @@ } s->line = line + 1; - s->ref = opcode; + s->ref = opcode; Context::Current->AddStep(s); } diff -Nru metview-5.17.4/metview/src/Macro/compute.cc metview-5.19.2/metview/src/Macro/compute.cc --- metview-5.17.4/metview/src/Macro/compute.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/compute.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ // Get rid of quotes if (*buf == '"' || *buf == '\'') { - p = buf + 1; + p = buf + 1; buf[strlen(buf) - 1] = 0; } @@ -113,8 +113,8 @@ Script(name) { const char* form = get_value(r, "FORMULA", 0); - char* file = marstmp(); - FILE* f = fopen(file, "w"); + char* file = marstmp(); + FILE* f = fopen(file, "w"); if (!f) marslog(LOG_EROR | LOG_PERR, "Cannot open %s", file); else { diff -Nru metview-5.17.4/metview/src/Macro/context.cc metview-5.19.2/metview/src/Macro/context.cc --- metview-5.17.4/metview/src/Macro/context.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/context.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,28 +13,28 @@ #include "script.h" #include -boolean Context::stop = false; -int Context::trace = 0; -int Context::waitmode = 0; -int Context::sendlines = 0; -int Context::pause = 0; -int Context::baseIndex = 1; // Macro uses 1-based indexing, Python uses 0 +boolean Context::stop = false; +int Context::trace = 0; +int Context::waitmode = 0; +int Context::sendlines = 0; +int Context::pause = 0; +int Context::baseIndex = 1; // Macro uses 1-based indexing, Python uses 0 const char* Context::baseLanguage = "macro"; -Context* Context::Current = 0; -Step* Context::Instruction = 0; -Linkage* Linkage::Links = 0; -const char* Context::InitGlobals = strcache(".init_globals"); -const int UN_BUFSIZ = 300; +Context* Context::Current = 0; +Step* Context::Instruction = 0; +Linkage* Linkage::Links = 0; +const char* Context::InitGlobals = strcache(".init_globals"); +const int UN_BUFSIZ = 300; const char* Context::UniqueName(void) { static char buf[UN_BUFSIZ]; static int n = 0; - Context* c = Current; + Context* c = Current; while (c && c->Owner()) c = c->Owner(); const char* name = (c && c->Name()) ? c->Name() : "?macro?"; - int cnt = sprintf(buf, "/Process@%d/%s, line %d:%d", getpid(), name, + int cnt = sprintf(buf, "/Process@%d/%s, line %d:%d", getpid(), name, Instruction ? Instruction->line : 0, n++); if (cnt >= UN_BUFSIZ) marslog(LOG_EXIT, "Buffer overflow in Context::UniqueName()"); @@ -106,7 +106,7 @@ } Context* savedContext = Current; // save the previous context - Current = this; // ????? + Current = this; // ????? SetError(0); @@ -163,7 +163,7 @@ bool foundName = false; // these functions will set to true if the name is valid, even if args are not - Function* v = FindMethod(name, foundName, arity, arg, GetObject()); + Function* v = FindMethod(name, foundName, arity, arg, GetObject()); if (!method) { if (v == 0) @@ -289,7 +289,7 @@ Value Context::ImportVariable(const char* name) { Context* c = this; - auto* v = (Variable*)Locals.Find(name); + auto* v = (Variable*)Locals.Find(name); if (v) { Error( @@ -499,11 +499,11 @@ Node(name), oo(o) { - error = 0; - argc = 0; - argv = 0; - argn = 0; - Macro = 0; + error = 0; + argc = 0; + argv = 0; + argn = 0; + Macro = 0; inited = 0; object = 0; diff -Nru metview-5.17.4/metview/src/Macro/date.cc metview-5.19.2/metview/src/Macro/date.cc --- metview-5.17.4/metview/src/Macro/date.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/date.cc 2023-07-15 08:28:47.000000000 +0000 @@ -142,7 +142,7 @@ const char* Date::MonthName(int n, boolean full) { - request* p = pref(); + request* p = pref(); const char* s = get_value(p, full ? "MONTH_LONG_NAMES" : "MONTH_SHORT_NAMES", n - 1); return s ? s : _mvmonth[n - 1][int(full)]; @@ -150,21 +150,21 @@ const char* Date::DayName(int n, boolean full) { - request* p = pref(); + request* p = pref(); const char* s = get_value(p, full ? "DAY_LONG_NAMES" : "DAY_SHORT_NAMES", n - 1); return s ? s : _mvday[n - 1][int(full)]; } const char* Date::StringFormat(void) { - request* p = pref(); + request* p = pref(); const char* s = no_quotes(get_value(p, "STRING_DATE_FORMAT", 0)); return s ? s : stringFormat; } const char* Date::NumberFormat(void) { - request* p = pref(); + request* p = pref(); const char* s = no_quotes(get_value(p, "NUMBER_DATE_FORMAT", 0)); return s ? s : numberFormat; } @@ -179,7 +179,7 @@ Date::Date(double n) { - julian = (long)n; + julian = (long)n; double s = n - (double)julian; if (s < 0.0) { //-- 'n' is a negative decimal value; decimal part thus @@ -328,7 +328,7 @@ void Date::Format(const char* f, char* buf) { - int i = 0; + int i = 0; char c = 0; for (;;) { diff -Nru metview-5.17.4/metview/src/Macro/debug.cc metview-5.19.2/metview/src/Macro/debug.cc --- metview-5.17.4/metview/src/Macro/debug.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/debug.cc 2023-07-15 08:28:47.000000000 +0000 @@ -260,7 +260,7 @@ Value MemFunction::Execute(int, Value*) { #ifdef COMPILE_MEMORY_FUNCTION - static long last = 0; + static long last = 0; struct mallinfo minfo = mallinfo(); long used = minfo.uordblks + minfo.usmblks; diff -Nru metview-5.17.4/metview/src/Macro/extern.cc metview-5.19.2/metview/src/Macro/extern.cc --- metview-5.17.4/metview/src/Macro/extern.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/extern.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,8 +14,8 @@ ExternFunction::ExternFunction(const char* nam, Context* s) : UserFunction(nam, s) { - cmd = nullptr; - file = nullptr; + cmd = nullptr; + file = nullptr; compiled = 0; } @@ -77,7 +77,7 @@ free_all_requests(r); const char* FortranDbg = getenv("MACRO_FORTRAN_DBG"); - int n = -1; + int n = -1; if (FortranDbg) { marslog(LOG_INFO, "MACRO_FORTRAN_DBG is set to %s", FortranDbg); @@ -144,7 +144,7 @@ char* newcmd = marstmp(); const char* mvVersion = getenv("METVIEW_VERSION"); - const char* mvDir = getenv("METVIEW_DIR"); + const char* mvDir = getenv("METVIEW_DIR"); sprintf(buf, "env METVIEW_VVERSION=%s METVIEW_DDIR=%s $METVIEW_BIN/compile %s \"%s\" %s %s 2>&1", diff -Nru metview-5.17.4/metview/src/Macro/files.cc metview-5.19.2/metview/src/Macro/files.cc --- metview-5.17.4/metview/src/Macro/files.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/files.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,9 +35,9 @@ using closeproc = int (*)(FILE*); char* name; - int rmode; // read mode - FILE* f; - closeproc closef; + int rmode{1}; // read mode + FILE* f{nullptr}; + closeproc closef{nullptr}; virtual void ToFile(CFile*& x) { x = this; } @@ -47,9 +47,7 @@ CFile(const char* n) : Content(tfile) { - f = nullptr; - name = strcache(n); - rmode = 1; + name = strcache(n); } ~CFile(); @@ -81,11 +79,11 @@ if (f == nullptr) { if (*name == '|') { - f = popen(name + 1, m); + f = popen(name + 1, m); closef = pclose; } else { - f = fopen(name, m); + f = fopen(name, m); closef = fclose; } if (f == nullptr) @@ -161,7 +159,7 @@ for (int i = 1; i < arity; i++) { arg[i].Sync(); // This will force sync - //Flextra related part + // Flextra related part if (arg[i].GetType() == trequest) { request* r; arg[i].GetValue(r); @@ -181,7 +179,7 @@ break; } - //Any other type + // Any other type else if ((e = arg[i].Write(f))) break; } @@ -237,7 +235,7 @@ for (int i = 1; i < arity; i++) { arg[i].Sync(); // This will force sync - //Flextra related part + // Flextra related part if (arg[i].GetType() == trequest) { request* r; arg[i].GetValue(r); @@ -405,7 +403,7 @@ request* r = empty_request("FLEXTRA_FILE"); if (p) { - //TODO: figure out if handling relative paths like this still makes any sense + // TODO: figure out if handling relative paths like this still makes any sense std::string pStr(p); if (pStr.length() > 0 && pStr[0] != '/') { const char* pwd = getenv("PWD"); @@ -474,7 +472,7 @@ return Value(); // get the definition&rules filenames - std::string sdef = (const char*)mbasename(get_value(req_obj, "definition_file", 0)); + std::string sdef = (const char*)mbasename(get_value(req_obj, "definition_file", 0)); std::string srules = (const char*)mbasename(get_value(req_obj, "rules_file", 0)); if (sdef.empty() || srules.empty()) return Value(); diff -Nru metview-5.17.4/metview/src/Macro/function.cc metview-5.19.2/metview/src/Macro/function.cc --- metview-5.17.4/metview/src/Macro/function.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/function.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,9 @@ Function::Function(const char* n, int arity, ...) : Node(n) { - info = 0; + info = 0; types = 0; - cnt = arity; + cnt = arity; if (cnt > 0) { va_list list; diff -Nru metview-5.17.4/metview/src/Macro/grib.cc metview-5.19.2/metview/src/Macro/grib.cc --- metview-5.17.4/metview/src/Macro/grib.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/grib.cc 2023-07-15 08:28:47.000000000 +0000 @@ -72,8 +72,7 @@ 0, 0, 0, - 0 -}; + 0}; static const char* parameterKey = "paramId"; @@ -85,9 +84,9 @@ request* s = empty_request(0); for (int i = 0; i < fs->count; i++) { - field* g = get_field(fs, i, packed_mem); + field* g = get_field(fs, i, packed_mem); request* r = empty_request(0); - //grib_to_request(r,g->buffer,g->length); + // grib_to_request(r,g->buffer,g->length); /*int e = */ handle_to_request(r, g->handle, nullptr); release_field(g); #if 0 @@ -133,9 +132,9 @@ // -- Sec0 is 8 octets + Sec1 6th octet = 14th octet from the start // request *r = empty_request((g->ksec1[2] != mars.computeflg) - //request *r = empty_request((g->buffer[13] != mars.computeflg) + // request *r = empty_request((g->buffer[13] != mars.computeflg) // ? "GRIB" : "COMPUTED"); - //grib_to_request(r,g->buffer,g->length); + // grib_to_request(r,g->buffer,g->length); request* r = empty_request("GRIB"); //-- simplified gribapi port /*int e = */ handle_to_request(r, g->handle, nullptr); @@ -249,7 +248,7 @@ static inline void SetFieldElementToMissingValue(field* f, int i) { f->values[i] = mars.grib_missing_value; - f->bitmap = true; + f->bitmap = true; } /* End of function "SetFieldElementToMissingValue" */ @@ -299,7 +298,8 @@ field_state oriState_{unknown}; }; -AtLeastPackedMemExpander::AtLeastPackedMemExpander(field* f) : field_(f) +AtLeastPackedMemExpander::AtLeastPackedMemExpander(field* f) : + field_(f) { if (field_) { oriState_ = field_->shape; @@ -346,7 +346,7 @@ virtual int ValidArguments(int arity, Value* arg); private: - eGribIndexType indexType_; + eGribIndexType indexType_{GINDEX_NUMBERS}; }; int SubGribFunction::ValidArguments(int arity, Value* arg) @@ -402,8 +402,8 @@ if (arity > 3) arg[3].GetValue(step); - int baseIndex = Context::BaseIndex(); // = 1(Macro) or 0(Python) - int indexOffset = 1 - baseIndex; // = 0(Macro) or 1(Python) + int baseIndex = Context::BaseIndex(); // = 1(Macro) or 0(Python) + int indexOffset = 1 - baseIndex; // = 0(Macro) or 1(Python) if (from < 1 || from > v->count) return Error("Fieldset index must be from %d to %d. %d was supplied and is out of range.", baseIndex, v->count - indexOffset, from - indexOffset); @@ -434,7 +434,7 @@ if (index < 1 || index > v->count) return Error("index %d(%d) is out of range. Fieldset size is %d", i + 1, index, v->count); - field* g = v->fields[index - 1]; + field* g = v->fields[index - 1]; w->fields[i] = g; g->refcnt++; } @@ -467,9 +467,9 @@ Value MergeGribFunction::Execute(int arity, Value* arg) { - int cnt = arity; + int cnt = arity; bool anyFromFilter = false; - fieldset* w = nullptr; + fieldset* w = nullptr; fieldset* z; while (cnt--) { CGrib* v; @@ -510,15 +510,16 @@ // Base class for functions taking a fieldset as the first argument and performing gridpoint based // computations using the lat/lon coordinates of a given gridpoint only. Computations where the // grid geometry is also needed (e.g. gradient) do not belong to this category. -class GeoLocationBasedFunction: public Function +class GeoLocationBasedFunction : public Function { public: - GeoLocationBasedFunction(const char* n) : Function(n) {} + GeoLocationBasedFunction(const char* n) : + Function(n) {} Value Execute(int arity, Value* arg) override; protected: - virtual void extractArguments(int arity, Value* arg)=0; - virtual bool compute(MvGridPtr)=0; + virtual void extractArguments(int arity, Value* arg) = 0; + virtual bool compute(MvGridPtr) = 0; virtual void updateResult(field*); }; @@ -527,8 +528,8 @@ metview::MarsComputeFlagDisabler mflagDisabler; // the first argument is always a fieldset - assert(arity >=1); - fieldset* v= nullptr; + assert(arity >= 1); + fieldset* v = nullptr; arg[0].GetValue(v); assert(v); @@ -554,7 +555,7 @@ // create the resulting field and save it auto fRes = copy_field(v->fields[i], true); - fRes->bitmap = (hasMissing)?1:0; + fRes->bitmap = (hasMissing) ? 1 : 0; assert(fRes->shape == expand_mem); updateResult(fRes); @@ -566,8 +567,8 @@ } return Value(result); - - } catch (MvException &e) { + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } @@ -576,8 +577,8 @@ void GeoLocationBasedFunction::updateResult(field* fld) { - // mark fields as derived - MvGridBase::setLong(fld, "generatingProcessIdentifier", 254); + // mark fields as derived + MvGridBase::setLong(fld, "generatingProcessIdentifier", 254); } //============================================================================= @@ -773,9 +774,9 @@ void MaskFunction::extractArguments(int arity, Value* arg) { - assert(arity>=1); + assert(arity >= 1); - double d[4]; //n,w,s,e + double d[4]; // n,w,s,e arity = adjustedArity_; if (!incorrectOption_.empty()) { @@ -785,26 +786,28 @@ if (arity < 4) { getListArgAsArrayOfNumbers(arg, 1, 4, &d[0]); - } else { + } + else { getNumberArgsAsArrayOfNumbers(arg, 1, 4, d); } - double n = d[0], w = d[1], s=d[2], e=d[3]; + double n = d[0], w = d[1], s = d[2], e = d[3]; while (w > e) { w -= 360.0; } - geoArea_ = MvGeoBox(n,w,s,e); + geoArea_ = MvGeoBox(n, w, s, e); } bool MaskFunction::compute(MvGridPtr grd) { - bool hasMissing=false; + bool hasMissing = false; do { if (setMissing_) { if (!geoArea_.isInside(grd->lat_y(), grd->lon_x())) { grd->value(mars.grib_missing_value); hasMissing = true; } - } else { + } + else { grd->value(geoArea_.isInside(grd->lat_y(), grd->lon_x())); } } while (grd->advance()); @@ -829,8 +832,8 @@ bool setMissing_{false}; int adjustedArity_{0}; std::string incorrectOption_; - MvLocationHub centre_; //mask center, lat/lon - double cosOfRadius_{1.}; // cosine of the angular distance representing the radius + MvLocationHub centre_; // mask center, lat/lon + double cosOfRadius_{1.}; // cosine of the angular distance representing the radius }; int RMaskFunction::ValidArguments(int arity, Value* arg) @@ -886,7 +889,8 @@ double d[3]; if (arity < 4) { getListArgAsArrayOfNumbers(arg, 1, 3, &d[0]); //-- extract 3 numeric values from a list - } else { + } + else { getNumberArgsAsArrayOfNumbers(arg, 1, 3, d); } @@ -904,13 +908,14 @@ double dst = centre_.cosOfDistance(grd->lat_y(), grd->lon_x()); // cosine is monotone descreasing in [0, pi]!.So the larger the value // the smaller the distance! - bool outside = (dst < cosOfRadius_); + bool outside = (dst < cosOfRadius_); if (setMissing_) { if (outside) { grd->value(mars.grib_missing_value); hasMissing = true; } - } else { + } + else { grd->value(outside ? 0.0 : 1.0); } } while (grd->advance()); @@ -975,7 +980,7 @@ do { eckit::geometry::Point2 p(grd->lon_x(), grd->lat_y()); bool inside = false; - for (auto const& poly: polygons_) { + for (auto const& poly : polygons_) { if (poly.contains(p)) { inside = true; break; @@ -1103,7 +1108,7 @@ int GridBearingFunction::ValidArguments(int arity, Value* arg) { - CList* l=nullptr; + CList* l = nullptr; switch (arity) { case 3: //-- bearing( fieldset, lat, lon ) { @@ -1148,7 +1153,8 @@ double d[2]; if (arity == 2) { getListArgAsArrayOfNumbers(arg, 1, 2, &d[0]); - } else { + } + else { getNumberArgsAsArrayOfNumbers(arg, 1, 2, d); } @@ -1167,8 +1173,8 @@ bool hasMissing = false; do { double bearing = 0.; - double lon = grd->lon_x(); - double lat = grd->lat_y(); + double lon = grd->lon_x(); + double lat = grd->lat_y(); const double eps = 1E-9; if (lon > 180.) { @@ -1176,26 +1182,26 @@ } double d_lon = MvSci::degToRad(lon - lonRef_); - //the bearing is constant on the same latitude + // the bearing is constant on the same latitude if (fabs(lat - latRef_) < eps) { - //same location + // same location if (fabs(lon - lonRef_) < eps) { grd->value(mars.grib_missing_value); hasMissing = true; } else { - bearing = (d_lon <= 0.)?270.:90.; + bearing = (d_lon <= 0.) ? 270. : 90.; grd->value(bearing); } } else { lat = MvSci::degToRad(lat); - //bearing in degrees, x axis points to East, anti-clockwise + // bearing in degrees, x axis points to East, anti-clockwise bearing = atan2(cosLatRef * sin(lat) - sinLatRef * cos(lat) * cos(d_lon), sin(d_lon) * cosLatRef); - //transforms to the required coordinate system: x axis points to North, clockwise + // transforms to the required coordinate system: x axis points to North, clockwise bearing = M_PI_2 - bearing; if (bearing < 0) { bearing += 2.0 * M_PI; @@ -1222,7 +1228,7 @@ Value DistributionFunction::Execute(int, Value* arg) { - //nontested_eccodes_port("DistributionFunction::Execute"); + // nontested_eccodes_port("DistributionFunction::Execute"); #if 0 fieldset *v; @@ -1311,15 +1317,15 @@ int err = 0; for (int i = 0; i < z->count; i++) { // Ensemble distribution - //f[i]->ksec1[39-1] = 23; + // f[i]->ksec1[39-1] = 23; grib_set_long(f[i]->handle, "mars.type", 23); // Number - //f[i]->ksec1[42-1] = i + 1; - //err = grib_set_long( f[i]->handle, "mars.number", i+1 ); + // f[i]->ksec1[42-1] = i + 1; + // err = grib_set_long( f[i]->handle, "mars.number", i+1 ); grib_set_long(f[i]->handle, "perturbationNumber", i + 1); } - //mars.accuracy = f[0]->ksec4[1]; + // mars.accuracy = f[0]->ksec4[1]; long acc0; // err = grib_get_long( f[0]->handle, "setDecimalPrecision", &acc0 ); err = grib_get_long(f[0]->handle, "numberOfBitsContainingEachPackedValue", &acc0); @@ -1376,25 +1382,25 @@ switch (type) { case GRIB_LONG: { long n = MvGridBase::getLong(fld, key, true, true); - value = n; + value = n; break; } case GRIB_DOUBLE: { double r = MvGridBase::getDouble(fld, key, true, true); - value = r; + value = r; break; } case GRIB_STRING: { std::string str = MvGridBase::getString(fld, key, true, true); - value = str.c_str(); + value = str.c_str(); break; } case GRIB_LONG_ARRAY: { - long* lvals = nullptr; - long num_vals = MvGridBase::getLongArray(fld, key, &lvals, true, true); + long* lvals = nullptr; + long num_vals = MvGridBase::getLongArray(fld, key, &lvals, true, true); if ((lvals != nullptr) && (num_vals > 0)) { auto* v = new CVector(num_vals); @@ -1410,7 +1416,7 @@ case GRIB_DOUBLE_ARRAY: { double* dvals = nullptr; - long num_vals = MvGridBase::getDoubleArray(fld, key, &dvals, true, true); + long num_vals = MvGridBase::getDoubleArray(fld, key, &dvals, true, true); if ((dvals != nullptr) && (num_vals > 0)) { auto* v = new CVector(num_vals); for (int j = 0; j < num_vals; j++) { @@ -1438,7 +1444,7 @@ Value GribHeaderFunctionR::Execute(int, Value* arg) { - fieldset* fs=nullptr; + fieldset* fs = nullptr; const char* key; arg[0].GetValue(fs); // get the fieldset variable @@ -1449,11 +1455,11 @@ for (int i = 0; i < fs->count; i++) { // the input field has to be in packed_mem state at least AtLeastPackedMemExpander fx(fs->fields[i]); - Value value = GetGribHeaderValue(fs->fields[i], key, type); + Value value = GetGribHeaderValue(fs->fields[i], key, type); (*l)[i] = value; } - return (l->Count() > 1)?Value(l):Value((*l)[0]); + return (l->Count() > 1) ? Value(l) : Value((*l)[0]); } @@ -1523,7 +1529,7 @@ } CList* fieldValues = nullptr; - CList* keyValues = nullptr; + CList* keyValues = nullptr; if (grouping == GROUP_BY_FIELD) fieldValues = new CList(fs->count); // top-level list is the fields @@ -1541,7 +1547,7 @@ for (int k = 0; k < keys->Count(); k++) { eGribHeaderType dataType = GRIB_STRING; // default type - char typeString[5] = ""; + char typeString[5] = ""; const char* origKey; char* key; (*keys)[k].GetValue(origKey); @@ -1550,7 +1556,7 @@ if (grouping == GROUP_BY_KEY) { if (i == 0) // first field, group-by-key { - fieldValues = new CList(fs->count); + fieldValues = new CList(fs->count); (*keyValues)[k] = fieldValues; } else { @@ -1616,7 +1622,7 @@ } // for each field - return (grouping == GROUP_BY_FIELD)?fieldValues:keyValues; + return (grouping == GROUP_BY_FIELD) ? fieldValues : keyValues; } @@ -1665,8 +1671,8 @@ Value GribHeaderFunctionW::Execute(int arity, Value* arg) { - fieldset* v=nullptr; - CList* l=nullptr; + fieldset* v = nullptr; + CList* l = nullptr; assert(arity >= 2); arity = adjustedArity_; @@ -1682,16 +1688,16 @@ return Error("%s: the list does not contain an even number of values", Name()); } - int save = mars.computeflg; + int save = mars.computeflg; mars.computeflg = 0; - int acc = mars.accuracy; + int acc = mars.accuracy; // create the resulting fieldset with empty fields fieldset* result = new_fieldset(v->count); // for each field, apply the changes for (int i = 0; i < v->count; i++) { - field * fRes = nullptr; + field* fRes = nullptr; { // the input field has to be in packed_mem state at least AtLeastPackedMemExpander fx(v->fields[i]); @@ -1743,6 +1749,24 @@ } break; } + + case GRIB_LONG_ARRAY: { + for (int j = 0; j < l->Count(); j += 2) { + CVector *value; + const char* key; + (*l)[j].GetValue(key); + (*l)[j + 1].GetValue(value); + int num_vals = value->Count(); + long *vals_array = new long[num_vals]; + for (int j = 0; j < num_vals; j++) { + vals_array[j] = static_cast(value->getIndexedValue(j)); + } + MvGridBase::setLongArray(fRes, key, vals_array, num_vals); + delete [] vals_array; + } + break; + } + default: return Error("GribHeaderFunctionW: bad key type (%d)", type); } @@ -1756,7 +1780,7 @@ Value x(result); mars.computeflg = save; - mars.accuracy = acc; + mars.accuracy = acc; return x; } @@ -1802,8 +1826,8 @@ Value GribHeaderFunctionWGeneric::Execute(int arity, Value* arg) { - fieldset* v=nullptr; - CList* l=nullptr; + fieldset* v = nullptr; + CList* l = nullptr; assert(arity >= 2); arity = adjustedArity_; @@ -1819,16 +1843,16 @@ return Error("%s: the list does not contain an even number of values", Name()); } - int save = mars.computeflg; + int save = mars.computeflg; mars.computeflg = 0; - int acc = mars.accuracy; + int acc = mars.accuracy; // create the resulting fieldset with empty fields fieldset* result = new_fieldset(v->count); // for each field, apply the changes for (int i = 0; i < v->count; i++) { - field * fRes = nullptr; + field* fRes = nullptr; { AtLeastPackedMemExpander fx(v->fields[i]); // create the resulting fieldset with empty fields @@ -1847,7 +1871,7 @@ // for each key/value pair, set them in the field for (int j = 0; j < l->Count(); j += 2) { - const char* key=nullptr; + const char* key = nullptr; vtype valueType; (*l)[j].GetValue(key); @@ -1868,7 +1892,7 @@ // try to figure out if it's an integer (long) or double double epsilon = 0.000000001; // a bit arbitrary - long numAsInt = (long)(value + epsilon); + long numAsInt = (long)(value + epsilon); if (fabs(numAsInt - value) < epsilon) { // close enough - set as integer MvGridBase::setLong(fRes, key, numAsInt); @@ -1894,7 +1918,7 @@ Value x(result); mars.computeflg = save; - mars.accuracy = acc; + mars.accuracy = acc; return x; } @@ -1920,8 +1944,8 @@ fieldset* z = copy_fieldset(v, 1, false); - field* h = get_field(z, 0, expand_mem); - field* g = get_field(v, 0, expand_mem); + field* h = get_field(z, 0, expand_mem); + field* g = get_field(v, 0, expand_mem); for (size_t j = 0; j < g->value_count; j++) @@ -1936,8 +1960,8 @@ field* g = get_field(v, i, expand_mem); /* For performance, we have two versions of these comparison loops - - one that considers missing values (only called if there are any) - and one that does not (called if there are none). */ + one that considers missing values (only called if there are any) + and one that does not (called if there are none). */ if (min) // Get the minimum { @@ -2015,9 +2039,9 @@ l = new CList(v->count); for (int i = 0; i < v->count; i++) { - field* g = get_field(v, i, packed_mem); + field* g = get_field(v, i, packed_mem); request* r = empty_request(0); - //grib_to_request(r,g->buffer,g->length); + // grib_to_request(r,g->buffer,g->length); /*int e = */ handle_to_request(r, g->handle, nullptr); release_field(g); @@ -2049,6 +2073,8 @@ } virtual Value Execute(int arity, Value* arg); virtual int ValidArguments(int arity, Value* arg); + +protected: static void sort(char*, request**, int*, int, char*); static char** extract(Value&, int&); static char** up(int, const char* = "<"); @@ -2066,7 +2092,7 @@ int i = 0; while (i < count - 1) { - request* r1 = reqs[indix[i]]; + request* r1 = reqs[indix[i]]; const char* p1 = get_value(r1, parm, 0); if (p1 == 0) p1 = ""; @@ -2074,7 +2100,7 @@ int j = i; do { j++; - request* r2 = reqs[indix[j]]; + request* r2 = reqs[indix[j]]; const char* p2 = get_value(r2, parm, 0); if (p2 == 0) p2 = ""; @@ -2121,7 +2147,7 @@ n = 1; chrp* p = new chrp[n]; - p[0] = _up(s); + p[0] = _up(s); return p; } @@ -2150,11 +2176,12 @@ int SortGribFunction::ValidArguments(int arity, Value* arg) { - if (arity < 1 || arity > 3) + if (arity < 1 || arity > 3) { return false; - if (arg[0].GetType() != tgrib) + } + if (arg[0].GetType() != tgrib) { return false; - + } if (arity > 1) { if (arg[1].GetType() != tstring && arg[1].GetType() != tlist) return false; @@ -2166,13 +2193,14 @@ if (arg[1].GetType() == tstring) return false; - CList *l1, *l2; + CList *l1 = nullptr, *l2 = nullptr; arg[1].GetValue(l1); arg[2].GetValue(l2); - if (l2->Count() != 1 && l2->Count() != l1->Count()) + if (l2->Count() != 1 && l2->Count() != l1->Count()) { return false; + } } } } @@ -2190,30 +2218,29 @@ (char*)"PARAM", }; - Value SortGribFunction::Execute(int arity, Value* arg) { - fieldset *v, *w; - + fieldset* v = nullptr; arg[0].GetValue(v); - w = copy_fieldset(v, v->count, true); + + if (v == nullptr) { + return Error("%s: invalid input fieldset", Name()); + } auto** r = new reqp[v->count]; - auto* n = new int[v->count]; + auto* n = new int[v->count]; auto** g = new grbp[v->count]; - int i; - for (i = 0; i < w->count; i++) { - g[i] = get_field(w, i, packed_mem); + for (int i = 0; i < v->count; i++) { + g[i] = get_field(v, i, packed_mem); n[i] = i; r[i] = empty_request(0); - //grib_to_request(r[i],g[i]->buffer,g[i]->length); - /*int e = */ handle_to_request(r[i], g[i]->handle, nullptr); + handle_to_request(r[i], g[i]->handle, nullptr); release_field(g[i]); } - char** names; - char** order; + char** names = nullptr; + char** order = nullptr; int count = 0; switch (arity) { @@ -2231,47 +2258,60 @@ case 3: names = extract(arg[1], count); if (arg[2].GetType() == tstring) { - const char* p; + const char* p = nullptr; arg[2].GetValue(p); order = up(count, p); } - else + else { order = extract(arg[2], count); + } break; default: delete[] r; delete[] n; delete[] g; - return Value(); + return Error("%s: invalid sort parameters", Name()); } - i = count; - while (--i >= 0) - sort(names[i], r, n, v->count, order[i]); + int pos = count; + while (--pos >= 0) { + sort(names[pos], r, n, v->count, order[pos]); + } - for (i = 0; i < v->count; i++) + for (int i = 0; i < v->count; i++) { free_all_requests(r[i]); + } - for (i = 0; i < w->count; i++) - w->fields[i] = g[n[i]]; + fieldset* result = new_fieldset(v->count); + for (int i = 0; i < v->count; i++) { + auto fOri = get_field(v, n[i], packed_mem); + auto fRes = copy_field(fOri, false); + set_field(result, fRes, i); + save_fieldset(result); + release_field(fOri); + assert(fOri->shape == packed_file); + assert(fRes->shape == packed_file); + } delete[] r; delete[] n; delete[] g; - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { strfree(order[i]); - if (arity != 1) + if (arity != 1) { strfree(names[i]); + } } + delete[] order; - if (arity != 1) + if (arity != 1) { delete[] names; + } - return Value(w); + return Value(result); } - //============================================================================= class LatLonTransformFunction : public GeoLocationBasedFunction @@ -2305,11 +2345,13 @@ do { if (!checkPole_) { grd->value(method_(MvSci::degToRad(grd->lat_y()))); - } else { + } + else { if (fabs(grd->lat_y()) > latLimit) { grd->value(mars.grib_missing_value); hasMissing = true; - } else { + } + else { grd->value(method_(MvSci::degToRad(grd->lat_y()))); } } @@ -2322,7 +2364,8 @@ { public: CosLatFunction(const char* n) : - LatLonTransformFunction(n, std::cos, false) { + LatLonTransformFunction(n, std::cos, false) + { info = "Generates a field with the cosine of the gridpoint latitudes"; } }; @@ -2331,7 +2374,8 @@ { public: SinLatFunction(const char* n) : - LatLonTransformFunction(n, std::sin, false) { + LatLonTransformFunction(n, std::sin, false) + { info = "Generates a field with the sine of the gridpoint latitudes"; } }; @@ -2340,7 +2384,8 @@ { public: TanLatFunction(const char* n) : - LatLonTransformFunction(n, std::tan, true) { + LatLonTransformFunction(n, std::tan, true) + { info = "Generates a field with the tangent of the gridpoint latitudes"; } }; @@ -2360,7 +2405,7 @@ protected: void extractArguments(int arity, Value* arg) override; bool compute(MvGridPtr grd) override; - void updateResult(field *) override; + void updateResult(field*) override; protected: bool toCosine_{false}; @@ -2387,7 +2432,7 @@ void SolarZenithAngleFunction::extractArguments(int arity, Value* /*arg*/) { - assert(arity>=1); + assert(arity >= 1); if (!incorrectOption_.empty()) { throw MvException("if supplied, the option parameter must be 'missing'; it is '" + incorrectOption_ + "'"); @@ -2396,7 +2441,7 @@ bool SolarZenithAngleFunction::compute(MvGridPtr grd) { - bool hasMissing=false; + bool hasMissing = false; // solar declination // TODO: what to do if dt is invalid? @@ -2411,7 +2456,8 @@ if (declInRad < -2 || fabs(hourAngleGM) > 180.001) { grd->setAllValuesToMissing(false); hasMissing = true; - } else { + } + else { do { if (!MISSING_VALUE(grd->value())) { auto rv = MvSci::cosineSolarZenithAngle(grd->lat_y(), grd->lon_x(), @@ -2424,15 +2470,15 @@ } } else { - grd->value(mars.grib_missing_value); - hasMissing = true; + grd->value(mars.grib_missing_value); + hasMissing = true; } } while (grd->advance()); } return hasMissing; } -void SolarZenithAngleFunction::updateResult(field *fld) +void SolarZenithAngleFunction::updateResult(field* fld) { if (toCosine_) { MvGridBase::setLong(fld, "paramId", 214001); @@ -2458,18 +2504,18 @@ protected: void extractArguments(int /*arity*/, Value* /*arg*/) override {} bool compute(MvGridPtr grd) override; - void updateResult(field *) override; + void updateResult(field*) override; }; int AbsVortFunction::ValidArguments(int arity, Value* arg) { - return (arity == 1 && arg[0].GetType() == tgrib); + return (arity == 1 && arg[0].GetType() == tgrib); } bool AbsVortFunction::compute(MvGridPtr grd) { - bool hasMissing=false; - const double omega = 2.* 7.29211508E-5; + bool hasMissing = false; + const double omega = 2. * 7.29211508E-5; do { if (!MISSING_VALUE(grd->value())) { @@ -2484,7 +2530,7 @@ return hasMissing; } -void AbsVortFunction::updateResult(field *fld) +void AbsVortFunction::updateResult(field* fld) { // 3014 = "absv" MvGridBase::setLong(fld, "paramId", 3041); @@ -2513,13 +2559,13 @@ auto* l = new CList(fs->count); // initialise the resulting list for (int i = 0; i < fs->count; i++) { - field* h = GetIndexedFieldWithAtLeastPackedMem(fs, i); + field* h = GetIndexedFieldWithAtLeastPackedMem(fs, i); auto* mvf = new MvField(h); std::vector v; if (mvf->mvGrid()) { mvf->mvGrid()->boundingBox(v); auto* vec4 = new CVector(v); - (*l)[i] = vec4; + (*l)[i] = vec4; } else { (*l)[i] = Value(); @@ -2579,7 +2625,7 @@ for (i = 0; i < fs->count; i++) // for each field... { field* g = get_field(fs, i, expand_mem); - auto* z = new CVector(g->value_count); + auto* z = new CVector(g->value_count); if (MISSING_VALUE(z->MissingValueIndicator())) // is the vector missing value the same as GRIB? { @@ -2684,9 +2730,9 @@ class SetGridValsFunction : public Function { - bool deprecated; + bool deprecated{false}; const char* newName; - bool option_given; // did the user supply a string option parameter? + bool option_given{false}; // did the user supply a string option parameter? public: SetGridValsFunction(const char* n, bool d, const char* nn = nullptr) : Function(n), @@ -2862,15 +2908,15 @@ auto* l = new CList(fs->count); // initialise the resulting list for (int i = 0; i < fs->count; i++) { - field* h = GetIndexedFieldWithAtLeastPackedMem(fs, i); - auto* mvfield = new MvField(h); - double baseDate = mvfield->yyyymmddFoh(); + // the input field has to be in packed_mem state at least + AtLeastPackedMemExpander fx(fs->fields[i]); + double baseDate = MvGridBase::yyyymmddFoh(fs->fields[i]); double dateAsNumber = baseDate; Date d(dateAsNumber); if (type == GDT_VALID) // valid_date requested? then add the step { - double stepFoh = mvfield->stepFoh(); - d = d + stepFoh; + double stepFoh = MvGridBase::stepFoh(fs->fields[i]); + d = d + stepFoh; } (*l)[i] = d; @@ -2923,7 +2969,7 @@ for (i = 0; i < v->count; i++) { field* g = get_field(v, i, expand_mem); - d = 0; + d = 0; nNumValidPoints = 0; for (size_t j = 0; j < g->value_count; j++) { @@ -2983,7 +3029,7 @@ fieldset* z = copy_fieldset(v, v->count, false); - int count = l->Count(); + int count = l->Count(); auto* values = new double[l->Count()]; int i; for (i = 0; i < count; i++) @@ -3034,7 +3080,7 @@ arg[1].GetValue(w); fieldset* z = copy_fieldset(v, v->count, false); - int count = w->count; + int count = w->count; int prev = -1; field* k = nullptr; @@ -3050,7 +3096,7 @@ } if (n != prev) { - k = get_field(w, n, expand_mem); + k = get_field(w, n, expand_mem); prev = n; if (j >= k->value_count) { return Error("lookup: fields mismatch"); @@ -3095,7 +3141,7 @@ A value lying between two values in the vector will use the index of the nearest value; if equidistant, then the higher value is used. - GRIB: 1, 3, 5, 5 + GRIB: 1, 3, 5, 5 2, 4, 5, 5 1, 0, 3, 1 @@ -3107,7 +3153,7 @@ class FindIndexesFunction : public Function { - bool option_given; // did the user supply a string option parameter? + bool option_given{false}; // did the user supply a string option parameter? public: FindIndexesFunction(const char* n) : @@ -3173,7 +3219,7 @@ for (size_t j = 0; j < f->value_count; j++) { int vindex; double result = v->Count() - 1; // if we don't find it, then choose the last value - double d = f->values[j]; + double d = f->values[j]; if (!MISSING_VALUE(d)) { // find this point's position in the vector @@ -3192,7 +3238,7 @@ // find the closest point - the current or the previous one double dvectorprev = v->getIndexedValue(vindex - 1); - double distPrev = d - dvectorprev; + double distPrev = d - dvectorprev; if (interpolate) { // result is previous index plus proportion of the way to the next one @@ -3356,8 +3402,8 @@ return Error("integrate: field and mask don't match"); double wght = 0; - double sum = 0; - int pcnt = 0; + double sum = 0; + int pcnt = 0; for (int j = 0; j < grd->length(); ++j) { int pointOk; @@ -3383,7 +3429,7 @@ if (wght) { double val = sum / wght; - returnVal = Value(val); + returnVal = Value(val); } else { returnVal = Value(); // nil @@ -3393,7 +3439,7 @@ if (v->count > 1) // multiple fields? add value to a list (*l)[i] = returnVal; - //std::cout << " integrated over " << pcnt << " points" << std::endl; + // std::cout << " integrated over " << pcnt << " points" << std::endl; } // end 'for each field' if (v->count > 1) @@ -3460,7 +3506,7 @@ MvGeoBox geoArea(n, w, s, e); - double val = DBL_MAX; + double val = DBL_MAX; boolean first_found = true; int pointOk; @@ -3474,7 +3520,7 @@ if (pointOk) { if (first_found) { - val = grd->value(); + val = grd->value(); first_found = false; } @@ -3618,7 +3664,7 @@ for (i = 0; i < v->count; i++) { #if NO_MVGRID - field* g = get_field(v, i, expand_mem); + field* g = get_field(v, i, expand_mem); gribsec2_ll* s2 = (gribsec2_ll*)&g->ksec2[0]; if (s2->data_rep != GRIB_LAT_LONG) @@ -3786,7 +3832,7 @@ CVector* vlon = nullptr; // if vector of coordinates CList* lvals; // if list of vectors of coordinates Value returnVal; - bool collectAll = false; + bool collectAll = false; vtype input_type = tnumber; @@ -4046,7 +4092,7 @@ for (j = 0; j < vlat->Count(); j++) { double vlatval = vlat->getIndexedValue(j); double vlonval = vlon->getIndexedValue(j); - gp = grd->nearestGridpoint(vlatval, vlonval, nearestValid); + gp = grd->nearestGridpoint(vlatval, vlonval, nearestValid); if (loc_info) { if (gp.value_ == DBL_MAX) // no grid point (e.g. out of sub-area) @@ -4258,7 +4304,7 @@ return Error("find: field and mask don't match"); auto** q = new CList*[grd->length()]; - int cnt = 0; + int cnt = 0; int j; for (j = 0; j < grd->length(); ++j) { @@ -4273,9 +4319,9 @@ if (b) { if (grd->value() >= min && grd->value() <= max) { - auto* z = new CList(2); - (*z)[0] = grd->lat_y(); - (*z)[1] = grd->lon_x(); + auto* z = new CList(2); + (*z)[0] = grd->lat_y(); + (*z)[1] = grd->lon_x(); q[cnt++] = z; } } @@ -4344,7 +4390,7 @@ Value GFindFunction::Execute(int arity, Value* arg) { char* path = marstmp(); - FILE* f = fopen(path, "w"); + FILE* f = fopen(path, "w"); if (!f) return Error("gfind: cannot open %s", path); @@ -4353,7 +4399,7 @@ fieldset* v; - double value = 0; + double value = 0; double epsilon = 0; @@ -4417,7 +4463,7 @@ int GeoOnMlFunction::ValidArguments(int arity, Value* arg) { if (arity == 4) { - for (int i=0; i < 4; i++) { + for (int i = 0; i < 4; i++) { if (arg[i].GetType() != tgrib) { return false; } @@ -4429,10 +4475,10 @@ Value GeoOnMlFunction::Execute(int /*arity*/, Value* arg) { - fieldset* t=nullptr; - fieldset* q=nullptr; - fieldset* lnsp=nullptr; - fieldset* zs=nullptr; + fieldset* t = nullptr; + fieldset* q = nullptr; + fieldset* lnsp = nullptr; + fieldset* zs = nullptr; arg[0].GetValue(t); arg[1].GetValue(q); @@ -4440,11 +4486,12 @@ arg[3].GetValue(zs); try { - return metview::geopotentialOnMl(t,q,lnsp, zs); -// metview::MlToPlInter inter = metview::MlToPlInter(fs, lnsp); -// inter.setTargetVc(pres); -// return Value(inter.compute()); - } catch (MvException& e) { + return metview::geopotentialOnMl(t, q, lnsp, zs); + // metview::MlToPlInter inter = metview::MlToPlInter(fs, lnsp); + // inter.setTargetVc(pres); + // return Value(inter.compute()); + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } return Value(); @@ -4469,7 +4516,7 @@ { if (arity == 3) { if (arg[0].GetType() == tgrib && arg[1].GetType() == tgrib && - (arg[2].GetType() == tlist || arg[2].GetType() == tvector)) { + (arg[2].GetType() == tlist || arg[2].GetType() == tvector)) { return true; } } @@ -4478,25 +4525,26 @@ Value MLToPLInterpolateFunction::Execute(int /*arity*/, Value* arg) { - fieldset* lnsp=nullptr; - fieldset* fs=nullptr; + fieldset* lnsp = nullptr; + fieldset* fs = nullptr; arg[0].GetValue(lnsp); arg[1].GetValue(fs); std::vector pres; - if(arg[2].GetType() == tlist) { - CList* l=nullptr; + if (arg[2].GetType() == tlist) { + CList* l = nullptr; arg[2].GetValue(l); - for (int i=0; i < l->Count(); i++) { + for (int i = 0; i < l->Count(); i++) { double v; (*l)[i].GetValue(v); pres.push_back(v); } - } else if (arg[2].GetType() == tvector) { - CVector* v=nullptr; + } + else if (arg[2].GetType() == tvector) { + CVector* v = nullptr; arg[2].GetValue(v); - for (int i=0; i < v->Count(); i++) { + for (int i = 0; i < v->Count(); i++) { pres.push_back((*v)[i]); } } @@ -4505,7 +4553,8 @@ metview::MlToPlInter inter = metview::MlToPlInter(fs, lnsp); inter.setTargetVc(pres); return Value(inter.compute()); - } catch (MvException& e) { + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } return Value(); @@ -4533,7 +4582,8 @@ const char* v; arg[4].GetValue(v); sea = (strcmp(v, "sea") == 0); - } else { + } + else { return false; } @@ -4567,12 +4617,11 @@ Value MLToHLInterpolateFunction::Execute(int arity, Value* arg) { - - fieldset* fs=nullptr; - fieldset* zFs=nullptr; - fieldset* zsFs=nullptr; - fieldset* hFs=nullptr; - fieldset* surfFs=nullptr; + fieldset* fs = nullptr; + fieldset* zFs = nullptr; + fieldset* zsFs = nullptr; + fieldset* hFs = nullptr; + fieldset* surfFs = nullptr; std::vector hVec; double surfVal = 0.; @@ -4581,14 +4630,14 @@ const char* chV; arg[4].GetValue(chV); - bool aboveSea = (strcmp(chV, "sea") == 0); + bool aboveSea = (strcmp(chV, "sea") == 0); arg[5].GetValue(chV); metview::VerticalInterpolation::VerticalInterpolationMethod interMode = - (strcmp(chV, "linear") == 0)?metview::VerticalInterpolation::LinearInterpolation:metview::VerticalInterpolation::LogInterpolation; + (strcmp(chV, "linear") == 0) ? metview::VerticalInterpolation::LinearInterpolation : metview::VerticalInterpolation::LogInterpolation; - if (!aboveSea){ + if (!aboveSea) { arg[2].GetValue(zsFs); } @@ -4597,34 +4646,39 @@ if (arg[3].GetType() == tgrib) { arg[3].GetValue(hFs); inter.setTargetVc(hFs); - } else if (arg[3].GetType() == tlist) { - CList* l=nullptr; + } + else if (arg[3].GetType() == tlist) { + CList* l = nullptr; arg[3].GetValue(l); - for (int i=0; i < l->Count(); i++) { + for (int i = 0; i < l->Count(); i++) { double v; (*l)[i].GetValue(v); hVec.push_back(v); } inter.setTargetVc(hVec); - } else { - return Error("%s: invalid h argument!", Name()); + } + else { + return Error("%s: invalid h argument!", Name()); } if (arity == 7) { if (arg[6].GetType() == tgrib) { arg[6].GetValue(surfFs); inter.setSurfaceValues(surfFs); - } else if (arg[6].GetType() == tnumber) { + } + else if (arg[6].GetType() == tnumber) { arg[6].GetValue(surfVal); inter.setSurfaceValues(surfVal); - } else { + } + else { return Error("%s: invalid fs_surf argument!", Name()); } } try { return Value(inter.compute()); - } catch (MvException& e) { + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } return Value(); @@ -4654,7 +4708,8 @@ if (strcmp(name, "linear") != 0 && strcmp(name, "log") != 0) { return false; } - } else { + } + else { return false; } } @@ -4668,24 +4723,25 @@ Value PLToPLInterpolateFunction::Execute(int arity, Value* arg) { - fieldset* fs=nullptr; + fieldset* fs = nullptr; arg[0].GetValue(fs); // target pressure values std::vector pres; - if(arg[1].GetType() == tlist) { - CList* l=nullptr; + if (arg[1].GetType() == tlist) { + CList* l = nullptr; arg[1].GetValue(l); - for (int i=0; i < l->Count(); i++) { + for (int i = 0; i < l->Count(); i++) { double v; (*l)[i].GetValue(v); pres.push_back(v); } - } else if (arg[1].GetType() == tvector) { - CVector* v=nullptr; + } + else if (arg[1].GetType() == tvector) { + CVector* v = nullptr; arg[1].GetValue(v); - for (int i=0; i < v->Count(); i++) { + for (int i = 0; i < v->Count(); i++) { pres.push_back((*v)[i]); } } @@ -4694,14 +4750,16 @@ if (arity == 3) { const char* chV; arg[2].GetValue(chV); - if (chV) { + if (chV) { if (strcmp(chV, "log") == 0) { interMode = VerticalInterpolation::LogInterpolation; - } else if(strcmp(chV, "linear") != 0) { + } + else if (strcmp(chV, "linear") != 0) { return Error("%s: invalid interpolation method=", Name(), chV); - } - } else { - return Error("%s: invalid interpolation method", Name()); + } + } + else { + return Error("%s: invalid interpolation method", Name()); } } @@ -4709,7 +4767,8 @@ auto inter = metview::PlToPlInter(fs, interMode); inter.setTargetVc(pres); return Value(inter.compute()); - } catch (MvException& e) { + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } return Value(); @@ -4757,9 +4816,9 @@ for (int i = 0; (i < v->count) && (n == -1); i++) { field* g = GetIndexedFieldWithAtLeastPackedMem(v, i); - //gribsec1 *s1 = (gribsec1*)&g->ksec1[0]; + // gribsec1 *s1 = (gribsec1*)&g->ksec1[0]; std::unique_ptr grd(MvGridFactory(g)); - //if(s1->parameter == 152) n = i; + // if(s1->parameter == 152) n = i; if (grd->getLong(parameterKey) == 152) n = i; release_field(g); @@ -4783,7 +4842,7 @@ MvField F_lnsp(lnsp); MvFieldExpander expa_lnsp(F_lnsp); - datarep = F_lnsp.dataRepres(); //s2->data_rep; + datarep = F_lnsp.dataRepres(); // s2->data_rep; if (datarep != GRIB_LAT_LONG && datarep != GRIB_GAUSSIAN) return Error("vertint: Field is not lat/long nor Gaussian!"); @@ -4794,7 +4853,7 @@ return Error("vertint: Field is not LNSP (152)"); fieldset* z = copy_fieldset(v, 1, false); //-- this releases lnsp memory (if same field) - field* h = get_field(z, 0, expand_mem); + field* h = get_field(z, 0, expand_mem); set_field_state(lnsp, expand_mem); //-- restore into memory (may have been released) set_field_state(h, expand_mem); @@ -4943,7 +5002,7 @@ } Value UniVertIntFunction::Execute(int /*arity*/, Value* arg) -{ +{ fieldset* dataFs; fieldset* lnspFs = 0; @@ -4956,7 +5015,8 @@ try { return Value(metview::verticalIntegral(dataFs, lnspFs, lnspId_, top_, bottom_)); - } catch (MvException& e) { + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } @@ -5032,15 +5092,15 @@ int i; switch (arg[1].GetType()) { case tnumber: - count = 1; + count = 1; levels = new int[1]; arg[1].GetValue(levels[0]); break; case tlist: { - CList* l; //this shadows int l above + CList* l; // this shadows int l above arg[1].GetValue(l); - count = l->Count(); + count = l->Count(); levels = new int[count]; for (i = 0; i < count; i++) (*l)[i].GetValue(levels[i]); @@ -5051,12 +5111,12 @@ fieldset* w; arg[1].GetValue(w); - count = w->count; + count = w->count; levels = new int[w->count]; for (i = 0; i < w->count; i++) { field* g = GetIndexedFieldWithAtLeastPackedMem(w, i); - auto* f = new MvField(g); + auto* f = new MvField(g); if (f->dataRepres() != GRIB_LAT_LONG) ++l; if (!f->isModelLevel()) @@ -5076,8 +5136,8 @@ for (int i = 0; i < v->count; i++) { - field* g = get_field(v, i, expand_mem); - auto* F_g = new MvField(g); + field* g = get_field(v, i, expand_mem); + auto* F_g = new MvField(g); int levcount = F_g->vertCoordCoefPairCount(); if ((int)F_g->parameter() == 152) @@ -5092,7 +5152,7 @@ delete[] levels; } - count = levcount - 1; + count = levcount - 1; levels = new int[count]; for (int k = 0; k < count; k++) levels[k] = k + 1; @@ -5100,7 +5160,7 @@ for (int k = 0; k < count; k++) { int level = levels[k]; - field* h = copy_field(g, false); + field* h = copy_field(g, false); MvField F_h(h); double C11, C12, C21, C22; @@ -5110,9 +5170,9 @@ if (pressure) for (size_t j = 0; j < g->value_count; j++) { if (!MISSING_VALUE(g->values[j])) { - double e = exp(g->values[j]); - double a = (C11 + C21) / 2.0; - double b = (C12 + C22) / 2.0; + double e = exp(g->values[j]); + double a = (C11 + C21) / 2.0; + double b = (C12 + C22) / 2.0; h->values[j] = a + b * e; } else { @@ -5122,10 +5182,10 @@ else for (size_t j = 0; j < g->value_count; j++) { if (!MISSING_VALUE(g->values[j])) { - double e = exp(g->values[j]); - double pkpd = C21 + C22 * e; - double pkmd = C11 + C12 * e; - double dpg = pkpd - pkmd; + double e = exp(g->values[j]); + double pkpd = C21 + C22 * e; + double pkmd = C11 + C12 * e; + double dpg = pkpd - pkmd; h->values[j] = dpg; } else { @@ -5167,7 +5227,7 @@ private: boolean needPressure_{true}; int arity_{-1}; - int lnspId_{152}; //-- default ECMWF 'lnsp' code value, in table 2 version 128 + int lnspId_{152}; //-- default ECMWF 'lnsp' code value, in table 2 version 128 public: UniThicknessAndPressureFunction(const char* n, boolean p) : @@ -5245,7 +5305,8 @@ assert(arity_ == 1 || arity_ == 2); if (arity_ == 1) { return Value(metview::pressureOnMl(lnsp, lnspId_, !needPressure_)); - } else if (arg[1].GetType() == tlist) { + } + else if (arg[1].GetType() == tlist) { CList* l = nullptr; std::vector levels; arg[1].GetValue(l); @@ -5255,12 +5316,14 @@ levels.push_back(levVal); } return Value(metview::pressureOnMl(lnsp, lnspId_, !needPressure_, levels)); - } else if (arg[1].GetType() == tgrib) { + } + else if (arg[1].GetType() == tgrib) { fieldset* fs; arg[1].GetValue(fs); return Value(metview::pressureOnMl(lnsp, lnspId_, !needPressure_, fs)); } - } catch (MvException& e) { + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } @@ -5334,8 +5397,8 @@ f = get_field(fs, i, expand_mem); r = empty_request(nullptr); - nNumPresent = 0; - nNumMissing = 0; + nNumPresent = 0; + nNumMissing = 0; dProportionPresent = 0.0; dProportionMissing = 0.0; @@ -5358,8 +5421,8 @@ else { // field has no missing values - we can take a shortcut - nNumPresent = f->value_count; - nNumMissing = 0; + nNumPresent = f->value_count; + nNumMissing = 0; dProportionPresent = 1.0; dProportionMissing = 0.0; } @@ -5441,8 +5504,8 @@ Value GribMatrixFunction::Execute(int, Value* arg) { fieldset* v; - CList* l = nullptr; - CMatrix* m = nullptr; + CList* l = nullptr; + CMatrix* m = nullptr; int fields_processed = 0; arg[0].GetValue(v); @@ -5453,7 +5516,7 @@ for (int i = 0; i < v->count; i++) { field* g = get_field(v, i, expand_mem); - //gribsec2_ll *s2 = (gribsec2_ll*) &g->ksec2[0]; + // gribsec2_ll *s2 = (gribsec2_ll*) &g->ksec2[0]; std::unique_ptr grd(MvGridFactory(g)); std::string gridType = grd->gridType(); @@ -5464,8 +5527,8 @@ continue; } - //int x = (int)s2->points_meridian; - //int y = (int)s2->points_parallel; + // int x = (int)s2->points_meridian; + // int y = (int)s2->points_parallel; int x = (int)grd->getLong("numberOfPointsAlongAParallel"); int y = (int)grd->getLong("numberOfPointsAlongAMeridian"); @@ -5539,8 +5602,8 @@ int baseIndex = Context::BaseIndex(); for (int i = 0; i < u->count; i++) { - field* fu = get_field(u, i, expand_mem); - field* fv = get_field(v, i, expand_mem); + field* fu = get_field(u, i, expand_mem); + field* fv = get_field(v, i, expand_mem); long uParamId = 131; { // TODO: only the spectral fields should be omitted here! Speed and dir computations otherwise are @@ -5554,7 +5617,7 @@ return Error("%s: V[field=%d]: cannot process this type of field!", Name(), i + baseIndex); if (!gu->isEqual(gv.get())) - return Error("%s: U and V [field=%d]: different grids!", Name(), i + baseIndex); + return Error("%s: U and V [field=%d]: different grids!", Name(), i + baseIndex); uParamId = gu->getLong("paramId", false, true); } @@ -5573,7 +5636,7 @@ double v2 = fv->values[j]; if (!MISSING_VALUE(v1) && !MISSING_VALUE(v2)) { - double s = sqrt(v1 * v1 + v2 * v2); + double s = sqrt(v1 * v1 + v2 * v2); result_i->values[j] = s; } else { @@ -5584,7 +5647,7 @@ } case G2TO1_DIRECTION: default: { - const double cEpsilon = 1E-5; + const double cEpsilon = 1E-5; const double c270inRad = MvSci::degToRad(270.); for (size_t j = 0; j < fu->value_count; ++j) { @@ -5598,7 +5661,8 @@ { if (v2 > 0) { d = M_PI; //-- from South - } else { + } + else { d = 0; //-- from North } } @@ -5625,14 +5689,14 @@ } else { // U paramId -> wind speed paramId - static std::map uToSpeed = { + static std::map uToSpeed = { {131, 10}, // atmospheric wind {165, 207}, // 10m wind {228246, 228249}, // 100m wind {228239, 228241} // 200m wind }; long speedParamId = 10; - auto it = uToSpeed.find(uParamId); + auto it = uToSpeed.find(uParamId); if (it != uToSpeed.end()) { speedParamId = it->second; } @@ -5664,7 +5728,7 @@ Value MeanEwFunction::Execute(int, Value* arg) { - fieldset* v=nullptr; + fieldset* v = nullptr; arg[0].GetValue(v); assert(v); @@ -5689,11 +5753,11 @@ // When it is destroyed the shape of fRes will not be reset std::unique_ptr newGrd(MvGridFactory(fRes, false)); double currentLatRow = grd->lat_y(); - bool cont = true; + bool cont = true; while (cont) { double sum = 0; - int cnt = 0; + int cnt = 0; //-- compute mean of one lat row --// while (cont && (grd->lat_y() == currentLatRow)) { @@ -5746,9 +5810,9 @@ virtual Value Execute(int arity, Value* arg); private: - double area_[4]; - double grid_; - bool isEW_; + double area_[4] = {0., 0., 0., 0.}; + double grid_{1.}; + bool isEW_{false}; }; int LatLonAverageFunction::ValidArguments(int arity, Value* arg) @@ -5813,7 +5877,7 @@ } int listSize = vals.size(); - auto* z = new CVector(listSize); + auto* z = new CVector(listSize); for (int iv = 0; iv < listSize; ++iv) { z->setIndexedValue(iv, vals[iv]); @@ -5842,7 +5906,7 @@ GribFunction(const char* n, func* f) : Function(n) { - F_ = f; + F_ = f; info = f->info; } virtual Value Execute(int arity, Value* arg); @@ -5897,7 +5961,7 @@ break; } - Math.name = (char*)Name(); + Math.name = (char*)Name(); Math.arity = arity; feclearexcept(FE_ALL_EXCEPT); @@ -5969,7 +6033,7 @@ virtual int ValidArguments(int arity, Value* arg); private: - int marsAccuracy; + int marsAccuracy{-1}; }; int GribIntToFloatFunction::ValidArguments(int arity, Value* arg) @@ -6008,7 +6072,7 @@ for (int i = 0; i < v->count; ++i) //-- for all fields in a fieldset { field* g = get_field(v, i, expand_mem); - std::unique_ptr grd(MvGridFactory(g)); + std::unique_ptr grd(MvGridFactory(g, false)); if (!grd->isValid()) return Error("float: unimplemented grid type: %s", grd->gridType().c_str()); @@ -6052,7 +6116,7 @@ virtual int ValidArguments(int arity, Value* arg); private: - int marsAccuracy; + int marsAccuracy{-1}; }; int GribFloatToIntFunction::ValidArguments(int arity, Value* arg) @@ -6091,7 +6155,7 @@ for (int i = 0; i < v->count; ++i) //-- for all fields in a fieldset { field* g = get_field(v, i, expand_mem); //-- input field - std::unique_ptr grd(MvGridFactory(g)); + std::unique_ptr grd(MvGridFactory(g, false)); if (!grd->isValid()) return Error("integer: unimplemented grid type: %s", grd->gridType().c_str()); @@ -6161,8 +6225,8 @@ assert(v->fields[i]->shape == expand_mem); - //df/dx - field* fResX = copy_field(v->fields[i], false); + // df/dx + field* fResX = copy_field(v->fields[i], false); assert(fResX->shape == expand_mem); { // will not change expanded state in the desctructor @@ -6174,8 +6238,8 @@ set_field(result, fResX, 2 * i); save_fieldset(result); - //df/dy - field* fResY = copy_field(v->fields[i], false); + // df/dy + field* fResY = copy_field(v->fields[i], false); assert(fResY->shape == expand_mem); { // will not change expanded state in the desctructor @@ -6183,7 +6247,7 @@ grd->firstDerivativeY(grdY.get()); } assert(fResY->shape == expand_mem); - set_field(result, fResY, 2 * i+1); + set_field(result, fResY, 2 * i + 1); save_fieldset(result); } @@ -6208,7 +6272,7 @@ if (type_ >= 0 && type_ < 4) { info = strcache(infoVec[type_].c_str()); } - assert(type_>=0 && type_ < 4); + assert(type_ >= 0 && type_ < 4); } Value Execute(int arity, Value* arg) override; @@ -6235,7 +6299,8 @@ MvGridBase::DerivativeMethod dMethod; if (type_ >= 0 && type_ < 4) { dMethod = derivativeMethods[type_]; - } else { + } + else { return Error("%s: invalid function type=%d is specified", Name(), type_); } @@ -6249,7 +6314,7 @@ if (!grd->isRegularLatLongGrid()) return Error("%s: [field %d] unsupported grid - implemented only for regular lat-lon grid", Name(), i + baseIndex); - field* fRes = copy_field(v->fields[i], false); + field* fRes = copy_field(v->fields[i], false); assert(fRes->shape == expand_mem); { // will not change expanded state in the desctructor @@ -6309,7 +6374,7 @@ grd->gridCellArea(grdZ.get()); } assert(fRes->shape == expand_mem); - set_field(result, fRes,i); + set_field(result, fRes, i); save_fieldset(result); } @@ -6327,7 +6392,16 @@ int ValidArguments(int arity, Value* arg) override; private: - enum Type {NoType, CorrType, CovarType, VarType, StdevType, RmsType, DeprecType}; + enum Type + { + NoType, + CorrType, + CovarType, + VarType, + StdevType, + RmsType, + DeprecType + }; Type type_{NoType}; static std::map types_; @@ -6338,8 +6412,7 @@ }; std::map CovarianceFunction::types_ = - {{"corr_a", CorrType}, {"covar_a", CovarType}, {"var_a", VarType}, {"stdev_a", StdevType}, - {"rms_a", RmsType}}; + {{"corr_a", CorrType}, {"covar_a", CovarType}, {"var_a", VarType}, {"stdev_a", StdevType}, {"rms_a", RmsType}}; CovarianceFunction::CovarianceFunction(const char* n) : Function(n) @@ -6348,28 +6421,29 @@ auto it = types_.find(nStr); if (it != types_.end()) { type_ = it->second; - } else { + } + else { throw MvException("CovarianceFunction: invalid function name=" + nStr + " specified!"); } - switch(type_) { - case CorrType: - info = "Computes the area-weighted correlation for each field in a fieldset"; - break; - case CovarType: - info = "Computes the area-weighted covariance for each field in a fieldset"; - break; - case VarType: - info = "Computes the area-weighted variance for each field in a fieldset"; - break; - case StdevType: - info = "Computes the area-weighted standard deviation for each field in a fieldset"; - break; - case RmsType: - info = "Computes the area-weighted root mean square for each field in a fieldset"; - break; - default: - break; + switch (type_) { + case CorrType: + info = "Computes the area-weighted correlation for each field in a fieldset"; + break; + case CovarType: + info = "Computes the area-weighted covariance for each field in a fieldset"; + break; + case VarType: + info = "Computes the area-weighted variance for each field in a fieldset"; + break; + case StdevType: + info = "Computes the area-weighted standard deviation for each field in a fieldset"; + break; + case RmsType: + info = "Computes the area-weighted root mean square for each field in a fieldset"; + break; + default: + break; } } @@ -6394,8 +6468,7 @@ return false; } } - else - { + else { if (arity > 2) return false; @@ -6457,27 +6530,28 @@ double val = 0; for (int i = 0; i < v1->count; i++) //-- loop all fields in fieldset(s) { - try { - switch(type_) { - case VarType: - val = computeVar(v1->fields[i], geoArea); - break; - case StdevType: - val = std::sqrt(computeVar(v1->fields[i], geoArea)); - break; - case RmsType: - val = computeRms(v1->fields[i], geoArea); - break; - case CovarType: - val = computeCovar(v1->fields[i], v2->fields[i], geoArea); - break; - case CorrType: - val = computeCorr(v1->fields[i], v2->fields[i], geoArea); - break; - default: - break; + try { + switch (type_) { + case VarType: + val = computeVar(v1->fields[i], geoArea); + break; + case StdevType: + val = std::sqrt(computeVar(v1->fields[i], geoArea)); + break; + case RmsType: + val = computeRms(v1->fields[i], geoArea); + break; + case CovarType: + val = computeCovar(v1->fields[i], v2->fields[i], geoArea); + break; + case CorrType: + val = computeCorr(v1->fields[i], v2->fields[i], geoArea); + break; + default: + break; } - } catch (MvException& e) { + } + catch (MvException& e) { return Error("%s: %s", Name(), e.what()); } @@ -6500,18 +6574,18 @@ throw MvException("Unimplemented or spectral data - unable to extract location data"); } - double wght = 0; - double sum11 = 0; - double sum1 = 0; + double wght = 0; + double sum11 = 0; + double sum1 = 0; for (int j = 0; j < grd->length(); ++j) { if (grd->hasValue() && area.isInside(grd->lat_y(), grd->lon_x())) { double w = grd->weight(); double v = grd->value(); - double wv = w*v; + double wv = w * v; sum1 += wv; - sum11 += wv*v; + sum11 += wv * v; wght += w; } grd->advance(); @@ -6520,7 +6594,7 @@ if (!wght) throw MvException("No points to compute"); - return sum11 / wght - (sum1 *sum1) / (wght * wght); + return sum11 / wght - (sum1 * sum1) / (wght * wght); } double CovarianceFunction::computeRms(field* f, const MvGeoBox& area) @@ -6530,15 +6604,15 @@ throw MvException("Unimplemented or spectral data - unable to extract location data"); } - double wght = 0; - double sum11 = 0; + double wght = 0; + double sum11 = 0; for (int j = 0; j < grd->length(); ++j) { if (grd->hasValue() && area.isInside(grd->lat_y(), grd->lon_x())) { double w = grd->weight(); double v = grd->value(); - sum11 += w*v*v; + sum11 += w * v * v; wght += w; } grd->advance(); @@ -6562,9 +6636,9 @@ if (!grd1->isEqual(grd2.get())) throw MvException("fields are in different grids!"); - double wght = 0; - double sum1 = 0; - double sum2 = 0; + double wght = 0; + double sum1 = 0; + double sum2 = 0; double sum12 = 0; for (int j = 0; j < grd1->length(); ++j) { @@ -6605,9 +6679,9 @@ if (!grd1->isEqual(grd2.get())) throw MvException("fields are in different grids!"); - double wght = 0; - double sum1 = 0; - double sum2 = 0; + double wght = 0; + double sum1 = 0; + double sum2 = 0; double sum12 = 0; double sum11 = 0; double sum22 = 0; @@ -6638,9 +6712,9 @@ if (!wght) throw MvException("No points to compute"); - double var1 = sum11 / wght - (sum1 *sum1) / (wght * wght); - double var2 = sum22 / wght - (sum2 *sum2) / (wght * wght); - return ((sum12 / wght) - (sum1 / wght) * (sum2 / wght))/std::sqrt(var1*var2); + double var1 = sum11 / wght - (sum1 * sum1) / (wght * wght); + double var2 = sum22 / wght - (sum2 * sum2) / (wght * wght); + return ((sum12 / wght) - (sum1 / wght) * (sum2 / wght)) / std::sqrt(var1 * var2); } //============================================================================= @@ -6654,7 +6728,7 @@ static int done = 0; if (!done) { - //check_precision(); //-- was needed previously for Fortran REAL interface + // check_precision(); //-- was needed previously for Fortran REAL interface done = 1; } @@ -6668,7 +6742,7 @@ { from_filter_ = (const char*)get_value(r, "FIELDSET_FROM_FILTER", 0) ? true : false; - fs = request_to_fieldset(r); + fs = request_to_fieldset(r); path_ = MakeAbsolutePath((const char*)get_value(r, "PATH", 0), mdirname(Script::MacroMainPath())); // Make sure all path are temporary @@ -6696,7 +6770,7 @@ from_filter_(from_filter) { path_ = ""; - fs = read_fieldset(FullPathName(fname).c_str(), 0); + fs = read_fieldset(FullPathName(fname).c_str(), 0); } void CGrib::DestroyContent() @@ -6793,7 +6867,7 @@ const char* ctemp = get_value(r, "TEMPORARY", 0); - int itemp = atoi(ctemp); + int itemp = atoi(ctemp); if (itemp) { IsIcon(true); // InPool won't touch the data SetFileTempFlag(true); @@ -6804,7 +6878,7 @@ // Temp fix : Some one want the path, so don't delete it - //Attach(); + // Attach(); s = r; } @@ -6822,7 +6896,7 @@ void CGrib::SetFileTempFlag(boolean temp) { for (int i = 0; i < fs->count; i++) { - field* g = fs->fields[i]; + field* g = fs->fields[i]; g->file->temp = temp; } } @@ -6850,9 +6924,9 @@ // Initial checks if (arity < 2) return false; - if (arg[0].GetType() != tgrib) //fieldset + if (arg[0].GetType() != tgrib) // fieldset return false; - if (arg[1].GetType() != tlist) //intervals + if (arg[1].GetType() != tlist) // intervals return false; // Check area values @@ -6881,8 +6955,8 @@ { fieldset* v; int i, j, k; - Value lst1; //single: will store a list of numbers - CList* lst2 = 0; //double: will store a list of lists of numbers + Value lst1; // single: will store a list of numbers + CList* lst2 = 0; // double: will store a list of lists of numbers // Get fieldset arg[0].GetValue(v); @@ -6901,21 +6975,21 @@ double& w = d[1]; double& s = d[2]; double& e = d[3]; - if (arity == 2) //default area + if (arity == 2) // default area { n = 90; s = -90; w = 0; e = 360; } - else if (arity == 3) //area given as a list + else if (arity == 3) // area given as a list { arg[2].GetValue(l); for (i = 0; i < 4; i++) (*l)[i].GetValue(d[i]); } else - getNumberArgsAsArrayOfNumbers(arg, 1, 4, d); //area given as 4 numbers + getNumberArgsAsArrayOfNumbers(arg, 1, 4, d); // area given as 4 numbers // note: looks like ValidArguments prevents this case while (w > e) @@ -6943,7 +7017,7 @@ // Check if it is a valid point if (grd->hasValue() && geoArea.isInside(grd->lat_y(), grd->lon_x())) { // Compute frequency - v1 = grd->value(); + v1 = grd->value(); found = false; for (k = 0; k < nint; k++) { if (v1 < vint[k]) { @@ -7051,8 +7125,7 @@ Function(n, 1, tgrib), doAvg_(a) { - info = (doAvg_)?"Returns the mean of the values in a Fieldset in each gridpoint": - "Returns the sum of the values in a Fieldset in each gridpoint"; + info = (doAvg_) ? "Returns the mean of the values in a Fieldset in each gridpoint" : "Returns the sum of the values in a Fieldset in each gridpoint"; } int ValidArguments(int arity, Value* arg) override; Value Execute(int arity, Value* arg) override; @@ -7086,7 +7159,7 @@ fieldset* v{nullptr}; arg[0].GetValue(v); - if (v->count <=0) { + if (v->count <= 0) { return Error("%s: empty input fieldset", Name()); } @@ -7106,32 +7179,36 @@ for (std::size_t j = 0; j < resF->value_count; j++) { if (!MISSING_VALUE(resF->values[j])) { validNum[j] = 1; - } else { + } + else { resF->values[j] = 0.0; validNum[j] = 0; } } // at this point we do not have bitmap in the resulting field resF->bitmap = false; - } else { + } + else { assert(resF); if (g->value_count != resF->value_count) { release_field(g); release_field(resF); return Error("%s: not all fields have the same number of values!", Name()); - // has missing value in input - } else if (g->missing_vals) { + // has missing value in input + } + else if (g->missing_vals) { for (std::size_t j = 0; j < g->value_count; j++) { if (!MISSING_VALUE(g->values[j])) { resF->values[j] += g->values[j]; validNum[j]++; } } - } else { + } + else { for (std::size_t j = 0; j < g->value_count; j++) { resF->values[j] += g->values[j]; validNum[j]++; - } + } } } } @@ -7146,21 +7223,24 @@ for (std::size_t j = 0; j < resF->value_count; j++) { if (validNum[j] > 0) { resF->values[j] /= validNum[j]; - } else { + } + else { SetFieldElementToMissingValue(resF, j); } } - } else { + } + else { for (std::size_t j = 0; j < resF->value_count; j++) { if (validNum[j] == 0) { SetFieldElementToMissingValue(resF, j); } } } - // default mode: if there is even one missing value in a gridpoint the result will be missing - // value in that gridpoint - } else { - int missingFieldNum = 0 ; + // default mode: if there is even one missing value in a gridpoint the result will be missing + // value in that gridpoint + } + else { + int missingFieldNum = 0; for (int i = 0; i < v->count; i++) { field* g = get_field(v, i, expand_mem); if (!MISSING_FIELD(g)) { @@ -7173,24 +7253,28 @@ release_field(g); release_field(resF); return Error("%s: not all fields have the same number of values!", Name()); - // has missing value in either res or input - } else if (g->missing_vals || resF->missing_vals) { + // has missing value in either res or input + } + else if (g->missing_vals || resF->missing_vals) { for (std::size_t j = 0; j < g->value_count; j++) { if (!MISSING_VALUE(resF->values[j])) { if (!MISSING_VALUE(g->values[j])) { resF->values[j] += g->values[j]; - } else { + } + else { SetFieldElementToMissingValue(resF, j); } } } - } else { + } + else { for (std::size_t j = 0; j < g->value_count; j++) { resF->values[j] += g->values[j]; } } - } - } else { + } + } + else { missingFieldNum++; } release_field(g); @@ -7210,7 +7294,7 @@ } assert(resF); - fieldset *resFs = new_fieldset(1); + fieldset* resFs = new_fieldset(1); set_field(resFs, resF, 0); return Value(resFs); } @@ -7336,6 +7420,7 @@ c->AddFunction(new GribHeaderFunctionW("grib_set_long", GRIB_LONG)); c->AddFunction(new GribHeaderFunctionW("grib_set_double", GRIB_DOUBLE)); c->AddFunction(new GribHeaderFunctionW("grib_set_string", GRIB_STRING)); + c->AddFunction(new GribHeaderFunctionW("grib_set_long_array", GRIB_LONG_ARRAY)); c->AddFunction(new GribHeaderFunctionWGeneric("grib_set")); c->AddFunction(new FillMVEWFunction("fill_missing_values_ew")); diff -Nru metview-5.17.4/metview/src/Macro/image.cc metview-5.19.2/metview/src/Macro/image.cc --- metview-5.17.4/metview/src/Macro/image.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/image.cc 2023-07-15 08:28:47.000000000 +0000 @@ -59,21 +59,21 @@ class Image { - long nx; //-- pixels along x-axis - long ny; //-- pixels along y-axis - char* name; //-- unique name for Macro prints/debugs - char* path; //-- path to satellite GRIB file + long nx{0}; //-- pixels along x-axis + long ny{0}; //-- pixels along y-axis + char* name{nullptr}; //-- unique name for Macro prints/debugs + char* path{nullptr}; //-- path to satellite GRIB file //-- DO WE NEED TO USE MEMORY MAPPING ALSO WITH ecCodes???? - unsigned char* buffer; //-- memory mapped GRIB file/msg - unsigned char* data; //-- data part in memory mapped GRIB msg - int length; //-- length of the GRIB file/msg - long offset; //-- start of data in memory mapped GRIB msg - size_t count; //-- total number of pixel values - int mapped; //-- OBSOLETE? only set, not checked at all!!!? + unsigned char* buffer{nullptr}; //-- memory mapped GRIB file/msg + unsigned char* data{nullptr}; //-- data part in memory mapped GRIB msg + int length{0}; //-- length of the GRIB file/msg + long offset{0}; //-- start of data in memory mapped GRIB msg + size_t count{0}; //-- total number of pixel values + int mapped{0}; //-- OBSOLETE? only set, not checked at all!!!? - FILE* file; //-- store file descr between Map() and Unmap() + FILE* file{nullptr}; //-- store file descr between Map() and Unmap() public: int Count(void) { return count; } @@ -91,6 +91,8 @@ Image(Image*, long); Image(const char* p, const char* n); ~Image(); + Image(const Image&) = delete; + Image& operator=(const Image&) = delete; }; #if USE_OLD_GRIBEX_CODE @@ -103,16 +105,16 @@ Image::Image(const char* p, const char* n) { #if USE_OLD_GRIBEX_CODE - name = n ? strcache(n) : strcache(Context::UniqueName()); - path = strcache(p); + name = n ? strcache(n) : strcache(Context::UniqueName()); + path = strcache(p); buffer = 0; length = 0; offset = 0; mapped = 0; - file = 0; - nx = 0; - ny = 0; - count = 0; + file = 0; + nx = 0; + ny = 0; + count = 0; fortint ksec0[ISECTION_0]; fortint ksec1[ISECTION_1]; @@ -126,14 +128,14 @@ Map(); fortint len = length; - err e = cgribex(ksec0, ksec1, + err e = cgribex(ksec0, ksec1, ksec2, zsec2, ksec3, zsec3, ksec4, zsec4, len4, (char*)buffer, &len, "G"); offset = (int)ksec4[33] / 8; - count = (int)ksec4[0]; - nx = (int)ksec2[1]; - ny = (int)ksec2[2]; + count = (int)ksec4[0]; + nx = (int)ksec2[1]; + ny = (int)ksec2[2]; Unmap(); #else @@ -144,13 +146,13 @@ if (!in) marslog(LOG_EROR, "Image::Image - unable to open input file"); - int ret = 0; + int ret = 0; grib_handle* h = grib_handle_new_from_file(0, in, &ret); if (!h) marslog(LOG_EROR, "Image::Image - unable to get grib_handle"); - //ret = grib_get_long( h, "x", &offset ); //-- do we need offset with ecCodes??? - //if( ! ret ) ... + // ret = grib_get_long( h, "x", &offset ); //-- do we need offset with ecCodes??? + // if( ! ret ) ... ret = grib_get_size(h, "values", &count); if (ret != 0) marslog(LOG_EROR, "Image::Image - unable to read image size"); @@ -170,14 +172,14 @@ Image::Image(Image* i) { - name = strcache(Context::UniqueName()); - path = strcache(marstmp()); + name = strcache(Context::UniqueName()); + path = strcache(marstmp()); buffer = 0; length = i->length; offset = i->offset; - count = i->count; - nx = i->nx; - ny = i->ny; + count = i->count; + nx = i->nx; + ny = i->ny; mapped = 0; @@ -192,7 +194,7 @@ /* std::memcpy(buffer,i->buffer,length); - */ + */ std::memcpy(buffer, i->buffer, offset); std::memcpy(buffer + offset + count, @@ -276,7 +278,7 @@ InPool(timage, r) { const char* path = get_value(r, "PATH", 0); - image = new Image(path, GetName()); + image = new Image(path, GetName()); } CImage::~CImage() @@ -619,7 +621,7 @@ cgribex(ksec0, ksec1, ksec2, zsec2, ksec3, zsec3, ksec4, zsec4, len4, (char*)i->buffer, &len, "G"); i->Unmap(); - //Get scaled pict + // Get scaled pict /* nx/ny: number of points along x/y-axis */ ksec2[1] = ksec2[1] / scale; @@ -638,16 +640,16 @@ /* # of data values in psec4: columns x rows */ ksec4[0] = ksec2[1] * ksec2[2]; - name = strcache(Context::UniqueName()); - path = strcache(marstmp()); + name = strcache(Context::UniqueName()); + path = strcache(marstmp()); buffer = 0; - count = (int)ksec4[0]; + count = (int)ksec4[0]; length = i->length - i->count + count; offset = i->offset; mapped = 0; - file = 0; - nx = (int)ksec2[1]; - ny = (int)ksec2[2]; + file = 0; + nx = (int)ksec2[1]; + ny = (int)ksec2[2]; file = fopen(path, "r+"); @@ -661,7 +663,7 @@ len = length; - len4 = count; + len4 = count; fortfloat* sec4 = new fortfloat[len4]; cgribex(ksec0, ksec1, ksec2, zsec2, ksec3, zsec3, ksec4, sec4, len4, (char*)buffer, &len, "C"); diff -Nru metview-5.17.4/metview/src/Macro/include/arith.h metview-5.19.2/metview/src/Macro/include/arith.h --- metview-5.17.4/metview/src/Macro/include/arith.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/arith.h 2023-07-15 08:28:47.000000000 +0000 @@ -47,4 +47,3 @@ // one way to detect a NaN is to compare it with itself - it will be false return (d != d); } - diff -Nru metview-5.17.4/metview/src/Macro/include/cgptset.h metview-5.19.2/metview/src/Macro/include/cgptset.h --- metview-5.17.4/metview/src/Macro/include/cgptset.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/cgptset.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,28 +17,28 @@ class CGeoptSet : public Content { - //MvGeoPointSet gptset; - // we use a vector of Value instead of CGeopts because it does - // the reference counting for us (shared pointer basically) + // MvGeoPointSet gptset; + // we use a vector of Value instead of CGeopts because it does + // the reference counting for us (shared pointer basically) std::vector vgpts; eGeoFormat format; request* r; - //void ToRequest(request* &); - //void ToGeoptSet(CGeoptSet* &x) { x = this; } - //int Write(FILE*); + // void ToRequest(request* &); + // void ToGeoptSet(CGeoptSet* &x) { x = this; } + // int Write(FILE*); public: - //void load(void); - //void unload(void); - //long Count(void) { return gpts.count();} + // void load(void); + // void unload(void); + // long Count(void) { return gpts.count();} Value& operator[](unsigned long n) { assert(n - 1 >= 0 && n - 1 < vgpts.size()); return vgpts[n - 1]; } - //eGeoFormat Format(void) { return gpts.format(); } - //const char *GetFileName(); + // eGeoFormat Format(void) { return gpts.format(); } + // const char *GetFileName(); CGeoptSet(); CGeoptSet(const CGeoptSet* src); @@ -46,16 +46,16 @@ void Print(void); int Write(FILE* f); void load(void); - //CGeoptSet(CGeoptSet &ref); + // CGeoptSet(CGeoptSet &ref); CGeoptSet(request* r); - //CGeopts(long count); - //CGeopts(CGeopts *); - //CGeopts(fieldset*,int); - //CGeopts(CGeopts *,fieldset*,int, bool nearest=false); - //CGeopts(const char *name,int temp = 0); + // CGeopts(long count); + // CGeopts(CGeopts *); + // CGeopts(fieldset*,int); + // CGeopts(CGeopts *,fieldset*,int, bool nearest=false); + // CGeopts(const char *name,int temp = 0); ~CGeoptSet(); virtual void ToGeoptSet(CGeoptSet*& x) { x = this; } - //void CopyContentsFrom(const CGeoptSet *src); + // void CopyContentsFrom(const CGeoptSet *src); unsigned long Count() { return vgpts.size(); } void Add(Value& g) { vgpts.push_back(g); } diff -Nru metview-5.17.4/metview/src/Macro/include/codb.h metview-5.19.2/metview/src/Macro/include/codb.h --- metview-5.17.4/metview/src/Macro/include/codb.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/codb.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,25 +26,25 @@ public: void load(); void unload(); - //void sort(){ gpts.sort(); } - //void removeDuplicates(){ gpts.removeDuplicates(); } - //void offset( double dlat, double dlon ){ gpts.offset( dlat, dlon ); } + // void sort(){ gpts.sort(); } + // void removeDuplicates(){ gpts.removeDuplicates(); } + // void offset( double dlat, double dlon ){ gpts.offset( dlat, dlon ); } MvAbstractOdb* odb() { return odb_; } long Count(); - //string dbSystem() { return gpts.dbSystem();} - //string dbPath() { return gpts.dbPath();} - //string dbColumn(string c) { return gpts.dbColumn(c);} - //string dbColumnAlias(string c) { return gpts.dbColumnAlias(c);} - //const std::vector& dbQuery() { return gpts.dbQuery();} + // string dbSystem() { return gpts.dbSystem();} + // string dbPath() { return gpts.dbPath();} + // string dbColumn(string c) { return gpts.dbColumn(c);} + // string dbColumnAlias(string c) { return gpts.dbColumnAlias(c);} + // const std::vector& dbQuery() { return gpts.dbQuery();} COdb(request* r); - //COdb(long count); - //COdb(CGeopts *); - //COdb(fieldset*,int); - //COdb(CGeopts *,fieldset*,int, bool nearest=false); + // COdb(long count); + // COdb(CGeopts *); + // COdb(fieldset*,int); + // COdb(CGeopts *,fieldset*,int, bool nearest=false); COdb(const char* name, int temp = 0); ~COdb(); }; diff -Nru metview-5.17.4/metview/src/Macro/include/code.h metview-5.19.2/metview/src/Macro/include/code.h --- metview-5.17.4/metview/src/Macro/include/code.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/code.h 2023-07-15 08:28:47.000000000 +0000 @@ -64,7 +64,7 @@ public: OpStore(const char* nam, int n = 0) { - Name = strcache(nam); + Name = strcache(nam); Count = n; } ~OpStore() { strfree(Name); } diff -Nru metview-5.17.4/metview/src/Macro/include/macro.h metview-5.19.2/metview/src/Macro/include/macro.h --- metview-5.17.4/metview/src/Macro/include/macro.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/macro.h 2023-07-15 08:28:47.000000000 +0000 @@ -72,7 +72,7 @@ { delete[] types; types = t; - cnt = n; + cnt = n; } void AddType(vtype t); @@ -310,8 +310,8 @@ public: Linkage(cproc p) { - proc = p; - next = Links; + proc = p; + next = Links; Links = this; } Linkage* Next(void) { return next; } diff -Nru metview-5.17.4/metview/src/Macro/include/methods.h metview-5.19.2/metview/src/Macro/include/methods.h --- metview-5.17.4/metview/src/Macro/include/methods.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/methods.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,11 @@ #include "eckit/geometry/polygon/LonLatPolygon.h" -namespace metview { +namespace metview +{ void buildOnePolygon(int idx, CVector* vlat, CVector* vlon, std::vector& polygons); void buildPolygons(Value* arg1, Value* arg2, std::vector& polygons); void checkStringOption(const char* optionName, int& arity, Value* arg, bool& optionValue, std::string& incorrectOption); -} +} // namespace metview diff -Nru metview-5.17.4/metview/src/Macro/include/node.h metview-5.19.2/metview/src/Macro/include/node.h --- metview-5.17.4/metview/src/Macro/include/node.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/node.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ Node(const char* n = nullptr) { owner = nullptr; - name = strcache(n); + name = strcache(n); } virtual ~Node() { strfree(name); } @@ -91,7 +91,7 @@ void Insert(Node* o) { o->next = head; - head = o; + head = o; if (tail == nullptr) tail = o; } @@ -151,8 +151,8 @@ } void Restore(List& l) { - head = l.head; - tail = l.tail; + head = l.head; + tail = l.tail; l.head = l.tail = nullptr; } }; diff -Nru metview-5.17.4/metview/src/Macro/include/script.h metview-5.19.2/metview/src/Macro/include/script.h --- metview-5.17.4/metview/src/Macro/include/script.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/script.h 2023-07-15 08:28:47.000000000 +0000 @@ -133,4 +133,4 @@ ~Batch(); }; -//SCRIPT_H__ +// SCRIPT_H__ diff -Nru metview-5.17.4/metview/src/Macro/include/value.h metview-5.19.2/metview/src/Macro/include/value.h --- metview-5.17.4/metview/src/Macro/include/value.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/value.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,8 @@ // Define needed on Solaris #define vtype _vtype -//GNU 2.96: type clash! -//typedef argtype _vtype; // from mars.h +// GNU 2.96: type clash! +// typedef argtype _vtype; // from mars.h typedef int _vtype; class Value; @@ -54,7 +54,7 @@ int RefCount(void) { return count; } Reference() { - count = 0; + count = 0; notify = 0; } void Attach(void) { count++; } @@ -230,11 +230,20 @@ } #endif virtual void Dump(int); - virtual void Dump1() { Print(); } - virtual void Dump2() { Print(); } + virtual void Dump1() + { + Print(); + } + virtual void Dump2() + { + Print(); + } int Check(int, Value&, int, Value*, vtype, int, ...); - virtual void SetSubValue(Value&, int, Value*) { Fail("Index"); } + virtual void SetSubValue(Value&, int, Value*) + { + Fail("Index"); + } // }; @@ -252,7 +261,7 @@ InPool(vtype t, const char* n = nullptr); ~InPool(); - //SetName(char *n); + // SetName(char *n); const char* GetName(void) { return iconName; } boolean IsIcon() { return isIcon; } void IsIcon(boolean n) { isIcon = n; } @@ -352,7 +361,7 @@ Content(terror) { error = e; - msg = strcache(m); + msg = strcache(m); } ~CError() { strfree(msg); } const char* Message() { return msg; } @@ -424,23 +433,23 @@ class CImage : public InPool { /* - int temp; - const char *path; - char *buffer; - long length; - long offset; - long size; - long width; - long height; - */ + int temp; + const char *path; + char *buffer; + long length; + long offset; + long size; + long width; + long height; + */ Image* image; virtual void ToRequest(request*&); - //virtual void ToImage(CImage* &x) { x = this; }; + // virtual void ToImage(CImage* &x) { x = this; }; virtual void ToImage(Image*& x) { x = image; } virtual int Write(FILE*); public: - //CImage(CImage*); + // CImage(CImage*); CImage(Image*); CImage(request* r); ~CImage(); @@ -524,7 +533,7 @@ { nil.Attach(); nil.Attach(); - } //ensure never deleted, even on termination + } // ensure never deleted, even on termination } * nilvalue; public: @@ -642,8 +651,14 @@ { c->Print(); } - void Dump(int trace) { c->Dump(trace); } - int Write(FILE* f) { return c->Write(f); } + void Dump(int trace) + { + c->Dump(trace); + } + int Write(FILE* f) + { + return c->Write(f); + } static const char* TypeName(vtype); static vtype NameType(const char*); @@ -669,7 +684,7 @@ virtual void SetSubValue(Value&, int, Value*); int capacity; - static constexpr int CHUNK = 64; //must be a power of 2 + static constexpr int CHUNK = 64; // must be a power of 2 static constexpr int calcCapacity(const int n) { @@ -747,26 +762,26 @@ CArray::ValuesType type() { return valtype; } void copyValues(int targetIndex, CArray* source, int sourceIndex, int numValues); void setSize(int newSize) { size = newSize; } // only sets the counter - virtual void allocateMemory(int numElements) = 0; - virtual void setValuesToConstant(double c) = 0; + virtual void allocateMemory(int numElements) = 0; + virtual void setValuesToConstant(double c) = 0; virtual void memorycopy(int targetIndex, const double* srcVals, int numVals) = 0; - virtual void memorycopy(int targetIndex, const float* srcVals, int numVals) = 0; - virtual double* asDoubles(int i) = 0; - virtual float* asFloat32s(int i) = 0; - virtual void setIndexedValue(int i, double v) = 0; - virtual void setIndexedValueToMissing(int i) = 0; - virtual bool isIndexedValueMissing(int i) = 0; - virtual double getIndexedValue(int i) = 0; - virtual double getMissingValueIndicator() = 0; - virtual size_t writeValuesToFile(FILE* fp) = 0; - virtual size_t readValuesFromFile(FILE* fp, int n) = 0; - virtual void clean() = 0; - virtual void resize(int newSize) = 0; - virtual void applyNumBinProc(binproc f, double other, bool otherFirst) = 0; - virtual void applyVectorBinProc(binproc f, CArray* v1, CArray* v2) = 0; - virtual void applyVectorUniProc(uniproc f, CArray* v) = 0; + virtual void memorycopy(int targetIndex, const float* srcVals, int numVals) = 0; + virtual double* asDoubles(int i) = 0; + virtual float* asFloat32s(int i) = 0; + virtual void setIndexedValue(int i, double v) = 0; + virtual void setIndexedValueToMissing(int i) = 0; + virtual bool isIndexedValueMissing(int i) = 0; + virtual double getIndexedValue(int i) = 0; + virtual double getMissingValueIndicator() = 0; + virtual size_t writeValuesToFile(FILE* fp) = 0; + virtual size_t readValuesFromFile(FILE* fp, int n) = 0; + virtual void clean() = 0; + virtual void resize(int newSize) = 0; + virtual void applyNumBinProc(binproc f, double other, bool otherFirst) = 0; + virtual void applyVectorBinProc(binproc f, CArray* v1, CArray* v2) = 0; + virtual void applyVectorUniProc(uniproc f, CArray* v) = 0; - //virtual double& operator[](int n) = 0; + // virtual double& operator[](int n) = 0; static CArray::ValuesType valuesTypeFromString(const std::string& s); static std::string stringFromValuesType(CArray::ValuesType type); @@ -806,7 +821,7 @@ private: double* values; - //double& operator[](int n) { return values[n]; }; + // double& operator[](int n) { return values[n]; }; }; class CArrayF32 : public CArray @@ -837,7 +852,7 @@ private: float* values; - //float& operator[](int n) { return values[n]; }; + // float& operator[](int n) { return values[n]; }; }; @@ -892,7 +907,7 @@ void Replace(double dold, double dnew); void Replace(float dold, float dnew); void setIndexedValue(int i, double v) { values->setIndexedValue(i, v); } - //void setIndexedValueToMissing(int i); + // void setIndexedValueToMissing(int i); bool isIndexedValueMissing(int i) { return values->isIndexedValueMissing(i); } double getIndexedValue(int i) { return values->getIndexedValue(i); } void setIndexedValueToMissing(int i) { values->setIndexedValueToMissing(i); } @@ -963,7 +978,10 @@ { return row; } - int Col(void) { return col; } + int Col(void) + { + return col; + } virtual int Write(FILE*); }; @@ -1003,4 +1021,4 @@ void GetInheritance(Context**, int& count); }; -//VALUE_H__ +// VALUE_H__ diff -Nru metview-5.17.4/metview/src/Macro/include/widgets.h metview-5.19.2/metview/src/Macro/include/widgets.h --- metview-5.17.4/metview/src/Macro/include/widgets.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/include/widgets.h 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,7 @@ /* -** Generated by X-Designer +** Generated by X-Designer */ extern Widget run_top; diff -Nru metview-5.17.4/metview/src/Macro/library.cc metview-5.19.2/metview/src/Macro/library.cc --- metview-5.17.4/metview/src/Macro/library.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/library.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ path++; char q = *path; - *path = 0; + *path = 0; sprintf(buf, "%s/%s", p, name); *path = q; diff -Nru metview-5.17.4/metview/src/Macro/main.cc metview-5.19.2/metview/src/Macro/main.cc --- metview-5.17.4/metview/src/Macro/main.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/main.cc 2023-07-15 08:28:47.000000000 +0000 @@ -90,7 +90,7 @@ { // 76830942 char line[1024]; - int n; + int n{0}; // Oops, SUN says streambuf::seekoff(long,std::ios::seek_dir,int) undefined ???? @@ -121,8 +121,7 @@ public: - sbuf() : - n(0) {} + sbuf() = default; }; @@ -189,28 +188,28 @@ reqPid("PID") = getpid(); send_progress(id, nullptr, reqPid); - auto* param = (request*)data; - const char* path = get_value(r, "PATH", 0); - const char* name = get_value(r, "_NAME", 0); - const char* action = get_value(r, "_ACTION", 0); - const char* trace = get_value(r, "_TRACE", 0); - const char* wait = get_value(r, "_WAITMODE", 0); - const char* lines = get_value(r, "_SENDLINES", 0); - const char* pause = get_value(r, "_PAUSE", 0); - const char* print = get_value(r, "_RETURN", 0); + auto* param = (request*)data; + const char* path = get_value(r, "PATH", 0); + const char* name = get_value(r, "_NAME", 0); + const char* action = get_value(r, "_ACTION", 0); + const char* trace = get_value(r, "_TRACE", 0); + const char* wait = get_value(r, "_WAITMODE", 0); + const char* lines = get_value(r, "_SENDLINES", 0); + const char* pause = get_value(r, "_PAUSE", 0); + const char* print = get_value(r, "_RETURN", 0); const char* extendMsg = get_value(r, "_EXTENDMESSAGE", 0); request* output = get_subrequest(r, "_DEVICE_DRIVER", 0); //-- uPlot/PlotMod/MetZoom request* device = get_subrequest(r, "_DEVICE", 0); //-- VisMod - //Arguments to be passed to the Macro (not allowed in param mode!) - int argNum = count_values(r, "_ARGUMENTS"); + // Arguments to be passed to the Macro (not allowed in param mode!) + int argNum = count_values(r, "_ARGUMENTS"); Value* argVal = 0; if (!param && argNum > 0 && argNum < 32) { argVal = new Value[argNum]; for (int i = 0; i < argNum; i++) { const char* t = get_value(r, "_ARGUMENTS", i); - argVal[i] = Value(t); + argVal[i] = Value(t); } } else { @@ -347,7 +346,7 @@ if (argVal) delete[] argVal; - mars.outproc = 0; + mars.outproc = 0; Script::SvcId = 0; char info[1024]; @@ -362,14 +361,16 @@ set_value(reply, "_PATH", fullPath.c_str()); } + // Be aware that send_reply deletes the id but not the service. See METV-3335 + svc* currentSvc = id->s; send_reply(id, reply); - // Don't free reply, it's go when the Value is destroyed + // Don't free reply, will be done when the Value is destroyed // Restore current directory chdir(save); if (forked != -1) { - destroy_service(id->s); + destroy_service(currentSvc); marsexit(0); } } @@ -423,7 +424,7 @@ } Script::SvcId = id; - mars.outproc = Script::PutMessage; + mars.outproc = Script::PutMessage; Compute s(name, r); @@ -444,7 +445,7 @@ send_reply(id, reply); - mars.outproc = 0; + mars.outproc = 0; Script::SvcId = 0; if (forked != -1) { @@ -492,7 +493,7 @@ } Script::SvcId = id; - mars.outproc = Script::PutMessage; + mars.outproc = Script::PutMessage; Formula s(name, r); @@ -518,7 +519,7 @@ marsexit(0); } - mars.outproc = 0; + mars.outproc = 0; Script::SvcId = 0; } @@ -532,7 +533,7 @@ CNumber::SetPrecision(CNumber::GetDefaultPrecision()); //-- print precision in digits - if (setup.serve) //interactive mode + if (setup.serve) // interactive mode { // Send prints to caller @@ -569,9 +570,9 @@ s->Run(); delete s; } - else //batch mode + else // batch mode { - //Script *s = setup.module ? (Script*)new Module(setup.name) + // Script *s = setup.module ? (Script*)new Module(setup.name) // : (Script*)new Batch(setup.name); //-- Here we rely on $MACRO_STARTUP, set up by Metview startup script: @@ -582,7 +583,7 @@ : (Script*)new Batch(mname); s->AddBaseLanguageGlobalVar(); - int n = 0; + int n = 0; Value* v = args_from_file(setup.args, n); if (s->Compile(setup.script) == 0) diff -Nru metview-5.17.4/metview/src/Macro/matrix.cc metview-5.19.2/metview/src/Macro/matrix.cc --- metview-5.17.4/metview/src/Macro/matrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/matrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,11 +13,11 @@ { // Assumes that m is square double d = 0, p1, p2, p3; - int n = m.Col(); + int n = m.Col(); for (int i = 0; i < n; i++) { p1 = p2 = 1.0; - p3 = m(0, i); + p3 = m(0, i); int k = i; @@ -48,8 +48,8 @@ if (j != i) { for (k = 0; k < cols; k++) { double d = m(i, k); - m(i, k) = m(j, k); - m(j, k) = d; + m(i, k) = m(j, k); + m(j, k) = d; } } for (j = cols - 1; j >= 0; j--) @@ -88,7 +88,7 @@ d(j, n) = (j == 0.0); for (k = 0; k < n; k++) { - ncol = (ncol + 1) % n; + ncol = (ncol + 1) % n; d(j, k) = sm(nrow, ncol); } } @@ -98,7 +98,7 @@ else { nrow = i - 1; for (j = 0; j < n; j++) { - nrow = (nrow + 1) % n; + nrow = (nrow + 1) % n; dm(nrow, i) = d(j, n); } } @@ -500,7 +500,7 @@ c->AddFunction(new MatrixGetElemFunction("[]")); c->AddFunction(new MatrixMulFunction("*")); - //c->AddFunction(new MatrixProdFunction("*")); + // c->AddFunction(new MatrixProdFunction("*")); c->AddFunction(new MatrixAddFunction("+")); c->AddFunction(new MatrixSubFunction("-")); c->AddFunction(new MatrixNegFunction("-")); diff -Nru metview-5.17.4/metview/src/Macro/methods.cc metview-5.19.2/metview/src/Macro/methods.cc --- metview-5.17.4/metview/src/Macro/methods.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/methods.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,8 @@ #include "MvException.h" -namespace metview { +namespace metview +{ void buildOnePolygon(int idx, CVector* vlat, CVector* vlon, std::vector& polygons) { @@ -19,17 +20,18 @@ std::string msg; if (idx == -1) { msg = "latitude and longitude vectors must be the same size!"; - } else { + } + else { msg = "latitude and longitude vectors at index=" + std::to_string(idx) + " must be the same size!"; } - msg += " " + std::to_string(vlat->Count()) + " != " + std::to_string(vlon->Count()); + msg += " " + std::to_string(vlat->Count()) + " != " + std::to_string(vlon->Count()); throw MvException(msg); } // create an eckit polygon std::vector points; points.reserve(vlat->Count()); - for (int i=0; i < vlat->Count(); i++) { + for (int i = 0; i < vlat->Count(); i++) { points.emplace_back((*vlon)[i], (*vlat)[i]); } @@ -48,8 +50,8 @@ { // list of vectors if (arg1->GetType() == tlist) { - CList* latLst=nullptr; - CList* lonLst=nullptr; + CList* latLst = nullptr; + CList* lonLst = nullptr; arg1->GetValue(latLst); arg2->GetValue(lonLst); if (latLst->Count() != lonLst->Count()) { @@ -65,8 +67,9 @@ (*lonLst)[i].GetValue(vlon); metview::buildOnePolygon(i, vlat, vlon, polygons); } - // vectors - } else if (arg1->GetType() == tvector) { + // vectors + } + else if (arg1->GetType() == tvector) { CVector* vlat; CVector* vlon; arg1->GetValue(vlat); @@ -89,10 +92,9 @@ */ void checkStringOption(const char* optionName, int& arity, Value* arg, bool& optionValue, std::string& incorrectOption) { - - optionValue = false; + optionValue = false; incorrectOption = ""; - int option = -1; + int option = -1; if (arity >= 2) { // check the last two arguments to see if one is the option name @@ -142,4 +144,4 @@ } -} +} // namespace metview diff -Nru metview-5.17.4/metview/src/Macro/mflextra.cc metview-5.19.2/metview/src/Macro/mflextra.cc --- metview-5.17.4/metview/src/Macro/mflextra.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/mflextra.cc 2023-07-15 08:28:47.000000000 +0000 @@ -87,7 +87,7 @@ if (arity != 2) return false; - if (arg[0].GetType() != trequest) //first must be a request + if (arg[0].GetType() != trequest) // first must be a request return false; if (arg[1].GetType() != tstring && arg[1].GetType() != tlist) { @@ -171,10 +171,10 @@ if (arity != 3) return false; - if (arg[0].GetType() != trequest) //first must be a request + if (arg[0].GetType() != trequest) // first must be a request return false; - if (arg[1].GetType() != tnumber) //second must be a number + if (arg[1].GetType() != tnumber) // second must be a number return false; if (arg[2].GetType() != tstring && arg[2].GetType() != tlist) { @@ -218,7 +218,7 @@ std::map::const_iterator it; - //A single key is specified + // A single key is specified if (arg[2].GetType() == tstring) { const char* key; arg[2].GetValue(key); @@ -428,9 +428,9 @@ trExe = std::string(mvbin) + "/" + trExe; - //Run the conversion + // Run the conversion std::string cmd = trExe + " \"" + inPath + "\" \"" + outPath + "\""; - //std::cout << cmd << std::endl; + // std::cout << cmd << std::endl; std::stringstream out; std::stringstream err; diff -Nru metview-5.17.4/metview/src/Macro/mgptset.cc metview-5.19.2/metview/src/Macro/mgptset.cc --- metview-5.17.4/metview/src/Macro/mgptset.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/mgptset.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ /* - A GeopointSet is simply a file with + A GeopointSet is simply a file with #GEOPOINTSET @@ -38,7 +38,7 @@ CGeoptSet::CGeoptSet(const CGeoptSet* src) : Content(tgptset) { - vgpts = src->vgpts; + vgpts = src->vgpts; format = src->format; } @@ -73,7 +73,7 @@ fprintf(f, "#GEOPOINTSET\n"); for (unsigned long i = 1; i < Count() + 1; i++) { Content* c = (*this)[i].GetContent(); - e = c->Write(f); + e = c->Write(f); if (e) return e; } @@ -97,8 +97,8 @@ // read each embedded geopoints file from the 'master file' bool readOk = true; while (readOk && !f.eof()) { - auto* gp = new MvGeoPoints(); - readOk = gp->load(f); + auto* gp = new MvGeoPoints(); + readOk = gp->load(f); auto* cgp = new CGeopts(*gp); Add(*(new Value(cgp))); } @@ -247,7 +247,7 @@ { CGeoptSet* g; arg[0].GetValue(g); - //g->load(); + // g->load(); return Value(g->Count()); } @@ -293,7 +293,7 @@ else if (arg[1].GetType() == tgptset) { CGeoptSet* gset2; arg[1].GetValue(gset2); - auto* newgpset = new CGeoptSet(geoset); + auto* newgpset = new CGeoptSet(geoset); unsigned long n = gset2->Count(); for (unsigned long i = 1; i < n + 1; i++) newgpset->Add((*gset2)[i]); @@ -327,7 +327,7 @@ } // otherwise, do the filtering - auto* result = new CGeoptSet(); + auto* result = new CGeoptSet(); unsigned long c = gps->Count(); for (unsigned long i = 1; i <= c; i++) { Value& val = (*gps)[i]; diff -Nru metview-5.17.4/metview/src/Macro/misc.cc metview-5.19.2/metview/src/Macro/misc.cc --- metview-5.17.4/metview/src/Macro/misc.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/misc.cc 2023-07-15 08:28:47.000000000 +0000 @@ -312,7 +312,7 @@ class DescribeFunction : public Function { - bool actionSpecified; + bool actionSpecified{false}; public: DescribeFunction(const char* n) : @@ -343,7 +343,7 @@ Value DescribeFunction::Execute(int, Value* arg) { const char* p; - Context* c = Context::Instruction->Owner(); + Context* c = Context::Instruction->Owner(); int num_matches = 0; arg[0].GetValue(p); @@ -520,7 +520,7 @@ FILE* f; long len; void* buffer = 0; - char* q = 0; + char* q = 0; arg[0].GetValue(t); arg[1].GetValue(p); @@ -535,9 +535,9 @@ // Should check more here,,, fseek(f, 0, SEEK_END); - len = ftell(f); + len = ftell(f); buffer = MALLOC(int(len + 1)); - q = (char*)buffer; + q = (char*)buffer; rewind(f); fread(buffer, 1, (unsigned int)len, f); fclose(f); @@ -575,8 +575,8 @@ Value ArgsFunction::Execute(int, Value*) { Context* c = Context::Instruction->Owner(); - int n = c->Argc(); - Value* v = c->Argv(); + int n = c->Argc(); + Value* v = c->Argv(); auto* l = new CList(n); @@ -608,9 +608,9 @@ Value DictionaryFunction::Execute(int arity, Value*) { using charp = const char*; - Context* c = Context::Instruction->Owner(); - int count = 0; - int all = arity > 0; + Context* c = Context::Instruction->Owner(); + int count = 0; + int all = arity > 0; List* l = (List*)c->Dictionaries()->Head(); while (l) { @@ -637,7 +637,7 @@ auto* names = new charp[count]; count = 0; - l = (List*)c->Dictionaries()->Head(); + l = (List*)c->Dictionaries()->Head(); while (l) { auto* n = (Function*)l->Head(); while (n) { @@ -726,11 +726,11 @@ MvRequest r; r.setVerb("MAGML"); - r("PATH") = magml_file; - r("_MODE") = "MACRO"; - r("PATH") = magml_file; + r("PATH") = magml_file; + r("_MODE") = "MACRO"; + r("PATH") = magml_file; r("_MACRO") = Script::MacroPath(); - r("_PATH") = Script::MacroMainPath(); + r("_PATH") = Script::MacroMainPath(); // call the MagML service directly with this request @@ -770,31 +770,31 @@ { MvRequest out; Value v; - const char* verb = nullptr; + const char* verb = nullptr; const char* service = nullptr; #ifdef ENABLE_UI // check the data type and lauch the correct examiner if (arg[0].GetType() == tgrib) { - verb = "GRIB"; + verb = "GRIB"; service = "UiAppManager"; } else if (arg[0].GetType() == tbufr) { - verb = "BUFR"; + verb = "BUFR"; service = "UiAppManager"; } else if (arg[0].GetType() == tnetcdf) { - verb = "NETCDF"; + verb = "NETCDF"; service = "UiAppManager"; } else if (arg[0].GetType() == todb) { - verb = "ODB_DB"; + verb = "ODB_DB"; service = "UiAppManager"; } else if (arg[0].GetType() == tgeopts) { - verb = "GEOPOINTS"; + verb = "GEOPOINTS"; service = "UiAppManager"; } else { @@ -814,7 +814,7 @@ const char* fff = get_value(datareq, "FIELDSET_FROM_FILTER", 0); if (fff && !strcmp(fff, "1")) { fieldset* fs = request_to_fieldset(datareq); - fieldset* z = copy_fieldset(fs, fs->count, true); + fieldset* z = copy_fieldset(fs, fs->count, true); save_fieldset(z); finalreq = fieldset_to_request(z); } @@ -825,9 +825,9 @@ MvRequest r; r.setVerb(verb); const char* path = get_value(finalreq, "PATH", 0); - r("PATH") = path; - r("_ACTION") = "examine"; - v = Value(service, r); + r("PATH") = path; + r("_ACTION") = "examine"; + v = Value(service, r); #else // warning, but do not fail, as this could be part of an interactive Jupyter session @@ -835,7 +835,7 @@ marslog(LOG_WARN, message.c_str()); if (Context::IsPython()) { std::string message2 = message + "; consider using methods ls() and describe() if using a Fieldset"; - v = Value(message2.c_str()); + v = Value(message2.c_str()); } else v = Value(message.c_str()); @@ -883,7 +883,7 @@ request* datareq; arg[0].GetValue(datareq); const char* path = get_value(datareq, "PATH", 0); - spath = std::string(path); + spath = std::string(path); } std::string kind = ScanFileType(spath.c_str()); @@ -893,7 +893,7 @@ service = "macroedit"; r.setVerb("MACROEDIT"); r("LANGUAGE") = kind.c_str(); - r("_CLASS") = kind.c_str(); + r("_CLASS") = kind.c_str(); } else if (kind == "SCM_INPUT_DATA") { service = "ScmDataEditor"; @@ -906,7 +906,7 @@ // construct the request to launch the editor service r("PATH") = spath.c_str(); - v = Value(service, r); + v = Value(service, r); #else // warning, but do not fail, as this could be part of an interactive Jupyter session diff -Nru metview-5.17.4/metview/src/Macro/mlist.cc metview-5.19.2/metview/src/Macro/mlist.cc --- metview-5.17.4/metview/src/Macro/mlist.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/mlist.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ { static request* r = 0; free_all_requests(r); - r = 0; + r = 0; request *s = 0, *t = 0; for (int i = 0; i < count; i++) { @@ -79,9 +79,9 @@ void CList::Copy(const CList& v) { - count = v.count; + count = v.count; capacity = v.capacity; - values = new Value[capacity]; + values = new Value[capacity]; for (int i = 0; i < count; i++) values[i] = v.values[i]; @@ -89,10 +89,10 @@ void CList::Move(CList&& v) { - count = v.count; + count = v.count; capacity = v.capacity; - values = v.values; + values = v.values; v.values = nullptr; } void CList::Add(const Value& v) @@ -216,7 +216,7 @@ virtual int ValidArguments(int arity, Value* arg); private: - eListIndexType indexType_; + eListIndexType indexType_{LINDEX_NUMBERS}; }; int ListElemFunction::ValidArguments(int arity, Value* arg) @@ -280,7 +280,7 @@ return (*v)[n - 1]; - int c = (m - n) / s + 1; + int c = (m - n) / s + 1; auto* l = new CList(c); int i, j; @@ -361,9 +361,9 @@ Value ListInFunction::Execute(int, Value* arg) { CList* v; - vtype t = arg[0].GetType(); + vtype t = arg[0].GetType(); char* eq = strcache("="); - int x = 0; + int x = 0; arg[1].GetValue(v); OpTest test; @@ -415,9 +415,9 @@ Value ListFindFunction::Execute(int arity, Value* arg) { CList* v; - vtype t = arg[1].GetType(); - char* eq = strcache("="); - int x = 0; + vtype t = arg[1].GetType(); + char* eq = strcache("="); + int x = 0; bool findAll = false; if (arity == 3) { @@ -500,9 +500,9 @@ }; -CList* ListSortFunction::SortList = 0; +CList* ListSortFunction::SortList = 0; const char* ListSortFunction::SortFunc = 0; -Context* ListSortFunction::SortCtxt = 0; +Context* ListSortFunction::SortCtxt = 0; int ListSortFunction::ValidArguments(int arity, Value* arg) { @@ -548,7 +548,7 @@ arg[1].GetValue(SortFunc); - //int *x = (int*)NEW_ARRAY(int,SortList->Count()); // new int seems to crash !!! + // int *x = (int*)NEW_ARRAY(int,SortList->Count()); // new int seems to crash !!! int* x = new int[SortList->Count()]; int i; @@ -606,7 +606,7 @@ { CList* v; char* in = strcache("in"); - int x = 0; + int x = 0; arg[0].GetValue(v); @@ -666,7 +666,7 @@ char* funcname = strcache(Name()); if (v->Count() != w->Count()) { - //marslog(LOG_WARN, "lists have different numbers of elements (%d and %d) - '%s' returning nil", v->Count(), w->Count(), funcname); + // marslog(LOG_WARN, "lists have different numbers of elements (%d and %d) - '%s' returning nil", v->Count(), w->Count(), funcname); return Value(); } diff -Nru metview-5.17.4/metview/src/Macro/module.cc metview-5.19.2/metview/src/Macro/module.cc --- metview-5.17.4/metview/src/Macro/module.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/module.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ void Module::Dispatch(svcid* id, request* r) { - SvcId = id; + SvcId = id; mars.outproc = PutMessage; Value v; @@ -71,7 +71,7 @@ send_reply(id, r); } - SvcId = 0; + SvcId = 0; mars.outproc = 0; strfree(p); diff -Nru metview-5.17.4/metview/src/Macro/mstring.cc metview-5.19.2/metview/src/Macro/mstring.cc --- metview-5.17.4/metview/src/Macro/mstring.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/mstring.cc 2023-07-15 08:28:47.000000000 +0000 @@ -147,10 +147,10 @@ chr[1] = '\0'; int cnt = strlen(p); - l = new CList(cnt); + l = new CList(cnt); for (int i = 0; i < cnt; ++i) { - chr[0] = p[i]; + chr[0] = p[i]; (*l)[i] = Value(chr); } } @@ -231,7 +231,7 @@ } else { int sslen = c2 - c1 + 1; //-- substring length - char* ss = new char[sslen + 1]; + char* ss = new char[sslen + 1]; strncpy(ss, (s + c1 - 1), sslen); ss[sslen] = '\0'; //-- make sure ss is terminated diff -Nru metview-5.17.4/metview/src/Macro/mtable.cc metview-5.19.2/metview/src/Macro/mtable.cc --- metview-5.17.4/metview/src/Macro/mtable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/mtable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ loaded_(false), ok_(true) { - //odb_=0; + // odb_=0; r = clone_all_requests(s); if (r) { @@ -101,10 +101,10 @@ /* long CTable::Count() -{ +{ if(odb_) { - return odb_->rowNum(); + return odb_->rowNum(); } else { @@ -132,8 +132,8 @@ int CTable::Write(FILE* /*f*/) { - //unload(); - //return CopyFile(get_value(r,"PATH",0),f); + // unload(); + // return CopyFile(get_value(r,"PATH",0),f); printf("CTable::Write\n"); return 1; } @@ -178,7 +178,7 @@ void CTable::ToRequest(request*& s) { Attach(); // Temp fix: if someone want the request - //unload(); + // unload(); s = r; } @@ -331,14 +331,14 @@ else if (!strcmp(upper_param, "TABLE_COLUMNS")) if (type == tlist) SimpleListToRequestParameter(r, upper_param, list); - //set_list(r, upper_param, list); + // set_list(r, upper_param, list); else set_value(r, upper_param, value); else if (!strcmp(upper_param, "TABLE_COLUMN_TYPES")) if (type == tlist) SimpleListToRequestParameter(r, upper_param, list); - //set_list(r, upper_param, list); + // set_list(r, upper_param, list); else { char paramCopy[1024]; strcpy(paramCopy, upper_param); @@ -348,7 +348,7 @@ else if (!strcmp(upper_param, "TABLE_META_DATA_ROWS")) if (type == tlist) SimpleListToRequestParameter(r, upper_param, list); - //set_list(r, upper_param, list); + // set_list(r, upper_param, list); else set_value(r, upper_param, value); @@ -358,7 +358,7 @@ // find the file that we want to load - //const char *p = get_value(request,"FILENAME",0); + // const char *p = get_value(request,"FILENAME",0); auto* table = new CTable(r); if (!table->constructedOk()) { @@ -393,7 +393,7 @@ class TableValuesFunction : public Function { - bool fieldFromName_; + bool fieldFromName_{false}; public: TableValuesFunction(const char* n) : @@ -453,7 +453,7 @@ int colNum; arg[1].GetValue(colNum); // second arg is the index of the desired column int baseIndex = Context::BaseIndex(); - int colIndex = colNum - baseIndex; // our internal indexes are zero-based + int colIndex = colNum - baseIndex; // our internal indexes are zero-based if (colIndex < 0 || colIndex > ctable->Count() - 1) // index bounds check @@ -477,14 +477,14 @@ if (col->type() == MvTableColumn::COL_NUMBER) { auto* v = new CVector(col->count()); // vectors can only hold numbers - c = v; + c = v; for (int i = 0; i < col->count(); i++) { v->setIndexedValue(i, col->dVals().at(i)); } } else if (col->type() == MvTableColumn::COL_STRING) { auto* v = new CList(col->count()); // we need a list to hold strings - c = v; + c = v; for (int i = 0; i < col->count(); i++) { (*v)[i] = col->sVals().at(i).c_str(); } @@ -567,7 +567,7 @@ auto* v = new CList(metadata.size()); // we need a list to hold strings - auto iter = metadata.begin(); + auto iter = metadata.begin(); auto iter_end = metadata.end(); int i = 0; @@ -590,7 +590,7 @@ SINGLE, LIST }; - eModeType mode; + eModeType mode{SINGLE}; public: TableMetaDataValueFunction(const char* n) : diff -Nru metview-5.17.4/metview/src/Macro/mvector.cc metview-5.19.2/metview/src/Macro/mvector.cc --- metview-5.17.4/metview/src/Macro/mvector.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/mvector.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ /* To do: (o = to do, * = done) - + * allow nil & vector * allow vector & vector * vector op vector @@ -149,13 +149,13 @@ void CArrayF64::allocateMemory(int numElements) { - size = numElements; + size = numElements; values = new double[numElements]; } void CArrayF32::allocateMemory(int numElements) { - size = numElements; + size = numElements; values = new float[numElements]; } @@ -234,7 +234,7 @@ if (size > 0) { delete[] values; values = 0; - size = 0; + size = 0; } } @@ -243,7 +243,7 @@ if (size > 0) { delete[] values; values = 0; - size = 0; + size = 0; } } @@ -253,7 +253,7 @@ std::memcpy(newValues, values, newSize * sizeof(double)); delete[] values; values = newValues; - size = newSize; + size = newSize; for (int i = size; i < newSize; i++) // pad extra elements with zeros values[i] = 0.0; } @@ -264,7 +264,7 @@ std::memcpy(newValues, values, newSize * sizeof(float)); delete[] values; values = newValues; - size = newSize; + size = newSize; for (int i = size; i < newSize; i++) // pad extra elements with zeros values[i] = 0.0; } @@ -650,7 +650,7 @@ /* - int err = read_vector_from_request(r, double** vec, int* length ) + int err = read_vector_from_request(r, double** vec, int* length ) const char* c = get_value( r, "SIZE", 0 ); size = (fortint)atoi(c); @@ -718,28 +718,28 @@ /* int CVector::Read(FILE *f) { - size_t read; - int size; - char buf[20]; + size_t read; + int size; + char buf[20]; - fread (buf, sizeof(char), 14, f); - buf[14] = '\0'; + fread (buf, sizeof(char), 14, f); + buf[14] = '\0'; - if (strcmp(buf, "METVIEW_VECTOR")) - { - Error("Start of vector file should be METVIEW_VECTOR."); - } + if (strcmp(buf, "METVIEW_VECTOR")) + { + Error("Start of vector file should be METVIEW_VECTOR."); + } - read = fread (&size, sizeof(int), 1, f); // write the number of values - written = fwrite (values, sizeof(double), size, f); // write the values + read = fread (&size, sizeof(int), 1, f); // write the number of values + written = fwrite (values, sizeof(double), size, f); // write the values - if (written != size) - { - Error("Tried to write %d elements - managed %d.", size, written); - } + if (written != size) + { + Error("Tried to write %d elements - managed %d.", size, written); + } - return ferror(f); + return ferror(f); } */ @@ -759,7 +759,7 @@ r = empty_request("VECTOR"); char* path = marstmp(); - FILE* f = fopen(path, "w"); + FILE* f = fopen(path, "w"); if (f) { Write(f); @@ -769,7 +769,7 @@ x = r; if (mars.debug) print_all_requests(r); - //Attach(); // Temp fix: if someone want the request + // Attach(); // Temp fix: if someone want the request } else { Error("Failed to open temporary file for writing: %s", path); @@ -777,19 +777,19 @@ /* static request *r = 0; - if(r == 0) - r = empty_request("VECTOR"); + if(r == 0) + r = empty_request("VECTOR"); - set_value( r, "SIZE", "%d", size ); - set_value( r, "VALUES", "%g", size > 0 ? values[0] : 0 ); - for( int i = 1; i < size; ++i ) - { - add_value( r, "VALUES", "%g", values[i] ); - } - - if (mars.debug) - print_all_requests(r); - x = r;*/ + set_value( r, "SIZE", "%d", size ); + set_value( r, "VALUES", "%g", size > 0 ? values[0] : 0 ); + for( int i = 1; i < size; ++i ) + { + add_value( r, "VALUES", "%g", values[i] ); + } + + if (mars.debug) + print_all_requests(r); + x = r;*/ } @@ -865,9 +865,9 @@ void CVector::Resize(int newSize) { - const int memorySavingThreshold = 1024 * 1024; // we will resize if it will save us this much memory (bytes) - const int numElementsThreshold = memorySavingThreshold / sizeof(double); // expressed as number of elements - int size = Count(); + const int memorySavingThreshold = 1024 * 1024; // we will resize if it will save us this much memory (bytes) + const int numElementsThreshold = memorySavingThreshold / sizeof(double); // expressed as number of elements + int size = Count(); if (newSize == size) // shortcut for the trivial case return; @@ -1209,7 +1209,7 @@ fractionalIndex = 0.0; else if (fractionalIndex > (Count() - 1)) fractionalIndex = Count() - 1; - int nearestIndex = (int)(fractionalIndex + 0.5); // nearest neighbour; may add more modes + int nearestIndex = (int)(fractionalIndex + 0.5); // nearest neighbour; may add more modes double foundValue = getIndexedValue(nearestIndex); result.setIndexedValue(pi, foundValue); } @@ -1221,31 +1221,31 @@ /* class VectorProductFunction : public Function { public: - VectorProductFunction(char *n) : Function(n,2,tvector,tvector) - {info = "Vector product";}; - virtual Value Execute(int arity,Value *arg); + VectorProductFunction(char *n) : Function(n,2,tvector,tvector) + {info = "Vector product";}; + virtual Value Execute(int arity,Value *arg); }; Value VectorProductFunction::Execute(int ,Value *arg) { - CVector *a; - CVector *b; - CVector *c; - - arg[0].GetValue(a); - arg[1].GetValue(b); - - if(a->Count() != b->Count()) - return Error("Cannot multiply vectors of different sizes: %d <> %d", - a->Count(),b->Count()); - - c = new CVector(a->Count()); - - for(int i=0;iCount();i++) - ; - - return Value(c); + CVector *a; + CVector *b; + CVector *c; + + arg[0].GetValue(a); + arg[1].GetValue(b); + + if(a->Count() != b->Count()) + return Error("Cannot multiply vectors of different sizes: %d <> %d", + a->Count(),b->Count()); + + c = new CVector(a->Count()); + + for(int i=0;iCount();i++) + ; + + return Value(c); } */ @@ -1293,10 +1293,10 @@ class Vector2Function : public Function { - bool fromList; + bool fromList{false}; public: - Vector2Function(const char* n) : + explicit Vector2Function(const char* n) : Function(n, 1, tnumber) { info = "Builds a new vector either with 'n' zero elements or populated from a list"; @@ -1489,7 +1489,7 @@ virtual int ValidArguments(int arity, Value* arg); private: - eVectorIndexType indexType_; + eVectorIndexType indexType_{VINDEX_NUMBERS}; }; int VectorGetElemFunction::ValidArguments(int arity, Value* arg) @@ -1528,8 +1528,8 @@ if (indexType_ == VINDEX_NUMBERS) { CVector* v; int first; - int last = 0; // index of first element - int step = 0; // step + int last = 0; // index of first element + int step = 0; // step int length = 1; // how many we extract at each step arg[0].GetValue(v); @@ -1562,7 +1562,7 @@ return (*v)[first - 1]; } - int c = ((last - first) / step + 1) * length; + int c = ((last - first) / step + 1) * length; auto* vnew = new CVector(c); int i, j; @@ -2355,7 +2355,7 @@ Value MeanVectorFunction::Execute(int, Value* arg) { CVector* g; - double dSum = 0.0; + double dSum = 0.0; int nNumValid = 0; arg[0].GetValue(g); @@ -2468,7 +2468,7 @@ if (arg[1].GetType() != tlist && arg[1].GetType() != tvector && arg[1].GetType() != tnumber) return false; - //if ((arity == 3) && arg[2].GetType() != tstring) // if we do multiple interpolation types + // if ((arity == 3) && arg[2].GetType() != tstring) // if we do multiple interpolation types // return false; return true; @@ -2499,7 +2499,7 @@ int numPercentiles = percents->Count(); - int numVectors = listOfInputVectors->Count(); + int numVectors = listOfInputVectors->Count(); CVector* c; (*listOfInputVectors)[0].GetValue(c); int numValsInVector = c->Count(); @@ -2519,8 +2519,8 @@ if (resultIsList) listOfResults = new CList(numPercentiles); - auto* row = new CVector(numVectors); - auto* pthPercentile = new CVector(numValsInVector); + auto* row = new CVector(numVectors); + auto* pthPercentile = new CVector(numValsInVector); auto* temporaryPercentiles = new CVector(numPercentiles); // loop over each 'row' of the input vectors and construct a new vector from it - we will compute the p'ctiles from this @@ -2581,7 +2581,7 @@ c->AddFunction(new VectorGetElemFunction("[]")); c->AddFunction(new VectorSetTypeFunction("vector_set_default_type")); c->AddFunction(new VectorDTypeFunction("dtype")); - //c->AddFunction(new VectorProductFunction("^")); + // c->AddFunction(new VectorProductFunction("^")); c->AddFunction(new VectorMergeFunction("&")); c->AddFunction(new VectorMergeFunction("merge")); diff -Nru metview-5.17.4/metview/src/Macro/mvimport.c metview-5.19.2/metview/src/Macro/mvimport.c --- metview-5.17.4/metview/src/Macro/mvimport.c 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/mvimport.c 2023-07-15 08:28:47.000000000 +0000 @@ -74,7 +74,7 @@ static int cvtdates = 0; -static char tab[256] = ""; /* either a tab string or else a row of spaces, set in main() */ +static char tab[256] = ""; /* either a tab string or else a row of spaces, set in main() */ static boolean spaces = false; static void putdate(FILE* f, long date) @@ -117,8 +117,8 @@ static const char* low(const char* s, int under, int clean) { static char buf[1024]; - int i = 0; - int c = 0; + int i = 0; + int c = 0; buf[0] = 0; if (under && !isalpha(*s)) { @@ -247,8 +247,8 @@ { static cache* langs = NULL; cache* c; - char* obj = strcache("object"); - request* r = mars.setup; + char* obj = strcache("object"); + request* r = mars.setup; const char* file = NULL; while (r) { @@ -275,9 +275,9 @@ } if (c == NULL) { - c = NEW_CLEAR(cache); + c = NEW_CLEAR(cache); c->next = langs; - langs = c; + langs = c; c->name = strcache(file); c->lang = read_language_file(file); } @@ -385,8 +385,8 @@ static void import_values(FILE* f, request* r, parameter* p) { - value* v = p->values; - int flg = v && v->next; + value* v = p->values; + int flg = v && v->next; int dateflg = 0; if (strcmp(p->name, "DATE") == 0 && cvtdates) @@ -423,8 +423,8 @@ /*fprintf(f,"\n",pch);*/ /*fprintf(f,"string inline\n"); - fprintf(f,"%s\n",v->name); - fprintf(f,"%s%s%stend inline", tab, tab, tab);*/ + fprintf(f,"%s\n",v->name); + fprintf(f,"%s%s%stend inline", tab, tab, tab);*/ } } else if (isdate(v->name)) @@ -463,9 +463,9 @@ return false; { - parameter* p0 = find_parameter(r, "PARAMETER"); - parameter* p1 = find_parameter(r, "PARAMETER_1"); - parameter* p2 = find_parameter(r, "PARAMETER_2"); + parameter* p0 = find_parameter(r, "PARAMETER"); + parameter* p1 = find_parameter(r, "PARAMETER_1"); + parameter* p2 = find_parameter(r, "PARAMETER_2"); const char* fn = get_value(r, "FUNCTION", 0); const char* op = get_value(r, "OPERATOR", 0); @@ -523,14 +523,14 @@ if (quote) { char c = '\''; - q = p; + q = p; while (*q) if (*q++ == '\'') c = '"'; - i = 0; + i = 0; buf[i++] = c; - q = p; + q = p; while (*q) { if (*q == c) buf[i++] = '\\'; @@ -548,12 +548,16 @@ const char* m = NULL; parameter* p; + if (!r) { + return false; + } + if (strncmp(r->name, "SAMPLE_FORMULA", strlen("SAMPLE_FORMULA")) == 0) return import_simple_formula(f, icon, r); /* Note: TABLE_READER does not have an associated macro in - ObjecList because we want to over-ride it here. */ + ObjecList because we want to over-ride it here. */ if (strncmp(r->name, "TABLE_READER", strlen("TABLE_READER")) == 0) m = "read_table"; @@ -573,12 +577,12 @@ p = r->params; /* if using spaces, then we can be more clever in how we align - the colons after the parameter names; start by finding the length - of the longest parameter name. */ + the colons after the parameter names; start by finding the length + of the longest parameter name. */ if (spaces) { while (p) { const char* str = clean(low(p->name, 0, 0)); - size_t thislen = strlen(str); + size_t thislen = strlen(str); if (thislen > maxlen) maxlen = thislen; @@ -591,7 +595,7 @@ while (p) { const char* str = clean(low(p->name, 0, 0)); - size_t thislen = strlen(str); + size_t thislen = strlen(str); size_t i; fprintf(f, "%s%s", tab, clean(low(p->name, 0, 0))); if (spaces) { @@ -732,9 +736,9 @@ boolean import_read(FILE* f, const char* icon, request* r) { /* if only PATH is set, use the read function */ - parameter* p = r->params; + parameter* p = r->params; const char* path = get_value(r, "SOURCE", 0); - int n = 0; + int n = 0; while (p) { if (*p->name != '_') @@ -803,7 +807,7 @@ char buf[1024]; char dot[1024]; char icon[1024]; - boolean ok = false; + boolean ok = false; const char* c = NULL; request *r, *u; @@ -845,7 +849,7 @@ } if (!ok && (r != NULL || c != NULL)) { - request* u = find_object(r ? r->name : c); + request* u = find_object(r ? r->name : c); const char* t = u ? get_value(u, "type", 0) : NULL; if (t) { @@ -911,7 +915,7 @@ sprintf(buf, "%s", m->name); if (*buf == '"' || *buf == '\'') { - p = buf + 1; + p = buf + 1; buf[strlen(buf) - 1] = 0; } @@ -974,7 +978,7 @@ static request* link1(FILE* f, request* r) { request* s = empty_request(NULL); - r = r->next; + r = r->next; while (r) { request* u = find_object(get_value(r, "CLASS", 0)); if (u) @@ -1042,9 +1046,9 @@ FILE* f; request* u; const char* p; - int n = 0; + int n = 0; const char* userd = getenv("METVIEW_USER_DIRECTORY"); - long now = mars_julian_to_date(mars_date_to_julian(0), 1); + long now = mars_julian_to_date(mars_date_to_julian(0), 1); /* mars.debug = 1; */ /* print_all_requests(r); */ @@ -1136,20 +1140,20 @@ } else /* - argv[1]: path to icon file - argv[2]: path to output file - argv[3]: number of spaces to use instead of tabs (optional) */ + argv[1]: path to icon file + argv[2]: path to output file + argv[3]: number of spaces to use instead of tabs (optional) */ if (argc > 3) { - int num_spaces = atoi(argv[3]); - int i; - spaces = true; - for (i = 0; i < num_spaces; i++) - tab[i] = ' '; - tab[i] = '\0'; - } - else - strcpy(tab, "\t"); + int num_spaces = atoi(argv[3]); + int i; + spaces = true; + for (i = 0; i < num_spaces; i++) + tab[i] = ' '; + tab[i] = '\0'; + } + else + strcpy(tab, "\t"); import(fopen(argv[2], "w"), argv[1]); return 0; diff -Nru metview-5.17.4/metview/src/Macro/mvimportDesktop.c metview-5.19.2/metview/src/Macro/mvimportDesktop.c --- metview-5.17.4/metview/src/Macro/mvimportDesktop.c 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/mvimportDesktop.c 2023-07-15 08:28:47.000000000 +0000 @@ -80,7 +80,7 @@ translation macro_translations[] = {}; translation* translations = macro_translations; -size_t num_translations = sizeof(macro_translations) / sizeof(translation); +size_t num_translations = sizeof(macro_translations) / sizeof(translation); const char* import(FILE* f, const char* icon, const char* className); @@ -95,16 +95,16 @@ static int cvtdates = 0; -static char tab[256] = ""; // tab string or row of spaces -static boolean spaces = false; +static char tab[256] = ""; // tab string or row of spaces +static boolean spaces = false; static char language_[64] = "macro"; // macro or python -static char prefix_[8] = ""; // empty or "mv." +static char prefix_[8] = ""; // empty or "mv." static char separator_[2] = ":"; // : or = static const char* translate(const char* from) { - int i; + int i = 0; /* look it up in the translation table */ for (i = 0; i < num_translations; i++) { @@ -167,8 +167,8 @@ static const char* low(const char* s, int under, int clean) { static char buf[1024]; - int i = 0; - int c = 0; + int i = 0; + int c = 0; buf[0] = 0; if (under && !isalpha(*s)) { @@ -304,8 +304,8 @@ { static cache* langs = NULL; cache* c; - char* obj = strcache("object"); - request* r = mars.setup; + char* obj = strcache("object"); + request* r = mars.setup; const char* file = NULL; while (r) { @@ -332,9 +332,9 @@ } if (c == NULL) { - c = NEW_CLEAR(cache); + c = NEW_CLEAR(cache); c->next = langs; - langs = c; + langs = c; c->name = strcache(file); c->lang = read_language_file(file); } @@ -442,8 +442,8 @@ static void import_values(FILE* f, request* r, parameter* p) { - value* v = p->values; - int flg = v && v->next; + value* v = p->values; + int flg = v && v->next; int dateflg = 0; if (strcmp(p->name, "DATE") == 0 && cvtdates) @@ -480,8 +480,8 @@ /*fprintf(f,"\n",pch);*/ /*fprintf(f,"string inline\n"); - fprintf(f,"%s\n",v->name); - fprintf(f,"%s%s%stend inline", tab, tab, tab);*/ + fprintf(f,"%s\n",v->name); + fprintf(f,"%s%s%stend inline", tab, tab, tab);*/ } } else if (isdate(v->name)) @@ -520,9 +520,9 @@ return false; { - parameter* p0 = find_parameter(r, "PARAMETER"); - parameter* p1 = find_parameter(r, "PARAMETER_1"); - parameter* p2 = find_parameter(r, "PARAMETER_2"); + parameter* p0 = find_parameter(r, "PARAMETER"); + parameter* p1 = find_parameter(r, "PARAMETER_1"); + parameter* p2 = find_parameter(r, "PARAMETER_2"); const char* fn = get_value(r, "FUNCTION", 0); const char* op = get_value(r, "OPERATOR", 0); @@ -580,14 +580,14 @@ if (quote) { char c = '\''; - q = p; + q = p; while (*q) if (*q++ == '\'') c = '"'; - i = 0; + i = 0; buf[i++] = c; - q = p; + q = p; while (*q) { if (*q == c) buf[i++] = '\\'; @@ -605,12 +605,16 @@ const char* m = NULL; parameter* p; + if (!r) { + return false; + } + if (strncmp(r->name, "SAMPLE_FORMULA", strlen("SAMPLE_FORMULA")) == 0) return import_simple_formula(f, icon, r); /* Note: TABLE_READER does not have an associated macro in - ObjecList because we want to over-ride it here. */ + ObjecList because we want to over-ride it here. */ if (strncmp(r->name, "TABLE_READER", strlen("TABLE_READER")) == 0) m = "read_table"; @@ -630,12 +634,12 @@ p = r->params; /* if using spaces, then we can be more clever in how we align - the colons after the parameter names; start by finding the length - of the longest parameter name. */ + the colons after the parameter names; start by finding the length + of the longest parameter name. */ if (spaces) { while (p) { const char* str = clean(low(p->name, 0, 0)); - size_t thislen = strlen(str); + size_t thislen = strlen(str); if (thislen > maxlen) maxlen = thislen; @@ -648,7 +652,7 @@ while (p) { const char* str = translate(clean(low(p->name, 0, 0))); - size_t thislen = strlen(str); + size_t thislen = strlen(str); size_t i; fprintf(f, "%s%s", tab, str); if (spaces) { @@ -735,7 +739,7 @@ strcpy(name, low(mbasename(icon), 1, 1)); - //We emulate the old dot request! + // We emulate the old dot request! request* dot = empty_request("USER_INTERFACE"); set_value(dot, "ICON_CLASS", "MACROPARAM"); set_value(dot, "macro", ""); @@ -795,9 +799,9 @@ boolean import_read(FILE* f, const char* icon, request* r) { /* if only PATH is set, use the read function */ - parameter* p = r->params; + parameter* p = r->params; const char* path = get_value(r, "SOURCE", 0); - int n = 0; + int n = 0; while (p) { if (*p->name != '_') @@ -864,7 +868,7 @@ boolean import_weather_symbol(FILE* f, const char* icon, const char* className) { char buf[1024]; - request* r = NULL; + request* r = NULL; boolean ret = false; if (strcmp(className, "WS_COLLECTION") == 0) { r = empty_request("WS_COLLECTION"); @@ -875,7 +879,7 @@ const char* fTmp = marstmp(); sprintf(buf, "$METVIEW_BIN/MvWsToRequest \"%s\" %s", icon, fTmp); if (system(buf) == 0) { - r = read_request_file(fTmp); + r = read_request_file(fTmp); ret = import_request(f, icon, r, NULL); } } @@ -889,7 +893,7 @@ char dot[1024]; char icon[1024]; char cname[256]; - boolean ok = false; + boolean ok = false; const char* c = 0; request *r = NULL, *u = NULL; @@ -908,8 +912,8 @@ strcpy(cname, className); c = &cname[0]; } - //If the classname is not present we need to find out the iconclass from - //the folder-level dot file + // If the classname is not present we need to find out the iconclass from + // the folder-level dot file else { if (get_iconClass(buf, cname) == 0) c = &cname[0]; @@ -926,17 +930,17 @@ r = read_request_file(buf); - /*We need to read the request again (into *u) otherwise mars cannot read the - PARAMETER_2 subrequest from the request below: - - SIMPLE_FORMULA_FAMILY, - FORMULA = SAMPLE_FORMULA_DOD - - SAMPLE_FORMULA_DOD, - PARAMETER_1 = GRIB Filter 1, - PARAMETER_2 = GRIB Filter 1 + /*We need to read the request again (into *u) otherwise mars cannot read the + PARAMETER_2 subrequest from the request below: - The reason for this behaviour is unclear at the moment*/ + SIMPLE_FORMULA_FAMILY, + FORMULA = SAMPLE_FORMULA_DOD + + SAMPLE_FORMULA_DOD, + PARAMETER_1 = GRIB Filter 1, + PARAMETER_2 = GRIB Filter 1 + + The reason for this behaviour is unclear at the moment*/ u = read_request_file(buf); @@ -962,7 +966,7 @@ } if (!ok && (r != NULL || c != NULL)) { - request* v = find_object(c ? c : r->name); + request* v = find_object(c ? c : r->name); const char* t = v ? get_value(v, "type", 0) : NULL; if (t) { @@ -978,13 +982,16 @@ } } - if (!ok && (r != NULL) && (c = r->name)) { - if (strcmp(c, "LINK") == 0) - ok = import_link(f, icon, r); - else if (strcmp(c, "COMPUTE") == 0) - ok = import_compute(f, icon, r); - else - ok = import_request(f, icon, r, NULL); + if (!ok && (r != NULL)) { + c = r->name; + if (c) { + if (strcmp(c, "LINK") == 0) + ok = import_link(f, icon, r); + else if (strcmp(c, "COMPUTE") == 0) + ok = import_compute(f, icon, r); + else + ok = import_request(f, icon, r, NULL); + } } if (!ok) { @@ -1015,13 +1022,13 @@ FILE* fp; if ((fp = fopen(dot, "r")) != NULL) { while (fgets(buff, 1024, fp)) { - //Remove end of line + // Remove end of line char* nlptr = strchr(buff, '\n'); if (nlptr) *nlptr = '\0'; - //Find string after the third "," - int cnt = 0; + // Find string after the third "," + int cnt = 0; const char* cp = &buff[0]; const char *c1 = 0, *c2 = 0; cp = strstr(cp, ","); @@ -1074,7 +1081,7 @@ sprintf(buf, "%s", m->name); if (*buf == '"' || *buf == '\'') { - p = buf + 1; + p = buf + 1; buf[strlen(buf) - 1] = 0; } @@ -1137,7 +1144,7 @@ static request* link1(FILE* f, request* r) { request* s = empty_request(NULL); - r = r->next; + r = r->next; while (r) { request* u = find_object(get_value(r, "CLASS", 0)); if (u) @@ -1205,9 +1212,9 @@ FILE* f; request* u; const char* p; - int n = 0; + int n = 0; const char* userd = getenv("METVIEW_USER_DIRECTORY"); - long now = mars_julian_to_date(mars_date_to_julian(0), 1); + long now = mars_julian_to_date(mars_date_to_julian(0), 1); /* mars.debug = 1; */ /* print_all_requests(r); */ @@ -1316,8 +1323,8 @@ // Get input info const char* iconName = argv[1]; - FILE* f = fopen(argv[2], "w"); - const char* cclass = NULL; + FILE* f = fopen(argv[2], "w"); + const char* cclass = NULL; strcpy(tab, "\t"); if (argc == 4) @@ -1347,7 +1354,7 @@ if (strcmp(language_, "python") == 0) { strcpy(prefix_, "mv."); strcpy(separator_, "="); - translations = python_translations; + translations = python_translations; num_translations = sizeof(python_translations) / sizeof(translation); } diff -Nru metview-5.17.4/metview/src/Macro/netcdf.cc metview-5.19.2/metview/src/Macro/netcdf.cc --- metview-5.17.4/metview/src/Macro/netcdf.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/netcdf.cc 2023-07-15 08:28:47.000000000 +0000 @@ -72,7 +72,7 @@ mode_(mode) { r_ = empty_request("NETCDF"); - //set_value(r_,"PATH","%s",p); + // set_value(r_,"PATH","%s",p); set_value(r_, "PATH", "%s", FullPathName(p).c_str()); set_value(r_, "TEMPORARY", "%d", temp); } @@ -99,7 +99,7 @@ load(); int count = netCDF_->getNumberOfVariables(); - auto* l = new CList(count); + auto* l = new CList(count); for (int i = 0; i < count; i++) (*l)[i] = netCDF_->getVariable(i)->name(); @@ -279,7 +279,7 @@ class CDFValuesFunction : public Function { - bool listOfDims; + bool listOfDims{false}; public: CDFValuesFunction(const char* n) : @@ -329,7 +329,7 @@ if (nr_dims > 0) //-- arrays of data { long num_values = 1; - long* dim = aVar->edges(); //-- ~MvNcVar deletes! + long* dim = aVar->edges(); //-- ~MvNcVar deletes! if (aVar->type() == ncChar) //-- string (char) data - we will return a list of strings { @@ -416,7 +416,7 @@ if (pos == 0) // selected dimension? { indexOfSelectedDimension = i; - pos = 1; // we will start at the first element of this dimension + pos = 1; // we will start at the first element of this dimension } vPositionList.push_back(pos - 1); // user supplies 1-based indexes, we want 0-based @@ -522,8 +522,8 @@ int indexOffset = 1 - Context::BaseIndex(); // 0(Macro) or 1(Python) elem += indexOffset; long num_values = 1; - int nr_dims = aVar->getNumberOfDimensions(); - long* dim = aVar->edges(); //-- ~MvNcVar deletes! + int nr_dims = aVar->getNumberOfDimensions(); + long* dim = aVar->edges(); //-- ~MvNcVar deletes! if (aVar->type() == ncChar) //-- string (char) data - we will return a list of strings { @@ -539,7 +539,7 @@ str[string_length] = '\0'; //-- terminating NULL int index = 0; - elem = string_length * (elem - 1); + elem = string_length * (elem - 1); for (long j = 0; j < string_length; ++j) { str[index++] = aVar->as_char(elem++); //-- padding spaces at the end seem to be automagically removed, } //-- so we don't need to worry about them! @@ -590,8 +590,8 @@ MvNcVar* aVar = a->GetVar(); long* edges = aVar->edges(); - int nrDims = aVar->getNumberOfDimensions(); - auto* l = new CList(nrDims); + int nrDims = aVar->getNumberOfDimensions(); + auto* l = new CList(nrDims); for (int i = 0; i < nrDims; i++) (*l)[i] = edges[i]; @@ -618,7 +618,7 @@ MvNcVar* aVar = a->GetVar(); int nrDims = aVar->getNumberOfDimensions(); - auto* l = new CList(nrDims); + auto* l = new CList(nrDims); for (int i = 0; i < nrDims; i++) (*l)[i] = aVar->getDimension(i)->name(); diff -Nru metview-5.17.4/metview/src/Macro/number.cc metview-5.19.2/metview/src/Macro/number.cc --- metview-5.17.4/metview/src/Macro/number.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/number.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,7 @@ #include "arith.h" -long CNumber::sPrec = 0; //-- cout precision, default set in serve_macro(...) +long CNumber::sPrec = 0; //-- cout precision, default set in serve_macro(...) long CNumber::sDefaultPrec = 12; @@ -185,7 +185,7 @@ arg[1].GetValue(d); double sgn = v < 0 ? -1.0 : 1.0; - double e1 = pow(10.0, d); + double e1 = pow(10.0, d); if (v < 0) v = -v; @@ -231,7 +231,7 @@ Value NumberPrecision::Execute(int arity, Value* arg) { long oldPrec = CNumber::GetPrecision(); - long prec = CNumber::GetDefaultPrecision(); //-- precision not given + long prec = CNumber::GetDefaultPrecision(); //-- precision not given if (arity == 1) arg[0].GetValue(prec); //-- precision given diff -Nru metview-5.17.4/metview/src/Macro/object.cc metview-5.19.2/metview/src/Macro/object.cc --- metview-5.17.4/metview/src/Macro/object.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/object.cc 2023-07-15 08:28:47.000000000 +0000 @@ -162,7 +162,7 @@ // Binary op // int i; - //for(i=0;BinOps[i].symb;i++) + // for(i=0;BinOps[i].symb;i++) // c->AddFunction(new CdfCdfBinOp(BinOps[i].symb,BinOps[i].proc )); // for(i=0;BinOps[i].symb;i++) diff -Nru metview-5.17.4/metview/src/Macro/perlaccess.cc metview-5.19.2/metview/src/Macro/perlaccess.cc --- metview-5.17.4/metview/src/Macro/perlaccess.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/perlaccess.cc 2023-07-15 08:28:47.000000000 +0000 @@ -62,7 +62,7 @@ const char* path = (argc > 1) ? argv[1] : "/dev/null"; const char* mode = (argc > 2) ? argv[2] : "edit"; - const char* req = (argc > 3) ? argv[3] : "/dev/null"; + const char* req = (argc > 3) ? argv[3] : "/dev/null"; svc* s = create_service(progname()); @@ -75,7 +75,7 @@ if (argc > 3) { request* v = empty_request("MACROPARAM"); set_subrequest(v, "MACRO", r); - r = v; + r = v; r->next = u; } diff -Nru metview-5.17.4/metview/src/Macro/python.cc metview-5.19.2/metview/src/Macro/python.cc --- metview-5.17.4/metview/src/Macro/python.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/python.cc 2023-07-15 08:28:47.000000000 +0000 @@ -70,7 +70,7 @@ // the data file char pwd[1024]; getcwd(pwd, sizeof(pwd) - 1); - //Script::MacroPath(makepath(pwd,"PythonScript.py")); // dummy filename + // Script::MacroPath(makepath(pwd,"PythonScript.py")); // dummy filename Script::MacroMainPath(makepath(pwd, "PythonScript.py")); // dummy filename doneInit = true; } @@ -89,9 +89,9 @@ void p_init() { - //printf("Metview::p_init called from Python\n"); + // printf("Metview::p_init called from Python\n"); progName = "Python"; - argv[0] = progName; + argv[0] = progName; mp_init(1, argv); } @@ -107,18 +107,18 @@ const char* p_call_function(const char* name, int arity) { - //printf("MARS: %s\n", mars.langfile); - //printf("MARS: %s\n", mars.mars_home); + // printf("MARS: %s\n", mars.langfile); + // printf("MARS: %s\n", mars.mars_home); char* fname = strcache(name); - //printf("Calling function %s with %d args!\n", name, arity); + // printf("Calling function %s with %d args!\n", name, arity); metviewPythonScript->SetError(0); // reset the error flag metviewPythonScript->CallFunction(fname, arity); - //printf("Calling finished!\n\n"); + // printf("Calling finished!\n\n"); // if there was an error, we should return a CError value if (metviewPythonScript->GetError()) { - auto* ce = new CError(1, "Error calling Metview function"); + auto* ce = new CError(1, "Error calling Metview function"); metviewPythonResult = new Value(ce); return fname; } @@ -156,7 +156,7 @@ // if there was an error, we should return a CError value if (metviewPythonScript->GetError()) { - auto* ce = new CError(1, "Error calling Metview function"); + auto* ce = new CError(1, "Error calling Metview function"); metviewPythonResult = new Value(ce); return fname; } @@ -196,10 +196,10 @@ void p_push_datestring(const char* str) { - //The string is in "yyyy-mm-ddTHH:MM:SS" format + // The string is in "yyyy-mm-ddTHH:MM:SS" format if (strlen(str) >= 19) { - //We need to convert it to "yyyy-mm-dd HH:MM:SS" format - //for the Date constructor + // We need to convert it to "yyyy-mm-dd HH:MM:SS" format + // for the Date constructor static char mdateStr[20]; strncpy(mdateStr, str, 19); mdateStr[19] = '\0'; @@ -388,8 +388,8 @@ // XXX should report an error err e = 1; return new Value(e, "Internal: bad list index"); - //printf("p_list_element_as_value: %d\n", i); - //return 0; + // printf("p_list_element_as_value: %d\n", i); + // return 0; } return local_copy_of_value((*lst)[i]); @@ -457,7 +457,7 @@ val->GetValue(r); if (r) { MvRequest req(r, false, false); // clone=false, free_req_on_destroy=false - return req.countParameters(false); //includeHidden=false + return req.countParameters(false); // includeHidden=false } else return 0; // NULL request pointer -> no parameters @@ -520,7 +520,7 @@ const char* fff = get_value(req, "FIELDSET_FROM_FILTER", 0); if (fff && !strcmp(fff, "1")) { fieldset* fs = request_to_fieldset(req); - fieldset* z = copy_fieldset(fs, fs->count, true); + fieldset* z = copy_fieldset(fs, fs->count, true); save_fieldset(z); finalreq = fieldset_to_request(z); } @@ -557,10 +557,10 @@ printf("Done\n"); */ - //MvRequest* r = p_new_request("MCOAST"); - //p_set_value(r, "map_coastline_colour", "red"); - //p_push_request(r); - //const char *pr = p_call_function("plot", 1); + // MvRequest* r = p_new_request("MCOAST"); + // p_set_value(r, "map_coastline_colour", "red"); + // p_push_request(r); + // const char *pr = p_call_function("plot", 1); return 0; } diff -Nru metview-5.17.4/metview/src/Macro/remote.cc metview-5.19.2/metview/src/Macro/remote.cc --- metview-5.17.4/metview/src/Macro/remote.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/remote.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,9 +28,9 @@ Function(n) { service = strcache(s); - args = clone_all_requests(r); + args = clone_all_requests(r); - int m = count_values(r, "_types"); + int m = count_values(r, "_types"); auto* t = new vtype[m]; for (int i = 0; i < m; i++) t[i] = (vtype)atoi(get_value(r, "_types", i)); diff -Nru metview-5.17.4/metview/src/Macro/request.cc metview-5.19.2/metview/src/Macro/request.cc --- metview-5.17.4/metview/src/Macro/request.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/request.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,8 @@ static const char* find_service(const char* verb, const char* mode) { - char* state = strcache("state"); - request* u = mars.setup; + char* state = strcache("state"); + request* u = mars.setup; const char* service = 0; while (u && !service) { @@ -108,7 +108,7 @@ request* s = r; while (s) { - int pflg = 0; + int pflg = 0; parameter* p = s->params; if (*s->name != '_') @@ -315,9 +315,9 @@ SimpleRequestFunction::SimpleRequestFunction(request* r, const char* n) : Function(n) { - def = r; - verb = get_value(r, "class", 0); - info = strcache(get_value(r, "info", 0)); + def = r; + verb = get_value(r, "class", 0); + info = strcache(get_value(r, "info", 0)); service = find_service(verb, 0); if (verb == 0) @@ -408,7 +408,7 @@ default: return false; - //break; + // break; } i++; } @@ -424,7 +424,7 @@ // Build request from arguments - static std::set needToAttachTypes = + static std::set needToAttachTypes = {tgrib, tbufr, tvector, tgeopts, tnetcdf, todb, ttable, tgptset}; int i = 0; @@ -450,7 +450,7 @@ if (needToAttachTypes.find(val.GetType()) != needToAttachTypes.end()) { Content* c = arg[i].GetContent(); attachedContent.push_back(c); // we will need to detach these later - see comments for attachedContent in value.h. - c->Attach(); // attach because the data will be passed to another module, so we shouldn't allow it to be deleted yet + c->Attach(); // attach because the data will be passed to another module, so we shouldn't allow it to be deleted yet } break; } @@ -507,8 +507,8 @@ const char* p = 0; request* lang = GetLanguage(); - rule* test = GetRules(); - long flag = EXPAND_MARS; + rule* test = GetRules(); + long flag = EXPAND_MARS; if (lang == 0 && (verb == 0 || *verb == '_')) { const char* c = get_value(r, "_CLASS", 0); @@ -537,7 +537,7 @@ } else { marslog(LOG_EROR, "There was a problem parsing the definition finishing on line %d. Please see the above message(s) to see which parameter(s) could be at fault.", Context::CurrentLine()); - //print_all_requests(r); + // print_all_requests(r); } free_all_requests(r); @@ -569,7 +569,7 @@ Script::Output.GetValue(s); set_subrequest(r, "_DEVICE_DRIVER", s); //-- directly for uPlot } -#if 0 //Remove this code later. We decided not to use a translator anymore. +#if 0 // Remove this code later. We decided not to use a translator anymore. else if( strcmp( service, "VisModTrans" ) == 0 ) { // Script::Driver.GetValue(s); @@ -649,13 +649,15 @@ set_value(r, "_MODE", "MACRO"); set_value(r, "_CALLED_FROM_MACRO", "0"); - //Get desktop app name + // Get desktop app name + std::string desktopName; char* desktop = getenv("MV_DESKTOP_NAME"); - if (desktop == 0) { + if (!desktop) { std::cout << "Error: MV_DESKTOP_NAME is not defined! Macro exits!" << std::endl; } - - std::string desktopName(desktop); + else { + desktopName = std::string(desktop); + } Value v(desktopName.c_str(), r); free_all_requests(s); free_all_requests(r); @@ -717,7 +719,7 @@ } //============================================================================= -char* PlotterFunction::plotter = strcache(nullptr); +char* PlotterFunction::plotter = strcache(nullptr); boolean PlotterFunction::setbyuser = false; //-- list for plotters given by numbers (starting from 0) @@ -744,7 +746,7 @@ Function(n) { setbyuser = false; - plotter = 0; + plotter = 0; } void PlotterFunction::Init() @@ -777,7 +779,7 @@ if (strcmp(p, i) == 0) { strfree(plotter); plotter = strcache(p); - found = true; + found = true; } } @@ -787,7 +789,7 @@ if (strcmp(p, aliases[i]) == 0) { strfree(plotter); plotter = strcache(aliases[i + 1]); - found = true; + found = true; } i = i + 2; } @@ -819,7 +821,7 @@ char* PlotterFunction::Plotter() { if (plotter == 0) - plotter = strcache(M_UPLOT); //default value + plotter = strcache(M_UPLOT); // default value return plotter; } @@ -868,11 +870,11 @@ if ((s = get_subrequest(r, p, 0))) { Value v; - v.SetContent(s); // This will force expension of "DATA",.. + v.SetContent(s); // This will force expension of "DATA",.. // The line below was commented out to solve the performance issues in METV-3244 // The bottom line is: Attach() should not be called because v is already a copy. - //v.GetContent()->Attach(); // Subrequests are parameters, - // they must be saved .... + // v.GetContent()->Attach(); // Subrequests are parameters, + // they must be saved .... free_all_requests(s); return v; } @@ -892,7 +894,7 @@ // Check if request has a language file auto* f = (SimpleRequestFunction*)ObjsCache.Find(r->name); if (f == 0) - return Value(); //return nil + return Value(); // return nil // Get the closest parameter name parameter* q = closest_parameter( @@ -934,7 +936,7 @@ parameter* stringpar = find_parameter(r, "__strings"); if (stringpar) { value* svi = stringpar->values; - //const char* svn = par->name; + // const char* svn = par->name; if (!strcmp(svi->name, p)) return Value(vi->name); } @@ -986,7 +988,7 @@ Function(n), argsRequired(argsReq) { - service = strcache(s); + service = strcache(s); plot_command_ = n; } virtual int ValidArguments(int arity, Value* arg); @@ -1180,7 +1182,7 @@ // 1. Drivers defined in the "plot" command have top priority (overwrite "setoutput") // 2. Drivers defined in the "setoutput" command have second priority // 3. If neither 1 or 2 is defined then output goes to "screen" - if (preq) //drivers defined in the plot command + if (preq) // drivers defined in the plot command { // Set output function PlotterFunction::SetPlotter("uPlotBatch"); @@ -1234,7 +1236,7 @@ { // Get header info MvRequest hreq = Header(); - request* r = 0; + request* r = 0; if (hreq) { // Concatenate all requests if (Script::PlotReq) @@ -1387,17 +1389,17 @@ return ""; parameter* p = r->params; - int count = 0; + int count = 0; while (p) { count++; p = p->next; } auto* l = new CList(count); - p = r->params; - int n = 0; + p = r->params; + int n = 0; while (p) { (*l)[n++] = p->name; - p = p->next; + p = p->next; } return Value(l); @@ -1413,8 +1415,8 @@ Value OrderFunction::Execute(int, Value*) { - int count = mars_order_count(); - auto* l = new CList(count); + int count = mars_order_count(); + auto* l = new CList(count); char** order = mars_order(); for (int i = 0; i < count; i++) (*l)[i] = order[i]; @@ -1489,10 +1491,10 @@ int npages = count_requests(pages); auto* lreq = new CList(npages); for (int i = 0; i < npages; i++) { - MvRequest page = pages.justOneRequest(); + MvRequest page = pages.justOneRequest(); MvRequest oneReq = superpage; - oneReq("PAGES") = page; - (*lreq)[i] = Value(oneReq); + oneReq("PAGES") = page; + (*lreq)[i] = Value(oneReq); pages.advance(); } @@ -1571,7 +1573,7 @@ strfree(object); - //Get desktop name + // Get desktop name char* desktop = getenv("MV_DESKTOP_NAME"); if (desktop == 0) { std::cout << "Error: MV_DESKTOP_NAME is not defined! GeoTool exits!" << std::endl; diff -Nru metview-5.17.4/metview/src/Macro/script.cc metview-5.19.2/metview/src/Macro/script.cc --- metview-5.17.4/metview/src/Macro/script.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/script.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,12 +11,12 @@ #include "Cached.h" #include "MvRequest.h" -svcid* Script::SvcId = 0; +svcid* Script::SvcId = 0; Script* Script::Compiled = 0; -Value Script::Output = (request*)0; // Default uPlot output/device -Value Script::Device = (request*)0; // Default VisMod device/output -MvRequest Script::PlotReq; // Plot request -char* Script::macropath = 0; +Value Script::Output = (request*)0; // Default uPlot output/device +Value Script::Device = (request*)0; // Default VisMod device/output +MvRequest Script::PlotReq; // Plot request +char* Script::macropath = 0; char* Script::macroMainPath = 0; extern "C" { @@ -32,7 +32,7 @@ void Script::PutMessage(int /*code*/, const char* msg) { if (Script::SvcId) { - //if(code != LOG_INFO) set_svc_msg(Script::SvcId,msg); + // if(code != LOG_INFO) set_svc_msg(Script::SvcId,msg); send_progress(Script::SvcId, msg, 0); } printf("%s\n", msg); @@ -41,7 +41,7 @@ void Script::PutExtendedMessage(int /*code*/, const char* msg) { if (Script::SvcId) { - //if(code != LOG_INFO) set_svc_msg(Script::SvcId,msg); + // if(code != LOG_INFO) set_svc_msg(Script::SvcId,msg); request* r = empty_request("SEND_PROGRESS"); set_value(r, "PROGRESS", "%s", msg); send_progress(Script::SvcId, msg, r); @@ -92,15 +92,15 @@ zzlineno = 0; - Step* i = Instruction; - Context* c = Current; - Script* s = Compiled; + Step* i = Instruction; + Context* c = Current; + Script* s = Compiled; Instruction = 0; Current = Compiled = this; parse_macro(); Instruction = i; - Current = c; - Compiled = s; + Current = c; + Compiled = s; fclose(zzin); MacroMainPath((const char*)oldDir); //-- revert to previous path @@ -165,7 +165,7 @@ { if (last == 0) { last = s; - s = 0; + s = 0; } while ((Instruction = last) && last->Ready()) last = last->Execute(); diff -Nru metview-5.17.4/metview/src/Macro/stack.cc metview-5.19.2/metview/src/Macro/stack.cc --- metview-5.17.4/metview/src/Macro/stack.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/stack.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ { if (top == 0) return Error("Stack is empty (pop)"); - Value v = stack[--top]; + Value v = stack[--top]; stack[top] = Value(0.0); return v; } diff -Nru metview-5.17.4/metview/src/Macro/Unix.cc metview-5.19.2/metview/src/Macro/Unix.cc --- metview-5.17.4/metview/src/Macro/Unix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/Unix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -138,7 +138,7 @@ if (!p && !q) return Value((char*)nullptr); - char* buf = new char[strlen(p) + strlen(q) + 2]; //memory leak!!! + char* buf = new char[strlen(p) + strlen(q) + 2]; // memory leak!!! sprintf(buf, "%s=%s", p, q); putenv(buf); return Value(buf); diff -Nru metview-5.17.4/metview/src/Macro/userintf.cc metview-5.19.2/metview/src/Macro/userintf.cc --- metview-5.17.4/metview/src/Macro/userintf.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/userintf.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,19 +31,17 @@ e->next = clone_all_requests(r); - - //Get desktop app name + // Get desktop app name + std::string desktopName; char* desktop = getenv("MV_DESKTOP_NAME"); - if (desktop == 0) { + if (!desktop) { std::cout << "Error: MV_DESKTOP_NAME is not defined! Macro exits!" << std::endl; } - - std::string desktopName(desktop); - + else { + desktopName = std::string(desktop); + } Value v = Value(desktopName.c_str(), e); - free_all_requests(e); - return v; } diff -Nru metview-5.17.4/metview/src/Macro/value.cc metview-5.19.2/metview/src/Macro/value.cc --- metview-5.17.4/metview/src/Macro/value.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/value.cc 2023-07-15 08:28:47.000000000 +0000 @@ -237,14 +237,14 @@ Content(t) { iconName = strcache(n ? n : Context::UniqueName()); - isIcon = false; + isIcon = false; } InPool::InPool(vtype t, request* r) : Content(t) { iconName = strcache(get_value(r, "_NAME", 0)); - isIcon = true; // This comes from MetviewUI + isIcon = true; // This comes from MetviewUI if (iconName == 0) iconName = strcache(Context::UniqueName()); @@ -282,16 +282,16 @@ } //============================================================================= -svc* ASync::Svc = 0; +svc* ASync::Svc = 0; int ASync::RequestMax = 3; int ASync::RequestCnt = 0; -char* ASync::Name = 0; +char* ASync::Name = 0; void ASync::Connect() { if (Svc == 0) { Name = strcache(Context::UniqueName()); - Svc = create_service(Name); + Svc = create_service(Name); add_reply_callback(Svc, 0, Reply, 0); add_service_callback(Svc, "DEFINITION", Definition, 0); keep_alive(Svc, 1); // Stay alive until macro dies @@ -469,14 +469,14 @@ void Value::SetContent(Content* x) { Content* y = c; - c = x; + c = x; c->Attach(); y->Detach(); } void ASync::Sync(Value* v) { - request* s = Wait(); + request* s = Wait(); Content* vc = v->GetContent(); vc->Attach(); // so we don't lose it in the next line v->SetContent(s); @@ -535,7 +535,7 @@ // find the corresponding gribfile quicky). for (int i = 0; i < fs1->count; i++) { - field* f1 = fs1->fields[i]; + field* f1 = fs1->fields[i]; gribfile* g1 = f1->file; for (int j = 0; j < fs2->count; j++) { @@ -546,6 +546,15 @@ g2->refcnt++; g1->refcnt--; f1->file = g2; + // if no one is pointing to g1 we need to delete the object + // without removing the file from disk. Not deleting g1 will + // result in a memory leak. See: METV-3389 + if (g1->refcnt <= 0) { + // we need to pretend g1 is not temporary. Otherwise + // free_gribfile() would delete the file from disk! + g1->temp = 0; + free_gribfile(g1); + } break; // don't need to search fs1 any further } } @@ -615,7 +624,7 @@ return; } - char* from = strcache(get_value(r, "_FROM", 0)); + char* from = strcache(get_value(r, "_FROM", 0)); char* notify = strcache(get_value(r, "_NOTIFY", 0)); unset_value(r, "_NOTIFY"); @@ -628,7 +637,7 @@ }; Content* c = nullptr; - CList* l = n != 1 ? new CList(n) : nullptr; + CList* l = n != 1 ? new CList(n) : nullptr; int i = 0; while (r) { @@ -638,7 +647,7 @@ if (n > 1) set_value(r, "_NAME", "%s", Context::UniqueName()); - s = r->next; + s = r->next; r->next = 0; char* p = r->name; @@ -673,7 +682,7 @@ c = new CRequest(r); r->next = s; - r = s; + r = s; if (n != 1) (*l)[i++] = Value(c); @@ -700,25 +709,25 @@ } request* s = r; - int n = 0; + int n = 0; while (s) { s = s->next; n++; }; Content* c = nullptr; - auto* l = new CList(n); + auto* l = new CList(n); int i = 0; while (r) { - s = r->next; + s = r->next; r->next = 0; - c = new CRequest(r); + c = new CRequest(r); (*l)[i++] = Value(c); r->next = s; - r = s; + r = s; } c = l; diff -Nru metview-5.17.4/metview/src/Macro/vismod.cc metview-5.19.2/metview/src/Macro/vismod.cc --- metview-5.17.4/metview/src/Macro/vismod.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Macro/vismod.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ //============================================================================= -static Value reply = 0.0; +static Value reply = 0.0; static boolean ready = false; @@ -62,8 +62,8 @@ ASync::Connect(); add_service_callback(ASync::Svc, "WINDOW_INFO", info_cb, (void*)"input"); add_service_callback(ASync::Svc, "CHANGE_WINDOW", info_cb, (void*)"change"); - //add_service_callback(ASync::Svc,"MOVE_CURSOR", info_cb,0); - //add_service_callback(ASync::Svc,"CONTENTS", info_cb,0); + // add_service_callback(ASync::Svc,"MOVE_CURSOR", info_cb,0); + // add_service_callback(ASync::Svc,"CONTENTS", info_cb,0); add_service_callback(ASync::Svc, "CLOSE_WINDOW", close_cb, nullptr); first = 0; } diff -Nru metview-5.17.4/metview/src/MacroEditor/CodeHelperWidget.cc metview-5.19.2/metview/src/MacroEditor/CodeHelperWidget.cc --- metview-5.17.4/metview/src/MacroEditor/CodeHelperWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/CodeHelperWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -67,7 +67,7 @@ connect(closeTb, SIGNAL(clicked()), this, SLOT(slotCloseSideBar())); - //stacked widget cotaining the actual helpers + // stacked widget cotaining the actual helpers stackedW_ = new QStackedWidget(this); vb->addWidget(stackedW_); } @@ -113,7 +113,7 @@ void CodeHelperWidget::setCodeEditorTheme(EditorTheme* theme, QFont font) { editorTheme_ = theme; - editorFont_ = font; + editorFont_ = font; if (functionHelper_) functionHelper_->setCodeEditorTheme(theme, font); @@ -138,7 +138,7 @@ ConfigLoader::init(); // verb help. Uses VerbFunctionHelp, which will initailised later - auto* w = new QWidget(this); + auto* w = new QWidget(this); auto* sbVb = new QVBoxLayout(w); sbVb->setContentsMargins(0, 0, 0, 0); sbVb->setSpacing(1); @@ -149,7 +149,7 @@ Q_ASSERT(FunctionHelpIndex == modeCombo_->count() - 1); // colour editor. Uses MvQPalette - initialised via ConfigLoader - w = new QWidget(this); + w = new QWidget(this); sbVb = new QVBoxLayout(w); sbVb->setContentsMargins(0, 0, 0, 0); sbVb->setSpacing(1); diff -Nru metview-5.17.4/metview/src/MacroEditor/CodeHelperWidget.h metview-5.19.2/metview/src/MacroEditor/CodeHelperWidget.h --- metview-5.17.4/metview/src/MacroEditor/CodeHelperWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/CodeHelperWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -55,7 +55,7 @@ enum HelpModeIndex { FunctionHelpIndex = 0, - ColourHelpIndex = 1 + ColourHelpIndex = 1 }; bool built_; diff -Nru metview-5.17.4/metview/src/MacroEditor/CodeTemplateDialog.cc metview-5.19.2/metview/src/MacroEditor/CodeTemplateDialog.cc --- metview-5.17.4/metview/src/MacroEditor/CodeTemplateDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/CodeTemplateDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,7 +42,7 @@ if (file.open(QFile::ReadOnly | QFile::Text)) // try to open in read-only mode { - int index = 0; + int index = 0; QString body = ""; QTextStream in(&file); QString spaces = ""; @@ -64,7 +64,7 @@ while (!file.atEnd()) // each line in the file is a function name to add to the list { - QListWidgetItem* item; + QListWidgetItem* item = nullptr; QString s = file.readLine(); // is this the heading of a new template? @@ -76,9 +76,9 @@ body = ""; } - QString title = s.mid(1, s.count() - 3); // remove the curly brackets and the newline - item = new QListWidgetItem(title, templateListWidget); // create a new item for the tree - item->setData(Qt::UserRole, index); // set the index + QString title = s.mid(1, s.count() - 3); // remove the curly brackets and the newline + item = new QListWidgetItem(title, templateListWidget); // create a new item for the tree + item->setData(Qt::UserRole, index); // set the index index++; } @@ -126,8 +126,8 @@ // set up the signal/slot connections - //connect (insertButton, SIGNAL(clicked()), this, SLOT(onInsertButtonClicked())); - //connect (treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(onItemDoubleClicked(QTreeWidgetItem*, int))); + // connect (insertButton, SIGNAL(clicked()), this, SLOT(onInsertButtonClicked())); + // connect (treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(onItemDoubleClicked(QTreeWidgetItem*, int))); connect(templateListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(onItemChanged(QListWidgetItem*, QListWidgetItem*))); } diff -Nru metview-5.17.4/metview/src/MacroEditor/ColourHelpWidget.ui metview-5.19.2/metview/src/MacroEditor/ColourHelpWidget.ui --- metview-5.17.4/metview/src/MacroEditor/ColourHelpWidget.ui 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/ColourHelpWidget.ui 2023-07-15 08:28:47.000000000 +0000 @@ -10,12 +10,59 @@ 300 + + + 0 + 0 + + Form + + 1 + + + 0 + + + 0 + + + 0 + + + 0 + - + + + + 0 + 1 + + + + Qt::ScrollBarAsNeeded + + + QAbstractScrollArea::AdjustToContents + + + true + + + + + 0 + 0 + 398 + 265 + + + + diff -Nru metview-5.17.4/metview/src/MacroEditor/EditorTheme.cc metview-5.19.2/metview/src/MacroEditor/EditorTheme.cc --- metview-5.17.4/metview/src/MacroEditor/EditorTheme.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/EditorTheme.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,7 +20,7 @@ #include #endif -EditorTheme* EditorTheme::current_ = 0; +EditorTheme* EditorTheme::current_ = nullptr; QMap EditorTheme::items_; EditorTheme::EditorTheme(const MvRequest& r) : @@ -28,7 +28,7 @@ { const char* verb = req_.getVerb(); Q_ASSERT(verb); - name_ = QString(verb); + name_ = QString(verb); label_ = value("label"); if (label_.isEmpty()) { label_ = name_; @@ -58,7 +58,7 @@ QString s(c); return s; } - return QString(); + return {}; } QColor EditorTheme::colour(QString key) const @@ -71,7 +71,7 @@ return hexa(s); } - return QColor(); + return {}; } bool EditorTheme::bold(QString key) const @@ -95,7 +95,7 @@ QColor EditorTheme::rgb(QString name) const { QColor col; - QRegExp rx("rgb\\((\\d+),(\\d+),(\\d+),?(\\d+)?"); + QRegExp rx(R"(rgb\((\d+),(\d+),(\d+),?(\d+)?)"); if (rx.indexIn(name) > -1) { if (rx.captureCount() >= 3) { @@ -111,7 +111,7 @@ QColor EditorTheme::hexa(QString name) const { if (name.size() != 7) - return QColor(); + return {}; return QColor(name); } @@ -164,7 +164,7 @@ r.read(p.c_str()); if (r) { do { - auto* t = new EditorTheme(r); + auto* t = new EditorTheme(r); items_[t->name()] = t; } while (r.advance()); } diff -Nru metview-5.17.4/metview/src/MacroEditor/FindTextDialog.cc metview-5.19.2/metview/src/MacroEditor/FindTextDialog.cc --- metview-5.17.4/metview/src/MacroEditor/FindTextDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/FindTextDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,7 @@ FindTextDialog::FindTextDialog(QWidget* parent) : QDialog(parent) { - //setAttribute(Qt::WA_DeleteOnClose); + // setAttribute(Qt::WA_DeleteOnClose); setupUi(this); // this sets up GUI// setupFileMenu(); findComboBox->setInsertPolicy(QComboBox::InsertAtTop); @@ -180,7 +180,7 @@ { replaceAllInGroupBox->setSize(0, 0); // replaceAllInGroupBox->setMinimumSize(0, 0); - } + } resize(sizeHint()); */ } diff -Nru metview-5.17.4/metview/src/MacroEditor/FunctionHelpWidget.cc metview-5.19.2/metview/src/MacroEditor/FunctionHelpWidget.cc --- metview-5.17.4/metview/src/MacroEditor/FunctionHelpWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/FunctionHelpWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -89,10 +89,10 @@ bool FunctionHelpWidget::adjustContents(QString functionName, QString paramName) { - functionName = functionName.toLower(); - paramName = paramName.toLower(); + functionName = functionName.toLower(); + paramName = paramName.toLower(); VerbFunctionHelpFunction* verb = nullptr; - VerbFunctionHelpParam* param = nullptr; + VerbFunctionHelpParam* param = nullptr; if (functionName.isEmpty()) { @@ -137,18 +137,7 @@ if (!fn) return; - QString web; - if (fn->iconClass()) { - web = language_->functionHelp()->iconUrl(fn); - } - else if (descIndex >= 0) { - QPair desc = fn->descriptions()[descIndex]; - QString webGroup = desc.first; - if (!webGroup.isEmpty()) { - web = language_->functionHelp()->url(webGroup, fn->name()); - } - } - + QString web = language_->functionHelp()->url(fn, descIndex); if (!web.isEmpty()) { std::string err; if (!metview::openInBrowser(web.toStdString(), err)) { diff -Nru metview-5.17.4/metview/src/MacroEditor/FunctionHelpWidget.h metview-5.19.2/metview/src/MacroEditor/FunctionHelpWidget.h --- metview-5.17.4/metview/src/MacroEditor/FunctionHelpWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/FunctionHelpWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -46,8 +46,8 @@ protected: enum ViewIndex { - FunctionViewIndex = 0, - VerbHelpViewIndex = 1, + FunctionViewIndex = 0, + VerbHelpViewIndex = 1, FunctionInfoViewIndex = 2 }; LanguageHelper* language_; diff -Nru metview-5.17.4/metview/src/MacroEditor/FunctionInfoWidget.cc metview-5.19.2/metview/src/MacroEditor/FunctionInfoWidget.cc --- metview-5.17.4/metview/src/MacroEditor/FunctionInfoWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/FunctionInfoWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,10 +36,7 @@ connect(ui_->showFunctionListTb, SIGNAL(clicked()), this, SIGNAL(functionListRequested())); - ui_->macroLabel->setPixmap(QPixmap(":/macroEditor/macro.svg").scaledToHeight(20, Qt::SmoothTransformation)); - ui_->pythonLabel->setPixmap(QPixmap(":/macroEditor/python.svg").scaledToHeight(20, Qt::SmoothTransformation)); - - //Set css for the text formatting + // Set css for the text formatting QString cssDoc = "td {background: " + MvQTheme::htmlTableBg().name() + "; color: " + MvQTheme::htmlTableText().name() + "; padding-left: 4px; padding-right: 3px;}" + @@ -90,7 +87,7 @@ return; } - fn_ = fn; + fn_ = fn; descIndex_ = descIndex; Q_ASSERT(descIndex_ >= 0); ui_->functionNameLabel->setText(" " + fn_->name() + "()"); @@ -106,8 +103,8 @@ txt += "
"; } } - //txt += ""; - //txt += ""; + // txt += ""; + // txt += ""; txt += "
" + fn->descriptions()[i].first + "" + fn->descriptions()[i].second + "
Category" + fn_->descriptions()[descIndex_].first + "
Description " + fn->descriptionAsStr(descIndex_) + "
Category" + fn_->descriptions()[descIndex_].first + "
Description " + fn->descriptionAsStr(descIndex_) + "
"; ui_->descBrowser->show(); ui_->descBrowser->insertHtml(txt); diff -Nru metview-5.17.4/metview/src/MacroEditor/FunctionInfoWidget.ui metview-5.19.2/metview/src/MacroEditor/FunctionInfoWidget.ui --- metview-5.17.4/metview/src/MacroEditor/FunctionInfoWidget.ui 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/FunctionInfoWidget.ui 2023-07-15 08:28:47.000000000 +0000 @@ -48,23 +48,6 @@ - - - - - - - - - - - - - false - - - - Qt::Horizontal @@ -106,7 +89,7 @@ Function list - + :/macroEditor/narrow_arrow_left.svg:/macroEditor/narrow_arrow_left.svg @@ -129,7 +112,7 @@ - + @@ -179,7 +162,7 @@ Documentation - + :/macroEditor/web_link.svg:/macroEditor/web_link.svg @@ -192,7 +175,7 @@ - + diff -Nru metview-5.17.4/metview/src/MacroEditor/FunctionListWidget.cc metview-5.19.2/metview/src/MacroEditor/FunctionListWidget.cc --- metview-5.17.4/metview/src/MacroEditor/FunctionListWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/FunctionListWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,8 +43,8 @@ painter->save(); - //Render the horizontal border for rows. We only render the top border line. - //With this technique we miss the bottom border line of the last row!!! + // Render the horizontal border for rows. We only render the top border line. + // With this technique we miss the bottom border line of the last row!!! QRect bgRect = option.rect; painter->setPen(borderPen_); if (index.column() != 0) @@ -100,7 +100,7 @@ QPair item = data_->itemAtInTotal(index.row()); - //VerbFunctionHelpFunction *item = data_->itemAt(index.row()); + // VerbFunctionHelpFunction *item = data_->itemAt(index.row()); if (!item.first) return {}; @@ -166,16 +166,16 @@ QModelIndex FunctionListModel::index(int row, int column, const QModelIndex&) const { if (!hasData() || row < 0 || column < 0) { - return QModelIndex(); + return {}; } - return createIndex(row, column, static_cast(0)); + return createIndex(row, column, static_cast(nullptr)); } QModelIndex FunctionListModel::parent(const QModelIndex&) const { - return QModelIndex(); + return {}; } void FunctionListModel::reload(VerbFunctionHelp* data) @@ -244,7 +244,7 @@ ui_->tree->setRootIsDecorated(false); ui_->tree->setItemDelegate(new FunctionListDelegate(this)); - model_ = new FunctionListModel(this); + model_ = new FunctionListModel(this); sortModel_ = new QSortFilterProxyModel(this); sortModel_->setDynamicSortFilter(true); sortModel_->setFilterKeyColumn(1); diff -Nru metview-5.17.4/metview/src/MacroEditor/LanguageHelper.cc metview-5.19.2/metview/src/MacroEditor/LanguageHelper.cc --- metview-5.17.4/metview/src/MacroEditor/LanguageHelper.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/LanguageHelper.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,7 +27,7 @@ { QString result; QStringList lines = text.split("\n"); // put separate lines into a list of strings - int numLines = lines.size(); + int numLines = lines.size(); for (int i = 0; i < numLines; i++) // each line will be pre-pended with a '#' { diff -Nru metview-5.17.4/metview/src/MacroEditor/LanguageHelper.h metview-5.19.2/metview/src/MacroEditor/LanguageHelper.h --- metview-5.17.4/metview/src/MacroEditor/LanguageHelper.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/LanguageHelper.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,12 +29,14 @@ { public: LanguageHelper(); - virtual ~LanguageHelper() {} + virtual ~LanguageHelper() = default; + LanguageHelper(const LanguageHelper&) = delete; + LanguageHelper& operator=(const LanguageHelper&) = delete; virtual Highlighter* createHighlighter(QTextDocument* parent = 0) = 0; - virtual bool canCheckSyntax() = 0; - virtual bool canRun() = 0; - virtual bool canDebug() = 0; + virtual bool canCheckSyntax() = 0; + virtual bool canRun() = 0; + virtual bool canDebug() = 0; virtual bool canHaveRunOptions() const { return false; } virtual bool runAsService() = 0; virtual QString pathToFunctionList() { return QString(""); } @@ -65,5 +67,5 @@ QString className_; QString serviceName_; QString iconName_; - VerbFunctionHelp* functionHelp_; + VerbFunctionHelp* functionHelp_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/MacroEditor/logedit.cc metview-5.19.2/metview/src/MacroEditor/logedit.cc --- metview-5.17.4/metview/src/MacroEditor/logedit.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/logedit.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ LogEdit::~LogEdit() = default; -//Set the colour scheme +// Set the colour scheme void LogEdit::setTheme(EditorTheme* theme) { Q_ASSERT(theme); @@ -44,7 +44,7 @@ QPlainTextEdit:!focus{" + styleStr + "selection-color: black; selection-background-color: rgb(180,204,234);}"); - QFont f = font(); + QFont f = font(); int fSize = f.pointSize(); QString family = theme->value("font"); diff -Nru metview-5.17.4/metview/src/MacroEditor/MacroEdit.cc metview-5.19.2/metview/src/MacroEditor/MacroEdit.cc --- metview-5.17.4/metview/src/MacroEditor/MacroEdit.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/MacroEdit.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,8 +41,8 @@ #include "Path.h" #include "Metview.h" #include "MvPath.hpp" -#include -#include +#include +#include //#define MACROEDIT_USE_LOGTIMER #define MACROEDIT_DEBUG__ @@ -105,15 +105,15 @@ MvRequest r(editor_->languageHelper()->className().toUtf8().constData()); // is this the right string to use? - r("PATH") = macro_.toUtf8().constData(); // path to macro - r("_NAME") = macro_.toUtf8().constData(); // path to macro - r("_CLASS") = editor_->languageHelper()->className().toUtf8().constData(); // class name - r("_ACTION") = options_.runMode_.c_str(); // e.g. "prepare" or "syntax" - r("_SERVICE") = editor_->languageHelper()->serviceName().toUtf8().constData(); // service name - r("_TRACE") = options_.trace_; - r("_WAITMODE") = options_.waitMode_; + r("PATH") = macro_.toUtf8().constData(); // path to macro + r("_NAME") = macro_.toUtf8().constData(); // path to macro + r("_CLASS") = editor_->languageHelper()->className().toUtf8().constData(); // class name + r("_ACTION") = options_.runMode_.c_str(); // e.g. "prepare" or "syntax" + r("_SERVICE") = editor_->languageHelper()->serviceName().toUtf8().constData(); // service name + r("_TRACE") = options_.trace_; + r("_WAITMODE") = options_.waitMode_; r("_SENDLINES") = options_.sendLines_; - r("_PAUSE") = options_.pause_; + r("_PAUSE") = options_.pause_; r.print(); @@ -166,7 +166,7 @@ void MacroRunTask::stop() { - //qDebug() << "stop" << "macroPid=" << macroPid_; + // qDebug() << "stop" << "macroPid=" << macroPid_; if (macroPid_ > 0) { Q_ASSERT(proc_ == nullptr); if (kill(macroPid_, 9) == 0) { @@ -179,7 +179,7 @@ return; } else if (proc_) { - //qDebug() << "procId" << proc_->processId(); + // qDebug() << "procId" << proc_->processId(); proc_->terminate(); } } @@ -226,9 +226,9 @@ char command[64] = ""; - char param[8] = ""; + char param[8] = ""; - if (sscanf(msg.c_str(), "MACROEDITOR:%s %s", command, param) == 2) { + if (sscanf(msg.c_str(), "MACROEDITOR:%63s %7s", command, param) == 2) { // special message for the macro editor - which message is it? if (!strcmp(command, "LINE")) // line number { @@ -286,12 +286,12 @@ void MacroRunTask::print(std::ostream&) const { - /* s << "MacroRunTask[" - << action_.name() - << "," - << action_.mode() + /* s << "MacroRunTask[" + << action_.name() << "," - << *object_ + << action_.mode() + << "," + << *object_ << "]"; */ } @@ -303,7 +303,7 @@ //================================================================= class ReplyHandler : public MvReply { - virtual void callback(MvRequest&); + void callback(MvRequest&) override; }; void ReplyHandler::callback(MvRequest& in) @@ -312,7 +312,7 @@ if (s == 0) return; - const char* p; + const char* p = nullptr; int i = 0; while ((p = getMessage(i++))) (*s)->message(p); @@ -326,13 +326,13 @@ class ProgressHandler : public MvProgress { - virtual void callback(MvRequest& r); + void callback(MvRequest& r) override; }; void ProgressHandler::callback(MvRequest& in) { auto* s = (ReplyObserverH*)getReference(); - if (s == 0) + if (s == nullptr) return; // get the pid of the macro we run @@ -348,7 +348,7 @@ return; } - const char* p; + const char* p = nullptr; int i = 0; while ((p = getMessage(i++))) (*s)->message(p); @@ -387,16 +387,16 @@ readOnly_(false), haveFocus_(false), autoInsertLicence_(false), - runTask_(0), - findDialog_(0), - gotoLineDialog_(0), - tabsDialog_(0), - runDialog_(0), - codeTemplateDialog_(0), - rowColLabel_(0), - messageLabel_(0), - languageHelper_(0), - highlighter_(0) + runTask_(nullptr), + findDialog_(nullptr), + gotoLineDialog_(nullptr), + tabsDialog_(nullptr), + runDialog_(nullptr), + codeTemplateDialog_(nullptr), + rowColLabel_(nullptr), + messageLabel_(nullptr), + languageHelper_(nullptr), + highlighter_(nullptr) { setupUi(this); // this sets up GUI// setupFileMenu(); @@ -416,7 +416,7 @@ // menuBar()->setNativeMenuBar(false); //#endif - //setupHelpMenu(); + // setupHelpMenu(); setupEditor(); // read the user's settings from a file @@ -428,7 +428,7 @@ loadTextFile(fileName_); } - //setCentralWidget(editor); + // setCentralWidget(editor); setWindowTitle(tr("Metview Code Editor [*]")); initFinished = true; @@ -533,10 +533,10 @@ QKeySequence f3(tr("F3")); QList qks; qks.push_back(ctrlg); - //qks.push_back (QKeySequence::FindNext); + // qks.push_back (QKeySequence::FindNext); qks.push_back(f3); // for when FindNext is not F3 actionFind_Next->setShortcuts(qks); - //actionFind_Next->setShortcutContext(Qt::WidgetShortcut); + // actionFind_Next->setShortcutContext(Qt::WidgetShortcut); actionFind->setShortcut(QKeySequence::Find); actionFind_Previous->setShortcut(QKeySequence::FindPrevious); @@ -581,8 +581,8 @@ // --- Font size --- - //actionEnlarge_Font->setShortcutContext(Qt::WidgetShortcut); - //actionShrink_Font->setShortcutContext(Qt::WidgetShortcut); + // actionEnlarge_Font->setShortcutContext(Qt::WidgetShortcut); + // actionShrink_Font->setShortcutContext(Qt::WidgetShortcut); connect(actionEnlarge_Font, SIGNAL(triggered()), this, SLOT(enlargeFont())); connect(actionShrink_Font, SIGNAL(triggered()), this, SLOT(shrinkFont())); @@ -647,19 +647,19 @@ printToolBar->setVisible(false); findToolBar->setVisible(false); editToolBar->setVisible(true); + viewToolBar->setVisible(true); programToolBar->setVisible(true); insertItemToolBar->setVisible(false); + helpToolBar->setVisible(true); - - //actionStop->setVisible(false); - + // actionStop->setVisible(false); // This message label will show the main messages in the status bar. // We ensure that the user can select & copy the text in case they // need to send it to us. messageLabel_ = new QLabel("", this); messageLabel_->setTextInteractionFlags(Qt::TextSelectableByMouse); - //messageLabel_->setMinimumSize(messageLabel_->sizeHint()); + // messageLabel_->setMinimumSize(messageLabel_->sizeHint()); statusBar()->addPermanentWidget(messageLabel_, 1); // '1' means 'please stretch me when resized' @@ -677,7 +677,7 @@ // we do not want a line to be highlighted initially highlightedLine_ = -1; - //Colour scheme menu + // Colour scheme menu themeAg_ = new QActionGroup(this); QMapIterator it(EditorTheme::items()); while (it.hasNext()) { @@ -691,10 +691,20 @@ connect(themeAg_, SIGNAL(triggered(QAction*)), this, SLOT(slotSelectTheme(QAction*))); - //Initialise with the default theme + // Initialise with the default theme setTheme("metview"); //------------------------------------ + // Log panel + //------------------------------------ + + logMessages->show(); + actionLogPanel->setChecked(true); + + connect(actionLogPanel, SIGNAL(toggled(bool)), + logMessages, SLOT(setVisible(bool))); + + //------------------------------------ // Sidebar //------------------------------------ @@ -812,12 +822,12 @@ readOnly_ = true; textEditor->setReadOnly(true); title += tr(" (Read only)"); - //onReadOnlyStatusChanged (true); + // onReadOnlyStatusChanged (true); } else { readOnly_ = false; textEditor->setReadOnly(false); - //onReadOnlyStatusChanged (false); + // onReadOnlyStatusChanged (false); } title += " - " + fileName_; @@ -916,10 +926,10 @@ { if (textEditor->document()->isModified()) { auto ret = QMessageBox::warning(this, appName_, - tr("The document has been modified.\n" - "Do you want to save your changes?"), - QMessageBox::Cancel | QMessageBox::No | QMessageBox::Yes, - QMessageBox::Yes); + tr("The document has been modified.\n" + "Do you want to save your changes?"), + QMessageBox::Cancel | QMessageBox::No | QMessageBox::Yes, + QMessageBox::Yes); if (ret == QMessageBox::Yes) return save(); else if (ret == QMessageBox::Cancel) @@ -974,7 +984,7 @@ bool MacroEdit::reload() { QTextCursor cursor = textEditor->textCursor(); // note the current text cursor position - int pos = cursor.position(); // note the current text cursor position + int pos = cursor.position(); // note the current text cursor position loadTextFile(fileName_); // reload the file cursor.setPosition(pos); // restore the cursor position textEditor->setTextCursor(cursor); // send the cursor back to the document @@ -1015,7 +1025,7 @@ if (languageHelper_) { QString currentWord = wordUnderCursor(); - //actionVerb_Function_Help->setEnabled(!readOnly_ && languageHelper_->isHelpAvailableForFunction(currentWord)); + // actionVerb_Function_Help->setEnabled(!readOnly_ && languageHelper_->isHelpAvailableForFunction(currentWord)); } @@ -1088,7 +1098,7 @@ // if there is user-selected text, then use that as the search string if (textEditor->textCursor().hasSelection()) { - selected = textEditor->textCursor().selectedText(); + selected = textEditor->textCursor().selectedText(); isSelection = true; } @@ -1152,9 +1162,9 @@ void MacroEdit::findString(const QString& s, QTextDocument::FindFlags flags, bool replace, const QString& r) { - lastFindString_ = s; // store for repeat searches - lastFindFlags_ = flags; // store for repeat searches - bool found = false; + lastFindString_ = s; // store for repeat searches + lastFindFlags_ = flags; // store for repeat searches + bool found = false; if (textEditor->find(s, flags)) // find and select the string - were we successful? { @@ -1400,7 +1410,7 @@ // to indent this line, and so we move it up one line QTextBlock cb = cursor.block(); - int column = (cursor.position() - cb.position()) + 1; + int column = (cursor.position() - cb.position()) + 1; if (column == 1) { cursor.movePosition(QTextCursor::Up, QTextCursor::MoveAnchor); @@ -1471,7 +1481,7 @@ // to indent this line, and so we move it up one line QTextBlock cb = cursor.block(); - int column = (cursor.position() - cb.position()) + 1; + int column = (cursor.position() - cb.position()) + 1; if (column == 1) { cursor.movePosition(QTextCursor::Up, QTextCursor::KeepAnchor); // move the cursor to the end of the previous line @@ -1655,7 +1665,7 @@ if (!codeTemplateDialog_) { // we will give the dialog the path to the file containing the function names - QString path = languageHelper_->pathToTemplateList(); + QString path = languageHelper_->pathToTemplateList(); codeTemplateDialog_ = new CodeTemplateDialog(path, this); connect(codeTemplateDialog_, SIGNAL(insertCodeTemplate(QString)), this, SLOT(onInsertCodeTemplate(QString))); @@ -1708,25 +1718,25 @@ void MacroEdit::insertText(QString text) { - //insert at cursor + // insert at cursor QTextCursor tc = textEditor->textCursor(); - //int lastPosition = tc.position(); + // int lastPosition = tc.position(); // this should be seen as a single operation for 'undo' purposes tc.beginEditBlock(); - //int extra = text.length() - completer_->completionPrefix().length(); - //tc.movePosition(QTextCursor::Left); - //tc.movePosition(QTextCursor::EndOfWord); + // int extra = text.length() - completer_->completionPrefix().length(); + // tc.movePosition(QTextCursor::Left); + // tc.movePosition(QTextCursor::EndOfWord); tc.insertText(text); textEditor->setTextCursor(tc); - //textEditor->insertPlainText(text + postString); + // textEditor->insertPlainText(text + postString); tc.endEditBlock(); - //int pos = tc.position(); - //tc.setPosition(lastPosition); + // int pos = tc.position(); + // tc.setPosition(lastPosition); textEditor->setFocus(); } @@ -1847,7 +1857,7 @@ QFile file(licenceTextPath.c_str()); if (file.open(QIODevice::ReadOnly)) { // read the file into a string, and replace the year placeholder with the real thing - int year = QDateTime::currentDateTime().date().year(); + int year = QDateTime::currentDateTime().date().year(); QString yearString = QString::number(year); QTextStream ts(&file); licenceText_ = ts.readAll(); @@ -1867,7 +1877,7 @@ // header, then we should put the licence text AFTER that. const int numLinesToLookForHeader = 3; - int line = 0; + int line = 0; QTextBlock b; QTextCursor cursor = textEditor->textCursor(); // get the document's cursor @@ -1953,7 +1963,7 @@ void MacroEdit::monitor() { MvRequest r; - MvApplication::callService("MvMonitor", r, nullptr); //Qt-based monitor + MvApplication::callService("MvMonitor", r, nullptr); // Qt-based monitor } @@ -1965,7 +1975,7 @@ void MacroEdit::external() { QString command = getenv("METVIEW_EDITOR"); - QString quote = "\""; + QString quote = "\""; command += " " + quote + fileName_ + quote; @@ -2046,16 +2056,16 @@ int ms = time_.elapsed(); // get the elapsed time since the macro was started QString finishedTime(tr(" [Finished at ") + QTime::currentTime().toString() + "]"); - double seconds = ms / 1000.0; + double seconds = ms / 1000.0; int wholeSeconds = (int)seconds; if (wholeSeconds > 0) { - double minutes = seconds / 60.0; + double minutes = seconds / 60.0; int wholeMinutes = (int)minutes; if (wholeMinutes > 0) { int remainingSeconds = seconds - (wholeMinutes * 60); - elapsedMsg = QString("%1 m, %2 s").arg(wholeMinutes).arg(remainingSeconds, 2); + elapsedMsg = QString("%1 m, %2 s").arg(wholeMinutes).arg(remainingSeconds, 2); } else { elapsedMsg = QString("%1 s").arg(seconds, 0, 'g', 4); @@ -2069,14 +2079,14 @@ if (errorCode) { statusMessage(tr("Program finished (FAILED) : ") + elapsedMsg + finishedTime); highlightLine(-2); // set a warning colour on the highlight line - //editor_.logMessage("FAILED"); - //Task::failure(); + // editor_.logMessage("FAILED"); + // Task::failure(); } else { statusMessage(tr("Program finished (OK) : ") + elapsedMsg + finishedTime); highlightLine(-1); // un-highlight the highlight line - //editor_.logMessage("RUN OK"); - //Task::success(r); + // editor_.logMessage("RUN OK"); + // Task::success(r); } #ifdef MACROEDIT_USE_LOGTIMER @@ -2134,7 +2144,7 @@ QString qs(s.c_str()); qs.replace("<", "<"); qs.replace(">", ">"); - //qs = "" + qs + " "; + // qs = "" + qs + " "; qs = "" + qs + " "; logMessages->appendHtml(qs); } @@ -2205,7 +2215,7 @@ void MacroEdit::updateRowColLabel() { - int line, column; + int line = 0, column = 0; textEditor->cursorRowCol(&line, &column); @@ -2324,7 +2334,7 @@ MacroRunOptions options; options.runMode_ = "syntax"; - runTask_ = new MacroRunTask(this, fileName_, options); // start the macro running in a new task object + runTask_ = new MacroRunTask(this, fileName_, options); // start the macro running in a new task object runTask_->start(); } @@ -2366,10 +2376,10 @@ if (dt > lastSaveTime_) { // yes - ask the user if they want to reload the document from disk auto ret = QMessageBox::warning(this, appName_, - tr("The document has been externally modified (%1).\n" - "Do you want to reload from disk?\n") - .arg(dt.toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat))), - QMessageBox::No | QMessageBox::Yes, QMessageBox::Yes); + tr("The document has been externally modified (%1).\n" + "Do you want to reload from disk?\n") + .arg(dt.toString(QLocale::system().dateTimeFormat(QLocale::ShortFormat))), + QMessageBox::No | QMessageBox::Yes, QMessageBox::Yes); if (ret == QMessageBox::Yes) { reload(); // reload the file @@ -2404,15 +2414,15 @@ { // we've only *really* lost focus if none of our widgets have it - if (QApplication::focusWidget() == 0) + if (QApplication::focusWidget() == nullptr) haveFocus_ = false; } void MacroEdit::slotChanegFont(bool) { QFontDialog d; - //d.setCurrentFont(editor_->); - //d.setOptions(QFontDialog::MonospacedFonts); + // d.setCurrentFont(editor_->); + // d.setOptions(QFontDialog::MonospacedFonts); } // --------------------------------------------------------------------------- @@ -2439,7 +2449,7 @@ #endif fontSize_ = newSize; - //Save the settings + // Save the settings if (initFinished) writeSettings(); } @@ -2508,7 +2518,7 @@ { textEditor->setShowLineNumbers(show); - //Save the settings + // Save the settings if (initFinished) writeSettings(); } @@ -2563,18 +2573,18 @@ textEditor->setExtraSelections(extras); break; - //QTextCursor cursor = textEditor->textCursor(); // get the document's cursor - //cursor.setPosition (b.position()); // set it to the right position - //cursor.select(QTextCursor::LineUnderCursor); // select the whole line - //textEditor->setTextCursor(cursor); // send the cursor back to the document - //break; + // QTextCursor cursor = textEditor->textCursor(); // get the document's cursor + // cursor.setPosition (b.position()); // set it to the right position + // cursor.select(QTextCursor::LineUnderCursor); // select the whole line + // textEditor->setTextCursor(cursor); // send the cursor back to the document + // break; } bn++; } } else { - //statusMessage(tr("Line not in document"), 0); + // statusMessage(tr("Line not in document"), 0); } } @@ -2617,7 +2627,7 @@ // does this language provide a list of built-in functions or code templates? actionCode_Template->setEnabled(!readOnly_ && !languageHelper_->pathToTemplateList().isEmpty()); - //action_List_of_available_functions->setEnabled(!readOnly_); + // action_List_of_available_functions->setEnabled(!readOnly_); // we must call when a language is set adjustSideBarForLanguage(); @@ -2639,7 +2649,7 @@ // window title QString langName = languageHelper_->name(); - //setWindowTitle(tr("Metview ") + langName + tr("Macro Editor [*]")); + // setWindowTitle(tr("Metview ") + langName + tr("Macro Editor [*]")); // set the application icon QPixmap winPix(MvQ::iconPixmapPath(languageHelper_->iconName())); @@ -2661,7 +2671,7 @@ { actionRun->setEnabled(enable && languageHelper_->canRun()); actionStop->setEnabled(!enable && languageHelper_->canRun()); - //actionDebug ->setEnabled (enable && languageHelper_->canDebug()); + // actionDebug ->setEnabled (enable && languageHelper_->canDebug()); actionCheckSyntax->setEnabled(enable && languageHelper_->canCheckSyntax()); actionRun_Options->setEnabled(enable && languageHelper_->canHaveRunOptions()); } @@ -2762,7 +2772,7 @@ highlighter_->rehighlight(); } - //Adjust the menu + // Adjust the menu foreach (QAction* a, themeAg_->actions()) { if (a->data().toString() == name) { a->setChecked(true); @@ -2770,7 +2780,7 @@ } } - //Save the settings + // Save the settings if (initFinished) writeSettings(); } @@ -2795,7 +2805,8 @@ settings.beginGroup("mainWindow"); settings.setValue("geometry", saveGeometry()); settings.setValue("state", saveState()); - settings.setValue("splitter", splitter->saveState()); + settings.setValue("sidebarSplitter_v2", sidebarSplitter->saveState()); + settings.setValue("splitter_v2", splitter->saveState()); settings.setValue("fontSize", fontSize_); settings.setValue("useSpacesForTabs", textEditor->useSpacesForTabs()); settings.setValue("numSpacesInTab", textEditor->numSpacesInTab()); @@ -2804,8 +2815,7 @@ settings.setValue("autoIndent", textEditor->autoIndent()); settings.setValue("showLineNumbers", textEditor->showLineNumbers()); settings.setValue("autoInsertLicence", autoInsertLicence_); - //settings.setValue("sidebar", actionSideBar->isChecked() && actionSideBar->isEnabled()); - settings.setValue("sidebarSplitter_v1", sidebarSplitter->saveState()); + settings.setValue("logPanel", actionLogPanel->isChecked()); if (EditorTheme* t = EditorTheme::current()) settings.setValue("theme", t->name()); @@ -2832,23 +2842,14 @@ settings.beginGroup("mainWindow"); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("state").toByteArray()); - splitter->restoreState(settings.value("splitter").toByteArray()); - newFontSize = settings.value("fontSize").toInt(); - useSpacesForTabs = settings.value("useSpacesForTabs", true).toBool(); - numSpacesInTab = settings.value("numSpacesInTab", 4).toInt(); - useSpacesForDrops = settings.value("useSpacesForDrops", true).toBool(); - displayTabsAndSpaces = settings.value("displayTabsAndSpaces", false).toBool(); - autoIndent = settings.value("autoIndent", true).toBool(); - visLineNumbers = settings.value("showLineNumbers", true).toBool(); - autoInsertLicence = settings.value("autoInsertLicence", false).toBool(); - QString theme = settings.value("theme").toString(); - if (settings.contains("sidebarSplitter_v1")) - sidebarSplitter->restoreState(settings.value("sidebarSplitter_v1").toByteArray()); + // Init sidebarSplitter + if (settings.contains("sidebarSplitter_v2")) + sidebarSplitter->restoreState(settings.value("sidebarSplitter_v2").toByteArray()); else { Q_ASSERT(sidebarSplitter->count() == 2); if (sidebarSplitter->count() == 2) { - int w = size().width(); + int w = size().width(); QList sLst = sidebarSplitter->sizes(); if (w > 500) { sLst[1] = 220; @@ -2862,11 +2863,23 @@ } } -#if 0 - bool sidebar = false; - if (settings.contains("sidebar")) - sidebar = settings.value("sidebar").toBool(); -#endif + // Init splitter (it is within sidebarSplitter + if (settings.contains("splitter_v2")) { + splitter->restoreState(settings.value("splitter_v2").toByteArray()); + } + + newFontSize = settings.value("fontSize").toInt(); + useSpacesForTabs = settings.value("useSpacesForTabs", true).toBool(); + numSpacesInTab = settings.value("numSpacesInTab", 4).toInt(); + useSpacesForDrops = settings.value("useSpacesForDrops", true).toBool(); + displayTabsAndSpaces = settings.value("displayTabsAndSpaces", false).toBool(); + autoIndent = settings.value("autoIndent", true).toBool(); + visLineNumbers = settings.value("showLineNumbers", true).toBool(); + autoInsertLicence = settings.value("autoInsertLicence", false).toBool(); + + actionLogPanel->setChecked(settings.value("logPanel", false).toBool()); + + QString theme = settings.value("theme").toString(); settings.endGroup(); @@ -2885,10 +2898,4 @@ setTheme(theme); else setTheme("metview"); - -#if 0 - if (actionSideBar->isEnabled()) { - actionSideBar->setChecked(sidebar); - } -#endif } diff -Nru metview-5.17.4/metview/src/MacroEditor/MacroEdit.h metview-5.19.2/metview/src/MacroEditor/MacroEdit.h --- metview-5.17.4/metview/src/MacroEditor/MacroEdit.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/MacroEdit.h 2023-07-15 08:28:47.000000000 +0000 @@ -85,9 +85,9 @@ }; -//class Request; +// class Request; -//class ReplyObserver : public virtual Counted { +// class ReplyObserver : public virtual Counted { class ReplyObserver : public QObject { Q_OBJECT @@ -97,10 +97,10 @@ virtual ~ReplyObserver(); // Change to virtual if base class virtual void reply(const MvRequest&, int) = 0; - virtual void progress(const MvRequest&) = 0; - virtual void message(const std::string&) = 0; - void attach(); //ir - void detach(); //ir + virtual void progress(const MvRequest&) = 0; + virtual void message(const std::string&) = 0; + void attach(); // ir + void detach(); // ir int macroPid() const { return macroPid_; } void setMacroPid(int v) { macroPid_ = v; } @@ -179,12 +179,12 @@ public: MvPlainTextEdit(QWidget * parent = 0); - ~MvPlainTextEdit() {}; + ~MvPlainTextEdit() {}; }; */ -//class MacroEdit : public QMainWindow, private Ui::MainWindow, public MacroRunTask +// class MacroEdit : public QMainWindow, private Ui::MainWindow, public MacroRunTask class MacroEdit : public QMainWindow, private Ui::MainWindow { Q_OBJECT @@ -201,14 +201,14 @@ LanguageHelper* languageHelper() { return languageHelper_; } - //void init(OdbMetaData*); + // void init(OdbMetaData*); QEventLoop eventLoop_; // xxxx should really be private! public slots: - //void searchInColTree(QString); - //void searchInTableTree(QString); - //void mousePressedInTableGraph(int,int); - //void selectTableFromList(QModelIndex); + // void searchInColTree(QString); + // void searchInTableTree(QString); + // void mousePressedInTableGraph(int,int); + // void selectTableFromList(QModelIndex); void findDialog(); void findReplaceDialog(); void findNext(); @@ -226,7 +226,7 @@ void tabsDialog(); void runDialog(); void codeTemplateDialog(); - //void onReadOnlyStatusChanged (bool readOnly); + // void onReadOnlyStatusChanged (bool readOnly); void onTabsSettingsChanged(TabsSettings settings); void onRunOptionsChanged(MacroRunOptions options); void onInsertFunctionName(QString); @@ -234,7 +234,7 @@ void onInsertTextIntoFunctionCall(QString); void clipboardDataChanged(); void run(); - //void debug(); + // void debug(); void stop(); void monitor(); void external(); @@ -340,7 +340,7 @@ QString licenceText_; QActionGroup* autoInsertLicenceGroup_; QActionGroup* themeAg_; - //MvQColourWidget* colourHelper_; - //VerbFunctionHelpWidget* verbHelper_; - //QComboBox *sidebarCombo_; + // MvQColourWidget* colourHelper_; + // VerbFunctionHelpWidget* verbHelper_; + // QComboBox *sidebarCombo_; }; diff -Nru metview-5.17.4/metview/src/MacroEditor/MacroEdit.ui metview-5.19.2/metview/src/MacroEditor/MacroEdit.ui --- metview-5.17.4/metview/src/MacroEditor/MacroEdit.ui 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/MacroEdit.ui 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ - + 1 @@ -34,55 +34,18 @@ 0 - + - Qt::Vertical + Qt::Horizontal - - - - 0 - 7 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - + + 4 + + + false + + + 1 @@ -99,82 +62,67 @@ 0 - + - Qt::Horizontal + Qt::Vertical + + + 4 false - - - - 1 - - - 0 - - - 0 - - - 0 - - - 0 - - + + + + 0 + 0 + + + + + + + + + 246 + 245 + 236 + + + + + + + + + 246 + 245 + 236 + + + + + + + + + 255 + 255 + 255 + + + + + + - - - - 0 - 0 - - - - - - - - - 246 - 245 - 236 - - - - - - - - - 246 - 245 - 236 - - - - - - - - - 255 - 255 - 255 - - - - - - - + @@ -185,7 +133,7 @@ 0 0 854 - 21 + 24 @@ -239,6 +187,9 @@ + + + @@ -371,8 +322,22 @@ + + + + View Toolbar + + + TopToolBarArea + + + false + + + + Program Toolbar @@ -387,10 +352,6 @@ - - - - @@ -404,9 +365,23 @@ + + + Help Toolbar + + + TopToolBarArea + + + false + + + + + - + :/macroEditor/filesave.svg:/macroEditor/filesave.svg @@ -418,7 +393,7 @@ - + :/macroEditor/close_red.svg:/macroEditor/close_red.svg @@ -430,7 +405,7 @@ - + :/macroEditor/editcopy.svg:/macroEditor/editcopy.svg @@ -439,7 +414,7 @@ - + :/macroEditor/editpaste.svg:/macroEditor/editpaste.svg @@ -451,7 +426,7 @@ - + :/macroEditor/editcut.svg:/macroEditor/editcut.svg @@ -460,7 +435,7 @@ - + :/macroEditor/find.svg:/macroEditor/find.svg @@ -506,7 +481,7 @@ - + :/macroEditor/undo.svg:/macroEditor/undo.svg @@ -515,7 +490,7 @@ - + :/macroEditor/redo.svg:/macroEditor/redo.svg @@ -529,7 +504,7 @@ - + :/macroEditor/filesaveas.svg:/macroEditor/filesaveas.svg @@ -538,7 +513,7 @@ - + :/macroEditor/fontsize_up.svg:/macroEditor/fontsize_up.svg @@ -547,7 +522,7 @@ - + :/macroEditor/fontsize_down.svg:/macroEditor/fontsize_down.svg @@ -569,7 +544,7 @@ - + :/macroEditor/macro_start.svg:/macroEditor/macro_start.svg @@ -584,7 +559,7 @@ - + :/macroEditor/check_syntax.svg:/macroEditor/check_syntax.svg @@ -598,7 +573,7 @@ - + :/macroEditor/macro_stop.svg:/macroEditor/macro_stop.svg @@ -613,7 +588,7 @@ - + :/macroEditor/monitor.svg:/macroEditor/monitor.svg @@ -622,7 +597,7 @@ - + :/macroEditor/print.svg:/macroEditor/print.svg @@ -631,7 +606,7 @@ - + :/macroEditor/edit.svg:/macroEditor/edit.svg @@ -702,7 +677,7 @@ - + :/macroEditor/run_options.svg:/macroEditor/run_options.svg @@ -717,7 +692,7 @@ - + :/macroEditor/insert_licence.svg:/macroEditor/insert_licence.svg @@ -790,7 +765,7 @@ true - + :/macroEditor/sidebar.svg:/macroEditor/sidebar.svg @@ -802,7 +777,7 @@ - + :/macroEditor/help.svg:/macroEditor/help.svg @@ -817,7 +792,7 @@ - + :/macroEditor/colour.svg:/macroEditor/colour.svg @@ -837,7 +812,7 @@ - + :/macroEditor/function_list.svg:/macroEditor/function_list.svg @@ -847,6 +822,21 @@ Function List + + + true + + + + :/macroEditor/logpanel.svg:/macroEditor/logpanel.svg + + + Output panel + + + Show Macro output panel + + @@ -869,8 +859,7 @@ - - + diff -Nru metview-5.17.4/metview/src/MacroEditor/MacroHelper.cc metview-5.19.2/metview/src/MacroEditor/MacroHelper.cc --- metview-5.17.4/metview/src/MacroEditor/MacroHelper.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/MacroHelper.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ { public: MacroHighlighter(QString& pathToFunctionList, QString& pathToMacroDeprecatedFunctionList, QTextDocument* parent = nullptr); - ~MacroHighlighter() = default; + ~MacroHighlighter() override = default; private: void LoadKeywordsFromFile(QString& fileName, QTextCharFormat& format); @@ -82,7 +82,7 @@ if (!theme) return; - //Functions - user defined + // Functions - user defined QString pattern("\\b[A-Za-z0-9_]+(?=\\()"); #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); @@ -95,8 +95,8 @@ highlightingRules.append(rule); - //Numerics - pattern = "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b"; + // Numerics + pattern = R"(\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\b)"; theme->setFormat("number", numberFormat); #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); @@ -106,8 +106,8 @@ rule.format = numberFormat; highlightingRules.append(rule); - //Built in functions - these are stored in a text file, so we read it in and parse it - //builtinFunctionFormat.setFontWeight(QFont::Bold); + // Built in functions - these are stored in a text file, so we read it in and parse it + // builtinFunctionFormat.setFontWeight(QFont::Bold); theme->setFormat("builtin_function", builtinFunctionFormat); LoadKeywordsFromFile(pathToFunctionList, builtinFunctionFormat); @@ -116,8 +116,8 @@ // Deprecated functions - these are stored in a text file, so we read it in and parse it // - the font will be a bit darker than that for 'normal' functions, and also underlined deprecatedFunctionFormat = builtinFunctionFormat; - //deprecatedFunctionFormat.setForeground(builtinFunctionFormat.foreground().color().darker(115)); - //deprecatedFunctionFormat.setUnderlineStyle(QTextCharFormat::SpellCheckUnderline ); + // deprecatedFunctionFormat.setForeground(builtinFunctionFormat.foreground().color().darker(115)); + // deprecatedFunctionFormat.setUnderlineStyle(QTextCharFormat::SpellCheckUnderline ); deprecatedFunctionFormat.setToolTip(tr("Deprecated function")); // the tool top seems not to work... theme->setFormat("deprec_function", deprecatedFunctionFormat); @@ -125,9 +125,9 @@ LoadKeywordsFromFile(pathToMacroDeprecatedFunctionList, deprecatedFunctionFormat); - //Keywords - //keywordFormat.setForeground(Qt::darkBlue); - //keywordFormat.setFontWeight(QFont::Bold); + // Keywords + // keywordFormat.setForeground(Qt::darkBlue); + // keywordFormat.setFontWeight(QFont::Bold); theme->setFormat("keyword", keywordFormat); @@ -181,8 +181,8 @@ } // strings - //quotationFormat.setForeground(Qt::darkRed); - pattern = "(\"[^\"]*\")|(\'[^\']*\')"; + // quotationFormat.setForeground(Qt::darkRed); + pattern = R"(("[^"]*")|('[^']*'))"; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); #else @@ -192,9 +192,9 @@ rule.format = quotationFormat; highlightingRules.append(rule); - //Comments - //singleLineCommentFormat.setFontItalic(true); - //singleLineCommentFormat.setForeground(Qt::darkGreen); + // Comments + // singleLineCommentFormat.setFontItalic(true); + // singleLineCommentFormat.setForeground(Qt::darkGreen); pattern = "#[^\n]*"; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); @@ -224,7 +224,7 @@ std::string s; while (!file.atEnd()) { QString s = file.readLine(); - s = "\\b" + s.trimmed() + "\\b"; // note: the Qt docs say that trimmed() should not be necessary, but it is! + s = "\\b" + s.trimmed() + "\\b"; // note: the Qt docs say that trimmed() should not be necessary, but it is! #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(s); #else @@ -257,18 +257,18 @@ MacroHelper::MacroHelper() { languageName_ = "Macro"; - className_ = "MACRO"; - serviceName_ = "macro"; - iconName_ = "MACRO"; + className_ = "MACRO"; + serviceName_ = "macro"; + iconName_ = "MACRO"; QString etcDir = getenv("METVIEW_DIR_SHARE"); if (!etcDir.isEmpty()) etcDir += "/etc/"; - pathToMacroFunctionList_ = etcDir + "FunctionList.txt"; + pathToMacroFunctionList_ = etcDir + "FunctionList.txt"; pathToMacroDeprecatedFunctionList_ = etcDir + "macro_deprecated_functions.txt"; - pathToMacroTemplateList_ = etcDir + "macro_templates.txt"; + pathToMacroTemplateList_ = etcDir + "macro_templates.txt"; } @@ -365,7 +365,7 @@ QStringList capText; QList capPos; int pos = 0; - QRegExp rx("(?:[=?|\\:?|\\s?])?([A-z|0-9|_]+)\\("); + QRegExp rx(R"((?:[=?|\:?|\s?])?([A-z|0-9|_]+)\()"); rx.setMinimal(true); #ifdef MacroHelper_DEBUG_ @@ -431,7 +431,7 @@ // we are within a function if (sum > 0) { functionName = capText[j]; - paramName = whatParam(lines[0], cursorPosInLine); + paramName = whatParam(lines[0], cursorPosInLine); #ifdef MacroHelper_DEBUG_ qDebug() << " function" << functionName; qDebug() << " param" << paramName; @@ -469,7 +469,7 @@ if (pos > cursorPosInLine) break; - prevPos = pos; + prevPos = pos; prevText = text; pos += rx.matchedLength(); } @@ -489,8 +489,8 @@ return; QList rxLst; - rxLst << QRegExp("(rgb\\(\\d*\\.?\\d*,\\d*\\.?\\d*,\\d*\\.?\\d*\\))"); - rxLst << QRegExp("(rgba\\(\\d*\\.?\\d*,\\d*\\.?\\d*,\\d*\\.?\\d*\\))"); + rxLst << QRegExp(R"((rgb\(\d*\.?\d*,\d*\.?\d*,\d*\.?\d*\)))"); + rxLst << QRegExp(R"((rgba\(\d*\.?\d*,\d*\.?\d*,\d*\.?\d*\)))"); foreach (QRegExp rx, rxLst) { rx.setCaseSensitivity(Qt::CaseInsensitive); @@ -499,7 +499,7 @@ while ((pos = rx.indexIn(t, pos)) != -1) { QString capText = rx.cap(1); - int capPos = pos; + int capPos = pos; #ifdef MacroHelper_DEBUG_ qDebug() << " cap:" << std::endl; #endif diff -Nru metview-5.17.4/metview/src/MacroEditor/MacroHelper.h metview-5.19.2/metview/src/MacroEditor/MacroHelper.h --- metview-5.17.4/metview/src/MacroEditor/MacroHelper.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/MacroHelper.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ bool canRun() { return true; } bool canHaveRunOptions() const { return true; } bool runAsService() { return true; } - //bool isHelpAvailableForFunction(QString); + // bool isHelpAvailableForFunction(QString); QChar functionParameterAssignChar() const; bool isHeaderLine(const QString& text); // is the text a header line (e.g. "# Metview Macro")? QString requiredHeaderLine() { return QString("# Metview Macro\n\n"); } // required header line to be added automatically diff -Nru metview-5.17.4/metview/src/MacroEditor/MagMLHelper.cc metview-5.19.2/metview/src/MacroEditor/MagMLHelper.cc --- metview-5.17.4/metview/src/MacroEditor/MagMLHelper.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/MagMLHelper.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ { public: MagMLHighlighter(QTextDocument* parent = nullptr); - ~MagMLHighlighter() = default; + ~MagMLHighlighter() override = default; void highlightBlock(const QString& text) override; @@ -66,7 +66,7 @@ #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); #else - rule.pattern = QRegExp(pattern); + rule.pattern = QRegExp(pattern); #endif rule.format = tagNameFormat; highlightingRules.append(rule); @@ -76,7 +76,7 @@ #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); #else - rule.pattern = QRegExp(pattern); + rule.pattern = QRegExp(pattern); #endif rule.format = tagSymbolsFormat; highlightingRules.append(rule); @@ -86,7 +86,7 @@ #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); #else - rule.pattern = QRegExp(pattern); + rule.pattern = QRegExp(pattern); #endif attributeNameFormat.setForeground(Qt::red); rule.format = attributeNameFormat; @@ -94,11 +94,11 @@ // strings - pattern = "(\"[^\"]*\")|(\'[^\']*\')"; + pattern = R"(("[^"]*")|('[^']*'))"; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); #else - rule.pattern = QRegExp(pattern); + rule.pattern = QRegExp(pattern); #endif quotationFormat.setForeground(Qt::darkRed); rule.format = quotationFormat; @@ -108,10 +108,10 @@ // multi-line comments #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) commentStartExpression = QRegularExpression(""); + commentEndExpression = QRegularExpression("-->"); #else commentStartExpression = QRegExp(""); + commentEndExpression = QRegExp("-->"); #endif multiLineCommentFormat.setFontItalic(true); multiLineCommentFormat.setForeground(Qt::darkGreen); @@ -160,9 +160,9 @@ MagMLHelper::MagMLHelper() { languageName_ = "MagML"; - className_ = "MAGML"; - serviceName_ = "MagML"; - iconName_ = "MAGML"; + className_ = "MAGML"; + serviceName_ = "MagML"; + iconName_ = "MAGML"; } // --------------------------------------------------------------------------- diff -Nru metview-5.17.4/metview/src/MacroEditor/MvMain.cc metview-5.19.2/metview/src/MacroEditor/MvMain.cc --- metview-5.17.4/metview/src/MacroEditor/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -70,7 +70,7 @@ exit(1); } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("MacroEditor"); MvQApplication app(argc, argv, appName.c_str(), {"MacroEdit", "window", "editor"}); diff -Nru metview-5.17.4/metview/src/MacroEditor/mvplaintextedit.cc metview-5.19.2/metview/src/MacroEditor/mvplaintextedit.cc --- metview-5.17.4/metview/src/MacroEditor/mvplaintextedit.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/mvplaintextedit.cc 2023-07-15 08:28:47.000000000 +0000 @@ -96,7 +96,7 @@ // we want to insert enough spaces to bring us to the next 'tab stop' // e.g. if tab_spaces == 4 and we are at column 1, then we add 3 spaces - int row, col; + int row = 0, col = 0; cursorRowCol(&row, &col); int spaces = numSpacesInTab() - ((col - 1) % numSpacesInTab()); @@ -120,8 +120,8 @@ const QTextCursor cursor = textCursor(); QTextBlock cb, b; - int column, line = 1; - cb = cursor.block(); + int column = 0, line = 1; + cb = cursor.block(); column = (cursor.position() - cb.position()) + 1; // find the line number - is there a better way than this? @@ -144,7 +144,7 @@ QChar MvPlainTextEdit::characterBehindCursor(QTextCursor* cursor) { QTextCursor docTextCursor = textCursor(); - QTextCursor* theCursor = (cursor == nullptr) ? &docTextCursor : cursor; + QTextCursor* theCursor = (cursor == nullptr) ? &docTextCursor : cursor; return document()->characterAt(theCursor->position() - 1); } @@ -157,13 +157,13 @@ int MvPlainTextEdit::numLinesSelected() { QTextCursor cursor = textCursor(); // get the document's cursor - int selStart = cursor.selectionStart(); - int selEnd = cursor.selectionEnd(); - QTextBlock bStart = document()->findBlock(selStart); - QTextBlock bEnd = document()->findBlock(selEnd); - int lineStart = bStart.firstLineNumber(); - int lineEnd = bEnd.firstLineNumber(); - int numLines = (lineEnd - lineStart) + 1; + int selStart = cursor.selectionStart(); + int selEnd = cursor.selectionEnd(); + QTextBlock bStart = document()->findBlock(selStart); + QTextBlock bEnd = document()->findBlock(selEnd); + int lineStart = bStart.firstLineNumber(); + int lineEnd = bEnd.firstLineNumber(); + int numLines = (lineEnd - lineStart) + 1; return numLines; } @@ -176,7 +176,7 @@ void MvPlainTextEdit::autoIndentNewLine() { - int i; + int i = 0; QTextCursor cursor = textCursor(); QString indent("\n"); // start with a newline @@ -210,7 +210,7 @@ void MvPlainTextEdit::setDisplayTabsAndSpaces(bool show) { QTextDocument* doc = document(); - QTextOption opt = doc->defaultTextOption(); + QTextOption opt = doc->defaultTextOption(); if (show) opt.setFlags(opt.flags() | QTextOption::ShowTabsAndSpaces); @@ -251,7 +251,7 @@ if (rect.contains(viewport()->rect())) updateLineNumberAreaWidth(-1); - //lineNumberArea_->update(); + // lineNumberArea_->update(); } void MvPlainTextEdit::setShowLineNumbers(bool yes) @@ -328,34 +328,34 @@ void MvPlainTextEdit::mouseDoubleClickEvent(QMouseEvent* e) { - //we try to handle the double-click selection for colour here!! + // we try to handle the double-click selection for colour here!! if (languageHelper_ && languageHelper_->hasVerbFunctionHelp()) { QTextCursor cursor = textCursor(); - QString t = cursor.block().text(); + QString t = cursor.block().text(); if (!t.contains("RGB(", Qt::CaseInsensitive) && !t.contains("RGBA(", Qt::CaseInsensitive)) { return QPlainTextEdit::mouseDoubleClickEvent(e); } int cursorPosInLine = cursor.positionInBlock(); - int startPos = 0; - int endPos = t.size(); + int startPos = 0; + int endPos = t.size(); - QRegularExpression rx("(RGB\\(.+\\)|RGBA\\(.+\\))"); + QRegularExpression rx(R"((RGB\(.+\)|RGBA\(.+\)))"); rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption); - int pos = 0; + int pos = 0; bool found = false; auto rmatch = rx.match(t, pos); while (rmatch.hasMatch()) { QString capText = rmatch.captured(1); - int capPos = rmatch.capturedStart(1); + int capPos = rmatch.capturedStart(1); // the cursor must be inside the captured text if (cursorPosInLine >= capPos && cursorPosInLine <= capPos + capText.length()) { startPos = capPos; - endPos = capPos + capText.length(); - found = true; + endPos = capPos + capText.length(); + found = true; break; } pos += rmatch.capturedLength(1); @@ -386,20 +386,20 @@ void MvPlainTextEdit::lineNumberAreaPaintEvent(QPaintEvent* event) { - int currentRow, currentCol; + int currentRow = 0, currentCol = 0; cursorRowCol(¤tRow, ¤tCol); // get the current line number so we can highlight it QPainter painter(lineNumberArea); painter.fillRect(event->rect(), lineNumberArea->bgColour()); QTextBlock block = firstVisibleBlock(); - int blockNumber = block.blockNumber(); - int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top(); - int bottom = top + (int)blockBoundingRect(block).height(); + int blockNumber = block.blockNumber(); + int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top(); + int bottom = top + (int)blockBoundingRect(block).height(); painter.setPen(lineNumberArea->textColour()); - QFont f = font(); //the editor font + QFont f = font(); // the editor font QFont fontNormal(f.family(), f.pointSize()); // the font to use for most line numbers fontNormal.setFixedPitch(true); @@ -432,8 +432,8 @@ } } - block = block.next(); - top = bottom; + block = block.next(); + top = bottom; bottom = top + (int)blockBoundingRect(block).height(); ++blockNumber; } @@ -451,7 +451,7 @@ QPoint p(MvQ::eventPos(event)); QTextCursor tempCursor(cursorForPosition(p)); setTextCursor(tempCursor); - //setFocus(Qt::MouseFocusReason); + // setFocus(Qt::MouseFocusReason); event->accept(); } } @@ -499,7 +499,7 @@ system(st.toUtf8().constData()); - //qDebug() << st; + // qDebug() << st; // insert text to the Macro editor QFile file(temp.str().c_str()); @@ -518,7 +518,7 @@ return; } -//Set the colour scheme +// Set the colour scheme void MvPlainTextEdit::setTheme(EditorTheme* theme) { Q_ASSERT(theme); @@ -535,7 +535,7 @@ styleStr += "color: " + col.name() + ";"; } - //qDebug() << "style" << styleStr; + // qDebug() << "style" << styleStr; if (!styleStr.isEmpty()) setStyleSheet("QPlainTextEdit:focus{" + styleStr + @@ -544,7 +544,7 @@ styleStr + "selection-color: black; selection-background-color: rgb(180,204,234);}"); - //QString family = theme->value("font"); + // QString family = theme->value("font"); QFont f = MvQ::findMonospaceFont(); f.setPointSize(font().pointSize()); setFont(f); @@ -564,10 +564,10 @@ Q_ASSERT(maxLineNum > 0); QTextCursor cursor = textCursor(); - QTextBlock block = cursor.block(); + QTextBlock block = cursor.block(); QStringList res; QString t = block.text(); - t = t.left(cursor.positionInBlock()); + t = t.left(cursor.positionInBlock()); res << t; block = block.previous(); @@ -589,7 +589,7 @@ lines.clear(); QTextCursor cursor = textCursor(); - cursorPos = cursor.positionInBlock(); + cursorPos = cursor.positionInBlock(); QString sel = cursor.selectedText(); if (!sel.isEmpty() && cursor.position() == cursor.selectionEnd()) { @@ -631,22 +631,22 @@ QSize LineNumberArea::sizeHint() const { - return QSize(computedWidth(textEditor_->totalLineNumber()), 0); + return {computedWidth(textEditor_->totalLineNumber()), 0}; } void LineNumberArea::setTheme(EditorTheme* theme) { if (theme) { QColor col = theme->colour("lineNumBg"); - bgCol_ = col; + bgCol_ = col; - col = theme->colour("lineNumSelectBg"); + col = theme->colour("lineNumSelectBg"); selectBgCol_ = col; - col = theme->colour("lineNumBorder"); + col = theme->colour("lineNumBorder"); borderCol_ = col; - col = theme->colour("lineNumText"); + col = theme->colour("lineNumText"); textCol_ = col; } } @@ -665,7 +665,7 @@ int LineNumberArea::computedWidth(int maxLineNum) const { int maxDigits = 1; - int mx = maxLineNum; + int mx = maxLineNum; while (mx >= 10) { mx /= 10; ++maxDigits; @@ -674,7 +674,7 @@ if (maxDigits > digits_) digits_ = maxDigits; - int oneW = MvQ::textWidth(textEditor_->fontMetrics(), QLatin1Char('9')); + int oneW = MvQ::textWidth(textEditor_->fontMetrics(), QLatin1Char('9')); rightMargin_ = oneW / 3; return leftMargin_ + oneW * maxDigits + rightMargin_; diff -Nru metview-5.17.4/metview/src/MacroEditor/PlainTextHelper.cc metview-5.19.2/metview/src/MacroEditor/PlainTextHelper.cc --- metview-5.17.4/metview/src/MacroEditor/PlainTextHelper.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/PlainTextHelper.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,9 +38,9 @@ PlainTextHelper::PlainTextHelper() { languageName_ = "Plain Text"; - className_ = "NOTE"; - serviceName_ = "none"; - iconName_ = "NOTE"; + className_ = "NOTE"; + serviceName_ = "none"; + iconName_ = "NOTE"; } diff -Nru metview-5.17.4/metview/src/MacroEditor/PythonHelper.cc metview-5.19.2/metview/src/MacroEditor/PythonHelper.cc --- metview-5.17.4/metview/src/MacroEditor/PythonHelper.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/PythonHelper.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ { public: PythonHighlighter(QTextDocument* parent = nullptr); - ~PythonHighlighter() = default; + ~PythonHighlighter() override = default; protected: QTextCharFormat keywordFormat; @@ -62,7 +62,7 @@ if (!theme) return; - //Functions - user defined + // Functions - user defined QString pattern = "\\b[A-Za-z0-9_]+(?=\\()"; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); @@ -74,8 +74,8 @@ highlightingRules.append(rule); - //Numerics - pattern = "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b"; + // Numerics + pattern = R"(\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\b)"; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); #else @@ -85,7 +85,7 @@ rule.format = numberFormat; highlightingRules.append(rule); - //Built in functions + // Built in functions theme->setFormat("builtin_function", builtinFunctionFormat); // the list of builtins was generated from Python as follows: @@ -196,13 +196,13 @@ // Deprecated functions - these are stored in a text file, so we read it in and parse it // - the font will be a bit darker than that for 'normal' functions, and also underlined - //TODO: implement it!!! + // TODO: implement it!!! deprecatedFunctionFormat = builtinFunctionFormat; deprecatedFunctionFormat.setToolTip(tr("Deprecated function")); // the tool top seems not to work... theme->setFormat("deprec_function", deprecatedFunctionFormat); - //Keywords + // Keywords theme->setFormat("keyword", keywordFormat); // the list of keywords was generated from Python as follows: @@ -314,8 +314,8 @@ } // strings - //quotationFormat.setForeground(Qt::darkRed); - pattern = "(\"[^\"]*\")|(\'[^\']*\')"; + // quotationFormat.setForeground(Qt::darkRed); + pattern = R"(("[^"]*")|('[^']*'))"; theme->setFormat("string", quotationFormat); #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); @@ -326,7 +326,7 @@ highlightingRules.append(rule); - //Comments + // Comments pattern = "#[^\n]*"; #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) rule.pattern = QRegularExpression(pattern); @@ -351,9 +351,9 @@ PythonHelper::PythonHelper() { languageName_ = "Python"; - className_ = "PYTHON"; - serviceName_ = "(x=`dirname \"%s\"`;cd \"$x\" ; python3 \"%s\")"; - iconName_ = "PYTHON"; + className_ = "PYTHON"; + serviceName_ = R"((x=`dirname "%s"`;cd "$x" ; python3 "%s"))"; + iconName_ = "PYTHON"; QString etcDir = getenv("METVIEW_DIR_SHARE"); @@ -443,7 +443,7 @@ QStringList capText; QList capPos; int pos = 0; - QRegExp rx("(?:[=?|\\:?|\\s?])?(mv\\.[A-z|0-9|_]+)\\("); + QRegExp rx(R"((?:[=?|\:?|\s?])?(mv\.[A-z|0-9|_]+)\()"); rx.setMinimal(true); #ifdef PYTHONHELPER_DEBUG_ qDebug() << "line:" << t; @@ -508,7 +508,7 @@ // we are within a function if (sum > 0) { functionName = capText[j].mid(3); - paramName = whatParam(lines[0], cursorPosInLine); + paramName = whatParam(lines[0], cursorPosInLine); #ifdef PYTHONHELPER_DEBUG_ qDebug() << " function" << functionName; qDebug() << " param" << paramName; @@ -545,7 +545,7 @@ if (pos > cursorPosInLine) break; - prevPos = pos; + prevPos = pos; prevText = text; pos += rx.matchedLength(); } @@ -565,8 +565,8 @@ return; QList rxLst; - rxLst << QRegExp("(rgb\\(\\d*\\.?\\d*,\\d*\\.?\\d*,\\d*\\.?\\d*\\))"); - rxLst << QRegExp("(rgba\\(\\d*\\.?\\d*,\\d*\\.?\\d*,\\d*\\.?\\d*\\))"); + rxLst << QRegExp(R"((rgb\(\d*\.?\d*,\d*\.?\d*,\d*\.?\d*\)))"); + rxLst << QRegExp(R"((rgba\(\d*\.?\d*,\d*\.?\d*,\d*\.?\d*\)))"); foreach (QRegExp rx, rxLst) { rx.setCaseSensitivity(Qt::CaseInsensitive); @@ -575,7 +575,7 @@ while ((pos = rx.indexIn(t, pos)) != -1) { QString capText = rx.cap(1); - int capPos = pos; + int capPos = pos; #ifdef PYTHONHELPER_DEBUG_ qDebug() << " cap:"; #endif diff -Nru metview-5.17.4/metview/src/MacroEditor/RunDialog.cc metview-5.19.2/metview/src/MacroEditor/RunDialog.cc --- metview-5.17.4/metview/src/MacroEditor/RunDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/RunDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -54,15 +54,15 @@ MacroRunOptions options; options.sendLines_ = highlightLineCheckBox->isChecked(); - options.waitMode_ = waitCheckBox->isChecked(); - options.trace_ = traceCheckBox->isChecked(); + options.waitMode_ = waitCheckBox->isChecked(); + options.trace_ = traceCheckBox->isChecked(); if (PauseComboBox->currentIndex() == 0) options.pause_ = 0; else { QStringList strlist = PauseComboBox->currentText().split(" "); - options.pause_ = strlist[0].toInt(); + options.pause_ = strlist[0].toInt(); } diff -Nru metview-5.17.4/metview/src/MacroEditor/RunDialog.h metview-5.19.2/metview/src/MacroEditor/RunDialog.h --- metview-5.17.4/metview/src/MacroEditor/RunDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/RunDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -30,6 +30,6 @@ public slots: void done(); - //void setButtonStatus(); - //void onUseSpacesChanged(); + // void setButtonStatus(); + // void onUseSpacesChanged(); }; diff -Nru metview-5.17.4/metview/src/MacroEditor/ShellHelper.cc metview-5.19.2/metview/src/MacroEditor/ShellHelper.cc --- metview-5.17.4/metview/src/MacroEditor/ShellHelper.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/ShellHelper.cc 2023-07-15 08:28:47.000000000 +0000 @@ -37,9 +37,9 @@ ShellHelper::ShellHelper() { languageName_ = "Shell"; - className_ = "SHELL"; - serviceName_ = "(x=`dirname \"%s\"`;cd \"$x\" ; sh \"%s\")"; - iconName_ = "SHELL"; + className_ = "SHELL"; + serviceName_ = R"((x=`dirname "%s"`;cd "$x" ; sh "%s"))"; + iconName_ = "SHELL"; } diff -Nru metview-5.17.4/metview/src/MacroEditor/TabsDialog.cc metview-5.19.2/metview/src/MacroEditor/TabsDialog.cc --- metview-5.17.4/metview/src/MacroEditor/TabsDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/TabsDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -97,11 +97,11 @@ TabsSettings settings; int numSpaces = numSpacesLineEdit->text().toInt(); - settings.useSpacesForTabs = useSpacesCheckBox->isChecked(); - settings.numSpacesInTab = numSpaces; - settings.useSpacesForDrops = droppedIconSpacesCheckBox->isChecked(); + settings.useSpacesForTabs = useSpacesCheckBox->isChecked(); + settings.numSpacesInTab = numSpaces; + settings.useSpacesForDrops = droppedIconSpacesCheckBox->isChecked(); settings.displayTabsAndSpaces = displayTabsAndSpacesCheckBox->isChecked(); - settings.autoIndent = autoIndentCheckBox->isChecked(); + settings.autoIndent = autoIndentCheckBox->isChecked(); emit tabsSettingsChanged(settings); close(); diff -Nru metview-5.17.4/metview/src/MacroEditor/TabsDialog.h metview-5.19.2/metview/src/MacroEditor/TabsDialog.h --- metview-5.17.4/metview/src/MacroEditor/TabsDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/TabsDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -30,6 +30,6 @@ public slots: void done(); - //void setButtonStatus(); + // void setButtonStatus(); void onUseSpacesChanged(); }; diff -Nru metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelp.cc metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelp.cc --- metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -59,7 +59,7 @@ QStringList VerbFunctionHelpParam::defaultValues() const { QStringList lst; - for (auto it : param_.defaults()) { + for (const auto& it : param_.defaults()) { lst << QString::fromStdString(it).toLower(); } return lst; @@ -76,7 +76,7 @@ Request r = param_.interfaceRequest(); if (r) { const std::vector& cls = r.get("class"); - for (auto clsName : cls) { + for (const auto& clsName : cls) { if (IconClassHelp* clsH = IconClassHelp::find(clsName)) { if (QString::fromStdString(clsH->name()).toLower().startsWith("m")) { return QString::fromStdString(clsH->macroFunction()); @@ -107,7 +107,7 @@ void VerbFunctionHelpParam::toYaml(std::ofstream& out) { out << "- " << name().toLower().toStdString() << ":" << std::endl; - auto dv = defaultValues(); + auto dv = defaultValues(); std::string parType = interface().toStdString(); if (dv.count() > 0) { @@ -166,7 +166,7 @@ if (!parType.empty()) out << " type: " << parType << std::endl; - //out << " interface: " << interface().toStdString() << std::endl; + // out << " interface: " << interface().toStdString() << std::endl; } } @@ -202,7 +202,7 @@ void VerbFunctionHelpFunction::next(const MvIconParameter& p) { bool visible = true; - Request r = p.interfaceRequest(); + Request r = p.interfaceRequest(); if (r) { if (const char* vs = r("visible")) { if (strcmp(vs, "false") == 0) @@ -344,7 +344,7 @@ if (functions_.size() > 0) return; - for (auto it : IconClassHelp::items()) { + for (const auto& it : IconClassHelp::items()) { QString fname = QString::fromStdString(it.second->macroFunction()).simplified().toLower(); if (!it.second->isObsolete() && !fname.isEmpty() && it.second->type() != "File") { functionMap_[fname] = new VerbFunctionHelpFunction(fname, it.second); @@ -359,7 +359,7 @@ QString line; while (!file.atEnd() && !line.startsWith("-----")) { - line = file.readLine().simplified(); + line = file.readLine().simplified(); int pos = line.indexOf(":"); if (pos != -1) webIds_[line.left(pos).simplified()] = line.mid(pos + 1).simplified(); @@ -388,25 +388,36 @@ continue; if (item.startsWith("type:") && !currentName.isEmpty()) { - currentFn = nullptr; + currentFn = nullptr; QStringList lst = item.split("type:"); if (lst.count() == 2) { if (lst[1].simplified() == "script") { // it must be a non-iconclass functions!! if (IconClassHelp::findByMacroFunction(currentName.toStdString()) == nullptr) { - auto* fn = new VerbFunctionHelpFunction(currentName); - currentFn = fn; + auto* fn = new VerbFunctionHelpFunction(currentName); + currentFn = fn; functionMap_[currentName] = fn; } } } - } - else if (item.startsWith("desc:") && currentFn) { + } else if (item.startsWith("lang:") && currentFn) { + QStringList lst = item.split("lang:"); + if (lst.count() == 2) { + QString lang = lst[1].simplified(); + if (lang != language_->name().toLower()) { + functionMap_.erase(currentName); + currentFn = nullptr; + } else if (lang == "macro") { + currentFn->setMacroOnly(true); + + } + } + } else if (item.startsWith("desc:") && currentFn) { QStringList lst = item.split("desc:"); if (lst.count() == 2) { QString ds = lst[1].simplified(); - int p1 = ds.indexOf("["); - int p2 = ds.indexOf("]"); + int p1 = ds.indexOf("["); + int p2 = ds.indexOf("]"); if (p1 >= 0 && p2 > p1) { QString group = ds.mid(p1 + 1, p2 - p1 - 1); currentFn->setDescription(group, ds.mid(p2 + 1).simplified()); @@ -415,12 +426,12 @@ } else { currentName = item; - currentFn = nullptr; + currentFn = nullptr; } } } - for (auto it : functionMap_) { + for (const auto& it : functionMap_) { functions_ << it.second; it.second->adjustDescriptions(); } @@ -435,7 +446,7 @@ #ifdef GENERATE_ICONCLASS_YAML - std::string outDir = "/tmp/" + std::string(getenv("USER")) + "/icon_class"; + std::string outDir = "/tmp/" + std::string(getenv("USER")) + "/icon_class"; std::string outFile = outDir + "/index.yaml"; std::ofstream out; @@ -447,7 +458,7 @@ QString(kind->type().c_str()).toLower() != "folder") { auto icFile = MvQTheme::icIconFile(kind->pixmap()); Path pixPath(icFile.toStdString()); -// qDebug() << " fname" << QString::fromStdString(pixPath.str()); + // qDebug() << " fname" << QString::fromStdString(pixPath.str()); if (pixPath.exists()) { out << "- icon: " << kind->name() << std::endl; out << " web: " << kind->defaultName() << std::endl; @@ -460,7 +471,7 @@ std::string pixName, pixSuffix; pixPath.nameAndSuffix(pixName, pixSuffix); -// QIcon icon(pixPath.str().c_str()); + // QIcon icon(pixPath.str().c_str()); pixName += ".png"; out << " pixmap: " << pixName << std::endl; @@ -483,7 +494,7 @@ if (!kind->isObsolete() && !kind->isFamilyMember() && QString(kind->type().c_str()).toLower() != "folder" && kind->definitionFile().exists()) { - QString fname = QString::fromStdString(kind->macroFunction()).simplified().toLower(); + QString fname = QString::fromStdString(kind->macroFunction()).simplified().toLower(); std::string outFile = outDir + "/" + fname.toStdString() + "_def.yaml"; std::ofstream out; out.open(outFile.c_str()); @@ -542,37 +553,24 @@ return -1; } -QString VerbFunctionHelp::url(QString webGroup, QString fnName) -{ - if (webGroup.isEmpty()) - return {}; - - QString base = webIds_.value("url"); - if (!base.isEmpty()) { - if (fnName.isEmpty()) - return base + webIds_.value(webGroup); - else { - QString page = webIds_.value(webGroup); - QString pageAnchor = page; - return base + page + "#" + pageAnchor.replace("+", "") + "-" + fnName; - } - } - - return {}; -} - -QString VerbFunctionHelp::iconUrl(VerbFunctionHelpFunction* fn) +QString VerbFunctionHelp::url(VerbFunctionHelpFunction* fn, int descIndex) { - if (fn) { - QString base = webIds_.value("url"); - if (!base.isEmpty()) { - if (IconClassHelp* ic = fn->iconClass()) { - QString page = QString::fromStdString(ic->helpPage()); - return base + page; + if (fn != nullptr) { + if (!fn->isMacroOnly()) { + QString webGroup = fn->isIconFunction()?"icon_url":"script_url"; + QString base = webIds_.value(webGroup); + if (!base.isEmpty()) { + return base + fn->name() + ".html"; + } + } else { + QPair desc = fn->descriptions()[descIndex]; + QString base = webIds_.value("macro_url"); + QString webGroup = webIds_.value(desc.first); + if (!base.isEmpty()) { + return base + webGroup + ".html"; } } } - return {}; } diff -Nru metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelp.h metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelp.h --- metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelp.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelp.h 2023-07-15 08:28:47.000000000 +0000 @@ -90,7 +90,10 @@ VerbFunctionHelpParam* param(int i) const; int indexOfParam(VerbFunctionHelpParam*) const; IconClassHelp* iconClass() const { return iconClass_; } + bool isIconFunction() const {return iconClass_ != nullptr;} void loadParams(); + void setMacroOnly(bool b) {macroOnly_=b;} + bool isMacroOnly() const {return macroOnly_;} QString descriptionAsStr(int idx) const; QString descriptionAsRt(int idx) const; @@ -108,6 +111,7 @@ std::vector params_; std::map paramMap_; QList > descriptions_; + bool macroOnly_{false}; }; //------------------------------------------------------------------------------------- @@ -134,8 +138,7 @@ VerbFunctionHelpFunction* itemAt(int i) const; QPair itemAtInTotal(int i) const; int totalIndexOf(VerbFunctionHelpFunction* fn, int descIndex); - QString url(QString webGroup, QString fnName); - QString iconUrl(VerbFunctionHelpFunction*); + QString url(VerbFunctionHelpFunction* fn, int descIndex=0); QString scopePrefix() const; private: diff -Nru metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelpWidget.cc metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelpWidget.cc --- metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelpWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelpWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -243,7 +243,7 @@ return tr("Default"); } - return QVariant(); + return {}; } Qt::ItemFlags VerbFunctionHelpParamModel::flags(const QModelIndex& index) const @@ -257,16 +257,16 @@ QModelIndex VerbFunctionHelpParamModel::index(int row, int column, const QModelIndex&) const { if (!data_ || row < 0 || column < 0) { - return QModelIndex(); + return {}; } - return createIndex(row, column, static_cast(0)); + return createIndex(row, column, static_cast(nullptr)); } QModelIndex VerbFunctionHelpParamModel::parent(const QModelIndex&) const { - return QModelIndex(); + return {}; } void VerbFunctionHelpParamModel::setHelpData(VerbFunctionHelpFunction* data) @@ -338,7 +338,7 @@ QVariant VerbFunctionHelpValueModel::headerData(const int /*section*/, const Qt::Orientation /*orient*/, const int /*role*/) const { - return QVariant(); + return {}; } Qt::ItemFlags VerbFunctionHelpValueModel::flags(const QModelIndex& index) const @@ -352,15 +352,15 @@ QModelIndex VerbFunctionHelpValueModel::index(int row, int column, const QModelIndex&) const { if (!data_ || row < 0 || column < 0) { - return QModelIndex(); + return {}; } - return createIndex(row, column, static_cast(0)); + return createIndex(row, column, static_cast(nullptr)); } QModelIndex VerbFunctionHelpValueModel::parent(const QModelIndex&) const { - return QModelIndex(); + return {}; } void VerbFunctionHelpValueModel::setHelpData(VerbFunctionHelpParam* data) @@ -397,9 +397,6 @@ connect(ui_->showFunctionListTb, SIGNAL(clicked()), this, SIGNAL(functionListRequested())); - ui_->descriptionLabel->setWordWrap(true); - ui_->descriptionLabel->setProperty("type", "info"); - connect(ui_->fontSizeDownTb, SIGNAL(clicked()), this, SLOT(slotFontSizeDown())); @@ -429,13 +426,13 @@ //----------------------------------- int cnt = 0; - ParamValueEditor* e; - e = new ParamListValueEditor("list", cnt, this); + ParamValueEditor* e = nullptr; + e = new ParamListValueEditor("list", cnt, this); editors_["list"] = e; ui_->editorStackW->addWidget(e->realWidget()); cnt++; - e = new ParamColourValueEditor("colour", cnt, this); + e = new ParamColourValueEditor("colour", cnt, this); editors_["colour"] = e; ui_->editorStackW->addWidget(e->realWidget()); cnt++; @@ -465,7 +462,7 @@ ui_->tab->setCurrentIndex(0); - //Adjust tree columns + // Adjust tree columns QFont f; QFontMetrics fm(f); ui_->paramTree->setColumnWidth(0, MvQ::textWidth(fm, "grib_interpolation_method_missing_fill_count")); @@ -486,7 +483,7 @@ QString sh = "QLabel{background: " + editorTheme_->colour("background").name() + "; color: " + editorTheme_->colour("text").name() + ";}"; QFont f(editorFont.family()); - //f.setPointSize(f.pointSize()+1); + // f.setPointSize(f.pointSize()+1); f.setFixedPitch(true); f.setPointSize(currentTreeFontSize()); ui_->selectionLabel->setStyleSheet(sh); @@ -571,37 +568,36 @@ if (param) { QString editorType = param->interface(); - if (editorType == "menu" || editorType == "option_menu" || editorType == "on_off") + if (editorType == "menu" || editorType == "option_menu" || editorType == "on_off" || + editorType == "line_style") editorType = "list"; if (!editorType.isEmpty()) { ParamValueEditor* e = editors_.value(editorType, nullptr); - if (!e) { + if (e == nullptr) { if (currentEditor_) currentEditor_->clear(); currentEditor_ = nullptr; - ui_->valuesLabel->hide(); - ui_->editorStackW->hide(); + ui_->editorHolderW->hide(); } else { if (currentEditor_ != e) { currentEditor_ = e; ui_->editorStackW->setCurrentWidget(e->realWidget()); - ui_->valuesLabel->setVisible(true); - ui_->editorStackW->setVisible(true); + ui_->valuesLabel->setText("" + param->name() + ": set/select value"); + ui_->editorHolderW->show(); } currentEditor_->setParam(param); } } else { - if (currentEditor_) { + if (currentEditor_ != nullptr) { currentEditor_->clear(); currentEditor_ = nullptr; } - ui_->valuesLabel->hide(); - ui_->editorStackW->hide(); + ui_->editorHolderW->hide(); } } @@ -662,19 +658,12 @@ ui_->functionNameLabel->setText("" + fn->name() + "()"); if (IconClassHelp* ic = fn->iconClass()) { - ui_->descriptionLabel->show(); - ui_->descriptionLabel->setText(QString::fromStdString(ic->defaultName())); - } - else { - ui_->descriptionLabel->clear(); - ui_->descriptionLabel->hide(); +// ui_->descriptionLabel->setText(QString::fromStdString(ic->defaultName())); } } else { ui_->functionIconLabel->setPixmap(QPixmap()); ui_->functionNameLabel->setText(""); - ui_->descriptionLabel->clear(); - ui_->descriptionLabel->hide(); } } @@ -723,7 +712,7 @@ void VerbFunctionHelpWidget::slotWebDoc() { if (VerbFunctionHelpFunction* fn = paramModel_->helpData()) { - QString web = language_->functionHelp()->iconUrl(fn); + QString web = language_->functionHelp()->url(fn); std::string err; if (!metview::openInBrowser(web.toStdString(), err)) { QMessageBox::warning(this, "Code editor - Metview", @@ -764,14 +753,17 @@ void VerbFunctionHelpWidget::writeSettings(QSettings& settings) { settings.beginGroup("VerbFunctionHelpWidget"); + settings.setValue("paramTreeSplitter", ui_->paramTreeSplitter->saveState()); MvQ::saveTreeColumnWidth(settings, "paramTreeWidth", ui_->paramTree); - settings.setValue("fontSize", ui_->paramTree->font().pointSize()); + settings.setValue("fontSize", ui_->paramTree->font().pointSize()); settings.endGroup(); } void VerbFunctionHelpWidget::readSettings(QSettings& settings) { settings.beginGroup("VerbFunctionHelpWidget"); + ui_->paramTreeSplitter->restoreState(settings.value("paramTreeSplitter").toByteArray()); + MvQ::initTreeColumnWidth(settings, "paramTreeWidth", ui_->paramTree); int fs = settings.value("fontSize").toInt(); diff -Nru metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelpWidget.h metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelpWidget.h --- metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelpWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelpWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,12 +31,12 @@ Q_OBJECT public: ParamValueEditor(QString id, int index, QWidget* parent); - virtual QString value() = 0; + virtual QString value() = 0; virtual void setParam(VerbFunctionHelpParam*) = 0; - virtual QWidget* realWidget() = 0; - virtual void clear() = 0; - virtual void fontSizeUp() = 0; - virtual void fontSizeDown() = 0; + virtual QWidget* realWidget() = 0; + virtual void clear() = 0; + virtual void fontSizeUp() = 0; + virtual void fontSizeDown() = 0; signals: void valueChanged(QString); diff -Nru metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelpWidget.ui metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelpWidget.ui --- metview-5.17.4/metview/src/MacroEditor/VerbFunctionHelpWidget.ui 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MacroEditor/VerbFunctionHelpWidget.ui 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ - + 1 @@ -100,37 +100,6 @@ - - - Function list - - - - :/macroEditor/narrow_arrow_left.svg:/macroEditor/narrow_arrow_left.svg - - - Qt::ToolButtonTextBesideIcon - - - false - - - Qt::NoArrow - - - - - - - - - - - TextLabel - - - - Decrease font size @@ -139,7 +108,7 @@ ... - + :/macroEditor/fontsize_down.svg:/macroEditor/fontsize_down.svg @@ -153,7 +122,7 @@ ... - + :/macroEditor/fontsize_up.svg:/macroEditor/fontsize_up.svg @@ -161,6 +130,42 @@ + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 4 + 20 + + + + + + + + Function list + + + + :/macroEditor/narrow_arrow_left.svg:/macroEditor/narrow_arrow_left.svg + + + Qt::ToolButtonTextBesideIcon + + + false + + + Qt::NoArrow + + + @@ -172,10 +177,7 @@ Icon parameters - - - 1 - + 0 @@ -189,57 +191,62 @@ 0 - - - false + + + Qt::Vertical - - true + + 6 - - - - - - - - - <b>Values:</b> + + false + + + false + + + true + + + + + + + + + + + Values + + + + + + + true + + + + + 0 + 0 + 798 + 170 + + + + + + + - - - - - - background-color: rgb(216, 216, 216); - - - - 0 - - - 2 - - - 1 - - - 0 - - - 1 - - - - - @@ -342,7 +349,7 @@ Documentation - + :/macroEditor/web_link.svg:/macroEditor/web_link.svg @@ -359,7 +366,7 @@ - + diff -Nru metview-5.17.4/metview/src/MagML/MagML.cc metview-5.19.2/metview/src/MagML/MagML.cc --- metview-5.17.4/metview/src/MagML/MagML.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MagML/MagML.cc 2023-07-15 08:28:47.000000000 +0000 @@ -99,7 +99,7 @@ /******************************************************************************** - MagicsLogObserver: derived from the Magics MagicsObserver, this is + MagicsLogObserver: derived from the Magics MagicsObserver, this is created so that we can receive callbacks whenever Magics logs any messages. @@ -108,7 +108,7 @@ class MagicsLogObserver : public magics::MagicsObserver { public: - MagicsLogObserver() = default; + MagicsLogObserver() = default; ~MagicsLogObserver() = default; @@ -167,8 +167,8 @@ static void substitute(std::string& xml, const std::string& var, const std::string& val) { std::string name = "$" + var; - size_t index = xml.find(name); - int last = 0; + size_t index = xml.find(name); + int last = 0; while (index != std::string::npos) { xml.replace(index, name.length(), val); @@ -215,7 +215,7 @@ std::string xml = marstmp(); - std::string ps = (magml_visitor.hasDriversNode) ? "" : marstmp(); + std::string ps = (magml_visitor.hasDriversNode) ? "" : marstmp(); if (!ps.empty()) { ParameterManager::set("output_fullname", ps); @@ -276,7 +276,7 @@ if (!ps.empty()) { MvRequest data("PSFILE"); - data("PATH") = ps.c_str(); + data("PATH") = ps.c_str(); data("TEMPORARY") = 1; data.print(); out = data; diff -Nru metview-5.17.4/metview/src/Met3D/Met3D.cc metview-5.19.2/metview/src/Met3D/Met3D.cc --- metview-5.17.4/metview/src/Met3D/Met3D.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Met3D/Met3D.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,15 +18,15 @@ Met3D::Met3D(const char* kw) : MvService(kw) { - //empty + // empty } Met3D::~Met3D() = default; void Met3D::serve(MvRequest& in, MvRequest& /*out*/) { - //cout << "Met3D::serve in" << std::endl; - //in.print(); + // cout << "Met3D::serve in" << std::endl; + // in.print(); // Get information from the user interface if (!GetInputInfo(in)) @@ -110,7 +110,7 @@ if (!frontend_file_.empty()) cmd += " --frontend=" + frontend_file_; - //cout << "Met3D command: " << cmd << std::endl; + // cout << "Met3D command: " << cmd << std::endl; // Execute command line int ret = system(cmd.c_str()); @@ -161,9 +161,9 @@ // The applications don't try to read or write from pool, this // should not be done with the new PlotMod. - //a.addModeService("GRIB", "DATA"); - //c.saveToPool(false); - //met3d.saveToPool(false); + // a.addModeService("GRIB", "DATA"); + // c.saveToPool(false); + // met3d.saveToPool(false); theApp.run(); } diff -Nru metview-5.17.4/metview/src/Met3D/Met3DPrepare.cc metview-5.19.2/metview/src/Met3D/Met3DPrepare.cc --- metview-5.17.4/metview/src/Met3D/Met3DPrepare.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Met3D/Met3DPrepare.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ protected: void registerCallbacks(); - virtual void reply(const MvRequest&) = 0; + virtual void reply(const MvRequest&) = 0; virtual void progress(const MvRequest&) = 0; }; @@ -52,7 +52,7 @@ void MvMacroCallerService::progressCb(svcid* /*id*/, request* r, void* obj) { - //std::cout << "PROG callback: " << std::endl; + // std::cout << "PROG callback: " << std::endl; MvRequest in(r); if (auto* b = static_cast(obj)) b->progress(in); @@ -60,8 +60,8 @@ void MvMacroCallerService::replyCb(svcid* /*id*/, request* r, void* obj) { - //std::cout << "REPLY: " << std::endl; - //print_all_requests(r); + // std::cout << "REPLY: " << std::endl; + // print_all_requests(r); MvRequest in(r); if (auto* b = static_cast(obj)) b->reply(in); @@ -101,9 +101,9 @@ levelTypeIds_["ML"] = "ml"; prodIds_["HIRES"] = "hires"; - prodIds_["ENS"] = "ens"; + prodIds_["ENS"] = "ens"; - onOffIds_["ON"] = "1"; + onOffIds_["ON"] = "1"; onOffIds_["OFF"] = "0"; } @@ -138,17 +138,17 @@ std::vector param; - //retrieve mode + // retrieve mode std::string retMode; FLEXTRA_CHK(in.getValueId("RETRIEVE_GROUP_BY_TIME", retMode, onOffIds_)); param.push_back(retMode); - //perparation mode + // perparation mode std::string prepMode; FLEXTRA_CHK(in.getValueId("MODE", prepMode, modeIds_)); param.push_back(prepMode); - //Product + // Product std::string prod; if (prepMode != "an") FLEXTRA_CHK(in.getValueId("PRODUCT", prod, prodIds_)); @@ -157,7 +157,7 @@ param.push_back(prod); - //ENS member + // ENS member if (prod == "ens") { std::vector ensNumbers; FLEXTRA_CHK(in.getValue("NUMBER", ensNumbers)); @@ -167,31 +167,31 @@ param.push_back("-1"); } - //level type + // level type std::string levType; FLEXTRA_CHK(in.getValueId("LEVTYPE", levType, levelTypeIds_)); param.push_back(levType); - //pressure levels + // pressure levels if (levType == "pl") { std::vector plLevels; FLEXTRA_CHK(in.getValue("PL_LEVELIST", plLevels)); param.push_back(metview::merge(plLevels, "/")); } - //model levels + // model levels else if (levType == "ml") { std::vector mlLevels; FLEXTRA_CHK(in.getValue("ML_LEVELIST", mlLevels)); param.push_back(metview::merge(mlLevels, "/")); } - //surf params + // surf params std::vector surfParams; FLEXTRA_CHK(in.getValue("PARAMS_2D", surfParams)); param.push_back(metview::merge(surfParams, "/")); - //upper params + // upper params std::vector upperParams; FLEXTRA_CHK(in.getValue("PARAMS_3D", upperParams)); param.push_back(metview::merge(upperParams, "/")); @@ -209,12 +209,12 @@ #endif - //Add area + // Add area std::vector area; FLEXTRA_CHK(in.getValue("AREA", area)); param.push_back(metview::merge(area, "/")); - //Add grid resolution + // Add grid resolution std::vector grid; FLEXTRA_CHK(in.getValue("GRID", grid)); param.push_back(metview::merge(grid, "/")); @@ -303,30 +303,30 @@ } } - //The output file + // The output file char* outPath = marstmp(); - param.insert(param.begin(), std::string(outPath)); //This should be the first argument! + param.insert(param.begin(), std::string(outPath)); // This should be the first argument! - //Build request to be sent to Macro + // Build request to be sent to Macro MvRequest req("MACRO"); std::string processName = MakeProcessName("Met3DPrepare"); MvRequest macroReq("MACRO"); - req("PATH") = prepMacro.c_str(); - req("_CLASS") = "MACRO"; - req("_ACTION") = "execute"; - req("_REPLY") = processName.c_str(); + req("PATH") = prepMacro.c_str(); + req("_CLASS") = "MACRO"; + req("_ACTION") = "execute"; + req("_REPLY") = processName.c_str(); req("_EXTENDMESSAGE") = "1"; - //Define argument list for the macro! + // Define argument list for the macro! for (auto& it : param) { req.addValue("_ARGUMENTS", it.c_str()); } - //const char *cdir=getenv("PWD"); - //marslog(LOG_INFO,"PWD=%s",cdir); + // const char *cdir=getenv("PWD"); + // marslog(LOG_INFO,"PWD=%s",cdir); - //Run macro + // Run macro sendProgress("Met3DPrepare-> Execute macro: %s", prepMacro.c_str()); svc* mysvc = MvApplication::getService(); @@ -385,11 +385,11 @@ return; } #endif - //reply.print(); + // reply.print(); - out = MvRequest("GRIB"); + out = MvRequest("GRIB"); out("TEMPORARY") = 1; - out("PATH") = outPath; + out("PATH") = outPath; std::cout << "--------------FlextraPrepare::serve() out--------------" << std::endl; out.print(); diff -Nru metview-5.17.4/metview/src/Meteogram/MetPlus.cc metview-5.19.2/metview/src/Meteogram/MetPlus.cc --- metview-5.17.4/metview/src/Meteogram/MetPlus.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Meteogram/MetPlus.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,9 +41,9 @@ protected: void handle_local(MvRequest&, MvRequest&); void handle_remote(MvRequest&, MvRequest&); - void join_outputs(const std::vector tempFileNames, const std::string &format, MvRequest &out); - bool download_file(const std::string &url, std::string &target, std::string &msg); - std::string get_image_url_from_metadata(std::string &metadata_path); + void join_outputs(const std::vector tempFileNames, const std::string& format, MvRequest& out); + bool download_file(const std::string& url, std::string& target, std::string& msg); + std::string get_image_url_from_metadata(std::string& metadata_path); std::map local_databases_; std::map remote_databases_; }; @@ -59,16 +59,16 @@ while (setup) { if (setup.getVerb() == Cached("MetPlus")) { - local_databases_["10_days_epsgram"] = "10_days"; - local_databases_["15_days_epsgram"] = "15_days"; - local_databases_["10_days_wave_epsgram"] = "10_days_wave"; - local_databases_["10_days_plumes"] = "10_days_plumes"; + local_databases_["10_days_epsgram"] = "10_days"; + local_databases_["15_days_epsgram"] = "15_days"; + local_databases_["10_days_wave_epsgram"] = "10_days_wave"; + local_databases_["10_days_plumes"] = "10_days_plumes"; local_databases_["15_days_epsgram_with_climate"] = "15_days_with_clim"; - remote_databases_["10_days_epsgram"] = "classical_10d"; - remote_databases_["15_days_epsgram"] = "classical_15d"; - remote_databases_["10_days_wave_epsgram"] = "classical_wave"; - remote_databases_["10_days_plumes"] = "classical_plume"; + remote_databases_["10_days_epsgram"] = "classical_10d"; + remote_databases_["15_days_epsgram"] = "classical_15d"; + remote_databases_["10_days_wave_epsgram"] = "classical_wave"; + remote_databases_["10_days_plumes"] = "classical_plume"; remote_databases_["15_days_epsgram_with_climate"] = "classical_15d_with_climate"; break; @@ -81,7 +81,7 @@ static std::string toString(double val) { std::ostringstream tool; - //tool.width(7); + // tool.width(7); tool.precision(5); tool << val; return tool.str(); @@ -97,8 +97,7 @@ } - -bool Meteogram::download_file(const std::string &url, std::string &target, std::string &msg) +bool Meteogram::download_file(const std::string& url, std::string& target, std::string& msg) { // create a request and delegate the download to the Download module bool ok = true; @@ -117,7 +116,6 @@ } - /* Meteogram::join_outputs Returns the output request (via 'out') containing the path either to the single downloaded @@ -125,9 +123,8 @@ */ -void Meteogram::join_outputs(const std::vector tempFileNames, const std::string &format, MvRequest &out) +void Meteogram::join_outputs(const std::vector tempFileNames, const std::string& format, MvRequest& out) { - std::string outclass; if (format == "ps") outclass = "PSFILE"; @@ -136,7 +133,6 @@ MvRequest data(outclass.c_str()); - if (true) { // check if any of the returned files are either non-existent or of zero-length @@ -153,7 +149,6 @@ // copy the temporary files to their proper destinations if (tempFileNames.size() > 1) { - std::string outputFileName = marstmp(); data("PATH") = outputFileName.c_str(); @@ -187,7 +182,7 @@ } else { data("PATH") = tempFileNames[0].c_str(); - } + } } else { @@ -198,7 +193,7 @@ // return the path to the output file // - this will allow the user to save or visualise the result - //data("TEMPORARY") = 1; + // data("TEMPORARY") = 1; out = data; } @@ -212,12 +207,10 @@ return; } } - } - -std::string Meteogram::get_image_url_from_metadata(std::string &metadata_path) +std::string Meteogram::get_image_url_from_metadata(std::string& metadata_path) { std::ifstream in(metadata_path, std::ifstream::binary); if (in) { @@ -239,9 +232,7 @@ } - - -void Meteogram::handle_remote(MvRequest &in, MvRequest &out) +void Meteogram::handle_remote(MvRequest& in, MvRequest& out) { // the first URL to get the metadata looks like this: // https://apps.ecmwf.int/webapps/opencharts-api/v1/products/opencharts_meteogram/?epsgram=classical_15d& @@ -277,7 +268,7 @@ // get the date and tias a full string int time = in("FORECAST_RUN_TIME"); MvDate date = in("DATE"); - date += (double)time/24.0; + date += (double)time / 24.0; std::ostringstream date_option; date_option << date.ISO8601(); restUrl += "&base_time=" + date_option.str(); @@ -305,7 +296,7 @@ // get the station coordinates - std::string latitude_option = toString(station("LATITUDE")); + std::string latitude_option = toString(station("LATITUDE")); std::string longitude_option = toString(station("LONGITUDE")); restUrl += "&lat=" + latitude_option; restUrl += "&lon=" + longitude_option; @@ -362,15 +353,14 @@ // final step: generate the output request - either containing a single image or the result // of contatenating multiple images join_outputs(tempFileNames, format, out); - } -void Meteogram::handle_local(MvRequest &in, MvRequest &out) +void Meteogram::handle_local(MvRequest& in, MvRequest& out) { std::vector tempFileNames; // will store a list of all the temporary filenames used - std::string outclass = "BAD"; + std::string outclass = "BAD"; std::string outputFileName = marstmp(); @@ -394,13 +384,13 @@ // start creating our xml metgram request. We will write this to the file 'mgrequestfile' mgrequest = "<" + mainTag + " "; - + // get the template we'll use (e.g. 10 days eps) // first, convert the name to what the metgram client expects std::string type = (const char*)in("type"); - type = local_databases_[type]; + type = local_databases_[type]; mgrequest += "template='" + type + "' "; @@ -472,13 +462,12 @@ // get the station coordinates - std::string latitude_option = toString(station("LATITUDE")); + std::string latitude_option = toString(station("LATITUDE")); std::string longitude_option = toString(station("LONGITUDE")); mgrequest += "latitude='" + latitude_option + "' "; mgrequest += "longitude='" + longitude_option + "' "; - // get the station height if (station.countValues("HEIGHT") != 0) { @@ -614,7 +603,6 @@ std::cout << "--------------Meteogram::serve() out--------------" << std::endl; out.print(); - } //_____________________________________________________________________ diff -Nru metview-5.17.4/metview/src/MvApp/geo_to_grib.cc metview-5.19.2/metview/src/MvApp/geo_to_grib.cc --- metview-5.17.4/metview/src/MvApp/geo_to_grib.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MvApp/geo_to_grib.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,14 +26,14 @@ const double MISSING_DATA = 1E21; #endif -const float cLatBandSize = 1.0; -const int cLatBandCount = (int)(180.0 / cLatBandSize) + 1; -const int G2G_RECIPROCAL = 0; +const float cLatBandSize = 1.0; +const int cLatBandCount = (int)(180.0 / cLatBandSize) + 1; +const int G2G_RECIPROCAL = 0; const int G2G_EXPONENTIAL_MEAN = 1; -const int G2G_EXPONENTIAL_SUM = 2; -const int G2G_NEAREST_MEAN = 3; -const int G2G_NEAREST_SUM = 4; -const int G2G_NEAREST_COUNT = 5; +const int G2G_EXPONENTIAL_SUM = 2; +const int G2G_NEAREST_MEAN = 3; +const int G2G_NEAREST_SUM = 4; +const int G2G_NEAREST_COUNT = 5; double makeDateNumber(long date, long time); @@ -43,23 +43,23 @@ { MvGeoPoints GPoints; - double North; - double South; - double West; - double East; - double GridLat; - double GridLon; - double Tolerance; - int Weight_; - int NbLat; - int NbLon; - int numValsInTemplateGrib; - double Date; - int Parameter; - int Table2; - double* Matrix; + double North{0.}; + double South{0.}; + double West{0.}; + double East{0.}; + double GridLat{1.}; + double GridLon{1.}; + double Tolerance{0.}; + int Weight_{0}; + int NbLat{0}; + int NbLon{0}; + int numValsInTemplateGrib{0}; + double Date{0.}; + int Parameter{-1}; + int Table2{-1}; + double* Matrix{nullptr}; std::vector > LatListVec; // will store indexes - MvField* templateField; // template field - defines the output grid + MvField* templateField{nullptr}; // template field - defines the output grid public: enum GribDefinitionMode @@ -69,6 +69,9 @@ }; ToMatrix(MvRequest&); + ToMatrix(const ToMatrix&) = delete; + ToMatrix& operator=(const ToMatrix&) = delete; + int load(const char*); int save(std::string&); bool estimate(); @@ -137,17 +140,17 @@ if (mode == "USER") { gribDefMode = User; - North = def("AREA", 0); - West = def("AREA", 1); - South = def("AREA", 2); - East = def("AREA", 3); - GridLon = def("GRID"); - GridLat = def("GRID", 1); + North = def("AREA", 0); + West = def("AREA", 1); + South = def("AREA", 2); + East = def("AREA", 3); + GridLon = def("GRID"); + GridLat = def("GRID", 1); if (North < South) { double tmp = North; - North = South; - South = tmp; + North = South; + South = tmp; } if (!GridLon) @@ -161,8 +164,8 @@ //-- data request => MvField MvRequest grb; def.getValue(grb, "TEMPLATE_GRIB"); - fieldset* fs = request_to_fieldset((request*)grb); - field* f = get_field(fs, 0, expand_mem); + fieldset* fs = request_to_fieldset((request*)grb); + field* f = get_field(fs, 0, expand_mem); templateField = new MvField(f); if (fs->count > 1) //-- warning if several fields @@ -172,9 +175,9 @@ } - Tolerance = def("TOLERANCE"); - Parameter = def("PARAMETER"); - Table2 = def("GRIB_TABLE2_VERSION"); + Tolerance = def("TOLERANCE"); + Parameter = def("PARAMETER"); + Table2 = def("GRIB_TABLE2_VERSION"); std::string st = (const char*)def("INTERPOLATION_METHOD"); if (st == "RECIPROCAL") @@ -227,7 +230,7 @@ if (!GPoints.value_missing(gp_iter, 0)) { double x = minDistance(lon, pi_lon); double y = lat - pi_lat; - dist = (x * x) + (y * y); + dist = (x * x) + (y * y); // Compute weight if (Weight_ == G2G_RECIPROCAL) { @@ -333,10 +336,10 @@ East -= GridLon; double dNbLon = (East - West) / GridLon; - NbLon = static_cast(rint(dNbLon)) + 1; + NbLon = static_cast(rint(dNbLon)) + 1; double dNbLat = (North - South) / GridLat; - NbLat = static_cast(rint(dNbLat)) + 1; + NbLat = static_cast(rint(dNbLat)) + 1; if (fabs(rint(dNbLon) - dNbLon) > epsilon) { marslog(LOG_WARN, "Target grid resolution does not match the domain in West-East direction!"); @@ -350,8 +353,8 @@ marslog(LOG_WARN, "Please check grid geometry in the resulting GRIB!"); } -//This is the old method, which did not always work properly. Sometimes there were -// one less column or row in the target grid than expected! +// This is the old method, which did not always work properly. Sometimes there were +// one less column or row in the target grid than expected! #if 0 NbLon = static_cast< int >( (East - West ) / GridLon + 1 ); NbLat = static_cast< int >( (North - South) / GridLat + 1 ); @@ -524,7 +527,7 @@ if (gribDefMode == User) { // create an LLMatrix text file to be later converted to GRIB - path = marstmp(); + path = marstmp(); FILE* f = fopen(path.c_str(), "w"); if (f == nullptr) return 1; @@ -543,11 +546,11 @@ fprintf(f, "TABLE2 = %d\n", Table2); fprintf(f, "#DATA\n"); - //int last; + // int last; for (int j = 0; j < NbLat; j++) { for (int i = 0; i < NbLon; i++) { - //last = i + ( j*NbLon); + // last = i + ( j*NbLon); fprintf(f, "%g\n", Matrix[i + (j * NbLon)]); } } @@ -625,8 +628,8 @@ } } - MvRequest grib = "GRIB"; - grib("PATH") = tmpGribFile.c_str(); + MvRequest grib = "GRIB"; + grib("PATH") = tmpGribFile.c_str(); grib("TEMPORARY") = 1; out = grib; diff -Nru metview-5.17.4/metview/src/MvApp/grib_to_geo.cc metview-5.19.2/metview/src/MvApp/grib_to_geo.cc --- metview-5.17.4/metview/src/MvApp/grib_to_geo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MvApp/grib_to_geo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -46,8 +46,8 @@ in.getValue(grb, "DATA"); fieldset* fs = request_to_fieldset((request*)grb); - field* f = get_field(fs, 0, expand_mem); - //gribsec1* s1 = (gribsec1*)&f->ksec1[0]; + field* f = get_field(fs, 0, expand_mem); + // gribsec1* s1 = (gribsec1*)&f->ksec1[0]; MvField field(f); // create MvField object MvGridBase* grd = field.mvGrid(); // be careful with this pointer because MvField is in charge! @@ -65,12 +65,12 @@ } - //double height = grd->getDouble("heightPressureEtcOfLevels");//aki always // s1->top_level; + // double height = grd->getDouble("heightPressureEtcOfLevels");//aki always // s1->top_level; double height = field.level(); MvDate vDate(field.yyyymmddFoh()); - //long timePeriod = grd->getLong("periodOfTimeIntervals");//aki grib2// + // long timePeriod = grd->getLong("periodOfTimeIntervals");//aki grib2// long step = field.stepFoh(); if (step != LONG_MAX && step != 0) // s1->p1 > 0 ) { @@ -78,10 +78,10 @@ } long dat = vDate.YyyyMmDd(); long tim = 100 * vDate.Hour() + vDate.Minute(); - //std::cout << height << cTAB << dat << cTAB << tim << cTAB << step << std::endl; + // std::cout << height << cTAB << dat << cTAB << tim << cTAB << step << std::endl; - bool formatXYV = true; //-- which geopoints file format ? + bool formatXYV = true; //-- which geopoints file format ? const char* fmt = in("GEOPOINTS_FORMAT"); if (fmt && strcmp(fmt, "TRADITIONAL") == 0) { formatXYV = false; @@ -89,7 +89,7 @@ bool includeMissing = true; //-- what to do with missing values ? - const char* mis = in("MISSING_DATA"); + const char* mis = in("MISSING_DATA"); if (mis && strcmp(mis, "IGNORE") == 0) { includeMissing = false; } @@ -98,8 +98,8 @@ std::string tmp = marstmp(); //-- open output file std::ofstream fout(tmp.c_str()); - //long paramNumber = grd->getLong("indicatorOfParameter");//aki grib2// - //long table2Version = grd->getLong("gribTablesVersionNo");//aki grib2// + // long paramNumber = grd->getLong("indicatorOfParameter");//aki grib2// + // long table2Version = grd->getLong("gribTablesVersionNo");//aki grib2// std::string paramNumber = grd->getString("mars.param"); fout << "#GEO\n" //-- write geopoints header, with a comment @@ -125,7 +125,7 @@ int cnt = 0; do { - gp = grd->gridPoint(); + gp = grd->gridPoint(); bool valueIsMissing = (gp.value_ == grd->missingValue()); if (includeMissing || !valueIsMissing) { ++cnt; @@ -150,8 +150,8 @@ } } while (grd->advance()); - MvRequest gpts = "GEOPOINTS"; //-- return reply request - gpts("PATH") = tmp.c_str(); + MvRequest gpts = "GEOPOINTS"; //-- return reply request + gpts("PATH") = tmp.c_str(); gpts("TEMPORARY") = 1; out = gpts; diff -Nru metview-5.17.4/metview/src/MvApp/MarsG2.cc metview-5.19.2/metview/src/MvApp/MarsG2.cc --- metview-5.17.4/metview/src/MvApp/MarsG2.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MvApp/MarsG2.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ #include -//static Cached METVIEW_ICON ("METVIEW_ICON"); +// static Cached METVIEW_ICON ("METVIEW_ICON"); class Retrieve : public MvService { @@ -63,16 +63,16 @@ const char* mlog = getenv("MV_MLOG"); if ((mlog && strcmp(mlog, "yes") == 0) || forcePrintLog_) { - mars.info = true; + mars.info = true; mars.warning = true; - //putenv("MV_DEBUG_PRINT=1"); - //sendProgress("Retrieve-> Spotted -mlog, set all kind of flags..."); + // putenv("MV_DEBUG_PRINT=1"); + // sendProgress("Retrieve-> Spotted -mlog, set all kind of flags..."); } } void Retrieve::marsServe(MvRequest& in, MvRequest& out) { - Cached name = (const char*)in("_NAME"); + Cached name = (const char*)in("_NAME"); Cached icon_class = (const char*)in("_CLASS"); Cached mode = getenv("METVIEW_MODE"); @@ -113,8 +113,8 @@ return; } - MvRequest r = "BUFR"; - r("PATH") = in("TARGET"); + MvRequest r = "BUFR"; + r("PATH") = in("TARGET"); r("TEMPORARY") = 1; out = r; @@ -152,11 +152,11 @@ // then there is no data retrieved if (!FileHasValidSize(in("TARGET"))) { request* field = nullptr; - out = field; + out = field; } else { - MvRequest r = "ODB_DB"; - r("PATH") = in("TARGET"); + MvRequest r = "ODB_DB"; + r("PATH") = in("TARGET"); r("TEMPORARY") = 1; out = r; @@ -175,14 +175,14 @@ // then there is no data retrieved if (!FileHasValidSize(in("TARGET"))) { request* field = nullptr; - out = field; + out = field; } else { // MvRequest r = "IMAGE"; - MvRequest r = "GRIB"; // we don't want to distinguish between IMAGEs and other GRIBs now - r("PATH") = in("TARGET"); + MvRequest r = "GRIB"; // we don't want to distinguish between IMAGEs and other GRIBs now + r("PATH") = in("TARGET"); r("TEMPORARY") = 1; - out = r; + out = r; } } else { @@ -200,7 +200,7 @@ if (v->scalar) { MvRequest r = "NUMBER"; - r("VALUE") = v->val; + r("VALUE") = v->val; out = r; } @@ -235,18 +235,18 @@ if ((const char*)grib("FIELDSET_FROM_FILTER") && (int)grib("FIELDSET_FROM_FILTER") == 1) { fieldset* fs = request_to_fieldset(grib); - fieldset* z = copy_fieldset(fs, fs->count, true); + fieldset* z = copy_fieldset(fs, fs->count, true); save_fieldset(z); - grib = fieldset_to_request(z); + grib = fieldset_to_request(z); grib("FIELDSET_FROM_FILTER") = 1; } - path = grib("PATH"); + path = grib("PATH"); in("SOURCE") = path; in.unsetParam("DATA"); } - int temp = 0; + int temp = 0; char* name = guess_class(path); FILE* f = fopen(path, "r"); @@ -316,8 +316,8 @@ } } else { - out = MvRequest(name); - out("PATH") = path; + out = MvRequest(name); + out("PATH") = path; out("TEMPORARY") = temp; } } @@ -361,7 +361,7 @@ { // from the environment, check whether we're in 'standard', 'MIR' or 'TIGGE' mode - char* marsmode = getenv("MV_MARS_MODE"); + char* marsmode = getenv("MV_MARS_MODE"); const char* servicename = "mars"; if (marsmode && strcmp(marsmode, "MIR") == 0) { diff -Nru metview-5.17.4/metview/src/MvApp/pool.cc metview-5.19.2/metview/src/MvApp/pool.cc --- metview-5.17.4/metview/src/MvApp/pool.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MvApp/pool.cc 2023-07-15 08:28:47.000000000 +0000 @@ -46,7 +46,7 @@ }; static cache* head = nullptr; -static svc* s = nullptr; +static svc* s = nullptr; static args setup; static int retention; @@ -67,12 +67,12 @@ /* static void birth(svcid *id,request *r,void *data) { - cache *c = head; - while(c) - { - send_status(c->pclass,c->name,"READY"); - c = c->next; - } + cache *c = head; + while(c) + { + send_status(c->pclass,c->name,"READY"); + c = c->next; + } } */ @@ -90,10 +90,10 @@ static void clean() { time_t now = time(0); - cache* c = head; + cache* c = head; while (c) { cache* thiscache = c; - c = c->next; /* do this in advance because we might delete c */ + c = c->next; /* do this in advance because we might delete c */ if (difftime(now, thiscache->lastuse) > retention) destroy("pool: file not used", thiscache); } @@ -113,7 +113,7 @@ static void subname(char* name) { cache* c = head; - int len = strlen(name); + int len = strlen(name); while (c) { if (strncmp(name, c->name, len) == 0) if (c->name[len] == '/') @@ -149,7 +149,7 @@ while (r) { const char* p = get_value(r, "PATH", 0); const char* t = get_value(r, "TEMPORARY", 0); - int tmp = t ? atoi(t) : 0; + int tmp = t ? atoi(t) : 0; if (p) { if (tmp) { unlink(p); @@ -183,7 +183,7 @@ static void newstat(svcid* id, request* r, void* /*data*/) { const char* state = get_value(r, "STATUS", 0); - const char* name = get_value(r, "NAME", 0); + const char* name = get_value(r, "NAME", 0); cache* c; if (name && state) { @@ -198,7 +198,7 @@ static void store(svcid* id, request* r, void* /*data*/) { - const char* name = get_value(r, "NAME", 0); + const char* name = get_value(r, "NAME", 0); const char* pclass = get_value(r, "CLASS", 0); if (name && r && r->next) { cache* c; @@ -211,13 +211,13 @@ get_svc_source(id), name); #endif - c = NEW_CLEAR(cache); - c->name = strcache(name); - c->pclass = strcache(pclass); - c->r = clone_all_requests(r->next); + c = NEW_CLEAR(cache); + c->name = strcache(name); + c->pclass = strcache(pclass); + c->r = clone_all_requests(r->next); c->lastuse = time(0); - c->next = head; - head = c; + c->next = head; + head = c; marslog(LOG_INFO, "[%-10s] - Caching %s", get_svc_source(id), c->name); } @@ -226,9 +226,9 @@ static void fetchcb(svcid* id, request* r, void* /*data*/) { - const char* name = get_value(r, "NAME", 0); + const char* name = get_value(r, "NAME", 0); const char* pclass = get_value(r, "CLASS", 0); - cache* c = find(name, pclass); + cache* c = find(name, pclass); if (!name) c = nullptr; @@ -246,7 +246,7 @@ { const char* name1 = get_value(r, "NAME1", 0); const char* name2 = get_value(r, "NAME2", 0); - cache* c = find(name2, nullptr); + cache* c = find(name2, nullptr); if (c == nullptr) marslog(LOG_INFO, "[%-10s] - Link %s not found", @@ -264,9 +264,9 @@ int main(int argc, char** argv) { - //time_t now,then; - //int day = 60*60*24; - //int sec; + // time_t now,then; + // int day = 60*60*24; + // int sec; MvRequest pref; const char* r; @@ -275,9 +275,9 @@ s = create_service("pool"); - pref = MvApplication::getPreferences(); - r = get_value(pref, "DATA_CACHE_RETENTION_PERIOD", 0); - retention = (r) ? atoi(r) : setup.timeout; + pref = MvApplication::getPreferences(); + r = get_value(pref, "DATA_CACHE_RETENTION_PERIOD", 0); + retention = (r) ? atoi(r) : setup.timeout; s->timeout = retention * 60; diff -Nru metview-5.17.4/metview/src/MvApp/togrib.cc metview-5.19.2/metview/src/MvApp/togrib.cc --- metview-5.17.4/metview/src/MvApp/togrib.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MvApp/togrib.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,15 +42,15 @@ void ToGrib::serve(MvRequest& in, MvRequest& out) { const char* path = in("PATH"); - char* tmp = marstmp(); + char* tmp = marstmp(); if (LLMatrixToGRIB(path, tmp)) { setError(1, "ToGrib-> Convertion from LLMatrix to GRIB failed"); return; } - MvRequest grib = "GRIB"; - grib("PATH") = tmp; + MvRequest grib = "GRIB"; + grib("PATH") = tmp; grib("TEMPORARY") = 1; out = grib; @@ -67,7 +67,7 @@ // void ToGeo::serve(MvRequest& in, MvRequest& out) { - char* tmp = marstmp(); + char* tmp = marstmp(); MvRequest geo = "GEOPOINTS"; FILE* f = fopen(tmp, "w"); @@ -79,10 +79,10 @@ fprintf(f, "#GEO\n#DATA\n"); while (in) { - double lat = in("LATITUDE"); - double lon = in("LONGITUDE"); + double lat = in("LATITUDE"); + double lon = in("LONGITUDE"); const char* name = in("NAME"); - int ident = in("IDENT"); + int ident = in("IDENT"); fprintf(f, "%g %g 0 0 0 %d %s\n", lat, lon, ident, name); @@ -90,7 +90,7 @@ } fclose(f); - geo("PATH") = tmp; + geo("PATH") = tmp; geo("TEMPORARY") = 1; out = geo; diff -Nru metview-5.17.4/metview/src/MvApp/tomatrix.cc metview-5.19.2/metview/src/MvApp/tomatrix.cc --- metview-5.17.4/metview/src/MvApp/tomatrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/MvApp/tomatrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,12 +30,12 @@ geopt() { - latitude = 0; + latitude = 0; longitude = 0; - height = 0; - date = 0; - time = 0; - value = 0; + height = 0; + date = 0; + time = 0; + value = 0; } geopt& operator=(const geopt& in) = default; void load(const char* line); @@ -51,19 +51,19 @@ class ToMatrix { - geopt* Points; - int NbPoints; - double North; - double South; - double West; - double East; - double GridLat; - double GridLon; - double Tolerance; - int NbLat; - int NbLon; - double Date; - double* Matrix; + geopt* Points{nullptr}; + int NbPoints{0}; + double North{0.}; + double South{0.}; + double West{0.}; + double East{0.}; + double GridLat{1.}; + double GridLon{1.}; + double Tolerance{0.}; + int NbLat{0}; + int NbLon{0}; + double Date{0.}; + double* Matrix{nullptr}; public: ToMatrix(MvRequest&); @@ -133,18 +133,18 @@ ToMatrix::ToMatrix(MvRequest& def) { - North = def("AREA", 0); - West = def("AREA", 1); - South = def("AREA", 2); - East = def("AREA", 3); - GridLat = def("GRID"); - GridLon = def("GRID", 1); + North = def("AREA", 0); + West = def("AREA", 1); + South = def("AREA", 2); + East = def("AREA", 3); + GridLat = def("GRID"); + GridLon = def("GRID", 1); Tolerance = def("TOLERANCE"); if (North < South) { double tmp = North; - North = South; - South = tmp; + North = South; + South = tmp; } if (!GridLat) @@ -208,8 +208,8 @@ if ((lat - Points[i].latitude) > Tolerance) continue; - //if ((Points[i].longitude - lon) > Tolerance ) continue; - //if ((lon - Points[i].longitude) > Tolerance ) continue; + // if ((Points[i].longitude - lon) > Tolerance ) continue; + // if ((lon - Points[i].longitude) > Tolerance ) continue; if (longDistance(Points[i].longitude, lon) > Tolerance) continue; @@ -253,31 +253,31 @@ { float lonmin = 99999; float latmin = 99999; - int min = 99999; + int min = 99999; geopt tmp; for (int s = 0; s < NbPoints; s++) { lonmin = 99999; latmin = 99999; - min = 99999; + min = 99999; for (int i = s; i < NbPoints; i++) { if (Points[i].latitude < latmin) { lonmin = Points[i].longitude; latmin = Points[i].latitude; - min = i; + min = i; } else if (Points[i].latitude == latmin) { if (Points[i].longitude < lonmin) { lonmin = Points[i].longitude; latmin = Points[i].latitude; - min = i; + min = i; } } } if (min != 99999) { - tmp = Points[s]; - Points[s] = Points[min]; + tmp = Points[s]; + Points[s] = Points[min]; Points[min] = tmp; } } @@ -324,11 +324,11 @@ fprintf(f, "MISSING = '%g'\n", MISSING_DATA); fprintf(f, "#DATA\n"); - //int last; + // int last; for (int j = 0; j < NbLat; j++) { for (int i = 0; i < NbLon; i++) { - //last = i + ( j*NbLon); + // last = i + ( j*NbLon); fprintf(f, "%g\n", Matrix[i + (j * NbLon)]); } } @@ -354,7 +354,7 @@ MvRequest llmatrix("LLMATRIX"); - llmatrix("PATH") = path; + llmatrix("PATH") = path; llmatrix("TEMPORARY") = 0; out = llmatrix; diff -Nru metview-5.17.4/metview/src/NcExaminer/MvMain.cc metview-5.19.2/metview/src/NcExaminer/MvMain.cc --- metview-5.17.4/metview/src/NcExaminer/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/NcExaminer/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ exit(1); } - //Get the nc file name + // Get the nc file name std::string fnc; if (const char* tmpc = in("PATH")) { fnc = std::string(tmpc); @@ -42,16 +42,16 @@ exit(1); } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("NcExaminer"); MvQApplication app(argc, argv, appName.c_str(), {"examiner", "keyDialog", "window", "find"}); - //Create the netcdf browser, initialize it and show it + // Create the netcdf browser, initialize it and show it auto* browser = new NcExaminer; browser->setAppIcon("NETCDF"); browser->initMetaData(fnc); browser->show(); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/NcExaminer/NcExaminer.cc metview-5.19.2/metview/src/NcExaminer/NcExaminer.cc --- metview-5.17.4/metview/src/NcExaminer/NcExaminer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/NcExaminer/NcExaminer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("Metview - Netcdf Examiner")); - //Initial size + // Initial size setInitialSize(1100, 800); // Main splitter @@ -69,7 +69,7 @@ setupParamBox(); setupDumpBox(); - //Log + // Log logPanel_ = new MvQLogPanel(this); mainSplitter_->addWidget(logPanel_); @@ -246,7 +246,7 @@ MvNcDim* dim; QTreeWidgetItem* item = treeParam_->topLevelItem(1); for (i = 0; i < data_->getNumberOfDimensions(); i++) { - dim = data_->getDimension(i); + dim = data_->getDimension(i); auto* sub = new QTreeWidgetItem(item); sub->setText(0, QString(dim->name())); sub->setText(1, QString::number(dim->size())); @@ -331,7 +331,7 @@ sub->setExpanded(false); // Add variable type and dimensions - int numDim = var->getNumberOfDimensions(); + int numDim = var->getNumberOfDimensions(); QString qstr = " ( "; for (j = 0; j < numDim; j++) { dim = var->getDimension(j); @@ -361,8 +361,8 @@ } // Add first n values - long nvals = getNumberValues(var); // total number of values - long maxvals = 20; // number of values to be printed + long nvals = getNumberValues(var); // total number of values + long maxvals = 20; // number of values to be printed QStringList strvals; getDataValues(var, strvals, maxvals); // get values auto* sub3 = new QTreeWidgetItem(sub); @@ -373,7 +373,7 @@ } if (maxvals < nvals) { auto* sub1 = new QTreeWidgetItem(sub3); - qstr = " ... " + QString::number(nvals - maxvals) + " more values"; + qstr = " ... " + QString::number(nvals - maxvals) + " more values"; sub1->setText(1, qstr); } } @@ -440,7 +440,7 @@ --ndim; // Get total number of values - long nval = 1L; + long nval = 1L; long* edges = var->edges(); for (int i = 0; i < ndim; i++) nval *= edges[i]; diff -Nru metview-5.17.4/metview/src/ObsFilter/BufrFilter.cc metview-5.19.2/metview/src/ObsFilter/BufrFilter.cc --- metview-5.17.4/metview/src/ObsFilter/BufrFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/ObsFilter/BufrFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -183,15 +183,15 @@ BufrFilterEngine filter(bufrFile, BufrFilterEngine::IconMode, 0); - //The object to store the extracted values + // The object to store the extracted values auto* extractedProf = new MvKeyProfile("result"); - //The output file + // The output file std::string resFile(marstmp()); MvRequest x; if (outFormat == "CSV") { - x = MvRequest("TABLE"); //CSV represented by TABLE in metview + x = MvRequest("TABLE"); // CSV represented by TABLE in metview } else if (outFormat == "BUFR") { x = MvRequest("BUFR"); @@ -200,7 +200,7 @@ x = MvRequest("GEOPOINTS"); } x("TEMPORARY") = 1; - x("PATH") = resFile.c_str(); + x("PATH") = resFile.c_str(); #if 0 outfile_.open( fileName, std::ios::out );if(def_.value("OUTPUT") == "CSV") @@ -220,7 +220,7 @@ << "time" << mySeparator; #endif - //the USE_PREFILTER option is only used for test purposes at the moment + // the USE_PREFILTER option is only used for test purposes at the moment MvEccBufr* bd = nullptr; if (const char* val = in("USE_PREFILTER")) { if (strcmp(val, "1") == 0) { diff -Nru metview-5.17.4/metview/src/ObsFilter/BufrPicker.cc metview-5.19.2/metview/src/ObsFilter/BufrPicker.cc --- metview-5.17.4/metview/src/ObsFilter/BufrPicker.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/ObsFilter/BufrPicker.cc 2023-07-15 08:28:47.000000000 +0000 @@ -56,9 +56,9 @@ // Get output format const char* outStr = in("OUTPUT"); - out("OUTPUT") = outStr ? outStr : "GEOPOINTS"; + out("OUTPUT") = outStr ? outStr : "GEOPOINTS"; - //Get parameter values + // Get parameter values MvObs obs; std::string aux; if ((const char*)in("PARAMETER")) @@ -67,7 +67,7 @@ if (aux.empty()) throw MvException("No parameter given"); - int nparams = in.countValues("PARAMETER"); + int nparams = in.countValues("PARAMETER"); out("PARAMETER_COUNT") = nparams; for (int i = 0; i < nparams; i++) { // Convert descriptor to key @@ -83,7 +83,7 @@ // Get missing data info const char* myMissingData = (const char*)in("MISSING_DATA"); if (myMissingData && strcmp(myMissingData, "INCLUDE") == 0) { - out("MISSING_DATA") = "INCLUDE"; + out("MISSING_DATA") = "INCLUDE"; out("MISSING_DATA_VALUE") = (double)in("MISSING_DATA_VALUE"); } @@ -100,7 +100,7 @@ throw MvException("Different number of coordinate descriptors and values"); // Get coordinate descriptors and coordinate values - bool extractAll = false; + bool extractAll = false; out("COORDINATE_COUNT") = ncoords; for (int i = 0; i < ncoords; i++) { // Convert descriptor to key @@ -133,7 +133,7 @@ //_________________________________________________________serve void BufrPicker::serve(MvRequest& in, MvRequest& out) { - //in.print(); + // in.print(); try { // Get user input parameters MvRequest bufrIn("BUFRFILTER"); @@ -147,7 +147,7 @@ setError(errcode, "BufrPicker-> %s", e.what()); } - //out.print(); + // out.print(); return; } diff -Nru metview-5.17.4/metview/src/ObsFilter/CleanFile.cc metview-5.19.2/metview/src/ObsFilter/CleanFile.cc --- metview-5.17.4/metview/src/ObsFilter/CleanFile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/ObsFilter/CleanFile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -87,7 +87,7 @@ } //-- search for real data start - char myMsgType = '?'; + char myMsgType = '?'; int mySkipCount = 0; bool found = findNextMsg(myStream, mySkipCount, myMsgType); @@ -106,7 +106,7 @@ if (skipFirstMsg && strcmp(skipFirstMsg, "YES") == 0) { int mySkipCount2 = 0; - found = findNextMsg(myStream, mySkipCount2, myMsgType); + found = findNextMsg(myStream, mySkipCount2, myMsgType); //-- still data after 1st msg? if (!found) { @@ -132,7 +132,7 @@ myStream.get(); } //-- create a clean file - myCount = 0; + myCount = 0; int myOctet = myStream.get(); while (!myStream.eof()) { ++myCount; @@ -142,8 +142,8 @@ //-- create return request MvRequest myOutReq((myMsgType == 'G' ? "GRIB" : "BUFR")); myOutReq("TEMPORARY") = 1; - myOutReq("PATH") = myFileOut; - out = myOutReq; + myOutReq("PATH") = myFileOut; + out = myOutReq; sendProgress("Created %d clean octets", myCount); diff -Nru metview-5.17.4/metview/src/ObsFilter/ObsFilter.cc metview-5.19.2/metview/src/ObsFilter/ObsFilter.cc --- metview-5.17.4/metview/src/ObsFilter/ObsFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/ObsFilter/ObsFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -23,11 +24,11 @@ #include "MvMiscellaneous.h" #include "MvGeoPoints.h" -const char cTab = 9; // ascii code for 'tab' +const char cTab = 9; // ascii code for 'tab' const char cComma = ','; -const std::string TEMP_2M = "airTemperatureAt2M"; //12004; +const std::string TEMP_2M = "airTemperatureAt2M"; // 12004; enum eLevel { @@ -65,6 +66,7 @@ void serve(MvRequest&, MvRequest&); protected: + void getControl(); void getParams(); void getData(); void getParameterSpecifiers(); @@ -84,13 +86,14 @@ float coordinateRangeValue(const std::string&, float, float, int); private: + std::string moduleLabel_{"ObsFiler-> "}; long _counter{0}; MvRequest _in; MvRequest _data; MvObs obs_; MvObsSet* _inSet{nullptr}; MvObsSetIterator* _iter{nullptr}; - eOutput outType_; + eOutput outType_{eBUFR}; MvObsSet* _outBufr{nullptr}; std::ofstream _outFile; eLevel _level{LVL_Surface}; @@ -123,18 +126,10 @@ delete _outBufr; obs_.clear(); } -//_________________________________________________________ -void ObsFilter ::getData() -{ - //-- D A T A -- - _in.getValue(_data, "DATA"); - _inSet = new MvObsSet(_data); - _iter = new MvObsSetIterator(*_inSet); - - //-- O U T P U T -- - outType_ = (eOutput)((int)_in("OUTPUT")); +void ObsFilter::getControl() +{ if (strcmp(_in("FAIL_ON_ERROR"), "NO") == 0) failOnError_ = false; else @@ -144,9 +139,28 @@ failOnEmptyOutput_ = true; else failOnEmptyOutput_ = false; // default value + + //-- O U T P U T -- + outType_ = (eOutput)((int)_in("OUTPUT")); } + + //_________________________________________________________ -void ObsFilter ::getParameterSpecifiers() +void ObsFilter::getData() +{ + //-- D A T A -- + _in.getValue(_data, "DATA"); + + if (!_data) { + throw MvException("empty or unspecified input data"); + } + + _inSet = new MvObsSet(_data); + _iter = new MvObsSetIterator(*_inSet); +} + +//_________________________________________________________ +void ObsFilter::getParameterSpecifiers() { //-- P A R A M E T E R -- int nrParams = _in.countValues("PARAMETER"); @@ -168,10 +182,10 @@ const char* myMissingData = _in("MISSING_DATA"); if (myMissingData && strcmp(myMissingData, "INCLUDE") == 0) { _includeMissingValues = true; - _missingValue = (double)_in("MISSING_DATA_VALUE"); + _missingValue = (double)_in("MISSING_DATA_VALUE"); } - //Check if there are attributes in params + // Check if there are attributes in params for (auto& i : param_) { if (i.find("->") != std::string::npos) { hasAttributeCondition_ = true; @@ -197,24 +211,24 @@ if (_in.countValues("FIRST_LEVEL") > 0) _firstLevel = (double)_in("FIRST_LEVEL"); else - _firstLevel = 0.; //default value + _firstLevel = 0.; // default value if (_in.countValues("SECOND_LEVEL") > 0) _secondLevel = (double)_in("SECOND_LEVEL"); else - _secondLevel = 0.; //default value + _secondLevel = 0.; // default value if (_in.countValues("OCCURRENCE_INDEX") > 0) _occurrenceIndex = (long)_in("OCCURRENCE_INDEX"); else - _occurrenceIndex = 0L; //default value + _occurrenceIndex = 0L; // default value if (_in.countValues("LEVEL_DESCRIPTOR") > 0) _coordLevelDescriptor = (const char*)_in("LEVEL_DESCRIPTOR"); else - _coordLevelDescriptor = ""; //0L; //default value + _coordLevelDescriptor = ""; // 0L; //default value - //Check if there are attributes in _coordLevelDescriptor + // Check if there are attributes in _coordLevelDescriptor if (_coordLevelDescriptor.find("->") != std::string::npos) { hasAttributeCondition_ = true; @@ -259,7 +273,7 @@ // both DATE and TIME are ANY } // TIME==ANY && DATE==value is illegal else { - int myTime = (int)_in("TIME"); + int myTime = (int)_in("TIME"); int myDelta = (int)_in("RESOLUTION_IN_MINS"); if (dateStr && strcmp(dateStr, "ANY") == 0) // only TIME is given @@ -338,10 +352,10 @@ if (lineStr) { if (_in.countValues("LINE") == 4) { float myDeltaInM = (double)_in("DELTA_IN_KM") * 1000; - float y1 = (double)_in("LINE", 0); - float x1 = (double)_in("LINE", 1); - float y2 = (double)_in("LINE", 2); - float x2 = (double)_in("LINE", 3); + float y1 = (double)_in("LINE", 0); + float x1 = (double)_in("LINE", 1); + float y2 = (double)_in("LINE", 2); + float x2 = (double)_in("LINE", 3); MvLocation loc1(y1, x1); MvLocation loc2(y2, x2); _iter->setXSectionLine(loc1, loc2, myDeltaInM); @@ -355,13 +369,13 @@ //_________________________________________________________ void ObsFilter ::getCustom() { - const char* customFilterStr = _in("CUSTOM_FILTER"); + const char* customFilterStr = _in("CUSTOM_FILTER"); std::string customDescriptor = ""; if ((const char*)_in("CUSTOM_PARAMETER")) customDescriptor = (const char*)_in("CUSTOM_PARAMETER"); - float customFirstValue = 0; + float customFirstValue = 0; float customSecondValue = 0; - int mySelectValueCount = _in.countValues("CUSTOM_VALUES"); + int mySelectValueCount = _in.countValues("CUSTOM_VALUES"); if (mySelectValueCount > 0) customFirstValue = (double)_in("CUSTOM_VALUES", 0); if (mySelectValueCount > 1) @@ -392,7 +406,7 @@ throw MvException("ObsFilter-> Custom Filter/ExcludeRange: number of CUSTOM_VALUES != 2"); } - //Check if there are attributes in custom param + // Check if there are attributes in custom param if (customDescriptor.find("->") != std::string::npos) { hasAttributeCondition_ = true; } @@ -403,7 +417,6 @@ _obsOrMsg = NR_returnMsg; //-- set msg level as default //-- these have no effect on _obsOrMsg -- - getData(); getParameterSpecifiers(); getTypes(); @@ -422,6 +435,7 @@ else _obsOrMsg = NR_returnObs; //-- for geopoints always on obs level!!! } + //_________________________________________________________ MvRequest ObsFilter ::createRequest() @@ -431,8 +445,8 @@ { MvRequest x("BUFR"); //-- BUFR return request x("TEMPORARY") = 1; - x("PATH") = marstmp(); - _outBufr = new MvObsSet(x, "w"); + x("PATH") = marstmp(); + _outBufr = new MvObsSet(x, "w"); return x; } @@ -443,7 +457,7 @@ MvRequest x("TABLE"); //-- CSV return request (TABLE) x("TEMPORARY") = 1; - x("PATH") = fileName; + x("PATH") = fileName; _outFile.open(fileName, std::ios::out); //-- construct CSV header line @@ -464,7 +478,7 @@ MvRequest x("GEOPOINTS"); //-- GEOPOINTS return request x("TEMPORARY") = 1; - x("PATH") = fileName; + x("PATH") = fileName; _outFile.open(fileName, std::ios::out); @@ -497,7 +511,7 @@ MvRequest x("GEOPOINTS"); x("TEMPORARY") = 1; - x("PATH") = fileName; + x("PATH") = fileName; _outFile.open(fileName, std::ios::out); @@ -642,7 +656,7 @@ } } - //traditional geopoints + // traditional geopoints else if (outType_ != eNCOLS) { float myValue = 0; float myDirec = 0; //-- for geovectors @@ -776,10 +790,10 @@ return; } - MvLocation myLoc = obs_.location(); + MvLocation myLoc = obs_.location(); TStaticTime myTime = obs_.obsTime(); - std::string ident = obs_.headerIdent(); - ident = metview::stationIdForWritingToFile(ident); + std::string ident = obs_.headerIdent(); + ident = metview::stationIdForWritingToFile(ident); _outFile << ident << cTab; if (myLoc.latitude() != kBufrMissingValue) { @@ -853,53 +867,89 @@ time_t myStartTime; time(&myStartTime); clock_t myStartCpu = clock(); + _counter = 0; // The input request needs to be expanded with flag EXPAND_LAST_NAME. // This is required by functions getTypes and getCustom. _in = in.ExpandRequest("ObsFilterDef", "ObsFilterRules", EXPAND_LAST_NAME); - getParams(); //-- new _inSet & _iter + // get some params upfront + getControl(); + + bool hasData=false; - //we turn off caching compressed data - having it on does not improve performance for - //obsfilter - _inSet->setCacheCompressedData(false); - - MvRequest x = createRequest(); - _counter = 0; //-- m a i n l o o p - try { - while ((obs_ = (*_iter)(_obsOrMsg))) { - add(); + // get data. We do it in a separate block to check if the + // input is empty or invalid. FailOnError does not apply at this stage! + try { + // load the data + getData(); + hasData=true; + } catch (MvException& e) { + if (!failOnEmptyOutput_) { + // creates a properly formatted (with the exception of bufr) + // empty output file + getParameterSpecifiers(); + out = createRequest(); + close(); } - close(); - obs_.clear(); //-- initialise MvObs (serve function may be call iteractively - } - catch (MvException& e) { - std::string err = "ObsFilter-> Failed: "; + std::string err = "ObsFilter-> Input error: "; err += e.what(); - if (failOnError_) - throw MvException(err.c_str()); - else - setError(0, err.c_str()); + setError(0, err.c_str()); } - time_t myEndTime; - time(&myEndTime); - double wallClockTime = difftime(myEndTime, myStartTime); - clock_t myEndCpu = clock(); - double cpuTime = ((double)(myEndCpu - myStartCpu)) / (double)CLOCKS_PER_SEC; // CLK_TCK; + if (hasData) { + try { + getParams(); //-- new _inSet & _iter + + // the output request + MvRequest x = createRequest(); + + // we turn off caching compressed data - having it on does not improve performance for + // obsfilter + _inSet->setCacheCompressedData(false); + + while ((obs_ = (*_iter)(_obsOrMsg))) { + add(); + } + + // close the output file + close(); + + // initialise MvObs (serve function may be called iteractively) + // TODO: when can it be iteratively called? + obs_.clear(); - sendProgress("ObsFilter-> Filtered %d observations (out of %d) into a %s file in %d secs (cpu %d secs)", _counter, _inSet->obsCount(), outTypeStr[(int)outType_].c_str(), (int)wallClockTime, (int)cpuTime); + out = x; + + time_t myEndTime; + time(&myEndTime); + double wallClockTime = difftime(myEndTime, myStartTime); + clock_t myEndCpu = clock(); + double cpuTime = ((double)(myEndCpu - myStartCpu)) / (double)CLOCKS_PER_SEC; // CLK_TCK; + sendProgress("ObsFilter-> Filtered %d observations (out of %d) into a %s file in %d secs (cpu %d secs)", _counter, _inSet->obsCount(), outTypeStr[(int)outType_].c_str(), (int)wallClockTime, (int)cpuTime); + } + catch (MvException& e) { + std::string err = e.what(); + if (failOnError_) { + std::string msg = moduleLabel_ + "Abort[FAIL_ON_ERROR=Yes] Filter error : " + err; + throw MvException(msg.c_str()); + } else { + std::string msg = moduleLabel_ + "Filter error: " + err; + setError(0, msg.c_str()); + } + } + } + // TODO: improve cleanup delete _iter; _iter = nullptr; delete _inSet; _inSet = nullptr; - if (_counter == 0 && failOnEmptyOutput_) - throw MvException("ObsFilter-> Abort: Fail-On-Empty-Output requested!"); - - out = x; + if (_counter == 0 && failOnEmptyOutput_) { + throw MvException(moduleLabel_ + "Abort[FAIL_ON_EMPTY_OUTPUT=Yes] output is empty!"); + } std::cout << "ObsFilter::serve() out" << std::endl; out.print(); diff -Nru metview-5.17.4/metview/src/Obstat/MvMain.cc metview-5.19.2/metview/src/Obstat/MvMain.cc --- metview-5.17.4/metview/src/Obstat/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Obstat/MvMain.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ -/***************************** LICENSE START *********************************** - - Copyright 2012 ECMWF and INPE. This software is distributed under the terms - of the Apache License version 2.0. In applying this license, ECMWF does not - waive the privileges and immunities granted to it by virtue of its status as - an Intergovernmental Organization or submit itself to any jurisdiction. - - ***************************** LICENSE END *************************************/ - -#include "Metview.h" - -#include -#include -#include - -#include -#include - - -static std::map onOffMap; - - -void setParam(std::vector >& param, MvRequest& in, std::string parMv, std::string parObstat) -{ - const char* cval = in(parMv.c_str()); - - if (cval) { - std::string val(cval); - - if (parMv == "all_data" || parMv == "use_ecfs_log" || - parMv == "stdev" || parMv == "stat_calc" || - parMv == "scat_period" || parMv == "coverage" || - parMv == "use_ecfs_log" || parMv == "sta_calc" || - parMv == "sta_accum" || parMv == "update_soft" || - parMv == "retrieve_odb" || parMv == "feedback_clean" || - parMv == "sta_clean" || parMv == "sta_plot") { - if (onOffMap.find(val) != onOffMap.end()) { - val = onOffMap[val]; - } - } - - else if (parMv == "odb_datalist") { - std::transform(val.begin(), val.end(), val.begin(), ::tolower); - } - if (val.size() != 0) - param.push_back(make_pair(parObstat, val)); - } -} - - -class Base : public MvService -{ -protected: - Base(char* a) : - MvService(a){}; -}; - -class Obstat : public Base -{ -public: - Obstat() : - Base("OBSTAT"){}; - void serve(MvRequest&, MvRequest&); -}; - -void Obstat::serve(MvRequest& in, MvRequest& out) -{ - std::cout << "--------------Obstat::serve()--------------" << std::endl; - in.print(); - - std::string obstatScript; - char* mvbin = getenv("METVIEW_BIN"); - if (mvbin == 0) { - marslog(LOG_EROR, "No METVIEW_BIN env variable is defined. Cannot locate mv_obstat script!"); - setError(13); - return; - } - else { - obstatScript = std::string(mvbin) + "/mv_obstat"; - } - - //Get values from the ui - std::vector > param; - - setParam(param, in, "first_cycle", "FIRSTCYCLE"); - setParam(param, in, "last_cycle", "LASTCYCLE"); - setParam(param, in, "expver_1", "EXPVER1"); - setParam(param, in, "class_1", "CLASS1"); - setParam(param, in, "stream_1", "STREAM1"); - setParam(param, in, "expver_2", "EXPVER2"); - setParam(param, in, "class_2", "CLASS2"); - setParam(param, in, "stream_2", "STREAM2"); - setParam(param, in, "all_data", "LALLDATA"); - setParam(param, in, "use_ecfs_log", "USE_ECFSLOG"); - setParam(param, in, "stat_def", "STATDEF"); - //setParam(param,in,"user_params","STATDEF"); - //setParam(param,in,"user_flags","STATDEF"); - //setParam(param,in,"output_grib_dir","GRIBDIR"); - //setParam(param,in,"store_dir","STOREDIR"); - //setParam(param,in,"exe_dir","EXEDIR"); - //setParam(param,in,"lib_dir","LIBDIR"); - //setParam(param,in,"data_dir","DATADIR"); - setParam(param, in, "stdev", "STDEV"); - setParam(param, in, "stat_merge", "STAMERGE"); - setParam(param, in, "obs_format", "OBSFORMAT"); - setParam(param, in, "odb_file_type", "ODBFILETYPE"); - setParam(param, in, "odb_datalist", "ODBDATALIST"); - setParam(param, in, "stat_calc", "STACALC"); - setParam(param, in, "obstat_plot", "OBSTATPLOT"); - setParam(param, in, "geogrib_average_period", "GEOGRIB_AVE_PERIOD"); - setParam(param, in, "scat_period", "SCAT_PERIOD"); - setParam(param, in, "coverage", "LCOVERAGE"); - setParam(param, in, "use_ecf_log", "USE_ECFSLOG"); - setParam(param, in, "comment", "COMMENT"); - setParam(param, in, "sta_calc", "STACALC"); - setParam(param, in, "sta_accum", "STACALC"); - setParam(param, in, "update_soft", "UPDSOFT"); - setParam(param, in, "retrieve_odb", "RETRIEVEODB"); - setParam(param, in, "feedback_clean", "FBKCLEAN"); - setParam(param, in, "sta_clean", "STACLEAN"); - setParam(param, in, "sta_plot", "STAPLOT"); - - std::string outFile = marstmp(); //"/var/tmp/dummy-user/obstat.txt"; - - FILE* fp = fopen(outFile.c_str(), "w+"); - if (fp == 0) { - return; - } - - for (std::vector >::iterator it = param.begin(); - it != param.end(); it++) { - fprintf(fp, "%s=%s\n", (*it).first.c_str(), (*it).second.c_str()); - } - - fclose(fp); - - - //Run obstat - - std::string cmd = obstatScript + " " + outFile; - - marslog(LOG_INFO, "Execute command: %s", cmd.c_str()); - - system(cmd.c_str()); -} - - -int main(int argc, char** argv) -{ - MvApplication theApp(argc, argv); - - Obstat obstat; - - onOffMap["ON"] = "yes"; - onOffMap["OFF"] = "no"; - - theApp.run(); -} diff -Nru metview-5.17.4/metview/src/Obstat/ObjectSpec.Obstat metview-5.19.2/metview/src/Obstat/ObjectSpec.Obstat --- metview-5.17.4/metview/src/Obstat/ObjectSpec.Obstat 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Obstat/ObjectSpec.Obstat 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -################################################################################ -# -# ObjectSpec.Obstat -# - -object, - class = OBSTAT, - can_be_created = True, - definition_file = '$METVIEW_DIR_SHARE/etc/ObstatDef', - rules_file = '$METVIEW_DIR_SHARE/etc/ObstatRules', - default_name = 'Obstat', - type = Data, - expand = 75, - macro = obstat, - editor_type = SimpleEditor, - pixmap = '$METVIEW_DIR_SHARE/icons/OBSTAT.icon' - - -state, - class = OBSTAT, - output_class = GEOPOINTS, - service = Obstat - - -service, - cmd = '$METVIEW_CMD $METVIEW_BIN/Obstat', - name = 'Obstat' - diff -Nru metview-5.17.4/metview/src/Obstat/ObstatDef metview-5.19.2/metview/src/Obstat/ObstatDef --- metview-5.17.4/metview/src/Obstat/ObstatDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Obstat/ObstatDef 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -OBSTAT; Obstat; experimental -{ - first_cycle {@} = "2010081512" - last_cycle {@} = "2010081512" - expver_1 {@} = "0001" - class_1 {@} = "od" - stream_1 {@} = "DCDA" - expver_2 {@} - class_2 {@} - stream_2 {@} - all_data { - ON ; ON - OFF ; OFF - } = OFF - use_ecfs_log { - ON ; ON - OFF ; OFF - } = OFF - stat_def {@} = "/home/mo/obstat/OBSTAT/stat.ref" - user_params {@} - user_flags {@} - output_grib_dir {@} - store_dir {@} - exe_dir {@} - lib_dir {@} - data_dir {@} = "/home/mo/obstat/OBSTAT/data" - stdev { - ON ; ON - OFF ; OFF - } = ON - stat_merge {@} - stat_calc { - ON ; ON - OFF ; OFF - } = ON - obs_format [interface = option_menu ] { - ODB ; ODB - BUFR ; BUFR - USER ; USER - } = ODB - odb_file_type [interface = option_menu ] { - CCMA ; CCMA - ECMA ; ECMA - ODBCMP ; ODBCMP - MONDB ; MONDB - } = CCMA - odb_datalist [interface = option_menu ] { - AMSUA - AMSRE - AMSUA - AMSUB - CONV - GEOS - GPSRO - HIRS - IASI - MERIS - MHS - MWHS - MWTS - REO3 - SATOB - SCATT - SSMI - SSMIS - SURF_CONV - TMI - } = CONV - retireve_odb { - ON ; ON - OFF ; OFF - } = ON - - obstat_plot { - ON ; ON - OFF ; OFF - } = ON - coverage { - ON ; ON - OFF ; OFF - } = OFF - geogrib_average_period { - ON ; ON - OFF ; OFF - } = ON - fovgrib_average_period { - ON ; ON - OFF ; OFF - } = ON - scat_period { - ON ; ON - OFF ; OFF - } = ON - comment {@} - sta_calc { - ON ; ON - OFF ; OFF - } = ON - sta_accum { - ON ; ON - OFF ; OFF - } = ON - update_soft { - ON ; ON - OFF ; OFF - } = ON - feedback_clean { - ON ; ON - OFF ; OFF - } = ON - sta_clean { - ON ; ON - OFF ; OFF - } = OFF - sta_plot { - ON ; ON - OFF ; OFF - } = ON - sql_section {@} -} diff -Nru metview-5.17.4/metview/src/Obstat/OBSTAT.xpm metview-5.19.2/metview/src/Obstat/OBSTAT.xpm --- metview-5.17.4/metview/src/Obstat/OBSTAT.xpm 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Obstat/OBSTAT.xpm 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* XPM */ -static char *Obstat[] = { -/* columns rows colors chars-per-pixel */ -"16 16 1 1", -" c #DC243A", -/* pixels */ -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" " -}; diff -Nru metview-5.17.4/metview/src/Odb/OdbFilter.cc metview-5.19.2/metview/src/Odb/OdbFilter.cc --- metview-5.17.4/metview/src/Odb/OdbFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Odb/OdbFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ send_message(MvApplication::getService(), (request*)reqst); } - out = MvRequest("REPLY"); + out = MvRequest("REPLY"); out("_FILTER_MESSAGE") = msg.c_str(); // also send to the Mars/Metview module log @@ -56,16 +56,16 @@ void getShellArgument(std::string ibuff, std::string& obuff) { std::string::size_type pos = 0; - obuff = ibuff; + obuff = ibuff; - //Replace linebrake with whitespace + // Replace linebrake with whitespace pos = 0; while ((pos = obuff.find("\n", pos)) != std::string::npos) { obuff.replace(pos, 1, " "); pos++; } - //Replace linebrake with whitespace + // Replace linebrake with whitespace pos = 0; while ((pos = obuff.find("$", pos)) != std::string::npos) { obuff.replace(pos, 1, "\\$"); @@ -75,19 +75,19 @@ // "(" -> "/(" /*pos=0; - while((pos=obuff.find("(",pos)) !=std::string::npos) - { - obuff.replace(pos,1,"\\("); - pos+=3; - } - - // ")" -> "/)" - pos=0; - while((pos=obuff.find(")",pos)) !=std::string::npos) - { - obuff.replace(pos,1,"\\)"); - pos+=3; - }*/ + while((pos=obuff.find("(",pos)) !=std::string::npos) + { + obuff.replace(pos,1,"\\("); + pos+=3; + } + + // ")" -> "/)" + pos=0; + while((pos=obuff.find(")",pos)) !=std::string::npos) + { + obuff.replace(pos,1,"\\)"); + pos+=3; + }*/ } class Base : public MvService @@ -112,14 +112,14 @@ in.print(); // Get prefix - std::string verb = in.getVerb(); + std::string verb = in.getVerb(); const char* useLogWindow = (const char*)in("_USELOGWINDOW"); const char* dataPath; MvRequest dataR = in("ODB_DATA"); if (dataR != nullptr) { const char* dc = dataR("PATH"); - dataPath = dc; + dataPath = dc; } else { dataPath = in("ODB_FILENAME"); @@ -140,12 +140,12 @@ std::string query(in("ODB_QUERY")); /*if(static_cast(in("ODB_OUTPUT")) == 0) - { - messageToLog("No output format is specified!",LOG_EROR,useLogWindow); - setError(13); - return; - } - std::string outputFormat(in("ODB_OUTPUT"));*/ + { + messageToLog("No output format is specified!",LOG_EROR,useLogWindow); + setError(13); + return; + } + std::string outputFormat(in("ODB_OUTPUT"));*/ std::string outputFormat("ODB"); @@ -156,7 +156,7 @@ } std::string nb_rows(in("ODB_NB_ROWS")); - //Find out and check odb format + // Find out and check odb format std::string odbType = MvOdbType(dataPath, true); if (odbType != "ODB_NEW" && odbType != "ODB_OLD") { std::stringstream err_s; @@ -181,7 +181,7 @@ #endif } - //Check if the old odb api is able to produce a new odb ouput + // Check if the old odb api is able to produce a new odb ouput if (odbType == "ODB_OLD" && outputFormat == "ODB") { #ifndef METVIEW_ODB_OLD messageToLog("Cannot handle ODB-1 data! ODB-1 support is disabled!", LOG_EROR, useLogWindow, out); @@ -202,10 +202,10 @@ return; } - //Outfile name + // Outfile name std::string outFile = marstmp(); - //Odbsql script + // Odbsql script std::string odbsqlScript; if (odbType == "ODB_OLD") { char* mvbin = getenv("METVIEW_BIN"); @@ -224,12 +224,12 @@ // Performs filter //------------------------- - //std::string cmd="odbsql -q '" << query << "' -o " << outFile << " "; + // std::string cmd="odbsql -q '" << query << "' -o " << outFile << " "; if (outputFormat == "ODB") { if (odbType == "ODB_NEW") { bool notEmpty = true; - //MvOdb odb(dataPath); + // MvOdb odb(dataPath); try { notEmpty = MvOdb::retrieveToFile(query, dataPath, outFile); } @@ -262,7 +262,7 @@ cmd += " -m " + nb_rows; } - //marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); + // marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); int ret = system(cmd.c_str()); @@ -284,7 +284,7 @@ } MvRequest rdata("ODB_DB"); - rdata("PATH") = outFile.c_str(); + rdata("PATH") = outFile.c_str(); rdata("TEMPORARY") = 1; rdata.print(); out = rdata; @@ -321,7 +321,7 @@ getShellArgument(query, queryForShell); std::string tmpFile = marstmp(); - std::string cmd = odbsqlScript + " -q \"" + queryForShell + "\" -o " + tmpFile + + std::string cmd = odbsqlScript + " -q \"" + queryForShell + "\" -o " + tmpFile + " -i " + dataPath + " -f newodb "; if (nb_rows != "-1") { @@ -359,7 +359,7 @@ } MvRequest rdata("GEOPOINTS"); - rdata("PATH") = outFile.c_str(); + rdata("PATH") = outFile.c_str(); rdata("TEMPORARY") = 1; rdata.print(); out = rdata; diff -Nru metview-5.17.4/metview/src/Odb/OdbVisualiser.cc metview-5.19.2/metview/src/Odb/OdbVisualiser.cc --- metview-5.17.4/metview/src/Odb/OdbVisualiser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Odb/OdbVisualiser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -116,15 +116,15 @@ lst.push_back(metadata); /*Tokenizer parse(","); - std::vector vs; - - parse(metadata,vs); - - for(unsigned int i=0; i < vs.size() ; i++) - { - if(isTextContained(vs.at(i).c_str())) - lst.push_back(vs.at(i)); - }*/ + std::vector vs; + + parse(metadata,vs); + + for(unsigned int i=0; i < vs.size() ; i++) + { + if(isTextContained(vs.at(i).c_str())) + lst.push_back(vs.at(i)); + }*/ } std::string OdbVisualiser::buildQuery(const std::vector& columns) @@ -158,8 +158,8 @@ { std::string query; - //If the columns do not contain any expressions, we check if there is - //any need for having a query + // If the columns do not contain any expressions, we check if there is + // any need for having a query if (!probablyNeedAQuery) { if (!from && !isTextContained(from) && !uniqueby && !isTextContained(uniqueby) && @@ -213,14 +213,14 @@ MvRequest r("ODB_FILTER"); r("ODB_FILENAME") = path.c_str(); - r("ODB_QUERY") = query.c_str(); - //r("ODB_OUTPUT") = "ODB"; - r("ODB_NB_ROWS") = "-1"; + r("ODB_QUERY") = query.c_str(); + // r("ODB_OUTPUT") = "ODB"; + r("ODB_NB_ROWS") = "-1"; r("FAIL_ON_EMPTY_OUTPUT") = "on"; - r("_CLASS") = "ODB_FILTER"; - r("_ACTION") = "execute"; - r("_SERVICE") = "OdbFilter"; - r("_USELOGWINDOW") = "1"; + r("_CLASS") = "ODB_FILTER"; + r("_ACTION") = "execute"; + r("_SERVICE") = "OdbFilter"; + r("_USELOGWINDOW") = "1"; int error; MvRequest result = MvApplication::waitService("OdbFilter", r, error); @@ -228,7 +228,7 @@ const char* rPath = result("PATH"); if (error != 0 || !rPath || std::string(rPath).empty()) { if (failOnEmpty_) { - std::string err = "OdbVisualiser-> Calling ODB Filter failed. "; + std::string err = "OdbVisualiser-> Calling ODB Filter failed. "; const char* errmsg = result("_FILTER_MESSAGE"); if (errmsg) err += errmsg; @@ -273,10 +273,6 @@ return; #endif - - // Get prefix - std::string verb = in.getVerb(); - const char* type = in("ODB_PLOT_TYPE"); if (!type) { @@ -367,19 +363,19 @@ return; } - const char* vars = in("ODB_PARAMETERS"); + const char* vars = in("ODB_PARAMETERS"); const char* uniqueby = in("ODB_UNIQUEBY"); - const char* from = in("ODB_FROM"); - const char* where = in("ODB_WHERE"); - const char* orderby = in("ODB_ORDERBY"); + const char* from = in("ODB_FROM"); + const char* where = in("ODB_WHERE"); + const char* orderby = in("ODB_ORDERBY"); - //Get metadata columns + // Get metadata columns std::string metadata; const char* metadataC = in("ODB_METADATA_VARIABLES"); if (metadataC) metadata = std::string(metadataC); - //Build the final column list + // Build the final column list std::vector columns; buildColumnList(cols, metadata, columns); @@ -390,18 +386,18 @@ std::string odbPath; std::string odbType; - MvRequest dataR = in("ODB_DATA"); + MvRequest dataR = in("ODB_DATA"); const char* iconType = dataR.getVerb(); - //If no icon is specified + // If no icon is specified if (!iconType) { - //If no path is there either + // If no path is there either const char* path = in("ODB_FILENAME"); if (!path || strcmp(path, "OFF") == 0) { setError(1, "OdbVisualiser-> No data icon or path is specified!"); return; } - //If the path is defined it checks the filetype. It has to be "ODB_NEW" + // If the path is defined it checks the filetype. It has to be "ODB_NEW" else { odbType = MvOdbType(path, true); if (odbType != "ODB_OLD" && odbType != "ODB_NEW") { @@ -412,12 +408,12 @@ odbPath = std::string(path); } - //The icon type can only be "ODB_DB" + // The icon type can only be "ODB_DB" else if (strcmp(iconType, "ODB_DB") != 0) { setError(1, "OdbVisualiser-> Wrong data type: %s! Only ODB_DB is accepted", iconType); return; } - //The "ODB_DB" icon can only be a new ODB!! + // The "ODB_DB" icon can only be a new ODB!! else { const char* path = dataR("PATH"); if (!path) { @@ -442,15 +438,15 @@ MvRequest tmpR = in; tmpR.setVerb(outReqName.c_str()); - tmpR("_VERB") = outReqName.c_str(); + tmpR("_VERB") = outReqName.c_str(); tmpR("_CLASS") = outReqName.c_str(); bool queryWasRun = false; - //For ODB-1 we always need the filter!! + // For ODB-1 we always need the filter!! std::string query; if (odbType == "ODB_OLD") { - //Build the query + // Build the query query = buildQuery(columns, vars, uniqueby, from, where, orderby, true); MvRequest r; @@ -466,16 +462,16 @@ queryWasRun = true; } - //For ODB-2 + // For ODB-2 if (odbType == "ODB_NEW") { - //If we have metadata columns we surely need to run a query + // If we have metadata columns we surely need to run a query bool needAQuery = isTextContained(metadata.c_str()); - //Get odb object to access metadata + // Get odb object to access metadata MvAbstractOdb* db = MvOdbFactory::make(odbPath); - //Check if any of the specified columns (in the request) contains an expression. If does we - //we need to run a query. + // Check if any of the specified columns (in the request) contains an expression. If does we + // we need to run a query. if (!needAQuery && columnsHaveExpression(db, cols)) { needAQuery = true; } @@ -483,11 +479,11 @@ if (db) delete db; - //Get the query + // Get the query query = buildQuery(columns, vars, uniqueby, nullptr, where, orderby, needAQuery); - //The query is empty if the columns do not contain any expressions - //and there are no SET, WHERE, ORDERBY, UNIQUEBY statments specified + // The query is empty if the columns do not contain any expressions + // and there are no SET, WHERE, ORDERBY, UNIQUEBY statments specified if (!query.empty()) { MvRequest r; tmpR("ODB_DATA") = r; @@ -498,7 +494,7 @@ return; } tmpR("ODB_FILENAME") = res.c_str(); - queryWasRun = true; + queryWasRun = true; } else { tmpR("ODB_FILENAME") = odbPath.c_str(); @@ -506,13 +502,13 @@ } - //Column names can change during the query. E.g. ODB_VALUE_VARIABLE=an_depar-fg_depar - //changes to -(an_depar,fg_depar) in the resulting ODB file. This causes magics++ crash - //because it uses the column name specified in ODB_VALUE_VARIABLE etc to extract the columns - //data from the ODB. - //As a workaround wee need to replace all the request column names to the actual ones in - //the resulting ODB! We suppose that the column order in the resulting ODB is exactly - //the same as in the qurey!! + // Column names can change during the query. E.g. ODB_VALUE_VARIABLE=an_depar-fg_depar + // changes to -(an_depar,fg_depar) in the resulting ODB file. This causes magics++ crash + // because it uses the column name specified in ODB_VALUE_VARIABLE etc to extract the columns + // data from the ODB. + // As a workaround wee need to replace all the request column names to the actual ones in + // the resulting ODB! We suppose that the column order in the resulting ODB is exactly + // the same as in the qurey!! if (queryWasRun == true) { const char* pR = tmpR("ODB_FILENAME"); @@ -520,7 +516,7 @@ if (pR) outPath = std::string(pR); - //Get odb object to access metadata + // Get odb object to access metadata MvAbstractOdb* db = MvOdbFactory::make(outPath); if (!db) { setError(1, "OdbVisualiser-> ODB object not found"); diff -Nru metview-5.17.4/metview/src/OdbExaminer/MvMain.cc metview-5.19.2/metview/src/OdbExaminer/MvMain.cc --- metview-5.17.4/metview/src/OdbExaminer/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OdbExaminer/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -59,7 +59,7 @@ exit(1); } - //Find out and check odb format + // Find out and check odb format std::string odbType = MvOdbType(dataPath.c_str(), true); if (odbType != "ODB_NEW" && odbType != "ODB_OLD") { @@ -80,19 +80,19 @@ #endif } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("OdbExaminer"); MvQApplication app(argc, argv, appName.c_str(), {"examiner", "window", "find"}); - //Create the oda object and initialize it + // Create the oda object and initialize it auto* odb = new MvQOdbMetaData(dataPath, odbType); - //Create the oda examiner and initialize it + // Create the oda examiner and initialize it auto* browser = new OdbExaminer; browser->setAppIcon("ODB_DB"); browser->init(odb); browser->show(); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/OdbExaminer/MvQOdbTableView.cc metview-5.19.2/metview/src/OdbExaminer/MvQOdbTableView.cc --- metview-5.17.4/metview/src/OdbExaminer/MvQOdbTableView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OdbExaminer/MvQOdbTableView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,61 +19,53 @@ MvQOdbTableView::MvQOdbTableView(QWidget* parent) : QGraphicsView(parent) { - //Table graph - tableOffsetX_ = 15; - tableWidth_ = 70; - tableGapX_ = 12; - tableOffsetY_ = 15; - tableHeight_ = 15; - tableGapY_ = 12; } - void MvQOdbTableView::init(MvQOdbMetaData* odb, QString table) { - odb_ = odb; + odb_ = odb; selectedTable_ = table; - //Number of rows and cols in graph + // Number of rows and cols in graph int nx, ny; odb_->getTreePosRange(nx, ny); nx += 1; - //ny+=1; + // ny+=1; - //Compute the area occupied by the graph + // Compute the area occupied by the graph int w = 2 * tableOffsetX_ + nx * tableWidth_ + (nx - 1) * tableGapX_; int h = 2 * tableOffsetY_ + ny * tableHeight_ + (ny - 1) * tableGapY_; - graphWidth_ = w; + graphWidth_ = w; graphHeight_ = h; int dw, dh, pw, ph; - //adjustPixmapSizeToView(width(),height(),dw,dh); + // adjustPixmapSizeToView(width(),height(),dw,dh); adjustPixmapSizeToView(w, h, dw, dh); pw = w + dw; ph = h + dh; - //pw=width()+dw; - //ph=height()+dh; + // pw=width()+dw; + // ph=height()+dh; - //Create the pixmap + // Create the pixmap tablePixmap_ = new QPixmap(pw, ph); - //Scene rect + // Scene rect setSceneRect(0, 0, pw, ph); - //Create a scene for the table graph + // Create a scene for the table graph auto* scene = new OdbTableScene; - //Add scene to the graphics view + // Add scene to the graphics view setScene(scene); - //Mouse press event in scene goes to + // Mouse press event in scene goes to connect(scene, SIGNAL(mousePressed(int, int)), this, SLOT(mousePressedInTableGraph(int, int))); setCacheMode(QGraphicsView::CacheBackground); - //setBackgroundBrush(*tablePixmap_); + // setBackgroundBrush(*tablePixmap_); renderTableGraph(); @@ -83,12 +75,12 @@ void MvQOdbTableView::renderTableGraph() { - //QPixmap *pixmap = new QPixmap(600,400); + // QPixmap *pixmap = new QPixmap(600,400); QPainter painter(tablePixmap_); painter.setRenderHint(QPainter::Antialiasing, false); - //QLinearGradient grad(0,0,100,100); + // QLinearGradient grad(0,0,100,100); QLinearGradient grad(0, 0, tablePixmap_->width(), tablePixmap_->height()); grad.setColorAt(0, QColor::fromRgb(255, 242, 222)); @@ -98,9 +90,9 @@ // Define clear color and clear the display painter.fillRect(0, 0, tablePixmap_->width(), tablePixmap_->height(), QBrush(grad)); - //QBrush(Qt::white, Qt::SolidPattern)); + // QBrush(Qt::white, Qt::SolidPattern)); - //Render net + // Render net int xp, yp; painter.setPen(QPen(QColor(213, 209, 217), 0.5, Qt::SolidLine, Qt::RoundCap)); @@ -118,7 +110,7 @@ painter.setPen(QPen(Qt::black, 0.5, Qt::SolidLine, Qt::RoundCap)); - //Draw the graph + // Draw the graph QMapIterator it(odb_->tables()); while (it.hasNext()) { @@ -139,7 +131,7 @@ painter.setFont(QFont("Helvetica [Cronyx]", 8)); painter.setRenderHint(QPainter::TextAntialiasing, true); - //painter.setFont(QFont("Sans Serif", 7)); + // painter.setFont(QFont("Sans Serif", 7)); it.toFront(); while (it.hasNext()) { @@ -154,7 +146,7 @@ painter.fillRect(xp - tableWidth_ / 2., yp - tableHeight_ / 2., tableWidth_, tableHeight_, QBrush(gradient)); - //QBrush(QColor(255,64,105), Qt::SolidPattern)); + // QBrush(QColor(255,64,105), Qt::SolidPattern)); } else { QLinearGradient gradient(xp, yp - tableHeight_ / 2., @@ -164,14 +156,14 @@ painter.fillRect(xp - tableWidth_ / 2., yp - tableHeight_ / 2., tableWidth_, tableHeight_, QBrush(gradient)); - //QBrush(QColor(119,215,196), Qt::SolidPattern)); + // QBrush(QColor(119,215,196), Qt::SolidPattern)); } painter.drawRect(xp - tableWidth_ / 2., yp - tableHeight_ / 2., tableWidth_, tableHeight_); if (it.value()->name() == selectedTable_) { - //painter.setPen(QPen(Qt::white, 0.5, Qt::SolidLine, Qt::RoundCap)); + // painter.setPen(QPen(Qt::white, 0.5, Qt::SolidLine, Qt::RoundCap)); } @@ -184,12 +176,12 @@ if (it.value()->name() == selectedTable_) { - //painter.setPen(QPen(Qt::black, 0.5, Qt::SolidLine, Qt::RoundCap)); + // painter.setPen(QPen(Qt::black, 0.5, Qt::SolidLine, Qt::RoundCap)); } } /*graphicsView_table->setCacheMode(QGraphicsView::CacheBackground); - graphicsView_table->resetCachedContent();*/ + graphicsView_table->resetCachedContent();*/ setBackgroundBrush(*tablePixmap_); } @@ -259,7 +251,7 @@ delete tablePixmap_; tablePixmap_ = new QPixmap(pw + dw, ph + dh); - //setBackgroundBrush(*tablePixmap_); + // setBackgroundBrush(*tablePixmap_); setSceneRect(0, 0, pw + dw, ph + dh); diff -Nru metview-5.17.4/metview/src/OdbExaminer/MvQOdbTableView.h metview-5.19.2/metview/src/OdbExaminer/MvQOdbTableView.h --- metview-5.17.4/metview/src/OdbExaminer/MvQOdbTableView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OdbExaminer/MvQOdbTableView.h 2023-07-15 08:28:47.000000000 +0000 @@ -37,20 +37,20 @@ void resizeEvent(QResizeEvent*); void adjustPixmapSizeToView(int, int, int&, int&); - MvQOdbMetaData* odb_; + MvQOdbMetaData* odb_{nullptr}; - int tableOffsetX_; - int tableOffsetY_; - int tableWidth_; - int tableHeight_; - int tableGapX_; - int tableGapY_; - int graphWidth_; - int graphHeight_; + int tableOffsetX_{15}; + int tableOffsetY_{15}; + int tableWidth_{70}; + int tableHeight_{15}; + int tableGapX_{12}; + int tableGapY_{12}; + int graphWidth_{70}; + int graphHeight_{15}; QString selectedTable_; - QPixmap* tablePixmap_; + QPixmap* tablePixmap_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/OdbExaminer/OdbExaminer.cc metview-5.19.2/metview/src/OdbExaminer/OdbExaminer.cc --- metview-5.17.4/metview/src/OdbExaminer/OdbExaminer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OdbExaminer/OdbExaminer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -56,14 +56,14 @@ { data_ = 0; #if UI_TODO - columnFind_ = 0; + columnFind_ = 0; tableColumnFind_ = 0; #endif setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("Metview - ODB Examiner")); - //Initial size + // Initial size setInitialSize(1100, 800); QWidget* w; @@ -104,31 +104,31 @@ metaTab_ = new QTabWidget; mainLayout->addWidget(metaTab_, 1); - //Set up grib message group box + // Set up grib message group box setupTableBox(); setupColumnBox(); setupVarBox(); - //setupStatsBox(); + // setupStatsBox(); dataPanel_ = new MvQOdbDataWidget(this); - //setupDataBox(); + // setupDataBox(); metaTab_->addTab(tablePanel_, tr("Tables")); metaTab_->addTab(columnPanel_, tr("Columns")); metaTab_->addTab(varPanel_, tr("SET Variables")); metaTab_->addTab(dataPanel_, tr("Data")); - //Find panel + // Find panel - //We need to call it after the tab is populated - //setupFindBox(); - //mainLayout->addWidget(findPanel_); + // We need to call it after the tab is populated + // setupFindBox(); + // mainLayout->addWidget(findPanel_); //-------------------------- // Log Area //-------------------------- - //Set up the panels + // Set up the panels logPanel_ = new MvQLogPanel(this); mainSplitter_->addWidget(logPanel_); logPanel_->hide(); @@ -164,7 +164,7 @@ connect(metaTab_, SIGNAL(currentChanged(int)), this, SLOT(slotTabIndexChanged(int))); - //setupEditActions(); + // setupEditActions(); setupViewActions(); setupSettingsActions(); setupHelpActions(); @@ -175,8 +175,8 @@ setupMenus(menuItems_); - //Should be called only after init - //readSettings(); + // Should be called only after init + // readSettings(); } OdbExaminer::~OdbExaminer() @@ -184,13 +184,13 @@ writeSettings(); /*if(columnModel_) delete columnModel_; - if(dataModel_) delete dataModel_; - if(bitmapModel_) delete bitmapModel_; + if(dataModel_) delete dataModel_; + if(bitmapModel_) delete bitmapModel_; - for(std::vector::iterator it=secModel_.begin(); it != secModel_.end(); it++) - { - delete *it; - }*/ + for(std::vector::iterator it=secModel_.begin(); it != secModel_.end(); it++) + { + delete *it; + }*/ } void OdbExaminer::setupEditActions() @@ -226,7 +226,7 @@ icon.addPixmap(QPixmap(QString::fromUtf8(":/examiner/info_light.svg")), QIcon::Normal, QIcon::Off); actionFileInfo->setIcon(icon); - //Define routines + // Define routines connect(actionFileInfo, SIGNAL(triggered(bool)), fileInfoLabel_, SLOT(setVisible(bool))); @@ -265,28 +265,28 @@ // Message tree (key profile) //-------------------------------- - tablePanel_ = new QWidget; + tablePanel_ = new QWidget; auto* tableLayout = new QVBoxLayout; tableLayout->setContentsMargins(0, 0, 0, 0); tablePanel_->setLayout(tableLayout); - //Hbox + // Hbox tableSplitter_ = new QSplitter; tableLayout->addWidget(tableSplitter_); - //Table view + // Table view tableView_ = new MvQOdbTableView; tableSplitter_->addWidget(tableView_); - //Column tree - tableColumnModel_ = new MvQOdbColumnModel(false); + // Column tree + tableColumnModel_ = new MvQOdbColumnModel(false); tableColumnSortModel_ = new QSortFilterProxyModel; tableColumnSortModel_->setSourceModel(tableColumnModel_); tableColumnSortModel_->setDynamicSortFilter(true); - //columnSortModel_->setFilterRole(Qt::UserRole); - //columnSortModel_->setFilterRegExp(QRegExp("[1]")); - //columnSortModel_->setFilterFixedString("1"); - //columnSortModel_->setFilterKeyColumn(0); + // columnSortModel_->setFilterRole(Qt::UserRole); + // columnSortModel_->setFilterRegExp(QRegExp("[1]")); + // columnSortModel_->setFilterFixedString("1"); + // columnSortModel_->setFilterKeyColumn(0); tableColumnTree_ = new QTreeView(this); @@ -295,10 +295,10 @@ tableColumnTree_->setAlternatingRowColors(true); tableColumnTree_->setAllColumnsShowFocus(true); tableColumnTree_->setModel(tableColumnSortModel_); - //columnTree_->header()->setContextMenuPolicy(Qt::CustomContextMenu); - //columnTree_->setActvatedByKeyNavigation(true); - //columnTree_->setAcceptDrops(true); - //columnTree_->setDragDropMode(QAbstractItemView::DropOnly); + // columnTree_->header()->setContextMenuPolicy(Qt::CustomContextMenu); + // columnTree_->setActvatedByKeyNavigation(true); + // columnTree_->setAcceptDrops(true); + // columnTree_->setDragDropMode(QAbstractItemView::DropOnly); tableColumnTree_->setRootIsDecorated(true); tableSplitter_->addWidget(tableColumnTree_); @@ -310,13 +310,13 @@ // Message tree (key profile) //-------------------------------- - columnPanel_ = new QWidget(this); + columnPanel_ = new QWidget(this); auto* columnLayout = new QVBoxLayout; columnLayout->setContentsMargins(0, 0, 0, 0); columnPanel_->setLayout(columnLayout); - //Column tree - columnModel_ = new MvQOdbColumnModel(true); + // Column tree + columnModel_ = new MvQOdbColumnModel(true); columnSortModel_ = new QSortFilterProxyModel; columnSortModel_->setSourceModel(columnModel_); columnSortModel_->setDynamicSortFilter(true); @@ -337,13 +337,13 @@ // Message tree (key profile) //-------------------------------- - varPanel_ = new QWidget; + varPanel_ = new QWidget; auto* varLayout = new QVBoxLayout; varLayout->setContentsMargins(0, 0, 0, 0); varPanel_->setLayout(varLayout); - //Var tree - varModel_ = new MvQOdbVarModel; + // Var tree + varModel_ = new MvQOdbVarModel; varSortModel_ = new QSortFilterProxyModel; varSortModel_->setSourceModel(varModel_); varSortModel_->setDynamicSortFilter(true); @@ -354,10 +354,10 @@ varTree_->setAlternatingRowColors(true); varTree_->setAllColumnsShowFocus(true); varTree_->setModel(varSortModel_); - //varTree_->header()->setContextMenuPolicy(Qt::CustomContextMenu); - //varTree_->setActvatedByKeyNavigation(true); - //varTree_->setAcceptDrops(true); - //varTree_->setDragDropMode(QAbstractItemView::DropOnly); + // varTree_->header()->setContextMenuPolicy(Qt::CustomContextMenu); + // varTree_->setActvatedByKeyNavigation(true); + // varTree_->setAcceptDrops(true); + // varTree_->setDragDropMode(QAbstractItemView::DropOnly); varTree_->setRootIsDecorated(false); varLayout->addWidget(varTree_); @@ -380,10 +380,10 @@ void OdbExaminer::init(MvQOdbMetaData* data) { - //Set bufr metadata object + // Set bufr metadata object data_ = data; - //It is using the ODB version!!! + // It is using the ODB version!!! readSettings(); if (data_->odbVersion() == MvQOdbMetaData::Version1) { @@ -430,15 +430,15 @@ metaTab_->setCurrentIndex(1); } - //Fileinfo label + // Fileinfo label updateFileInfoLabel(); //----------------------- // Data //----------------------- - //Data tab is initialised when we first click on it!! + // Data tab is initialised when we first click on it!! - //It is using the ODB version so has to be called here!!! + // It is using the ODB version so has to be called here!!! readSettings(); } @@ -466,7 +466,7 @@ } } - //findPanel_->setCurrentSearchLineById(metaTab_->currentWidget()); + // findPanel_->setCurrentSearchLineById(metaTab_->currentWidget()); } void OdbExaminer::slotShowAboutBox() @@ -500,17 +500,17 @@ { QApplication::setOverrideCursor(QCursor(Qt::BusyCursor)); - //loadProgress_->setRange(0,0); - //loadProgress_->show(); + // loadProgress_->setRange(0,0); + // loadProgress_->show(); } void OdbExaminer::loadFinished() { QApplication::restoreOverrideCursor(); - //loadProgress_->hide(); - //loadProgress_->setRange(0,1); - //loadProgress_->setValue(1); + // loadProgress_->hide(); + // loadProgress_->setRange(0,1); + // loadProgress_->setValue(1); } void OdbExaminer::updateFileInfoLabel() @@ -529,7 +529,7 @@ settings.beginGroup("mainWindow_version1"); settings.setValue("geometry", saveGeometry()); settings.setValue("mainSplitter", mainSplitter_->saveState()); - //settings.setValue("bottomSplitter",bottomSplitter->saveState()); + // settings.setValue("bottomSplitter",bottomSplitter->saveState()); settings.endGroup(); } else if (data_->odbVersion() == MvQOdbMetaData::Version2) { @@ -555,14 +555,14 @@ settings.beginGroup("mainWindow_version1"); restoreGeometry(settings.value("geometry").toByteArray()); mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); - //bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray()); + // bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray()); settings.endGroup(); } else if (data_->odbVersion() == MvQOdbMetaData::Version2) { settings.beginGroup("mainWindow_version2"); restoreGeometry(settings.value("geometry").toByteArray()); mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); - //bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray()); + // bottomSplitter->restoreState(settings.value("bottomSplitter").toByteArray()); settings.endGroup(); } diff -Nru metview-5.17.4/metview/src/OgcClient/MvMain.cc metview-5.19.2/metview/src/OgcClient/MvMain.cc --- metview-5.17.4/metview/src/OgcClient/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,7 +34,7 @@ public: MvWmsClient() : MvQService("WMSCLIENT") {} - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; // void processUiMode(MvRequest&, MvRequest&); void processGetMode(MvRequest&, MvRequest&, const std::string&); }; @@ -86,35 +86,35 @@ client->runGetMap(); - //Listen to the mars event loop! + // Listen to the mars event loop! setupSocketNotifier(); - //Enter the app loop + // Enter the app loop app.exec(); - //If the getMap request failed returns + // If the getMap request failed returns if (client->getMapRunStatus() == false) { delete client; setError(13); //,"GetMap request failed!"); return; } - //Else build the output request + // Else build the output request MvRequest req("PRASTER"); - req("IMPORT_FILE_TYPE") = "png", + req("IMPORT_FILE_TYPE") = "png", req("IMPORT_X_POSITION") = -180; req("IMPORT_Y_POSITION") = -90; - req("IMPORT_WIDTH") = 360; - req("IMPORT_HEIGHT") = 180; + req("IMPORT_WIDTH") = 360; + req("IMPORT_HEIGHT") = 180; MvQGetMapRequest* gmr = client->getMapRequest(); req("CRS") = gmr->crs().toStdString().c_str(); - //In version 1.3.0 for epsg:4326 x lat and y is lon !!!!! - //We need to swap here the coordinates because - //magics++ interprets x as lon and y as lat!! + // In version 1.3.0 for epsg:4326 x lat and y is lon !!!!! + // We need to swap here the coordinates because + // magics++ interprets x as lon and y as lat!! if (gmr->request().contains("CRS=", Qt::CaseInsensitive) && gmr->crs() == "EPSG:4326") { req("CRS_MINX") = gmr->minY().toStdString().c_str(); @@ -146,8 +146,8 @@ if (title) req("SERVICE_TITLE") = title; - //const char *legend=static_cast(in("LAYER_LEGEND")); - //if(legend) req("LEGEND") = legend; + // const char *legend=static_cast(in("LAYER_LEGEND")); + // if(legend) req("LEGEND") = legend; if (client->legendImagePath().isEmpty() == false) { req("LEGEND") = client->legendImagePath().toStdString().c_str(); @@ -163,41 +163,41 @@ req("URL") = url; /*QMap nonTimeDim; - gmr->nonTimeDimValues(nonTimeDim); - QStringList nonTimeDimName, nonTimeDimValue; - QMapIterator it(nonTimeDim); - while(it.hasNext()) - { - it.next(); - nonTimeDimName << it.key(); - nonTimeDimValue << it.value(); - }*/ + gmr->nonTimeDimValues(nonTimeDim); + QStringList nonTimeDimName, nonTimeDimValue; + QMapIterator it(nonTimeDim); + while(it.hasNext()) + { + it.next(); + nonTimeDimName << it.key(); + nonTimeDimValue << it.value(); + }*/ /*QMap nonTimeDimUnit; - gmr->nonTimeDimUnits(nonTimeDimUnit); - QStringList nonTimeDimUnit; - QMapIterator itu(nonTimeDimUnit); - while(it.hasNext()) - { - it.next(); - nonTimeDimUnit << it.value(); - }*/ - - //req("NON_TIME_DIM_NAME")=nonTimeDimName.join("/").toStdString().c_str(); - //req("NON_TIME_DIM_VALUE")=nonTimeDimValue.join("/").toStdString().c_str(); - //req("NON_TIME_DIM_UNIT")=nonTimeDimUnit.join(":").toStdString().c_str(); + gmr->nonTimeDimUnits(nonTimeDimUnit); + QStringList nonTimeDimUnit; + QMapIterator itu(nonTimeDimUnit); + while(it.hasNext()) + { + it.next(); + nonTimeDimUnit << it.value(); + }*/ + + // req("NON_TIME_DIM_NAME")=nonTimeDimName.join("/").toStdString().c_str(); + // req("NON_TIME_DIM_VALUE")=nonTimeDimValue.join("/").toStdString().c_str(); + // req("NON_TIME_DIM_UNIT")=nonTimeDimUnit.join(":").toStdString().c_str(); - //Build rasterloop if there is at least one frame in the request + // Build rasterloop if there is at least one frame in the request if (gmr->requestFrameNum() > 0) { MvRequest reqLoop; QVector rFrame(gmr->requestFrameNum()); for (int i = 0; i < rFrame.count(); i++) { - MvRequest reqFrame = req; - QString fnam = gmr->outFile(i); + MvRequest reqFrame = req; + QString fnam = gmr->outFile(i); reqFrame("IMPORT_FILE_PATH") = fnam.toStdString().c_str(); - reqFrame("PATH") = fnam.toStdString().c_str(); + reqFrame("PATH") = fnam.toStdString().c_str(); QMap dim; gmr->dimValuesForFrame(dim, i); @@ -214,7 +214,7 @@ } } - reqFrame("DIM_NAME") = dimName.join("/").toStdString().c_str(); + reqFrame("DIM_NAME") = dimName.join("/").toStdString().c_str(); reqFrame("DIM_VALUE") = dimValue.join("/").toStdString().c_str(); reqLoop = reqLoop + reqFrame; @@ -224,10 +224,10 @@ out("RASTERS") = reqLoop; } else { - MvRequest reqFrame = req; - QString fnam = gmr->outFile(0); + MvRequest reqFrame = req; + QString fnam = gmr->outFile(0); reqFrame("IMPORT_FILE_PATH") = fnam.toStdString().c_str(); - reqFrame("PATH") = fnam.toStdString().c_str(); + reqFrame("PATH") = fnam.toStdString().c_str(); out.setVerb("PRASTERLOOP"); out("RASTERS") = reqFrame; @@ -235,15 +235,15 @@ out("IMPORT_X_POSITION") = -180; out("IMPORT_Y_POSITION") = -90; - out("IMPORT_WIDTH") = 360; - out("IMPORT_HEIGHT") = 180; + out("IMPORT_WIDTH") = 360; + out("IMPORT_HEIGHT") = 180; // MvRequest current = in.justOneRequest(); while (current != nullptr) { std::string verb = current.getVerb(); if (verb == "WMSCLIENT") { - current("REQUEST") = gmr->request().toStdString().c_str(); + current("REQUEST") = gmr->request().toStdString().c_str(); out("WMS_CLIENT_REQUEST") = current; } break; diff -Nru metview-5.17.4/metview/src/OgcClient/MvQOgcParam.cc metview-5.19.2/metview/src/OgcClient/MvQOgcParam.cc --- metview-5.17.4/metview/src/OgcClient/MvQOgcParam.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQOgcParam.cc 2023-07-15 08:28:47.000000000 +0000 @@ -68,7 +68,7 @@ if (currentIndex_ != -1) { return values_[currentIndex_]; } - return QString(); + return {}; } QString MvQOgcList::currentDisplayValue() @@ -76,7 +76,7 @@ if (currentIndex_ != -1) { return displayValues_[currentIndex_]; } - return QString(); + return {}; } QString MvQOgcList::currentDescription() @@ -84,7 +84,7 @@ if (currentIndex_ != -1) { return descriptions_[currentIndex_]; } - return QString(); + return {}; } @@ -113,7 +113,7 @@ if (currentIndex_ != -1) { return legends_[currentIndex_]; } - return QString(); + return {}; } void MvQOgcStyleList::setLegends(QStringList lst) @@ -130,9 +130,9 @@ void MvQOgcCrsList::init() { - //desc_["EPSG:4326"] = "Cylindrical/WGS 84"; - //desc_["EPSG:32661"] = "Polar Stereo North"; - //desc_["EPSG:32761"] = "Polar Stereo South"; + // desc_["EPSG:4326"] = "Cylindrical/WGS 84"; + // desc_["EPSG:32661"] = "Polar Stereo North"; + // desc_["EPSG:32761"] = "Polar Stereo South"; } void MvQOgcCrsList::setValues(QStringList values) @@ -172,9 +172,9 @@ // MvQOgcBoundingBox //-------------------------------- -MvQOgcBoundingBox::MvQOgcBoundingBox(MvQOgcGeoBoundingBox* geo) +MvQOgcBoundingBox::MvQOgcBoundingBox(MvQOgcGeoBoundingBox* geo) : + crs_("EPSG:4326") { - crs_ = "EPSG:4326"; minX_ = geo->minX(); maxX_ = geo->maxX(); minY_ = geo->minY(); @@ -203,8 +203,8 @@ MvQOgcDimension::MvQOgcDimension(QMap att, QString value) { - //qDebug() << "dimName:" << att["name"]; - //valueMode_=ListMode; + // qDebug() << "dimName:" << att["name"]; + // valueMode_=ListMode; setAttributes(att); setValues(value); } @@ -219,7 +219,7 @@ unitSymbol_ = att["unitSymbol"]; if (att.contains("default")) default_ = htmlDecoder_.decode(att["default"]); - //default_=att["default"]; + // default_=att["default"]; if (att.contains("multipleValues")) multipleValues_ = att["multipleValues"]; if (att.contains("nearesValues")) @@ -232,7 +232,7 @@ { dimData = htmlDecoder_.decode(dimData); - //Time + // Time values_.clear(); if (default_.isEmpty() == false) { @@ -244,94 +244,94 @@ /* if(units_ == "ISO8601") - { - if(name_.compare("time",Qt::CaseInsensitive) == 0) - { - valueSelectionMode_=MultipleSelectionMode; - } - - qDebug() << "Time:" << dimData; - QStringList data=dimData.split(","); - foreach(QString item, data) - { - QStringList lst=item.split("/"); - - qDebug() << "Time:" << lst; - - //Period - if(lst.count() == 3) - { - QDateTime startDate=QDateTime::fromString(lst[0],Qt::ISODate); - QDateTime endDate=QDateTime::fromString(lst[1],Qt::ISODate); - QMap period; - decodePeriod(lst[2],period); - - QDateTime dt=startDate; - while(dt <= endDate) - { - QString s=dt.toString(Qt::ISODate); - s+="Z"; - values_.push_back(s); - addPeriod(dt,period); - if(dt <= startDate) - break; - } - - qDebug() << "time: " << startDate << endDate << period; - qDebug() << "value_" << values_; - - } - else - { - values_.push_back(item); - } - } - } - else - { - QStringList data=dimData.split(","); - foreach(QString item, data) - { - QStringList lst=item.split("/"); - - //Period - if(lst.count() == 3) - { - float minVal=lst[0].toFloat(); - float maxVal=lst[1].toFloat(); - float stepVal=lst[2].toFloat(); - - if( (maxVal-minVal)/stepVal > 20) - { - valueMode_=StepMode; - minValue_=minVal; - maxValue_=maxVal; - stepValue_=stepVal; - } - else - { - float v=minVal; - while(v <= maxVal) - { - QString s=QString::number(v); - values_.push_back(s); - v+=stepVal; - if(v <= minVal) - break; - } - } - - } - else - { - values_.push_back(item); - } - - } - } */ + { + if(name_.compare("time",Qt::CaseInsensitive) == 0) + { + valueSelectionMode_=MultipleSelectionMode; + } + + qDebug() << "Time:" << dimData; + QStringList data=dimData.split(","); + foreach(QString item, data) + { + QStringList lst=item.split("/"); + + qDebug() << "Time:" << lst; + + //Period + if(lst.count() == 3) + { + QDateTime startDate=QDateTime::fromString(lst[0],Qt::ISODate); + QDateTime endDate=QDateTime::fromString(lst[1],Qt::ISODate); + QMap period; + decodePeriod(lst[2],period); + + QDateTime dt=startDate; + while(dt <= endDate) + { + QString s=dt.toString(Qt::ISODate); + s+="Z"; + values_.push_back(s); + addPeriod(dt,period); + if(dt <= startDate) + break; + } + + qDebug() << "time: " << startDate << endDate << period; + qDebug() << "value_" << values_; + + } + else + { + values_.push_back(item); + } + } + } + else + { + QStringList data=dimData.split(","); + foreach(QString item, data) + { + QStringList lst=item.split("/"); + + //Period + if(lst.count() == 3) + { + float minVal=lst[0].toFloat(); + float maxVal=lst[1].toFloat(); + float stepVal=lst[2].toFloat(); + + if( (maxVal-minVal)/stepVal > 20) + { + valueMode_=StepMode; + minValue_=minVal; + maxValue_=maxVal; + stepValue_=stepVal; + } + else + { + float v=minVal; + while(v <= maxVal) + { + QString s=QString::number(v); + values_.push_back(s); + v+=stepVal; + if(v <= minVal) + break; + } + } + + } + else + { + values_.push_back(item); + } + + } + } */ - //displayValues_=values_; + // displayValues_=values_; } @@ -339,30 +339,30 @@ { QString pDate, pTime; - //Test + // Test if (period.startsWith("P") == false) return; QStringList lst = period.split("T"); - pDate = lst[0]; + pDate = lst[0]; if (lst.count() > 1) { pTime = lst[1]; } if (pDate.isEmpty() == false) { - //Year + // Year QRegExp rx("(\\d+Y)"); if (rx.indexIn(pDate) > -1) { res["year"] = rx.cap(1).remove("Y").toInt(); } - //Month + // Month rx = QRegExp("(\\d+M)"); if (rx.indexIn(pDate) > -1) { res["month"] = rx.cap(1).remove("M").toInt(); } - //Day + // Day rx = QRegExp("(\\d+D)"); if (rx.indexIn(pDate) > -1) { res["day"] = rx.cap(1).remove("D").toInt(); @@ -370,19 +370,19 @@ } if (pTime.isEmpty() == false) { - //Hour + // Hour QRegExp rx("(\\d+H)"); if (rx.indexIn(pTime) > -1) { res["hour"] = rx.cap(1).remove("H").toInt(); } - //Minute + // Minute rx = QRegExp("(\\d+M)"); if (rx.indexIn(pTime) > -1) { res["minute"] = rx.cap(1).remove("M").toInt(); } - //Minute + // Minute rx = QRegExp("(\\d+S)"); if (rx.indexIn(pTime) > -1) { res["sec"] = rx.cap(1).remove("S").toInt(); @@ -395,30 +395,30 @@ { if (period.contains("year")) { dt = dt.addYears(period["year"]); - //qDebug() << d; + // qDebug() << d; } if (period.contains("month")) { dt = dt.addMonths(period["month"]); - //qDebug() << d; + // qDebug() << d; } if (period.contains("day")) { dt = dt.addDays(period["day"]); - //qDebug() << d; + // qDebug() << d; } if (period.contains("hour")) { dt = dt.addSecs(period["hour"] * 3600); - //qDebug() << d; + // qDebug() << d; } if (period.contains("minute")) { dt = dt.addSecs(period["minute"] * 60); - //qDebug() << d; + // qDebug() << d; } if (period.contains("sec")) { dt = dt.addSecs(period["sec"]); - //qDebug() << d; + // qDebug() << d; } } @@ -483,7 +483,7 @@ if (attr_.contains(id)) return attr_[id]; else - return QString(); + return {}; } void MvQOgcNode::addAttribute(QString id, QString val) { @@ -525,7 +525,7 @@ if (attr_.contains(id)) return attr_[id]; else - return QString(); + return {}; } MvQOgcElem* MvQOgcElem::elem(QString id) @@ -533,7 +533,7 @@ if (elem_.contains(id)) return elem_[id]; else - return 0; + return nullptr; } void MvQOgcElem::addAttribute(QString id, QString val) diff -Nru metview-5.17.4/metview/src/OgcClient/MvQOgcParam.h metview-5.19.2/metview/src/OgcClient/MvQOgcParam.h --- metview-5.17.4/metview/src/OgcClient/MvQOgcParam.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQOgcParam.h 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ requestName_(requestName), displayName_(displayName) {} - virtual ~MvQOgcName() {} + virtual ~MvQOgcName() = default; QString requestName() { return requestName_; } void setRequestName(QString s) { requestName_ = s; } @@ -76,7 +76,7 @@ void setMinValue(int); void setMaxValue(int); -protected: +private: void checkValue(); int value_; @@ -90,11 +90,10 @@ class MvQOgcList : public MvQOgcName { public: - //MvQOgcList() : {}; + // MvQOgcList() : {}; MvQOgcList(QString requestName, QString displayName) : - MvQOgcName(requestName, displayName), - currentIndex_(-1) {} - ~MvQOgcList() { clear(); } + MvQOgcName(requestName, displayName) {} + ~MvQOgcList() override { clear(); } virtual void clear() { @@ -127,18 +126,18 @@ QStringList values_; QStringList displayValues_; QStringList descriptions_; - int currentIndex_; + int currentIndex_{-1}; }; class MvQOgcStyleList : public MvQOgcList { public: - //MvQOgcList() : {}; + // MvQOgcList() : {}; MvQOgcStyleList(QString requestName, QString displayName) : MvQOgcList(requestName, displayName) {} - ~MvQOgcStyleList() { clear(); } + ~MvQOgcStyleList() override { clear(); } - void clear() + void clear() override { legends_.clear(); MvQOgcList::clear(); @@ -147,7 +146,7 @@ QStringList legends() { return legends_; } QString currentLegend(); -protected: +private: QStringList legends_; }; @@ -157,9 +156,9 @@ MvQOgcCrsList(QString requestName, QString displayName) : MvQOgcList(requestName, displayName) { init(); } - void setValues(QStringList); + void setValues(QStringList) override; -protected: +private: void init(); QStringList allowedCrs_; @@ -180,7 +179,7 @@ QString minY() { return minY_; } QString maxY() { return maxY_; } -protected: +private: QString minX_; QString maxX_; QString minY_; @@ -222,7 +221,7 @@ resY_.clear(); } -protected: +private: QString crs_; QString minX_; QString maxX_; @@ -250,7 +249,7 @@ bool isTime(); -protected: +private: void decodePeriod(const QString&, QMap& res); void addPeriod(QDateTime&, const QMap&); @@ -269,8 +268,8 @@ class MvQOgcNode : public MvQOgcName { public: - MvQOgcNode() { parent_ = 0; } - ~MvQOgcNode() { clear(); } + MvQOgcNode() = default; + ~MvQOgcNode() override { clear(); } void clear() { @@ -304,7 +303,7 @@ QString attribute(QString); void addAttribute(QString, QString); -protected: +private: void setParent(MvQOgcNode* parent) { parent_ = parent; } QString value_; @@ -313,7 +312,7 @@ QString logo_; QMap attr_; - MvQOgcNode* parent_; + MvQOgcNode* parent_{nullptr}; QList children_; }; @@ -321,12 +320,9 @@ { public: MvQOgcTree(QString requestName, QString displayName) : - MvQOgcName(requestName, displayName) - { - root_ = new MvQOgcNode; - currentNode_ = 0; - } - ~MvQOgcTree() { clear(); } + MvQOgcName(requestName, displayName), root_(new MvQOgcNode) {} + + ~MvQOgcTree() override { clear(); } MvQOgcNode* currentNode() { return currentNode_; } void setCurrentNode(MvQOgcNode*); @@ -341,12 +337,12 @@ void clear() { root_->clear(); - currentNode_ = 0; + currentNode_ = nullptr; } -protected: - MvQOgcNode* root_; - MvQOgcNode* currentNode_; +private: + MvQOgcNode* root_{nullptr}; + MvQOgcNode* currentNode_{nullptr}; }; @@ -362,7 +358,7 @@ void addAttribute(QString, QString); void addElem(QString, MvQOgcElem*); -protected: +private: QMap attr_; QMap elem_; }; diff -Nru metview-5.17.4/metview/src/OgcClient/MvQOgcRequest.cc metview-5.19.2/metview/src/OgcClient/MvQOgcRequest.cc --- metview-5.17.4/metview/src/OgcClient/MvQOgcRequest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQOgcRequest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,9 @@ /* Warning!!! - + QDateTime::fromString(QString,Qt::ISODate) - + is not able to handle fractional dates like 1991-01 or 1991-01-01T02:02. So we need to figure aou the actual date format and that has to be used in the second argument of @@ -40,7 +40,7 @@ return requestMap_[sid]; } else { - return QString(); + return {}; } } @@ -49,7 +49,7 @@ QString sid = getStoredId(id); if (!sid.isEmpty()) { QString sFrom = sid + "=" + requestMap_[sid]; - QString sTo = sid + "=" + value; + QString sTo = sid + "=" + value; request_.replace(sFrom, sTo); parse(); } @@ -88,7 +88,7 @@ } } - return QString(); + return {}; } @@ -132,14 +132,14 @@ if (lst.count() > 0) return lst[0]; else - return QString(); + return {}; } QString MvQOgcRequest::timeToString(QString t) { if (t.startsWith("P")) { int s = periodToSeconds(t); - //There are minutes or seconds + // There are minutes or seconds if (s % 3600 != 0) { t.remove(0, 1); return t; @@ -149,17 +149,17 @@ } } else { - //QDateTime d=QDateTime::fromString(correctDateTime(t),Qt::ISODate); + // QDateTime d=QDateTime::fromString(correctDateTime(t),Qt::ISODate); QDateTime d = QDateTime::fromString(t, timeFormat(t)); - //qDebug() << "timetostring" << t << d << timeFormat(t); + // qDebug() << "timetostring" << t << d << timeFormat(t); return d.toString("yyyyMMddhhmmss"); } } -//We need this to overcome a Qt bug. If the seconds are missing -//from an ISO 8601 time string qt QDateTime incorrectly interpret the time part of -//the string. So in this case the we add the seconds to the string! +// We need this to overcome a Qt bug. If the seconds are missing +// from an ISO 8601 time string qt QDateTime incorrectly interpret the time part of +// the string. So in this case the we add the seconds to the string! QString MvQOgcRequest::correctDateTime(QString d) { @@ -170,20 +170,20 @@ QStringList lst = d.split("T"); - //qDebug() << "corr" << lst; + // qDebug() << "corr" << lst; if (lst.count() == 2) { QStringList t = lst[1].split(":"); if (t.count() == 2) { res = lst[0] + "T" + t[0] + ":" + t[1] + ":00"; - //qDebug() << "corr" << res; + // qDebug() << "corr" << res; if (tzone) { res += "Z"; } } } - //qDebug() << "corr" << res; + // qDebug() << "corr" << res; return res; } @@ -191,61 +191,61 @@ { QString pDate, pTime; - //Test + // Test if (period.startsWith("P") == false) return; QStringList lst = period.split("T"); - pDate = lst[0]; + pDate = lst[0]; if (lst.count() > 1) { pTime = lst[1]; } - //qDebug() << period << pDate << pTime; + // qDebug() << period << pDate << pTime; if (pDate.isEmpty() == false) { - //Year + // Year QRegExp rx("(\\d+Y)"); if (rx.indexIn(pDate) > -1) { res["year"] = rx.cap(1).remove("Y").toInt(); - //qDebug() << "year: " << res["year"]; + // qDebug() << "year: " << res["year"]; } - //Month + // Month rx = QRegExp("(\\d+M)"); if (rx.indexIn(pDate) > -1) { res["month"] = rx.cap(1).remove("M").toInt(); - //qDebug() << "Month: " << res["month"]; + // qDebug() << "Month: " << res["month"]; } - //Day + // Day rx = QRegExp("(\\d+D)"); if (rx.indexIn(pDate) > -1) { res["day"] = rx.cap(1).remove("D").toInt(); - //qDebug() << "Day: " << res["day"]; + // qDebug() << "Day: " << res["day"]; } } if (pTime.isEmpty() == false) { - //Hour + // Hour QRegExp rx("(\\d+H)"); if (rx.indexIn(pTime) > -1) { res["hour"] = rx.cap(1).remove("H").toInt(); - //qDebug() << "hour: " << res["hour"]; + // qDebug() << "hour: " << res["hour"]; } - //Minute + // Minute rx = QRegExp("(\\d+M)"); if (rx.indexIn(pTime) > -1) { res["minute"] = rx.cap(1).remove("M").toInt(); - //qDebug() << "Month: " << res["minute"]; + // qDebug() << "Month: " << res["minute"]; } - //Minute + // Minute rx = QRegExp("(\\d+S)"); if (rx.indexIn(pTime) > -1) { res["sec"] = rx.cap(1).remove("S").toInt(); - //qDebug() << "Second: " << res["sec"]; + // qDebug() << "Second: " << res["sec"]; } } } @@ -254,30 +254,30 @@ { if (period.contains("year")) { dt = dt.addYears(period["year"]); - //qDebug() << d; + // qDebug() << d; } if (period.contains("month")) { dt = dt.addMonths(period["month"]); - //qDebug() << d; + // qDebug() << d; } if (period.contains("day")) { dt = dt.addDays(period["day"]); - //qDebug() << d; + // qDebug() << d; } if (period.contains("hour")) { dt = dt.addSecs(period["hour"] * 3600); - //qDebug() << d; + // qDebug() << d; } if (period.contains("minute")) { dt = dt.addSecs(period["minute"] * 60); - //qDebug() << d; + // qDebug() << d; } if (period.contains("sec")) { dt = dt.addSecs(period["sec"]); - //qDebug() << d; + // qDebug() << d; } } @@ -287,7 +287,7 @@ decodePeriod(t, period); QDateTime dtBase = QDateTime::currentDateTime(); - QDateTime dtEnd = dtBase; + QDateTime dtEnd = dtBase; addPeriod(dtEnd, period); return dtBase.secsTo(dtEnd); } @@ -372,7 +372,7 @@ void MvQGetMapRequest::editRequest(QString r) { - //timeDimName_=timeDimName; + // timeDimName_=timeDimName; clear(); request_ = r; @@ -394,12 +394,12 @@ MvQOgcRequest::parse(); - //Parse for time dimension + // Parse for time dimension QList > frameLst; QList indexRange, indexState; - //qDebug() << "timeDimName_" << timeDimName_; + // qDebug() << "timeDimName_" << timeDimName_; foreach (QString dimName, dims()) { if (requestMap_.contains(dimName)) { @@ -425,23 +425,23 @@ } } - //qDebug() << "frames" << frameLst; + // qDebug() << "frames" << frameLst; if (frameLst.count() > 0) { bool moreIndex = true; int currentPos = indexState.count() - 1; while (moreIndex) { - //qDebug() << "index" << indexState; + // qDebug() << "index" << indexState; QString req = request_; - //qDebug() << req; + // qDebug() << req; for (int i = 0; i < indexState.count(); i++) { QString dimName = frameLst[i].first; - QString value = frameLst[i].second.at(indexState[i]); + QString value = frameLst[i].second.at(indexState[i]); QString frameReq = dimName + "=" + requestMap_[dimName]; - //qDebug() << "frameReq" << frameReq; + // qDebug() << "frameReq" << frameReq; req.replace(frameReq, dimName + "=" + value); } @@ -460,28 +460,28 @@ } /*if(requestMap_.contains("TIME")) - { - QString timeReq="TIME=" + requestMap_["TIME"]; - foreach(QString time, requestMap_["TIME"].split("/")) - { - QString req=request_; - req.replace(timeReq,"TIME=" + time); - requestStep_ << req; - outFile_ << " "; - - } - time_=requestMap_["TIME"].split("/"); - }*/ - //else + { + QString timeReq="TIME=" + requestMap_["TIME"]; + foreach(QString time, requestMap_["TIME"].split("/")) + { + QString req=request_; + req.replace(timeReq,"TIME=" + time); + requestStep_ << req; + outFile_ << " "; + + } + time_=requestMap_["TIME"].split("/"); + }*/ + // else //{ // requestStep_ << request_; // outFile_ << " "; - //} + // } } bool MvQGetMapRequest::getNextVariation(int& currentPos, QList ranges, QList& currentState, bool forward) { - //qDebug() << currentPos << currentState << ranges; + // qDebug() << currentPos << currentState << ranges; if (currentState[currentPos] == ranges[currentPos] - 1) { if (currentPos == 0) { @@ -532,7 +532,7 @@ if (index >= 0 && index < outFile_.count()) { return outFile_[index]; } - return QString(); + return {}; } QString MvQGetMapRequest::requestFrame(int index) @@ -540,7 +540,7 @@ if (index >= 0 && index < requestFrame_.count()) { return requestFrame_[index]; } - return QString(); + return {}; } void MvQGetMapRequest::dimValuesForFrame(QMap& val, int frame) @@ -566,33 +566,33 @@ /*void MvQGetMapRequest::timeDimValuesForFrame(QMap& val, int step) { - if(step < 0 || step >= requestStep_.count()) - { - return; - - } - - MvQOgcRequest r; - foreach(QString s,timeDimName_) - { - r.setRequest(requestStep_[step]); - val[s]=r.item(s); - } + if(step < 0 || step >= requestStep_.count()) + { + return; + + } + + MvQOgcRequest r; + foreach(QString s,timeDimName_) + { + r.setRequest(requestStep_[step]); + val[s]=r.item(s); + } } void MvQGetMapRequest::nonTimeDimValues(QMap& val) { - if(requestMap_.contains("ELEVATION")) - { - val["ELEVATION"]=requestMap_["ELEVATION"]; - } - foreach(QString s,requestMap_.keys()) - { - if(s.startsWith("DIM_") && timeDimName_.indexOf(s) == -1 ) - { - val[s]=requestMap_[s]; - } - } + if(requestMap_.contains("ELEVATION")) + { + val["ELEVATION"]=requestMap_["ELEVATION"]; + } + foreach(QString s,requestMap_.keys()) + { + if(s.startsWith("DIM_") && timeDimName_.indexOf(s) == -1 ) + { + val[s]=requestMap_[s]; + } + } }*/ QString MvQGetMapRequest::crs() const @@ -604,55 +604,55 @@ return requestMap_["SRS"]; } - return QString(); + return {}; } QString MvQGetMapRequest::minX() { if (requestMap_.contains("BBOX")) { - QString bb = requestMap_["BBOX"]; + QString bb = requestMap_["BBOX"]; QStringList lst = bb.split(","); if (lst.count() == 4) { return lst[0]; } } - return QString(); + return {}; } QString MvQGetMapRequest::maxX() { if (requestMap_.contains("BBOX")) { - QString bb = requestMap_["BBOX"]; + QString bb = requestMap_["BBOX"]; QStringList lst = bb.split(","); if (lst.count() == 4) { return lst[2]; } } - return QString(); + return {}; } QString MvQGetMapRequest::minY() { if (requestMap_.contains("BBOX")) { - QString bb = requestMap_["BBOX"]; + QString bb = requestMap_["BBOX"]; QStringList lst = bb.split(","); if (lst.count() == 4) { return lst[1]; } } - return QString(); + return {}; } QString MvQGetMapRequest::maxY() { if (requestMap_.contains("BBOX")) { - QString bb = requestMap_["BBOX"]; + QString bb = requestMap_["BBOX"]; QStringList lst = bb.split(","); if (lst.count() == 4) { return lst[3]; } } - return QString(); + return {}; } @@ -662,44 +662,44 @@ return requestMap_["LAYERS"]; } - return QString(); + return {}; } void MvQGetMapRequest::decodeTimeDimItem(QString item, QStringList& values) { QStringList lst = item.split("/"); - //qDebug() << "Time:" << lst; + // qDebug() << "Time:" << lst; - //QDateTime dm=QDateTime::fromString(lst[0],Qt::ISODate); - //qDebug() << dm.toString("-yyyy") << dm.toString("MM") << dm.toString("dd") << - //dm.toString("hh") << dm.toString("mm") << dm.toString("ss"); + // QDateTime dm=QDateTime::fromString(lst[0],Qt::ISODate); + // qDebug() << dm.toString("-yyyy") << dm.toString("MM") << dm.toString("dd") << + // dm.toString("hh") << dm.toString("mm") << dm.toString("ss"); - //Period + // Period if (lst.count() == 3) { QString tf = timeFormat(lst[0]); - //qDebug() << "tf" << tf; + // qDebug() << "tf" << tf; QDateTime startDate = QDateTime::fromString(lst[0], tf); - QDateTime endDate = QDateTime::fromString(lst[1], tf); + QDateTime endDate = QDateTime::fromString(lst[1], tf); - //QDateTime startDate=QDateTime::fromString(MvQOgcRequest::correctDateTime(lst[0]),Qt::ISODate); - //QDateTime endDate=QDateTime::fromString(MvQOgcRequest::correctDateTime(lst[1]),Qt::ISODate); + // QDateTime startDate=QDateTime::fromString(MvQOgcRequest::correctDateTime(lst[0]),Qt::ISODate); + // QDateTime endDate=QDateTime::fromString(MvQOgcRequest::correctDateTime(lst[1]),Qt::ISODate); - //qDebug() << startDate << endDate; + // qDebug() << startDate << endDate; QMap period; MvQOgcRequest::decodePeriod(lst[2], period); - //qDebug() << period; + // qDebug() << period; - int cnt = 0; + int cnt = 0; QDateTime dt = startDate; while (dt <= endDate && cnt < maxFrame_) { - //QString s=dt.toString(Qt::ISODate); - //s+="Z"; + // QString s=dt.toString(Qt::ISODate); + // s+="Z"; QString s = dt.toString(tf); @@ -710,8 +710,8 @@ break; } - //qDebug() << "time: " << startDate << endDate << period; - //qDebug() << "value_" << values; + // qDebug() << "time: " << startDate << endDate << period; + // qDebug() << "value_" << values; } else if (lst.count() == 1 && lst[0].isEmpty() == false) { values.push_back(item); @@ -722,11 +722,11 @@ { QStringList lst = item.split("/"); - //qDebug() << "Decode other dim:" << lst; + // qDebug() << "Decode other dim:" << lst; if (lst.count() == 3) { - float minVal = lst[0].toFloat(); - float maxVal = lst[1].toFloat(); + float minVal = lst[0].toFloat(); + float maxVal = lst[1].toFloat(); float stepVal = lst[2].toFloat(); float v = minVal; @@ -761,7 +761,7 @@ QString MvQGetMapRequest::item(QString id) const { - //qDebug() << "id" << id; + // qDebug() << "id" << id; if (id == "mv_key_url") { return guessUrl(); @@ -786,7 +786,7 @@ } } - //qDebug() << lst.join("&"); + // qDebug() << lst.join("&"); return lst.join("&"); } else if (id == "mv_key_extrapar") { @@ -863,7 +863,7 @@ void MvQGetMapRequest::setDims(QString value, bool temporal) { - //qDebug() << "setDims" << value << temporal; + // qDebug() << "setDims" << value << temporal; QMap dimLst; if (temporal) { @@ -883,18 +883,18 @@ QStringList dimNames = dimLst.keys(); - //qDebug() << dimNames; + // qDebug() << dimNames; QStringList lst = value.split("&"); for (int i = 0; i < lst.count(); i++) { QStringList items = lst[i].split("="); if (items.count() > 1) { if (items[0].startsWith("DIM_", Qt::CaseInsensitive)) { - QString dim = items[0]; + QString dim = items[0]; QString dimValue = lst[i].right(lst[i].count() - dim.count() - 1); - QString sid = getStoredId(dim); + QString sid = getStoredId(dim); - //qDebug() << "setDim" << dim << dimValue; + // qDebug() << "setDim" << dim << dimValue; if (!sid.isEmpty() && dimNames.contains(sid, Qt::CaseInsensitive)) { MvQOgcRequest::setItem(dim, dimValue); @@ -911,9 +911,9 @@ } } - //qDebug() << dimLst; + // qDebug() << dimLst; - //Remove unsepcified dims + // Remove unsepcified dims foreach (QString dim, dimLst.keys()) { if (dimLst[dim] == false) { removeItem(dim); @@ -938,11 +938,11 @@ if (items.count() > 1) { if (!stdParams_.contains(items[0], Qt::CaseInsensitive) && !items[0].startsWith("DIM_", Qt::CaseInsensitive)) { - QString par = items[0]; + QString par = items[0]; QString parValue = lst[i].right(lst[i].count() - par.count() - 1); - QString sid = getStoredId(par); + QString sid = getStoredId(par); - //qDebug() << "setPar" << par << parValue; + // qDebug() << "setPar" << par << parValue; if (!sid.isEmpty() && pars.contains(sid)) { MvQOgcRequest::setItem(par, parValue); @@ -958,7 +958,7 @@ } } - //Remove unsepcified pars + // Remove unsepcified pars foreach (QString par, pars.keys()) { if (pars[par] == false) { removeItem(par); diff -Nru metview-5.17.4/metview/src/OgcClient/MvQOgcRequest.h metview-5.19.2/metview/src/OgcClient/MvQOgcRequest.h --- metview-5.17.4/metview/src/OgcClient/MvQOgcRequest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQOgcRequest.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ class MvQOgcRequest { public: - MvQOgcRequest() = default; + MvQOgcRequest() = default; virtual ~MvQOgcRequest() = default; const QString& request() const { return request_; } @@ -51,7 +51,7 @@ void setRequest(QString, QStringList lst = QStringList()); void editRequest(QString); - void clear(); + void clear() override; int requestFrameNum() { return requestFrame_.count(); } QString requestFrame(int); QStringList requestFrame() { return requestFrame_; } @@ -70,17 +70,17 @@ QString maxY(); QString layers(); void dimValuesForFrame(QMap&, int); - //void timeDimValuesForFrame(QMap&,int); - //void nonTimeDimValues(QMap&); + // void timeDimValuesForFrame(QMap&,int); + // void nonTimeDimValues(QMap&); bool isTimeDim(QString); - QString item(QString) const; + QString item(QString) const override; void setItem(QString, QString); - void removeItem(QString); + void removeItem(QString) override; void setDims(QString, bool); QStringList dims() const; -protected: - void parse(); +private: + void parse() override; bool getNextVariation(int&, QList, QList&, bool); void decodeTimeDimItem(QString, QStringList&); void decodeDimItem(QString, QStringList&); @@ -96,10 +96,10 @@ class MvQGetCoverageRequest : public MvQOgcRequest { public: - MvQGetCoverageRequest() {} + MvQGetCoverageRequest() = default; QString outFile() { return outFile_; } void setOutFile(QString s) { outFile_ = s; } -protected: +private: QString outFile_; }; diff -Nru metview-5.17.4/metview/src/OgcClient/MvQOgcServiceManager.cc metview-5.19.2/metview/src/OgcClient/MvQOgcServiceManager.cc --- metview-5.17.4/metview/src/OgcClient/MvQOgcServiceManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQOgcServiceManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,7 +42,7 @@ void MvQOgcServiceManager::writeConfig() { - //Open file for writing + // Open file for writing QFile out(configFile_); out.open(QFile::WriteOnly | QFile::Text); @@ -97,20 +97,20 @@ QString shortName, url; QStringList lst; - //QXmlQuery query; + // QXmlQuery query; query.setFocus(item); - //shortName + // shortName query.setQuery("string(./@shortName)"); query.evaluateTo(&shortName); shortName = shortName.simplified(); - //url + // url query.setQuery("string(./@url)"); query.evaluateTo(&url); url = url.simplified(); - //Name + // Name QXmlResultItems versionResult; query.setQuery("./data(Version)"); query.evaluateTo(&versionResult); diff -Nru metview-5.17.4/metview/src/OgcClient/MvQOgcServiceManagerDialog.cc metview-5.19.2/metview/src/OgcClient/MvQOgcServiceManagerDialog.cc --- metview-5.17.4/metview/src/OgcClient/MvQOgcServiceManagerDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQOgcServiceManagerDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ MvQOgcServiceManagerDialog::MvQOgcServiceManagerDialog(QWidget* parent) : QDialog(parent) { - //setAttribute(Qt::WA_DeleteOnClose); + // setAttribute(Qt::WA_DeleteOnClose); manager_ = 0; setWindowTitle("Metview - OGC Server Manager"); @@ -39,9 +39,9 @@ QSplitter* splitter = new QSplitter; layout_->addWidget(splitter); - //Servers + // Servers QVBoxLayout* vbServer = new QVBoxLayout; - w = new QWidget; + w = new QWidget; w->setLayout(vbServer); splitter->addWidget(w); @@ -55,9 +55,9 @@ serverTree_->setHeaderLabels(headers); vbServer->addWidget(serverTree_); - //Versions + // Versions QVBoxLayout* vbVersion = new QVBoxLayout; - w = new QWidget; + w = new QWidget; w->setLayout(vbVersion); splitter->addWidget(w); @@ -68,13 +68,13 @@ versionList_->setMaximumWidth(100); vbVersion->addWidget(versionList_); - //Populate versionList + // Populate versionList versions_ << "Default" << "1.0.0" << "1.1.1" << "1.3.0"; - QPushButton* addPb = new QPushButton("Add"); + QPushButton* addPb = new QPushButton("Add"); QPushButton* deletePb = new QPushButton("Delete"); QHBoxLayout* hb = new QHBoxLayout; @@ -148,8 +148,8 @@ for (unsigned int i = 0; i < serverTree_->topLevelItemCount(); i++) { QTreeWidgetItem* item = serverTree_->topLevelItem(i); - QString name = item->data(0, Qt::DisplayRole).toString(); - QString url = item->data(1, Qt::DisplayRole).toString(); + QString name = item->data(0, Qt::DisplayRole).toString(); + QString url = item->data(1, Qt::DisplayRole).toString(); QList versionStatus = item->data(0, Qt::UserRole).toList(); QStringList versions; @@ -175,7 +175,7 @@ void MvQOgcServiceManagerDialog::slotSelectServer(QTreeWidgetItem* current, QTreeWidgetItem* prev) { int row = serverTree_->indexOfTopLevelItem(current); - //const QStringList currentVersions = manager_->wms().at(row)->versions(); + // const QStringList currentVersions = manager_->wms().at(row)->versions(); QList versionStatus = current->data(0, Qt::UserRole).toList(); diff -Nru metview-5.17.4/metview/src/OgcClient/MvQOgcTreeModel.cc metview-5.19.2/metview/src/OgcClient/MvQOgcTreeModel.cc --- metview-5.17.4/metview/src/OgcClient/MvQOgcTreeModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQOgcTreeModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,6 @@ MvQOgcTreeModel::MvQOgcTreeModel(QObject* parent) : QAbstractItemModel(parent) { - root_ = nullptr; } void MvQOgcTreeModel::dataIsAboutToChange() @@ -26,7 +25,7 @@ { root_ = root; - //Reset the model (views will be notified) + // Reset the model (views will be notified) endResetModel(); } @@ -56,12 +55,12 @@ QVariant MvQOgcTreeModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || (role != Qt::DisplayRole && role != Qt::ToolTipRole)) { - return QVariant(); + return {}; } MvQOgcNode* node = nodeFromIndex(index); if (!node) - return QVariant(); + return {}; if (role == Qt::ToolTipRole) { QString s = "Title: " + node->displayValue() + "
" + @@ -86,14 +85,14 @@ QModelIndex MvQOgcTreeModel::index(int row, int column, const QModelIndex& parent) const { if (!root_ || row < 0 || column < 0) { - return QModelIndex(); + return {}; } MvQOgcNode* parentNode = nodeFromIndex(parent); - MvQOgcNode* childNode = parentNode->children().at(row); + MvQOgcNode* childNode = parentNode->children().at(row); if (!childNode) - return QModelIndex(); + return {}; return createIndex(row, column, childNode); } @@ -112,15 +111,15 @@ { MvQOgcNode* node = nodeFromIndex(child); if (!node) - return QModelIndex(); + return {}; MvQOgcNode* parentNode = node->parent(); if (!parentNode) - return QModelIndex(); + return {}; MvQOgcNode* grandParentNode = parentNode->parent(); if (!grandParentNode) - return QModelIndex(); + return {}; int row = grandParentNode->children().indexOf(parentNode); return createIndex(row, 0, parentNode); @@ -135,5 +134,5 @@ } } - return QModelIndex(); + return {}; } diff -Nru metview-5.17.4/metview/src/OgcClient/MvQOgcTreeModel.h metview-5.19.2/metview/src/OgcClient/MvQOgcTreeModel.h --- metview-5.17.4/metview/src/OgcClient/MvQOgcTreeModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQOgcTreeModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,20 +18,20 @@ public: MvQOgcTreeModel(QObject* parent); - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void dataIsAboutToChange(); void setRootNode(MvQOgcNode*); QModelIndex indexFromNode(MvQOgcNode*) const; MvQOgcNode* nodeFromIndex(const QModelIndex& index) const; -protected: - MvQOgcNode* root_; +private: + MvQOgcNode* root_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/OgcClient/MvQWmsClient.cc metview-5.19.2/metview/src/OgcClient/MvQWmsClient.cc --- metview-5.17.4/metview/src/OgcClient/MvQWmsClient.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQWmsClient.cc 2023-07-15 08:28:47.000000000 +0000 @@ -63,7 +63,6 @@ QDomElement DomFinder::find(const QDomElement& elem, QStringList pathLst) { - QDomNode n = elem; if (!elem.isNull()) { if (elem.nodeName() == pathLst[0]) { pathLst.removeFirst(); @@ -127,7 +126,7 @@ { auto a = elem.attributes(); for (int i = 0; i < a.count(); i++) { - auto item = a.item(i); + auto item = a.item(i); att[item.toAttr().name()] = item.toAttr().value().simplified(); } } @@ -164,7 +163,6 @@ str.remove("{"); str.remove("}"); - QMap param; foreach (QString s, str.split(",")) { QStringList s1 = s.split(":"); if (s1.count() == 2) { @@ -186,13 +184,13 @@ { MvRequest ctx; - //Expand the request + // Expand the request char* shareDir = getenv("METVIEW_DIR_SHARE"); if (shareDir) { std::string path(shareDir); path.append("/etc/"); - std::string defFileName = path + "GeoViewDef"; + std::string defFileName = path + "GeoViewDef"; std::string rulesFileName = path + "GeoViewRules"; MvLanguage langMetview(defFileName.c_str(), @@ -221,7 +219,7 @@ return; if (areaDef == "corners" && ctx.countValues("AREA") == 4) { - double dval; + double dval = 0.; ctx.getValue(dval, "AREA", 0); insert("subpage_lower_left_latitude", QString::number(dval)); ctx.getValue(dval, "AREA", 1); @@ -248,7 +246,7 @@ return it.value(); else - return QString(); + return {}; } @@ -286,10 +284,7 @@ // queryMsgHandler_ = new MvQWmsMessageHandler; } -MvQWmsClientBase::~MvQWmsClientBase() -{ - // delete queryMsgHandler_; -} +MvQWmsClientBase::~MvQWmsClientBase() = default; QString MvQWmsClientBase::getMimeType(QByteArray ba) { @@ -304,7 +299,7 @@ return "image/gif"; } - return QString("text/plain"); + return {"text/plain"}; } @@ -324,30 +319,16 @@ MvQWmsGetClient::MvQWmsGetClient(MvRequest& req) : reqInfo_(req) { - //Init - getMapRunStatus_ = false; - requestChanged_ = false; - - networkGetMap_ = 0; - networkLegend_ = 0; - networkLogo_ = 0; - getMapReply_ = 0; - legendReply_ = 0; - logoReply_ = 0; - - getMapFrameNum_ = 0; - getMapFrameToDownload_ = -1; - - //Mode + // Mode const char* modec = (const char*)reqInfo_("_ACTION"); QString mode; if (modec) mode = QString(modec); - //Nosubsets + // Nosubsets const char* noSubsets = (const char*)reqInfo_("LAYER_NOSUBSETS"); - //Time dimensions + // Time dimensions QStringList timeDimName; const char* tdn = (const char*)reqInfo_("TIME_DIMENSIONS"); if (tdn) { @@ -355,22 +336,22 @@ timeDimName = s.split("/"); } - //Create and initialise request object + // Create and initialise request object getMapRequest_ = new MvQGetMapRequest; getMapRequest_->setRequest(QString((const char*)reqInfo_("REQUEST")), timeDimName); - //Update bbox if needed + // Update bbox if needed if ((mode == "prepare" || mode == "update") && - (noSubsets == 0 || strcmp(noSubsets, "0") == 0)) { + (noSubsets == nullptr || strcmp(noSubsets, "0") == 0)) { requestChanged_ = updateBoundingBox(); } - //In update mode if bbox was not updated we quit + // In update mode if bbox was not updated we quit if (mode == "update" && requestChanged_ == false) { return; } - //Legend and log path + // Legend and log path const char* legend = (const char*)reqInfo_("LAYER_LEGEND"); if (legend) legendPath_ = QString(legend); @@ -380,10 +361,10 @@ logoPath_ = QString(logo); - //Network access + // Network access networkGetMap_ = new MvQNetworkAccessManager(this); networkLegend_ = new MvQNetworkAccessManager(this); - networkLogo_ = new MvQNetworkAccessManager(this); + networkLogo_ = new MvQNetworkAccessManager(this); connect(networkGetMap_, SIGNAL(replyReadyToProcess(QNetworkReply*)), this, SLOT(slotReplyGetMap(QNetworkReply*))); @@ -408,19 +389,19 @@ bool MvQWmsGetClient::updateBoundingBox() { - //Get current view area in the plot + // Get current view area in the plot MvRequest ctxIn = reqInfo_("_CONTEXT"); if (!ctxIn || strcmp(ctxIn.getVerb(), "GEOVIEW") != 0) return false; - //ctxIn.print(); + // ctxIn.print(); MvQProjInfo projInfo(ctxIn); - //ctxIn.print(); + // ctxIn.print(); QList areaL; - //Cylindrical + // Cylindrical if (projInfo.get("subpage_map_projection") == "cylindrical") { if (projInfo.get("subpage_map_area_definition") == "corners" || projInfo.get("subpage_map_area_definition") == "full") { @@ -477,7 +458,7 @@ return false; } #endif - //Max bounding box for the given CRS/SRS + // Max bounding box for the given CRS/SRS const char* bbChar = (const char*)reqInfo_("MAX_BOUNDING_BOX"); QRectF maxBox; if (bbChar) { @@ -494,7 +475,7 @@ return false; } - //Current bounding box from the request + // Current bounding box from the request QRectF currentBox; QStringList lst = getMapRequest_->item("BBOX").split(","); if (lst.count() == 4) { @@ -507,17 +488,17 @@ return false; } - //We reached this point only if both view area and - //bounding box were found!!!! + // We reached this point only if both view area and + // bounding box were found!!!! if (projInfo.get("subpage_map_projection") == "cylindrical") { - //areaL: s,w,n,e - //bbox: mix, miny, max, maxy - //qDebug() << "area" << areaL; + // areaL: s,w,n,e + // bbox: mix, miny, max, maxy + // qDebug() << "area" << areaL; QRectF areaBox; - //For 1.3.0 in epsg:4326 x is lat and y is lon !!!!! + // For 1.3.0 in epsg:4326 x is lat and y is lon !!!!! if (getMapRequest_->request().contains("CRS=", Qt::CaseInsensitive) && getMapRequest_->crs() == "EPSG:4326") { areaBox = QRectF(areaL[0], areaL[1], areaL[2] - areaL[0], areaL[3] - areaL[1]); @@ -532,11 +513,11 @@ if (areaBox.intersects(maxBox)) { // maxAreaBox = the intersection of the viewable area - //and the max bounding box for the srs/c + // and the max bounding box for the srs/c QRectF maxAreaBox = areaBox.intersected(maxBox); - //Find out the relation of the maxAreaBox and the current bounding - //box in the request + // Find out the relation of the maxAreaBox and the current bounding + // box in the request QRectF resBox; if (maxAreaBox != currentBox) { resBox = maxAreaBox; @@ -561,8 +542,8 @@ { outFiles_.clear(); - QStringList lst = getMapRequest_->requestFrame(); - getMapFrameNum_ = lst.count(); + QStringList lst = getMapRequest_->requestFrame(); + getMapFrameNum_ = lst.count(); getMapFrameToDownload_ = 0; getMapRunStatus_ = false; @@ -571,10 +552,10 @@ void MvQWmsGetClient::downloadGetMapFrame() { - //qDebug() << "request" << getMapFrameToDownload_ << getMapRequest_->requestFrame(getMapFrameToDownload_); + // qDebug() << "request" << getMapFrameToDownload_ << getMapRequest_->requestFrame(getMapFrameToDownload_); QNetworkRequest netReq(QUrl::fromPercentEncoding(getMapRequest_->requestFrame(getMapFrameToDownload_).toUtf8())); - //netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); + // netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); getMapReply_ = networkGetMap_->get(netReq); } @@ -582,14 +563,14 @@ void MvQWmsGetClient::downloadLegend() { if (!legendPath_.isEmpty()) { - //qDebug() << "legend" << QUrl::fromPercentEncoding(legendPath_.toAscii()); + // qDebug() << "legend" << QUrl::fromPercentEncoding(legendPath_.toAscii()); QNetworkRequest netReq(QUrl::fromPercentEncoding(legendPath_.toUtf8())); - //netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); + // netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); legendReply_ = networkLegend_->get(netReq); } else { - //QApplication::exit(); + // QApplication::exit(); downloadLogo(); } } @@ -608,14 +589,14 @@ void MvQWmsGetClient::slotReplyGetMap(QNetworkReply* reply) { QNetworkRequest r = reply->request(); - QUrl url = r.url(); + QUrl url = r.url(); - //qDebug() << url.toString(); + // qDebug() << url.toString(); QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); if (reply->error() != QNetworkReply::NoError) { - getMapFrameNum_ = 0; + getMapFrameNum_ = 0; getMapFrameToDownload_ = -1; QString ems = "GetMap request failed!\nError: "; @@ -636,18 +617,17 @@ if (mimeType.isEmpty()) mimeType = getMimeType(ba); - //If exception is returned or mime type is - //different to what was requested + // If exception is returned or mime type is + // different to what was requested if (mimeType.contains("application/vnd.ogc.se_xml") || mimeType.contains("text/xml") || !mimeType.contains(getRequestedMimeType(url.toString()))) { - QString eMsg; - //readException(ba,eMsg); + // readException(ba,eMsg); - getMapFrameNum_ = 0; + getMapFrameNum_ = 0; getMapFrameToDownload_ = -1; - //marslog(LOG_EROR,"GetMap request failed!\nError: %s ",eMsg.toStdString().c_str()); + // marslog(LOG_EROR,"GetMap request failed!\nError: %s ",eMsg.toStdString().c_str()); marslog(LOG_EROR, "GetMap request failed! "); QApplication::exit(); return; @@ -664,42 +644,38 @@ downloadGetMapFrame(); } else { - getMapFrameNum_ = 0; + getMapFrameNum_ = 0; getMapFrameToDownload_ = -1; getMapRunStatus_ = true; downloadLegend(); - //QApplication::exit(); + // QApplication::exit(); } } reply->deleteLater(); - getMapReply_ = 0; + getMapReply_ = nullptr; } void MvQWmsGetClient::slotReplyLegend(QNetworkReply* reply) { QNetworkRequest r = reply->request(); - QUrl url = r.url(); - - //qDebug() << url.toString(); - QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); if (reply->error() != QNetworkReply::NoError) { QString ems = "Legend download failed!\nError: "; ems += reply->errorString(); marslog(LOG_EROR, "Legend download failed!\nError: %s ", reply->errorString().toStdString().c_str()); - //log->error(reply->errorString().toStdString() + "\n"); + // log->error(reply->errorString().toStdString() + "\n"); downloadLogo(); - //QApplication::exit(); + // QApplication::exit(); return; } else { QByteArray ba = reply->readAll(); - //If exception is returned ot mime type is - //different ot what was requested + // If exception is returned ot mime type is + // different ot what was requested if (mimeType.contains("application/vnd.ogc.se_xml") || mimeType.contains("text/xml") || mimeType.contains("text/plain")) //|| @@ -718,38 +694,34 @@ legendImagePath_ = outFile; - //QApplication::exit(); + // QApplication::exit(); downloadLogo(); } } reply->deleteLater(); - legendReply_ = 0; + legendReply_ = nullptr; } void MvQWmsGetClient::slotReplyLogo(QNetworkReply* reply) { QNetworkRequest r = reply->request(); - QUrl url = r.url(); - - //qDebug() << url.toString(); - QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); if (reply->error() != QNetworkReply::NoError) { QString ems = "Logo download failed!\nError: "; ems += reply->errorString(); marslog(LOG_EROR, "Logo download failed!\nError: %s ", reply->errorString().toStdString().c_str()); - //log->error(reply->errorString().toStdString() + "\n"); + // log->error(reply->errorString().toStdString() + "\n"); QApplication::exit(); return; } else { QByteArray ba = reply->readAll(); - //If exception is returned ot mime type is - //different ot what was requested + // If exception is returned ot mime type is + // different ot what was requested if (mimeType.contains("application/vnd.ogc.se_xml") || mimeType.contains("text/xml") || mimeType.contains("text/plain")) //|| @@ -778,7 +750,7 @@ } reply->deleteLater(); - logoReply_ = 0; + logoReply_ = nullptr; } @@ -797,7 +769,7 @@ std::string path(shareDir); path.append("/etc/"); - std::string defFileName = path + "WmsClientDef"; + std::string defFileName = path + "WmsClientDef"; std::string rulesFileName = path + "WmsClientRules"; MvLanguage langMetview(defFileName.c_str(), @@ -810,11 +782,11 @@ reqInfo_.print(); - getMapRequest_ = new MvQGetMapRequest; + getMapRequest_ = new MvQGetMapRequest; lastGetMapRequest_ = new MvQGetMapRequest; // Initialize elements from Metview request - url_ = QString((const char*)reqInfo_("SERVER")); + url_ = QString((const char*)reqInfo_("SERVER")); version_ = (const char*)reqInfo_("VERSION"); QStringList timeDimName; @@ -828,7 +800,7 @@ getMapRequest_->setRequest(QString((const char*)reqInfo_("REQUEST")), timeDimName); clientMode_ = AdvancedMode; - if ((const char*)reqInfo_("MODE") != 0) { + if ((const char*)reqInfo_("MODE") != nullptr) { QString m(reqInfo_("MODE")); if (m == "EXPERT") clientMode_ = BasicMode; @@ -836,41 +808,41 @@ clientMode_ = AdvancedMode; } - if ((const char*)reqInfo_("EXTRA_GETCAP_PAR") != 0) { + if ((const char*)reqInfo_("EXTRA_GETCAP_PAR") != nullptr) { extraGetCapPar_ = QString(reqInfo_("EXTRA_GETCAP_PAR")); } - if ((const char*)reqInfo_("EXTRA_GETMAP_PAR") != 0) { + if ((const char*)reqInfo_("EXTRA_GETMAP_PAR") != nullptr) { extraGetMapPar_ = QString(reqInfo_("EXTRA_GETMAP_PAR")); } - if ((const char*)reqInfo_("HTTP_USER") != 0) { + if ((const char*)reqInfo_("HTTP_USER") != nullptr) { httpUser_ = QString(reqInfo_("HTTP_USER")); } - if ((const char*)reqInfo_("HTTP_PASSWORD") != 0) { + if ((const char*)reqInfo_("HTTP_PASSWORD") != nullptr) { httpPassword_ = QString(reqInfo_("HTTP_PASSWORD")); } - //qDebug() << "Init:" << url_ << version_ << getMapRequest_; + // qDebug() << "Init:" << url_ << version_ << getMapRequest_; - //Width - width_ = new MvQOgcIntValue(1024, "WIDTH", "Width:"); + // Width + width_ = new MvQOgcIntValue(1024, "WIDTH", "Width:"); QString val = getMapRequest_->item(width_->requestName()); if (!val.isEmpty()) width_->setValue(val.toInt()); - //Height + // Height height_ = new MvQOgcIntValue(512, "HEIGHT", "Height:"); - val = getMapRequest_->item(height_->requestName()); + val = getMapRequest_->item(height_->requestName()); if (!val.isEmpty()) height_->setValue(val.toInt()); - //Format + // Format format_ = new MvQOgcList("FORMAT", "Format:"); - //Transparent + // Transparent transparent_ = new MvQOgcList("TRANSPARENT", "Transparent:"); transparent_->setValues(QStringList() << "TRUE" << "FALSE"); @@ -878,7 +850,7 @@ << "False"); val = getMapRequest_->item(transparent_->requestName()); - //If it is a new request we set transparency to TRUE by default + // If it is a new request we set transparency to TRUE by default if (val.isEmpty() && getMapRequest_->request().isEmpty()) { transparent_->setCurrentValue("TRUE"); } @@ -886,34 +858,34 @@ transparent_->setCurrentValue(val); } - //BgColour + // BgColour bgColour_ = new MvQOgcColourValue("#FFFFFF", "BGCOLOUR", "Bg colour:"); - //Layer + // Layer layer_ = new MvQOgcTree("LAYERS", "Layer:"); - //CRS/SRS + // CRS/SRS crs_ = new MvQOgcCrsList("CRS", "CRS:"); - //Style + // Style style_ = new MvQOgcStyleList("STYLES", "Style:"); - //BoundingBox - requestBbox_ = new MvQOgcBoundingBox("BBOX", ""); - geographicBbox_ = 0; + // BoundingBox + requestBbox_ = new MvQOgcBoundingBox("BBOX", ""); + geographicBbox_ = nullptr; - //Dimension + // Dimension - //Network access - networkGetCap_ = new MvQNetworkAccessManager(this); + // Network access + networkGetCap_ = new MvQNetworkAccessManager(this); networkPreview_ = new MvQNetworkAccessManager(this); - networkLegend_ = new MvQNetworkAccessManager(this); - networkLogo_ = new MvQNetworkAccessManager(this); + networkLegend_ = new MvQNetworkAccessManager(this); + networkLogo_ = new MvQNetworkAccessManager(this); - getCapReply_ = 0; - previewReply_ = 0; - legendReply_ = 0; - logoReply_ = 0; + getCapReply_ = nullptr; + previewReply_ = nullptr; + legendReply_ = nullptr; + logoReply_ = nullptr; connect(networkGetCap_, SIGNAL(replyReadyToProcess(QNetworkReply*)), this, SLOT(slotReplyGetCap(QNetworkReply*))); @@ -940,10 +912,10 @@ this, SLOT(slotAuthentication(QNetworkReply*, QAuthenticator*))); previewFile_ = marstmp(); - legendFile_ = marstmp(); - logoFile_ = marstmp(); + legendFile_ = marstmp(); + logoFile_ = marstmp(); - //xml namspace + // xml namspace xlinkNsDeclaration_ = "declare namespace xlink = \"http://www.w3.org/1999/xlink\";"; } @@ -986,7 +958,7 @@ if (v.isEmpty()) { v = getMapRequest_->item("version"); } - url_ = getMapRequest_->guessUrl(); + url_ = getMapRequest_->guessUrl(); version_ = v; } @@ -1009,7 +981,7 @@ v = getMapRequest_->item("version"); } - //qDebug() << "new url:" << getMapRequest_->guessUrl(); + // qDebug() << "new url:" << getMapRequest_->guessUrl(); if (url_ != getMapRequest_->guessUrl() || version_ != v) { @@ -1060,7 +1032,7 @@ if (geographicBbox_) { delete geographicBbox_; - geographicBbox_ = 0; + geographicBbox_ = nullptr; } } @@ -1068,7 +1040,7 @@ { if (url_ != url) { slotAbortDownloadProcess(); - url_ = url; + url_ = url; version_ = version; clearServerDependentData(); } @@ -1079,14 +1051,14 @@ if (version_ != version) { slotAbortDownloadProcess(); version_ = version; - //clearServerDependentData(); + // clearServerDependentData(); } } void MvQWmsUiClient::slotRunGetCapabilities() { lastGetMapRequest_->setRequest(getMapRequest_->request()); - clearServerDependentData(true); //keeps the original request + clearServerDependentData(true); // keeps the original request QString r = url_; @@ -1106,7 +1078,7 @@ QUrl url = QUrl::fromPercentEncoding(r.toUtf8()); QNetworkRequest nr(url); - //nr.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); + // nr.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); getCapReply_ = networkGetCap_->get(QNetworkRequest(nr)); } @@ -1138,12 +1110,12 @@ req.setItem("HEIGHT", h); GuiLog().task() << "Load preview" << GuiLog().requestKey() << req.request().toStdString(); - //log->setStatus("In progress"); + // log->setStatus("In progress"); StatusMsgHandler::instance()->show(tr("Load preview ..."), true); QNetworkRequest netReq(QUrl::fromPercentEncoding(req.request().toUtf8())); netReq.setOriginatingObject(this); - //netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); + // netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); previewReply_ = networkPreview_->get(netReq); @@ -1153,14 +1125,14 @@ { if (!style_->currentLegend().isEmpty()) { GuiLog().task() << "Load legend" << GuiLog().requestKey() << style_->currentLegend().toStdString(); - //log->setStatus("In progress"); + // log->setStatus("In progress"); StatusMsgHandler::instance()->show(tr("Load legend"), true); - //Fix for KNMI radar + // Fix for KNMI radar QNetworkRequest netReq(QUrl::fromPercentEncoding(style_->currentLegend().toUtf8())); netReq.setOriginatingObject(this); - //netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); + // netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); legendReply_ = networkLegend_->get(netReq); } else { @@ -1173,13 +1145,13 @@ MvQOgcNode* node = layer_->currentNode(); if (node && !node->logo().isEmpty()) { GuiLog().task() << "Load logo" << GuiLog().requestKey() << node->logo().toStdString(); - //log->setStatus("In progress"); + // log->setStatus("In progress"); StatusMsgHandler::instance()->show(tr("Load logo"), true); - //Fix for KNMI radar + // Fix for KNMI radar QNetworkRequest netReq(QUrl::fromPercentEncoding(node->logo().toUtf8())); netReq.setOriginatingObject(this); - //netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); + // netReq.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("egows").arg("egows").toAscii()).toBase64()); logoReply_ = networkLogo_->get(netReq); } else { @@ -1201,11 +1173,11 @@ // Get info MvRequest r("WMSCLIENT"); - r("SERVER") = url_.toStdString().c_str(); - r("VERSION") = version_.toStdString().c_str(); - r("REQUEST") = getMapRequest_->request().toStdString().c_str(); + r("SERVER") = url_.toStdString().c_str(); + r("VERSION") = version_.toStdString().c_str(); + r("REQUEST") = getMapRequest_->request().toStdString().c_str(); r("TIME_DIMENSIONS") = timeDimName().join("/").toStdString().c_str(); - //r("NON_TIME_DIMENSIONS") = nonTimeDimName().join("/").toStdString().c_str(); + // r("NON_TIME_DIMENSIONS") = nonTimeDimName().join("/").toStdString().c_str(); // reqInfo_("SERVICE") = 1; if (clientMode_ == BasicMode) { @@ -1218,13 +1190,13 @@ r("EXTRA_GETCAP_PAR") = extraGetCapPar_.toStdString().c_str(); r("EXTRA_GETMAP_PAR") = extraGetMapPar_.toStdString().c_str(); - r("HTTP_USER") = httpUser_.toStdString().c_str(); + r("HTTP_USER") = httpUser_.toStdString().c_str(); r("HTTP_PASSWORD") = httpPassword_.toStdString().c_str(); - r("LAYER_TITLE") = layer_->currentDisplayValue().toStdString().c_str(); + r("LAYER_TITLE") = layer_->currentDisplayValue().toStdString().c_str(); r("LAYER_DESCRIPTION") = layer_->currentDescription().toStdString().c_str(); - r("SERVICE_TITLE") = serviceMeta_["Title"].toStdString().c_str(); - r("LAYER_LEGEND") = style_->currentLegend().toStdString().c_str(); + r("SERVICE_TITLE") = serviceMeta_["Title"].toStdString().c_str(); + r("LAYER_LEGEND") = style_->currentLegend().toStdString().c_str(); MvQOgcNode* node = layer_->currentNode(); if (node) { @@ -1243,8 +1215,8 @@ r("MAX_BOUNDING_BOX") = getMapRequest_->item("BBOX").split(",").join("/").toStdString().c_str(); - //qDebug() << version_; - //qDebug() << url_; + // qDebug() << version_; + // qDebug() << url_; MvRequest rout; @@ -1255,7 +1227,7 @@ std::string path(shareDir); path.append("/etc/"); - std::string defFileName = path + "WmsClientDef"; + std::string defFileName = path + "WmsClientDef"; std::string rulesFileName = path + "WmsClientRules"; MvLanguage langMetview(defFileName.c_str(), @@ -1283,17 +1255,13 @@ auth->setUser("egows"); auth->setPassword("egows"); - //auth->setUser(httpUser_); - //auth->setPassword(httpPassword_); + // auth->setUser(httpUser_); + // auth->setPassword(httpPassword_); } void MvQWmsUiClient::slotReplyGetCap(QNetworkReply* reply) { QNetworkRequest r = reply->request(); - QUrl url = r.url(); - - //qDebug() << url.toString(); - QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); GuiLog().task() << "Load GetCapabilities"; @@ -1303,7 +1271,7 @@ StatusMsgHandler::instance()->failed(); emit getCapabilityLoaded(); - //QApplication::exit(); + // QApplication::exit(); } else { QByteArray ba = reply->readAll(); @@ -1324,15 +1292,15 @@ } else { capability_ = QString(ba); - dom_ = QDomDocument(); + dom_ = QDomDocument(); dom_.setContent(capability_); - //Uncomment these lines to load a getCapabilities file from the disk + // Uncomment these lines to load a getCapabilities file from the disk /*QFile file("/var/tmp/dummy-user/PERFORCE/metview_4/src/OgcClient/marc_dla.xml"); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return; + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return; - capability_=QString(file.readAll());*/ + capability_=QString(file.readAll());*/ repliedVersion_ = readVersion(); readService(); @@ -1347,7 +1315,7 @@ } reply->deleteLater(); - getCapReply_ = 0; + getCapReply_ = nullptr; } void MvQWmsUiClient::updateAfterGetCapLoaded() @@ -1378,7 +1346,7 @@ void MvQWmsUiClient::updateAfterLayerLoaded() { - //lastGetMapRequest_->setRequest(getMapRequest_->request()); + // lastGetMapRequest_->setRequest(getMapRequest_->request()); QString val; @@ -1396,14 +1364,14 @@ } } - //readLayerAbstract(); + // readLayerAbstract(); readLayerProperties(); // readStyle(); // readBoundingBox(); //bounding box should be called before crs!!!!! // readCrs(); // readGeographicBoundingBox(); // readDimension(); - //readAttribution(); + // readAttribution(); val = lastGetMapRequest_->item(style_->requestName()); style_->setCurrentValue(val); @@ -1420,15 +1388,15 @@ buildGetMapRequest(); - //qDebug() << lastGetMapRequest_->request() << "\n" << getMapRequest_->request(); + // qDebug() << lastGetMapRequest_->request() << "\n" << getMapRequest_->request(); } void MvQWmsUiClient::slotReplyPreview(QNetworkReply* reply) { QNetworkRequest r = reply->request(); - QUrl url = r.url(); + QUrl url = r.url(); - //qDebug() << url.toString(); + // qDebug() << url.toString(); GuiLog().task() << "Load preview"; @@ -1441,12 +1409,12 @@ } else { QString outFile = previewFile_; - QByteArray ba = reply->readAll(); + QByteArray ba = reply->readAll(); if (mimeType.isEmpty()) mimeType = getMimeType(ba); - //qDebug() << "preview mimeType" << mimeType; + // qDebug() << "preview mimeType" << mimeType; if (mimeType.contains("application/vnd.ogc.se_xml") || mimeType.contains("text/xml") || @@ -1484,18 +1452,14 @@ } reply->deleteLater(); - previewReply_ = 0; + previewReply_ = nullptr; } void MvQWmsUiClient::slotReplyLegend(QNetworkReply* reply) { - //Here, reply is not necessary the legendReply_ because the - //request might have been redirected!! + // Here, reply is not necessary the legendReply_ because the + // request might have been redirected!! QNetworkRequest r = reply->request(); - QUrl url = r.url(); - - //qDebug() << url.toString(); - QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); GuiLog().task() << "Load legend"; @@ -1507,15 +1471,15 @@ } else { QString outFile = legendFile_; - QByteArray ba = reply->readAll(); + QByteArray ba = reply->readAll(); if (mimeType.isEmpty()) mimeType = getMimeType(ba); - //qDebug() << "mime" << mimeType << getRequestedMimeType(url.toString()); + // qDebug() << "mime" << mimeType << getRequestedMimeType(url.toString()); - //If exception is returned or mime type is - //different to what was requested + // If exception is returned or mime type is + // different to what was requested if (mimeType.contains("application/vnd.ogc.se_xml") || mimeType.contains("text/xml")) // || mimeType != getRequestedMimeType(url.toString())) @@ -1535,7 +1499,7 @@ StatusMsgHandler::instance()->failed(); } else { - //qDebug() << outFile; + // qDebug() << outFile; QFile out(outFile); out.open(QIODevice::WriteOnly); @@ -1548,16 +1512,12 @@ } reply->deleteLater(); - legendReply_ = 0; + legendReply_ = nullptr; } void MvQWmsUiClient::slotReplyLogo(QNetworkReply* reply) { QNetworkRequest r = reply->request(); - QUrl url = r.url(); - - //qDebug() << url.toString(); - QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); GuiLog().task() << "Load logo"; @@ -1569,15 +1529,15 @@ } else { QString outFile = logoFile_; - QByteArray ba = reply->readAll(); + QByteArray ba = reply->readAll(); if (mimeType.isEmpty()) mimeType = getMimeType(ba); - //qDebug() << "mime" << mimeType << getRequestedMimeType(url.toString()); + // qDebug() << "mime" << mimeType << getRequestedMimeType(url.toString()); - //If exception is returned or mime type is - //different to what was requested + // If exception is returned or mime type is + // different to what was requested if (mimeType.contains("application/vnd.ogc.se_xml") || mimeType.contains("text/xml")) // || mimeType != getRequestedMimeType(url.toString())) @@ -1597,7 +1557,7 @@ StatusMsgHandler::instance()->failed(); } else { - //qDebug() << outFile; + // qDebug() << outFile; QFile out(outFile); out.open(QIODevice::WriteOnly); @@ -1615,7 +1575,7 @@ } reply->deleteLater(); - logoReply_ = 0; + logoReply_ = nullptr; } @@ -1637,7 +1597,7 @@ StatusMsgHandler::instance()->failed(); getCapReply_->deleteLater(); - getCapReply_ = 0; + getCapReply_ = nullptr; emit getCapabilityLoaded(); } else if (previewReply_ && previewReply_->isRunning()) { @@ -1646,7 +1606,7 @@ StatusMsgHandler::instance()->failed(); previewReply_->deleteLater(); - previewReply_ = 0; + previewReply_ = nullptr; clearPreview(); emit previewLoaded(previewFile_); } @@ -1656,7 +1616,7 @@ StatusMsgHandler::instance()->failed(); legendReply_->deleteLater(); - legendReply_ = 0; + legendReply_ = nullptr; clearLegend(); emit legendLoaded(legendFile_); } @@ -1666,7 +1626,7 @@ StatusMsgHandler::instance()->failed(); logoReply_->deleteLater(); - logoReply_ = 0; + logoReply_ = nullptr; clearLogo(); emit logoLoaded(logoFile_); } @@ -1688,17 +1648,17 @@ // qDebug() << "root" << docElem.text() << docElem.tagName(); if (docElem.tagName() == "WMS_Capabilities") { auto attr = docElem.attributes(); - result = attr.namedItem("version").toAttr().value(); + result = attr.namedItem("version").toAttr().value(); qDebug() << "VERSION" << result; } else { - //auto lst = docElem.elementsByTagNameNS(defaultNsDeclaration_, "WMS_Capabilities"); + // auto lst = docElem.elementsByTagNameNS(defaultNsDeclaration_, "WMS_Capabilities"); auto lst = docElem.elementsByTagName("WMS_Capabilities"); qDebug() << "readVersion"; if (lst.count() > 0) { auto node = lst.item(0); auto attr = node.attributes(); - result = attr.namedItem("version").toAttr().value(); + result = attr.namedItem("version").toAttr().value(); qDebug() << "VERSION NODE:" << node.nodeName(); } } @@ -1715,7 +1675,7 @@ } buffer.close(); #endif - //Remove linebreak!! + // Remove linebreak!! return result.simplified(); } @@ -1725,7 +1685,7 @@ serviceMeta_.clear(); QDomElement docElem = dom_.documentElement(); - QDomNode n = docElem.firstChild(); + QDomNode n = docElem.firstChild(); while (!n.isNull()) { if (n.nodeName() == "Service") { // qDebug() << "SERVICE found"; @@ -1773,11 +1733,11 @@ MvQXmlQuery query; query.bindVariable("myDoc", &buffer); - //query.setQuery(defaultNsDeclaration_ + "doc($myDoc)//Service/data(Title)"); + // query.setQuery(defaultNsDeclaration_ + "doc($myDoc)//Service/data(Title)"); query.setQuery(defaultNsDeclaration_ + "doc($myDoc)//Service"); query.evaluateTo(&result); - //serviceTitle_=result.simplified(); + // serviceTitle_=result.simplified(); QXmlItem item(result.next()); while (!item.isNull()) { @@ -1823,7 +1783,7 @@ buffer.close(); #endif - //Remove linebreak!! + // Remove linebreak!! } @@ -1882,7 +1842,7 @@ void MvQWmsUiClient::readLayer() { - //Dom + // Dom QDomDocument doc("mydocument"); if (!doc.setContent(capability_, true)) { @@ -1905,7 +1865,7 @@ QDomNode title = dNode.namedItem("Title"); if (!title.isNull()) { - //qDebug() << title.toElement().text().simplified(); + // qDebug() << title.toElement().text().simplified(); layer->setDisplayValue(title.toElement().text().simplified()); } @@ -1960,7 +1920,7 @@ } readStyle(layers); - readBoundingBox(layers); //bounding box should be called before crs!!!!! + readBoundingBox(layers); // bounding box should be called before crs!!!!! readCrs(layers); readGeographicBoundingBox(layers); readDimension(layers); @@ -2013,25 +1973,25 @@ if (item.isNode()) { QString name, title, abstract, legend; - //QXmlQuery query; + // QXmlQuery query; query.setFocus(item); - //Name + // Name query.setQuery(defaultNsDeclaration_ + "./data(Name)"); query.evaluateTo(&name); nameLst << name.simplified(); - //Title + // Title query.setQuery(defaultNsDeclaration_ + "./data(Title)"); query.evaluateTo(&title); titleLst << title.simplified(); - //Abstract + // Abstract query.setQuery(defaultNsDeclaration_ + "./data(Abstract)"); query.evaluateTo(&abstract); abstractLst << abstract.simplified(); - //Legend url + // Legend url query.setQuery(defaultNsDeclaration_ + xlinkNsDeclaration_ + "string(./LegendURL/OnlineResource/@xlink:href)"); query.evaluateTo(&legend); legendLst << legend.simplified(); @@ -2105,7 +2065,7 @@ MvQXmlQuery query; query.bindVariable("myDoc", &buffer); query.bindVariable("myLayer", QVariant(layer_->currentValue())); - //query.bindVariable("myCrsName", QVariant(crsRequestName())); + // query.bindVariable("myCrsName", QVariant(crsRequestName())); if (crsRequestName() == "SRS") { query.setQuery("doc($myDoc)//Layer[normalize-space(Name) = $myLayer]/ancestor-or-self::*/data(SRS)"); } @@ -2164,7 +2124,7 @@ QMap att; DomFinder::attributes(bbElems[i], att); auto* bb = new MvQOgcBoundingBox(att); - //Remove all previously defined (in the ancestors) bboxes + // Remove all previously defined (in the ancestors) bboxes foreach (MvQOgcBoundingBox* bitem, bbox_) { if (bitem->crs() == bb->crs()) { bbox_.removeOne(bitem); @@ -2197,7 +2157,7 @@ MvQOgcBoundingBox* bb = new MvQOgcBoundingBox(att); - //Remove all previously defined (in the ancestors) bboxes + // Remove all previously defined (in the ancestors) bboxes foreach (MvQOgcBoundingBox* bitem, bbox_) { if (bitem->crs() == bb->crs()) { bbox_.removeOne(bitem); @@ -2208,7 +2168,7 @@ bbox_.push_back(bb); - //qDebug() << "bb" << bb->crs() << bb->minX() << bb->maxX(); + // qDebug() << "bb" << bb->crs() << bb->minX() << bb->maxX(); } item = result.next(); } @@ -2237,7 +2197,7 @@ if (geographicBbox_) { delete geographicBbox_; } - geographicBbox_ = new MvQOgcGeoBoundingBox(att); //new MvQXmlElementNode(query,item); + geographicBbox_ = new MvQOgcGeoBoundingBox(att); // new MvQXmlElementNode(query,item); return; } } @@ -2249,7 +2209,7 @@ if (geographicBbox_) { delete geographicBbox_; } - geographicBbox_ = new MvQOgcGeoBoundingBox(att); //new MvQXmlElementNode(query,item); + geographicBbox_ = new MvQOgcGeoBoundingBox(att); // new MvQXmlElementNode(query,item); return; } } @@ -2278,7 +2238,7 @@ if (item.isNode()) { QString val; - //QXmlQuery query; + // QXmlQuery query; query.setFocus(item); query.setQuery(defaultNsDeclaration_ + "./data(westBoundLongitude)"); @@ -2300,7 +2260,7 @@ if (geographicBbox_) { delete geographicBbox_; } - geographicBbox_ = new MvQOgcGeoBoundingBox(att); //new MvQXmlElementNode(query,item); + geographicBbox_ = new MvQOgcGeoBoundingBox(att); // new MvQXmlElementNode(query,item); break; } @@ -2320,7 +2280,7 @@ if (geographicBbox_) { delete geographicBbox_; } - geographicBbox_ = new MvQOgcGeoBoundingBox(att); //new MvQXmlElementNode(query,item); + geographicBbox_ = new MvQOgcGeoBoundingBox(att); // new MvQXmlElementNode(query,item); break; } item = result.next(); @@ -2357,8 +2317,8 @@ } else { QString dname = dim->name(); - dname = dname.toUpper(); - dname = "DIM_" + dname; + dname = dname.toUpper(); + dname = "DIM_" + dname; dim->setRequestName(dname); dname += " :"; dim->setDisplayName(dname); @@ -2430,8 +2390,8 @@ } else { QString dname = dim->name(); - dname = dname.toUpper(); - dname = "DIM_" + dname; + dname = dname.toUpper(); + dname = "DIM_" + dname; dim->setRequestName(dname); dname += " :"; dim->setDisplayName(dname); @@ -2457,7 +2417,7 @@ query.getAttributes(item, att); query.getAtomicValue(item, value); - //MvQXmlElementNode *elem=new MvQXmlElementNode(query,item); + // MvQXmlElementNode *elem=new MvQXmlElementNode(query,item); foreach (MvQOgcDimension* dim, dimension_) { if (dim->name() == att["name"]) { dim->setAttributes(att); @@ -2506,10 +2466,10 @@ if (item.isNode()) { QString logo; - //QXmlQuery query; + // QXmlQuery query; query.setFocus(item); - //Logo url + // Logo url query.setQuery(defaultNsDeclaration_ + xlinkNsDeclaration_ + "string(./LogoURL/OnlineResource/@xlink:href)"); query.evaluateTo(&logo); layerNode->setLogo(logo.simplified()); @@ -2522,7 +2482,7 @@ void MvQWmsUiClient::readException(QByteArray ba, QString& msg) { - //if(xmlMsg.isEmpty()) + // if(xmlMsg.isEmpty()) // return; QDomDocument doc; @@ -2556,7 +2516,7 @@ #if OLD_XML QXmlResultItems result; - //QByteArray ba=xmlMsg.toUtf8(); + // QByteArray ba=xmlMsg.toUtf8(); QBuffer buffer(&ba); // This is a QIODevice. buffer.open(QIODevice::ReadOnly); @@ -2596,7 +2556,7 @@ item = result.next(); } - //If XML parsing failed + // If XML parsing failed #if 0 if (queryMsgHandler_->fatalFound()) { msg += "Exception: parsing of exception document failed!!\n"; @@ -2618,50 +2578,49 @@ getMapRequest_->clear(); - QString s; QString str = url_; str += "?SERVICE=WMS"; - //Version + // Version /*if(version_ != "Default") - { - str+="&VERSION="; - str+=version_; - }*/ + { + str+="&VERSION="; + str+=version_; + }*/ str += "&VERSION="; str += repliedVersion_; - //Request + // Request str += "&REQUEST=GetMap"; - //Layers + // Layers str += "&" + layer_->requestName() + "=" + layer_->currentValue(); - //Style + // Style str += "&" + style_->requestName() + "=" + style_->currentValue(); - //srs or crs + // srs or crs str += "&" + crs_->requestName() + "=" + crs_->currentValue(); - //bbox + // bbox str += "&BBOX=" + requestBbox_->minX() + "," + requestBbox_->minY() + "," + requestBbox_->maxX() + "," + requestBbox_->maxY(); - //width + // width str += "&WIDTH=" + QString::number(width_->value()); str += "&HEIGHT=" + QString::number(height_->value()); - //Format + // Format str += "&" + format_->requestName() + "=" + format_->currentValue(); - //Transparent + // Transparent str += "&" + transparent_->requestName() + "=" + transparent_->currentValue(); - //Dimensions + // Dimensions foreach (MvQOgcDimension* dim, dimension_) { str += "&"; str += dim->requestName(); @@ -2677,13 +2636,13 @@ currentGetMapRequest_ = getMapRequest_; - //qDebug() << getMapRequest_->requestFrame(); + // qDebug() << getMapRequest_->requestFrame(); - //str+="&stream=false"; + // str+="&stream=false"; - //getMapRequest_=str; + // getMapRequest_=str; - //saveGetMapRequest(currentGetMapRequest_); + // saveGetMapRequest(currentGetMapRequest_); emit getMapRequestChanged(getMapRequest_->request(), getMapRequest_->requestFrame()); } @@ -2695,7 +2654,7 @@ // //=========================================== -//Format +// Format QStringList MvQWmsUiClient::formatDisplayValues() const { return format_->displayValues(); @@ -2714,7 +2673,7 @@ } } -//Transparent +// Transparent QStringList MvQWmsUiClient::transparentDisplayValues() const { return transparent_->displayValues(); @@ -2733,7 +2692,7 @@ } } -//Width +// Width QString MvQWmsUiClient::width() const { return QString::number(width_->value()); @@ -2747,7 +2706,7 @@ } } -//Height +// Height QString MvQWmsUiClient::height() const { return QString::number(height_->value()); @@ -2761,7 +2720,7 @@ } } -//Extra par +// Extra par void MvQWmsUiClient::setExtraGetCapPar(QString value) { if (extraGetCapPar_ != value) { @@ -2777,7 +2736,7 @@ } } -//Style +// Style QStringList MvQWmsUiClient::styleDisplayValues() const { return style_->displayValues(); @@ -2802,7 +2761,7 @@ } -//CRS +// CRS QStringList MvQWmsUiClient::crsDisplayValues() const { return crs_->displayValues(); @@ -2823,24 +2782,24 @@ } } -//Layer +// Layer int MvQWmsUiClient::layerCurrentIndex() { return 0; - //return layer_->values().indexOf(layer_->currentValue()); + // return layer_->values().indexOf(layer_->currentValue()); } QStringList MvQWmsUiClient::layerDisplayValues() const { - return QStringList(); - //return layer_->displayValues(); + return {}; + // return layer_->displayValues(); } QStringList MvQWmsUiClient::layerDescriptions() const { - return QStringList(); - //qDebug() << layer_->descriptions(); - //return layer_->descriptions(); + return {}; + // qDebug() << layer_->descriptions(); + // return layer_->descriptions(); } void MvQWmsUiClient::setLayerFromDpy(MvQOgcNode* node) @@ -2857,7 +2816,7 @@ } -//BBOX +// BBOX void MvQWmsUiClient::setBoundingBoxFromDpy(QString minX, QString maxX, QString minY, QString maxY) { slotAbortDownloadProcess(); @@ -2868,7 +2827,7 @@ MvQOgcBoundingBox MvQWmsUiClient::lastBoundingBox() const { QString lastValue = lastGetMapRequest_->item("BBOX"); - QStringList lst = lastValue.split(","); + QStringList lst = lastValue.split(","); MvQOgcBoundingBox bb; if (lst.count() == 4) { bb.setArea(lst[0], lst[2], lst[1], lst[3]); @@ -2884,17 +2843,17 @@ } } - return 0; + return nullptr; } -//Dimensions +// Dimensions QStringList MvQWmsUiClient::dimensionNameToDpy() const { QStringList lst; /*foreach(MvQOgcDimensionList *dim,dimension_) - { - lst << dim->displayName(); - }*/ + { + lst << dim->displayName(); + }*/ return lst; } @@ -2902,14 +2861,14 @@ QStringList MvQWmsUiClient::dimensionToDpy(QString /*dimDpyName*/) const { /*foreach(MvQOgcDimensionList *dim,dimension_) - { - if(dim->displayName() == dimDpyName) - { - return dim->displayValues(); - } - }*/ + { + if(dim->displayName() == dimDpyName) + { + return dim->displayValues(); + } + }*/ - return QStringList(); + return {}; } void MvQWmsUiClient::setDimensionFromDpy(QString dimDpyName, QString val) @@ -2918,7 +2877,7 @@ foreach (MvQOgcDimension* dim, dimension_) { if (dim->displayName() == dimDpyName) { - //dim->setCurrentDisplayValue(val); + // dim->setCurrentDisplayValue(val); dim->setCurrentValues(val); buildGetMapRequest(); return; @@ -2929,44 +2888,44 @@ void MvQWmsUiClient::setDimensionFromDpy(QString /*dimDpyName*/, QStringList /*val*/) { /*foreach(MvQOgcDimensionList *dim,dimension_) - { - if(dim->displayName() == dimDpyName) - { - //dim->setCurrentDisplayValues(val); - setCurrentValues(val); - buildGetMapRequest(); - return; - } - }*/ + { + if(dim->displayName() == dimDpyName) + { + //dim->setCurrentDisplayValues(val); + setCurrentValues(val); + buildGetMapRequest(); + return; + } + }*/ } QString MvQWmsUiClient::crsQueryName() { if (repliedVersion_ < QString("1.3.0")) { - return QString("SRS"); + return {"SRS"}; } else { - return QString("CRS"); + return {"CRS"}; } } QString MvQWmsUiClient::crsRequestName() { if (repliedVersion_ < QString("1.3.0")) { - return QString("SRS"); + return {"SRS"}; } else { - return QString("CRS"); + return {"CRS"}; } } QString MvQWmsUiClient::crsDisplayName() { if (repliedVersion_ < QString("1.3.0")) { - return QString("SRS:"); + return {"SRS:"}; } else { - return QString("CRS:"); + return {"CRS:"}; } } @@ -2984,28 +2943,28 @@ void MvQWmsUiClient::clearPreview() { - //if(previewFile_ != emptyFileNameString_) + // if(previewFile_ != emptyFileNameString_) //{ QFile f(previewFile_); if (!f.remove()) { - //qDebug() << "MvQZoomStackLevel::clearPreview() ---> Preview file" << imgFileName_ << "could not be deleted!"; + // qDebug() << "MvQZoomStackLevel::clearPreview() ---> Preview file" << imgFileName_ << "could not be deleted!"; } - //previewFile_ = emptyFileNameString_; - //} + // previewFile_ = emptyFileNameString_; + // } } void MvQWmsUiClient::clearLegend() { - //if(previewFile_ != emptyFileNameString_) + // if(previewFile_ != emptyFileNameString_) //{ QFile f(legendFile_); if (!f.remove()) { - //qDebug() << "MvQZoomStackLevel::clearPreview() ---> Preview file" << imgFileName_ << "could not be deleted!"; + // qDebug() << "MvQZoomStackLevel::clearPreview() ---> Preview file" << imgFileName_ << "could not be deleted!"; } - //previewFile_ = emptyFileNameString_; - //} + // previewFile_ = emptyFileNameString_; + // } } void MvQWmsUiClient::clearLogo() @@ -3022,8 +2981,8 @@ requestBbox_->clear(); bool foundBb = false; - //Check if bbox is available for the current crs. - //It is mandatory from 1.3.0 !!! + // Check if bbox is available for the current crs. + // It is mandatory from 1.3.0 !!! foreach (MvQOgcBoundingBox* bb, bbox_) { if (bb->crs() == crs_->currentValue()) { foundBb = true; @@ -3032,8 +2991,8 @@ } } - if (!foundBb && geographicBbox_ != 0) { - //For 1.3.0 epsg:4326 lat is x and lon is y!!!!! + if (!foundBb && geographicBbox_ != nullptr) { + // For 1.3.0 epsg:4326 lat is x and lon is y!!!!! if (repliedVersion_ >= "1.3.0") { if (crs_->currentValue() == "EPSG:4326") { requestBbox_->setArea(geographicBbox_->minY(), @@ -3053,7 +3012,7 @@ } } else { - //Else for older versions lat-lon we try to use the geographic bounding box + // Else for older versions lat-lon we try to use the geographic bounding box requestBbox_->setArea(geographicBbox_->minX(), geographicBbox_->maxX(), geographicBbox_->minY(), @@ -3063,8 +3022,8 @@ } } - //For special non-geographical projections where no crs is defined (e.g. cross-section) - if (!foundBb && crs_->currentValue().isEmpty() && geographicBbox_ != 0) { + // For special non-geographical projections where no crs is defined (e.g. cross-section) + if (!foundBb && crs_->currentValue().isEmpty() && geographicBbox_ != nullptr) { requestBbox_->setArea(geographicBbox_->minX(), geographicBbox_->maxX(), geographicBbox_->minY(), diff -Nru metview-5.17.4/metview/src/OgcClient/MvQWmsClientEditor.cc metview-5.19.2/metview/src/OgcClient/MvQWmsClientEditor.cc --- metview-5.17.4/metview/src/OgcClient/MvQWmsClientEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQWmsClientEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -69,7 +69,7 @@ row_ = parentRow; parentLayout->addWidget(label_, row_, 0); - //Expand + // Expand expandTb_ = new QToolButton(); QIcon ic; ic.addPixmap(QPixmap(":/OgcClient/expand_left.svg"), QIcon::Normal, QIcon::On); @@ -78,33 +78,33 @@ expandTb_->setMaximumSize(QSize(16, 16)); expandTb_->setCheckable(true); expandTb_->setChecked(false); - //expandTb_->setAutoRaise(true); + // expandTb_->setAutoRaise(true); expandTb_->setToolTip(tr("View value list")); parentLayout->addWidget(expandTb_, row_, 1); - //LinEdit + // LinEdit lineEdit_ = new QLineEdit(); lineEdit_->setText(text); #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) lineEdit_->setClearButtonEnabled(true); #endif - //nameLabel_->setBuddy(lineEdit_); + // nameLabel_->setBuddy(lineEdit_); parentLayout->addWidget(lineEdit_, row_, 2); - //Get values - //QStringList values_=dim->displayValues(); + // Get values + // QStringList values_=dim->displayValues(); QStringList values_ = dim->values(); list_ = new QListWidget(); list_->setVisible(false); - //Populate the list + // Populate the list foreach (QString str, values_) { new QListWidgetItem(str, list_); - //item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - //item->setCheckState(Qt::Unchecked); + // item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + // item->setCheckState(Qt::Unchecked); } parentLayout->addWidget(list_, row_ + 1, 2); @@ -116,7 +116,7 @@ this, SLOT(slotAddItem(QListWidgetItem*))); /*connect(list_,SIGNAL(itemPressed(QListWidgetItem*)), - this,SLOT(slotAddItem(QListWidgetItem*)));*/ + this,SLOT(slotAddItem(QListWidgetItem*)));*/ connect(list_, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotListItemChanged(QListWidgetItem*))); @@ -173,9 +173,9 @@ text += item->data(Qt::DisplayRole).toString(); } else { - QString itemText = item->data(Qt::DisplayRole).toString(); + QString itemText = item->data(Qt::DisplayRole).toString(); QStringList textList = text.split("/"); - int itemIndex = textList.indexOf(itemText); + int itemIndex = textList.indexOf(itemText); QString newText; for (int i = 0; i < textList.count(); i++) { @@ -195,8 +195,8 @@ void MvQWmsDimensionGuiItem::addValue(QString value) { new QListWidgetItem(value, list_); - //item->setFlags(Qt::ItemIsSelectable |Qt::ItemIsEnabled); - //item->setCheckState(Qt::Unchecked); + // item->setFlags(Qt::ItemIsSelectable |Qt::ItemIsEnabled); + // item->setCheckState(Qt::Unchecked); } QString MvQWmsDimensionGuiItem::currentValue() @@ -214,14 +214,14 @@ MvQWmsClientEditor::MvQWmsClientEditor(MvQWmsUiClient* client, QWidget* parent) : MvQMainWindow(parent) { - //Window setup + // Window setup QString iconName; QStringList lst = client->iconFile().split("/"); if (lst.count() > 0) { iconName = lst.last(); } - //Initial size + // Initial size setInitialSize(1100, 800); setAttribute(Qt::WA_DeleteOnClose); @@ -230,18 +230,18 @@ client_ = client; - //ClientModeMap - clientModeMap_["Plain"] = MvQWmsUiClient::BasicMode; + // ClientModeMap + clientModeMap_["Plain"] = MvQWmsUiClient::BasicMode; clientModeMap_["Interactive"] = MvQWmsUiClient::AdvancedMode; - //Main layout + // Main layout mainLayout_ = new QVBoxLayout; mainLayout_->setContentsMargins(1, 1, 1, 1); auto* w = new QWidget(this); w->setLayout(mainLayout_); setCentralWidget(w); - //Main splitter + // Main splitter mainSplitter_ = new QSplitter(this); mainSplitter_->setOrientation(Qt::Vertical); mainSplitter_->setOpaqueResize(false); @@ -255,15 +255,15 @@ requestSplitter_->setOpaqueResize(false); mainSplitter_->addWidget(requestSplitter_); - //Request left layout - layerPanel_ = new QWidget(this); + // Request left layout + layerPanel_ = new QWidget(this); auto* requestLeftLayout = new QVBoxLayout; requestLeftLayout->setContentsMargins(1, 1, 1, 1); requestLeftLayout->setSpacing(1); layerPanel_->setLayout(requestLeftLayout); requestSplitter_->addWidget(layerPanel_); - //Request right layout + // Request right layout layerInfoTab_ = new QTabWidget(this); requestSplitter_->addWidget(layerInfoTab_); @@ -283,11 +283,11 @@ // Bottom part with buttons //--------------------------------------- - //Buttons + // Buttons auto* hb = new QHBoxLayout; mainLayout_->addLayout(hb); - auto* labelMode = new QLabel(tr("Mode:"), this); + auto* labelMode = new QLabel(tr("Mode:"), this); clientModeCombo_ = new QComboBox(this); clientModeCombo_->addItem("Plain"); clientModeCombo_->addItem("Interactive"); @@ -308,8 +308,8 @@ buttonBox_ = new QDialogButtonBox(this); - savePb_ = buttonBox_->addButton(QDialogButtonBox::Save); - okPb_ = buttonBox_->addButton(QDialogButtonBox::Ok); + savePb_ = buttonBox_->addButton(QDialogButtonBox::Save); + okPb_ = buttonBox_->addButton(QDialogButtonBox::Ok); cancelPb_ = buttonBox_->addButton(QDialogButtonBox::Cancel); savePb_->setDefault(true); @@ -328,7 +328,7 @@ //------------------- loadProgress_ = new QProgressBar(this); - //loadProgress_->setRange(0,0); + // loadProgress_->setRange(0,0); statusBar()->addPermanentWidget(loadProgress_); loadProgress_->hide(); @@ -342,7 +342,7 @@ // Init //------------- - //actions + // actions setupFileActions(); setupViewActions(); setupSettingsActions(); @@ -356,7 +356,7 @@ insertToolBarBreak(tb); } - //Request panel + // Request panel setupLayerPanel(requestLeftLayout); setupLayerInfoTab(); @@ -371,8 +371,8 @@ connect(client_, SIGNAL(clientResetDone()), this, SLOT(slotClientReset())); - //Initialise the current mode --> call loadGetCapabilities - //This must come last!!! + // Initialise the current mode --> call loadGetCapabilities + // This must come last!!! initClientMode(); // @@ -392,7 +392,7 @@ actionImport->setText(tr("&Import")); actionImport->setToolTip(tr("Import request")); - //Define routines + // Define routines connect(actionImport, SIGNAL(activated()), this, SLOT(slotImportRequest())); @@ -418,10 +418,10 @@ icon2.addPixmap(QPixmap(QString::fromUtf8(":/examiner/log.svg")), QIcon::Normal, QIcon::Off); actionLog_->setIcon(icon2); - //logPanel connects up logAction and manages it + // logPanel connects up logAction and manages it logPanel_->setViewAction(actionLog_); - //Log is hidden by default!!! + // Log is hidden by default!!! actionLog_->setChecked(false); auto* actionSeparator = new QAction(this); @@ -448,14 +448,14 @@ urlCombo_ = new QComboBox(this); urlCombo_->setEditable(true); urlCombo_->setMinimumContentsLength(20); - //urlCombo_->setMaxCount(20); + // urlCombo_->setMaxCount(20); QSizePolicy p = urlCombo_->sizePolicy(); urlCombo_->setSizePolicy(QSizePolicy::Expanding, p.verticalPolicy()); urlCombo_->setInsertPolicy(QComboBox::InsertAtTop); urlCombo_->setMaximumWidth(700); advancedModeOnlyWidgets_ << urlCombo_; - //Server version combo + // Server version combo auto* labelVersion = new QLabel(tr(" Version:"), this); advancedModeOnlyWidgets_ << labelVersion; versionCombo_ = new QComboBox(this); @@ -472,7 +472,7 @@ //---> Init - //Init url and version combos + // Init url and version combos if (!client_->url().isEmpty()) { urlCombo_->insertItem(0, client_->url()); urlCombo_->setCurrentIndex(0); @@ -511,21 +511,19 @@ //-------------------- auto* labelFormat = new QLabel(tr("Format:"), this); - formatCombo_ = new QComboBox(this); + formatCombo_ = new QComboBox(this); formatCombo_->setSizeAdjustPolicy(QComboBox::AdjustToContents); - //Extra getcap + // Extra getcap auto* labelGetCap = new QLabel(tr(" Extra getCap param:"), this); - extraGetCapEdit_ = new QLineEdit("", this); + extraGetCapEdit_ = new QLineEdit("", this); - //Extra getmap + // Extra getmap auto* labelGetMap = new QLabel(tr(" Extra getMap param:"), this); - extraGetMapEdit_ = new QLineEdit("", this); + extraGetMapEdit_ = new QLineEdit("", this); - QString mName = "Format"; - - //Put this toolbar into another line!!! - //addToolBarBreak(Qt::TopToolBarArea); + // Put this toolbar into another line!!! + // addToolBarBreak(Qt::TopToolBarArea); MvQMainWindow::MenuType menuType = MvQMainWindow::SettingsMenu; @@ -536,7 +534,7 @@ menuItems_[menuType].push_back(new MvQMenuItem(labelGetMap, MvQMenuItem::ToolBarTarget)); menuItems_[menuType].push_back(new MvQMenuItem(extraGetMapEdit_, MvQMenuItem::ToolBarTarget)); - //These are independent from getCapabilities + // These are independent from getCapabilities initExtraParEdit(); connect(formatCombo_, SIGNAL(activated(QString)), @@ -552,12 +550,12 @@ void MvQWmsClientEditor::setupLayerPanel(QVBoxLayout* layout) { - QLabel* label; + QLabel* label = nullptr; int row = 0; layerParamRowNum_ = 0; - //Tab + // Tab layerTab_ = new QTabWidget(this); layout->addWidget(layerTab_); @@ -569,7 +567,7 @@ layerTree_->setAlternatingRowColors(true); layerTree_->setUniformRowHeights(true); - //layerSplitter_->addWidget(layerTree_); + // layerSplitter_->addWidget(layerTree_); layerModel_ = new MvQOgcTreeModel(this); layerTree_->setModel(layerModel_); @@ -589,7 +587,7 @@ auto* scroll = new QScrollArea(this); layerTab_->addTab(scroll, tr("Layer settings")); - auto* w = new QWidget(this); + auto* w = new QWidget(this); layerGrid_ = new QGridLayout; layerGrid_->setSizeConstraint(QLayout::SetMinAndMaxSize); w->setLayout(layerGrid_); @@ -597,7 +595,7 @@ scroll->setWidgetResizable(true); scroll->setWidget(w); - label = new QLabel("Styles:", this); + label = new QLabel("Styles:", this); styleCombo_ = new QComboBox(this); layerGrid_->addWidget(label, row, 0); layerGrid_->addWidget(styleCombo_, row, 2); @@ -612,8 +610,8 @@ layerParamRowNum_ = row; - //layerGrid_->setColumnStretch(1,1); - //layerGrid_->setRowStretch(row,1); + // layerGrid_->setColumnStretch(1,1); + // layerGrid_->setRowStretch(row,1); connect(crsCombo_, SIGNAL(activated(QString)), this, SLOT(slotSelectCrs(QString))); @@ -622,7 +620,7 @@ this, SLOT(slotSelectStyle(int))); - //Preview pb + // Preview pb previewPb_ = new QPushButton(tr("Generate preview"), this); layout->addWidget(previewPb_); @@ -632,13 +630,13 @@ void MvQWmsClientEditor::setupLayerInfoTab() { - QLabel* label; - QWidget* w; + QLabel* label = nullptr; + QWidget* w = nullptr; //-------------------------- // Layer preview tab //-------------------------- - w = new QWidget(this); + w = new QWidget(this); auto previewLayout = new QVBoxLayout(w); previewLayout->setContentsMargins(0, 2, 0, 0); previewLayout->setSpacing(0); @@ -670,7 +668,7 @@ reqSplitter_ = new QSplitter(this); layerInfoTab_->addTab(reqSplitter_, tr("GetMap request")); - reqEditPanel_ = new QWidget(this); + reqEditPanel_ = new QWidget(this); auto* reqEditLayout = new QVBoxLayout; reqEditPanel_->setLayout(reqEditLayout); reqSplitter_->addWidget(reqEditPanel_); @@ -689,7 +687,7 @@ // --> Request display //--------------------------------------- - w = new QWidget(this); + w = new QWidget(this); auto mapInfoLayout = new QVBoxLayout; mapInfoLayout->setContentsMargins(0, 2, 0, 0); mapInfoLayout->setSpacing(0); @@ -704,8 +702,8 @@ getMapInfoSplit_ = new QTextBrowser(this); getMapInfoSplit_->setReadOnly(true); getMapInfoSplit_->document()->setDefaultStyleSheet(MvQTheme::htmlTableCss()); - //getMapInfoSplit_->setLineWrapMode(QTextEdit::NoWrap); - //reqSplitter_->addWidget(reqGrid_); + // getMapInfoSplit_->setLineWrapMode(QTextEdit::NoWrap); + // reqSplitter_->addWidget(reqGrid_); mapInfoLayout->addWidget(getMapInfoSplit_, 1); new DocHighlighter(getMapInfoSplit_->document(), "getMap"); @@ -727,20 +725,20 @@ plainPreviewLabel_ = new QLabel(this); plainPreviewLabel_->setFrameStyle(QFrame::Box | QFrame::Plain); - //plainPreviewLabel_->setFixedSize(QSize(256,128)); + // plainPreviewLabel_->setFixedSize(QSize(256,128)); plainPreviewLabel_->setFixedWidth(260); plainPreviewLabel_->setMinimumHeight(128); plainPreviewLabel_->setAutoFillBackground(true); QPalette pal = plainPreviewLabel_->palette(); - //QColor col=pal.color(QPalette::Window).lighter(120); + // QColor col=pal.color(QPalette::Window).lighter(120); pal.setColor(QPalette::Window, Qt::white); plainPreviewLabel_->setPalette(pal); plainPreLayout->addWidget(plainPreviewLabel_); plainPreviewPb_ = new QPushButton(tr("Generate preview"), this); - //plainPreLayout->addWidget(plainPreviewPb_); + // plainPreLayout->addWidget(plainPreviewPb_); reqEditLayout->addWidget(plainPreviewPb_); plainPreviewPanel_->hide(); @@ -774,7 +772,7 @@ // Service meta-data tab //-------------------------- - w = new QWidget(this); + w = new QWidget(this); auto serviceLayout = new QVBoxLayout; serviceLayout->setContentsMargins(0, 2, 0, 0); serviceLayout->setSpacing(0); @@ -793,16 +791,16 @@ if (reqEditSa_->widget()) return; - auto* w = new QWidget(this); + auto* w = new QWidget(this); auto* reqGrid = new QGridLayout; reqGrid->setSizeConstraint(QLayout::SetMinAndMaxSize); w->setLayout(reqGrid); reqEditSa_->setWidget(w); - QLabel* label; - QLineEdit* le; - QTextEdit* te; + QLabel* label = nullptr; + QLineEdit* le = nullptr; + QTextEdit* te = nullptr; auto* sigMapper = new QSignalMapper(this); QStringList labelText, key; @@ -827,9 +825,9 @@ int row = 0; for (int i = 0; i < labelText.count(); i++) { - label = new QLabel(labelText[i], this); + label = new QLabel(labelText[i], this); reqLe_[key[i]] = new QLineEdit(this); - le = reqLe_[key[i]]; + le = reqLe_[key[i]]; reqGrid->addWidget(label, row, 0); reqGrid->addWidget(le, row, 1); @@ -847,9 +845,9 @@ key << tr("mv_key_tdim") << tr("mv_key_otherdim"); for (int i = 0; i < labelText.count(); i++) { - label = new QLabel(labelText[i], this); + label = new QLabel(labelText[i], this); reqTe_[key[i]] = new QTextEdit(this); - te = reqTe_[key[i]]; + te = reqTe_[key[i]]; reqGrid->addWidget(label, row, 0); reqGrid->addWidget(te, row, 1); @@ -898,7 +896,7 @@ void MvQWmsClientEditor::clearLayerDependentData() { layerModel_->dataIsAboutToChange(); - layerModel_->setRootNode(0); + layerModel_->setRootNode(nullptr); styleCombo_->clear(); crsCombo_->clear(); @@ -908,12 +906,12 @@ void MvQWmsClientEditor::clearDimension() { - int row = layerParamRowNum_; //layerGrid_->rowCount(); - row = row - 1; + int row = layerParamRowNum_; // layerGrid_->rowCount(); + row = row - 1; - //Remove previous dimension widgets from the grid + // Remove previous dimension widgets from the grid for (int i = 0; i < dimensionNum_; i++) { - QWidget* w; + QWidget* w = nullptr; w = layerGrid_->itemAtPosition(row, 2)->widget(); layerGrid_->removeWidget(w); @@ -958,7 +956,7 @@ } QString cv = client_->formatCurrentDisplayValue(); - int index = -1; + int index = -1; if (!cv.isEmpty()) { index = values.indexOf(cv); } @@ -992,7 +990,7 @@ layerTree_->setCurrentIndex(layerModel_->indexFromNode(client_->layer()->currentNode())); - //Try to expand the first child of the root node + // Try to expand the first child of the root node if (layerModel_->rowCount(QModelIndex()) > 0) { QModelIndex index = layerModel_->index(0, 0, QModelIndex()); layerTree_->expand(index); @@ -1004,7 +1002,7 @@ styleCombo_->clear(); QStringList values = client_->styleDisplayValues(); - QStringList desc = client_->styleDescriptions(); + QStringList desc = client_->styleDescriptions(); int i = 0; foreach (QString str, values) { @@ -1040,7 +1038,7 @@ } QString cv = client_->crsCurrentDisplayValue(); - int index = -1; + int index = -1; if (!cv.isEmpty()) { index = values.indexOf(cv); @@ -1070,7 +1068,7 @@ foreach (MvQOgcDimension* dim, client_->dimension()) { QString name = dim->displayName(); - dim_[name] = new MvQWmsDimensionGuiItem(dim, dim->currentValues(), layerGrid_, layerParamRowNum_); + dim_[name] = new MvQWmsDimensionGuiItem(dim, dim->currentValues(), layerGrid_, layerParamRowNum_); connect(dim_[name], SIGNAL(textChanged(MvQOgcDimension*, QString)), this, SLOT(slotDimensionChanged(MvQOgcDimension*, QString))); @@ -1087,7 +1085,7 @@ // //------------------------------------------ /*! - Replaces the URL combobox's curret text with the given url and runs getCapabilities. + Replaces the URL combobox's curret text with the given url and runs getCapabilities. */ void MvQWmsClientEditor::slotSelectUrl(const QString& url) { @@ -1098,12 +1096,12 @@ /*! Removes duplicates from the URL combobox and trims down the its size to a predefined number. This method should be called - whenever a new item is inserted into the combo box. + whenever a new item is inserted into the combo box. */ void MvQWmsClientEditor::checkUrlComboItems() { - //Duplicates are removed first! + // Duplicates are removed first! QMap cntMap; for (int i = 0; i < urlCombo_->count(); i++) { QString s = urlCombo_->itemText(i); @@ -1115,16 +1113,16 @@ } } - //qDebug() << cntMap; + // qDebug() << cntMap; foreach (QString s, cntMap.keys()) { int itemCnt = cntMap[s]; if (itemCnt > 1) { for (int i = urlCombo_->count() - 1; i >= 0 && itemCnt > 1; i--) { if (urlCombo_->itemText(i) == s) { - //qDebug() << "remove" << i << urlCombo_->currentIndex() << urlCombo_->itemText(i) << urlCombo_->currentText(); + // qDebug() << "remove" << i << urlCombo_->currentIndex() << urlCombo_->itemText(i) << urlCombo_->currentText(); urlCombo_->removeItem(i); - //qDebug() << urlCombo_->currentText(); + // qDebug() << urlCombo_->currentText(); itemCnt--; } } @@ -1132,10 +1130,10 @@ } - //for(int i=0; i < urlCombo_->count(); i++) + // for(int i=0; i < urlCombo_->count(); i++) // qDebug() << "after" << urlCombo_->itemText(i); - //Trim down the combo size to maxCount + // Trim down the combo size to maxCount int maxCount = 25; for (int i = urlCombo_->count() - 1; i > maxCount; i--) { urlCombo_->removeItem(i); @@ -1152,8 +1150,8 @@ void MvQWmsClientEditor::slotRunGetCapabilities() { - //Check if the URL combobox's current text was - //inserted into URL combobox. + // Check if the URL combobox's current text was + // inserted into URL combobox. client_->setUrl(urlCombo_->currentText(), versionCombo_->currentText()); clearServerDependentData(); @@ -1164,7 +1162,7 @@ } layerModel_->dataIsAboutToChange(); - layerModel_->setRootNode(0); + layerModel_->setRootNode(nullptr); requestSplitter_->setEnabled(false); @@ -1202,25 +1200,25 @@ loadFinished(); - //slotPreviewLoaded(QString()); + // slotPreviewLoaded(QString()); getCapInfo_->editor()->setPlainText(client_->getCapabilityDoc()); slotUpdateServiceInfo(); - //serviceInfo_->setPlainText(client_->serviceTitle()); + // serviceInfo_->setPlainText(client_->serviceTitle()); - //loadFinished(); + // loadFinished(); slotUpdateLayerInfo(); loadStarted(); client_->downloadLogo(); if (urlCombo_->findText(urlCombo_->currentText()) == -1) { - //for(int i=0; i < urlCombo_->count(); i++) + // for(int i=0; i < urlCombo_->count(); i++) // qDebug() << urlCombo_->itemText(i) // urlCombo_->currentText(); - disconnect(urlCombo_, SIGNAL(activated(QString)), 0, 0); + disconnect(urlCombo_, SIGNAL(activated(QString)), nullptr, nullptr); urlCombo_->insertItem(0, urlCombo_->currentText()); urlCombo_->setCurrentIndex(0); connect(urlCombo_, SIGNAL(activated(QString)), @@ -1228,7 +1226,7 @@ // urlCombo_->currentText(); checkUrlComboItems(); - //qDebug() << urlCombo_->currentText(); + // qDebug() << urlCombo_->currentText(); } else { checkUrlComboItems(); @@ -1245,7 +1243,7 @@ initCrsCombo(); setupDimension(); - //slotPreviewLoaded(QString()); + // slotPreviewLoaded(QString()); slotUpdateLayerInfo(); loadStarted(); @@ -1339,14 +1337,14 @@ s += "Style" + styleCombo_->currentText() + ""; /*s+="Dimensions"; - QMapIterator it(dim_); - s+=""; - while (it.hasNext()) - { - it.next(); - s+=it.key() + " = " + it.value()->currentValue() + "
"; - } - s+="";*/ + QMapIterator it(dim_); + s+=""; + while (it.hasNext()) + { + it.next(); + s+=it.key() + " = " + it.value()->currentValue() + "
"; + } + s+="";*/ s += "Preview"; s += "Preview not loaded"; @@ -1434,7 +1432,6 @@ { QString s; if (!req.isEmpty()) { - QString getMaps; s = ""; s += ""; @@ -1484,7 +1481,7 @@ else { initExtraParEdit(); - //Init url + // Init url if (client_->url().isEmpty() || urlCombo_->itemText(0) != client_->url()) { urlCombo_->insertItem(0, client_->url()); urlCombo_->setCurrentIndex(0); @@ -1497,7 +1494,7 @@ void MvQWmsClientEditor::initClientMode() { if (client_->clientMode() == MvQWmsUiClient::BasicMode) { - //Toolbar + menubar + log + // Toolbar + menubar + log actionCapability_->setEnabled(false); actionStopLoad_->setEnabled(false); @@ -1508,7 +1505,7 @@ logPanel_->clearLog(); StatusMsgHandler::instance()->clear(); - //Layer tabs + // Layer tabs layerPanel_->hide(); clearLayerDependentData(); @@ -1522,7 +1519,7 @@ plainPreviewPanel_->show(); - //This build the scrollarea and the request editors + // This build the scrollarea and the request editors setupReqEditPanel(); MvQGetMapRequest* req = client_->getMapRequest(); @@ -1561,14 +1558,14 @@ initExtraParEdit(); - //Init url + // Init url if (client_->url().isEmpty() || urlCombo_->itemText(0) != client_->url()) { urlCombo_->insertItem(0, client_->url()); } urlCombo_->setCurrentIndex(0); - //Run getCapapabilities - //This will init most of the GUIs + // Run getCapapabilities + // This will init most of the GUIs slotRunGetCapabilities(); } } @@ -1590,7 +1587,7 @@ void MvQWmsClientEditor::loadStarted() { /*loadLabel_->show(); - loadLabel_->movie()->start();*/ + loadLabel_->movie()->start();*/ loadProgress_->setRange(0, 0); loadProgress_->show(); @@ -1654,7 +1651,7 @@ settings.setValue("state", saveState()); settings.setValue("mainSplitter", mainSplitter_->saveState()); settings.setValue("requestSplitter", requestSplitter_->saveState()); - //settings.setValue("layerSplitter",layerSplitter_->saveState()); + // settings.setValue("layerSplitter",layerSplitter_->saveState()); settings.setValue("layerTabIndex", layerTab_->currentIndex()); settings.setValue("layerInfoTabIndex", layerInfoTab_->currentIndex()); @@ -1695,7 +1692,7 @@ mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); requestSplitter_->restoreState(settings.value("requestSplitter").toByteArray()); - //Init tabs + // Init tabs int ival = settings.value("layerInfoTabIndex").toInt(); layerInfoTab_->setCurrentIndex(ival); @@ -1705,7 +1702,7 @@ getCapInfo_->readSettings(settings, "getCapInfo"); QStringList lst(settings.value("urlCombo").toStringList()); - //lst.remove(client_->url()) + // lst.remove(client_->url()) urlCombo_->addItems(lst); if (client_->url().isEmpty()) @@ -1720,7 +1717,7 @@ settings.beginGroup("mainWindow"); if (settings.value("actionLogStatus").isNull()) { - //Hidden by default + // Hidden by default actionLog_->setChecked(false); } else { diff -Nru metview-5.17.4/metview/src/OgcClient/MvQWmsClientEditor.h metview-5.19.2/metview/src/OgcClient/MvQWmsClientEditor.h --- metview-5.17.4/metview/src/OgcClient/MvQWmsClientEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQWmsClientEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -51,7 +51,7 @@ Q_OBJECT public: MvQWmsDimensionGuiItem(MvQOgcDimension*, QString, QGridLayout*, int); - ~MvQWmsDimensionGuiItem(); + ~MvQWmsDimensionGuiItem() override; QString currentValue(); void addValue(QString); @@ -81,12 +81,12 @@ Q_OBJECT public: - MvQWmsClientEditor(MvQWmsUiClient*, QWidget* w = 0); - ~MvQWmsClientEditor(); + MvQWmsClientEditor(MvQWmsUiClient*, QWidget* w = nullptr); + ~MvQWmsClientEditor() override; public slots: void slotClientModeChanged(QString); - //void slotSaveInfo(); + // void slotSaveInfo(); void slotSelectUrl(const QString&); void slotSelectVersion(const QString&); void slotRunGetCapabilities(); @@ -142,56 +142,57 @@ void writeSettings(); void readSettings(); - MvQWmsUiClient* client_; +private: + MvQWmsUiClient* client_{nullptr}; - QVBoxLayout* mainLayout_; - QSplitter* mainSplitter_; - QSplitter* requestSplitter_; + QVBoxLayout* mainLayout_{nullptr}; + QSplitter* mainSplitter_{nullptr}; + QSplitter* requestSplitter_{nullptr}; - //QCheckBox* openCb_; + // QCheckBox* openCb_; - QLabel* loadLabel_; - QLabel* statusMessageLabel_; + QLabel* loadLabel_{nullptr}; + QLabel* statusMessageLabel_{nullptr}; QList advancedModeOnlyWidgets_; MvQMainWindow::MenuItemMap menuItems_; - QAction* actionCapability_; - QAction* actionStopLoad_; - QAction* actionLog_; - QComboBox* urlCombo_; - QComboBox* versionCombo_; - QComboBox* clientModeCombo_; + QAction* actionCapability_{nullptr}; + QAction* actionStopLoad_{nullptr}; + QAction* actionLog_{nullptr}; + QComboBox* urlCombo_{nullptr}; + QComboBox* versionCombo_{nullptr}; + QComboBox* clientModeCombo_{nullptr}; QMap clientModeMap_; - QComboBox* formatCombo_; - QLineEdit* extraGetCapEdit_; - QLineEdit* extraGetMapEdit_; - - QTabWidget* layerTab_; - QWidget* layerPanel_; - QGridLayout* layerGrid_; - QHBoxLayout* layerLayout_; - MvQTreeView* layerTree_; - MvQOgcTreeModel* layerModel_; - QComboBox* crsCombo_; - QComboBox* styleCombo_; - QPushButton* previewPb_; - int dimensionNum_; - int layerParamRowNum_; + QComboBox* formatCombo_{nullptr}; + QLineEdit* extraGetCapEdit_{nullptr}; + QLineEdit* extraGetMapEdit_{nullptr}; + + QTabWidget* layerTab_{nullptr}; + QWidget* layerPanel_{nullptr}; + QGridLayout* layerGrid_{nullptr}; + QHBoxLayout* layerLayout_{nullptr}; + MvQTreeView* layerTree_{nullptr}; + MvQOgcTreeModel* layerModel_{nullptr}; + QComboBox* crsCombo_{nullptr}; + QComboBox* styleCombo_{nullptr}; + QPushButton* previewPb_{nullptr}; + int dimensionNum_{0}; + int layerParamRowNum_{0}; QMap dim_; - QLabel* crsLabel_; + QLabel* crsLabel_{nullptr}; - QTabWidget* layerInfoTab_; - PlainTextWidget* getCapInfo_; - QTextBrowser* serviceInfo_; - QTextBrowser* layerPreview_; - QTextBrowser* getMapInfoSplit_; + QTabWidget* layerInfoTab_{nullptr}; + PlainTextWidget* getCapInfo_{nullptr}; + QTextBrowser* serviceInfo_{nullptr}; + QTextBrowser* layerPreview_{nullptr}; + QTextBrowser* getMapInfoSplit_{nullptr}; // MvQHighlighter* highlighterSplit_; - QPushButton* plainPreviewPb_; - QLabel* plainPreviewLabel_; - QWidget* plainPreviewPanel_; + QPushButton* plainPreviewPb_{nullptr}; + QLabel* plainPreviewLabel_{nullptr}; + QWidget* plainPreviewPanel_{nullptr}; - MvQLogPanel* logPanel_; + MvQLogPanel* logPanel_{nullptr}; #ifdef UI_TODO MvQTextEditSearchLine* getCapSearch_; @@ -199,16 +200,16 @@ // MvQWmsGetCapHighlighter* highlighterGetCap_; - QProgressBar* loadProgress_; + QProgressBar* loadProgress_{nullptr}; QMap reqLe_; QMap reqTe_; - QSplitter* reqSplitter_; - QWidget* reqEditPanel_; - QScrollArea* reqEditSa_; - - QDialogButtonBox* buttonBox_; - QPushButton* savePb_; - QPushButton* okPb_; - QPushButton* cancelPb_; + QSplitter* reqSplitter_{nullptr}; + QWidget* reqEditPanel_{nullptr}; + QScrollArea* reqEditSa_{nullptr}; + + QDialogButtonBox* buttonBox_{nullptr}; + QPushButton* savePb_{nullptr}; + QPushButton* okPb_{nullptr}; + QPushButton* cancelPb_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/OgcClient/MvQWmsClient.h metview-5.19.2/metview/src/OgcClient/MvQWmsClient.h --- metview-5.17.4/metview/src/OgcClient/MvQWmsClient.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/MvQWmsClient.h 2023-07-15 08:28:47.000000000 +0000 @@ -40,17 +40,17 @@ }; -//class MvQWmsMessageHandler : public QAbstractMessageHandler +// class MvQWmsMessageHandler : public QAbstractMessageHandler //{ -//public: -// MvQWmsMessageHandler(QObject* parent = 0) : -// QAbstractMessageHandler(parent){}; -// void clear() { fatalMsg_.clear(); } -// bool fatalFound() { return fatalMsg_.count() > 0; } -// QStringList fatalMessages() { return fatalMsg_; } +// public: +// MvQWmsMessageHandler(QObject* parent = 0) : +// QAbstractMessageHandler(parent){}; +// void clear() { fatalMsg_.clear(); } +// bool fatalFound() { return fatalMsg_.count() > 0; } +// QStringList fatalMessages() { return fatalMsg_; } -//protected: -// void handleMessage(QtMsgType, const QString&, const QUrl&, const QSourceLocation&); +// protected: +// void handleMessage(QtMsgType, const QString&, const QUrl&, const QSourceLocation&); // QStringList fatalMsg_; //}; @@ -58,7 +58,7 @@ class MvQWmsClientBase : public QObject { public: - virtual ~MvQWmsClientBase(); + ~MvQWmsClientBase() override; QStringList supportedMimeType() { return supportedMimeType_; } QStringList supportedCrs() { return supportedCrs_; } @@ -81,7 +81,7 @@ public: MvQWmsGetClient(MvRequest&); - ~MvQWmsGetClient(); + ~MvQWmsGetClient() override; MvQGetMapRequest* getMapRequest() { return getMapRequest_; } void setGetMapRequest(QString); @@ -100,34 +100,34 @@ void slotReplyLegend(QNetworkReply*); void slotReplyLogo(QNetworkReply*); -protected: +private: bool updateBoundingBox(); void downloadGetMapFrame(); void downloadLegend(); void downloadLogo(); - MvQGetMapRequest* getMapRequest_; + MvQGetMapRequest* getMapRequest_{nullptr}; - MvQNetworkAccessManager* networkGetMap_; - MvQNetworkAccessManager* networkLegend_; - MvQNetworkAccessManager* networkLogo_; - - QNetworkReply* getMapReply_; - QNetworkReply* legendReply_; - QNetworkReply* logoReply_; + MvQNetworkAccessManager* networkGetMap_{nullptr}; + MvQNetworkAccessManager* networkLegend_{nullptr}; + MvQNetworkAccessManager* networkLogo_{nullptr}; + + QNetworkReply* getMapReply_{nullptr}; + QNetworkReply* legendReply_{nullptr}; + QNetworkReply* logoReply_{nullptr}; - int getMapFrameNum_; - int getMapFrameToDownload_; + int getMapFrameNum_{0}; + int getMapFrameToDownload_{-1}; MvRequest reqInfo_; QString iconFile_; QStringList outFiles_; - bool getMapRunStatus_; + bool getMapRunStatus_{false}; QString legendPath_; QString legendImagePath_; QString logoPath_; QString logoImagePath_; - bool requestChanged_; + bool requestChanged_{false}; }; @@ -137,7 +137,7 @@ public: MvQWmsUiClient(std::string&, MvRequest&); - ~MvQWmsUiClient(); + ~MvQWmsUiClient() override; enum ClientMode { @@ -242,7 +242,7 @@ void logoLoaded(QString); void clientResetDone(); -protected: +private: void clearServerDependentData(bool keepRequest = false); void clearLayerDependentData(); void clearDimension(); @@ -257,7 +257,7 @@ void readFormat(); void readLayer(); void readLayer(QDomElement&, MvQOgcNode*); - //void readLayerAbstract(); + // void readLayerAbstract(); void readLayerProperties(); void readStyle(const QList& layers); void readBoundingBox(const QList& layers); @@ -283,37 +283,37 @@ QString version_; QString repliedVersion_; QString capability_; - MvQGetMapRequest* getMapRequest_; - MvQGetMapRequest* currentGetMapRequest_; - MvQGetMapRequest* lastGetMapRequest_; - - //Global - MvQOgcList* format_; - MvQOgcList* transparent_; - MvQOgcIntValue* width_; - MvQOgcIntValue* height_; - MvQOgcColourValue* bgColour_; + MvQGetMapRequest* getMapRequest_{nullptr}; + MvQGetMapRequest* currentGetMapRequest_{nullptr}; + MvQGetMapRequest* lastGetMapRequest_{nullptr}; + + // Global + MvQOgcList* format_{nullptr}; + MvQOgcList* transparent_{nullptr}; + MvQOgcIntValue* width_{nullptr}; + MvQOgcIntValue* height_{nullptr}; + MvQOgcColourValue* bgColour_{nullptr}; - //Layer - MvQOgcTree* layer_; + // Layer + MvQOgcTree* layer_{nullptr}; QString layerAbstract_; - MvQOgcCrsList* crs_; - MvQOgcStyleList* style_; + MvQOgcCrsList* crs_{nullptr}; + MvQOgcStyleList* style_{nullptr}; - MvQOgcBoundingBox* requestBbox_; - MvQOgcGeoBoundingBox* geographicBbox_; + MvQOgcBoundingBox* requestBbox_{nullptr}; + MvQOgcGeoBoundingBox* geographicBbox_{nullptr}; QList bbox_; QList dimension_; - MvQNetworkAccessManager* networkGetCap_; - MvQNetworkAccessManager* networkPreview_; - MvQNetworkAccessManager* networkLegend_; - MvQNetworkAccessManager* networkLogo_; - - QNetworkReply* getCapReply_; - QNetworkReply* previewReply_; - QNetworkReply* legendReply_; - QNetworkReply* logoReply_; + MvQNetworkAccessManager* networkGetCap_{nullptr}; + MvQNetworkAccessManager* networkPreview_{nullptr}; + MvQNetworkAccessManager* networkLegend_{nullptr}; + MvQNetworkAccessManager* networkLogo_{nullptr}; + + QNetworkReply* getCapReply_{nullptr}; + QNetworkReply* previewReply_{nullptr}; + QNetworkReply* legendReply_{nullptr}; + QNetworkReply* logoReply_{nullptr}; QString iconFile_; MvRequest reqInfo_; diff -Nru metview-5.17.4/metview/src/OgcClient/WmsClientEditor.cc metview-5.19.2/metview/src/OgcClient/WmsClientEditor.cc --- metview-5.17.4/metview/src/OgcClient/WmsClientEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/WmsClientEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,21 +43,21 @@ MvQApplication::writePidToFile(in); - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("WmsClientEditor"); MvQApplication app(argc, argv, appName.c_str(), {"MvQOgcClient", "examiner", "find", "window"}); // Initialize client auto* wmsClient = new MvQWmsUiClient(fPath, in); - //Define the ogc service manager configuration file name + // Define the ogc service manager configuration file name char* mvhome = getenv("METVIEW_USER_DIRECTORY"); - if (mvhome == 0) { + if (mvhome == nullptr) { marslog(LOG_EROR, "Environment variable METVIEW_USER_DIRECTORY is not defined!"); exit(1); } - //Read the icon file and initialize the dialog + // Read the icon file and initialize the dialog auto* editor = new MvQWmsClientEditor(wmsClient); editor->setAppIcon("WMS_CLIENT"); editor->show(); @@ -65,6 +65,6 @@ // register for callbacks from Desktop app.registerToDesktop(editor); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/OgcClient/WmsClientPlotter.cc metview-5.19.2/metview/src/OgcClient/WmsClientPlotter.cc --- metview-5.17.4/metview/src/OgcClient/WmsClientPlotter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/OgcClient/WmsClientPlotter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,12 +23,12 @@ #include "MvQApplication.h" -//class MvWmsClient : public MvQService +// class MvWmsClient : public MvQService //{ -//public: -// MvWmsClient() : -// MvQService("WMSCLIENT") {} -// void serve(MvRequest&, MvRequest&); +// public: +// MvWmsClient() : +// MvQService("WMSCLIENT") {} +// void serve(MvRequest&, MvRequest&); //// void processUiMode(MvRequest&, MvRequest&); // void processGetMode(MvRequest&, MvRequest&, const std::string&); //}; @@ -81,7 +81,7 @@ exit(0); } - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("WmsClient"); MvQApplication app(argc, argv, appName.c_str()); @@ -93,31 +93,31 @@ client->runGetMap(); - //Enter the app loop + // Enter the app loop app.exec(); - //If the getMap request failed returns + // If the getMap request failed returns if (client->getMapRunStatus() == false) { out.save(outPath.c_str()); marslog(LOG_EROR, "GetMap request failed!"); exit(13); } - //Else build the output request + // Else build the output request MvRequest req("PRASTER"); - req("IMPORT_FILE_TYPE") = "png", + req("IMPORT_FILE_TYPE") = "png", req("IMPORT_X_POSITION") = -180; req("IMPORT_Y_POSITION") = -90; - req("IMPORT_WIDTH") = 360; - req("IMPORT_HEIGHT") = 180; + req("IMPORT_WIDTH") = 360; + req("IMPORT_HEIGHT") = 180; MvQGetMapRequest* gmr = client->getMapRequest(); req("CRS") = gmr->crs().toStdString().c_str(); - //In version 1.3.0 for epsg:4326 x lat and y is lon !!!!! - //We need to swap here the coordinates because - //magics++ interprets x as lon and y as lat!! + // In version 1.3.0 for epsg:4326 x lat and y is lon !!!!! + // We need to swap here the coordinates because + // magics++ interprets x as lon and y as lat!! if (gmr->request().contains("CRS=", Qt::CaseInsensitive) && gmr->crs() == "EPSG:4326") { req("CRS_MINX") = gmr->minY().toStdString().c_str(); @@ -133,7 +133,7 @@ } - req("LAYERS") = gmr->layers().toStdString().c_str(); + req("LAYERS") = gmr->layers().toStdString().c_str(); req("SERVICE") = "WMS"; const char* layerTitle = static_cast(in("LAYER_TITLE")); @@ -148,8 +148,8 @@ if (title) req("SERVICE_TITLE") = title; - //const char *legend=static_cast(in("LAYER_LEGEND")); - //if(legend) req("LEGEND") = legend; + // const char *legend=static_cast(in("LAYER_LEGEND")); + // if(legend) req("LEGEND") = legend; if (client->legendImagePath().isEmpty() == false) { req("LEGEND") = client->legendImagePath().toStdString().c_str(); @@ -185,21 +185,21 @@ nonTimeDimUnit << it.value(); }*/ - //req("NON_TIME_DIM_NAME")=nonTimeDimName.join("/").toStdString().c_str(); - //req("NON_TIME_DIM_VALUE")=nonTimeDimValue.join("/").toStdString().c_str(); - //req("NON_TIME_DIM_UNIT")=nonTimeDimUnit.join(":").toStdString().c_str(); + // req("NON_TIME_DIM_NAME")=nonTimeDimName.join("/").toStdString().c_str(); + // req("NON_TIME_DIM_VALUE")=nonTimeDimValue.join("/").toStdString().c_str(); + // req("NON_TIME_DIM_UNIT")=nonTimeDimUnit.join(":").toStdString().c_str(); - //Build rasterloop if there is at least one frame in the request + // Build rasterloop if there is at least one frame in the request if (gmr->requestFrameNum() > 0) { MvRequest reqLoop; QVector rFrame(gmr->requestFrameNum()); for (int i = 0; i < rFrame.count(); i++) { - MvRequest reqFrame = req; - QString fnam = gmr->outFile(i); + MvRequest reqFrame = req; + QString fnam = gmr->outFile(i); reqFrame("IMPORT_FILE_PATH") = fnam.toStdString().c_str(); - reqFrame("PATH") = fnam.toStdString().c_str(); + reqFrame("PATH") = fnam.toStdString().c_str(); QMap dim; gmr->dimValuesForFrame(dim, i); @@ -216,19 +216,19 @@ } } - reqFrame("DIM_NAME") = dimName.join("/").toStdString().c_str(); + reqFrame("DIM_NAME") = dimName.join("/").toStdString().c_str(); reqFrame("DIM_VALUE") = dimValue.join("/").toStdString().c_str(); - reqLoop = reqLoop + reqFrame; + reqLoop = reqLoop + reqFrame; } out.setVerb("PRASTERLOOP"); out("RASTERS") = reqLoop; } else { - MvRequest reqFrame = req; - QString fnam = gmr->outFile(0); + MvRequest reqFrame = req; + QString fnam = gmr->outFile(0); reqFrame("IMPORT_FILE_PATH") = fnam.toStdString().c_str(); - reqFrame("PATH") = fnam.toStdString().c_str(); + reqFrame("PATH") = fnam.toStdString().c_str(); out.setVerb("PRASTERLOOP"); out("RASTERS") = reqFrame; @@ -236,15 +236,15 @@ out("IMPORT_X_POSITION") = -180; out("IMPORT_Y_POSITION") = -90; - out("IMPORT_WIDTH") = 360; - out("IMPORT_HEIGHT") = 180; + out("IMPORT_WIDTH") = 360; + out("IMPORT_HEIGHT") = 180; // MvRequest current = in.justOneRequest(); while (current != nullptr) { std::string verb = current.getVerb(); if (verb == "WMSCLIENT") { - current("REQUEST") = gmr->request().toStdString().c_str(); + current("REQUEST") = gmr->request().toStdString().c_str(); out("WMS_CLIENT_REQUEST") = current; } break; @@ -256,10 +256,10 @@ } -//int main(int argc, char** argv) +// int main(int argc, char** argv) //{ -// ac = argc; -// av = argv; +// ac = argc; +// av = argv; // // Initialize a Metview application // MvApplication app(argc, argv, "wmsclient"); diff -Nru metview-5.17.4/metview/src/Percentile/Percentile.cc metview-5.19.2/metview/src/Percentile/Percentile.cc --- metview-5.17.4/metview/src/Percentile/Percentile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Percentile/Percentile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,15 +26,15 @@ fieldset* v = new_fieldset(count); if (count != 0) { - int i; + int i = 0; for (i = 0; i < count; i++) { - int source_index; + int source_index = 0; if (i < x->count) source_index = i; else source_index = x->count - 1; - field* gx = get_field(x, source_index, expand_mem); + field* gx = get_field(x, source_index, expand_mem); v->fields[i] = copy_field(gx, copydata); v->fields[i]->refcnt++; release_field(gx); @@ -47,7 +47,7 @@ Percentile::Percentile(const char* kw) : MvService(kw) { - //empty + // empty } Percentile::~Percentile() = default; @@ -73,8 +73,8 @@ bool Percentile::GetInputInfo(MvRequest& in) { - const char* cw; // auxiliary variables - int i; // auxiliary variables + const char* cw = nullptr; // auxiliary variables + int i = 0; // auxiliary variables // Get data information from UI std::string str; @@ -107,10 +107,10 @@ // Get interpolation method const char* caux1 = in("INTERPOLATION"); - interp_ = (strcmp(caux1, "NEAREST_NEIGHBOUR") == 0) ? PERC_NN : PERC_LI; + interp_ = (strcmp(caux1, "NEAREST_NEIGHBOUR") == 0) ? PERC_NN : PERC_LI; // Get missing value strategy - const char* caux2 = in("COMPUTE_IF_MISSING_PRESENT"); + const char* caux2 = in("COMPUTE_IF_MISSING_PRESENT"); computeWithMissing_ = (strcmp(caux2, "OFF") == 0) ? false : true; return true; @@ -121,7 +121,7 @@ double rank; rank = percentile / 100. * (numInputFields + 1); - rank = rank - 1.; //c++ index + rank = rank - 1.; // c++ index if (rank < 0.) return 0.; @@ -147,20 +147,20 @@ /* ----------------------------------------------------------------------------------------- NOTE: we use the basic MARS fieldset here instead of the MvFieldSet. This is because this - is a highly memory-intensive module, and we want to be able to get rid of the GRIB - handles as quickly as possible - this is easier with the basic fieldset structure. - ----------------------------------------------------------------------------------------- */ + is a highly memory-intensive module, and we want to be able to get rid of the GRIB + handles as quickly as possible - this is easier with the basic fieldset structure. + ----------------------------------------------------------------------------------------- */ bool Percentile::ComputePercentile(MvRequest& out) { - size_t numGridPoints = 0; + size_t numGridPoints = 0; size_t numPercentiles = percList_.size(); std::vector > fsValues; // vector of vector of values - a vector for each field's values // initialise the fieldset - fieldset* fs = request_to_fieldset(dataRequest_); + fieldset* fs = request_to_fieldset(dataRequest_); size_t numInputFields = fs->count; @@ -183,7 +183,7 @@ // Check fieldset: all fields should have the same number of grid points if (first) { - first = false; + first = false; numGridPoints = f->value_count; } else { @@ -202,8 +202,8 @@ std::vector gvals(numInputFields, 0); // values for one grid point across all fields for (size_t gp = 0; gp < numGridPoints; gp++) { - bool returnMissing = false; - bool missingPresent = false; + bool returnMissing = false; + bool missingPresent = false; size_t numValsForCompute = numInputFields; // get values for the current grid point across all fields @@ -261,10 +261,10 @@ double Percentile::GetValue(double rank, std::vector& gvals, size_t numVals) { - if (interp_ == PERC_NN) //Nearest neighbour interpolation + if (interp_ == PERC_NN) // Nearest neighbour interpolation return gvals[int(rank + 0.5)]; - else { //Linear interpolation - auto ir = size_t(rank); + else { // Linear interpolation + auto ir = size_t(rank); double fr = rank - double(ir); // Test boundary @@ -285,9 +285,9 @@ // The applications don't try to read or write from pool, this // should not be done with the new PlotMod. - //a.addModeService("GRIB", "DATA"); - //c.saveToPool(false); - //perc.saveToPool(false); + // a.addModeService("GRIB", "DATA"); + // c.saveToPool(false); + // perc.saveToPool(false); theApp.run(); } diff -Nru metview-5.17.4/metview/src/Percentile/Percentile.h metview-5.19.2/metview/src/Percentile/Percentile.h --- metview-5.17.4/metview/src/Percentile/Percentile.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Percentile/Percentile.h 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ /************** Application Percentile. - A percentile is a value on a scale of one hundred that indicates the + A percentile is a value on a scale of one hundred that indicates the percent of a distribution that is equal to or below it. ***************/ @@ -23,7 +23,7 @@ { PERC_NN, PERC_LI -}; //interpolation: nearest neighbour/linear +}; // interpolation: nearest neighbour/linear class Percentile : public MvService { @@ -32,9 +32,9 @@ Percentile(const char* kw); // Destructor - ~Percentile(); + ~Percentile() override; - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; // Initialize variables from user interface bool GetInputInfo(MvRequest& in); @@ -53,8 +53,8 @@ protected: // variables - MvRequest dataRequest_; // input data request - std::vector percList_; // percentiles input values - int interp_; // interporlation method - bool computeWithMissing_; // if missing values present, do we still compute? + MvRequest dataRequest_; // input data request + std::vector percList_; // percentiles input values + int interp_{0}; // interporlation method + bool computeWithMissing_{true}; // if missing values present, do we still compute? }; diff -Nru metview-5.17.4/metview/src/PottF/PottF.cc metview-5.19.2/metview/src/PottF/PottF.cc --- metview-5.17.4/metview/src/PottF/PottF.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/PottF/PottF.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ #include #include "MvSci.h" -#include +#include #include class ThetaBase : public MvService @@ -26,9 +26,9 @@ enum ParamIds { TemperatureId = 130, - SpecHumId = 133, - LnspId = 152, - RelHumId = 157 + SpecHumId = 133, + LnspId = 152, + RelHumId = 157 }; ThetaBase(const char* a, LevelType levelType, int resultParamId) : @@ -41,7 +41,7 @@ strcpy(Plevtype_, "ML"); } } - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; protected: virtual MvRequest process(MvRequest& In) = 0; @@ -76,7 +76,7 @@ ThetaBase(a, levelType, resultParamId) {} protected: - MvRequest process(MvRequest&); + MvRequest process(MvRequest&) override; MvRequest compute(int num, MvFieldSetIterator& tIter, MvFieldSetIterator& qIter, MvField& lnspF); virtual void computeVals(MvField& tF, MvField& qF, MvField& lnsp, double p, int level, bool flag) = 0; }; @@ -240,7 +240,7 @@ while ((tF = tIter())) { MvFieldExpandThenFree xpt(tF); checkGrid(tF, fieldCnt); - double p = 0.; + double p = 0.; int level = 1; if (levelType_ == PressureLevelType) { p = tF.level() * 100; @@ -347,7 +347,7 @@ checkGrid(tF, i); checkGrid(qF, i); - double p = 0.; + double p = 0.; int level = 1; if (levelType_ == PressureLevelType) { p = tF.level() * 100.; @@ -356,7 +356,7 @@ if (fabs(p - pFromQ) > eps) { throw MvException("Pressure level does not match for temperature and humidity, field [" + std::to_string(i) + "]!"); } - valNum = tF.countValues(); + valNum = tF.countValues(); double valNumFromQ = qF.countValues(); if (valNum != valNumFromQ) { throw MvException("Temperature and humidity does not have the same numbe rof gridpoints, field [" + std::to_string(i) + "]!"); diff -Nru metview-5.17.4/metview/src/PythonServe/PythonServe.cc metview-5.19.2/metview/src/PythonServe/PythonServe.cc --- metview-5.17.4/metview/src/PythonServe/PythonServe.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/PythonServe/PythonServe.cc 2023-07-15 08:28:47.000000000 +0000 @@ -46,15 +46,15 @@ // died and another process taken the same pid while (keepGoing) { sleep(1); - //std::cout << "Checking pid " << optvals.python_pid << std::endl; + // std::cout << "Checking pid " << optvals.python_pid << std::endl; int e = kill(optvals.python_pid, 0); - //std::cout << "Checking " << e << std::endl; + // std::cout << "Checking " << e << std::endl; if ((e == -1) && (errno == ESRCH)) { // in fact, don't print this message because it may not be true - we will get // to this part even if the Python code exited normally - //marslog(LOG_WARN, "Metview detected that the calling Python process terminated without closing Metview"); - //marslog(LOG_WARN, "Metview will now close"); + // marslog(LOG_WARN, "Metview detected that the calling Python process terminated without closing Metview"); + // marslog(LOG_WARN, "Metview will now close"); keepGoing = false; } } @@ -63,10 +63,10 @@ void PythonServe::serve(MvRequest& /*in*/, MvRequest& /*out*/) { - //cout << "--------------PythonServe::serve() start --------------" << std::endl; - //in.print(); + // cout << "--------------PythonServe::serve() start --------------" << std::endl; + // in.print(); checkCallingPythonProcess(); - //cout << "--------------PythonServe::serve() end --------------" << std::endl; + // cout << "--------------PythonServe::serve() end --------------" << std::endl; } diff -Nru metview-5.17.4/metview/src/Regrid/Regrid.cc metview-5.19.2/metview/src/Regrid/Regrid.cc --- metview-5.17.4/metview/src/Regrid/Regrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Regrid/Regrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -45,9 +45,9 @@ struct defaults_t { static constexpr auto grid_definition_mode = "grid"; - static constexpr auto debug = false; - static constexpr double first_point[] = {0., 0.}; - static constexpr long multi_dimensional = 1; + static constexpr auto debug = false; + static constexpr double first_point[] = {0., 0.}; + static constexpr long multi_dimensional = 1; }; @@ -82,7 +82,7 @@ bool has(const std::string& name) const override { - auto sane = sane_key(name); + auto sane = sane_key(name); const char* v = request_(sane.c_str()); return (v != nullptr) && (strlen(v) > 0); } @@ -108,7 +108,7 @@ template bool _getValue(const std::string& name, T& value) const { - auto sane = sane_key(name); + auto sane = sane_key(name); const char* v = request_(sane.c_str()); if ((v != nullptr) && (strlen(v) > 0)) { value = eckit::Translator()(v); @@ -120,7 +120,7 @@ template bool _getVector(const std::string& name, std::vector& value) const { - auto sane = sane_key(name); + auto sane = sane_key(name); const auto* k = sane.c_str(); const char* v = request_(k); if (v != nullptr && strlen(v) > 0) { @@ -147,15 +147,18 @@ { std::string source_; std::string target_; - int target_is_temporary_; // 'int' because that is what we pass to the output request + bool target_is_temporary_; public: const std::string& source() const { return source_; } const std::string& target() const { return target_; } - int target_is_temporary() const { return target_is_temporary_; } + bool target_is_temporary() const { return target_is_temporary_; } void source(const std::string& path) { source_ = path; } - void target(const std::string& path) { target_ = path; } - void target_is_temporary(int temp) { target_is_temporary_ = temp; } + void target(const std::string& path, bool temporary) + { + target_ = path; + target_is_temporary_ = temporary; + } }; @@ -181,7 +184,7 @@ name_(std::move(name)), protocol_(protocol) {} Param(const Param&) = delete; - Param(Param&&) = delete; + Param(Param&&) = delete; void operator=(const Param&) = delete; void operator=(Param&&) = delete; @@ -356,28 +359,19 @@ void eval(const RequestWrapper& param, JobWrapper& job) const override { - // requires prior setup of input, sets temporary output + // requires prior setup of input ASSERT(!job.source().empty()); - ASSERT(job.target().empty()); - std::string userTarget; - std::string outputPath; - int targetTemporary; - if (param.get("TARGET", userTarget)) { - outputPath = userTarget; - targetTemporary = 0; - } - else { - outputPath = marstmp(); - targetTemporary = 1; - } - + // setup output + ASSERT(job.target().empty()); + std::string target; + const bool temporary = !param.get("TARGET", target); + job.target(temporary ? marstmp() : target, temporary); + ASSERT(!job.target().empty()); - // setup a temporary target - job.target(outputPath); - job.target_is_temporary(targetTemporary); + // setup mode std::string mode = defaults_t::grid_definition_mode; param.get(name(), mode); mode = sane_value(mode); @@ -594,6 +588,7 @@ new ParamT(*this, "packing"), new ParamT(*this, "edition"), new ParamT(*this, "delete-local-definition"), + new ParamT(*this, "basic-angle"), new ParamT(*this, "input-statistics"), new ParamT(*this, "output-statistics"), new ParamT(*this, "precision"), @@ -663,8 +658,8 @@ // Set output out.setVerb("GRIB"); - out("PATH") = job.target().c_str(); - out("TEMPORARY") = job.target_is_temporary(); + out("PATH") = job.target().c_str(); + out("TEMPORARY") = job.target_is_temporary() ? 1 : 0; std::cout << "Regrid::serve out" << std::endl; diff -Nru metview-5.17.4/metview/src/Regrid/RegridDef metview-5.19.2/metview/src/Regrid/RegridDef --- metview-5.17.4/metview/src/Regrid/RegridDef 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Regrid/RegridDef 2023-07-15 08:28:47.000000000 +0000 @@ -21,12 +21,12 @@ GRID_DEFINITION_MODE { - GRID - LAMBERT_AZIMUTHAL_EQUAL_AREA - LAMBERT_CONFORMAL - TEMPLATE - FILTER - } = GRID + grid + lambert_azimuthal_equal_area + lambert_conformal + template + filter + } = grid TEMPLATE_SOURCE { @@ -133,17 +133,17 @@ WRITE_LAD_IN_DEGREES [ visible = false ] { - ON - OFF - } = OFF + on + off + } = off # lambert-only WRITE_LON_POSITIVE [ visible = false ] { - ON - OFF - } = OFF + on + off + } = off # lambert_azimuthal_equal_area-only STANDARD_PARALLEL_IN_DEGREES @@ -163,10 +163,10 @@ # Input is vector in Cartesian components (spectral U/V), convert to gridded u/v WIND_PROCESSING { - OFF - UV_TO_UV - VOD_TO_UV - } = OFF + off + uv_to_uv + vod_to_uv + } = off # Vector/scalar operator(s) NABLA @@ -176,15 +176,15 @@ uv_divergence uv_gradient uv_vorticity - OFF - } = OFF + off + } = off # Force missing values at the poles NABLA_POLES_MISSING_VALUES { - ON - OFF - } = OFF + on + off + } = off # cropping area: north/west/south/east AREA @@ -372,16 +372,16 @@ LSM [ visible = false ] { - ON - OFF - } = OFF + on + off + } = off DISTANCE_WEIGHTING_WITH_LSM # nearest_lsm { nearest_lsm nearest_lsm_with_lowest_index - OFF - } = OFF + off + } = off # LSM interpolation weight adjustment factor LSM_WEIGHT_ADJUSTMENT @@ -518,24 +518,33 @@ second_order ; so simple ieee - AS_INPUT - } = AS_INPUT + as_input + } = as_input # GRIB output edition number EDITION { 1 2 - AS_INPUT - } = AS_INPUT + as_input + } = as_input # GRIB output remove local extension DELETE_LOCAL_DEFINITION [ visible = false ] { - ON - DEFAULT - } = DEFAULT + on + default + } = default + + # GRIB basic angle + BASIC_ANGLE + [ visible = false ] + { + as_input + decimal + fraction + } = decimal # Statistics methods for interpreting field values (pre_processed) INPUT_STATISTICS @@ -553,8 +562,8 @@ scalar simple_packing_entropy spectral - OFF - } = OFF + off + } = off # Statistics methods for interpreting field values (post_processed) OUTPUT_STATISTICS @@ -572,8 +581,8 @@ scalar simple_packing_entropy spectral - OFF - } = OFF + off + } = off # Statistics methods output precision PRECISION @@ -599,8 +608,8 @@ # 3d_vector_u # ... # 3d_vector_v # ... # 3d_vector_w # ... - OFF - } = OFF + off + } = off # Select how to load matrices in memory MATRIX_LOADER @@ -609,8 +618,8 @@ file_io shared_memory ; shmem tmp_shared_memory ; tmp_shmem - OFF - } = OFF + off + } = off # Select how to load Legendre coefficients in memory LEGENDRE_LOADER @@ -621,8 +630,8 @@ shared_memory ; shmem tmp_shared_memory ; tmp_shmem none - OFF - } = OFF + off + } = off # k_d tree control POINT_SEARCH_TREES @@ -632,8 +641,8 @@ mapped_cache_file mapped_temporary_file memory - OFF - } = OFF + off + } = off MULTI_DIMENSIONAL [ visible = false ] @@ -645,9 +654,9 @@ ATLAS_TRANS_FLT [ visible = false ] { - ON - OFF - } = OFF + on + off + } = off # Atlas/Trans spectral transforms type ATLAS_TRANS_TYPE @@ -669,7 +678,7 @@ openmp viennacl off - } = OFF + } = off # Linear algebra backend (dense) DENSE_BACKEND @@ -684,7 +693,7 @@ openmp viennacl off - } = OFF + } = off # Linear algebra backend (sparse) SPARSE_BACKEND @@ -697,30 +706,30 @@ openmp viennacl off - } = OFF + } = off # Globalise (before interpolation) PRE_GLOBALISE [ visible = false ] { - ON - OFF - } = OFF + on + off + } = off # Globalise (after interpolation) GLOBALISE [ visible = false ] { - ON - OFF - } = OFF + on + off + } = off DEBUG [ visible = false ] { - ON - OFF - } = OFF + on + off + } = off TARGET { diff -Nru metview-5.17.4/metview/src/Regrid/RegridRules metview-5.19.2/metview/src/Regrid/RegridRules --- metview-5.17.4/metview/src/Regrid/RegridRules 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Regrid/RegridRules 2023-07-15 08:28:47.000000000 +0000 @@ -1,12 +1,12 @@ -%if GRID_DEFINITION_MODE <> TEMPLATE %then +%if GRID_DEFINITION_MODE <> template %then %unset TEMPLATE_SOURCE %unset TEMPLATE_DATA -%if GRID_DEFINITION_MODE <> GRID %then +%if GRID_DEFINITION_MODE <> grid %then %unset GRID -%if GRID_DEFINITION_MODE <> LAMBERT_CONFORMAL %and GRID_DEFINITION_MODE <> LAMBERT_AZIMUTHAL_EQUAL_AREA %then +%if GRID_DEFINITION_MODE <> lambert_conformal %and GRID_DEFINITION_MODE <> lambert_azimuthal_equal_area %then %unset FIRST_POINT %unset DX_IN_METRES %unset DY_IN_METRES @@ -17,7 +17,7 @@ %unset EARTH_MAJOR_AXIS %unset EARTH_MINOR_AXIS -%if GRID_DEFINITION_MODE <> LAMBERT_CONFORMAL %then +%if GRID_DEFINITION_MODE <> lambert_conformal %then %unset LAD_IN_DEGREES %unset LOV_IN_DEGREES %unset LATIN_1_IN_DEGREES @@ -25,22 +25,22 @@ %unset WRITE_LAD_IN_DEGREES %unset WRITE_LON_POSITIVE -%if GRID_DEFINITION_MODE <> LAMBERT_AZIMUTHAL_EQUAL_AREA %then +%if GRID_DEFINITION_MODE <> lambert_azimuthal_equal_area %then %unset STANDARD_PARALLEL_IN_DEGREES %unset CENTRAL_LONGITUDE_IN_DEGREES -%if GRID_DEFINITION_MODE = LAMBERT_CONFORMAL %or GRID_DEFINITION_MODE = LAMBERT_AZIMUTHAL_EQUAL_AREA %then +%if GRID_DEFINITION_MODE = lambert_conformal %or GRID_DEFINITION_MODE = lambert_azimuthal_equal_area %then %unset AREA %unset ROTATION -%if GRID_DEFINITION_MODE = TEMPLATE %or GRID_DEFINITION_MODE = FILTER %then +%if GRID_DEFINITION_MODE = template %or GRID_DEFINITION_MODE = filter %then %unset AREA %unset ROTATION %unset PL %unset FRAME %unset EDITION -%if INTERPOLATION <> nearest_lsm %and LSM = OFF %then +%if INTERPOLATION <> nearest_lsm %and LSM = off %then %unset LSM_INTERPOLATION_INPUT %unset LSM_SELECTION_INPUT %unset LSM_NAMED_INPUT @@ -52,7 +52,7 @@ %unset LSM_FILE_OUTPUT %unset LSM_VALUE_THRESHOLD_OUTPUT -%if LSM = OFF %then +%if LSM = off %then %unset LSM_WEIGHT_ADJUSTMENT %if LSM_SELECTION_INPUT <> file %then @@ -67,7 +67,7 @@ %if LSM_SELECTION_OUTPUT <> named %then %unset LSM_NAMED_OUTPUT -%if NABLA = OFF %then +%if NABLA = off %then %unset NABLA_POLES_MISSING_VALUES %if INTERPOLATION <> k_nearest_neighbours %then @@ -108,7 +108,7 @@ %warning "PACKING=ieee allows only ACCURACY=32 or 64" %error "PACKING=ieee allows only ACCURACY=32 or 64" -%if GRID_DEFINITION_MODE = FILTER %then +%if GRID_DEFINITION_MODE = filter %then %unset TRUNCATION %unset INTGRID %unset SPECTRAL_ORDER diff -Nru metview-5.17.4/metview/src/Relhum/MvRelhum.cc metview-5.19.2/metview/src/Relhum/MvRelhum.cc --- metview-5.17.4/metview/src/Relhum/MvRelhum.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Relhum/MvRelhum.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,8 +7,8 @@ ***************************** LICENSE END *************************************/ -#include -#include +#include +#include #include "Metview.h" #include "MvRelhum.h" #include "MvException.h" @@ -71,12 +71,12 @@ throw MvException("Q: different number of grid points!"); MvRequest r = f_q.getRequest(); - int level = r("LEVELIST"); + int level = r("LEVELIST"); for (int jl = 0; jl < f_t.countValues(); jl++) { - double EPS = RV / RD; - double C2ES = C1ES * RD / RV; - double esice = 0.0, eswat = 0.0, mixphase, es, pres; + double EPS = RV / RD; + double C2ES = C1ES * RD / RV; + double esice = 0.0, eswat = 0.0, mixphase = 0., es = 0., pres = 0.; if (f_t[jl] < TMELT) { esice = C2ES * exp(C3IES * (f_t[jl] - TMELT) / (f_t[jl] - C4IES)); @@ -93,7 +93,7 @@ es = mixphase * eswat + (1. - mixphase) * esice; - //pres = ((lmodlv) ? f_q.modelLevelToPressure (f_LNSP[jl], level) : level * 100.); + // pres = ((lmodlv) ? f_q.modelLevelToPressure (f_LNSP[jl], level) : level * 100.); pres = ((lmodlv) ? f_q.meanML_to_Pressure_byLNSP(f_LNSP[jl], level) : level * 100.); #define RELHUM_TESTPRINT 0 diff -Nru metview-5.17.4/metview/src/Relhum/MvRelhum.h metview-5.19.2/metview/src/Relhum/MvRelhum.h --- metview-5.17.4/metview/src/Relhum/MvRelhum.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Relhum/MvRelhum.h 2023-07-15 08:28:47.000000000 +0000 @@ -9,14 +9,14 @@ #pragma once -const int Temp = 130; -const int Dew = 133; +const int Temp = 130; +const int Dew = 133; const int LnPress = 152; -const float RD = 287.05967367; -const float RV = 461.52499331; +const float RD = 287.05967367; +const float RV = 461.52499331; const float TMELT = 273.16; -const float TICE = 250.16; -const float C1ES = 611.21; +const float TICE = 250.16; +const float C1ES = 611.21; const float C3LES = 17.502; const float C3IES = 22.587; const float C4LES = 32.19; @@ -26,8 +26,8 @@ class MvRelhum { protected: - int refDataRepres; - int refDataLength; + int refDataRepres{-1}; + int refDataLength{-1}; void init(); diff -Nru metview-5.17.4/metview/src/Relhum/Relhum.cc metview-5.19.2/metview/src/Relhum/Relhum.cc --- metview-5.17.4/metview/src/Relhum/Relhum.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Relhum/Relhum.cc 2023-07-15 08:28:47.000000000 +0000 @@ -8,8 +8,8 @@ ***************************** LICENSE END *************************************/ -#include -#include +#include +#include #include @@ -28,7 +28,7 @@ public: Relhum() : MvService("RELHUM2") {} - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; @@ -76,13 +76,13 @@ return; } - field = iter_q(); - MvRequest rq = field.getRequest(); + field = iter_q(); + MvRequest rq = field.getRequest(); const char* ML = rq("LEVTYPE"); - int lmodlv; + int lmodlv = 0; if (strcmp("ML", ML)) { - lmodlv = 0; + lmodlv = 0; count_LnPres = rq.countValues("LEVELIST"); } else { @@ -105,7 +105,7 @@ return; } mvrh->setRefDataRepres(repres); - //delete fe; + // delete fe; iter_q.rewind(); @@ -122,7 +122,7 @@ else { MvField f_LNSP; f_LNSP = iterLNSP(); - out = out + mvrh->compute(count_Temp, f_LNSP, iter_t, iter_q, lmodlv); + out = out + mvrh->compute(count_Temp, f_LNSP, iter_t, iter_q, lmodlv); } } } diff -Nru metview-5.17.4/metview/src/Reprojection/Reprojection.cc metview-5.19.2/metview/src/Reprojection/Reprojection.cc --- metview-5.17.4/metview/src/Reprojection/Reprojection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Reprojection/Reprojection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ Reprojection::Reprojection(const char* kw) : MvService(kw) { - //empty + // empty } Reprojection::~Reprojection() = default; @@ -95,7 +95,7 @@ bool Reprojection::ComputeReprojection(MvRequest& out) { - std::string gin = (const char*)dataRequest_("PATH"); + std::string gin = (const char*)dataRequest_("PATH"); std::string gout = marstmp(); ReprojectService reps(gin, gout, xres_, yres_, x1_, x2_, y1_, y2_); @@ -104,7 +104,7 @@ // Create fieldset request MvRequest req("GRIB"); - req("PATH") = gout.c_str(); + req("PATH") = gout.c_str(); req("TEMPORARY") = 1; // Update output request @@ -112,11 +112,11 @@ return true; } -//GRIB, -// PATH = '/var...', -// TEMPORARY = 1, -// OFFSET = 0, -// LENGTH = 87228 +// GRIB, +// PATH = '/var...', +// TEMPORARY = 1, +// OFFSET = 0, +// LENGTH = 87228 //-------------------------------------------------------- @@ -128,9 +128,9 @@ // The applications don't try to read or write from pool, this // should not be done with the new PlotMod. - //a.addModeService("GRIB", "DATA"); - //c.saveToPool(false); - //perc.saveToPool(false); + // a.addModeService("GRIB", "DATA"); + // c.saveToPool(false); + // perc.saveToPool(false); theApp.run(); } diff -Nru metview-5.17.4/metview/src/Reprojection/Reprojection.h metview-5.19.2/metview/src/Reprojection/Reprojection.h --- metview-5.17.4/metview/src/Reprojection/Reprojection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Reprojection/Reprojection.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ { REPROJ_NN, REPROJ_LI -}; //interpolation: nearest neighbour/linear +}; // interpolation: nearest neighbour/linear class Reprojection : public MvService { diff -Nru metview-5.17.4/metview/src/Reprojection/ReprojectService.cc metview-5.19.2/metview/src/Reprojection/ReprojectService.cc --- metview-5.17.4/metview/src/Reprojection/ReprojectService.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Reprojection/ReprojectService.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ resX_(rx), resY_(ry) { - //empty + // empty } bool ReprojectService::execute() @@ -76,9 +76,9 @@ long numberOfPointsAlongAParallel, numberOfPointsAlongAMeridian, numberOfPoints, i, j, k; grib_handle* hnew; - //int option_flags = GRIB_DUMP_FLAG_VALUES | - // //GRIB_DUMP_FLAG_OPTIONAL | - // GRIB_DUMP_FLAG_READ_ONLY; + // int option_flags = GRIB_DUMP_FLAG_VALUES | + // //GRIB_DUMP_FLAG_OPTIONAL | + // GRIB_DUMP_FLAG_READ_ONLY; double missingValueInGrib; const double missingValueInImage = 65535; // -1 as an unsigned short. @@ -107,23 +107,23 @@ grib_set_long(hnew, "bitmapPresent", 1); // tell the GRIB that it will contain missing values // Set bounding box - grib_set_double(hnew, "latitudeOfFirstGridPointInDegrees", matrix.minY()); //getUpperRightCorner().y()); - grib_set_double(hnew, "longitudeOfFirstGridPointInDegrees", matrix.minX()); //getLowerLeftCorner().x()); + grib_set_double(hnew, "latitudeOfFirstGridPointInDegrees", matrix.minY()); // getUpperRightCorner().y()); + grib_set_double(hnew, "longitudeOfFirstGridPointInDegrees", matrix.minX()); // getLowerLeftCorner().x()); - grib_set_double(hnew, "latitudeOfLastGridPointInDegrees", matrix.maxY()); //getLowerLeftCorner().y()); - grib_set_double(hnew, "longitudeOfLastGridPointInDegrees", matrix.maxX()); //getUpperRightCorner().x()); + grib_set_double(hnew, "latitudeOfLastGridPointInDegrees", matrix.maxY()); // getLowerLeftCorner().y()); + grib_set_double(hnew, "longitudeOfLastGridPointInDegrees", matrix.maxX()); // getUpperRightCorner().x()); grib_set_double(hnew, "jDirectionIncrementInDegrees", resX_); grib_set_double(hnew, "iDirectionIncrementInDegrees", resY_); - //Set matrix size + // Set matrix size numberOfPointsAlongAParallel = matrix.columns(); numberOfPointsAlongAMeridian = matrix.rows(); grib_set_long(hnew, "numberOfPointsAlongAParallel", numberOfPointsAlongAParallel); grib_set_long(hnew, "numberOfPointsAlongAMeridian", numberOfPointsAlongAMeridian); numberOfPoints = numberOfPointsAlongAMeridian * numberOfPointsAlongAParallel; - values = (double*)malloc(numberOfPoints * sizeof(double)); + values = (double*)malloc(numberOfPoints * sizeof(double)); for (j = 0; j < numberOfPointsAlongAMeridian; j++) { for (i = 0; i < numberOfPointsAlongAParallel; i++) { k = i + numberOfPointsAlongAParallel * j; diff -Nru metview-5.17.4/metview/src/Reprojection/ReprojectService.h metview-5.19.2/metview/src/Reprojection/ReprojectService.h --- metview-5.17.4/metview/src/Reprojection/ReprojectService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Reprojection/ReprojectService.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,5 +29,5 @@ private: std::string gribIn_; std::string gribOut_; - double resX_, resY_; //resolution + double resX_, resY_; // resolution }; diff -Nru metview-5.17.4/metview/src/Rttov/RttovRun.cc metview-5.19.2/metview/src/Rttov/RttovRun.cc --- metview-5.17.4/metview/src/Rttov/RttovRun.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Rttov/RttovRun.cc 2023-07-15 08:28:47.000000000 +0000 @@ -48,7 +48,7 @@ std::string errTxt; - //Find out rttov script path + // Find out rttov script path std::string rttovScript; char* mvbin = getenv("METVIEW_BIN"); if (mvbin == nullptr) { @@ -60,7 +60,7 @@ } - //Create tmp dir for the flextra run + // Create tmp dir for the flextra run std::string tmpPath; if (!metview::createWorkDir("rttov", tmpPath, errTxt)) { std::string err = "RttovRun-> " + errTxt; @@ -68,7 +68,7 @@ return; } - //RttovRun exe + // RttovRun exe std::string exe; if (!in.getPath("RTTOV_EXE_PATH", exe, true)) { setError(1, "RttovRun-> Error parameter RTTOV_EXE_PATH"); @@ -109,17 +109,17 @@ const char* sensor = in("RTTOV_SENSOR"); - std::string ch = "_UNDEF_"; + std::string ch = "_UNDEF_"; std::string coeff = "_UNDEF_"; if (sensor && strcmp(sensor, "CUSTOM") == 0) { - //Channels file + // Channels file if (!in.getPath("RTTOV_CHANNELS", "RTTOV_CHANNELS_PATH", ch, true, errTxt)) { std::string err = "RttovRun-> " + errTxt; setError(1, err.c_str()); return; } - //Coeff file + // Coeff file if (!in.getPath("RTTOV_COEFFICIENTS", "RTTOV_COEFFICIENTS_PATH", coeff, true, errTxt)) { std::string err = "RttovRun-> " + errTxt; setError(1, err.c_str()); @@ -143,7 +143,7 @@ //--------------------------- std::string inFile = tmpPath + "/rttov_in.txt"; - bool useOzone = (sensor && strcmp(sensor, "IASI") == 0) ? true : false; + bool useOzone = (sensor && strcmp(sensor, "IASI") == 0) ? true : false; if (MvScm::createRttovInput(data, inFile, sat_z, sat_az, solar_z, solar_az, useOzone, errTxt) == false) { std::string err = "RttovRun-> Could not generate RTTOV input file! " + errTxt; setError(1, err.c_str()); @@ -155,22 +155,22 @@ //------------------------- std::string resFileName = "rttov_out.txt"; - std::string resFile = tmpPath + "/" + resFileName; + std::string resFile = tmpPath + "/" + resFileName; std::string logFileName = "log.txt"; - std::string logFile = tmpPath + "/" + logFileName; + std::string logFile = tmpPath + "/" + logFileName; - //Run the scm script + // Run the scm script std::string cmd = rttovScript + " \"" + tmpPath + "\" \"" + exe + "\" \"" + inFile + "\" \"" + nlev + "\" \"" + sensor + "\" \"" + ch + "\" \"" + coeff + "\" \"" + logFileName + "\" \"" + resFileName + "\""; - //marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); + // marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); int ret = system(cmd.c_str()); bool runFailed = false; - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { std::ifstream in(logFile.c_str()); std::string line; @@ -188,7 +188,7 @@ } } - //Log locations are always printed!! + // Log locations are always printed!! if (runFailed) { marslog(LOG_EROR, "Log files are available at:"); @@ -212,31 +212,31 @@ //--------------------------------------------------- /*if(!userResFile.empty()) - { - const char *dn=dirname(userResFile.c_str()); - cmd="mkdir -p " + std::string(dn) + "; cp -f " + resFile + " " + userResFile; - - std::stringstream outStream; - std::stringstream errStream; - shellCommand(cmd,outStream,errStream); - - if(!errStream.str().empty()) - { - marslog(LOG_EROR,""); - marslog(LOG_EROR,"Could not copy ouput file to target location!"); - marslog(LOG_EROR,"This command:"); - marslog(LOG_EROR," %s",cmd.c_str()); - marslog(LOG_EROR,"failed with this error:"); - marslog(LOG_EROR," %s",errStream.str().c_str()); - setError(13); - } - }*/ + { + const char *dn=dirname(userResFile.c_str()); + cmd="mkdir -p " + std::string(dn) + "; cp -f " + resFile + " " + userResFile; + + std::stringstream outStream; + std::stringstream errStream; + shellCommand(cmd,outStream,errStream); + + if(!errStream.str().empty()) + { + marslog(LOG_EROR,""); + marslog(LOG_EROR,"Could not copy ouput file to target location!"); + marslog(LOG_EROR,"This command:"); + marslog(LOG_EROR," %s",cmd.c_str()); + marslog(LOG_EROR,"failed with this error:"); + marslog(LOG_EROR," %s",errStream.str().c_str()); + setError(13); + } + }*/ //------------------------------------------ - //Set out request + // Set out request //------------------------------------------ - out = MvRequest("RTTOV_OUTPUT_FILE"); + out = MvRequest("RTTOV_OUTPUT_FILE"); out("PATH") = resFile.c_str(); std::cout << "--------------RttovRun::serve() out--------------" << std::endl; diff -Nru metview-5.17.4/metview/src/Rttov/RttovVisualiser.cc metview-5.19.2/metview/src/Rttov/RttovVisualiser.cc --- metview-5.17.4/metview/src/Rttov/RttovVisualiser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Rttov/RttovVisualiser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,7 +43,7 @@ bool RttovVisualiser::getDataPath(MvRequest& in, const char* dataParamName, const char* dataPathParamName, std::string& result) { - MvRequest dataR = in(dataParamName); + MvRequest dataR = in(dataParamName); const char* dataPath = dataR("PATH"); if (dataPath) { @@ -123,45 +123,45 @@ if (str == "CHANNEL_TB_GRAPH" || str == defVal) { MvRequest netCDFVisualiserReq("NETCDF_XY_POINTS"); - netCDFVisualiserReq("NETCDF_FILENAME") = outNetCDFFileName.c_str(); - netCDFVisualiserReq("NETCDF_X_VARIABLE") = "channel"; - netCDFVisualiserReq("NETCDF_Y_VARIABLE") = "tb"; + netCDFVisualiserReq("NETCDF_FILENAME") = outNetCDFFileName.c_str(); + netCDFVisualiserReq("NETCDF_X_VARIABLE") = "channel"; + netCDFVisualiserReq("NETCDF_Y_VARIABLE") = "tb"; netCDFVisualiserReq("NETCDF_VALUE_VARIABLE") = "tb"; - netCDFVisualiserReq("_VERB") = "NETCDF_XY_POINTS"; + netCDFVisualiserReq("_VERB") = "NETCDF_XY_POINTS"; out = netCDFVisualiserReq; } else if (str == "JACOBIAN_MATRIX") { MvRequest netCDFVisualiserReq("NETCDF_XY_MATRIX"); - netCDFVisualiserReq("NETCDF_FILENAME") = outNetCDFFileName.c_str(); - netCDFVisualiserReq("NETCDF_X_VARIABLE") = "channel"; - netCDFVisualiserReq("NETCDF_Y_VARIABLE") = "pressure"; + netCDFVisualiserReq("NETCDF_FILENAME") = outNetCDFFileName.c_str(); + netCDFVisualiserReq("NETCDF_X_VARIABLE") = "channel"; + netCDFVisualiserReq("NETCDF_Y_VARIABLE") = "pressure"; netCDFVisualiserReq("NETCDF_VALUE_VARIABLE") = "jacobian"; - netCDFVisualiserReq("_VERB") = "NETCDF_XY_MATRIX"; + netCDFVisualiserReq("_VERB") = "NETCDF_XY_MATRIX"; out = netCDFVisualiserReq; } else if (str == "JACOBIAN_CHANNEL_CURVE") { - defVal = "1"; + defVal = "1"; std::string channelString = getString(in, "RTTOV_JACOBIAN_CHANNEL", defVal); - channelString = "channel/" + channelString; + channelString = "channel/" + channelString; MvRequest netCDFVisualiserReq("NETCDF_XY_POINTS"); - netCDFVisualiserReq("NETCDF_FILENAME") = outNetCDFFileName.c_str(); - netCDFVisualiserReq("NETCDF_X_VARIABLE") = "jacobian"; - netCDFVisualiserReq("NETCDF_Y_VARIABLE") = "pressure"; - netCDFVisualiserReq("NETCDF_VALUE_VARIABLE") = "jacobian"; + netCDFVisualiserReq("NETCDF_FILENAME") = outNetCDFFileName.c_str(); + netCDFVisualiserReq("NETCDF_X_VARIABLE") = "jacobian"; + netCDFVisualiserReq("NETCDF_Y_VARIABLE") = "pressure"; + netCDFVisualiserReq("NETCDF_VALUE_VARIABLE") = "jacobian"; netCDFVisualiserReq("NETCDF_DIMENSION_SETTING") = channelString.c_str(); - netCDFVisualiserReq("_VERB") = "NETCDF_XY_POINTS"; + netCDFVisualiserReq("_VERB") = "NETCDF_XY_POINTS"; // currently, NETCDF_XY_POINTS does not honour the order of the // values in the y-axis variable, so we have to create a Cartesian // View which reverses the axis MvRequest viewReq("CARTESIANVIEW"); - viewReq("X_AUTOMATIC") = "on"; - viewReq("Y_AUTOMATIC") = "on"; + viewReq("X_AUTOMATIC") = "on"; + viewReq("Y_AUTOMATIC") = "on"; viewReq("Y_AUTOMATIC_REVERSE") = "on"; out = netCDFVisualiserReq + viewReq; @@ -206,11 +206,11 @@ // add the Jacobians themselves std::vector jvals_dimsize(2); std::vector jacobiansDimNames(2); - jvals_dimsize[0] = channelsSize; - jvals_dimsize[1] = jpsSize; + jvals_dimsize[0] = channelsSize; + jvals_dimsize[1] = jpsSize; jacobiansDimNames[0] = "channel"; jacobiansDimNames[1] = "pressure"; - MvNcVar* ncJVals = netcdf.addVariable("jacobian", ncDouble, jvals_dimsize, jacobiansDimNames); + MvNcVar* ncJVals = netcdf.addVariable("jacobian", ncDouble, jvals_dimsize, jacobiansDimNames); for (size_t c = 0; c < (unsigned)channelsSize; c++) { ncJVals->setCurrent(c); diff -Nru metview-5.17.4/metview/src/Scm/ScmRun.cc metview-5.19.2/metview/src/Scm/ScmRun.cc --- metview-5.17.4/metview/src/Scm/ScmRun.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Scm/ScmRun.cc 2023-07-15 08:28:47.000000000 +0000 @@ -81,7 +81,7 @@ std::string errTxt; - //Find out scm script path + // Find out scm script path std::string scmScript; char* mvbin = getenv("METVIEW_BIN"); if (mvbin == nullptr) { @@ -93,14 +93,14 @@ } - //Create tmp dir for the flextra run + // Create tmp dir for the flextra run std::string tmpPath; if (!metview::createWorkDir("scm", tmpPath, errTxt)) { setError(1, "ScmRun-> %s", errTxt.c_str()); return; } - //Scm exe + // Scm exe std::string exe; if (!in.getPath("SCM_EXE_PATH", exe, true)) { setError(1, "ScmRun-> parameter SCM_EXE_PATH not defined"); @@ -135,7 +135,7 @@ std::string nlev = sst.str(); //------------------------- - //Namelist + // Namelist //------------------------- std::string namelist; @@ -145,7 +145,7 @@ } //------------------------- - //Vtable file + // Vtable file //------------------------- std::string vtable; @@ -190,19 +190,19 @@ std::string resFileName = "scm_out.nc"; std::string logFileName = "log.txt"; - std::string logFile = tmpPath + "/" + logFileName; + std::string logFile = tmpPath + "/" + logFileName; - //Run the scm script + // Run the scm script std::string cmd = scmScript + " \"" + tmpPath + "\" \"" + exe + "\" " + nlev + " \"" + data + "\" \"" + namelist + "\" \"" + vtable + "\" \"" + rclim + "\" \"" + logFileName + "\" \"" + resFileName + "\""; - //marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); + // marslog(LOG_INFO,"Execute command: %s",cmd.c_str()); int ret = system(cmd.c_str()); bool runFailed = false; - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR std::string err; if (ret == -1 || WEXITSTATUS(ret) != 0) { std::ifstream in(logFile.c_str()); @@ -212,7 +212,7 @@ setError(0, "ScmRun-> Warnings were generated during SCM run!"); } else if (WEXITSTATUS(ret) == 1) { - err = "ScmRun-> Failed to perform SCM run! "; + err = "ScmRun-> Failed to perform SCM run! "; runFailed = true; } else if (WEXITSTATUS(ret) > 1) { @@ -223,7 +223,7 @@ } } - //Log locations are always printed!! + // Log locations are always printed!! if (runFailed) { err += "Log files are available at: STDOUT "; @@ -244,10 +244,10 @@ // Merge the output files //--------------------------- - //At this point we have already copied progvar.nc into resFile in the script + // At this point we have already copied progvar.nc into resFile in the script - std::string resFile = tmpPath + "/" + resFileName; - std::string diagFile = tmpPath + "/diagvar.nc"; + std::string resFile = tmpPath + "/" + resFileName; + std::string diagFile = tmpPath + "/diagvar.nc"; std::string diag2File = tmpPath + "/diagvar2.nc"; if (MvScm::mergeOutFiles(resFile, diagFile, diag2File) == false) { @@ -261,7 +261,7 @@ if (!userResFile.empty()) { const char* dn = mdirname(userResFile.c_str()); - cmd = "mkdir -p " + std::string(dn) + "; cp -f " + resFile + " " + userResFile; + cmd = "mkdir -p " + std::string(dn) + "; cp -f " + resFile + " " + userResFile; std::stringstream outStream; std::stringstream errStream; @@ -278,10 +278,10 @@ } //------------------------------------------ - //Set out request + // Set out request //------------------------------------------ - out = MvRequest("SCM_OUTPUT_DATA"); + out = MvRequest("SCM_OUTPUT_DATA"); out("PATH") = resFile.c_str(); std::cout << "--------------ScmRun::serve() out--------------" << std::endl; diff -Nru metview-5.17.4/metview/src/Scm/ScmVisualiser.cc metview-5.19.2/metview/src/Scm/ScmVisualiser.cc --- metview-5.17.4/metview/src/Scm/ScmVisualiser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Scm/ScmVisualiser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -44,7 +44,7 @@ bool ScmVisualiser::getDataPath(MvRequest& in, const char* dataParamName, const char* dataPathParamName, std::string& result) { - MvRequest dataR = in(dataParamName); + MvRequest dataR = in(dataParamName); const char* dataPath = dataR("PATH"); if (dataPath) { @@ -77,7 +77,7 @@ std::string result; int nrParams = in.countValues(parameter); - numElements = nrParams; + numElements = nrParams; if (nrParams == 0) // is this case even possible? result = std::string("dummy"); @@ -129,7 +129,7 @@ std::vector params; std::string str; std::string listSeparator = ","; - const char* defVal = "dummy"; + const char* defVal = "dummy"; // set the MARS expand flags to avoid unwanted expansion of lists @@ -168,7 +168,7 @@ comparisonDataTitle = getString(in, "SCM_COMPARISON_DATA_TITLE", defVal); } else { - dataPath = "dummy"; + dataPath = "dummy"; comparisonDataTitle = "dummy"; } @@ -182,7 +182,7 @@ // var selection type - str = "LIST"; //getString(in, "SCM_VARIABLE_SELECTION_TYPE", defVal); + str = "LIST"; // getString(in, "SCM_VARIABLE_SELECTION_TYPE", defVal); params.push_back(str); @@ -278,27 +278,27 @@ } - //Build request to be sent to Macro + // Build request to be sent to Macro MvRequest req("MACRO"); std::string processName = MakeProcessName("ScmVisualiser"); MvRequest macroReq("MACRO"); - req("PATH") = ScmVisMacro.c_str(); - req("_CLASS") = "MACRO"; + req("PATH") = ScmVisMacro.c_str(); + req("_CLASS") = "MACRO"; req("_ACTION") = "execute"; - req("_REPLY") = processName.c_str(); + req("_REPLY") = processName.c_str(); - //Define argument list for the macro! + // Define argument list for the macro! for (auto& param : params) { req.addValue("_ARGUMENTS", param.c_str()); } - //Run macro + // Run macro int error; sendProgress("ScmVisualiser-> Execute macro: %s", ScmVisMacro.c_str()); MvRequest reply = MvApplication::waitService("macro", req, error); - //Call myself to process the macro reply request + // Call myself to process the macro reply request if (!error && reply) { const char* myname = reply("_REPLY"); MvApplication::callService(myname, reply, nullptr); @@ -308,9 +308,9 @@ return; } - //out=MvRequest("FLEXTRA_INPUT"); - //out("INPUT_DATA_PATH")=outPath.c_str(); - //out("AVAILABLE_FILE_PATH")=fAvailable.c_str(); + // out=MvRequest("FLEXTRA_INPUT"); + // out("INPUT_DATA_PATH")=outPath.c_str(); + // out("AVAILABLE_FILE_PATH")=fAvailable.c_str(); std::cout << "--------------ScmVisualiser::serve() out--------------" << std::endl; out.print(); diff -Nru metview-5.17.4/metview/src/ScmEditor/MvMain.cc metview-5.19.2/metview/src/ScmEditor/MvMain.cc --- metview-5.17.4/metview/src/ScmEditor/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/ScmEditor/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -45,7 +45,7 @@ MvQApplication::writePidToFile(in); - //Create the qt application. The appname must be unique! + // Create the qt application. The appname must be unique! std::string appName = MvApplication::buildAppName("ScmDataEditor"); MvQApplication app(argc, argv, appName.c_str(), {"examiner", "window", "scmEditor"}); @@ -63,6 +63,6 @@ // register for callbacks from Desktop app.registerToDesktop(browser); - //Enter the app loop + // Enter the app loop app.exec(); } diff -Nru metview-5.17.4/metview/src/ScmEditor/ScmDataEditor.cc metview-5.19.2/metview/src/ScmEditor/ScmDataEditor.cc --- metview-5.17.4/metview/src/ScmEditor/ScmDataEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/ScmEditor/ScmDataEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -45,10 +45,10 @@ void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - //Paint everything + // Paint everything QStyledItemDelegate::paint(painter, option, index); - //Paint the border + // Paint the border painter->save(); painter->setPen(pen_); painter->drawRect(option.rect); @@ -70,14 +70,14 @@ setWindowTitle(tr("Metview - Profile Data Editor")); - //Initial size + // Initial size setInitialSize(1100, 800); //---------------------- // Main layout //---------------------- - auto* w = new QWidget(this); + auto* w = new QWidget(this); mainLayout_ = new QVBoxLayout(w); mainLayout_->setContentsMargins(0, 0, 0, 0); mainLayout_->setSpacing(1); @@ -116,7 +116,7 @@ w->setLayout(viewVb); centralSplitter_->addWidget(w); - //Parameter list + // Parameter list parListW_ = new QListWidget(this); parListW_->setFlow(QListView::LeftToRight); parListW_->setWrapping(false); @@ -145,16 +145,16 @@ buttonBox_ = new QDialogButtonBox(this); - savePb_ = buttonBox_->addButton(QDialogButtonBox::Save); - okPb_ = buttonBox_->addButton(QDialogButtonBox::Ok); + savePb_ = buttonBox_->addButton(QDialogButtonBox::Save); + okPb_ = buttonBox_->addButton(QDialogButtonBox::Ok); cancelPb_ = buttonBox_->addButton(QDialogButtonBox::Cancel); - resetPb_ = buttonBox_->addButton(QDialogButtonBox::Reset); + resetPb_ = buttonBox_->addButton(QDialogButtonBox::Reset); savePb_->setDefault(true); savePb_->setEnabled(false); resetPb_->setEnabled(false); - //buttonBox_->addButton(QDialogButtonBox::Close); + // buttonBox_->addButton(QDialogButtonBox::Close); connect(buttonBox_, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotButtonClicked(QAbstractButton*))); @@ -289,14 +289,14 @@ connect(actionPrev_, SIGNAL(triggered(bool)), this, SLOT(slotToPrev(bool))); - //Combo box - //We will add items + signal/slots later in "init"! + // Combo box + // We will add items + signal/slots later in "init"! auto* hb = new QHBoxLayout; hb->setContentsMargins(10, 2, 10, 2); - //Combo box for key profile selection + // Combo box for key profile selection auto* label = new QLabel(tr("&Steps:")); - stepCombo_ = new QComboBox; + stepCombo_ = new QComboBox; stepCombo_->view()->setTextElideMode(Qt::ElideNone); stepCombo_->setSizeAdjustPolicy(QComboBox::AdjustToContents); label->setBuddy(stepCombo_); @@ -306,7 +306,7 @@ auto* wh = new QWidget; wh->setLayout(hb); - //Slot for the ombo will be added later in init + // Slot for the ombo will be added later in init MvQMainWindow::MenuType menuType = MvQMainWindow::StepMenu; menuItems_[menuType].push_back(new MvQMenuItem(wh)); @@ -328,7 +328,7 @@ icon.addPixmap(QPixmap(QString::fromUtf8(":/examiner/fileInfo.svg")), QIcon::Normal, QIcon::Off); actionFileInfo_->setIcon(icon); - //Define routines + // Define routines connect(actionFileInfo_, SIGNAL(toggled(bool)), fileInfoLabel_, SLOT(setVisible(bool))); @@ -377,26 +377,26 @@ data_ = data; - //Set actual consistency status in data + // Set actual consistency status in data data_->needConsistency(actionConsistency_->isChecked()); - //Get editable variables + // Get editable variables editableVars_ << data_->mlVar(MvScm::TempML) << data_->mlVar(MvScm::WindUML) << data_->mlVar(MvScm::WindVML) << data_->mlVar(MvScm::SpHumML) << data_->mlVar(MvScm::RelHumML) << data_->mlVar(MvScm::CloudLiqML) << data_->mlVar(MvScm::CloudIceML) << data_->mlVar(MvScm::OzoneML); - //Soil + // Soil editableVars_ << data_->soilVar(MvScm::TempSoil) << data_->soilVar(MvScm::HumSoil); - //Siurface + // Siurface for (auto i : data_->surfaceLevel()) editableVars_ << i; - //This method will select a paramater in the table view! This will trigger an uopdate in he profile view as well! + // This method will select a paramater in the table view! This will trigger an uopdate in he profile view as well! dataPanel_->init(data, editableVars_); QFont editableFont; editableFont.setBold(true); - //Par list widget + // Par list widget for (int i = 0; i < static_cast(data_->modelLevel().size()); i++) { QString name = QString::fromStdString(data_->modelLevel().at(i)->name()); if (name.size() == 1) { @@ -423,8 +423,8 @@ connect(parListW_, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(slotParamSelectedFromList(QListWidgetItem*, QListWidgetItem*))); - //Steps - editPix_ = QPixmap(QString::fromUtf8(":/scmEditor/edit.svg")); + // Steps + editPix_ = QPixmap(QString::fromUtf8(":/scmEditor/edit.svg")); noEditPix_ = QPixmap(editPix_.size()); noEditPix_.fill(QColor(255, 255, 255, 0)); @@ -450,7 +450,7 @@ actionOverwrite_->setEnabled(false); } - //Fileinfo label + // Fileinfo label updateFileInfoLabel(); } @@ -476,9 +476,9 @@ profileData_->setObserver(this); lst << profileData_; - //Temperature + // Temperature if (data_->mlVar(MvScm::TempML) == var) { - //Surf + // Surf MvScmVar* skinT = data_->surfVar(MvScm::TempSurf); if (skinT) { auto* p = new MvScmProfileData(data_, skinT, step); @@ -486,7 +486,7 @@ p->setObserver(this); } - //Soil + // Soil MvScmVar* soilT = data_->soilVar(MvScm::TempSoil); if (soilT) { auto* p = new MvScmProfileData(data_, soilT, step); @@ -497,7 +497,7 @@ profilePanel_->setProfile(lst, editable); - //Set the current index for param list + // Set the current index for param list updateParListW(var); } @@ -551,7 +551,7 @@ data_->modelLevelNum(), QString::fromStdString(data_->id())); } -//Callback from the table view editor +// Callback from the table view editor void ScmDataEditor::slotDataEdited(const MvScmProfileChange& item) { profilePanel_->update(item); @@ -564,7 +564,7 @@ resetPb_->setEnabled(true); } -//ProfileObserver method - Callback from curve plot editor, via the data object +// ProfileObserver method - Callback from curve plot editor, via the data object void ScmDataEditor::profileEdited(const MvScmProfileChange& item) { dataPanel_->update(item); @@ -692,7 +692,7 @@ if (showEditable) { for (int i = 0; i < parListW_->count(); i++) { QListWidgetItem* item = parListW_->item(i); - int index = item->data(Qt::UserRole).toInt(); + int index = item->data(Qt::UserRole).toInt(); if (!editableVars_.contains(data_->modelLevel().at(index))) { item->setHidden(true); } @@ -715,7 +715,7 @@ QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Yes) { data_->overwrite(ts); - //Clear the edithistory + // Clear the edithistory editHistory_.clear(); updateEditActionStatus(); } @@ -779,7 +779,7 @@ settings.beginGroup("mainWindow"); settings.setValue("geometry", saveGeometry()); - //settings.setValue("mainSplitter",mainSplitter_->saveState()); + // settings.setValue("mainSplitter",mainSplitter_->saveState()); settings.setValue("centralSplitter", centralSplitter_->saveState()); settings.setValue("actionFileInfoStatus", actionFileInfo_->isChecked()); settings.setValue("actionShowEditableStatus", actionShowEditable_->isChecked()); @@ -795,7 +795,7 @@ settings.beginGroup("mainWindow"); restoreGeometry(settings.value("geometry").toByteArray()); - //mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); + // mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); centralSplitter_->restoreState(settings.value("centralSplitter").toByteArray()); if (settings.value("actionFileInfoStatus").isNull()) diff -Nru metview-5.17.4/metview/src/ScmEditor/ScmDataEditor.h metview-5.19.2/metview/src/ScmEditor/ScmDataEditor.h --- metview-5.17.4/metview/src/ScmEditor/ScmDataEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/ScmEditor/ScmDataEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -51,7 +51,7 @@ void init(MvScm*); void updateFileInfoLabel(); - //From MvScmProfileObserver + // From MvScmProfileObserver void profileEdited(const MvScmProfileChange&); public slots: diff -Nru metview-5.17.4/metview/src/Spectra/Spectra.cc metview-5.19.2/metview/src/Spectra/Spectra.cc --- metview-5.17.4/metview/src/Spectra/Spectra.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Spectra/Spectra.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,6 +27,10 @@ if (vals_) delete[] vals_; } + + SpectraData(const SpectraData&) = delete; + SpectraData& operator=(const SpectraData&) = delete; + void setMetaData(MvField&); double* vals_{nullptr}; @@ -57,8 +61,8 @@ protected: void process(MvRequest&, MvRequest&); - virtual void getInputParameters(MvRequest&) = 0; - virtual void createOutputRequest(MvRequest&) = 0; + virtual void getInputParameters(MvRequest&) = 0; + virtual void createOutputRequest(MvRequest&) = 0; virtual void buildAxis(MvRequest&, MvRequest&) = 0; void computeSpectra(MvFieldSet& fs, bool firstFieldOnly); @@ -88,7 +92,7 @@ void buildAxis(MvRequest&, MvRequest&) override; void compute(); - //these params are not used at all + // these params are not used at all std::string tension_; // interpolation for smoothing curves bool smooth_{false}; // allows the curves to be smoothed }; @@ -98,10 +102,10 @@ { std::string t; shortName_ = f.getGribKeyValueString("shortName"); - units_ = f.getGribKeyValueString("units"); - level_ = f.getGribKeyValueString("level"); + units_ = f.getGribKeyValueString("units"); + level_ = f.getGribKeyValueString("level"); levelType_ = f.getGribKeyValueString("typeOfLevel"); - stepStr_ = f.getGribKeyValueString("stepHumanReadable"); + stepStr_ = f.getGribKeyValueString("stepHumanReadable"); if (stepStr_.empty()) { stepStr_ = f.getGribKeyValueString("step"); stepStr_ += f.getGribKeyValueString("stepUnits"); @@ -155,13 +159,13 @@ void SpectraBase::computeSpectra(MvFieldSet& fs, bool firstFieldOnly) { MvFieldSetIterator iter(fs); - //iter.sort("STEP"); + // iter.sort("STEP"); while (MvField& f = iter()) { MvFieldExpandThenFree xpf(f); if (f.isSpectral()) { - int spJ = static_cast(f.getGribKeyValueLong("J")); - int nMax = std::min(trunc_, spJ); - xMax_ = std::max(xMax_, nMax); + int spJ = static_cast(f.getGribKeyValueLong("J")); + int nMax = std::min(trunc_, spJ); + xMax_ = std::max(xMax_, nMax); auto* spVal = new SpectraData(nMax + 1); for (int n = 0; n <= nMax; n++) { double v = 0.; @@ -184,8 +188,8 @@ void SpectraGraph::getInputParameters(MvRequest& in) { - xMax_ = trunc_; - smooth_ = (strcmp(in("SMOOTHING"), "YES") == 0) ? true : false; + xMax_ = trunc_; + smooth_ = (strcmp(in("SMOOTHING"), "YES") == 0) ? true : false; tension_ = (const char*)in("TENSION"); if (const char* ch = in("X_AXIS_TYPE")) { if (strcmp(ch, "LOGARITHMIC") == 0) { @@ -215,7 +219,7 @@ MvRequest vaxis; buildAxis(vaxis, haxis); out("HORIZONTAL_AXIS") = haxis; - out("VERTICAL_AXIS") = vaxis; + out("VERTICAL_AXIS") = vaxis; MvRequest title; buildTitle(title); @@ -247,7 +251,7 @@ } else if (!spec_.empty()) { SpectraData* sp = spec_[0]; - std::string t = "Param: " + sp->shortName_ + " [" + sp->units_ + "] "; + std::string t = "Param: " + sp->shortName_ + " [" + sp->units_ + "] "; t += " Level: "; if (sp->levelType_ == "isobaricInhPa") { t += sp->level_ + "hPa"; @@ -274,14 +278,14 @@ void SpectraGraph::buildAxis(MvRequest& vaxis, MvRequest& haxis) { - vaxis = MvRequest("MAXIS"); - vaxis("AXIS_ORIENTATION") = "VERTICAL"; + vaxis = MvRequest("MAXIS"); + vaxis("AXIS_ORIENTATION") = "VERTICAL"; vaxis("AXIS_TICK_LABEL_ORIENTATION") = "HORIZONTAL"; - vaxis("AXIS_TITLE_TEXT") = "Amplitude"; + vaxis("AXIS_TITLE_TEXT") = "Amplitude"; - haxis = MvRequest("MAXIS"); + haxis = MvRequest("MAXIS"); haxis("AXIS_ORIENTATION") = "HORIZONTAL"; - haxis("AXIS_TITLE_TEXT") = "Legendre polynomial order (n)"; + haxis("AXIS_TITLE_TEXT") = "Legendre polynomial order (n)"; } diff -Nru metview-5.17.4/metview/src/Stations/CMakeLists.txt metview-5.19.2/metview/src/Stations/CMakeLists.txt --- metview-5.17.4/metview/src/Stations/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Stations/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ ecbuild_add_executable( TARGET station SOURCES Station.cc utils.cc station.h DEFINITIONS ${METVIEW_EXTRA_DEFINITIONS} - INCLUDES ${METVIEW_STANDARD_INCLUDES} + INCLUDES ${METVIEW_STANDARD_INCLUDES} ${GDBM_INCLUDE} LIBS ${STANDARD_METVIEW_LIBS} ${GDBM_LIB} ) diff -Nru metview-5.17.4/metview/src/Stations/fmt_stcat.c metview-5.19.2/metview/src/Stations/fmt_stcat.c --- metview-5.17.4/metview/src/Stations/fmt_stcat.c 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Stations/fmt_stcat.c 2023-07-15 08:28:47.000000000 +0000 @@ -43,9 +43,9 @@ void flush(void) { - char* p = station; + char* p = station; int nospace = 0; - int space = 0; + int space = 0; while (*p) { switch (*p) { @@ -58,7 +58,7 @@ case '/': putchar('-'); nospace = 1; - space = 0; + space = 0; break; case ',': @@ -68,7 +68,7 @@ putchar('.'); else putchar(*p); - space = 1; + space = 1; nospace = 1; break; @@ -96,7 +96,7 @@ else putchar(*p); nospace = 0; - space = 0; + space = 0; break; } @@ -110,9 +110,9 @@ char* argv[]; { unsigned pilot = 0; - unsigned temp = 0; + unsigned temp = 0; unsigned synop = 0; - unsigned f = 0; + unsigned f = 0; char* p; char* ptr; char st[256]; @@ -120,13 +120,13 @@ char buff[1024]; long n, m; int first = 1; - ptr = buff; + ptr = buff; gets(buff); gets(buff); while (gets(buff)) { - temp = 0; + temp = 0; pilot = 0; synop = 0; diff -Nru metview-5.17.4/metview/src/Stations/Station.cc metview-5.19.2/metview/src/Stations/Station.cc --- metview-5.17.4/metview/src/Stations/Station.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Stations/Station.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,23 +40,22 @@ void serve(MvRequest&, MvRequest&); private: - bool bFailError_; - char mode; + bool bFailError_{true}; + char mode{0}; position pos; station st; - int ident; - double north, west, south, east; - double point_lat, point_lon, threshold; + int ident{0}; + double north{90.}; + double west{-180.}; + double south{-90.}; + double east{180.}; + double point_lat{0.}; + double point_lon{0.}; + double threshold{0.1}; }; StationService::StationService() : - MvService("STATIONS"), - bFailError_(true), - mode(0), - north(90.0), - west(-180.0), - south(-90.0), - east(180.0) + MvService("STATIONS") { } @@ -80,11 +79,11 @@ if (count < MAX_LIST) { MvRequest y("STATION"); - y("NAME") = nice_name(st.name); - y("IDENT") = st.ident; - y("LATITUDE") = st.pos.lat / 100.0; + y("NAME") = nice_name(st.name); + y("IDENT") = st.ident; + y("LATITUDE") = st.pos.lat / 100.0; y("LONGITUDE") = st.pos.lon / 100.0; - y("HEIGHT") = st.pos.station_height; + y("HEIGHT") = st.pos.station_height; out = out + y; } @@ -119,19 +118,19 @@ break; case 'I': - mode = 'i'; + mode = 'i'; ident = in("IDENT"); break; case 'W': - mode = 'i'; + mode = 'i'; ident = in("WMO_BLOCK"); break; case 'P': - mode = 'l'; + mode = 'l'; threshold = in("THRESHOLD"); - north = in("POSITION", 0); + north = in("POSITION", 0); north += threshold; west = in("POSITION", 1); west -= threshold; @@ -142,15 +141,15 @@ break; case 'A': - mode = 'l'; + mode = 'l'; north = in("AREA", 0); - west = in("AREA", 1); + west = in("AREA", 1); south = in("AREA", 2); - east = in("AREA", 3); + east = in("AREA", 3); if (north < south) { double tmp = north; - north = south; - south = tmp; + north = south; + south = tmp; } break; } @@ -189,7 +188,7 @@ if (in.countValues("NAME") == 1) { name = in("NAME"); strcpy(st.name, upcase(name)); - k.dptr = (char*)&st.name; + k.dptr = (char*)&st.name; k.dsize = strlen(st.name) + 1; key = gdbm_fetch(db, k); @@ -206,8 +205,8 @@ if (in.countValues("IDENT") == 1) if (ident >= 01000) { st.ident = ident; - k.dptr = (char*)&st.ident; - k.dsize = sizeof(st.ident); + k.dptr = (char*)&st.ident; + k.dsize = sizeof(st.ident); key = gdbm_fetch(db, k); @@ -249,7 +248,7 @@ std::memcpy(&pos, key.dptr, sizeof(pos)); point_lat = ((double)pos.lat) / 100.0; point_lon = ((double)pos.lon) / 100.0; - ok = inbox(point_lat, point_lon, north, west, south, east); + ok = inbox(point_lat, point_lon, north, west, south, east); break; } @@ -275,14 +274,14 @@ bool StationService::serve_EPS(MvRequest& in, MvRequest& out) { - //serve_WMO( in, out ); //-- not yet implementd, use WMO!!!! + // serve_WMO( in, out ); //-- not yet implementd, use WMO!!!! const char* name; std::ifstream* EPS_file = nullptr; station st; if (open_EPS_stationfile(EPS_file)) { while (read_one_station(EPS_file, st)) { - int n = 0; + int n = 0; int ok = 0; switch (mode) { @@ -302,7 +301,7 @@ case 'l': point_lat = ((double)st.pos.lat) / 100.0; point_lon = ((double)st.pos.lon) / 100.0; - ok = inbox(point_lat, point_lon, north, west, south, east); + ok = inbox(point_lat, point_lon, north, west, south, east); break; } @@ -322,8 +321,8 @@ MvRequest y("STATION"); - y("NAME") = in("NAME"); - y("LATITUDE") = in("POSITION", 0); + y("NAME") = in("NAME"); + y("LATITUDE") = in("POSITION", 0); y("LONGITUDE") = in("POSITION", 1); y("THRESHOLD") = in("THRESHOLD"); diff -Nru metview-5.17.4/metview/src/Stations/utils.cc metview-5.19.2/metview/src/Stations/utils.cc --- metview-5.17.4/metview/src/Stations/utils.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Stations/utils.cc 2023-07-15 08:28:47.000000000 +0000 @@ -117,7 +117,7 @@ /* Write station name nicely with first character(s) as upper character */ static char buf[250]; - int i = 0; + int i = 0; int is_first = 1; while (*p) { @@ -169,7 +169,7 @@ if (!open_cached_EPS_stationfile(EPS_file)) { //-- real-time cached file not ok => use one stored in 'etc' const char* rootdir = getenv("METVIEW_DIR_SHARE"); - Cached path = Cached(rootdir) + "/etc/EPS_stations"; + Cached path = Cached(rootdir) + "/etc/EPS_stations"; std::cout << "Opening EPS stationfile in 'etc' directory" << std::endl; EPS_file = new std::ifstream((const char*)path, std::ios::in); } @@ -201,7 +201,7 @@ << std::ends; std::string filename = helper.str(); - EPS_file = new std::ifstream(filename.c_str(), std::ios::in); + EPS_file = new std::ifstream(filename.c_str(), std::ios::in); if (EPS_file->good()) { std::cout << "opened cached EPS stationfile" << std::endl; diff -Nru metview-5.17.4/metview/src/Stations/writebase.c metview-5.19.2/metview/src/Stations/writebase.c --- metview-5.17.4/metview/src/Stations/writebase.c 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Stations/writebase.c 2023-07-15 08:28:47.000000000 +0000 @@ -35,18 +35,18 @@ position pos; extern char* optarg; extern int optind, opterr; - char mode = 0; + char mode = 0; int errflg = 0, counter = 0; char* p; char base[1024]; char last_char = 'X'; - int blocksize = 0; /* less than 512 forces the system default */ + int blocksize = 0; /* less than 512 forces the system default */ while ((c = getopt(argc, argv, "l:n:i:")) != -1) switch (c) { case 'l': case 'n': case 'i': - mode = c; + mode = c; defbase = optarg; break; @@ -84,7 +84,7 @@ st.pos.flags, tmp_buf); /* Eat multiple whitespace to make the name look OK. */ - p = tmp_buf; + p = tmp_buf; counter = 0; while (*p) { @@ -94,7 +94,7 @@ } else { st.name[counter] = *p; - last_char = *p; + last_char = *p; p++; counter++; } @@ -104,22 +104,22 @@ switch (mode) { case 'i': - key.dptr = (char*)&st.ident; + key.dptr = (char*)&st.ident; key.dsize = sizeof(st.ident); break; case 'l': - key.dptr = (char*)&st.pos; + key.dptr = (char*)&st.pos; key.dsize = sizeof(st.pos); break; case 'n': - key.dptr = (char*)&st.name; + key.dptr = (char*)&st.name; key.dsize = strlen(st.name) + 1; break; default: break; } - content.dptr = (char*)&st; + content.dptr = (char*)&st; content.dsize = sizeof(st) - sizeof(st.name) + strlen(st.name) + 1; gdbm_store(db, key, content, GDBM_INSERT); diff -Nru metview-5.17.4/metview/src/StdAppManager/StdAppManager.cc metview-5.19.2/metview/src/StdAppManager/StdAppManager.cc --- metview-5.17.4/metview/src/StdAppManager/StdAppManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/StdAppManager/StdAppManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ // Get prefix std::string verb = in.getVerb(); - size_t found = verb.find('_'); + size_t found = verb.find('_'); if (found == std::string::npos) { setError(1, "StdAppManager-> Visualiser verb not found"); return; @@ -33,7 +33,7 @@ // Build the application verb std::string plotType = prefix + "PLOT_TYPE"; - const char* type = in(plotType.c_str()); + const char* type = in(plotType.c_str()); prefix += type; // special case - INPUT_XY_AREA only exists in Metview - @@ -46,7 +46,7 @@ out = in; out.setVerb(prefix.c_str()); out.unsetParam(plotType.c_str()); - out("_VERB") = prefix.c_str(); + out("_VERB") = prefix.c_str(); out("_CLASS") = prefix.c_str(); // Check missing values @@ -76,7 +76,7 @@ // Replace nil by missing value bool found = false; - const char* cval; + const char* cval = nullptr; std::vector dval; out.iterInit(param.c_str()); while (out.iterGetNextValue(cval)) { diff -Nru metview-5.17.4/metview/src/StdAppManager/StdAppManager.h metview-5.19.2/metview/src/StdAppManager/StdAppManager.h --- metview-5.17.4/metview/src/StdAppManager/StdAppManager.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/StdAppManager/StdAppManager.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,9 @@ StdAppManager(const char* kw); // Destructor - ~StdAppManager() {} + ~StdAppManager() override = default; - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; protected: // Handle missing value. For example: diff -Nru metview-5.17.4/metview/src/Stvl/Stvl.cc metview-5.19.2/metview/src/Stvl/Stvl.cc --- metview-5.17.4/metview/src/Stvl/Stvl.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Stvl/Stvl.cc 2023-07-15 08:28:47.000000000 +0000 @@ -175,7 +175,7 @@ // find out the stvl script path std::string stvlScript = "mv_stvl"; - char* mvbin = getenv("METVIEW_BIN"); + char* mvbin = getenv("METVIEW_BIN"); if (mvbin == nullptr) { throw MvException("No METVIEW_BIN env variable is defined. Cannot locate script " + stvlScript + "!"); } @@ -192,8 +192,8 @@ // define log file std::string logFileName = "log.txt"; - std::string logFile = Path(tmpPath).add(logFileName).str(); - int maxLogLineNum = 1000; + std::string logFile = Path(tmpPath).add(logFileName).str(); + int maxLogLineNum = 1000; // define res file std::string resFileName = "res.gpt"; @@ -206,7 +206,7 @@ int ret = system(cmd.c_str()); - //If the script failed, read log file and write it into LOG_EROR + // If the script failed, read log file and write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { marslog(LOG_EROR, "Failed to perform STVL retrieval!"); metview::writeFileToLogErr(logFile, maxLogLineNum); @@ -248,7 +248,7 @@ else { std::string fType = ScanFileType(rp.str().c_str()); if (fType == "GEOPOINTS" || fType == "GEOPOINTSET") { - out = MvRequest(fType.c_str()); + out = MvRequest(fType.c_str()); out("PATH") = rp.str().c_str(); } else { diff -Nru metview-5.17.4/metview/src/Thermo/BufrThermo.cc metview-5.19.2/metview/src/Thermo/BufrThermo.cc --- metview-5.17.4/metview/src/Thermo/BufrThermo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/BufrThermo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,13 +20,13 @@ #include -//using namespace metview; +// using namespace metview; -const int TOBSTEMP = 12001; -const int TOBSTD = 12003; -const int TOBSDIR = 11001; +const int TOBSTEMP = 12001; +const int TOBSTD = 12003; +const int TOBSDIR = 11001; const int TOBSSTRENGTH = 11002; -const int TOBSZ = 10003; +const int TOBSZ = 10003; bool BufrStation::initObsIter(MvObsSetIterator& iter) const { @@ -35,15 +35,18 @@ MvLocation loc2(lat_ - threshold_, lon_ + threshold_); iter.setArea(loc1, loc2); return true; - } else if (pointMode_ == WmoNameMode) { + } + else if (pointMode_ == WmoNameMode) { iter.setIdentKey("stationOrSiteName"); iter.setIdentKey("shipOrMobileLandStationIdentifier"); iter.setIdentValue(wmoName_); return true; - } else if (pointMode_ == WmoIdentMode) { + } + else if (pointMode_ == WmoIdentMode) { iter.setWmoStation(wmoIdent_); return true; - } else if (pointMode_ == WigosMode) { + } + else if (pointMode_ == WigosMode) { iter.setWigosId(wigosSeries_, wigosIssuer_, wigosIssueNumber_, wigosLocalName_); return true; } @@ -68,13 +71,13 @@ { pCount_ = 0; - //Deallocates memory - T_ = std::vector(); + // Deallocates memory + T_ = std::vector(); TD_ = std::vector(); - U_ = std::vector(); - V_ = std::vector(); - P_ = std::vector(); - Z_ = std::vector(); + U_ = std::vector(); + V_ = std::vector(); + P_ = std::vector(); + Z_ = std::vector(); // Allocate memory if (nlev_ > 0) { @@ -100,12 +103,12 @@ assert(Z_.size() == n); for (int i = 0; i < nlev_; i++) { - T_[i] = MissingValue; + T_[i] = MissingValue; TD_[i] = MissingValue; - U_[i] = MissingValue; - V_[i] = MissingValue; - P_[i] = MissingValue; - Z_[i] = MissingValue; + U_[i] = MissingValue; + V_[i] = MissingValue; + P_[i] = MissingValue; + Z_[i] = MissingValue; } } @@ -119,13 +122,14 @@ MvLog().info() << "POINT_SELECTION=" << ch; auto ps = std::string(ch); - if (ps == "COORDINATES") { + if (ps == "COORDINATES") { station_.pointMode_ = BufrStation::CoordMode; in.getValue(station_.lat_, "COORDINATES", 0); in.getValue(station_.lon_, "COORDINATES", 1); station_.threshold_ = in("THRESHOLD"); checkThreshold(station_.threshold_); - } else if (ps == "WMO_NAME") { + } + else if (ps == "WMO_NAME") { station_.pointMode_ = BufrStation::WmoNameMode; const char* chName = in("WMO_NAME"); if (!chName || strcmp(chName, "") == 0) { @@ -133,34 +137,37 @@ } assert(chName); station_.wmoName_ = std::string(chName); - } else if (ps == "WMO_IDENT") { + } + else if (ps == "WMO_IDENT") { station_.wmoIdent_ = in("WMO_IDENT"); - if(checkIdent(station_.wmoIdent_, false)) { + if (checkIdent(station_.wmoIdent_, false)) { station_.pointMode_ = BufrStation::WmoIdentMode; } - } else if (ps == "WIGOS") { + } + else if (ps == "WIGOS") { station_.pointMode_ = BufrStation::WigosMode; - if (const char *wgCh = in("WIGOS_SERIES")) { + if (const char* wgCh = in("WIGOS_SERIES")) { station_.wigosSeries_ = (int)in("WIGOS_SERIES"); } - if (const char *wgCh = in("WIGOS_ISSUER")) { + if (const char* wgCh = in("WIGOS_ISSUER")) { station_.wigosIssuer_ = (int)in("WIGOS_ISSUER"); } - if (const char *wgCh = in("WIGOS_ISSUE_NUMBER")) { + if (const char* wgCh = in("WIGOS_ISSUE_NUMBER")) { station_.wigosIssueNumber_ = (int)in("WIGOS_ISSUE_NUMBER"); } - if (const char *wgCh = in("WIGOS_LOCAL_NAME")) { + if (const char* wgCh = in("WIGOS_LOCAL_NAME")) { station_.wigosLocalName_ = std::string(wgCh); } - } else if (ps == "STATION") { + } + else if (ps == "STATION") { MvRequest stReq = in.getSubrequest("STATION"); if (!stReq) { throw MvException(moduleLabel_ + "No STATION specified"); } if (const char* chIdent = stReq("IDENT")) { station_.wmoIdent_ = stReq("IDENT"); - if(checkIdent(station_.wmoIdent_, false)) { - station_.pointMode_ = BufrStation::WmoIdentMode; + if (checkIdent(station_.wmoIdent_, false)) { + station_.pointMode_ = BufrStation::WmoIdentMode; } } if (station_.pointMode_ == BufrStation::NoMode) { @@ -220,13 +227,14 @@ // Evaluate dimensions // TODO: Remove this function after updating library MvNetCDF to create - // files of type Netcdf4 (allowing multiple unlimited dimensions) + // files of type Netcdf4 (allowing multiple unlimited dimensions) int msgNum = 0; evaluateNLevels(iter, msgNum, nlev_); if (msgNum <= 0) { throw MvException(moduleLabel_ + "No BUFR messages matching the required location and observation type found in input!"); - } else if (nlev_ <= 0) { + } + else if (nlev_ <= 0) { throw MvException(moduleLabel_ + "No pressure levels found in input!"); } @@ -246,22 +254,22 @@ obsset.rewind(); counter_ = 0; while ((obs = iter())) { -// // Skip PILOT -// if (obs.messageSubtype() != 101 && obs.messageSubtype() != 109 && obs.messageSubtype() != 4) //obs.messageSubtype() == 91 ) //-- ECMWF code for PILOT! -// { -// setError(0, "BufrThermo-> Skip PILOT soundings (full TEMP sounding needed)"); -// continue; -// } + // // Skip PILOT + // if (obs.messageSubtype() != 101 && obs.messageSubtype() != 109 && obs.messageSubtype() != 4) //obs.messageSubtype() == 91 ) //-- ECMWF code for PILOT! + // { + // setError(0, "BufrThermo-> Skip PILOT soundings (full TEMP sounding needed)"); + // continue; + // } - //obs.printAllValues(); + // obs.printAllValues(); // Initialise data values storage with MissingValue this->initialiseDataMemory(); // Get/compute data values for all pressure levels - int ic = 0; + int ic = 0; float PrevLevel = FLT_MAX; - float flevel = obs.firstPressureLevel(); + float flevel = obs.firstPressureLevel(); while (flevel != MissingValue) { //-- Pressure levels decrease in the main sounding data. //-- At the end of msg there can be data for "special levels" @@ -270,11 +278,11 @@ if (flevel >= PrevLevel) break; - float myT = obs.valueByPressureLevel(flevel, obsTemp); + float myT = obs.valueByPressureLevel(flevel, obsTemp); float myDew = obs.valueByPressureLevel(flevel, obsTd); float myDir = obs.valueByPressureLevel(flevel, obsDirection); float myStr = obs.valueByPressureLevel(flevel, obsStrength); - float myZ = obs.valueByPressureLevel(flevel, obsZ); + float myZ = obs.valueByPressureLevel(flevel, obsZ); // Temperature value, K -> C if (myT != MissingValue) @@ -301,7 +309,7 @@ ic++; PrevLevel = flevel; - flevel = obs.nextPressureLevel(); + flevel = obs.nextPressureLevel(); } // end while // Consistency check @@ -351,15 +359,15 @@ << std::setw(2) << tmpdate.GetMin(); // Get netcdf variables - MvNcVar* time = netcdf.getVariable(sTIME); - MvNcVar* nlev = netcdf.getVariable(sNLEV); - MvNcVar* temp = netcdf.getVariable(sTEMP); - MvNcVar* dew = netcdf.getVariable(sDEWPOINT); - MvNcVar* press = netcdf.getVariable(sPRESSURE); + MvNcVar* time = netcdf.getVariable(sTIME); + MvNcVar* nlev = netcdf.getVariable(sNLEV); + MvNcVar* temp = netcdf.getVariable(sTEMP); + MvNcVar* dew = netcdf.getVariable(sDEWPOINT); + MvNcVar* press = netcdf.getVariable(sPRESSURE); MvNcVar* geopot = netcdf.getVariable(sGEOPOTENTIAL); - MvNcVar* uwind = netcdf.getVariable(sU); - MvNcVar* vwind = netcdf.getVariable(sV); - MvNcVar* xwind = netcdf.getVariable(sXWIND); + MvNcVar* uwind = netcdf.getVariable(sU); + MvNcVar* vwind = netcdf.getVariable(sV); + MvNcVar* xwind = netcdf.getVariable(sXWIND); if (!time || !temp || !dew || !press || !uwind || !vwind || !xwind) { setError(1, "BufrThermo-> Error accessing netCDF variables"); return false; @@ -455,57 +463,57 @@ bool BufrThermo::createOutputRequest(MvRequest& out) { // Get default parameter to be plotted - //ParamInfo* parInfo = plotVariable(params); - //if ( !parInfo ) + // ParamInfo* parInfo = plotVariable(params); + // if ( !parInfo ) // return false; // Create netCDF data request MvRequest ncDataReq("NETCDF"); - ncDataReq("PATH") = this->ncFileName().c_str(); + ncDataReq("PATH") = this->ncFileName().c_str(); ncDataReq("TEMPORARY") = 1; // Create Temperature output request int thermoId = rand() % 10000; MvRequest dReq("NETCDF_XY_POINTS"); - dReq("NETCDF_DATA") = ncDataReq; + dReq("NETCDF_DATA") = ncDataReq; dReq("NETCDF_Y_VARIABLE") = sPRESSURE.c_str(); dReq("NETCDF_X_VARIABLE") = sTEMP.c_str(); - dReq("_MODULEID") = thermoId; + dReq("_MODULEID") = thermoId; MvRequest gReq("MGRAPH"); - gReq("GRAPH_LINE_COLOUR") = "red"; - gReq("GRAPH_LINE_THICKNESS") = 8; - gReq("GRAPH_MISSING_DATA_MODE") = "join"; - gReq("GRAPH_MISSING_DATA_STYLE") = "solid"; + gReq("GRAPH_LINE_COLOUR") = "red"; + gReq("GRAPH_LINE_THICKNESS") = 8; + gReq("GRAPH_MISSING_DATA_MODE") = "join"; + gReq("GRAPH_MISSING_DATA_STYLE") = "solid"; gReq("GRAPH_MISSING_DATA_THICKNESS") = 8; - gReq("_CLASS") = "MGRAPH"; - gReq("_MODULEID") = thermoId; - gReq("_SKIP_MACRO") = 1; // skip macro converter - MvRequest dataReq = dReq + gReq; + gReq("_CLASS") = "MGRAPH"; + gReq("_MODULEID") = thermoId; + gReq("_SKIP_MACRO") = 1; // skip macro converter + MvRequest dataReq = dReq + gReq; // Create Dewpoint output request dReq("NETCDF_X_VARIABLE") = sDEWPOINT.c_str(); - dReq("_SKIP_MACRO") = 1; // skip macro converter + dReq("_SKIP_MACRO") = 1; // skip macro converter - gReq("GRAPH_LINE_STYLE") = "dash", + gReq("GRAPH_LINE_STYLE") = "dash", gReq("GRAPH_MISSING_DATA_STYLE") = "dash"; // Create wind output request MvRequest wdReq("NETCDF_XY_VECTORS"); - wdReq("NETCDF_DATA") = ncDataReq; - wdReq("NETCDF_Y_POSITION_VARIABLE") = sPRESSURE.c_str(); - wdReq("NETCDF_X_POSITION_VARIABLE") = sXWIND.c_str(); + wdReq("NETCDF_DATA") = ncDataReq; + wdReq("NETCDF_Y_POSITION_VARIABLE") = sPRESSURE.c_str(); + wdReq("NETCDF_X_POSITION_VARIABLE") = sXWIND.c_str(); wdReq("NETCDF_X_COMPONENT_VARIABLE") = sU.c_str(); wdReq("NETCDF_Y_COMPONENT_VARIABLE") = sV.c_str(); - wdReq("_MODULEID") = thermoId; - wdReq("_SKIP_MACRO") = 1; // skip macro converter + wdReq("_MODULEID") = thermoId; + wdReq("_SKIP_MACRO") = 1; // skip macro converter MvRequest wReq("MWIND"); - wReq("WIND_FIELD_TYPE") = "flags"; + wReq("WIND_FIELD_TYPE") = "flags"; wReq("WIND_FLAG_COLOUR") = "black"; - wReq("_CLASS") = "MWIND"; - wReq("_MODULEID") = thermoId; - wReq("_SKIP_MACRO") = 1; // skip macro converter + wReq("_CLASS") = "MWIND"; + wReq("_MODULEID") = thermoId; + wReq("_SKIP_MACRO") = 1; // skip macro converter dataReq = dataReq + dReq + gReq + wdReq + wReq; @@ -537,20 +545,20 @@ // after the GribThermo requests then it will not be associated to the GribThermo's // output data because the existence of a MTEXT request between them. MvRequest titleReq("MTEXT"); - titleReq("TEXT_LINE_1") = this->title().c_str(); + titleReq("TEXT_LINE_1") = this->title().c_str(); titleReq("TEXT_FONT_SIZE") = 0.5; - titleReq("_MODULEID") = thermoId; - titleReq("_SKIP_MACRO") = 1; // skip macro converter + titleReq("_MODULEID") = thermoId; + titleReq("_SKIP_MACRO") = 1; // skip macro converter // If action is not visualisation related then return the netcdf data. // Also, add the visualisation and original requests as hidden parameters. // These may be used later to help the visualisation of the netcdf data. if (!this->isVisualise()) { - out = ncDataReq; - out("_VIEW") = "THERMOVIEW"; - out("_VISUALISE") = titleReq + dataReq; + out = ncDataReq; + out("_VIEW") = "THERMOVIEW"; + out("_VISUALISE") = titleReq + dataReq; out("_VIEW_REQUEST") = viewReq; - out("_MODULEID") = thermoId; + out("_MODULEID") = thermoId; return true; } @@ -579,8 +587,8 @@ // Get first time information from the netcdf file MvNetCDF netcdf(this->ncFileName(), 'r'); MvNcVar* time = netcdf.getVariable(sTIME); - MvNcDim* dim = time->getDimension(1); - int size = dim->size(); + MvNcDim* dim = time->getDimension(1); + int size = dim->size(); std::vector vtime; time->setCurrent(0L); time->get(vtime, 1, size); @@ -593,10 +601,10 @@ // Create title char title[200]; MvNcAtt* tmpatt = netcdf.getAttribute("Coordinates"); - str = tmpatt->as_string(0); - int ipos = str.find('/'); - float lat = atof(str.substr(0, ipos).c_str()); - float lon = atof(str.substr(ipos + 1).c_str()); + str = tmpatt->as_string(0); + int ipos = str.find('/'); + float lat = atof(str.substr(0, ipos).c_str()); + float lon = atof(str.substr(ipos + 1).c_str()); sprintf(title, "%s %s [lat,lon: %.2f,%.2f]", sdate.c_str(), stime.c_str(), lat, lon); @@ -608,7 +616,7 @@ if (ident <= 0) { if (failOnError) { throw MvException(moduleLabel_ + - "Invalid IDENT=" + std::to_string(ident) + " specified"); + "Invalid IDENT=" + std::to_string(ident) + " specified"); } return false; } @@ -619,6 +627,6 @@ { if (threshold < 0 || threshold > 100) { throw MvException(moduleLabel_ + - "Invalid THRESHOLD=" + std::to_string(threshold) + " specified"); + "Invalid THRESHOLD=" + std::to_string(threshold) + " specified"); } } diff -Nru metview-5.17.4/metview/src/Thermo/BufrThermo.h metview-5.19.2/metview/src/Thermo/BufrThermo.h --- metview-5.17.4/metview/src/Thermo/BufrThermo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/BufrThermo.h 2023-07-15 08:28:47.000000000 +0000 @@ -11,16 +11,18 @@ #include "Thermo.h" -namespace metview { +namespace metview +{ class MvObs; class MvObsSetIterator; -} +} // namespace metview class MvNetCDF; class BufrStation { friend class BufrThermo; + public: BufrStation() = default; bool initObsIter(MvObsSetIterator&) const; @@ -28,7 +30,7 @@ protected: double lat_{0}; double lon_{0}; - double threshold_{0.1}; //in degrees + double threshold_{0.1}; // in degrees std::string wmoName_; long wmoIdent_; int wigosSeries_{-1}; @@ -36,7 +38,14 @@ int wigosIssueNumber_{-1}; std::string wigosLocalName_; - enum PointMode {NoMode, CoordMode, WmoNameMode, WmoIdentMode, WigosMode}; + enum PointMode + { + NoMode, + CoordMode, + WmoNameMode, + WmoIdentMode, + WigosMode + }; PointMode pointMode_{NoMode}; }; @@ -87,9 +96,9 @@ void checkThreshold(double threshold) const; // Variables members - int counter_{0}; // number of thermo data - int pCount_{0}; // number of levels - int nlev_{0}; // maximum number of levels + int counter_{0}; // number of thermo data + int pCount_{0}; // number of levels + int nlev_{0}; // maximum number of levels int nTIME_STR_{13}; // 13 - yyyymmddhhmm + 1 ('end of string') std::vector T_; // variables data diff -Nru metview-5.17.4/metview/src/Thermo/DataThermo.cc metview-5.19.2/metview/src/Thermo/DataThermo.cc --- metview-5.17.4/metview/src/Thermo/DataThermo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/DataThermo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,14 +23,6 @@ //_____________________________________________________________________________ MvThermoDataBase::MvThermoDataBase(MvField& fieldToken, const ThermoParams& pars) : - lnspFlag_(false), - counter_(0), - tCount_(0), - dCount_(0), - uCount_(0), - vCount_(0), - pCount_(0), - nTIME_STR_(17), currField_(fieldToken), pars_(&pars) { @@ -52,7 +44,7 @@ void MvThermoDataBase::readOneSetOfFields(MvFieldSetIterator& iter) { const double cBIGDOUBLE = 3.4E35; - const double oneMinute = 1.0 / 24.0; + const double oneMinute = 1.0 / 24.0; // Get time key info this->generateTimeKey(); @@ -110,10 +102,10 @@ // Get netcdf variables // tCount_ and dCount_ should have the same value - long size = tCount_; - MvNcVar* time = netcdf.getVariable(sTIME); - MvNcVar* temp = netcdf.getVariable(sTEMP); - MvNcVar* dew = netcdf.getVariable(sDEWPOINT); + long size = tCount_; + MvNcVar* time = netcdf.getVariable(sTIME); + MvNcVar* temp = netcdf.getVariable(sTEMP); + MvNcVar* dew = netcdf.getVariable(sDEWPOINT); MvNcVar* press = netcdf.getVariable(sPRESSURE); if (!time || !temp || !dew || !press) throw MvException("Thermo-> ERROR accessing netCDF variables"); @@ -221,7 +213,7 @@ void MvThermoDataBase::collectValue(double val) { // Get param and level - int par = currField_.parameter(); + int par = currField_.parameter(); int level = this->getLevel(); // Save param and level values @@ -256,9 +248,9 @@ void MvThermoDataBase::rescaleValues() { for (int i = 0; i < tCount_; i++) { - T_[i] = T_[i] - K2C; + T_[i] = T_[i] - K2C; TD_[i] = TD_[i] - K2C; - P_[i] = P_[i] / 100.; + P_[i] = P_[i] / 100.; } // Re-scale pressure related to the wind @@ -365,7 +357,7 @@ std::string name = pars_->dewPointFormulaType_; for (char& it : name) { char cc = it; - it = (cc == '_') ? ' ' : tolower(cc); + it = (cc == '_') ? ' ' : tolower(cc); } return name; @@ -377,7 +369,7 @@ // Get first time information std::string sdate = timeKey_.substr(0, 8); std::string stime = timeKey_.substr(8, 4); - int istep = atoi(timeKey_.substr(12, 4).c_str()); + int istep = atoi(timeKey_.substr(12, 4).c_str()); // Create title char title[200]; @@ -393,9 +385,9 @@ // Coordinates used may not be the same as the input ones MvNcAtt* tmpatt = netcdf.getAttribute("Coordinates"); std::string str = tmpatt->as_string(0); - int ipos = str.find('/'); - float lat = atof(str.substr(0, ipos).c_str()); - float lon = atof(str.substr(ipos + 1).c_str()); + int ipos = str.find('/'); + float lat = atof(str.substr(0, ipos).c_str()); + float lon = atof(str.substr(ipos + 1).c_str()); sprintf(title, "%s %s step %d [nearest: %.2f,%.2f] %s", sdate.c_str(), stime.c_str(), istep, lat, lon, this->formulaPrintName().c_str()); @@ -433,7 +425,7 @@ void MvThermoDataHalfLevels::processPressure(double val) { lnspFlag_ = true; - LNSP_ = val; + LNSP_ = val; } @@ -454,7 +446,7 @@ void MvThermoDataFullLevels::processPressure(double val) { lnspFlag_ = true; - LNSP_ = val; + LNSP_ = val; } //============================================================== @@ -481,7 +473,7 @@ void MvThermoDataPressureLevels::rescaleValues() { for (int i = 0; i < tCount_; i++) { - T_[i] = T_[i] - K2C; + T_[i] = T_[i] - K2C; TD_[i] = TD_[i] - K2C; } } @@ -498,7 +490,7 @@ void MvThermoDataUkmoNDLevels::collectValue(double val) { // Get param and level - int par = currField_.parameter(); + int par = currField_.parameter(); int level = this->getLevel(); // Save param and level values @@ -555,7 +547,7 @@ void MvThermoDataUkmoNDLevels::rescaleValues() { for (int i = 0; i < tCount_; i++) { - T_[i] = T_[i] - K2C; + T_[i] = T_[i] - K2C; TD_[i] = TD_[i] - K2C; } } diff -Nru metview-5.17.4/metview/src/Thermo/DataThermo.h metview-5.19.2/metview/src/Thermo/DataThermo.h --- metview-5.17.4/metview/src/Thermo/DataThermo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/DataThermo.h 2023-07-15 08:28:47.000000000 +0000 @@ -61,7 +61,7 @@ std::string title(MvNetCDF&); protected: - virtual void computeLevelsTd() = 0; + virtual void computeLevelsTd() = 0; virtual void processPressure(double) = 0; // Re-scale values @@ -91,14 +91,15 @@ std::string formulaPrintName(); // Variable members - bool lnspFlag_; // T: lnsp is available - int counter_; // Number of plots - int tCount_; // Temp count - int dCount_; // Dewpoint count - int uCount_, vCount_; // Wind count - int pCount_; // Pressure/Levels count + bool lnspFlag_{false}; // T: lnsp is available + int counter_{0}; // Number of plots + int tCount_{0}; // Temp count + int dCount_{0}; // Dewpoint count + int uCount_{0}; + int vCount_{0}; // Wind count + int pCount_{0}; // Pressure/Levels count - int nTIME_STR_; // 17 - yyyymmddhhmmstep + 1 ('end of string') + int nTIME_STR_{17}; // 17 - yyyymmddhhmmstep + 1 ('end of string') // Data values storage std::vector T_; // Temperature @@ -108,7 +109,7 @@ std::vector TD_; // Dewpoint std::vector P_; // Pressure std::vector PUV_; // Pressure for wind (can be different from P_) - double LNSP_; + double LNSP_{0.}; std::string timeKey_; diff -Nru metview-5.17.4/metview/src/Thermo/GribThermo.cc metview-5.19.2/metview/src/Thermo/GribThermo.cc --- metview-5.17.4/metview/src/Thermo/GribThermo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/GribThermo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ // Retrieve point selection std::string ps = (const char*)expReq("POINT_SELECTION"); - if (ps == sPointSelection[0]) //Area average + if (ps == sPointSelection[0]) // Area average { pars_.pointType_ = eAreaAverage; expReq.getValue(pars_.lat_, ps.c_str(), 0); //-- n @@ -45,13 +45,13 @@ } else { // Retrieve point extraction - std::string pe = (const char*)expReq("POINT_EXTRACTION"); + std::string pe = (const char*)expReq("POINT_EXTRACTION"); pars_.pointType_ = (pe == "INTERPOLATE") ? eInterpolated : eGridPoint; if (ps == sPointSelection[1]) { expReq.getValue(pars_.lat_, ps.c_str(), 0); expReq.getValue(pars_.lon_, ps.c_str(), 1); } - else if (ps == sPointSelection[2]) //Station + else if (ps == sPointSelection[2]) // Station { MvRequest station; expReq.getValue(station, "STATION"); @@ -64,10 +64,10 @@ pars_.dewPointFormulaType_ = (const char*)expReq("DEW_POINT_FORMULATION"); // Retrieve fields parameter numbers - pars_.uFieldId_ = (int)expReq("U_WIND_PARAM"); - pars_.vFieldId_ = (int)expReq("V_WIND_PARAM"); - pars_.tempId_ = (int)expReq("TEMPERATURE_PARAM"); - pars_.dewId_ = (int)expReq("SPECIFIC_HUMIDITY_PARAM"); + pars_.uFieldId_ = (int)expReq("U_WIND_PARAM"); + pars_.vFieldId_ = (int)expReq("V_WIND_PARAM"); + pars_.tempId_ = (int)expReq("TEMPERATURE_PARAM"); + pars_.dewId_ = (int)expReq("SPECIFIC_HUMIDITY_PARAM"); pars_.lnPressId_ = (int)expReq("LNSP_PARAM"); return true; @@ -146,67 +146,67 @@ bool GribThermo::createOutputRequest(MvRequest& out) { - //MUDE ESTE TESTE PARA UMA FUNCAO. SUBSTITUA TAMBEM NA SUBROUTINA ACIMA - // If it is not a GRIB data then it has been already processed - // if ( strcmp(pars_.dataReq_.getVerb(),"GRIB") != 0 ) - // return createSimpleOutputRequest(out); + // MUDE ESTE TESTE PARA UMA FUNCAO. SUBSTITUA TAMBEM NA SUBROUTINA ACIMA + // If it is not a GRIB data then it has been already processed + // if ( strcmp(pars_.dataReq_.getVerb(),"GRIB") != 0 ) + // return createSimpleOutputRequest(out); // Get default parameter to be plotted - //ParamInfo* parInfo = plotVariable(params); - //if ( !parInfo ) + // ParamInfo* parInfo = plotVariable(params); + // if ( !parInfo ) // return false; // Create netCDF data request MvRequest ncDataReq("NETCDF"); - ncDataReq("PATH") = this->ncFileName().c_str(); + ncDataReq("PATH") = this->ncFileName().c_str(); ncDataReq("TEMPORARY") = 1; // Create Temperature output request int thermoId = rand() % 10000; MvRequest outd("NETCDF_XY_POINTS"); - outd("NETCDF_DATA") = ncDataReq; + outd("NETCDF_DATA") = ncDataReq; outd("NETCDF_Y_VARIABLE") = sPRESSURE.c_str(); outd("NETCDF_X_VARIABLE") = sTEMP.c_str(); - outd("_MODULEID") = thermoId; + outd("_MODULEID") = thermoId; MvRequest gReq("MGRAPH"); - gReq("GRAPH_LINE_COLOUR") = "red"; + gReq("GRAPH_LINE_COLOUR") = "red"; gReq("GRAPH_LINE_THICKNESS") = 8; - gReq("_CLASS") = "MGRAPH"; - gReq("_MODULEID") = thermoId; - gReq("_SKIP_MACRO") = 1; // skip macro converter - outd = outd + gReq; + gReq("_CLASS") = "MGRAPH"; + gReq("_MODULEID") = thermoId; + gReq("_SKIP_MACRO") = 1; // skip macro converter + outd = outd + gReq; // Create Dewpoint output request MvRequest outtd("NETCDF_XY_POINTS"); - outtd("NETCDF_DATA") = ncDataReq; + outtd("NETCDF_DATA") = ncDataReq; outtd("NETCDF_Y_VARIABLE") = sPRESSURE.c_str(); outtd("NETCDF_X_VARIABLE") = sDEWPOINT.c_str(); - outtd("_MODULEID") = thermoId; - outtd("_SKIP_MACRO") = 1; // skip macro converter + outtd("_MODULEID") = thermoId; + outtd("_SKIP_MACRO") = 1; // skip macro converter - gReq("GRAPH_LINE_COLOUR") = "red"; - gReq("GRAPH_LINE_STYLE") = "dash", + gReq("GRAPH_LINE_COLOUR") = "red"; + gReq("GRAPH_LINE_STYLE") = "dash", gReq("GRAPH_LINE_THICKNESS") = 8; - outd = outd + outtd + gReq; + outd = outd + outtd + gReq; // Create wind output request if (windFlag_) { MvRequest outw("NETCDF_XY_VECTORS"); - outw("NETCDF_DATA") = ncDataReq; - outw("NETCDF_X_POSITION_VARIABLE") = sXWIND.c_str(); - outw("NETCDF_Y_POSITION_VARIABLE") = sPWIND.c_str(); + outw("NETCDF_DATA") = ncDataReq; + outw("NETCDF_X_POSITION_VARIABLE") = sXWIND.c_str(); + outw("NETCDF_Y_POSITION_VARIABLE") = sPWIND.c_str(); outw("NETCDF_X_COMPONENT_VARIABLE") = sU.c_str(); outw("NETCDF_Y_COMPONENT_VARIABLE") = sV.c_str(); - outw("_MODULEID") = thermoId; - outw("_SKIP_MACRO") = 1; // skip macro converter + outw("_MODULEID") = thermoId; + outw("_SKIP_MACRO") = 1; // skip macro converter MvRequest wReq("MWIND"); - wReq("WIND_FIELD_TYPE") = "flags"; + wReq("WIND_FIELD_TYPE") = "flags"; wReq("WIND_FLAG_COLOUR") = "black"; - wReq("_CLASS") = "MWIND"; - wReq("_MODULEID") = thermoId; - wReq("_SKIP_MACRO") = 1; // skip macro converter + wReq("_CLASS") = "MWIND"; + wReq("_MODULEID") = thermoId; + wReq("_SKIP_MACRO") = 1; // skip macro converter outd = outd + outw + wReq; } @@ -238,20 +238,20 @@ // after the GribThermo requests then it will not be associated to the GribThermo's // output data because the existence of a MTEXT request between them. MvRequest titleReq("MTEXT"); - titleReq("TEXT_LINE_1") = title_.c_str(); + titleReq("TEXT_LINE_1") = title_.c_str(); titleReq("TEXT_FONT_SIZE") = 0.5; - titleReq("_MODULEID") = thermoId; - titleReq("_SKIP_MACRO") = 1; // skip macro converter + titleReq("_MODULEID") = thermoId; + titleReq("_SKIP_MACRO") = 1; // skip macro converter // If action is not visualisation related then return the netcdf data. // Also, add the visualisation and original requests as hidden parameters. // These may be used later to help the visualisation of the netcdf data. if (!this->isVisualise()) { - out = ncDataReq; - out("_VIEW") = "THERMOVIEW"; - out("_VISUALISE") = titleReq + outd; + out = ncDataReq; + out("_VIEW") = "THERMOVIEW"; + out("_VISUALISE") = titleReq + outd; out("_VIEW_REQUEST") = viewReq; - out("_MODULEID") = thermoId; + out("_MODULEID") = thermoId; return true; } diff -Nru metview-5.17.4/metview/src/Thermo/GribThermo.h metview-5.19.2/metview/src/Thermo/GribThermo.h --- metview-5.17.4/metview/src/Thermo/GribThermo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/GribThermo.h 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ virtual bool getAppParameters(MvRequest&); // Variables - bool windFlag_{false}; // T - there is wind data - std::string title_; // title information - ThermoParams pars_; // parameters from the user interface + bool windFlag_{false}; // T - there is wind data + std::string title_; // title information + ThermoParams pars_; // parameters from the user interface }; diff -Nru metview-5.17.4/metview/src/Thermo/ParamsThermo.h metview-5.19.2/metview/src/Thermo/ParamsThermo.h --- metview-5.17.4/metview/src/Thermo/ParamsThermo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/ParamsThermo.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,14 +25,14 @@ { std::string dewPointFormulaType_; std::string errorMsg_; - int uFieldId_; - int vFieldId_; - int tempId_; - int dewId_; - int lnPressId_; - double lat_; - double lon_; - double lat2_; - double lon2_; - EPointType pointType_; + int uFieldId_{0}; + int vFieldId_{0}; + int tempId_{0}; + int dewId_{0}; + int lnPressId_{0}; + double lat_{0.}; + double lon_{0.}; + double lat2_{0.}; + double lon2_{0}; + EPointType pointType_{eGridPoint}; }; diff -Nru metview-5.17.4/metview/src/Thermo/Thermo.cc metview-5.19.2/metview/src/Thermo/Thermo.cc --- metview-5.17.4/metview/src/Thermo/Thermo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/Thermo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,7 @@ #include "GribThermo.h" // Thermo data types -const static int N_DATATYPE = 3; +const static int N_DATATYPE = 3; const static std::string DATATYPE[N_DATATYPE] = {"GRIB_THERMO", "BUFR_THERMO", "ODB_THERMO"}; Thermo::Thermo(const char* kw) : @@ -101,7 +101,7 @@ viewRequest = in("_CONTEXT"); // Check if a data module was dropped into the view - const char* verb = (const char*)in("_VERB"); + const char* verb = (const char*)in("_VERB"); bool moduleDropped = this->isDataModule(verb); // Check the type of input request to be processed @@ -191,8 +191,8 @@ void Thermo::createProcessedOutputRequest(MvRequest& out) { // Create NetCDF output request - MvRequest data = origReq_.getSubrequest("DATA"); - MvRequest out1 = data.getSubrequest("_VISUALISE"); + MvRequest data = origReq_.getSubrequest("DATA"); + MvRequest out1 = data.getSubrequest("_VISUALISE"); MvRequest viewReq = data.getSubrequest("_CARTESIANVIEW"); data.unsetParam("_VISUALISE"); // to avoid duplication of info data.unsetParam("_CARTESIANVIEW"); // to avoid duplication of info diff -Nru metview-5.17.4/metview/src/Thermo/Thermo.h metview-5.19.2/metview/src/Thermo/Thermo.h --- metview-5.17.4/metview/src/Thermo/Thermo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Thermo/Thermo.h 2023-07-15 08:28:47.000000000 +0000 @@ -12,21 +12,21 @@ #include "Metview.h" // Constant variable names/sizes -static const float K2C = 273.15; -static const float MissingValue = 1.7e38; -static const std::string sTIME_STR = "str_length"; -static const std::string sTIME = "time"; -static const std::string sTEMP = "t"; -static const std::string sDEWPOINT = "td"; -static const std::string sPRESSURE = "pres"; +static const float K2C = 273.15; +static const float MissingValue = 1.7e38; +static const std::string sTIME_STR = "str_length"; +static const std::string sTIME = "time"; +static const std::string sTEMP = "t"; +static const std::string sDEWPOINT = "td"; +static const std::string sPRESSURE = "pres"; static const std::string sGEOPOTENTIAL = "z"; -static const std::string sWIND = "wind"; -static const std::string sU = "u"; -static const std::string sV = "v"; -static const std::string sXWIND = "xwind"; -static const std::string sPWIND = "pwind"; -static const std::string sNLEV = "nlev"; -static const std::string sNLEVWIND = "nlevwind"; +static const std::string sWIND = "wind"; +static const std::string sU = "u"; +static const std::string sV = "v"; +static const std::string sXWIND = "xwind"; +static const std::string sPWIND = "pwind"; +static const std::string sNLEV = "nlev"; +static const std::string sNLEVWIND = "nlevwind"; // Type of input request to be processed enum @@ -57,8 +57,8 @@ // Handle variable members void actionMode(std::string action) { actionMode_ = action; } std::string actionMode() { return actionMode_; } - //void processType( int type ) { procType_ = type; } - //int processType( ) { return procType_; } + // void processType( int type ) { procType_ = type; } + // int processType( ) { return procType_; } void ncFileName(std::string name) { ncFileName_ = name; } std::string ncFileName() { return ncFileName_; } diff -Nru metview-5.17.4/metview/src/TimeSeries/Metgram.cc metview-5.19.2/metview/src/TimeSeries/Metgram.cc --- metview-5.17.4/metview/src/TimeSeries/Metgram.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/TimeSeries/Metgram.cc 2023-07-15 08:28:47.000000000 +0000 @@ -57,10 +57,10 @@ void Metgram::grib(MvRequest& in, MvRequest& out) { - MvRequest grib = in("DATA"); + MvRequest grib = in("DATA"); MvRequest station = in("STATION"); - MvRequest axis = in("VERTICAL_AXIS"); - MvRequest graph = in("ATTRIBUTES"); + MvRequest axis = in("VERTICAL_AXIS"); + MvRequest graph = in("ATTRIBUTES"); MvTimeSerie serie(axis, graph); @@ -77,8 +77,8 @@ { char ref[1024]; char legend[1024]; - int param = -1; - int level = -1; + int param = -1; + int level = -1; int number = -1; int idat = -1, dateinc = 0, fdato = 0; double lat, lon; @@ -100,22 +100,22 @@ MvField field; while (field = iter()) { MvFieldExpander expand(field); - double min = field[0]; - double max = field[0]; + double min = field[0]; + double max = field[0]; MvRequest r = field.getRequest(); int p = r("PARAM"); - int l = r("LEVELIST"); - int n = r("NUMBER"); - int idato = r("DATE"); - int itime = r("TIME"); + int l = r("LEVELIST"); + int n = r("NUMBER"); + int idato = r("DATE"); + int itime = r("TIME"); const char* type = r("TYPE"); double x = r("STEP"); printf(" %lf date %d\n", x, idato); if (idat == -1) { - idat = idato; + idat = idato; fdato = idato; } if (idat != idato) { @@ -126,18 +126,18 @@ serie.setDate(fdato, itime); if (p != param || l != level || n != number) { - param = p; - level = l; + param = p; + level = l; number = n; while (station) { icon_name = station("_CLASS"); - name = station("NAME"); + name = station("NAME"); if (icon_name) last_station = station; sprintf(ref, "%d/%s/%d/%d", param, name, level, number); - lat = station("LATITUDE"); - lon = station("LONGITUDE"); + lat = station("LATITUDE"); + lon = station("LONGITUDE"); float abslat = lat > 0. ? lat : -lat; float abslon = lon > 0. ? lon : -lon; @@ -162,9 +162,9 @@ while (station) { double BIGDOUBLE = 3.4E35; - name = station("NAME"); - lat = station("LATITUDE"); - lon = station("LONGITUDE"); + name = station("NAME"); + lat = station("LATITUDE"); + lon = station("LONGITUDE"); sprintf(ref, "%d/%s/%d/%d", p, name, level, number); double y = field.interpolateAt(lon, lat); if (y < BIGDOUBLE) @@ -179,50 +179,50 @@ void Metgram::bufr(MvRequest&, MvRequest&) { /***************** - MvRequest bufr; - - in.getValue(bufr,"DATA"); - MvRequest station; - in.getValue(station,"STATION"); - double ident = station("IDENT"); - - while (station) { - char *name = station("NAME"); - printf("station : %s\n", name); - station.advance(); - } - - in.getValue(station,"STATION"); - MvRequest magics; - - in.getValue(magics,"VISUALISATION"); - printf("Magics parameter\n"); - magics.print(); - - - boolean bar = false; - boolean scale = false; - boolean overlay = false; - Cached BAR("BAR"); - Cached YES("YES"); - - if (magics("GRAPH_TYPE") == BAR) bar = true; - if (in("SCALE") == YES) scale = true; - if (in("OVERLAY_STATIONS") == YES) overlay = true; - - MvObsSet obsset(bufr); - MvObsSetIterator iter(obsset); - - MvBufrParam tempe("T"); - iter.setWmoStation(ident); - - MvObs obs; - while(obs = iter()) - { - obs.printParameters(); - float t = obs.value(tempe); - printf("Tempe : %f\n", t); - } + MvRequest bufr; + + in.getValue(bufr,"DATA"); + MvRequest station; + in.getValue(station,"STATION"); + double ident = station("IDENT"); + + while (station) { + char *name = station("NAME"); + printf("station : %s\n", name); + station.advance(); + } + + in.getValue(station,"STATION"); + MvRequest magics; + + in.getValue(magics,"VISUALISATION"); + printf("Magics parameter\n"); + magics.print(); + + + boolean bar = false; + boolean scale = false; + boolean overlay = false; + Cached BAR("BAR"); + Cached YES("YES"); + + if (magics("GRAPH_TYPE") == BAR) bar = true; + if (in("SCALE") == YES) scale = true; + if (in("OVERLAY_STATIONS") == YES) overlay = true; + + MvObsSet obsset(bufr); + MvObsSetIterator iter(obsset); + + MvBufrParam tempe("T"); + iter.setWmoStation(ident); + + MvObs obs; + while(obs = iter()) + { + obs.printParameters(); + float t = obs.value(tempe); + printf("Tempe : %f\n", t); + } *****************************/ } diff -Nru metview-5.17.4/metview/src/TimeSeries/Scores.cc metview-5.19.2/metview/src/TimeSeries/Scores.cc --- metview-5.17.4/metview/src/TimeSeries/Scores.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/TimeSeries/Scores.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,7 @@ #include -const int SC_RMS = 1; +const int SC_RMS = 1; const int SC_CORRELATION = 2; class Scores : public MvService @@ -83,8 +83,8 @@ char ref[1024]; char legend[1024]; - int param = -1; - int level = -1; + int param = -1; + int level = -1; int number = -1; @@ -156,12 +156,12 @@ first = 0; } - //printf("base = %d x = %d d = %d t = %d\n",base,x,d,t); + // printf("base = %d x = %d d = %d t = %d\n",base,x,d,t); if (p != param || l != level || n != number) { - param = p; - level = l; + param = p; + level = l; number = n; { @@ -209,7 +209,7 @@ } break; case SC_CORRELATION: { - double cov12 = f1.covar(f2, area[0], area[1], area[2], area[3]); + double cov12 = f1.covar(f2, area[0], area[1], area[2], area[3]); double stdev1 = f1.stdev(area[0], area[1], area[2], area[3]); double stdev2 = f2.stdev(area[0], area[1], area[2], area[3]); @@ -217,7 +217,7 @@ if (stdev1 != 0 && stdev2 != 0) y = cov12 / (stdev1 * stdev2); - //cout << y << " = " << cov12 << " / (" << stdev1 << " * " << stdev2 << ")" << std::endl; + // cout << y << " = " << cov12 << " / (" << stdev1 << " * " << stdev2 << ")" << std::endl; serie.addPoint(ref, x - base, y); } break; } diff -Nru metview-5.17.4/metview/src/TimeSeries/TimeSerie.cc metview-5.19.2/metview/src/TimeSeries/TimeSerie.cc --- metview-5.17.4/metview/src/TimeSeries/TimeSerie.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/TimeSeries/TimeSerie.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,12 +20,12 @@ const double cBIGDOUBLE = 3.4E35; -const char cTAB[] = "\t"; +const char cTAB[] = "\t"; const std::string cGRIB("GRIB"); const std::string cGPTS("GEOPOINTS"); const std::string cBUFR("BUFR"); -const long cBufrType = 252; +const long cBufrType = 252; const long cBufrSubtype = 0; @@ -106,9 +106,9 @@ //_____________________________________________________________________________ void TimeSerie::init(MvRequest& in) { - data_ = in("DATA"); + data_ = in("DATA"); station_ = in("STATION"); - //axis_ = in("VERTICAL_AXIS"); + // axis_ = in("VERTICAL_AXIS"); graph_ = in("ATTRIBUTES"); base_date_set_ = false; @@ -154,7 +154,7 @@ void TimeSerie::set_basedate(int bd) { if (!base_date_set_) { - base_date_ = MvDate((double)bd); + base_date_ = MvDate((double)bd); base_date_set_ = true; serie_->setDate(bd, 0); @@ -180,8 +180,8 @@ //-- this one increases legend texts to be visible/readable --// MvRequest biggerLegText("PTEXT"); - biggerLegText("TEXT_LEGEND_MAGICS_STYLE") = "ON"; - biggerLegText("LEGEND_COLUMN_COUNT") = 2; + biggerLegText("TEXT_LEGEND_MAGICS_STYLE") = "ON"; + biggerLegText("LEGEND_COLUMN_COUNT") = 2; biggerLegText("LEGEND_ENTRY_MAXIMUM_WIDTH") = 12.0; out = serie_->getRequest() + biggerLegText; @@ -209,8 +209,8 @@ //_____________________________________________________________________________ bool FieldPointTimeSerie::do_the_job() { - int param = -1; - int level = -1; + int param = -1; + int level = -1; int number = -1; MvRequest last_station; @@ -228,9 +228,9 @@ MvFieldExpander expand(field); MvRequest r = field.getRequest(); - int req_date = r("DATE"); - int req_time = r("TIME"); - double req_step = r("STEP"); + int req_date = r("DATE"); + int req_time = r("TIME"); + double req_step = r("STEP"); const char* req_expver = r("EXPVER"); set_basedate(req_date); @@ -239,7 +239,7 @@ MvDate cur_date((double)req_date + (double)req_time / 2400.0 + (double)req_step / 24); double x_offset = base_date_.time_interval_hours(cur_date); - //cout << req_date << cTAB << req_time << cTAB << req_step << cTAB << x_offset; //-- << std::endl; + // cout << req_date << cTAB << req_time << cTAB << req_step << cTAB << x_offset; //-- << std::endl; int req_par = r("PARAM"); int req_lev = r("LEVELIST"); @@ -247,14 +247,14 @@ //-- check if new time series --// if (req_par != param || req_lev != level || req_num != number) { - param = req_par; - level = req_lev; - number = req_num; + param = req_par; + level = req_lev; + number = req_num; std::string par_name = (const char*)field.marsName(); while (station_) { std::string station_name = (const char*)station_("NAME"); - const char* icon_name = station_("_CLASS"); + const char* icon_name = station_("_CLASS"); if (icon_name) last_station = station_; @@ -276,14 +276,14 @@ << ends; std::string title = otit.str(); - std::string ref = ref_string(param, level, number, loca, req_expver); + std::string ref = ref_string(param, level, number, loca, req_expver); serie_->createNewGroup(ref.c_str(), title.c_str()); serie_->addIconInfo(ref.c_str(), "DATA", data_); serie_->addIconInfo(ref.c_str(), "STATION", last_station); - //serie_->setTitle( ref.c_str(), title.c_str() ); + // serie_->setTitle( ref.c_str(), title.c_str() ); station_.advance(); } @@ -296,7 +296,7 @@ double lon = station_("LONGITUDE"); MvLocation loca(lat, lon); std::string ref = ref_string(param, level, number, loca, req_expver); - //cout << cTAB << ref.c_str() << std::endl; + // cout << cTAB << ref.c_str() << std::endl; double y = field.interpolateAt(lon, lat); if (y < cBIGDOUBLE) { @@ -316,8 +316,8 @@ //_____________________________________________________________________________ bool FieldMeanTimeSerie::do_the_job() { - int param = -1; - int level = -1; + int param = -1; + int level = -1; int number = -1; MvRequest last_station; @@ -335,9 +335,9 @@ MvFieldExpander expand(field); MvRequest r = field.getRequest(); - int req_date = r("DATE"); - int req_time = r("TIME"); - double req_step = r("STEP"); + int req_date = r("DATE"); + int req_time = r("TIME"); + double req_step = r("STEP"); const char* req_expver = r("EXPVER"); set_basedate(req_date); @@ -346,7 +346,7 @@ MvDate cur_date((double)req_date + (double)req_time / 2400.0 + (double)req_step / 24); double x_offset = base_date_.time_interval_hours(cur_date); - //cout << req_date << cTAB << req_time << cTAB << req_step << cTAB << x_offset; //-- << std::endl; + // cout << req_date << cTAB << req_time << cTAB << req_step << cTAB << x_offset; //-- << std::endl; int req_par = r("PARAM"); int req_lev = r("LEVELIST"); @@ -356,9 +356,9 @@ //-- check if new time series --// if (req_par != param || req_lev != level || req_num != number) { - param = req_par; - level = req_lev; - number = req_num; + param = req_par; + level = req_lev; + number = req_num; std::string par_name = (const char*)field.marsName(); std::ostringstream otit; @@ -432,13 +432,13 @@ MvDate cur_date((double)gp.date() + (double)gp.time() / 2400); double x_offset = base_date_.time_interval_hours(cur_date); - //cout << gp.date() << cTAB << gp.time() << cTAB << x_offset; //-- << std::endl; + // cout << gp.date() << cTAB << gp.time() << cTAB << x_offset; //-- << std::endl; double lat = gp.lat_y(); double lon = gp.lon_x(); MvLocation loca(lat, lon); std::string ref = ref_string(0, (int)gp.height(), 0, loca, "NA"); - //cout << cTAB << ref.c_str() << std::endl; + // cout << cTAB << ref.c_str() << std::endl; if (find(ref_list.begin(), ref_list.end(), ref) == ref_list.end()) { ref_list.push_back(ref); @@ -490,9 +490,9 @@ double lon = obs.value(6001); MvLocation loca(lat, lon); - int startIndex = 9; //-- check if xtra level coord descr + int startIndex = 9; //-- check if xtra level coord descr double mayBeLevel = obs[startIndex]; - long currDescr = obs.currentDescriptor(); + long currDescr = obs.currentDescriptor(); std::string levelInfo(""); if (currDescr == 7004 || currDescr == 7007) { @@ -508,7 +508,7 @@ ++startIndex; //-- adjust data starting index } - double parval = obs[startIndex + 1]; //-- extract parameter name + double parval = obs[startIndex + 1]; //-- extract parameter name std::string parnam = obs.name(); //-- non-orthodoxic but valid use of ref_string parameters --// diff -Nru metview-5.17.4/metview/src/UiAppManager/MvUiService.cc metview-5.19.2/metview/src/UiAppManager/MvUiService.cc --- metview-5.17.4/metview/src/UiAppManager/MvUiService.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/UiAppManager/MvUiService.cc 2023-07-15 08:28:47.000000000 +0000 @@ -57,16 +57,16 @@ return; } - //When the request written into a file and contains a "." value we cannot - //read it because the request parser fails reporting a syntax error! - //So we need to make sure the request does not contain any "." values! - //TODO: the solution below in not generic and only fixes the _PATH = . - //case. On top of that "." in theory could be a valid value in a request! + // When the request written into a file and contains a "." value we cannot + // read it because the request parser fails reporting a syntax error! + // So we need to make sure the request does not contain any "." values! + // TODO: the solution below in not generic and only fixes the _PATH = . + // case. On top of that "." in theory could be a valid value in a request! // As a safety measure we only apply it to the WMSCLIENT beacuse we know it happens when // run in batch mode! if (strcmp(in.getVerb(), "WMSCLIENT") == 0) { - MvRequest::replaceDotInPath(in); + MvRequest::replaceDotInPath(in); } auto appItem = it->second; diff -Nru metview-5.17.4/metview/src/UiAppManager/UiAppManager.cc metview-5.19.2/metview/src/UiAppManager/UiAppManager.cc --- metview-5.17.4/metview/src/UiAppManager/UiAppManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/UiAppManager/UiAppManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ if (r) { print_all_requests(r); do { - const char* verbCh = r("class"); + const char* verbCh = r("class"); const char* appNameCh = r("app"); if (verbCh && appNameCh) { std::string verb(verbCh); @@ -38,7 +38,7 @@ auto it = services.find(verb); MvUiService_ptr p; if (it == services.end()) { - p = std::make_shared(verbCh); + p = std::make_shared(verbCh); services[verb] = p; } else { diff -Nru metview-5.17.4/metview/src/uPlot/AnnotationView.cc metview-5.19.2/metview/src/uPlot/AnnotationView.cc --- metview-5.17.4/metview/src/uPlot/AnnotationView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/AnnotationView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,9 @@ class AnnotationViewFactory : public PlotModViewFactory { // -- Virtual Constructor - Builds a new AnnotationView - virtual PlotModView* Build(Page& page, - const MvRequest& contextRequest, - const MvRequest& setupRequest) + PlotModView* Build(Page& page, + const MvRequest& contextRequest, + const MvRequest& setupRequest) override { return new AnnotationView(page, contextRequest, setupRequest); } @@ -43,12 +43,6 @@ { } -AnnotationView::AnnotationView(const AnnotationView& old) : - PlotModView(old), - viewName_(old.viewName_) -{ -} - std::string AnnotationView::Name() { @@ -62,7 +56,7 @@ MvRequest dropRequest = context.InRequest(); while (dropRequest) { MvRequest request = dropRequest.justOneRequest(); - const char* verb = request.getVerb(); + const char* verb = request.getVerb(); if ((const char*)verb == PLOTSUPERPAGE) { context.AdvanceTo(PLOTSUPERPAGE); @@ -98,7 +92,7 @@ return true; // It should use the AnnotationView default value for parameter SUBPAGE_FRAME - MvRequest exp = ObjectList::ExpandRequest(viewRequest_, EXPAND_DEFAULTS); + MvRequest exp = ObjectList::ExpandRequest(viewRequest_, EXPAND_DEFAULTS); viewRequest_("SUBPAGE_FRAME") = exp("SUBPAGE_FRAME"); return true; diff -Nru metview-5.17.4/metview/src/uPlot/AnnotationView.h metview-5.19.2/metview/src/uPlot/AnnotationView.h --- metview-5.17.4/metview/src/uPlot/AnnotationView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/AnnotationView.h 2023-07-15 08:28:47.000000000 +0000 @@ -42,11 +42,11 @@ AnnotationView(Page&, const MvRequest&, const MvRequest&, const std::string& viewName = "annotationview"); - AnnotationView(const AnnotationView&); + AnnotationView& operator=(const AnnotationView&) = delete; PlotModView* Clone() const override { return new AnnotationView(*this); } // -- Destructor - ~AnnotationView() {} + ~AnnotationView() override = default; // -- Methods overriden from PlotModView class std::string Name() override; @@ -59,7 +59,7 @@ // Draw the background void DrawBackground() override {} - //virtual bool EmptyShared() { return false; } + // virtual bool EmptyShared() { return false; } // Draw the foreground void DrawForeground() override {} @@ -70,12 +70,8 @@ // Process the drop request void Drop(PmContext& context) override; - MvIconList InsertDataRequest(MvRequest&) override { return MvIconList(); } - -protected: - std::string viewName_; + MvIconList InsertDataRequest(MvRequest&) override { return {}; } private: - // No assignment - AnnotationView& operator=(const AnnotationView&); + std::string viewName_; }; diff -Nru metview-5.17.4/metview/src/uPlot/AverageView.cc metview-5.19.2/metview/src/uPlot/AverageView.cc --- metview-5.17.4/metview/src/uPlot/AverageView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/AverageView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -68,7 +68,7 @@ // Translate Levels interval viewReq("BOTTOM_LEVEL") = (double)req("BOTTOM_PRESSURE"); - viewReq("TOP_LEVEL") = (double)req("TOP_PRESSURE"); + viewReq("TOP_LEVEL") = (double)req("TOP_PRESSURE"); // Translate Vertical scaling parameter viewReq("VERTICAL_SCALING") = (const char*)req("PRESSURE_LEVEL_AXIS"); @@ -99,16 +99,9 @@ SetVariables(viewRequest, true); } -AverageView::AverageView(const AverageView& old) : - CommonXSectView(old), - axisType_(old.axisType_), - yReverse_(old.yReverse_) -{ -} - string AverageView::Name() { - int id = Owner().Id(); + int id = Owner().Id(); std::string name = (const char*)ObjectInfo::ObjectName(viewRequest_, "AverageView", id); return name; @@ -134,8 +127,8 @@ lonMin_ = in("AREA", 1); lonMax_ = in("AREA", 3); - if (strcmp(in("DIRECTION"), "NS") && - strcmp(in("DIRECTION"), "NORTH SOUTH")) + if (strcmp(in("DIRECTION"), "NS") != 0 && + strcmp(in("DIRECTION"), "NORTH SOUTH") != 0) axisType_ = "LATITUDE"; else axisType_ = "LONGITUDE"; @@ -150,11 +143,11 @@ if ((const char*)in("MODE") && strcmp(in("MODE"), "AVERAGE_EW") == 0) { viewRequest_("DIRECTION") = "NS"; - axisType_ = "LONGITUDE"; + axisType_ = "LONGITUDE"; } else { viewRequest_("DIRECTION") = "EW"; - axisType_ = "LATITUDE"; + axisType_ = "LATITUDE"; } } @@ -195,13 +188,13 @@ // Translate Y coordinates if (axisAuto) { - cartView("Y_AUTOMATIC") = "on"; + cartView("Y_AUTOMATIC") = "on"; cartView("Y_AUTOMATIC_REVERSE") = yReverse_.c_str(); } else { cartView("Y_AUTOMATIC") = "off"; - cartView("Y_MIN") = yMin_; - cartView("Y_MAX") = yMax_; + cartView("Y_MIN") = yMin_; + cartView("Y_MAX") = yMax_; } const char* log = viewRequest_("VERTICAL_SCALING"); @@ -248,9 +241,7 @@ bool AverageView::ConsistencyCheck(MvRequest& req1, MvRequest& req2) { // Build a list of parameters to be checked - std::vector params; - params.push_back("AREA"); - params.push_back("DIRECTION"); + std::vector params = {"AREA", "DIRECTION"}; // Expand requests using the same expansion flag to avoid // problems with parameters with multiple values (e.g. diff -Nru metview-5.17.4/metview/src/uPlot/AverageView.h metview-5.19.2/metview/src/uPlot/AverageView.h --- metview-5.17.4/metview/src/uPlot/AverageView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/AverageView.h 2023-07-15 08:28:47.000000000 +0000 @@ -55,7 +55,7 @@ class AverageViewFactory : public PlotModViewFactory { // -- Virtual Constructor - Builds a new AverageView - virtual PlotModView* Build(Page&, const MvRequest&, const MvRequest&); + PlotModView* Build(Page&, const MvRequest&, const MvRequest&) override; public: // Constructors @@ -70,7 +70,7 @@ class AverageViewM3Factory : public PlotModViewFactory { // -- Virtual Constructor - Builds a new AverageView - virtual PlotModView* Build(Page&, const MvRequest&, const MvRequest&); + PlotModView* Build(Page&, const MvRequest&, const MvRequest&) override; // Translate Metview 3 view request to Metview 4 MvRequest Translate(const MvRequest&); @@ -88,11 +88,11 @@ public: // -- Constructors AverageView(Page&, const MvRequest&, const MvRequest&); - AverageView(const AverageView&); + AverageView(const AverageView&) = default; PlotModView* Clone() const override { return new AverageView(*this); } // -- Destructor - ~AverageView() {} + ~AverageView() override = default; // -- Methods // -- Overriden from CommonXSectView class diff -Nru metview-5.17.4/metview/src/uPlot/BufrDecoder.cc metview-5.19.2/metview/src/uPlot/BufrDecoder.cc --- metview-5.17.4/metview/src/uPlot/BufrDecoder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/BufrDecoder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,7 +18,7 @@ class BufrDecoderFactory : public DecoderFactory { // Virtual Constructor - Builds a new BufrDecoder - virtual Decoder* Build(const MvRequest& inRequest) + Decoder* Build(const MvRequest& inRequest) override { return new BufrDecoder(inRequest); } @@ -39,10 +39,10 @@ struct BufrInfo { time_t mtime_; - int groupInterval_; + int groupInterval_{0}; GroupInfoMap groupInfo_; }; -using BufrInfoMap = std::multimap >; +using BufrInfoMap = std::multimap >; using BufrInfoIterator = BufrInfoMap::iterator; // Static map of existing grouped files. @@ -57,9 +57,11 @@ BufrDecoder::BufrDecoder(const MvRequest& dataUnitRequest) : Decoder(dataUnitRequest) { - struct stat bufrstat; + struct stat bufrstat + { + }; - const char* name = 0; + const char* name = nullptr; dataUnitRequest.getValue(name, "PATH"); if (stat(name, &bufrstat) == 0) { @@ -100,9 +102,9 @@ bufrRequest("PATH") = (*groupIterator_).second->path().c_str(); // Format the output to match the one for GRIB - std::string datestr = (*groupIterator_).first; + std::string datestr = (*groupIterator_).first; std::string yyyymmdd = datestr.substr(0, 8); - std::string hhmm = datestr.substr(8, 4); + std::string hhmm = datestr.substr(8, 4); bufrRequest("DATE") = yyyymmdd.c_str(); bufrRequest("TIME") = hhmm.c_str(); @@ -126,14 +128,16 @@ GroupInfoIterator ii; bool writeData = true; - time_t mtime; + time_t mtime = 0; // Only for timing during development - //time_t clock; - //time(&clock); + // time_t clock; + // time(&clock); // Find status and last modification of file - struct stat bufrstat; + struct stat bufrstat + { + }; if (stat(path_.c_str(), &bufrstat) < 0) { MvLog().popup().err() << "BufrDecoder-> File not OK : " << path_; cleanMap(); @@ -163,8 +167,8 @@ // Check that we have the same grouping interval else if ((*currentBufr).second.groupInterval_ == ObsGroupControl::groupPeriod()) { // Using existing files, new files not created - writeData = false; - groupInfo_ = (*currentBufr).second.groupInfo_; + writeData = false; + groupInfo_ = (*currentBufr).second.groupInfo_; groupIterator_ = groupInfo_.begin(); break; } @@ -179,7 +183,7 @@ // FAMI20171017 : VERY IMPORTANT : grouping observations by time is disabled. // Consenquently, the intermediate BUFR files (one for each group of observations) // will not be generated. Therefore, only the input BUFR file will be sent to MAGICS. -#if 0 //FAMI20171017 +#if 0 // FAMI20171017 while ( (obs = iter(NR_returnMsg)) ) #else writeData = false; @@ -200,7 +204,7 @@ if ((ii = groupInfo_.find(groupTime)) != groupInfo_.end()) (*ii).second->write(obs); else { -#if 0 //FAMI20171017 +#if 0 // FAMI20171017 generateGroupFileName(groupFileName,groupTime); #else groupFileName = path_; @@ -225,9 +229,9 @@ // Add file info to static map BufrInfo bufrinfo; - bufrinfo.mtime_ = mtime; + bufrinfo.mtime_ = mtime; bufrinfo.groupInterval_ = ObsGroupControl::groupPeriod(); - bufrinfo.groupInfo_ = groupInfo_; + bufrinfo.groupInfo_ = groupInfo_; bufrInfoMap.insert(std::pair(path_, bufrinfo)); // Rewind the iterator @@ -248,8 +252,8 @@ cleanMap(); // For testing - //time(&clock); - //COUT << " After grouping " << ctime(&clock) << std::endl; + // time(&clock); + // COUT << " After grouping " << ctime(&clock) << std::endl; } // BufrDecoder::findTime @@ -285,7 +289,9 @@ std::string curr_path; BufrInfo curr_info; GroupInfoIterator ii; - struct stat bufrstat; + struct stat bufrstat + { + }; auto bufrii = bufrInfoMap.begin(); while (bufrii != bufrInfoMap.end()) { @@ -309,10 +315,10 @@ //__________________________________________________________________ //-- default obs grouping parameters, valid for ECMWF --// -int ObsGroupControl::groupPeriodHours_ = 6; +int ObsGroupControl::groupPeriodHours_ = 6; int ObsGroupControl::groupPeriodStartMinute_ = 1; -bool ObsGroupControl::useObsTime_ = false; -bool ObsGroupControl::firstTime_ = true; +bool ObsGroupControl::useObsTime_ = false; +bool ObsGroupControl::firstTime_ = true; void ObsGroupControl::groupingValues() { @@ -347,8 +353,8 @@ { groupingValues(); - short yy, mm, dd; - short hh, min, sec; + short yy = 0, mm = 0, dd = 0; + short hh = 0, min = 0, sec = 0; TDynamicTime tt(tim); @@ -363,7 +369,7 @@ //-- calculate the correct group time hour --// int myGroupSize = ObsGroupControl::groupPeriod(); - hh = ((hh + myGroupSize / 2) / myGroupSize) * myGroupSize; + hh = ((hh + myGroupSize / 2) / myGroupSize) * myGroupSize; if (hh >= 24) { hh -= 24; tt.ChangeByDays(1); @@ -384,12 +390,12 @@ // changes in there, then this function may also have to be updated. void ObsGroupControl::printGroupingLimits(const std::string& groupTimeString) { - short yyyy, mm, dd, hh; + short yyyy = 0, mm = 0, dd = 0, hh = 0; char message[512]; - int groupHours = ObsGroupControl::groupPeriod(); + int groupHours = ObsGroupControl::groupPeriod(); int groupStartMinute = ObsGroupControl::groupPeriodStartMinute(); - int minutesAtStart = ((groupHours / 2) * 60); - int minutesAtEnd = minutesAtStart; + int minutesAtStart = ((groupHours / 2) * 60); + int minutesAtEnd = minutesAtStart; // the variable 'minutes' stores the number of minutes between the // 'official' group period hour (e.g. 06:00, i.e. midpoint of the period diff -Nru metview-5.17.4/metview/src/uPlot/BufrDecoder.h metview-5.19.2/metview/src/uPlot/BufrDecoder.h --- metview-5.17.4/metview/src/uPlot/BufrDecoder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/BufrDecoder.h 2023-07-15 08:28:47.000000000 +0000 @@ -58,11 +58,11 @@ { public: GroupInfo() : - out_(0), + out_(nullptr), path_("") {} GroupInfo(const std::string& path, bool writeData) : - out_(0), + out_(nullptr), path_(path) { if (writeData) @@ -82,7 +82,7 @@ if (out_) { out_->close(); delete out_; - out_ = 0; + out_ = nullptr; } } @@ -98,8 +98,8 @@ std::string path_; }; -typedef std::map > GroupInfoMap; -typedef GroupInfoMap::iterator GroupInfoIterator; +using GroupInfoMap = std::map>; +using GroupInfoIterator = GroupInfoMap::iterator; class BufrDecoder : public Decoder { @@ -108,12 +108,12 @@ BufrDecoder(const MvRequest& inRequest); // Destructor - virtual ~BufrDecoder(); + ~BufrDecoder() override; // Overridden methods from Decoder class - virtual bool ReadNextData(); + bool ReadNextData() override; - virtual MatchingInfo CreateMatchingInfo(); + MatchingInfo CreateMatchingInfo() override; private: void groupInfo(MvObsSetIterator&); @@ -136,7 +136,7 @@ class ObsGroupControl { public: - ObsGroupControl() {} + ObsGroupControl() = default; static std::string groupTimeString(const TDynamicTime& tim); static void printGroupingLimits(const std::string& groupTimeString); diff -Nru metview-5.17.4/metview/src/uPlot/Canvas.cc metview-5.19.2/metview/src/uPlot/Canvas.cc --- metview-5.17.4/metview/src/uPlot/Canvas.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Canvas.cc 2023-07-15 08:28:47.000000000 +0000 @@ -105,7 +105,7 @@ return deviceRequest; } -#if 0 //Change this code to PlotMod:IsWindow +#if 0 // Change this code to PlotMod:IsWindow //U If derived Canvas classes (e.g. XCanvas, PSCanvas,...) are // no longer needed, this code should be used instead. Cached Canvas::CanvasType () diff -Nru metview-5.17.4/metview/src/uPlot/CartesianView.cc metview-5.19.2/metview/src/uPlot/CartesianView.cc --- metview-5.17.4/metview/src/uPlot/CartesianView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CartesianView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,9 +26,9 @@ class CartesianViewFactory : public PlotModViewFactory { // Virtual Constructor - Builds a new CartesianView - virtual PlotModView* Build(Page& page, - const MvRequest& contextRequest, - const MvRequest& setupRequest) + PlotModView* Build(Page& page, + const MvRequest& contextRequest, + const MvRequest& setupRequest) override { return new CartesianView(page, contextRequest, setupRequest, "BACKGROUND_HORIZONTAL_AXIS", "BACKGROUND_VERTICAL_AXIS", "CartesianView"); @@ -66,7 +66,7 @@ // Create AREA parameter to be used by the Projection (SetProjection) MvRequest viewRequest1 = viewRequest_; - viewRequest1("AREA") = viewRequest1("Y_MIN"); + viewRequest1("AREA") = viewRequest1("Y_MIN"); viewRequest1("AREA") += viewRequest1("X_MIN"); viewRequest1("AREA") += viewRequest1("Y_MAX"); viewRequest1("AREA") += viewRequest1("X_MAX"); @@ -76,15 +76,6 @@ owner.SetProjection(viewRequest1); } -CartesianView::CartesianView(const CartesianView& old) : - PlotModView(old), - hAxisName_(old.hAxisName_), - vAxisName_(old.vAxisName_), - viewName_(old.viewName_) -// axisInfoMap_(old.axisInfoMap_) -{ -} - CartesianView::~CartesianView() = default; void CartesianView::GetBackgroundParameters(std::vector& vback) @@ -99,13 +90,13 @@ // Get background parameters if (sproj == "cartesian") { - vback.push_back("HORIZONTAL_AXIS"); - vback.push_back("VERTICAL_AXIS"); + vback.emplace_back("HORIZONTAL_AXIS"); + vback.emplace_back("VERTICAL_AXIS"); } else if (sproj == "taylor") { - vback.push_back("HORIZONTAL_AXIS"); - vback.push_back("VERTICAL_AXIS"); - vback.push_back("TAYLOR_GRID"); + vback.emplace_back("HORIZONTAL_AXIS"); + vback.emplace_back("VERTICAL_AXIS"); + vback.emplace_back("TAYLOR_GRID"); } return; @@ -154,7 +145,7 @@ } MvRequest request = dropRequest.justOneRequest(); - const char* verb = request.getVerb(); + const char* verb = request.getVerb(); if (ObjectList::IsDataUnit(verb) == true) { MvIcon dataUnit = dataBase.InsertDataUnit(request, Owner().Id()); duList.push_back(dataUnit); @@ -169,7 +160,7 @@ } if (ObjectList::IsVisDefAxis(verb)) - this->ProcessAxis(request); //this->ReplaceAxis(request); + this->ProcessAxis(request); // this->ReplaceAxis(request); // Replace the view (if applicable) else if (ObjectList::IsView(verb) == true) @@ -271,11 +262,11 @@ // Get axis orientation const char* cori = axisRequest("AXIS_ORIENTATION"); if (!cori) - cori = "HORIZONTAL"; //default + cori = "HORIZONTAL"; // default // Unset previous axis definition from the view, if exists std::string sorient = cori + (std::string) "_AXIS"; - MvRequest newView = viewRequest_; + MvRequest newView = viewRequest_; newView.unsetParam(sorient.c_str()); // Add new axis definition and update the view @@ -299,10 +290,10 @@ // Build a new data decoder, which will provide information // about the data std::unique_ptr decoder(DecoderFactory::Make(givenUnit.Request())); - ensure(decoder.get() != 0); + ensure(decoder.get() != nullptr); int subpageId = 0; - double minX, maxX, minY, maxY; + double minX = 0., maxX = 0., minY = 0., maxY = 0.; while (decoder->ReadNextData()) { MvRequest dataRequest = decoder->Request(); @@ -345,7 +336,7 @@ MvIconList duList; while (dropRequest) { MvRequest dataUnitRequest = dropRequest.justOneRequest(); - std::string verb = dataUnitRequest.getVerb(); + std::string verb = dataUnitRequest.getVerb(); if (verb == NETCDF) { MvIcon tmpIcon(dataUnitRequest); @@ -416,7 +407,7 @@ std::list doList; subPage->GetDataObjects(doList); std::list::iterator ii; - DataObject* dataObject = 0; + DataObject* dataObject = nullptr; DrawPriorMap drawPriorMap; DrawPriorMap::iterator j; @@ -466,11 +457,11 @@ // have saved all therequests for the dataunits. All the dataunits/vd's // was added by DrawPriorMap code above. - //However, we need to cheat with the axis. Get axislist for subpage, - //set min/max if not hardcoded, and put the axis on the end of the - //dataunit's request. If we're interactively, all requests must have - // the axis tagged on, otherwise Magics tries to make it's own, but - // for print, only one data unit should have axis. + // However, we need to cheat with the axis. Get axislist for subpage, + // set min/max if not hardcoded, and put the axis on the end of the + // dataunit's request. If we're interactively, all requests must have + // the axis tagged on, otherwise Magics tries to make it's own, but + // for print, only one data unit should have axis. // MvIconList axisList; // MvRequest fullAxisRequest; // MvRequest compare("PAXIS"); @@ -481,7 +472,7 @@ // FindAxis(fullAxisRequest,axisList,MinX,MaxX,MinY,MaxY); -#if 0 //F0410 +#if 0 // F0410 first = true; for ( std::multimap::iterator jj = duMap.begin(); jj != duMap.end(); jj++ ) { @@ -494,7 +485,7 @@ // Do the drawing CommonDraw(subPage, drawPriorMap); -#if 0 //FAMI 20100922 Is this needed in Metview 4? +#if 0 // FAMI 20100922 Is this needed in Metview 4? CommonDraw(subPage, drawPriorMap, reqMap); // Reset the data requests std::map::iterator kk; @@ -544,7 +535,7 @@ // Retrieve icons from the View std::vector vbackAux; int ncount = 0; - int nc = vback.size(); + int nc = vback.size(); for (int i = 0; i < nc; i++) { if ((const char*)viewRequest_(vback[i].c_str())) { backReq = viewRequest_.getSubrequest(vback[i].c_str()); @@ -555,7 +546,7 @@ } if (vbackAux.empty()) - return ncount; //all background parameters taken from the View + return ncount; // all background parameters taken from the View // Retrieve icons from the DataBase MvIconDataBase& dataBase = Owner().IconDataBase(); @@ -756,15 +747,15 @@ // different data units. const char* CartesianView::CheckDataRequest(MvIcon& dataUnit, MvIconList& vdList) { - auto ii = vdList.begin(); - const char* graphType = 0; + auto ii = vdList.begin(); + const char* graphType = nullptr; for (; ii != vdList.end(); ii++) { MvIcon visdef = *ii; if (visdef.Request().getVerb() != Cached("PGRAPH")) continue; - graphType = visdef.Request()("GRAPH_TYPE"); + graphType = visdef.Request()("GRAPH_TYPE"); MvRequest dataRequest = dataUnit.Request(); if (graphType) dataRequest("GRAPH_TYPE") = graphType; @@ -781,7 +772,7 @@ bool CartesianView::UpdateViewWithReq(MvRequest& viewRequest) { // Changing to another View is not allowed - if (strcmp(viewRequest_.getVerb(), viewRequest.getVerb())) { + if (strcmp(viewRequest_.getVerb(), viewRequest.getVerb()) != 0) { // Changing View is disabled at the moment MvLog().popup().err() << "Changing View (" << viewRequest_.getVerb() << " to " << viewRequest.getVerb() << ") is currently disabled"; diff -Nru metview-5.17.4/metview/src/uPlot/CartesianView.h metview-5.19.2/metview/src/uPlot/CartesianView.h --- metview-5.17.4/metview/src/uPlot/CartesianView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CartesianView.h 2023-07-15 08:28:47.000000000 +0000 @@ -44,13 +44,12 @@ CartesianView(Page&, const MvRequest&, const MvRequest&, const std::string& haxisName = "HORIZONTAL_AXIS", const std::string& vaxisName = "VERTICAL_AXIS", - const std::string& viewName = "cartesianview"); + const std::string& viewName = "cartesianview"); - CartesianView(const CartesianView&); PlotModView* Clone() const override { return new CartesianView(*this); } // Destructor - ~CartesianView(); + ~CartesianView() override; // Methods overriden from PlotModView class std::string Name() override; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/internal/diagnostics.hpp metview-5.19.2/metview/src/uPlot/cavc/internal/diagnostics.hpp --- metview-5.17.4/metview/src/uPlot/cavc/internal/diagnostics.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/internal/diagnostics.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,9 @@ template std::string propertiesFromPolyline(::cavc::Polyline const& pline) { - auto area = getArea(pline); + auto area = getArea(pline); auto pathLength = getPathLength(pline); - auto extents = getExtents(pline); + auto extents = getExtents(pline); std::stringstream ss; ss << std::setprecision(14) << "(" << pline.size() << ", " << area << ", " << pathLength << ", " << extents.xMin << ", " << extents.yMin << ", " << extents.xMax << ", " << extents.yMax << ")"; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/intrcircle2circle2.hpp metview-5.19.2/metview/src/uPlot/cavc/intrcircle2circle2.hpp --- metview-5.17.4/metview/src/uPlot/cavc/intrcircle2circle2.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/intrcircle2circle2.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -35,8 +35,8 @@ IntrCircle2Circle2Result result; Vector2 cv = center2 - center1; - Real d2 = dot(cv, cv); - Real d = std::sqrt(d2); + Real d2 = dot(cv, cv); + Real d = std::sqrt(d2); if (d < utils::realThreshold()) { // same center position if (utils::fuzzyEqual(radius1, radius2)) { @@ -53,23 +53,23 @@ result.intrType = Circle2Circle2IntrType::NoIntersect; } else { - Real rad1Sq = radius1 * radius1; - Real a = (rad1Sq - radius2 * radius2 + d2) / (Real(2) * d); + Real rad1Sq = radius1 * radius1; + Real a = (rad1Sq - radius2 * radius2 + d2) / (Real(2) * d); Vector2 midPoint = center1 + a * cv / d; - Real diff = rad1Sq - a * a; + Real diff = rad1Sq - a * a; if (diff < Real(0)) { result.intrType = Circle2Circle2IntrType::OneIntersect; - result.point1 = midPoint; + result.point1 = midPoint; } else { - Real h = std::sqrt(diff); - Real hOverD = h / d; - Real xTerm = hOverD * cv.y(); - Real yTerm = hOverD * cv.x(); - Real x1 = midPoint.x() + xTerm; - Real y1 = midPoint.y() - yTerm; - Real x2 = midPoint.x() - xTerm; - Real y2 = midPoint.y() + yTerm; + Real h = std::sqrt(diff); + Real hOverD = h / d; + Real xTerm = hOverD * cv.y(); + Real yTerm = hOverD * cv.x(); + Real x1 = midPoint.x() + xTerm; + Real y1 = midPoint.y() - yTerm; + Real x2 = midPoint.x() - xTerm; + Real y2 = midPoint.y() + yTerm; result.point1 = Vector2(x1, y1); result.point2 = Vector2(x2, y2); if (fuzzyEqual(result.point1, result.point2)) { diff -Nru metview-5.17.4/metview/src/uPlot/cavc/intrlineseg2circle2.hpp metview-5.19.2/metview/src/uPlot/cavc/intrlineseg2circle2.hpp --- metview-5.17.4/metview/src/uPlot/cavc/intrlineseg2circle2.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/intrlineseg2circle2.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,8 @@ IntrLineSeg2Circle2Result result; Real dx = p1.x() - p0.x(); Real dy = p1.y() - p0.y(); - Real h = circleCenter.x(); - Real k = circleCenter.y(); + Real h = circleCenter.x(); + Real k = circleCenter.y(); Real a = dx * dx + dy * dy; if (std::abs(a) < utils::realThreshold()) { @@ -41,7 +41,7 @@ Real yk = p0.y() - k; if (utils::fuzzyEqual(xh * xh + yk * yk, radius * radius)) { result.numIntersects = 1; - result.t0 = Real(0); + result.t0 = Real(0); } else { result.numIntersects = 0; @@ -56,16 +56,16 @@ if (std::abs(discr) < utils::realThreshold()) { // 1 solution (tangent line) result.numIntersects = 1; - result.t0 = -b / (Real(2) * a); + result.t0 = -b / (Real(2) * a); } else if (discr < Real(0)) { result.numIntersects = 0; } else { - result.numIntersects = 2; + result.numIntersects = 2; std::pair sols = utils::quadraticSolutions(a, b, c, discr); - result.t0 = sols.first; - result.t1 = sols.second; + result.t0 = sols.first; + result.t1 = sols.second; } } diff -Nru metview-5.17.4/metview/src/uPlot/cavc/intrlineseg2lineseg2.hpp metview-5.19.2/metview/src/uPlot/cavc/intrlineseg2lineseg2.hpp --- metview-5.17.4/metview/src/uPlot/cavc/intrlineseg2lineseg2.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/intrlineseg2lineseg2.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -44,7 +44,7 @@ IntrLineSeg2LineSeg2Result result; Vector2 u = u2 - u1; Vector2 v = v2 - v1; - Real d = perpDot(u, v); + Real d = perpDot(u, v); Vector2 w = u1 - v1; @@ -65,8 +65,8 @@ // threshold check here to avoid almost parallel lines resulting in very distant intersection if (std::abs(d) > utils::realThreshold()) { // segments not parallel or collinear - result.t0 = perpDot(v, w) / d; - result.t1 = perpDot(u, w) / d; + result.t0 = perpDot(v, w) / d; + result.t1 = perpDot(u, w) / d; result.point = v1 + result.t1 * v; if (result.t0 + utils::realThreshold() < Real(0) || result.t0 > Real(1) + utils::realThreshold() || @@ -95,7 +95,7 @@ // both segments are just points if (fuzzyEqual(u1, v1)) { // same point - result.point = u1; + result.point = u1; result.intrType = LineSeg2LineSeg2IntrType::True; } else { @@ -106,7 +106,7 @@ else if (uIsPoint) { if (isInSegment(u1, v1, v2)) { result.intrType = LineSeg2LineSeg2IntrType::True; - result.point = u1; + result.point = u1; } else { result.intrType = LineSeg2LineSeg2IntrType::None; @@ -115,7 +115,7 @@ else if (vIsPoint) { if (isInSegment(v1, u1, u2)) { result.intrType = LineSeg2LineSeg2IntrType::True; - result.point = v1; + result.point = v1; } else { result.intrType = LineSeg2LineSeg2IntrType::None; @@ -150,7 +150,7 @@ if (std::abs(result.t1 - result.t0) < utils::realThreshold()) { // intersect is a single point (segments line up end to end) result.intrType = LineSeg2LineSeg2IntrType::True; - result.point = v1 + result.t0 * v; + result.point = v1 + result.t0 * v; } else { result.intrType = LineSeg2LineSeg2IntrType::Coincident; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/mathutils.hpp metview-5.19.2/metview/src/uPlot/cavc/mathutils.hpp --- metview-5.17.4/metview/src/uPlot/cavc/mathutils.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/mathutils.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -117,7 +117,7 @@ // https://math.stackexchange.com/questions/311382/solving-a-quadratic-equation-with-precision-when-using-floating-point-variables CAVC_ASSERT(fuzzyEqual(b * b - Real(4) * a * c, discr), "discriminate is not correct"); Real sqrtDiscr = std::sqrt(discr); - Real denom = Real(2) * a; + Real denom = Real(2) * a; Real sol1; if (b < Real(0)) { sol1 = (-b + sqrtDiscr) / denom; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/plinesegment.hpp metview-5.19.2/metview/src/uPlot/cavc/plinesegment.hpp --- metview-5.17.4/metview/src/uPlot/cavc/plinesegment.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/plinesegment.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -81,14 +81,14 @@ CAVC_ASSERT(!fuzzyEqual(v1.pos(), v2.pos()), "v1 must not be ontop of v2"); // compute radius - Real b = std::abs(v1.bulge()); + Real b = std::abs(v1.bulge()); Vector2 v = v2.pos() - v1.pos(); - Real d = length(v); - Real r = d * (b * b + Real(1)) / (Real(4) * b); + Real d = length(v); + Real r = d * (b * b + Real(1)) / (Real(4) * b); // compute center - Real s = b * d / Real(2); - Real m = r - s; + Real s = b * d / Real(2); + Real m = r - s; Real offsX = -m * v.y() / d; Real offsY = m * v.x() / d; if (v1.bulgeIsNeg()) { @@ -118,30 +118,30 @@ SplitResult result; if (v1.bulgeIsZero()) { result.updatedStart = v1; - result.splitVertex = PlineVertex(point, Real(0)); + result.splitVertex = PlineVertex(point, Real(0)); } else if (fuzzyEqual(v1.pos(), v2.pos(), utils::realPrecision()) || fuzzyEqual(v1.pos(), point, utils::realPrecision())) { result.updatedStart = PlineVertex(point, Real(0)); - result.splitVertex = PlineVertex(point, v1.bulge()); + result.splitVertex = PlineVertex(point, v1.bulge()); } else if (fuzzyEqual(v2.pos(), point, utils::realPrecision())) { result.updatedStart = v1; - result.splitVertex = PlineVertex(v2.pos(), Real(0)); + result.splitVertex = PlineVertex(v2.pos(), Real(0)); } else { - auto radiusAndCenter = arcRadiusAndCenter(v1, v2); + auto radiusAndCenter = arcRadiusAndCenter(v1, v2); Vector2 arcCenter = radiusAndCenter.center; - Real a = angle(arcCenter, point); - Real arcStartAngle = angle(arcCenter, v1.pos()); - Real theta1 = utils::deltaAngle(arcStartAngle, a); - Real bulge1 = std::tan(theta1 / Real(4)); - Real arcEndAngle = angle(arcCenter, v2.pos()); - Real theta2 = utils::deltaAngle(a, arcEndAngle); - Real bulge2 = std::tan(theta2 / Real(4)); + Real a = angle(arcCenter, point); + Real arcStartAngle = angle(arcCenter, v1.pos()); + Real theta1 = utils::deltaAngle(arcStartAngle, a); + Real bulge1 = std::tan(theta1 / Real(4)); + Real arcEndAngle = angle(arcCenter, v2.pos()); + Real theta2 = utils::deltaAngle(a, arcEndAngle); + Real bulge2 = std::tan(theta2 / Real(4)); result.updatedStart = PlineVertex(v1.pos(), bulge1); - result.splitVertex = PlineVertex(point, bulge2); + result.splitVertex = PlineVertex(point, bulge2); } return result; @@ -229,7 +229,7 @@ // For arcs we don't compute the actual extents which is slower, instead we create an approximate // bounding box from the rectangle formed by extending the chord by the sagitta, NOTE: this // approximate bounding box is always equal to or bigger than the true bounding box - Real b = v1.bulge(); + Real b = v1.bulge(); Real offsX = b * (v2.y() - v1.y()) / Real(2); Real offsY = -b * (v2.x() - v1.x()) / Real(2); @@ -297,9 +297,9 @@ return std::sqrt(distSquared(v1.pos(), v2.pos())); } - auto arc = arcRadiusAndCenter(v1, v2); + auto arc = arcRadiusAndCenter(v1, v2); Real startAngle = angle(arc.center, v1.pos()); - Real endAngle = angle(arc.center, v2.pos()); + Real endAngle = angle(arc.center, v2.pos()); return std::abs(arc.radius * utils::deltaAngle(startAngle, endAngle)); } @@ -311,9 +311,9 @@ return midpoint(v1.pos(), v2.pos()); } - auto arc = arcRadiusAndCenter(v1, v2); - Real a1 = angle(arc.center, v1.pos()); - Real a2 = angle(arc.center, v2.pos()); + auto arc = arcRadiusAndCenter(v1, v2); + Real a1 = angle(arc.center, v1.pos()); + Real a2 = angle(arc.center, v2.pos()); Real angleOffset = std::abs(utils::deltaAngle(a1, a2) / Real(2)); // use arc direction to determine offset sign to robustly handle half circles Real midAngle = v1.bulgeIsPos() ? a1 + angleOffset : a1 - angleOffset; @@ -349,7 +349,7 @@ // helper function to process line arc intersect auto processLineArcIntr = [&result](Vector2 const& p0, Vector2 const& p1, PlineVertex const& a1, PlineVertex const& a2) { - auto arc = arcRadiusAndCenter(a1, a2); + auto arc = arcRadiusAndCenter(a1, a2); auto intrResult = intrLineSeg2Circle2(p0, p1, arc.radius, arc.center); // helper function to test and get point within arc sweep @@ -359,7 +359,7 @@ return std::make_pair(false, Vector2()); } - Vector2 p = pointFromParametric(p0, p1, t); + Vector2 p = pointFromParametric(p0, p1, t); bool withinSweep = pointWithinArcSweepAngle(arc.center, a1.pos(), a2.pos(), a1.bulge(), p); return std::make_pair(withinSweep, p); }; @@ -371,7 +371,7 @@ auto p = pointInSweep(intrResult.t0); if (p.first) { result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = p.second; + result.point1 = p.second; } else { result.intrType = PlineSegIntrType::NoIntersect; @@ -384,16 +384,16 @@ if (p1.first && p2.first) { result.intrType = PlineSegIntrType::TwoIntersects; - result.point1 = p1.second; - result.point2 = p2.second; + result.point1 = p1.second; + result.point2 = p2.second; } else if (p1.first) { result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = p1.second; + result.point1 = p1.second; } else if (p2.first) { result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = p2.second; + result.point1 = p2.second; } else { result.intrType = PlineSegIntrType::NoIntersect; @@ -409,7 +409,7 @@ break; case LineSeg2LineSeg2IntrType::True: result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = intrResult.point; + result.point1 = intrResult.point; break; case LineSeg2LineSeg2IntrType::Coincident: result.intrType = PlineSegIntrType::SegmentOverlap; @@ -452,7 +452,7 @@ case Circle2Circle2IntrType::OneIntersect: if (bothArcsSweepPoint(intrResult.point1)) { result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = intrResult.point1; + result.point1 = intrResult.point1; } else { result.intrType = PlineSegIntrType::NoIntersect; @@ -463,16 +463,16 @@ const bool pt2InSweep = bothArcsSweepPoint(intrResult.point2); if (pt1InSweep && pt2InSweep) { result.intrType = PlineSegIntrType::TwoIntersects; - result.point1 = intrResult.point1; - result.point2 = intrResult.point2; + result.point1 = intrResult.point1; + result.point2 = intrResult.point2; } else if (pt1InSweep) { result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = intrResult.point1; + result.point1 = intrResult.point1; } else if (pt2InSweep) { result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = intrResult.point2; + result.point1 = intrResult.point2; } else { result.intrType = PlineSegIntrType::NoIntersect; @@ -498,13 +498,13 @@ utils::realThreshold()) { // only end points touch at start of arc1 result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = v1.pos(); + result.point1 = v1.pos(); } else if (std::abs(utils::deltaAngle(arc2StartAndSweep.first, arc1End)) < utils::realThreshold()) { // only end points touch at start of arc2 result.intrType = PlineSegIntrType::OneIntersect; - result.point1 = u1.pos(); + result.point1 = u1.pos(); } else { const bool arc2StartsInArc1Sweep = utils::angleIsWithinSweep( @@ -514,28 +514,28 @@ if (arc2StartsInArc1Sweep && arc2EndsInArc1Sweep) { // arc2 is fully overlapped by arc1 result.intrType = PlineSegIntrType::ArcOverlap; - result.point1 = u1.pos(); - result.point2 = u2.pos(); + result.point1 = u1.pos(); + result.point2 = u2.pos(); } else if (arc2StartsInArc1Sweep) { // overlap from arc2 start to arc1 end result.intrType = PlineSegIntrType::ArcOverlap; - result.point1 = u1.pos(); - result.point2 = v2.pos(); + result.point1 = u1.pos(); + result.point2 = v2.pos(); } else if (arc2EndsInArc1Sweep) { // overlap from arc1 start to arc2 end result.intrType = PlineSegIntrType::ArcOverlap; - result.point1 = v1.pos(); - result.point2 = u2.pos(); + result.point1 = v1.pos(); + result.point2 = u2.pos(); } else { const bool arc1StartsInArc2Sweep = utils::angleIsWithinSweep( arc2StartAndSweep.first, arc2StartAndSweep.second, arc1StartAndSweep.first); if (arc1StartsInArc2Sweep) { result.intrType = PlineSegIntrType::ArcOverlap; - result.point1 = v1.pos(); - result.point2 = v2.pos(); + result.point1 = v1.pos(); + result.point2 = v2.pos(); } else { result.intrType = PlineSegIntrType::NoIntersect; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/polylinecombine.hpp metview-5.19.2/metview/src/uPlot/cavc/polylinecombine.hpp --- metview-5.17.4/metview/src/uPlot/cavc/polylinecombine.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/polylinecombine.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -129,7 +129,7 @@ // sort intersects by distance from start vertex for (auto& kvp : intersectsLookup) { Vector2 startPos = pline[kvp.first].pos(); - auto cmp = [&](SlicePoint const& i1, SlicePoint const& i2) { + auto cmp = [&](SlicePoint const& i1, SlicePoint const& i2) { return distSquared(i1.pos, startPos) < distSquared(i2.pos, startPos); }; std::sort(kvp.second.begin(), kvp.second.end(), cmp); @@ -142,8 +142,8 @@ std::vector> const& intrsList = kvp.second; const auto& firstSegStartVertex = pline[sIndex]; - std::size_t nextIndex = utils::nextWrappingIndex(sIndex, pline); - const auto& firstSegEndVertex = pline[nextIndex]; + std::size_t nextIndex = utils::nextWrappingIndex(sIndex, pline); + const auto& firstSegEndVertex = pline[nextIndex]; if (intrsList.size() != 1) { // build all the segments between the N intersects in siList (N > 1), skipping the first @@ -189,8 +189,8 @@ Polyline currSlice; currSlice.addVertex(split.splitVertex); - std::size_t index = nextIndex; - std::size_t loopCount = 0; + std::size_t index = nextIndex; + std::size_t loopCount = 0; const std::size_t maxLoopCount = pline.size(); while (true) { if (loopCount++ > maxLoopCount) { @@ -209,7 +209,7 @@ // trim last added vertex and add final intersect position PlineVertex endVertex = PlineVertex(intersectPos, Real(0)); - std::size_t nextIndex = utils::nextWrappingIndex(index, pline); + std::size_t nextIndex = utils::nextWrappingIndex(index, pline); SplitResult split = splitAtPoint(currSlice.lastVertex(), pline[nextIndex], intersectPos); currSlice.lastVertex() = split.updatedStart; @@ -309,7 +309,7 @@ std::vector> stitchOrderedSlicesIntoClosedPolylines(std::vector> const& slices, StitchSelector stitchSelector = StitchFirstAvailable(), - Real joinThreshold = utils::sliceJoinThreshold()) + Real joinThreshold = utils::sliceJoinThreshold()) { std::vector> result; if (slices.size() == 0) { @@ -358,9 +358,9 @@ slices[i].vertexes().end()); const std::size_t beginningSliceIndex = i; - std::size_t currSliceIndex = i; - std::size_t loopCount = 0; - const std::size_t maxLoopCount = slices.size(); + std::size_t currSliceIndex = i; + std::size_t loopCount = 0; + const std::size_t maxLoopCount = slices.size(); while (true) { if (loopCount++ > maxLoopCount) { CAVC_ASSERT(false, "Bug detected, should never loop this many times!"); @@ -442,7 +442,7 @@ CAVC_ASSERT(plineA.isClosed() && plineB.isClosed(), "combining only supports closed polylines"); using namespace internal; - auto plASpatialIndex = createApproxSpatialIndex(plineA); + auto plASpatialIndex = createApproxSpatialIndex(plineA); ProcessForCombineResult combineInfo = processForCombine(plineA, plineB, plASpatialIndex); CombineResult result; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/polyline.hpp metview-5.19.2/metview/src/uPlot/cavc/polyline.hpp --- metview-5.17.4/metview/src/uPlot/cavc/polyline.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/polyline.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -115,10 +115,10 @@ } else { PlineVertex const& v2 = pline[j]; - auto arc = arcRadiusAndCenter(v1, v2); + auto arc = arcRadiusAndCenter(v1, v2); Real startAngle = angle(arc.center, v1.pos()); - Real endAngle = angle(arc.center, v2.pos()); + Real endAngle = angle(arc.center, v2.pos()); Real sweepAngle = utils::deltaAngle(startAngle, endAngle); Real arcXMin, arcYMin, arcXMax, arcYMax; @@ -197,15 +197,15 @@ Real doubleArea = pline[i].x() * pline[j].y() - pline[i].y() * pline[j].x(); if (!pline[i].bulgeIsZero()) { // add arc segment area - Real b = std::abs(pline[i].bulge()); - Real sweepAngle = Real(4) * std::atan(b); - Real triangleBase = length(pline[j].pos() - pline[i].pos()); - Real radius = triangleBase * (b * b + Real(1)) / (Real(4) * b); - Real sagitta = b * triangleBase / Real(2); - Real triangleHeight = radius - sagitta; - Real doubleSectorArea = sweepAngle * radius * radius; + Real b = std::abs(pline[i].bulge()); + Real sweepAngle = Real(4) * std::atan(b); + Real triangleBase = length(pline[j].pos() - pline[i].pos()); + Real radius = triangleBase * (b * b + Real(1)) / (Real(4) * b); + Real sagitta = b * triangleBase / Real(2); + Real triangleHeight = radius - sagitta; + Real doubleSectorArea = sweepAngle * radius * radius; Real doubleTriangleArea = triangleBase * triangleHeight; - Real doubleArcSegArea = doubleSectorArea - doubleTriangleArea; + Real doubleArcSegArea = doubleSectorArea - doubleTriangleArea; if (pline[i].bulgeIsNeg()) { doubleArcSegArea = -doubleArcSegArea; } @@ -239,9 +239,9 @@ { CAVC_ASSERT(pline.vertexes().size() > 0, "empty polyline has no closest point"); if (pline.vertexes().size() == 1) { - m_index = 0; + m_index = 0; m_distance = length(point - pline[0].pos()); - m_point = pline[0].pos(); + m_point = pline[0].pos(); return; } @@ -249,11 +249,11 @@ auto visitor = [&](std::size_t i, std::size_t j) { Vector2 cp = closestPointOnSeg(pline[i], pline[j], point); - auto diffVec = point - cp; - Real dist2 = dot(diffVec, diffVec); + auto diffVec = point - cp; + Real dist2 = dot(diffVec, diffVec); if (dist2 < m_distance) { - m_index = i; - m_point = cp; + m_index = i; + m_point = cp; m_distance = dist2; } @@ -282,7 +282,7 @@ Real distance() const { return m_distance; } private: - std::size_t m_index = 0; + std::size_t m_index = 0; Vector2 m_point = Vector2::zero(); Real m_distance; }; @@ -295,7 +295,7 @@ { cavc::Polyline result; result.isClosed() = pline.isClosed(); - auto visitor = [&](std::size_t i, std::size_t j) { + auto visitor = [&](std::size_t i, std::size_t j) { const auto& v1 = pline[i]; const auto& v2 = pline[j]; if (v1.bulgeIsZero()) { @@ -309,11 +309,11 @@ } auto startAngle = angle(arc.center, v1.pos()); - auto endAngle = angle(arc.center, v2.pos()); + auto endAngle = angle(arc.center, v2.pos()); Real deltaAngle = std::abs(cavc::utils::deltaAngle(startAngle, endAngle)); - error = std::abs(error); - Real segmentSubAngle = std::abs(Real(2) * std::acos(Real(1) - error / arc.radius)); + error = std::abs(error); + Real segmentSubAngle = std::abs(Real(2) * std::acos(Real(1) - error / arc.radius)); std::size_t segmentCount = static_cast(std::ceil(deltaAngle / segmentSubAngle)); // update segment subangle for equal length segments segmentSubAngle = deltaAngle / segmentCount; @@ -432,7 +432,7 @@ if (pline.size() < 2) { return Real(0); } - Real result = Real(0); + Real result = Real(0); auto visitor = [&](std::size_t i, std::size_t j) { result += segLength(pline[i], pline[j]); return true; @@ -470,7 +470,7 @@ // Helper function to determine if point is inside an arc sector area auto distToArcCenterLessThanRadius = [](const auto& v1, const auto& v2, const auto& pt) { - auto arc = arcRadiusAndCenter(v1, v2); + auto arc = arcRadiusAndCenter(v1, v2); Real dist2 = distSquared(arc.center, pt); return dist2 < arc.radius * arc.radius; }; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/polylineintersects.hpp metview-5.19.2/metview/src/uPlot/cavc/polylineintersects.hpp --- metview-5.17.4/metview/src/uPlot/cavc/polylineintersects.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/polylineintersects.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -79,8 +79,8 @@ for (auto& intr : coincidentIntrs) { auto const& sp = pline1[intr.sIndex1].pos(); - Real dist1 = distSquared(sp, intr.point1); - Real dist2 = distSquared(sp, intr.point2); + Real dist1 = distSquared(sp, intr.point1); + Real dist2 = distSquared(sp, intr.point2); if (dist1 > dist2) { std::swap(intr.point1, intr.point2); } @@ -93,29 +93,29 @@ } // equal index so sort distance from start auto const& sp = pline1[intr1.sIndex1].pos(); - Real dist1 = distSquared(sp, intr1.point1); - Real dist2 = distSquared(sp, intr2.point1); + Real dist1 = distSquared(sp, intr1.point1); + Real dist2 = distSquared(sp, intr2.point1); return dist1 < dist2; }); - auto& sliceStartPoints = result.sliceStartPoints; - auto& sliceEndPoints = result.sliceEndPoints; - auto& coincidentSlices = result.coincidentSlices; + auto& sliceStartPoints = result.sliceStartPoints; + auto& sliceEndPoints = result.sliceEndPoints; + auto& coincidentSlices = result.coincidentSlices; auto& coincidentIsOpposingDirection = result.coincidentIsOpposingDirection; Polyline currCoincidentSlice; auto startCoincidentSliceAt = [&](std::size_t intrIndex) { const auto& intr = coincidentIntrs[intrIndex]; - const auto& v1 = pline1[intr.sIndex1]; - const auto& v2 = pline1[utils::nextWrappingIndex(intr.sIndex1, pline1)]; - const auto& u1 = pline2[intr.sIndex2]; - const auto& u2 = pline2[utils::nextWrappingIndex(intr.sIndex2, pline2)]; - auto const& t1 = segTangentVector(v1, v2, v1.pos()); - auto const& t2 = segTangentVector(u1, u2, u1.pos()); + const auto& v1 = pline1[intr.sIndex1]; + const auto& v2 = pline1[utils::nextWrappingIndex(intr.sIndex1, pline1)]; + const auto& u1 = pline2[intr.sIndex2]; + const auto& u2 = pline2[utils::nextWrappingIndex(intr.sIndex2, pline2)]; + auto const& t1 = segTangentVector(v1, v2, v1.pos()); + auto const& t2 = segTangentVector(u1, u2, u1.pos()); // tangent vectors are either going same direction or opposite direction, just test dot product // sign to determine if going same direction - auto dotP = dot(t1, t2); + auto dotP = dot(t1, t2); bool sameDirection = dotP > Real(0); coincidentIsOpposingDirection.push_back(!sameDirection); @@ -147,12 +147,12 @@ auto endCoincidentSliceAt = [&](std::size_t intrIndex) { const auto& intr = coincidentIntrs[intrIndex]; - const auto& u1 = pline2[intr.sIndex2]; + const auto& u1 = pline2[intr.sIndex2]; coincidentSlices.emplace_back(); std::swap(coincidentSlices.back(), currCoincidentSlice); PlineIntersect sliceEnd; - sliceEnd.pos = intr.point2; + sliceEnd.pos = intr.point2; sliceEnd.sIndex1 = intr.sIndex1; if (fuzzyEqual(u1.pos(), sliceEnd.pos, utils::realPrecision())) { sliceEnd.sIndex2 = utils::prevWrappingIndex(intr.sIndex2, pline2); @@ -167,8 +167,8 @@ startCoincidentSliceAt(0); for (std::size_t i = 1; i < coincidentIntrs.size(); ++i) { const auto& intr = coincidentIntrs[i]; - const auto& v1 = pline1[intr.sIndex1]; - const auto& v2 = pline1[utils::nextWrappingIndex(intr.sIndex1, pline1)]; + const auto& v1 = pline1[intr.sIndex1]; + const auto& v2 = pline1[utils::nextWrappingIndex(intr.sIndex1, pline1)]; if (fuzzyEqual(intr.point1, currCoincidentSlice.lastVertex().pos(), utils::realPrecision())) { @@ -191,7 +191,7 @@ if (coincidentSlices.size() > 1) { // check if last coincident slice connects with first - const auto& lastSliceEnd = coincidentSlices.back().lastVertex().pos(); + const auto& lastSliceEnd = coincidentSlices.back().lastVertex().pos(); const auto& firstSliceBegin = coincidentSlices[0][0].pos(); if (fuzzyEqual(lastSliceEnd, firstSliceBegin, utils::realPrecision())) { // they do connect, join them together @@ -310,7 +310,7 @@ queryStack.reserve(8); auto visitor = [&](std::size_t i, Real minX, Real minY, Real maxX, Real maxY) { - std::size_t j = utils::nextWrappingIndex(i, pline); + std::size_t j = utils::nextWrappingIndex(i, pline); const PlineVertex& v1 = pline[i]; const PlineVertex& v2 = pline[j]; AABB envelope{minX, minY, maxX, maxY}; @@ -402,7 +402,7 @@ std::unordered_set, internal::IndexPairHash> possibleDuplicates; - auto& intrs = output.intersects; + auto& intrs = output.intersects; auto& coincidentIntrs = output.coincidentIntersects; auto pline2SegVisitor = [&](std::size_t i2, std::size_t j2) { @@ -418,7 +418,7 @@ queryResults, queryStack); for (std::size_t i1 : queryResults) { - std::size_t j1 = utils::nextWrappingIndex(i1, pline1); + std::size_t j1 = utils::nextWrappingIndex(i1, pline1); PlineVertex const& p1v1 = pline1[i1]; PlineVertex const& p1v2 = pline1[j1]; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/polylineoffset.hpp metview-5.19.2/metview/src/uPlot/cavc/polylineoffset.hpp --- metview-5.17.4/metview/src/uPlot/cavc/polylineoffset.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/polylineoffset.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -37,20 +37,20 @@ auto lineVisitor = [&](PlineVertex const& v1, PlineVertex const& v2) { result.emplace_back(); PlineOffsetSegment& seg = result.back(); - seg.collapsedArc = false; - seg.origV2Pos = v2.pos(); - Vector2 edge = v2.pos() - v1.pos(); - Vector2 offsetV = offset * unitPerp(edge); - seg.v1.pos() = v1.pos() + offsetV; - seg.v1.bulge() = v1.bulge(); - seg.v2.pos() = v2.pos() + offsetV; - seg.v2.bulge() = v2.bulge(); + seg.collapsedArc = false; + seg.origV2Pos = v2.pos(); + Vector2 edge = v2.pos() - v1.pos(); + Vector2 offsetV = offset * unitPerp(edge); + seg.v1.pos() = v1.pos() + offsetV; + seg.v1.bulge() = v1.bulge(); + seg.v2.pos() = v2.pos() + offsetV; + seg.v2.bulge() = v2.bulge(); }; auto arcVisitor = [&](PlineVertex const& v1, PlineVertex const& v2) { - auto arc = arcRadiusAndCenter(v1, v2); - Real offs = v1.bulgeIsNeg() ? offset : -offset; - Real radiusAfterOffset = arc.radius + offs; + auto arc = arcRadiusAndCenter(v1, v2); + Real offs = v1.bulgeIsNeg() ? offset : -offset; + Real radiusAfterOffset = arc.radius + offs; Vector2 v1ToCenter = v1.pos() - arc.center; normalize(v1ToCenter); Vector2 v2ToCenter = v2.pos() - arc.center; @@ -58,20 +58,20 @@ result.emplace_back(); PlineOffsetSegment& seg = result.back(); - seg.origV2Pos = v2.pos(); - seg.v1.pos() = offs * v1ToCenter + v1.pos(); - seg.v2.pos() = offs * v2ToCenter + v2.pos(); - seg.v2.bulge() = v2.bulge(); + seg.origV2Pos = v2.pos(); + seg.v1.pos() = offs * v1ToCenter + v1.pos(); + seg.v2.pos() = offs * v2ToCenter + v2.pos(); + seg.v2.bulge() = v2.bulge(); if (radiusAfterOffset < utils::realThreshold()) { // collapsed arc, offset arc start and end points towards arc center and turn into line // handles case where offset vertexes are equal and simplifies path for clipping algorithm seg.collapsedArc = true; - seg.v1.bulge() = Real(0); + seg.v1.bulge() = Real(0); } else { seg.collapsedArc = false; - seg.v1.bulge() = v1.bulge(); + seg.v1.bulge() = v1.bulge(); } }; @@ -107,10 +107,10 @@ Real bulgeForConnection(Vector2 const& arcCenter, Vector2 const& sp, Vector2 const& ep, bool isCCW) { - Real a1 = angle(arcCenter, sp); - Real a2 = angle(arcCenter, ep); + Real a1 = angle(arcCenter, sp); + Real a2 = angle(arcCenter, ep); Real absSweepAngle = std::abs(utils::deltaAngle(a1, a2)); - Real absBulge = std::tan(absSweepAngle / Real(4)); + Real absBulge = std::tan(absSweepAngle / Real(4)); if (isCCW) { return absBulge; } @@ -130,9 +130,9 @@ auto connectUsingArc = [&] { auto const& arcCenter = s1.origV2Pos; - auto const& sp = v2.pos(); - auto const& ep = u1.pos(); - Real bulge = bulgeForConnection(arcCenter, sp, ep, connectionArcsAreCCW); + auto const& sp = v2.pos(); + auto const& ep = u1.pos(); + Real bulge = bulgeForConnection(arcCenter, sp, ep, connectionArcsAreCCW); addOrReplaceIfSamePos(result, PlineVertex(sp, bulge)); addOrReplaceIfSamePos(result, PlineVertex(ep, Real(0))); }; @@ -183,9 +183,9 @@ auto connectUsingArc = [&] { auto const& arcCenter = s1.origV2Pos; - auto const& sp = v2.pos(); - auto const& ep = u1.pos(); - Real bulge = bulgeForConnection(arcCenter, sp, ep, connectionArcsAreCCW); + auto const& sp = v2.pos(); + auto const& ep = u1.pos(); + Real bulge = bulgeForConnection(arcCenter, sp, ep, connectionArcsAreCCW); addOrReplaceIfSamePos(result, PlineVertex(sp, bulge)); addOrReplaceIfSamePos(result, u1); }; @@ -198,9 +198,9 @@ pointWithinArcSweepAngle(arc.center, u1.pos(), u2.pos(), u1.bulge(), intersect); if (trueSegIntersect && trueArcIntersect) { // trim at intersect - Real a = angle(arc.center, intersect); + Real a = angle(arc.center, intersect); Real arcEndAngle = angle(arc.center, u2.pos()); - Real theta = utils::deltaAngle(a, arcEndAngle); + Real theta = utils::deltaAngle(a, arcEndAngle); // ensure the sign matches (may get flipped if intersect is at the very end of the arc, in // which case we do not want to update the bulge) if ((theta > Real(0)) == u1.bulgeIsPos()) { @@ -235,9 +235,9 @@ CAVC_ASSERT(intrResult.numIntersects == 2, "should have 2 intersects here"); // always use intersect closest to original point Vector2 i1 = pointFromParametric(v1.pos(), v2.pos(), intrResult.t0); - Real dist1 = distSquared(i1, s1.origV2Pos); + Real dist1 = distSquared(i1, s1.origV2Pos); Vector2 i2 = pointFromParametric(v1.pos(), v2.pos(), intrResult.t1); - Real dist2 = distSquared(i2, s1.origV2Pos); + Real dist2 = distSquared(i2, s1.origV2Pos); if (dist1 < dist2) { processIntersect(intrResult.t0, i1); @@ -261,9 +261,9 @@ auto connectUsingArc = [&] { auto const& arcCenter = s1.origV2Pos; - auto const& sp = v2.pos(); - auto const& ep = u1.pos(); - Real bulge = bulgeForConnection(arcCenter, sp, ep, connectionArcsAreCCW); + auto const& sp = v2.pos(); + auto const& ep = u1.pos(); + Real bulge = bulgeForConnection(arcCenter, sp, ep, connectionArcsAreCCW); addOrReplaceIfSamePos(result, PlineVertex(sp, bulge)); addOrReplaceIfSamePos(result, u1); }; @@ -279,10 +279,10 @@ if (!prevVertex.bulgeIsZero() && !fuzzyEqual(prevVertex.pos(), v2.pos())) { // modify previous bulge and trim at intersect - Real a = angle(arc.center, intersect); - auto prevArc = arcRadiusAndCenter(prevVertex, v2); + Real a = angle(arc.center, intersect); + auto prevArc = arcRadiusAndCenter(prevVertex, v2); Real prevArcStartAngle = angle(prevArc.center, prevVertex.pos()); - Real updatedPrevTheta = utils::deltaAngle(prevArcStartAngle, a); + Real updatedPrevTheta = utils::deltaAngle(prevArcStartAngle, a); // ensure the sign matches (may get flipped if intersect is at the very end of the arc, in // which case we do not want to update the bulge) @@ -308,10 +308,10 @@ else { CAVC_ASSERT(intrResult.numIntersects == 2, "should have 2 intersects here"); const auto& origPoint = s2.collapsedArc ? u1.pos() : s1.origV2Pos; - Vector2 i1 = pointFromParametric(u1.pos(), u2.pos(), intrResult.t0); - Real dist1 = distSquared(i1, origPoint); - Vector2 i2 = pointFromParametric(u1.pos(), u2.pos(), intrResult.t1); - Real dist2 = distSquared(i2, origPoint); + Vector2 i1 = pointFromParametric(u1.pos(), u2.pos(), intrResult.t0); + Real dist1 = distSquared(i1, origPoint); + Vector2 i2 = pointFromParametric(u1.pos(), u2.pos(), intrResult.t1); + Real dist2 = distSquared(i2, origPoint); if (dist1 < dist2) { processIntersect(intrResult.t0, i1); @@ -337,9 +337,9 @@ auto connectUsingArc = [&] { auto const& arcCenter = s1.origV2Pos; - auto const& sp = v2.pos(); - auto const& ep = u1.pos(); - Real bulge = bulgeForConnection(arcCenter, sp, ep, connectionArcsAreCCW); + auto const& sp = v2.pos(); + auto const& ep = u1.pos(); + Real bulge = bulgeForConnection(arcCenter, sp, ep, connectionArcsAreCCW); addOrReplaceIfSamePos(result, PlineVertex(sp, bulge)); addOrReplaceIfSamePos(result, u1); }; @@ -354,10 +354,10 @@ PlineVertex& prevVertex = result.lastVertex(); if (!prevVertex.bulgeIsZero() && !fuzzyEqual(prevVertex.pos(), v2.pos())) { // modify previous bulge and trim at intersect - Real a1 = angle(arc1.center, intersect); - auto prevArc = arcRadiusAndCenter(prevVertex, v2); + Real a1 = angle(arc1.center, intersect); + auto prevArc = arcRadiusAndCenter(prevVertex, v2); Real prevArcStartAngle = angle(prevArc.center, prevVertex.pos()); - Real updatedPrevTheta = utils::deltaAngle(prevArcStartAngle, a1); + Real updatedPrevTheta = utils::deltaAngle(prevArcStartAngle, a1); // ensure the sign matches (may get flipped if intersect is at the very end of the arc, in // which case we do not want to update the bulge) @@ -367,9 +367,9 @@ } // add the vertex at our current trim/join point - Real a2 = angle(arc2.center, intersect); + Real a2 = angle(arc2.center, intersect); Real endAngle = angle(arc2.center, u2.pos()); - Real theta = utils::deltaAngle(a2, endAngle); + Real theta = utils::deltaAngle(a2, endAngle); // ensure the sign matches (may get flipped if intersect is at the very end of the arc, in // which case we do not want to update the bulge) @@ -494,15 +494,15 @@ Real offsetTol = utils::offsetThreshold()) { const Real absOffset = std::abs(offset) - offsetTol; - const Real minDist = absOffset * absOffset; + const Real minDist = absOffset * absOffset; bool pointValid = true; auto visitor = [&](std::size_t i) { - std::size_t j = utils::nextWrappingIndex(i, pline.vertexes()); + std::size_t j = utils::nextWrappingIndex(i, pline.vertexes()); auto closestPoint = closestPointOnSeg(pline[i], pline[j], point); - Real dist = distSquared(closestPoint, point); - pointValid = dist > minDist; + Real dist = distSquared(closestPoint, point); + pointValid = dist > minDist; return pointValid; }; @@ -598,9 +598,9 @@ } else if (result.size() > 1) { // update position and bulge - const auto arc = arcRadiusAndCenter(result[0], result[1]); - const Real a1 = angle(arc.center, updatedFirstPos); - const Real a2 = angle(arc.center, result[1].pos()); + const auto arc = arcRadiusAndCenter(result[0], result[1]); + const Real a1 = angle(arc.center, updatedFirstPos); + const Real a2 = angle(arc.center, result[1].pos()); const Real updatedTheta = utils::deltaAngle(a1, a2); if ((updatedTheta < Real(0) && result[0].bulgeIsPos()) || (updatedTheta > Real(0) && result[0].bulgeIsNeg())) { @@ -609,7 +609,7 @@ } else { // update position and bulge - result[0].pos() = updatedFirstPos; + result[0].pos() = updatedFirstPos; result[0].bulge() = std::tan(updatedTheta / Real(4)); } } @@ -660,7 +660,7 @@ return result; } - StaticSpatialIndex origPlineSpatialIndex = createApproxSpatialIndex(originalPline); + StaticSpatialIndex origPlineSpatialIndex = createApproxSpatialIndex(originalPline); StaticSpatialIndex rawOffsetPlineSpatialIndex = createApproxSpatialIndex(rawOffsetPline); std::vector> selfIntersects; @@ -696,7 +696,7 @@ // sort intersects by distance from start vertex for (auto& kvp : intersectsLookup) { Vector2 startPos = rawOffsetPline[kvp.first].pos(); - auto cmp = [&](Vector2 const& si1, Vector2 const& si2) { + auto cmp = [&](Vector2 const& si1, Vector2 const& si2) { return distSquared(si1, startPos) < distSquared(si2, startPos); }; std::sort(kvp.second.begin(), kvp.second.end(), cmp); @@ -704,8 +704,8 @@ auto intersectsOrigPline = [&](PlineVertex const& v1, PlineVertex const& v2) { AABB approxBB = createFastApproxBoundingBox(v1, v2); - bool hasIntersect = false; - auto visitor = [&](std::size_t i) { + bool hasIntersect = false; + auto visitor = [&](std::size_t i) { using namespace internal; std::size_t j = utils::nextWrappingIndex(i, originalPline); IntrPlineSegsResult intrResult = @@ -727,14 +727,14 @@ std::vector> const& siList = kvp.second; const auto& startVertex = rawOffsetPline[sIndex]; - std::size_t nextIndex = utils::nextWrappingIndex(sIndex, rawOffsetPline); - const auto& endVertex = rawOffsetPline[nextIndex]; + std::size_t nextIndex = utils::nextWrappingIndex(sIndex, rawOffsetPline); + const auto& endVertex = rawOffsetPline[nextIndex]; if (siList.size() != 1) { // build all the segments between the N intersects in siList (N > 1), skipping the first // segment (to be processed at the end) SplitResult firstSplit = splitAtPoint(startVertex, endVertex, siList[0]); - auto prevVertex = firstSplit.splitVertex; + auto prevVertex = firstSplit.splitVertex; for (std::size_t i = 1; i < siList.size(); ++i) { SplitResult split = splitAtPoint(prevVertex, endVertex, siList[i]); // update prevVertex for next loop iteration @@ -788,9 +788,9 @@ Polyline currSlice; currSlice.addVertex(split.splitVertex); - std::size_t index = nextIndex; - bool isValidPline = true; - std::size_t loopCount = 0; + std::size_t index = nextIndex; + bool isValidPline = true; + std::size_t loopCount = 0; const std::size_t maxLoopCount = rawOffsetPline.size(); while (true) { if (loopCount++ > maxLoopCount) { @@ -878,7 +878,7 @@ return result; } - StaticSpatialIndex origPlineSpatialIndex = createApproxSpatialIndex(originalPline); + StaticSpatialIndex origPlineSpatialIndex = createApproxSpatialIndex(originalPline); StaticSpatialIndex rawOffsetPlineSpatialIndex = createApproxSpatialIndex(rawOffsetPline); std::vector> selfIntersects; @@ -941,7 +941,7 @@ // sort intersects by distance from start vertex for (auto& kvp : intersectsLookup) { Vector2 startPos = rawOffsetPline[kvp.first].pos(); - auto cmp = [&](Vector2 const& si1, Vector2 const& si2) { + auto cmp = [&](Vector2 const& si1, Vector2 const& si2) { return distSquared(si1, startPos) < distSquared(si2, startPos); }; std::sort(kvp.second.begin(), kvp.second.end(), cmp); @@ -949,8 +949,8 @@ auto intersectsOrigPline = [&](PlineVertex const& v1, PlineVertex const& v2) { AABB approxBB = createFastApproxBoundingBox(v1, v2); - bool intersects = false; - auto visitor = [&](std::size_t i) { + bool intersects = false; + auto visitor = [&](std::size_t i) { using namespace internal; std::size_t j = utils::nextWrappingIndex(i, originalPline); IntrPlineSegsResult intrResult = @@ -969,8 +969,8 @@ // build first open polyline that ends at the first intersect since we will not wrap back to // capture it as in the case of a closed polyline Polyline firstSlice; - std::size_t index = 0; - std::size_t loopCount = 0; + std::size_t index = 0; + std::size_t loopCount = 0; const std::size_t maxLoopCount = rawOffsetPline.size(); while (true) { if (loopCount++ > maxLoopCount) { @@ -1005,7 +1005,7 @@ splitAtPoint(rawOffsetPline[index], rawOffsetPline[index + 1], intersectPos); PlineVertex sliceEndVertex = PlineVertex(intersectPos, Real(0)); - auto midpoint = segMidpoint(split.updatedStart, sliceEndVertex); + auto midpoint = segMidpoint(split.updatedStart, sliceEndVertex); if (!internal::pointValidForOffset(originalPline, offset, origPlineSpatialIndex, midpoint, queryStack)) { break; @@ -1032,14 +1032,14 @@ std::vector> const& siList = kvp.second; const auto& startVertex = rawOffsetPline[sIndex]; - std::size_t nextIndex = utils::nextWrappingIndex(sIndex, rawOffsetPline); - const auto& endVertex = rawOffsetPline[nextIndex]; + std::size_t nextIndex = utils::nextWrappingIndex(sIndex, rawOffsetPline); + const auto& endVertex = rawOffsetPline[nextIndex]; if (siList.size() != 1) { // build all the segments between the N intersects in siList (N > 1), skipping the first // segment (to be processed at the end) SplitResult firstSplit = splitAtPoint(startVertex, endVertex, siList[0]); - auto prevVertex = firstSplit.splitVertex; + auto prevVertex = firstSplit.splitVertex; for (std::size_t i = 1; i < siList.size(); ++i) { SplitResult split = splitAtPoint(prevVertex, endVertex, siList[i]); // update prevVertex for next loop iteration @@ -1093,9 +1093,9 @@ Polyline currSlice; currSlice.addVertex(split.splitVertex); - std::size_t index = nextIndex; - bool isValidPline = true; - std::size_t loopCount = 0; + std::size_t index = nextIndex; + bool isValidPline = true; + std::size_t loopCount = 0; const std::size_t maxLoopCount = rawOffsetPline.size(); while (true) { if (loopCount++ > maxLoopCount) { @@ -1221,9 +1221,9 @@ visitedIndexes[i] = true; Polyline currPline; - std::size_t currIndex = i; - auto const& initialStartPoint = slices[i].pline[0].pos(); - std::size_t loopCount = 0; + std::size_t currIndex = i; + auto const& initialStartPoint = slices[i].pline[0].pos(); + std::size_t loopCount = 0; const std::size_t maxLoopCount = slices.size(); while (true) { if (loopCount++ > maxLoopCount) { @@ -1232,8 +1232,8 @@ break; } const std::size_t currLoopStartIndex = slices[currIndex].intrStartIndex; - auto const& currSlice = slices[currIndex].pline; - auto const& currEndPoint = slices[currIndex].pline.lastVertex().pos(); + auto const& currSlice = slices[currIndex].pline; + auto const& currEndPoint = slices[currIndex].pline.lastVertex().pos(); currPline.vertexes().insert(currPline.vertexes().end(), currSlice.vertexes().begin(), currSlice.vertexes().end()); queryResults.clear(); @@ -1316,7 +1316,7 @@ // not closed polyline or has self intersects, must apply dual clipping auto dualRawOffset = createRawOffsetPline(pline, -offset); - auto slices = dualSliceAtIntersectsForOffset(pline, rawOffset, dualRawOffset, offset); + auto slices = dualSliceAtIntersectsForOffset(pline, rawOffset, dualRawOffset, offset); return stitchOffsetSlicesTogether(slices, pline.isClosed(), rawOffset.size() - 1); } diff -Nru metview-5.17.4/metview/src/uPlot/cavc/polylineoffsetislands.hpp metview-5.19.2/metview/src/uPlot/cavc/polylineoffsetislands.hpp --- metview-5.17.4/metview/src/uPlot/cavc/polylineoffsetislands.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/polylineoffsetislands.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -179,7 +179,7 @@ m_slicePointsLookup.resize(totalOffsetCount); PlineIntersectsResult intrsResults; for (std::size_t i = 0; i < totalOffsetCount; ++i) { - auto const& loop1 = getOffsetLoop(i); + auto const& loop1 = getOffsetLoop(i); auto const& index1 = loop1.spatialIndex; m_queryResults.clear(); m_offsetLoopsIndex->query(index1.minX(), index1.minY(), index1.maxX(), index1.maxY(), @@ -203,7 +203,7 @@ findIntersects(loop1.polyline, loop2.polyline, index1, intrsResults); if (intrsResults.hasIntersects()) { m_slicePointSets.emplace_back(); - auto& slicePointSet = m_slicePointSets.back(); + auto& slicePointSet = m_slicePointSets.back(); slicePointSet.loopIndex1 = i; slicePointSet.loopIndex2 = j; for (auto& intr : intrsResults.intersects) { @@ -254,11 +254,11 @@ std::vector& result) { OffsetLoop const& offsetLoop = getOffsetLoop(loopIndex); - std::size_t const parentIndex = offsetLoop.parentLoopIndex; - Polyline const& pline = offsetLoop.polyline; + std::size_t const parentIndex = offsetLoop.parentLoopIndex; + Polyline const& pline = offsetLoop.polyline; m_loopDissectionPoints.clear(); for (auto const& setIndex : m_slicePointsLookup[loopIndex]) { - auto const& set = m_slicePointSets[setIndex]; + auto const& set = m_slicePointSets[setIndex]; bool isFirstIndex = loopIndex == set.loopIndex1; if (isFirstIndex) { for (auto const& p : set.slicePoints) { @@ -275,7 +275,7 @@ // sort points by distance from start vertex for (auto& kvp : m_loopDissectionPoints) { Vector2 startPos = pline[kvp.first].pos(); - auto cmp = [&](DissectionPoint const& p1, DissectionPoint const& p2) { + auto cmp = [&](DissectionPoint const& p1, DissectionPoint const& p2) { return distSquared(p1.pos, startPos) < distSquared(p2.pos, startPos); }; std::sort(kvp.second.begin(), kvp.second.end(), cmp); @@ -289,8 +289,8 @@ std::vector const& intrsList = kvp.second; const auto& firstSegStartVertex = pline[sIndex]; - std::size_t nextIndex = utils::nextWrappingIndex(sIndex, pline); - const auto& firstSegEndVertex = pline[nextIndex]; + std::size_t nextIndex = utils::nextWrappingIndex(sIndex, pline); + const auto& firstSegEndVertex = pline[nextIndex]; if (intrsList.size() != 1) { // build all the segments between the N intersects in siList (N > 1), skipping the first @@ -300,8 +300,8 @@ auto prevVertex = firstSplit.splitVertex; for (std::size_t i = 1; i < intrsList.size(); ++i) { std::size_t const sliceStartIndex = intrsList[i - 1].otherLoopIndex; - std::size_t const sliceEndIndex = intrsList[i].otherLoopIndex; - SplitResult split = splitAtPoint(prevVertex, firstSegEndVertex, intrsList[i].pos); + std::size_t const sliceEndIndex = intrsList[i].otherLoopIndex; + SplitResult split = splitAtPoint(prevVertex, firstSegEndVertex, intrsList[i].pos); // update prevVertex for next loop iteration prevVertex = split.splitVertex; @@ -320,8 +320,8 @@ result.back().pline.addVertex(split.updatedStart); result.back().pline.addVertex(split.splitVertex); result.back().sliceParentIndex = loopIndex; - result.back().startLoopIndex = sliceStartIndex; - result.back().endLoopIndex = sliceEndIndex; + result.back().startLoopIndex = sliceStartIndex; + result.back().endLoopIndex = sliceEndIndex; } } @@ -332,10 +332,10 @@ DissectedSlice currSlice; currSlice.pline.addVertex(split.splitVertex); currSlice.sliceParentIndex = loopIndex; - currSlice.startLoopIndex = intrsList.back().otherLoopIndex; + currSlice.startLoopIndex = intrsList.back().otherLoopIndex; - std::size_t index = nextIndex; - std::size_t loopCount = 0; + std::size_t index = nextIndex; + std::size_t loopCount = 0; const std::size_t maxLoopCount = pline.size(); while (true) { if (loopCount++ > maxLoopCount) { @@ -354,7 +354,7 @@ // trim last added vertex and add final intersect position PlineVertex endVertex = PlineVertex(intersectPos, Real(0)); - std::size_t nextIndex = utils::nextWrappingIndex(index, pline); + std::size_t nextIndex = utils::nextWrappingIndex(index, pline); SplitResult split = splitAtPoint(currSlice.pline.lastVertex(), pline[nextIndex], intersectPos); currSlice.pline.lastVertex() = split.updatedStart; diff -Nru metview-5.17.4/metview/src/uPlot/cavc/staticspatialindex.hpp metview-5.19.2/metview/src/uPlot/cavc/staticspatialindex.hpp --- metview-5.17.4/metview/src/uPlot/cavc/staticspatialindex.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/staticspatialindex.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -19,12 +19,12 @@ static_assert(NodeSize >= 2 && NodeSize <= 65535, "node size must be between 2 and 65535"); // calculate the total number of nodes in the R-tree to allocate space for // and the index of each tree level (used in search later) - m_numItems = numItems; - std::size_t n = numItems; + m_numItems = numItems; + std::size_t n = numItems; std::size_t numNodes = numItems; - m_numLevels = computeNumLevels(numItems); - m_levelBounds = std::unique_ptr(new std::size_t[m_numLevels]); + m_numLevels = computeNumLevels(numItems); + m_levelBounds = std::unique_ptr(new std::size_t[m_numLevels]); m_levelBounds[0] = n * 4; // now populate level bounds and numNodes std::size_t i = 1; @@ -36,13 +36,13 @@ } while (n != 1); m_numNodes = numNodes; - m_boxes = std::unique_ptr(new Real[numNodes * 4]); - m_indices = std::unique_ptr(new std::size_t[numNodes]); - m_pos = 0; - m_minX = std::numeric_limits::infinity(); - m_minY = std::numeric_limits::infinity(); - m_maxX = -std::numeric_limits::infinity(); - m_maxY = -std::numeric_limits::infinity(); + m_boxes = std::unique_ptr(new Real[numNodes * 4]); + m_indices = std::unique_ptr(new std::size_t[numNodes]); + m_pos = 0; + m_minX = std::numeric_limits::infinity(); + m_minY = std::numeric_limits::infinity(); + m_maxX = -std::numeric_limits::infinity(); + m_maxY = -std::numeric_limits::infinity(); } Real minX() const { return m_minX; } @@ -53,11 +53,11 @@ void add(Real minX, Real minY, Real maxX, Real maxY) { std::size_t index = m_pos >> 2; - m_indices[index] = index; - m_boxes[m_pos++] = minX; - m_boxes[m_pos++] = minY; - m_boxes[m_pos++] = maxX; - m_boxes[m_pos++] = maxY; + m_indices[index] = index; + m_boxes[m_pos++] = minX; + m_boxes[m_pos++] = minY; + m_boxes[m_pos++] = maxX; + m_boxes[m_pos++] = maxY; if (minX < m_minX) m_minX = minX; @@ -85,14 +85,14 @@ return; } - Real width = m_maxX - m_minX; + Real width = m_maxX - m_minX; Real height = m_maxY - m_minY; std::unique_ptr hilbertValues(new std::uint32_t[m_numItems]); std::size_t pos = 0; for (std::size_t i = 0; i < m_numItems; ++i) { - pos = 4 * i; + pos = 4 * i; Real minX = m_boxes[pos++]; Real minY = m_boxes[pos++]; Real maxX = m_boxes[pos++]; @@ -104,9 +104,9 @@ // [0 -> n - 1] such that the min of the entire set of bounding boxes maps to 0 and the max of // the entire set of bounding boxes maps to n - 1 our 2d space is x: [0 -> n-1] and // y: [0 -> n-1], our 1d hilbert curve value space is d: [0 -> n^2 - 1] - Real x = std::floor(hilbertMax * ((minX + maxX) / 2 - m_minX) / width); + Real x = std::floor(hilbertMax * ((minX + maxX) / 2 - m_minX) / width); std::uint32_t hx = static_cast(x); - Real y = std::floor(hilbertMax * ((minY + maxY) / 2 - m_minY) / height); + Real y = std::floor(hilbertMax * ((minY + maxY) / 2 - m_minY) / height); std::uint32_t hy = static_cast(y); hilbertValues[i] = hilbertXYToIndex(hx, hy); } @@ -121,10 +121,10 @@ // generate a parent node for each block of consecutive nodes while (pos < end) { - auto nodeMinX = std::numeric_limits::infinity(); - auto nodeMinY = std::numeric_limits::infinity(); - auto nodeMaxX = -1 * std::numeric_limits::infinity(); - auto nodeMaxY = -1 * std::numeric_limits::infinity(); + auto nodeMinX = std::numeric_limits::infinity(); + auto nodeMinY = std::numeric_limits::infinity(); + auto nodeMaxX = -1 * std::numeric_limits::infinity(); + auto nodeMaxY = -1 * std::numeric_limits::infinity(); auto nodeIndex = pos; // calculate bbox for the new node @@ -145,10 +145,10 @@ // add the new node to the tree data m_indices[m_pos >> 2] = nodeIndex; - m_boxes[m_pos++] = nodeMinX; - m_boxes[m_pos++] = nodeMinY; - m_boxes[m_pos++] = nodeMaxX; - m_boxes[m_pos++] = nodeMaxY; + m_boxes[m_pos++] = nodeMinX; + m_boxes[m_pos++] = nodeMinY; + m_boxes[m_pos++] = nodeMaxX; + m_boxes[m_pos++] = nodeMaxY; } } } @@ -160,7 +160,7 @@ void visitBoundingBoxes(F&& visitor) const { std::size_t nodeIndex = 4 * m_numNodes - 4; - std::size_t level = m_numLevels - 1; + std::size_t level = m_numLevels - 1; std::vector stack; stack.reserve(16); @@ -249,7 +249,7 @@ CAVC_ASSERT(m_pos == 4 * m_numNodes, "data not yet indexed - call Finish() before querying"); auto nodeIndex = 4 * m_numNodes - 4; - auto level = m_numLevels - 1; + auto level = m_numLevels - 1; stack.clear(); @@ -366,7 +366,7 @@ static std::size_t computeNumLevels(std::size_t numItems) { - std::size_t n = numItems; + std::size_t n = numItems; std::size_t levelBoundsSize = 1; do { n = static_cast(std::ceil(static_cast(n) / NodeSize)); @@ -388,8 +388,8 @@ } auto pivot = values[(left + right) >> 1]; - auto i = left - 1; - auto j = right + 1; + auto i = left - 1; + auto j = right + 1; while (true) { do @@ -417,20 +417,20 @@ auto k = 4 * i; auto m = 4 * j; - auto a = boxes[k]; - auto b = boxes[k + 1]; - auto c = boxes[k + 2]; - auto d = boxes[k + 3]; - boxes[k] = boxes[m]; + auto a = boxes[k]; + auto b = boxes[k + 1]; + auto c = boxes[k + 2]; + auto d = boxes[k + 3]; + boxes[k] = boxes[m]; boxes[k + 1] = boxes[m + 1]; boxes[k + 2] = boxes[m + 2]; boxes[k + 3] = boxes[m + 3]; - boxes[m] = a; + boxes[m] = a; boxes[m + 1] = b; boxes[m + 2] = c; boxes[m + 3] = d; - auto e = indices[i]; + auto e = indices[i]; indices[i] = indices[j]; indices[j] = e; } diff -Nru metview-5.17.4/metview/src/uPlot/cavc/vector2.hpp metview-5.19.2/metview/src/uPlot/cavc/vector2.hpp --- metview-5.17.4/metview/src/uPlot/cavc/vector2.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/cavc/vector2.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -77,7 +77,7 @@ // See: http://geomalgorithms.com/a02-_lines.html Vector2 v = p1 - p0; Vector2 w = point - p0; - Real c1 = dot(w, v); + Real c1 = dot(w, v); if (c1 < utils::realThreshold()) { return p0; } diff -Nru metview-5.17.4/metview/src/uPlot/CMakeLists.txt metview-5.19.2/metview/src/uPlot/CMakeLists.txt --- metview-5.17.4/metview/src/uPlot/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -68,6 +68,7 @@ MvQLineSelection.cc MvQZoomStackWidget.cc LayerControlWidget.cc + LocationLabelWidget.cc ShareTargets.cc) @@ -100,6 +101,7 @@ MvQZoomStackWidget.h ExportDialog.h LayerControlWidget.h + LocationLabelWidget.h ShareTargets.h uPlotBase.h uPlot.h diff -Nru metview-5.17.4/metview/src/uPlot/CommonXSectView.cc metview-5.19.2/metview/src/uPlot/CommonXSectView.cc --- metview-5.17.4/metview/src/uPlot/CommonXSectView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CommonXSectView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -37,34 +37,17 @@ else { // Expand request MvRequest expReq = ObjectList::ExpandRequest(viewRequest_, EXPAND_DEFAULTS); - yMin_ = expReq("BOTTOM_LEVEL"); - yMax_ = expReq("TOP_LEVEL"); + yMin_ = expReq("BOTTOM_LEVEL"); + yMax_ = expReq("TOP_LEVEL"); } } -CommonXSectView::CommonXSectView(const CommonXSectView& old) : - PlotModView(old), - PlotModService(old), - latMin_(old.latMin_), - latMax_(old.latMax_), - lonMin_(old.lonMin_), - lonMax_(old.lonMax_), - yMin_(old.yMin_), - yMax_(old.yMax_), - applicationName_(old.applicationName_), - appViewReq_(old.appViewReq_) -{ - //empty -} - -CommonXSectView::~CommonXSectView() = default; - std::string CommonXSectView::Name() { char tmp[32]; sprintf(tmp, "CommonXSectView%d", Owner().Id()); - return std::string(tmp); + return {tmp}; } // Synchronous call service. Calls a service and wait its return. @@ -87,13 +70,13 @@ appRequest("DATA") = dataReq; appRequest("_CONTEXT") = viewRequest_; - appRequest("_ACTION") = (const char*)dataReq("_ACTION") ? (const char*)dataReq("_ACTION") : "prepare"; - appRequest("_VERB") = (const char*)dataReq("_VERB") ? (const char*)dataReq("_VERB") : ""; - appRequest("_CLASS") = (const char*)dataReq("_CLASS") ? (const char*)dataReq("_CLASS") : ""; + appRequest("_ACTION") = (const char*)dataReq("_ACTION") ? (const char*)dataReq("_ACTION") : "prepare"; + appRequest("_VERB") = (const char*)dataReq("_VERB") ? (const char*)dataReq("_VERB") : ""; + appRequest("_CLASS") = (const char*)dataReq("_CLASS") ? (const char*)dataReq("_CLASS") : ""; //( new PlotModTask (this, context, serviceName_.c_str(), appRequest ) )->run(); auto* pmt = new PlotModTask(this, context, serviceName_.c_str(), appRequest); - int err; + int err = 0; replyReq = pmt->run(err); if (!replyReq || err != 0) return false; @@ -102,7 +85,7 @@ viewRequest_("_DATAATTACHED") = "YES"; // This will be done by the destructor of the MvClient/MvTask - //delete pmt; pmt = 0; + // delete pmt; pmt = 0; return true; } @@ -110,7 +93,7 @@ { // Process the drop MvIconDataBase& dataBase = Owner().IconDataBase(); - MvRequest dropRequest = context.InRequest(); + MvRequest dropRequest = context.InRequest(); MvIconList duList; while (dropRequest) { // VisDefs are processed in one single goal. This is because the @@ -132,7 +115,7 @@ // Process data coming from special Modules (i.e. tag _MODULEID) MvRequest replyRequest; - bool consistency_check; + bool consistency_check = false; if (this->DropFromModule(dropRequest, replyRequest, consistency_check)) { // Insert reply request to the database if (consistency_check) @@ -144,14 +127,14 @@ // Process a dataUnit MvRequest request = dropRequest.justOneRequest(); - std::string verb = request.getVerb(); + std::string verb = request.getVerb(); if (ObjectList::IsDataUnit(verb.c_str()) == true) { // Call the service to process the request // After CallService is finished, function PlotModService::endOfTask // should be called and this function should perform the drawing. - //Owner().HasDrawTask(false); - //if ( ! CallService(request, context) ) + // Owner().HasDrawTask(false); + // if ( ! CallService(request, context) ) // InsertDataRequest(request); // It calls an external service and waits for its return. @@ -190,8 +173,8 @@ // may return: XY_MATRIX, XY_POINTS, MGRAPH) // IMPORTANT: DO WE NEED TO CREATE THIS 'PARENT' DATA UNIT???? - //request("_PARENT_DATAUNIT") = 1; - //this->ParentDataUnitId ( 5 ); + // request("_PARENT_DATAUNIT") = 1; + // this->ParentDataUnitId ( 5 ); // Insert reply request to the database duList = this->InsertDataRequest(replyRequest); @@ -219,7 +202,7 @@ Owner().SetDrawPriority(request); // Redraw this page - if (strcmp(request("_APPL"), "macro")) + if (strcmp(request("_APPL"), "macro") != 0) Owner().RedrawIfWindow(); } else @@ -275,7 +258,7 @@ // process option B bool found = false; - int moduleId; + int moduleId = 0; while (dropRequest) { if (!(const char*)dropRequest("_MODULEID")) return found; @@ -327,7 +310,7 @@ break; } - MvRequest req = dropRequest.justOneRequest(); + MvRequest req = dropRequest.justOneRequest(); std::string verb = req.getVerb(); if (verb.find(NETCDF) != std::string::npos || verb.find("INPUT") != std::string::npos) { // Insert the dataunit in the data base at the Page level @@ -342,7 +325,7 @@ DecodeDataUnit(dataUnit); if (this->ParentDataUnitId()) { - dataUnit.ParentId(this->ParentDataUnitId()); //Check if is needed + dataUnit.ParentId(this->ParentDataUnitId()); // Check if is needed MvIcon parentDataUnit; dataBase.RetrieveIconFromList(DB_DATAUNIT, ParentDataUnitId(), parentDataUnit); parentDataUnit.SvcRequest(req); @@ -378,7 +361,7 @@ // Build a new data decoder, which will provide information // about the data std::unique_ptr decoder(DecoderFactory::Make(dataUnit.Request())); - ensure(decoder.get() != 0); + ensure(decoder.get() != nullptr); int subpageId = 0; while (decoder->ReadNextData()) { @@ -397,7 +380,7 @@ std::list doList; subPage->GetDataObjects(doList); std::list::iterator ii; - DataObject* dataObject = 0; + DataObject* dataObject = nullptr; DrawPriorMap drawPriorMap; DrawPriorMap::iterator j; @@ -405,7 +388,7 @@ MvIcon dataUnit; for (ii = doList.begin(); ii != doList.end(); ii++) { dataObject = (*ii); - //if ( ! dataBase.RetrieveDataUnit (dataObject->DataUnitId(), dataUnit) ) + // if ( ! dataBase.RetrieveDataUnit (dataObject->DataUnitId(), dataUnit) ) if (!dataBase.RetrieveIconFromList(DB_DATAUNIT, dataObject->DataUnitId(), dataUnit)) continue; diff -Nru metview-5.17.4/metview/src/uPlot/CommonXSectView.h metview-5.19.2/metview/src/uPlot/CommonXSectView.h --- metview-5.17.4/metview/src/uPlot/CommonXSectView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CommonXSectView.h 2023-07-15 08:28:47.000000000 +0000 @@ -44,10 +44,11 @@ public: // -- Constructor CommonXSectView(Page&, const MvRequest&, const MvRequest&); - CommonXSectView(const CommonXSectView&); + CommonXSectView(const CommonXSectView&) = default; + CommonXSectView& operator=(const CommonXSectView&) = delete; // -- Destructor - ~CommonXSectView(); + ~CommonXSectView() override = default; // -- Methods overriden from PlotModView class std::string Name() override; @@ -67,11 +68,11 @@ void ParentDataUnitId(int parentDataUnitId) { viewRequest_("_PARENT_DATAUNIT_ID") = parentDataUnitId; - appViewReq_("_PARENT_DATAUNIT_ID") = parentDataUnitId; - parentDataUnitId_ = parentDataUnitId; + appViewReq_("_PARENT_DATAUNIT_ID") = parentDataUnitId; + parentDataUnitId_ = parentDataUnitId; } - int ParentDataUnitId() { return parentDataUnitId_; } + int ParentDataUnitId() const { return parentDataUnitId_; } bool ConsistencyCheck(MvRequest&, MvRequest&) override { return true; } @@ -100,47 +101,12 @@ // same tag _MODULEID bool DropFromModule(MvRequest&, MvRequest&, bool&); -#if 0 - // Provide Axis information - void DescribeAxis ( ObjectInfo& description, - MvRequest& axisRequest, - const Cached& axisName ); - - // Check and set axis values. - void CheckAxis(double minValue,double maxValue, - int axisType,MvRequest&, - std::string title = ""); - - bool CheckLatLon(const std::string&,double,double,MvRequest&, const char *); - - virtual void SetVariables(const MvRequest&, bool) {} - - // Check horizontal value - virtual bool CheckHorizontal(MvRequest &) = 0; - - // Add values to a request - void AddValues ( MvRequest& dataRequest, std::vector& dataVector, const char* variableName ); - - // Functions for generating matrix data. - - // convert a netcdf file into a matrix file for use by magics. - bool NetCDFtoMatrix(MvIcon&,MvRequest&); - - void GenerateData(FILE *fp,int startIndex,double yMin, - double yMax,vector &xvector, - std::vector &yvector, int nrPoints, - bool logax = false, bool modlev = false); - - bool FindPressure(vector &yvector,double pk, - int &firstindex,int &nextindex, int); -#endif - - double latMin_, latMax_, lonMin_, lonMax_; - double yMin_, yMax_; + double latMin_{0.}; + double latMax_{0.}; + double lonMin_{0.}; + double lonMax_{0.}; + double yMin_{0.}; + double yMax_{0.}; std::string applicationName_; - MvRequest appViewReq_; //original application view request - -private: - // No assignment - CommonXSectView& operator=(const CommonXSectView&); + MvRequest appViewReq_; // original application view request }; diff -Nru metview-5.17.4/metview/src/uPlot/Counted.h metview-5.19.2/metview/src/uPlot/Counted.h --- metview-5.17.4/metview/src/uPlot/Counted.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Counted.h 2023-07-15 08:28:47.000000000 +0000 @@ -49,8 +49,7 @@ { public: // Contructors - Counted() : - refCount_(0) {} + Counted() = default; // Methods void Attach() @@ -66,13 +65,13 @@ protected: // Destructor - virtual ~Counted() {} + virtual ~Counted() = default; private: // No copy allowed - Counted(const Counted&); + Counted(const Counted&) = delete; Counted& operator=(const Counted&) { return *this; } // Members - int refCount_; + int refCount_{0}; }; diff -Nru metview-5.17.4/metview/src/uPlot/CreateAction.h metview-5.19.2/metview/src/uPlot/CreateAction.h --- metview-5.17.4/metview/src/uPlot/CreateAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CreateAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -55,11 +55,11 @@ PlotModAction(name) {} // Destructor - ~CreateAction() {} + ~CreateAction() override = default; // Methods static PlotModAction& Instance(); // Overriden from PlotModAction - virtual void Execute(PmContext& context); + void Execute(PmContext& context) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/CreateTypeAction.cc metview-5.19.2/metview/src/uPlot/CreateTypeAction.cc --- metview-5.17.4/metview/src/uPlot/CreateTypeAction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CreateTypeAction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ typeReq.setVerb(type); typeReq.unsetParam("TYPE"); typeReq("_CLASS") = type; - typeReq("_VERB") = type; + typeReq("_VERB") = type; req.advance(); // It will skip all the previous requests and only save the diff -Nru metview-5.17.4/metview/src/uPlot/CreateTypeAction.h metview-5.19.2/metview/src/uPlot/CreateTypeAction.h --- metview-5.17.4/metview/src/uPlot/CreateTypeAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CreateTypeAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -46,11 +46,11 @@ PlotModAction(name) {} // Destructor - ~CreateTypeAction() {} + ~CreateTypeAction() override = default; // Methods static PlotModAction& Instance(); // Overriden from Base Class (PlotModAction) - virtual void Execute(PmContext& context); + void Execute(PmContext& context) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/CursorCoordinate.h metview-5.19.2/metview/src/uPlot/CursorCoordinate.h --- metview-5.17.4/metview/src/uPlot/CursorCoordinate.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/CursorCoordinate.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,29 @@ +/***************************** LICENSE START *********************************** + + Copyright 2023 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + + +#pragma once + +class CursorCoordinate +{ +public: + enum Type {NoType, LonLatType, XyType}; + CursorCoordinate(double x, double y, Type type) : x_(x), y_(y), type_(type), valid_{true} {} + CursorCoordinate() = default; + double x() const {return x_;} + double y() const {return y_;} + double isValid() const {return valid_;} + Type type() const {return type_;} + +private: + double x_{0.}; + double y_{0.}; + Type type_{NoType}; + bool valid_{false}; +}; diff -Nru metview-5.17.4/metview/src/uPlot/DataBuilder.cc metview-5.19.2/metview/src/uPlot/DataBuilder.cc --- metview-5.17.4/metview/src/uPlot/DataBuilder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DataBuilder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,12 +28,12 @@ // Make sure the macro is generated in current dir, even when defaults are used. const char* fullName = (const char*)dataReq("_NAME"); - const char* path = nullptr; + const char* path = nullptr; if (fullName) path = mdirname(fullName); // Creation of a new PlotPage and associated pages - Presentable* superpage = nullptr; + Presentable* superpage = nullptr; MvRequest defaultSuperPage = ObjectList::CreateDefaultRequest("PLOT_SUPERPAGE", 0, path); // Create default page and add view to this request @@ -48,7 +48,7 @@ MvRequest viewRequest = dataReq("_VIEW_REQUEST"); if (!viewRequest) { // Build a default - viewRequest = ObjectList::UserDefaultRequest(viewName, true); + viewRequest = ObjectList::UserDefaultRequest(viewName, true); viewRequest("_ORIGIN") = "DataBuilder"; } pageRequest("VIEW") = viewRequest; diff -Nru metview-5.17.4/metview/src/uPlot/DataBuilder.h metview-5.19.2/metview/src/uPlot/DataBuilder.h --- metview-5.17.4/metview/src/uPlot/DataBuilder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DataBuilder.h 2023-07-15 08:28:47.000000000 +0000 @@ -44,11 +44,11 @@ PlotModBuilder(name) {} // Destructor - ~DataBuilder() {} + ~DataBuilder() override = default; // Methods // Overriden from PlotModBuilder class - virtual Presentable* Execute(PmContext&); + Presentable* Execute(PmContext&) override; private: // No copy allowed diff -Nru metview-5.17.4/metview/src/uPlot/DataObject.cc metview-5.19.2/metview/src/uPlot/DataObject.cc --- metview-5.17.4/metview/src/uPlot/DataObject.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DataObject.cc 2023-07-15 08:28:47.000000000 +0000 @@ -45,7 +45,7 @@ return; } else if (strcmp(dt, "GRIB") == 0) { - int ndim = 1; + int ndim = 1; myRequest_("GRIB_POSITION") = offset; if (offset != offset2) { ndim = 2; @@ -55,15 +55,14 @@ } myRequest_("GRIB_DIMENSION") = ndim; - dimFlag_ = dimFlag_ | ndim; + dimFlag_ = dimFlag_ | ndim; } } DataObject::DataObject(MvRequest& reqst) : - Presentable(reqst), - dimFlag_(0) + Presentable(reqst) { - //empty + // empty } DataObject::DataObject(const DataObject& old) : @@ -74,7 +73,7 @@ titleText_(old.titleText_), titleRequest_(old.titleRequest_) { - //segmentNameMap_ not copied. + // segmentNameMap_ not copied. } bool DataObject::AppendDataUnit(int dataunitId, long offset, long offset2, const MvRequest& req) @@ -86,7 +85,7 @@ // Update position and dimension parameters int ndim = 1; myRequest_("GRIB_POSITION") += offset; - if (offset != offset2) //two dimensional data + if (offset != offset2) // two dimensional data { ndim = 2; myRequest_("GRIB_POSITION") += offset2; @@ -107,7 +106,7 @@ return false; // The request verbs are not the same -> return false - if (strcmp(myRequest_.getVerb(), req("DATA_TYPE"))) + if (strcmp(myRequest_.getVerb(), req("DATA_TYPE")) != 0) return false; return true; @@ -128,11 +127,11 @@ // Create Priority string based on only the first visdef. // It assumes that all the other visdefs will have the same "priority" MvListCursor vdCursor; - vdCursor = visdefList.begin(); - MvIcon& visDef = *(vdCursor); + vdCursor = visdefList.begin(); + MvIcon& visDef = *(vdCursor); MvRequest visRequest = visDef.Request(); - int visDefId = visDef.Id(); + int visDefId = visDef.Id(); Cached drawPrior = tmpDrawingPriority.DrawSegmentName(myDataUnitId_, visRequest, visDefId); @@ -156,9 +155,9 @@ // Retrieve the DataUnit // (the object only stores its dataunit Id and index) MvIcon dataUnit; - //if ( dataBase.RetrieveDataUnit (myDataUnitId_, dataUnit) == false) + // if ( dataBase.RetrieveDataUnit (myDataUnitId_, dataUnit) == false) if (dataBase.RetrieveIconFromList(DB_DATAUNIT, myDataUnitId_, dataUnit) == false) - return DrawPriorMap(); + return {}; // Retrieve the VisDefs associated to the DataUnit MvIconList visdefList; @@ -193,7 +192,7 @@ void DataObject::DrawDataVisDef() { // Retrieve the Graphics Engine and the data base info - GraphicsEngine& ge = GetGraphicsEngine(); + GraphicsEngine& ge = GetGraphicsEngine(); MvIconDataBase& dataBase = IconDataBase(); // Retrieve the DataUnit @@ -233,7 +232,7 @@ // all valid visdefs. After calling ge.Draw, it contains only the visdefs // used in the plotting. If this is not the first plot, the Drop scheme (executed // earlier) should update (add/replace/delete) the list of visdefs accordingly. - //F if ( first && defaultVD ) + // F if ( first && defaultVD ) if (defaultVD) { // Insert new VD in the dataBase connect to the superpage int spId = this->FindSuperPage()->Id(); @@ -294,7 +293,7 @@ if (dataBase.RetrieveVisDefList(dataUnit, visdefList)) { // Check if there is any valid visdef if (ObjectList::CheckValidVisDefList(myRequest_.getVerb(), visdefList)) - return usingDefault; //found a valid visdef + return usingDefault; // found a valid visdef } // Check if there is a parent DataUnit @@ -307,7 +306,7 @@ // Check that the parent has a valid visdef for this dataunit if (ObjectList::CheckValidVisDefList(myRequest_.getVerb(), visdefList)) - return usingDefault; //found a valid visdef + return usingDefault; // found a valid visdef } // There is no visdef associated to the dataunit -> get another visdef @@ -372,7 +371,7 @@ void DataObject::GetTitle(MvRequest& rqst, int* order) { - int i; + int i = 0; // Set TEXT_ORIGIN, internal parameter between PlotMod and Magics this->SetTextOrigin(rqst); @@ -386,7 +385,7 @@ rqst("$METVIEW_TITLE_PACKAGE_COUNT") = *order; Cached titlePackageName = "$METVIEW_TITLE_PACKAGE_"; - titlePackageName = titlePackageName + *order; + titlePackageName = titlePackageName + *order; rqst(titlePackageName) = titleText_[0]; for (i = 1; i < nValues; i++) @@ -397,7 +396,7 @@ (*order)++; } - else //Title defined by the user + else // Title defined by the user { // Merge 2 TEXT requests const char* origin = rqst("TEXT_ORIGIN"); @@ -406,7 +405,7 @@ char saux[13]; strcpy(saux, "TEXT_LINE_"); int size = strlen(saux); - int j = myRequest_("TEXT_LINE_COUNT"); + int j = myRequest_("TEXT_LINE_COUNT"); rqst.unsetParam("TEXT_LINE_COUNT"); for (i = 1; i <= j; i++) { sprintf(saux + size, "%d", i); @@ -419,7 +418,7 @@ else if (origin == Cached("BOTH") || origin == Cached("MERGE")) metview::MergeTextParameters(myRequest_, rqst, false); - ///F ( *order ) = rqst("TEXT_LINE_COUNT"); + /// F ( *order ) = rqst("TEXT_LINE_COUNT"); // Now we have already set the Text request. // For the Magics point of view, if the title came from @@ -434,7 +433,7 @@ void DataObject::SetTextOrigin(MvRequest& request) { // If TEXT_ORIGIN has already been set, return. - if ( metview::IsParameterSet(request, "TEXT_ORIGIN")) { + if (metview::IsParameterSet(request, "TEXT_ORIGIN")) { std::string val = (const char*)request("TEXT_ORIGIN"); if (val != "NOTSET") return; @@ -444,18 +443,18 @@ // been set (these are PlotMod parameters and // must not be sent to Magics) MvRequest reqAux = request; - bool expand = false; - if ( metview::IsParameterSet(reqAux, "TEXT_AUTOMATIC")) + bool expand = false; + if (metview::IsParameterSet(reqAux, "TEXT_AUTOMATIC")) request.unsetParam("TEXT_AUTOMATIC"); else expand = true; - if ( metview::IsParameterSet(reqAux, "TEXT_USER")) + if (metview::IsParameterSet(reqAux, "TEXT_USER")) request.unsetParam("TEXT_USER"); else expand = true; - if ( metview::IsParameterSet(reqAux, "TEXT_MERGE")) + if (metview::IsParameterSet(reqAux, "TEXT_MERGE")) request.unsetParam("TEXT_MERGE"); else expand = true; @@ -466,8 +465,8 @@ // Set TEXT_ORIGIN Cached yes("YES"); - bool autoText = (reqAux("TEXT_AUTOMATIC") == yes) ? true : false; - bool userText = (reqAux("TEXT_USER") == yes) ? true : false; + bool autoText = (reqAux("TEXT_AUTOMATIC") == yes) ? true : false; + bool userText = (reqAux("TEXT_USER") == yes) ? true : false; bool mergeText = (reqAux("TEXT_MERGE") == yes) ? true : false; if (mergeText) @@ -532,7 +531,7 @@ rqst(titlePackageName) += (legendPackage.second)[i]; Cached fileName = Cached("METVIEW_LEGEND_STORE_FILE_") + *order; - rqst(fileName) = (legendPackage.first).c_str(); + rqst(fileName) = (legendPackage.first).c_str(); (*order)++; if (*order > MAX_LEGENDS_PACKAGE) @@ -641,7 +640,7 @@ MvIconDataBase& dataBase = IconDataBase(); // Retrieve the DataUnit - //if (dataBase.RetrieveDataUnit (myDataUnitId_, dataUnit) == false) + // if (dataBase.RetrieveDataUnit (myDataUnitId_, dataUnit) == false) if (dataBase.RetrieveIconFromList(DB_DATAUNIT, myDataUnitId_, dataUnit) == false) { MvLog().popup().err() << "uPlot DataObject::DataUnit-> No Data Unit"; return; @@ -656,9 +655,9 @@ void DataObject::UpdateVisDef(MvRequest dataUnit, MvIconList& iconList) { // Get application name without the prefix - std::string verb = dataUnit.getVerb(); - size_t ipos = verb.find("_"); - std::string sapp = verb.substr(ipos + 1); + std::string verb = dataUnit.getVerb(); + size_t ipos = verb.find("_"); + std::string sapp = verb.substr(ipos + 1); std::string prefix = verb.substr(0, ipos); // Update visdef parameters only for the following applications @@ -674,7 +673,7 @@ // Update only MSYMB visdefs MvListCursor vdc; for (vdc = iconList.begin(); vdc != iconList.end(); ++vdc) { - MvIcon& visDef = *(vdc); + MvIcon& visDef = *(vdc); MvRequest vdRequest = visDef.Request(); if (strcmp(vdRequest.getVerb(), "MSYMB") == 0) { vdRequest("SYMBOL_TABLE_MODE") = "ADVANCED"; @@ -695,7 +694,7 @@ // Update only MWIND visdefs MvListCursor vdc; for (vdc = iconList.begin(); vdc != iconList.end(); ++vdc) { - MvIcon& visDef = *(vdc); + MvIcon& visDef = *(vdc); MvRequest vdRequest = visDef.Request(); if (strcmp(vdRequest.getVerb(), "MWIND") == 0) { vdRequest("WIND_ADVANCED_METHOD") = "ON"; @@ -708,7 +707,7 @@ // Update MGRAPH visdefs MvListCursor vdc; for (vdc = iconList.begin(); vdc != iconList.end(); ++vdc) { - MvIcon& visDef = *(vdc); + MvIcon& visDef = *(vdc); MvRequest vdRequest = visDef.Request(); if (strcmp(vdRequest.getVerb(), "MGRAPH") == 0) { vdRequest("GRAPH_TYPE") = "BAR"; diff -Nru metview-5.17.4/metview/src/uPlot/DataObject.h metview-5.19.2/metview/src/uPlot/DataObject.h --- metview-5.17.4/metview/src/uPlot/DataObject.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DataObject.h 2023-07-15 08:28:47.000000000 +0000 @@ -59,7 +59,7 @@ Presentable* Clone() const override { return new DataObject(*this); } // Destructor - ~DataObject() {} // Change to virtual if base class + ~DataObject() override = default; // Change to virtual if base class // Overridden from Presentable // virtual void DuplicateChildren(const Presentable&); @@ -120,18 +120,18 @@ DataObject& operator=(const DataObject&); // Members - int myDataUnitId_; - int dimFlag_; // 0 - no information - // 1 = one dimensional fields - // 2 = two dimensional fields - // 3 = one and two dimensional fields - // vector myDataIndex_; - // vector myDataIndex2_; + int myDataUnitId_{0}; + int dimFlag_{0}; // 0 - no information + // 1 = one dimensional fields + // 2 = two dimensional fields + // 3 = one and two dimensional fields + // vector myDataIndex_; + // vector myDataIndex2_; // this second index holds the index of a possible second component // in case of vector data - typedef std::pair > LegendPackage; - typedef std::map LegendsMap; + using LegendPackage = std::pair>; + using LegendsMap = std::map; LegendsMap legends_; // typedef std::map SegmentNameMap; diff -Nru metview-5.17.4/metview/src/uPlot/DataToolManager.cc metview-5.19.2/metview/src/uPlot/DataToolManager.cc --- metview-5.17.4/metview/src/uPlot/DataToolManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DataToolManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -37,7 +37,7 @@ DataToolManager::DataToolManager(const char* kw) : MvService(kw) { - //empty + // empty } void DataToolManager::serve(MvRequest& in, MvRequest& out) @@ -106,9 +106,9 @@ // Start the approriate service char cmd[1024]; /*if ( strcmp(in.getVerb(),"GRIB") == 0 ) - { - sprintf(cmd,"$metview_command $METVIEW_BIN/GribTool %s -stylesheet $METVIEW_DIR_SHARE/app-defaults/metview.qss&",ftemp); - }*/ + { + sprintf(cmd,"$metview_command $METVIEW_BIN/GribTool %s -stylesheet $METVIEW_DIR_SHARE/app-defaults/metview.qss&",ftemp); + }*/ #ifdef METVIEW_EXPERIMENTAL @@ -124,9 +124,9 @@ { // If error, send a message and return if (task->getError() != 0) { - //int i = 0; - //const char* msg = 0; - //while ( msg = task->getMessage (i++ ) ) + // int i = 0; + // const char* msg = 0; + // while ( msg = task->getMessage (i++ ) ) // PlotMod::MetviewError ( "uPlot crashed" ); // COUT << "DataTool crashed" << std::endl; diff -Nru metview-5.17.4/metview/src/uPlot/DataToolManager.h metview-5.19.2/metview/src/uPlot/DataToolManager.h --- metview-5.17.4/metview/src/uPlot/DataToolManager.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DataToolManager.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,9 @@ DataToolManager(const char* kw); // Destructor - ~DataToolManager() {} + ~DataToolManager() override = default; - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; protected: }; @@ -45,7 +45,7 @@ // Methods // Perform actions after receiving response from the data tools - virtual void endOfTask(MvTask*); + void endOfTask(MvTask*) override; // Call data tiik void CallDataTool(MvRequest& in, MvRequest& out); diff -Nru metview-5.17.4/metview/src/uPlot/Device.cc metview-5.19.2/metview/src/uPlot/Device.cc --- metview-5.17.4/metview/src/uPlot/Device.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Device.cc 2023-07-15 08:28:47.000000000 +0000 @@ -57,7 +57,7 @@ Device::CreateRequest(const MvRequest&) { return PlotMod::Instance().OutputFormat(); -#if 0 //U032010 +#if 0 // U032010 // If the device driver request is missing, plot on the screen if ( !IsParameterSet ( (MvRequest&)inRequest, "_DRIVER" ) ) return PlotMod::Instance().MakeDefaultOutputFormat(); diff -Nru metview-5.17.4/metview/src/uPlot/DeviceData.h metview-5.19.2/metview/src/uPlot/DeviceData.h --- metview-5.17.4/metview/src/uPlot/DeviceData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DeviceData.h 2023-07-15 08:28:47.000000000 +0000 @@ -59,14 +59,8 @@ class DeviceData { public: - // Contructors - DeviceData() {} - - // Destructor - virtual ~DeviceData() {} - -private: - // No copy allowed - DeviceData(const DeviceData&); - DeviceData& operator=(const DeviceData&) { return *this; } + DeviceData() = default; + virtual ~DeviceData() = default; + DeviceData(const DeviceData&) = delete; + DeviceData& operator=(const DeviceData&) = default; }; diff -Nru metview-5.17.4/metview/src/uPlot/Device.h metview-5.19.2/metview/src/uPlot/Device.h --- metview-5.17.4/metview/src/uPlot/Device.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Device.h 2023-07-15 08:28:47.000000000 +0000 @@ -72,8 +72,8 @@ // Class Device Factory - clones a new Device on Request struct DeviceFactoryTraits { - typedef Device Type; - typedef const MvRequest& Parameter; + using Type = Device; + using Parameter = const MvRequest&; static Cached FactoryName(Parameter); static Type* DefaultObject(Parameter); }; @@ -93,7 +93,7 @@ Device(const MvRequest& deviceRequest); // Destructor - virtual ~Device(); + ~Device() override; // Visitor methods virtual void Initialise(Presentable& p); @@ -135,5 +135,8 @@ private: // No copy allowed Device(const Device&); - Device& operator=(const Device&) { return *this; } + Device& operator=(const Device&) + { + return *this; + } }; diff -Nru metview-5.17.4/metview/src/uPlot/DrawingPriority.cc metview-5.19.2/metview/src/uPlot/DrawingPriority.cc --- metview-5.17.4/metview/src/uPlot/DrawingPriority.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DrawingPriority.cc 2023-07-15 08:28:47.000000000 +0000 @@ -161,11 +161,11 @@ MvRequest expRequest = ObjectList::ExpandRequest(drawPriorRequest, EXPAND_DEFAULTS); int count = expRequest.countParameters(); - int i; - int priorValue; + int i = 0; + int priorValue = 0; std::string keyString; for (i = 0; i < count; i++) { - keyString = expRequest.getParameter(i); + keyString = expRequest.getParameter(i); Cached tmpcached = expRequest(keyString.c_str()); if (isalpha(tmpcached[0])) { if (tmpcached == Cached("FIRST")) @@ -188,10 +188,10 @@ MvRequest expRequest = ObjectList::ExpandRequest(request, EXPAND_DEFAULTS); int count = expRequest.countParameters(); - int i, priorValue; + int i = 0, priorValue = 0; std::string keyString; for (i = 0; i < count; i++) { - keyString = expRequest.getParameter(i); + keyString = expRequest.getParameter(i); Cached tmpcached = expRequest(keyString.c_str()); if (isalpha(tmpcached[0])) { if (tmpcached == Cached("FIRST")) @@ -217,7 +217,7 @@ std::string keyString(expRequest.getVerb() ? expRequest.getVerb() : ""); if (!IsValidKey(keyString)) { int count = expRequest.countParameters(); - int i; + int i = 0; for (i = 0; i < count; i++) { std::string param = expRequest.getParameter(i); if (param.size() != 0) { @@ -228,7 +228,7 @@ if (expRequest.countValues(param.c_str())) { // Use only the first value - const char* value = 0; + const char* value = nullptr; expRequest.getValue(value, param.c_str(), 0); pairString += std::string("_") + std::string(value); } @@ -278,11 +278,11 @@ int count = defRequest.countParameters(); - int i; - int defPriorValue; + int i = 0; + int defPriorValue = 0; std::string keyString; for (i = 0; i < count; i++) { - keyString = defRequest.getParameter(i); + keyString = defRequest.getParameter(i); Cached tmpcached = defRequest(keyString.c_str()); if (isalpha(tmpcached[0])) { if ((tmpcached == Cached("FIRST")) && @@ -325,5 +325,5 @@ ss << ends; - return Cached(ss.str().c_str()); + return {ss.str().c_str()}; } diff -Nru metview-5.17.4/metview/src/uPlot/DrawingPriority.h metview-5.19.2/metview/src/uPlot/DrawingPriority.h --- metview-5.17.4/metview/src/uPlot/DrawingPriority.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DrawingPriority.h 2023-07-15 08:28:47.000000000 +0000 @@ -47,7 +47,7 @@ private: // No copy allowed - //DrawingPriority ( const DrawingPriority& ); + // DrawingPriority ( const DrawingPriority& ); DrawingPriority& operator=(const DrawingPriority&) { return *this; diff -Nru metview-5.17.4/metview/src/uPlot/DropAction.cc metview-5.19.2/metview/src/uPlot/DropAction.cc --- metview-5.17.4/metview/src/uPlot/DropAction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DropAction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ // Find the location on the Tree // Find the DROP_ID associated to the DROP request MvRequest dropRequest = context.InRequest(); - int treeNodeId = dropRequest("DROP_ID"); + int treeNodeId = dropRequest("DROP_ID"); if (treeNodeId == 0) { context.Advance(); // Skip DROP request return; @@ -39,11 +39,11 @@ // Special case when an object was dropped in a // DataUnit at Contents window - ///F int presentableId = dropRequest("PRESENTABLE_ID"); - ///F if ( presentableId == 0 ) - ///F presentableId = treeNodeId; - int contentsWindow = dropRequest("_CONTENTS"); - int dataUnitId = dropRequest("_CONTENTS_DATAUNIT_ID"); + /// F int presentableId = dropRequest("PRESENTABLE_ID"); + /// F if ( presentableId == 0 ) + /// F presentableId = treeNodeId; + int contentsWindow = dropRequest("_CONTENTS"); + int dataUnitId = dropRequest("_CONTENTS_DATAUNIT_ID"); int calledFromMacro = dropRequest("_CALLED_FROM_MACRO"); context.Advance(); // Skip DROP request @@ -55,7 +55,7 @@ } treeNode->SetContentsDataUnit(dataUnitId); // set Contents flag - ///F treeNode->DroppedHere ( presentableId ); + /// F treeNode->DroppedHere ( presentableId ); // Needs redrawing by default. This may be overrulled by the Drop function treeNode->NeedsRedrawing(true); treeNode->DroppedHere(treeNodeId); @@ -75,10 +75,10 @@ void DropAction::PrepareForMacro(PmContext& context) { MvRequest newRequest = context.InRequest(); - MvRequest inMode = newRequest.getSubrequest("_MODE"); - const char* inClass = (const char*)inMode("_CLASS"); - const char* inVerb = (const char*)inMode("_VERB"); - const char* inName = (const char*)inMode("_NAME"); + MvRequest inMode = newRequest.getSubrequest("_MODE"); + const char* inClass = (const char*)inMode("_CLASS"); + const char* inVerb = (const char*)inMode("_VERB"); + const char* inName = (const char*)inMode("_NAME"); const char* firstDataUnit = ""; while (newRequest) { @@ -108,9 +108,9 @@ if (!((const char*)newRequest("_NAME"))) newRequest("_NAME") = inName; - newRequest("_MODE") = inMode; + newRequest("_MODE") = inMode; newRequest("_USE_MODE") = 1; - firstDataUnit = newRequest.getVerb(); + firstDataUnit = newRequest.getVerb(); } else newRequest("_SKIP_MACRO") = 1; diff -Nru metview-5.17.4/metview/src/uPlot/DropAction.h metview-5.19.2/metview/src/uPlot/DropAction.h --- metview-5.17.4/metview/src/uPlot/DropAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/DropAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -54,11 +54,11 @@ PlotModAction(name) {} // Destructor - ~DropAction() {} + ~DropAction() override = default; // Methods // Overriden from PlotModActio - virtual void Execute(PmContext& context); + void Execute(PmContext& context) override; private: // Local to class diff -Nru metview-5.17.4/metview/src/uPlot/ErrorAction.cc metview-5.19.2/metview/src/uPlot/ErrorAction.cc --- metview-5.17.4/metview/src/uPlot/ErrorAction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ErrorAction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,7 +26,7 @@ void ErrorAction::Execute(PmContext& context) { // Get error request and message - MvRequest req = context.InRequest().justOneRequest(); + MvRequest req = context.InRequest().justOneRequest(); std::string error_message = (const char*)req("MESSAGE"); // Send the error message diff -Nru metview-5.17.4/metview/src/uPlot/ErrorAction.h metview-5.19.2/metview/src/uPlot/ErrorAction.h --- metview-5.17.4/metview/src/uPlot/ErrorAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ErrorAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -46,11 +46,11 @@ PlotModAction(name.c_str()) {} // Destructor - ~ErrorAction() {} + ~ErrorAction() override = default; // Methods static PlotModAction& Instance(); // Overriden from Base Class (PlotModAction) - virtual void Execute(PmContext& context); + void Execute(PmContext& context) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/ExportDialog.cc metview-5.19.2/metview/src/uPlot/ExportDialog.cc --- metview-5.17.4/metview/src/uPlot/ExportDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ExportDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -85,9 +85,9 @@ #endif // Get the main layout - auto* mainLayout = static_cast(layout()); - int row = mainLayout->rowCount(); - int col = mainLayout->columnCount(); + auto* mainLayout = dynamic_cast(layout()); + int row = mainLayout->rowCount(); + int col = mainLayout->columnCount(); // Build label for the Output format auto* label = new QLabel(this); @@ -139,7 +139,7 @@ row++; QLayoutItem* liCancel = mainLayout->itemAtPosition(row - 3, col - 1); mainLayout->removeItem(liCancel); - auto* bb = static_cast(liCancel->widget()); + auto* bb = dynamic_cast(liCancel->widget()); bb->setOrientation(Qt::Horizontal); mainLayout->addItem(liCancel, row, col - 1); } @@ -157,7 +157,7 @@ // Save current gui settings QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS, "uPlotExportDialog"); settings.beginGroup("main"); -// settings.setValue("fileName", selectedFiles()); + // settings.setValue("fileName", selectedFiles()); int fIndex = comboBox_->currentIndex(); settings.setValue("formatIndex", fIndex); @@ -179,7 +179,7 @@ return; // Get filename from the user interface - QStringList s = selectedFiles(); + QStringList s = selectedFiles(); std::string filename = s.at(0).toStdString(); // Get output format name from the user interface @@ -239,7 +239,7 @@ // If a relative path is not given, the Editor creates a temporary file, which // is not appropriate here. if (!(const char*)reqOut("_NAME")) { - errorMessage("Parameter _NAME not found!", 0); + errorMessage("Parameter _NAME not found!", nullptr); return; } @@ -250,14 +250,14 @@ // Get the prefix path (METVIEW_USER_DIRECTORY) and check it againt the filename std::string userDir = GetUserDirectory(); - std::string path = mdirname((const char*)reqOut("_NAME")); - std::size_t found = path.find(userDir); + std::string path = mdirname((const char*)reqOut("_NAME")); + std::size_t found = path.find(userDir); if (found != std::string::npos) path = path.substr(userDir.size()); // remove the prefix path // Compose the filename std::string filename = path + '/' + name; - reqOut("_NAME") = filename.c_str(); + reqOut("_NAME") = filename.c_str(); // Call Metview user interface's editor CallGenAppService(*this, &ExportDialog::edited, reqOut); @@ -286,9 +286,9 @@ { // Group Box with radio buttons and one line edit auto* gbFs = new QGroupBox(tr("Frame Selection"), this); - cbFs1_ = new QRadioButton(tr("&Current"), this); - cbFs2_ = new QRadioButton(tr("&All"), this); - cbFs3_ = new QRadioButton(tr("&Range"), this); + cbFs1_ = new QRadioButton(tr("&Current"), this); + cbFs2_ = new QRadioButton(tr("&All"), this); + cbFs3_ = new QRadioButton(tr("&Range"), this); cbFs1_->setChecked(frameSelRB[0]); cbFs2_->setChecked(frameSelRB[1]); cbFs3_->setChecked(frameSelRB[2]); @@ -296,7 +296,7 @@ // Line edit with a validator leFs3_ = new QLineEdit(this); leFs3_->setToolTip(tr("Specify one or more frame ranges, e.g. 1-3,6,7")); - QString pattern = "^\\d{1,}(-\\d{1,})?(,\\d{1,}|,\\d{1,}-\\d{1,})*"; + QString pattern = R"(^\d{1,}(-\d{1,})?(,\d{1,}|,\d{1,}-\d{1,})*)"; #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) QRegularExpression rx(pattern); @@ -334,7 +334,7 @@ return true; // CURRENT: get the current frame numbeer - int i; + int i = 0; QList list; if (cbFs1_->isChecked()) { list.append(current_ + 1); // start from 1, not from 0 @@ -367,8 +367,8 @@ if (i1 > i2) // invert sequence { int iaux = i1; - i1 = i2; - i2 = iaux; + i1 = i2; + i2 = iaux; } for (int j = i1; j <= i2; j++) list.append(j); @@ -420,5 +420,5 @@ reqFormats_.advance(); } - return 0; // not found + return nullptr; // not found } diff -Nru metview-5.17.4/metview/src/uPlot/ExportDialog.h metview-5.19.2/metview/src/uPlot/ExportDialog.h --- metview-5.17.4/metview/src/uPlot/ExportDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ExportDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,14 +26,14 @@ Q_OBJECT public: - ExportDialog(int, int, const std::string&, bool, QWidget* parent = 0); - ~ExportDialog(); + ExportDialog(int, int, const std::string&, bool, QWidget* parent = nullptr); + ~ExportDialog() override; void edited(MvRequest&); const MvRequest& reqOut() const { return reqOut_; } public slots: - void accept(); + void accept() override; void slotEditFormat(); void slotRangeFrameSelection(bool); @@ -43,17 +43,17 @@ bool getFrameSelection(MvRequest&); void buildFrameSelection(int, int, QGridLayout*, const std::vector&, const QString&, bool); - void errorMessage(const char*, const char* = 0); + void errorMessage(const char*, const char* = nullptr); - int current_{0}; // Current frame - int total_{0}; // Total number of frames - bool export_qt_{false}; // qt driver - MvRequest reqFormats_; // list of output formats requests - QComboBox* comboBox_{nullptr}; // List of output formats - QToolButton* bEdit_{nullptr}; // Edit button - QLineEdit* leFs3_{nullptr}; // Frame selection: line edit - QRadioButton* cbFs1_{nullptr}; // Frame selection: Current radio button - QRadioButton* cbFs2_{nullptr}; // Frame selection: All radio button - QRadioButton* cbFs3_{nullptr}; // Frame selection: Range radio button + int current_{0}; // Current frame + int total_{0}; // Total number of frames + bool export_qt_{false}; // qt driver + MvRequest reqFormats_; // list of output formats requests + QComboBox* comboBox_{nullptr}; // List of output formats + QToolButton* bEdit_{nullptr}; // Edit button + QLineEdit* leFs3_{nullptr}; // Frame selection: line edit + QRadioButton* cbFs1_{nullptr}; // Frame selection: Current radio button + QRadioButton* cbFs2_{nullptr}; // Frame selection: All radio button + QRadioButton* cbFs3_{nullptr}; // Frame selection: Range radio button MvRequest reqOut_; }; diff -Nru metview-5.17.4/metview/src/uPlot/FeatureStore.cc metview-5.19.2/metview/src/uPlot/FeatureStore.cc --- metview-5.17.4/metview/src/uPlot/FeatureStore.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/FeatureStore.cc 2023-07-15 08:28:47.000000000 +0000 @@ -53,13 +53,12 @@ FeatureStoreItem::FeatureStoreItem(QString fileName, QString dirPath, bool local) : fileName_(fileName), dirPath_(dirPath), + saved_(true), local_(local) { - saved_ = true; - loadJson(); type_ = WsDecoder::getWsType(doc_); - toolTip_ = WsDecoder::toolTip(doc_); + toolTip_ = WsDecoder::toolTip(doc_); geoLocked_ = WsDecoder::geoLocked(doc_); clearJson(); @@ -67,7 +66,7 @@ setPixmap(pix); } -FeatureStoreItem::FeatureStoreItem(QString fileName, MvQFeatureItemPtr fItem, QString dirPath, bool local) : +FeatureStoreItem::FeatureStoreItem(QString fileName, MvQFeatureItemPtr fItem, QString dirPath, bool local) : type_(fItem->feature()), fileName_(fileName), toolTip_(fItem->toolTip()), @@ -147,7 +146,7 @@ void FeatureStoreItem::saveToDisk() { - //loadJson(); + // loadJson(); if (!doc_.isEmpty()) { saved_ = false; QFile f(jsonFilePath()); @@ -188,10 +187,10 @@ QString err; if (FeatureStore::Instance()->checkName(fileName, err, local_) == FeatureStore::NameNoError) { auto oldJson = jsonFilePath(); - auto oldPix = pixFilePath(); - fileName_ = fileName; + auto oldPix = pixFilePath(); + fileName_ = fileName; auto newJson = jsonFilePath(); - auto newPix = pixFilePath(); + auto newPix = pixFilePath(); QFile::rename(oldJson, newJson); QFile::rename(oldPix, newPix); } @@ -205,7 +204,7 @@ if (contentChanged) { if (toolTip_ != toolTip) { - toolTip_ = toolTip; + toolTip_ = toolTip; WsDecoder::setToolTip(doc_, toolTip_); } if (geoLocked != geoLocked_) { @@ -238,10 +237,10 @@ return dir.absoluteFilePath(fileName_ + pixSuffix_); } -//void FeatureStoreItem::makeLabel() +// void FeatureStoreItem::makeLabel() //{ -// return fileName_.left(fileName_.lastIndexOf(".")); -//} +// return fileName_.left(fileName_.lastIndexOf(".")); +// } //================================================================= // @@ -290,7 +289,7 @@ for (const auto& fileName : fileList) { if (!fileName.endsWith(".png")) { QString cls = QString::fromStdString(ScanFileType(dir.absoluteFilePath(fileName).toStdString().c_str())); -// MvLog().dbg() << "fileName=" << fileName << " cls=" << cls; + // MvLog().dbg() << "fileName=" << fileName << " cls=" << cls; if (cls.startsWith("WS_")) { QString err; if (FeatureStore::Instance()->checkName(fileName, err, local) == FeatureStore::NameNoError) { @@ -299,7 +298,8 @@ } else { MvLog().warn() << "Cannot load weather symbol=" << fileName << " from user library = " - << dir.absolutePath() << ".\n\n" << err; + << dir.absolutePath() << ".\n\n" + << err; } } } @@ -371,7 +371,7 @@ } else if (invalidStartCharacters.contains(name[0]) || invalidCharacters.contains(name[0])) { err = QString("Name=\'" + name + - "\' starts with invalid character=\'%1\'. The following characters are not allowed to use: %2") + R"(' starts with invalid character='%1'. The following characters are not allowed to use: %2)") .arg(name[0]) .arg(invalidStartCharacters + invalidCharacters); return NameStartError; @@ -440,11 +440,11 @@ QAbstractItemModel(parent) { FeatureStore::Instance()->addObserver(this); - auto id = IconProvider::add(":/uPlot/geolock.svg", "geolock"); - lockPix_ = IconProvider::pixmap(id, 12); - id = IconProvider::add(":/uPlot/geolock_empty.svg", "geolock_empty"); + auto id = IconProvider::add(":/uPlot/geolock.svg", "geolock"); + lockPix_ = IconProvider::pixmap(id, 12); + id = IconProvider::add(":/uPlot/geolock_empty.svg", "geolock_empty"); emptyLockPix_ = IconProvider::pixmap(id, 12); - typeColour_ = MvQTheme::colour("uplot", "ws_store_type_fg"); + typeColour_ = MvQTheme::colour("uplot", "ws_store_type_fg"); } void FeatureStoreModel::notifyStoreChangeBegin() @@ -487,21 +487,21 @@ if (role == Qt::DecorationRole) { return item->isGeoLocked() ? lockPix_ : emptyLockPix_; } - } else if (index.column() == 1) { + } + else if (index.column() == 1) { switch (role) { case Qt::DisplayRole: return item->fileName() + " "; case Qt::DecorationRole: return item->pixmap(); - case Qt::ToolTipRole: - { + case Qt::ToolTipRole: { QString txt = MvQ::formatBoldText("Name: ") + item->fileName(); if (item->type()) { - txt += "
" + MvQ::formatBoldText("Class: ") + item->type()->reqVerb() + - "
" + MvQ::formatBoldText("Type: ") + item->type()->name(); + txt += "
" + MvQ::formatBoldText("Class: ") + item->type()->reqVerb() + + "
" + MvQ::formatBoldText("Type: ") + item->type()->name(); } txt += "
" + MvQ::formatBoldText("Storage: ") + - (item->isLocal()?"local":"extra"); + (item->isLocal() ? "local" : "extra"); if (!item->toolTip().isEmpty()) { txt += "
" + MvQ::formatBoldText("Desc: ") + item->toolTip(); } @@ -592,7 +592,7 @@ // //================================================================= -void FeatureStoreView::contextMenuEvent(QContextMenuEvent *e) +void FeatureStoreView::contextMenuEvent(QContextMenuEvent* e) { auto idx = indexAt(viewport()->mapFromGlobal(e->globalPos())); emit contextMenuRequested(idx); @@ -614,7 +614,7 @@ ui_->setupUi(this); filterModel_ = new FeatureStoreFilterModel(this); - model_ = new FeatureStoreModel(this); + model_ = new FeatureStoreModel(this); filterModel_->setSourceModel(model_); filterModel_->setDynamicSortFilter(true); @@ -672,11 +672,11 @@ void FeatureStoreWidget::slotClicked(const QModelIndex& idx) { - if (auto item = model_->indexToItem(filterModel_->mapToSource(idx))) { + if (auto item = model_->indexToItem(filterModel_->mapToSource(idx))) { MvLog().dbg() << "idx=" << idx << " name" << item->fileName(); if (idx.column() == 0) { item->setGeoLocked(!item->isGeoLocked()); - ui_->view->update(idx); + ui_->view->update(idx); } checkActionState(item); } @@ -684,7 +684,7 @@ void FeatureStoreWidget::slotDoubleClicked(const QModelIndex& idx) { - if (auto item = model_->indexToItem(filterModel_->mapToSource(idx))) { + if (auto item = model_->indexToItem(filterModel_->mapToSource(idx))) { FeatureStore::Instance()->edit(item); } } @@ -761,8 +761,8 @@ settings.beginGroup("FeatureStoreWidget"); if (settings.contains("treeColumnWidth")) { - MvQ::initTreeColumnWidth(settings, "treeColumnWidth", ui_->view); - columnWidthInitialised_ = true; + MvQ::initTreeColumnWidth(settings, "treeColumnWidth", ui_->view); + columnWidthInitialised_ = true; } settings.endGroup(); @@ -780,14 +780,14 @@ item_(item) { ui_->setupUi(this); - //setAttribute(Qt::WA_DeleteOnClose); + // setAttribute(Qt::WA_DeleteOnClose); } void FeatureStoreAddDialog::accept() { Q_ASSERT(item_); auto name = ui_->nameLe_->text(); -// auto desc = ui_->descLe_->text(); + // auto desc = ui_->descLe_->text(); QString err; auto errSt = FeatureStore::Instance()->checkName(name, err, true); @@ -827,7 +827,7 @@ QString t; if (auto ws = item->type()) { auto subCol = MvQTheme::subText(); - auto bold = MvQTheme::boldFileInfoTitle(); + auto bold = MvQTheme::boldFileInfoTitle(); t = MvQ::formatText("Class: ", subCol, bold) + ws->reqVerb() + MvQ::formatText(" Type: ", subCol, bold) + ws->name(); } @@ -841,8 +841,8 @@ { Q_ASSERT(item_); - auto name = ui_->nameLe->text(); - auto tt = ui_->tooltipTe->toPlainText(); + auto name = ui_->nameLe->text(); + auto tt = ui_->tooltipTe->toPlainText(); auto glock = ui_->geoLockCb->isChecked(); try { diff -Nru metview-5.17.4/metview/src/uPlot/FeatureStore.h metview-5.19.2/metview/src/uPlot/FeatureStore.h --- metview-5.17.4/metview/src/uPlot/FeatureStore.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/FeatureStore.h 2023-07-15 08:28:47.000000000 +0000 @@ -40,6 +40,7 @@ class FeatureStoreItem { friend class FeatureStore; + public: static FeatureStoreItemPtr make(QString fileName, QString dirPath, bool local); static FeatureStoreItemPtr make(QString fileName, MvQFeatureItemPtr fItem, QString dirPath, bool local); @@ -52,14 +53,14 @@ void setPixmap(QPixmap p); bool isGeoLocked() const { return geoLocked_; } void setGeoLocked(bool); - bool isLocal() const {return local_;} + bool isLocal() const { return local_; } void addToSceneAtGeoCoord(); void addToSceneAtClick(); void saveToDisk(); void removeFromDisk(); void update(QString fileName, QString toolTip, bool geoLocked); -protected: +private: FeatureStoreItem(QString fileName, QString dirPath, bool local); FeatureStoreItem(QString fileName, MvQFeatureItemPtr fItem, QString dirPath, bool local); QString jsonFilePath() const; @@ -87,8 +88,8 @@ { public: virtual void notifyStoreChangeBegin() = 0; - virtual void notifyStoreChangeEnd() = 0; - virtual void notifyStoreInitEnd() = 0; + virtual void notifyStoreChangeEnd() = 0; + virtual void notifyStoreInitEnd() = 0; }; class FeatureStore @@ -192,7 +193,7 @@ void contextMenuRequested(const QModelIndex&); protected: - void contextMenuEvent(QContextMenuEvent *event) override; + void contextMenuEvent(QContextMenuEvent* event) override; }; class FeatureStoreWidget : public QWidget diff -Nru metview-5.17.4/metview/src/uPlot/GenAppService.cc metview-5.19.2/metview/src/uPlot/GenAppService.cc --- metview-5.17.4/metview/src/uPlot/GenAppService.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/GenAppService.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,7 +40,7 @@ bool GenAppService::CallGenApp(MvCallbackBase* callback, MvRequest& defRequest) { - //require ( callback != 0); + // require ( callback != 0); if (!callback) return false; @@ -59,7 +59,7 @@ // Create a new task char* desktop = getenv("MV_DESKTOP_NAME"); - if (desktop == 0) { + if (desktop == nullptr) { MvLog().popup().warn() << "uPlot GenAppService::CallGenApp-> environmental variable MV_DESKTOP_NAME not defined"; return false; } diff -Nru metview-5.17.4/metview/src/uPlot/GeopointsDecoder.cc metview-5.19.2/metview/src/uPlot/GeopointsDecoder.cc --- metview-5.17.4/metview/src/uPlot/GeopointsDecoder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/GeopointsDecoder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ class GeopointsDecoderFactory : public DecoderFactory { // Virtual Constructor - Builds a new GeopointsDecoder - virtual Decoder* Build(const MvRequest& inRequest) + Decoder* Build(const MvRequest& inRequest) override { return new GeopointsDecoder(inRequest); } @@ -44,7 +44,7 @@ GeopointsDecoder::GeopointsDecoder(const MvRequest& dataUnitRequest) : Decoder(dataUnitRequest) { - nextData_ = true; + nextData_ = true; metadataRequest_ = dataUnitRequest; } @@ -104,7 +104,7 @@ // Save format info if (!(const char*)metadataRequest_("FORMAT")) { - metadataRequest_("FORMAT") = (const char*)gpts.sFormat().c_str(); + metadataRequest_("FORMAT") = (const char*)gpts.sFormat().c_str(); metadataRequest_("VECTOR_FORMAT") = gpts.hasVectors(); if (gpts.hasVectors()) metadataRequest_("_VISDEF") = "MWIND"; @@ -113,7 +113,7 @@ // Save data dimension info matchingRequest("_NDIM_FLAG") = gpts.hasVectors() ? 2 : 1; - return MatchingInfo(matchingRequest); + return {matchingRequest}; } // Add a proper datarequest with a geopoints record diff -Nru metview-5.17.4/metview/src/uPlot/GeopointsDecoder.h metview-5.19.2/metview/src/uPlot/GeopointsDecoder.h --- metview-5.17.4/metview/src/uPlot/GeopointsDecoder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/GeopointsDecoder.h 2023-07-15 08:28:47.000000000 +0000 @@ -51,15 +51,15 @@ GeopointsDecoder(const MvRequest& inRequest); // Destructor - virtual ~GeopointsDecoder(); + ~GeopointsDecoder() override; // Overridden methods from Decoder class // Returns true first time it's called - virtual bool ReadNextData(); + bool ReadNextData() override; - virtual MatchingInfo CreateMatchingInfo(); + MatchingInfo CreateMatchingInfo() override; - virtual bool UpdateDataRequest(MvRequest&); + bool UpdateDataRequest(MvRequest&) override; private: // No copy allowed diff -Nru metview-5.17.4/metview/src/uPlot/GeoTool.cc metview-5.19.2/metview/src/uPlot/GeoTool.cc --- metview-5.17.4/metview/src/uPlot/GeoTool.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/GeoTool.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,20 +41,20 @@ setAttribute(Qt::WA_DeleteOnClose); setWindowTitle("Metview - Geography Tool"); - //Initial size + // Initial size setInitialSize(600, 400); - //uPlot area. Define the whole lot as central widget + // uPlot area. Define the whole lot as central widget auto* w = new QWidget; setCentralWidget(w); auto* vlay = new QVBoxLayout(w); vlay->addWidget(plotView_); - //Setup the bottom layout (coordinates + buttons) + // Setup the bottom layout (coordinates + buttons) auto* hlay = new QHBoxLayout(); vlay->addLayout(hlay); auto* coordLabel = new QLabel(tr("S/W/N/E:")); - coordEdit_ = new QLineEdit(); + coordEdit_ = new QLineEdit(); coordEdit_->setMinimumSize(170, 0); coordEdit_->setText(tr(coord.toStdString().c_str())); auto* okPb = new QPushButton(tr("&OK")); @@ -67,12 +67,12 @@ hlay->addWidget(okPb); hlay->addWidget(cancelPb); - //Setup the actions + // Setup the actions setupZoomActions(); setupViewActions(); setupInputSelectionActions(); - //Setup menus and toolbars + // Setup menus and toolbars setupMenus(menuItems_, MvQMainWindow::ToolBarOnlyOption); isFirstMap_ = true; @@ -94,18 +94,18 @@ connect(this, SIGNAL(pointChanged(double, double)), plotView_, SLOT(slotChangePoint(double, double))); - //Read qt geometry settings + // Read qt geometry settings readSettings(); - //Enable antialias + // Enable antialias slotEnableAntialias(true); - //Hide view toolbar + // Hide view toolbar QToolBar* tb = findToolBar(MvQMainWindow::ViewMenu); if (tb) tb->hide(); - //Size is set to Fit to window + // Size is set to Fit to window int sizeIndex = predefSizeValues_.indexOf(uPlotBase::FitToWindow); if (sizeIndex != -1) sizeCombo_->setCurrentIndex(sizeIndex); @@ -120,7 +120,7 @@ void GeoTool::setupInputSelectionActions() { - //Selection action + // Selection action auto* actionSelection = new QAction(this); actionSelection->setObjectName(QString::fromUtf8("actionSelection")); actionSelection->setCheckable(true); @@ -149,8 +149,8 @@ } actionSelection->setText(selectionName); - //Clear selection action - QAction *actionClear, *actionAll, *actionChDir; + // Clear selection action + QAction *actionClear = nullptr, *actionAll = nullptr, *actionChDir = nullptr; if (inputType_ == "AREA") { actionClear = new QAction(this); actionClear->setObjectName(QString::fromUtf8("actionClear")); @@ -297,7 +297,7 @@ QString GeoTool::InitializeParams(MvRequest& req) { // Create a default superpage request - spRequest_ = ObjectList::CreateDefaultRequest("PLOT_SUPERPAGE"); + spRequest_ = ObjectList::CreateDefaultRequest("PLOT_SUPERPAGE"); spRequest_("_NAME") = "Geographical Tool Window"; // Get input type @@ -306,19 +306,19 @@ if (const char* cv = req("INPUT_TYPE")) inputType_ = std::string(cv); else - return QString("ERROR"); + return {"ERROR"}; if (inputType_ == "MAP") inputType_ = "AREA"; - //Get the paramater name + // Get the paramater name if (const char* cv = req("INPUT_PARAM")) inputPar_ = std::string(cv); // Update size - spRequest_("CUSTOM_WIDTH") = req("CUSTOM_WIDTH"); + spRequest_("CUSTOM_WIDTH") = req("CUSTOM_WIDTH"); spRequest_("CUSTOM_HEIGHT") = req("CUSTOM_HEIGHT"); - spRequest_("LAYOUT_SIZE") = "CUSTOM"; + spRequest_("LAYOUT_SIZE") = "CUSTOM"; req.advance(); // skip EDIT_MAP request // Create a coastline request from user's preferences @@ -326,18 +326,18 @@ // Create a default mapview request // Customize dimensions and add coastlines - MvRequest viewRequest = ObjectList::CreateDefaultRequest(DEFAULTVIEW.c_str()); + MvRequest viewRequest = ObjectList::CreateDefaultRequest(DEFAULTVIEW.c_str()); viewRequest("SUBPAGE_X_POSITION") = 7; viewRequest("SUBPAGE_Y_POSITION") = 7; - viewRequest("SUBPAGE_X_LENGTH") = 86; - viewRequest("SUBPAGE_Y_LENGTH") = 86, - viewRequest("COASTLINES") = coastRequest; + viewRequest("SUBPAGE_X_LENGTH") = 86; + viewRequest("SUBPAGE_Y_LENGTH") = 86, + viewRequest("COASTLINES") = coastRequest; // Initialize parameters QString coord; geoRequest_.setVerb("INPUT"); if (inputType_ == "POINT") { - //If there is no par specified we need to guess it + // If there is no par specified we need to guess it if (inputPar_.empty()) { if (static_cast(req("POINT"))) inputPar_ = "POINT"; @@ -345,7 +345,7 @@ inputPar_ = "POSITION"; else { MvLog().popup().err() << "GeoTool-> Invalid parameter value. Valid values: POINT/POSITION"; - return QString("ERROR"); + return {"ERROR"}; } } @@ -354,13 +354,13 @@ coord = (const char*)req(inputPar_.c_str(), 0) % QChar('/') % (const char*)req(inputPar_.c_str(), 1); } else if (inputType_ == "LINE") { - //If there is no par specified we need to guess it + // If there is no par specified we need to guess it if (inputPar_.empty()) { if (static_cast(req("LINE"))) inputPar_ = "LINE"; else { MvLog().popup().err() << "GeoTool-> No parameter is specified for line helper"; - return QString("ERROR"); + return {"ERROR"}; } } @@ -371,7 +371,7 @@ coord = requestToCoord(req, inputPar_.c_str()); } else if (inputType_ == "AREA") { - //If there is no par specified we need to guess it + // If there is no par specified we need to guess it if (inputPar_.empty()) { if (static_cast(req("AREA"))) inputPar_ = "AREA"; @@ -381,16 +381,16 @@ inputPar_ = "area"; else { MvLog().popup().err() << "GeoTool-> No parameter is specified for area helper"; - return QString("ERROR"); + return {"ERROR"}; } } /*if(static_cast(req("AREA"))) - areaParam_="AREA"; - else if(static_cast(req("FLEXTRA_AREA"))) - areaParam_="FLEXTRA_AREA"; - else if(static_cast(req("area"))) - areaParam_="area";*/ + areaParam_="AREA"; + else if(static_cast(req("FLEXTRA_AREA"))) + areaParam_="FLEXTRA_AREA"; + else if(static_cast(req("area"))) + areaParam_="area";*/ geoRequest_(inputPar_.c_str()) = req(inputPar_.c_str(), 0); geoRequest_(inputPar_.c_str()) += req(inputPar_.c_str(), 1); @@ -415,8 +415,8 @@ // Finalize superpage request // Create default page and add view to this request MvRequest pageRequest = ObjectList::CreateDefaultRequest("PLOT_PAGE"); - pageRequest("VIEW") = viewRequest; - spRequest_("PAGES") = pageRequest; + pageRequest("VIEW") = viewRequest; + spRequest_("PAGES") = pageRequest; return coord; } @@ -458,30 +458,27 @@ prevActiveSceneId_ = activeScene_->layout().id(); if (prevActiveSceneId_.empty()) { MgQLayoutItem* projItem = activeScene_->firstProjectorItem(); - prevActiveSceneId_ = projItem->layout().id(); + prevActiveSceneId_ = projItem->layout().id(); } } else { prevActiveSceneId_.clear(); } - activeScene_ = 0; + activeScene_ = nullptr; } void GeoTool::newRequestForDriversEnd() { - //Select the active scene + // Select the active scene if (!activeScene_) { if (!prevActiveSceneId_.empty()) { foreach (MgQSceneItem* item, plotScene_->sceneItems()) { MgQLayoutItem* projItem = item->firstProjectorItem(); - if (item->layout().id() == prevActiveSceneId_) { - activeScene_ = item; - break; - } - else if (item->layout().id().empty() && projItem && - prevActiveSceneId_ == projItem->layout().id()) { + if ((item->layout().id() == prevActiveSceneId_) || + (item->layout().id().empty() && projItem && + prevActiveSceneId_ == projItem->layout().id())) { activeScene_ = item; break; } @@ -494,25 +491,25 @@ } } - //Resize without rendering!! + // Resize without rendering!! changeSize(sizeCombo_->itemData(sizeCombo_->currentIndex(), Qt::UserRole).toInt(), false); - //Load steps/layers and generate layer thumbnails - No rendering at this point! - //It tries to set the current step for all the scenes! - //The current step should be correctly set at least for the active scene. + // Load steps/layers and generate layer thumbnails - No rendering at this point! + // It tries to set the current step for all the scenes! + // The current step should be correctly set at least for the active scene. plotScene_->updateAfterNewRequest(); - //Zoom stack + // Zoom stack zoomStackWidget_->reset(activeScene_, false); updateZoomActionState(); - //Magnifier, cursordata etc + // Magnifier, cursordata etc plotView_->resetEnd(); - //NOW RENDER IT! We render the whole scene into the pixmap cache at this point! + // NOW RENDER IT! We render the whole scene into the pixmap cache at this point! plotScene_->sceneItemChanged(); - //Emit a signal that the plot windows has been updated + // Emit a signal that the plot windows has been updated emit plotWindowUpdated(); } @@ -543,7 +540,7 @@ double blLon = clist.at(1).toDouble(); double trLat = clist.at(2).toDouble(); double trLon = clist.at(3).toDouble(); - //plotView_->DrawRectangle(north,west,south,east); + // plotView_->DrawRectangle(north,west,south,east); emit areaChanged(blLat, blLon, trLat, trLon); } @@ -552,7 +549,7 @@ double lon1 = clist.at(1).toDouble(); double lat2 = clist.at(2).toDouble(); double lon2 = clist.at(3).toDouble(); - //plotView_->DrawRectangle(north,west,south,east); + // plotView_->DrawRectangle(north,west,south,east); emit lineChanged(lat1, lon1, lat2, lon2); } @@ -560,7 +557,7 @@ double lat = clist.at(0).toDouble(); double lon = clist.at(1).toDouble(); - //plotView_->DrawRectangle(north,west,south,east); + // plotView_->DrawRectangle(north,west,south,east); emit pointChanged(lat, lon); } @@ -638,40 +635,24 @@ void GeoTool::slotPlotWindowUpdated() { - if (inputType_ == "AREA") { - if (isFirstMap_ == true) { - //plotView_->slotSelectAllArea(); - slotCoordChanged(); - isFirstMap_ = false; - } - //slotCoordChanged(); - } - else if (inputType_ == "LINE") { - if (isFirstMap_ == true) { - slotCoordChanged(); - isFirstMap_ = false; - } - //slotCoordChanged(); - } - else if (inputType_ == "POINT") { + if (inputType_ == "AREA" || inputType_ == "LINE" || inputType_ == "POINT") { if (isFirstMap_ == true) { slotCoordChanged(); isFirstMap_ = false; } - //slotCoordChanged(); } } -//void GeoTool::slotClearSelection() +// void GeoTool::slotClearSelection() //{ // slotAreaIsUndefined(); // plotView_->slotClearArea(); -//} +// } QString GeoTool::requestToCoord(MvRequest& req, const char* param) { if (!param) - return QString(); + return {}; QString coord = (const char*)req(param, 0) % QChar('/') % (const char*)req(param, 1) % QChar('/') % diff -Nru metview-5.17.4/metview/src/uPlot/GeoTool.h metview-5.19.2/metview/src/uPlot/GeoTool.h --- metview-5.17.4/metview/src/uPlot/GeoTool.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/GeoTool.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,8 @@ Q_OBJECT public: - GeoTool(MvRequest&, QWidget* parent = 0); - ~GeoTool(); + GeoTool(MvRequest&, QWidget* parent = nullptr); + ~GeoTool() override; MvRequest SuperPageRequest() override { return spRequest_; } diff -Nru metview-5.17.4/metview/src/uPlot/GeoToolManager.cc metview-5.19.2/metview/src/uPlot/GeoToolManager.cc --- metview-5.17.4/metview/src/uPlot/GeoToolManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/GeoToolManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -101,7 +101,7 @@ // Create a new task char* desktop = getenv("MV_DESKTOP_NAME"); - if (desktop == 0) { + if (desktop == nullptr) { std::cout << "GeoToolService-> Environmental variable MV_DESKTOP_NAME not defined" << std::endl; return; } @@ -119,9 +119,9 @@ { // If error, send a message and return if (task->getError() != 0) { - //int i = 0; - //const char* msg = 0; - //while ( msg = task->getMessage (i++ ) ) + // int i = 0; + // const char* msg = 0; + // while ( msg = task->getMessage (i++ ) ) // PlotMod::MetviewError ( "uPlot crashed" ); // COUT << "GeoTool crashed" << std::endl; diff -Nru metview-5.17.4/metview/src/uPlot/GeoToolManager.h metview-5.19.2/metview/src/uPlot/GeoToolManager.h --- metview-5.17.4/metview/src/uPlot/GeoToolManager.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/GeoToolManager.h 2023-07-15 08:28:47.000000000 +0000 @@ -76,9 +76,9 @@ GeoToolManager(const char* kw); // Destructor - ~GeoToolManager() {} + ~GeoToolManager() override = default; - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; @@ -89,12 +89,12 @@ static GeoToolService& Instance(); // Destructor - ~GeoToolService(); + ~GeoToolService() override; // Methods // Perform actions after receiving response from the GeographyTool tools - virtual void endOfTask(MvTask*); + void endOfTask(MvTask*) override; // Call data tiik void CallGeoTool(MvRequest& in, MvRequest& out); diff -Nru metview-5.17.4/metview/src/uPlot/GeoView.cc metview-5.19.2/metview/src/uPlot/GeoView.cc --- metview-5.17.4/metview/src/uPlot/GeoView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/GeoView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -53,11 +53,11 @@ MvRequest coastRequest = viewRequest_.getSubrequest("COASTLINES"); if (!ObjectList::IsVisDefCoastlines(coastRequest.getVerb())) { coastRequest = ObjectList::UserDefaultRequest("MCOAST"); - //Remove later and add the code below + // Remove later and add the code below viewRequest_("COASTLINES") = coastRequest; } // Split the coastline request into geolayers - //this-> + // this-> coastRequest.print(); #else // Get GeoLayers request. If it does not exist, create a default one. Otherwise, @@ -68,12 +68,12 @@ if (!glReq) { this->GeoLayersDefaultRequest(glReq); this->UpdateViewRequestGeoLayers(glReq); - //viewRequest_ ( "GEO_LAYERS" ) = glReq; + // viewRequest_ ( "GEO_LAYERS" ) = glReq; } else { this->CheckAddGeoLayers(glReq); this->UpdateViewRequestGeoLayers(glReq); - //viewRequest_ ( "GEO_LAYERS" ) = glReq; + // viewRequest_ ( "GEO_LAYERS" ) = glReq; } #endif } @@ -105,7 +105,7 @@ /// bool found = dataBase.CheckIcon ( PRES_GEOLAYERS_REL,Owner().Id() ); /// if ( !found ) // Insert only background geolayers /// this->InsertGeoLayers(0); - ///dataBase.Print(); + /// dataBase.Print(); // Process the drop MvRequest dropRequest = context.InRequest(); MvIcon dataUnit; @@ -123,7 +123,7 @@ } MvRequest request = dropRequest.justOneRequest(); - const char* verb = request.getVerb(); + const char* verb = request.getVerb(); // if ( strcmp(verb,"DRAWING_PRIORITY") == 0 ) // { // Owner().SetDrawPriority ( request ); @@ -136,7 +136,7 @@ // } // } if (ObjectList::IsDataUnit(verb) == true) { - //MvIconDataBase& dataBase = Owner().IconDataBase(); + // MvIconDataBase& dataBase = Owner().IconDataBase(); dataUnit = dataBase.InsertDataUnit(request, Owner().Id()); Owner().InitMatching(); DecodeDataUnit(dataUnit); @@ -161,7 +161,7 @@ // Avoid this drop to be send to visualization. The result of the // service call is the one that will be send to the visualization // procedure later - //Owner().NeedsRedrawing(false); + // Owner().NeedsRedrawing(false); } else if ((const char*)verb == PLOTSUPERPAGE) { context.AdvanceTo(PLOTSUPERPAGE); @@ -182,7 +182,7 @@ // Insert only foreground geolayers /// if ( !found ) /// this->InsertGeoLayers(999); - ///dataBase.Print(); + /// dataBase.Print(); context.AdvanceToEnd(); } @@ -224,7 +224,7 @@ // Pass this information to the page for matching int dimFlag = 0; while (decoder->ReadNextData()) { - long offset = decoder->CurrentOffset(); + long offset = decoder->CurrentOffset(); long nextDataOffset = offset; MatchingInfo dataInfo = decoder->CreateMatchingInfo(); @@ -232,7 +232,7 @@ MvRequest iconRequest = dataInfo.Request(); if (IsParameterSet(iconRequest, "MY_COMPANION")) { if (decoder->ReadNextData()) { - nextDataOffset = decoder->CurrentOffset(); + nextDataOffset = decoder->CurrentOffset(); MatchingInfo nextDataInfo = decoder->CreateMatchingInfo(); // Are they companions ? @@ -317,7 +317,7 @@ // viewRequest_("SUBPAGE_OVERLAY_MODE") = "ALWAYS"; // Update icon request to indicate a vector drawing - MvRequest req = dataUnit.Request(); + MvRequest req = dataUnit.Request(); req("_NDIM_FLAG") = dimFlag; dataUnit.SaveRequest(req); } @@ -328,23 +328,23 @@ viewRequest_.print(); // Expand coastlines request. This is only needed to check if the layers are on or off. MvRequest coastRequest = viewRequest_.getSubrequest("COASTLINES"); - MvRequest expRequest = ObjectList::ExpandRequest(coastRequest, EXPAND_DEFAULTS); + MvRequest expRequest = ObjectList::ExpandRequest(coastRequest, EXPAND_DEFAULTS); // Split coastline request according to the foreground and background default rules std::string name = (const char*)coastRequest("_NAME"); MvIconList iconList; { - //this->CoastGetBackground(iconList); - // Check if land shade is to be drawn on the background + // this->CoastGetBackground(iconList); + // Check if land shade is to be drawn on the background const char* on = (const char*)expRequest("MAP_COASTLINE_LAND_SHADE"); if (on && strcmp(on, "ON") == 0) { // Get request MvRequest newRequest("MCOAST"); newRequest("MAP_COASTLINE_LAND_SHADE") = "ON"; CopySomeParameters(coastRequest, newRequest, "MAP_COASTLINE_LAND_SHADE_"); - newRequest("MAP_COASTLINE") = "ON"; //ERROR: REPLACE TO OFF WHEN MAGICS IS FIXED - newRequest("MAP_LABEL") = "OFF"; - newRequest("MAP_GRID") = "OFF"; + newRequest("MAP_COASTLINE") = "ON"; // ERROR: REPLACE TO OFF WHEN MAGICS IS FIXED + newRequest("MAP_LABEL") = "OFF"; + newRequest("MAP_GRID") = "OFF"; // Update icon name std::string newName = name + "_LandShade"; @@ -362,9 +362,9 @@ MvRequest newRequest("MCOAST"); newRequest("MAP_COASTLINE_SEA_SHADE") = "ON"; CopySomeParameters(coastRequest, newRequest, "MAP_COASTLINE_SEA_SHADE_"); - newRequest("MAP_COASTLINE") = "ON"; //ERROR: REPLACE TO OFF WHEN MAGICS IS FIXED - newRequest("MAP_LABEL") = "OFF"; - newRequest("MAP_GRID") = "OFF"; + newRequest("MAP_COASTLINE") = "ON"; // ERROR: REPLACE TO OFF WHEN MAGICS IS FIXED + newRequest("MAP_LABEL") = "OFF"; + newRequest("MAP_GRID") = "OFF"; // Update icon name std::string newName = name + "_SeaShade"; @@ -526,7 +526,7 @@ CommonDraw(subPage, drawPriorMap); #else MvIconList duList; - int count = dataBase.RetrieveIcon(PRES_DATAUNIT_REL, subPage->Id(), duList); + int count = dataBase.RetrieveIcon(PRES_DATAUNIT_REL, subPage->Id(), duList); MvListCursor listCursor = duList.begin(); while (listCursor != duList.end()) { MvIcon duIcon = *listCursor; @@ -544,14 +544,14 @@ { // Expand coastlines request. This is only needed to check if the layers are on or off. MvRequest coastRequest = viewRequest_.getSubrequest("COASTLINES"); - MvRequest expRequest = ObjectList::ExpandRequest(coastRequest, EXPAND_DEFAULTS); + MvRequest expRequest = ObjectList::ExpandRequest(coastRequest, EXPAND_DEFAULTS); // Split coastline request according to the foreground default rules std::string name = (const char*)coastRequest("_NAME"); MvIconList iconList; { - //this->CoastGetForeground(iconList); - // Check if coastline is to be drawn on the foreground + // this->CoastGetForeground(iconList); + // Check if coastline is to be drawn on the foreground const char* on = (const char*)expRequest("MAP_COASTLINE"); if (on && strcmp(on, "ON") == 0) { // Get request @@ -559,9 +559,9 @@ newRequest("MAP_COASTLINE") = "ON"; CopySomeParameters(coastRequest, newRequest, "MAP_COASTLINE_"); newRequest("MAP_COASTLINE_LAND_SHADE") = "OFF"; - newRequest("MAP_COASTLINE_SEA_SHADE") = "OFF"; - newRequest("MAP_GRID") = "OFF"; - newRequest("MAP_LABEL") = "OFF"; + newRequest("MAP_COASTLINE_SEA_SHADE") = "OFF"; + newRequest("MAP_GRID") = "OFF"; + newRequest("MAP_LABEL") = "OFF"; // Update icon name std::string newName = name + "_Coastline"; @@ -582,8 +582,8 @@ CopySomeParameters(coastRequest, newRequest, "MAP_DISPUTED_BOUNDARIES"); CopySomeParameters(coastRequest, newRequest, "MAP_ADMINISTRATIVE_BOUNDARIES"); newRequest("MAP_COASTLINE") = "OFF"; - newRequest("MAP_LABEL") = "OFF"; - newRequest("MAP_GRID") = "OFF"; + newRequest("MAP_LABEL") = "OFF"; + newRequest("MAP_GRID") = "OFF"; // Update icon name std::string newName = name + "_Boundaries"; @@ -602,8 +602,8 @@ newRequest("MAP_CITIES") = "ON"; CopySomeParameters(coastRequest, newRequest, "MAP_CITIES_"); newRequest("MAP_COASTLINE") = "OFF"; - newRequest("MAP_LABEL") = "OFF"; - newRequest("MAP_GRID") = "OFF"; + newRequest("MAP_LABEL") = "OFF"; + newRequest("MAP_GRID") = "OFF"; // Update icon name std::string newName = name + "_Cities"; @@ -622,8 +622,8 @@ newRequest("MAP_RIVERS") = "ON"; CopySomeParameters(coastRequest, newRequest, "MAP_RIVERS_"); newRequest("MAP_COASTLINE") = "OFF"; - newRequest("MAP_LABEL") = "OFF"; - newRequest("MAP_GRID") = "OFF"; + newRequest("MAP_LABEL") = "OFF"; + newRequest("MAP_GRID") = "OFF"; // Update icon name std::string newName = name + "_Rivers"; @@ -642,7 +642,7 @@ newRequest("MAP_GRID") = "ON"; CopySomeParameters(coastRequest, newRequest, "MAP_GRID_"); newRequest("MAP_COASTLINE") = "OFF"; - newRequest("MAP_LABEL") = "OFF"; + newRequest("MAP_LABEL") = "OFF"; // Update icon name std::string newName = name + "_Grid"; @@ -661,7 +661,7 @@ newRequest("MAP_LABEL") = "ON"; CopySomeParameters(coastRequest, newRequest, "MAP_LABEL_"); newRequest("MAP_COASTLINE") = "OFF"; - newRequest("MAP_GRID") = "OFF"; + newRequest("MAP_GRID") = "OFF"; // Update icon name std::string newName = name + "_Label"; @@ -767,9 +767,9 @@ // Draw Coastline and/or other options (Grid,Label,...) on the foreground ge.Draw ( coastRequest, true ); */ - //Owner().SetProjection ( viewRequest_ ); - // Retrieve the graphics Engine - // GraphicsEngine& ge = Owner().GetGraphicsEngine(); + // Owner().SetProjection ( viewRequest_ ); + // Retrieve the graphics Engine + // GraphicsEngine& ge = Owner().GetGraphicsEngine(); // Ask the graphics engine to draw the coastlines // ge.DrawGeoLayersFront ( viewRequest_ ); @@ -789,7 +789,7 @@ bool GeoView::CallService(const MvRequest& req, PmContext& context) { - MvRequest appRequest = req; + MvRequest appRequest = req; appRequest("_CONTEXT") = viewRequest_; // Find service name @@ -810,14 +810,14 @@ { bool geoUpdated = false; if (IsParameterSet(glReq, "GEO_COASTLINE") == false) { - MvRequest coast = ObjectList::UserDefaultRequest("GEO_COASTLINE"); + MvRequest coast = ObjectList::UserDefaultRequest("GEO_COASTLINE"); glReq("GEO_COASTLINE") = coast; - geoUpdated = true; + geoUpdated = true; } if (IsParameterSet(glReq, "GEO_GRID") == false) { - MvRequest coast = ObjectList::UserDefaultRequest("GEO_GRID"); + MvRequest coast = ObjectList::UserDefaultRequest("GEO_GRID"); glReq("GEO_GRID") = coast; - geoUpdated = true; + geoUpdated = true; } return geoUpdated; @@ -826,12 +826,12 @@ void GeoView::UpdateViewWithReq(MvRequest& viewRequest) { if (strcmp(viewRequest_.getVerb(), viewRequest.getVerb()) == 0) - //ObjectList::IsGeographicalView( viewRequest.getVerb() ) ) + // ObjectList::IsGeographicalView( viewRequest.getVerb() ) ) { // Update GeoLayers information - //MvRequest glReq = viewRequest("GEO_LAYERS"); - //if ( this->InsertGeoLayers ( glReq ) ) - //viewRequest("GEO_LAYERS") = glReq; + // MvRequest glReq = viewRequest("GEO_LAYERS"); + // if ( this->InsertGeoLayers ( glReq ) ) + // viewRequest("GEO_LAYERS") = glReq; // Update view request viewRequest_ = viewRequest; @@ -853,9 +853,9 @@ { // The behaviou of dropping a Coastlines icon is different depending on // the running mode: interactive = replace Coastlines, batch = add Coastlines. - //if ( PlotMod::Instance().IsInteractive() ) + // if ( PlotMod::Instance().IsInteractive() ) if ((const char*)glReq("_APPL") && strcmp((const char*)glReq("_APPL"), "macro") == 0) { - //COUT <<"Add"< lonMax_) { double W = lonMin_; - lonMin_ = lonMax_; - lonMax_ = W; - swap = true; + lonMin_ = lonMax_; + lonMax_ = W; + swap = true; } if (latMin_ > latMax_) { double W = latMin_; - latMin_ = latMax_; - latMax_ = W; - swap = true; + latMin_ = latMax_; + latMax_ = W; + swap = true; } } @@ -151,17 +151,28 @@ if (swap) MvLog().popup().warn() << "Input geographical coordinates do not follow MARS rules (n/w/s/e). Values have been swapped "; + updateDates(in); + + // Set swapAxes flag + swapAxes_ = ((const char*)in("SWAP_AXES") && + strcmp(in("SWAP_AXES"), "YES") == 0) + ? true + : false; +} + +void HovmoellerView::updateDates(const MvRequest& in) +{ // Set date limits - bool bDateMin, bDateMax; + bool bDateMin = false, bDateMax = false; if ((const char*)in("TIME_AXIS_MODE") && strcmp((const char*)in("TIME_AXIS_MODE"), "AUTOMATIC_FORWARDS") == 0) { bDateMin = bDateMax = true; - dateMin_ = "2013-01-01"; - dateMax_ = "2013-01-01 00:01:00"; + dateMin_ = "2013-01-01"; + dateMax_ = "2013-01-01 00:01:00"; } else if ((const char*)in("TIME_AXIS_MODE") && strcmp((const char*)in("TIME_AXIS_MODE"), "AUTOMATIC_BACKWARDS") == 0) { bDateMin = bDateMax = true; - dateMax_ = "2013-01-01"; - dateMin_ = "2013-01-01 00:01:00"; + dateMax_ = "2013-01-01"; + dateMin_ = "2013-01-01 00:01:00"; } else { if (strcmp((const char*)in("DATE_MIN"), "AUTOMATIC") == 0) { @@ -192,14 +203,6 @@ MvLog().popup().err() << "Hovmoeller Error: both parameters DATE_MIN and DATE_MAX must be automatic or non-automatic."; bAutoDate_ = false; } - - // Set swapAxes flag - swapAxes_ = ((const char*)in("SWAP_AXES") && - strcmp(in("SWAP_AXES"), "YES") == 0) - ? true - : false; - - return; } bool HovmoellerView::UpdateView() @@ -220,8 +223,8 @@ (strcmp((const char*)viewRequest_("X_AXIS_TYPE"), "DATE") == 0)) { if (bAutoDate_) { viewRequest_("X_AUTOMATIC") = "ON"; - MvDate dmin = (const char*)viewRequest_("X_DATE_MIN"); - MvDate dmax = (const char*)viewRequest_("X_DATE_MAX"); + MvDate dmin = (const char*)viewRequest_("X_DATE_MIN"); + MvDate dmax = (const char*)viewRequest_("X_DATE_MAX"); if (dmin > dmax) viewRequest_("X_AUTOMATIC_REVERSE") = "ON"; @@ -234,8 +237,8 @@ (strcmp((const char*)viewRequest_("Y_AXIS_TYPE"), "DATE") == 0)) { if (bAutoDate_) { viewRequest_("Y_AUTOMATIC") = "ON"; - MvDate dmin = (const char*)viewRequest_("Y_DATE_MIN"); - MvDate dmax = (const char*)viewRequest_("Y_DATE_MAX"); + MvDate dmin = (const char*)viewRequest_("Y_DATE_MIN"); + MvDate dmax = (const char*)viewRequest_("Y_DATE_MAX"); if (dmin > dmax) viewRequest_("Y_AUTOMATIC_REVERSE") = "ON"; @@ -248,6 +251,13 @@ return true; } + // This is called to handle the case when a data icon is dropped into a + // view, which has initilally automatic dates set. Then the data is processed + // by the Hovmoller module that sends back an updated view, which will overwrite + // viewRequest_. However, its settings are not copied into member varables storing the + // dates. So we have to do it here! + updateDates(viewRequest_); + // Translate specific parameters MvRequest cartView("CARTESIANVIEW"); if (type_ == HOVLINE) @@ -281,7 +291,7 @@ void HovmoellerView::UpdateViewWithReq(MvRequest& view) { this->ApplicationInfo(view); - Owner().UpdateView(view); //Test 20160927 + Owner().UpdateView(view); // Test 20160927 } void HovmoellerView::UpdateViewLine(MvRequest& cartView) @@ -297,11 +307,12 @@ // 2) Hovmoeller computes values from North to South (first value // in the netCDF matrix is [LatNorth,LonWest] and Magics plots them // from bottom to top by default. + if (swapAxes_) { - cartView("Y_AUTOMATIC") = "OFF"; - cartView("Y_AXIS_TYPE") = "GEOLINE"; - cartView("Y_MIN_LATITUDE") = latMin_; - cartView("Y_MAX_LATITUDE") = latMax_; + cartView("Y_AUTOMATIC") = "OFF"; + cartView("Y_AXIS_TYPE") = "GEOLINE"; + cartView("Y_MIN_LATITUDE") = latMin_; + cartView("Y_MAX_LATITUDE") = latMax_; cartView("Y_MIN_LONGITUDE") = lonMax_; cartView("Y_MAX_LONGITUDE") = lonMin_; @@ -315,8 +326,8 @@ } else { cartView("X_AUTOMATIC") = "OFF"; - cartView("X_DATE_MIN") = dateMin_.c_str(); - cartView("X_DATE_MAX") = dateMax_.c_str(); + cartView("X_DATE_MIN") = dateMin_.c_str(); + cartView("X_DATE_MAX") = dateMax_.c_str(); if (!bAutoDate_) bUpdateDate_ = false; } @@ -326,10 +337,10 @@ cartView.setValue("VERTICAL_AXIS", viewRequest_.getSubrequest("GEO_AXIS")); } else { - cartView("X_AUTOMATIC") = "OFF"; - cartView("X_AXIS_TYPE") = "GEOLINE"; - cartView("X_MIN_LATITUDE") = latMax_; - cartView("X_MAX_LATITUDE") = latMin_; + cartView("X_AUTOMATIC") = "OFF"; + cartView("X_AXIS_TYPE") = "GEOLINE"; + cartView("X_MIN_LATITUDE") = latMax_; + cartView("X_MAX_LATITUDE") = latMin_; cartView("X_MIN_LONGITUDE") = lonMin_; cartView("X_MAX_LONGITUDE") = lonMax_; @@ -342,8 +353,8 @@ } else { cartView("Y_AUTOMATIC") = "OFF"; - cartView("Y_DATE_MIN") = dateMin_.c_str(); - cartView("Y_DATE_MAX") = dateMax_.c_str(); + cartView("Y_DATE_MIN") = dateMin_.c_str(); + cartView("Y_DATE_MAX") = dateMax_.c_str(); if (!bAutoDate_) bUpdateDate_ = false; } @@ -352,7 +363,7 @@ cartView.setValue("HORIZONTAL_AXIS", viewRequest_.getSubrequest("GEO_AXIS")); cartView.setValue("VERTICAL_AXIS", viewRequest_.getSubrequest("TIME_AXIS")); } - //cartView("X_AUTOMATIC") = "OFF"; + // cartView("X_AUTOMATIC") = "OFF"; } void HovmoellerView::UpdateViewArea(MvRequest& cartView) @@ -364,7 +375,7 @@ // Translate Geographical and Time coordinates std::string dir = (const char*)viewRequest_("AVERAGE_DIRECTION"); - int hAxis, vAxis; // 1 - time, 2 - latitude, 3 - longitude + int hAxis = 0, vAxis = 0; // 1 - time, 2 - latitude, 3 - longitude if (swapAxes_) { hAxis = (dir == "EAST_WEST") ? 2 : 1; vAxis = (dir == "EAST_WEST") ? 1 : 3; @@ -385,8 +396,8 @@ } else { cartView("X_AUTOMATIC") = "OFF"; - cartView("X_DATE_MIN") = dateMin_.c_str(); - cartView("X_DATE_MAX") = dateMax_.c_str(); + cartView("X_DATE_MIN") = dateMin_.c_str(); + cartView("X_DATE_MAX") = dateMax_.c_str(); if (!bAutoDate_) bUpdateDate_ = false; } @@ -395,13 +406,13 @@ if (vAxis == 2) // vertical latitude axis { geoAxisReq("AXIS_TICK_LABEL_TYPE") = "LATITUDE"; - cartView("Y_MIN") = latMin_; - cartView("Y_MAX") = latMax_; + cartView("Y_MIN") = latMin_; + cartView("Y_MAX") = latMax_; } else // vertical longitude axis { - cartView("Y_MIN") = lonMin_; - cartView("Y_MAX") = lonMax_; + cartView("Y_MIN") = lonMin_; + cartView("Y_MAX") = lonMax_; geoAxisReq("AXIS_TICK_LABEL_TYPE") = "LONGITUDE"; } @@ -411,10 +422,10 @@ } else if (hAxis == 2) // Horizontal latitude axis { - cartView("X_AXIS_TYPE") = "REGULAR"; - cartView("X_MIN") = latMin_; - cartView("X_MAX") = latMax_; - geoAxisReq("AXIS_ORIENTATION") = "HORIZONTAL"; + cartView("X_AXIS_TYPE") = "REGULAR"; + cartView("X_MIN") = latMin_; + cartView("X_MAX") = latMax_; + geoAxisReq("AXIS_ORIENTATION") = "HORIZONTAL"; geoAxisReq("AXIS_TICK_LABEL_TYPE") = "LATITUDE"; cartView("Y_AXIS_TYPE") = "DATE"; @@ -426,8 +437,8 @@ } else { cartView("Y_AUTOMATIC") = "OFF"; - cartView("Y_DATE_MIN") = dateMin_.c_str(); - cartView("Y_DATE_MAX") = dateMax_.c_str(); + cartView("Y_DATE_MIN") = dateMin_.c_str(); + cartView("Y_DATE_MAX") = dateMax_.c_str(); if (!bAutoDate_) bUpdateDate_ = false; } @@ -438,10 +449,10 @@ } else // Horizontal longitude axis { - cartView("X_AXIS_TYPE") = "REGULAR"; - cartView("X_MIN") = lonMin_; - cartView("X_MAX") = lonMax_; - geoAxisReq("AXIS_ORIENTATION") = "HORIZONTAL"; + cartView("X_AXIS_TYPE") = "REGULAR"; + cartView("X_MIN") = lonMin_; + cartView("X_MAX") = lonMax_; + geoAxisReq("AXIS_ORIENTATION") = "HORIZONTAL"; geoAxisReq("AXIS_TICK_LABEL_TYPE") = "LONGITUDE"; cartView("Y_AXIS_TYPE") = "DATE"; @@ -453,8 +464,8 @@ } else { cartView("Y_AUTOMATIC") = "OFF"; - cartView("Y_DATE_MIN") = dateMin_.c_str(); - cartView("Y_DATE_MAX") = dateMax_.c_str(); + cartView("Y_DATE_MIN") = dateMin_.c_str(); + cartView("Y_DATE_MAX") = dateMax_.c_str(); if (!bAutoDate_) bUpdateDate_ = false; } @@ -482,16 +493,16 @@ } else { cartView("X_AUTOMATIC") = "OFF"; - cartView("X_DATE_MIN") = dateMin_.c_str(); - cartView("X_DATE_MAX") = dateMax_.c_str(); + cartView("X_DATE_MIN") = dateMin_.c_str(); + cartView("X_DATE_MAX") = dateMax_.c_str(); if (!bAutoDate_) bUpdateDate_ = false; } cartView("Y_AUTOMATIC") = "OFF"; cartView("Y_AXIS_TYPE") = vs; - cartView("Y_MIN") = yMin_; - cartView("Y_MAX") = yMax_; + cartView("Y_MIN") = yMin_; + cartView("Y_MAX") = yMax_; // Copy axis definition cartView.setValue("HORIZONTAL_AXIS", viewRequest_.getSubrequest("TIME_AXIS")); diff -Nru metview-5.17.4/metview/src/uPlot/HovmoellerView.h metview-5.19.2/metview/src/uPlot/HovmoellerView.h --- metview-5.17.4/metview/src/uPlot/HovmoellerView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/HovmoellerView.h 2023-07-15 08:28:47.000000000 +0000 @@ -52,7 +52,7 @@ class HovmoellerViewFactory : public PlotModViewFactory { // -- Virtual Constructor - Builds a new HovmoellerView - virtual PlotModView* Build(Page&, const MvRequest&, const MvRequest&); + PlotModView* Build(Page&, const MvRequest&, const MvRequest&) override; public: // Constructors @@ -66,7 +66,7 @@ class HovmoellerViewM3Factory : public PlotModViewFactory { // -- Virtual Constructor - Builds a new HovmoellerView - virtual PlotModView* Build(Page&, const MvRequest&, const MvRequest&); + PlotModView* Build(Page&, const MvRequest&, const MvRequest&) override; // Translate Metview 3 view request to Metview 4 MvRequest Translate(const MvRequest&); @@ -88,7 +88,7 @@ PlotModView* Clone() const override { return new HovmoellerView(*this); } // -- Destructor - ~HovmoellerView() {} + ~HovmoellerView() override = default; // -- Methods // -- Overriden from CommonXSectView class @@ -113,6 +113,8 @@ void ApplicationInfo(const MvRequest&) override; + void updateDates(const MvRequest& in); + // Update View according to the Hovmoeller type void UpdateViewLine(MvRequest&); void UpdateViewArea(MvRequest&); diff -Nru metview-5.17.4/metview/src/uPlot/IconClass.h metview-5.19.2/metview/src/uPlot/IconClass.h --- metview-5.17.4/metview/src/uPlot/IconClass.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/IconClass.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ { public: IconClass(const std::string&, request*); - ~IconClass() {} + ~IconClass() override = default; static const std::map& items() { return items_; } static void load(request*); diff -Nru metview-5.17.4/metview/src/uPlot/LayerControlWidget.h metview-5.19.2/metview/src/uPlot/LayerControlWidget.h --- metview-5.17.4/metview/src/uPlot/LayerControlWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/LayerControlWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,8 @@ Q_OBJECT public: - LayerControlWidget(MvQLayerWidget*, MvQDataWidget*, QWidget* parent = 0); - ~LayerControlWidget() {} + LayerControlWidget(MvQLayerWidget*, MvQDataWidget*, QWidget* parent = nullptr); + ~LayerControlWidget() override = default; public slots: void showLayerList(); diff -Nru metview-5.17.4/metview/src/uPlot/Location.cc metview-5.19.2/metview/src/uPlot/Location.cc --- metview-5.17.4/metview/src/uPlot/Location.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Location.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,16 +16,16 @@ Location::Location(const MvRequest& pageRequest) { // Find out the size of the page - double top = pageRequest("TOP"); + double top = pageRequest("TOP"); double bottom = pageRequest("BOTTOM"); - double left = pageRequest("LEFT"); - double right = pageRequest("RIGHT"); + double left = pageRequest("LEFT"); + double right = pageRequest("RIGHT"); - rect_.top = top / 100.; + rect_.top = top / 100.; rect_.left = left / 100.; rect_.bottom = bottom / 100.; - rect_.right = right / 100.; + rect_.right = right / 100.; // CheckNormalised(); // ensure ( ( right - left ) <= 100. ); @@ -33,20 +33,20 @@ Location::Location(double top, double left, double bottom, double right) { - rect_.top = top; + rect_.top = top; rect_.left = left; rect_.bottom = bottom; - rect_.right = right; + rect_.right = right; } Location::Location(const Location& rhs) { - rect_.top = rhs.rect_.top; + rect_.top = rhs.rect_.top; rect_.left = rhs.rect_.left; rect_.bottom = rhs.rect_.bottom; - rect_.right = rhs.rect_.right; + rect_.right = rhs.rect_.right; } Location::Location(char* rect) @@ -54,11 +54,11 @@ // The expected format is: n1/n2... double coord[4]; char str1[30]; - int i, j; + int i = 0, j = 0; char* p1 = &rect[0]; coord[0] = coord[1] = coord[2] = coord[3] = 0; - j = 0; + j = 0; while (*p1 && j < 4) { i = 0; while (*p1 && *p1 != '/' && i < 29) { @@ -66,17 +66,17 @@ p1++; } - str1[i] = 0; + str1[i] = 0; coord[j++] = atof(str1); if (*p1) p1++; } - rect_.top = coord[2]; + rect_.top = coord[2]; rect_.left = coord[1]; rect_.bottom = coord[0]; - rect_.right = coord[3]; + rect_.right = coord[3]; } Location::~Location() = default; @@ -87,11 +87,11 @@ if (this == &rhs) return *this; - rect_.top = rhs.rect_.top; + rect_.top = rhs.rect_.top; rect_.left = rhs.rect_.left; rect_.bottom = rhs.rect_.bottom; - rect_.right = rhs.rect_.right; + rect_.right = rhs.rect_.right; return *this; } @@ -99,28 +99,28 @@ Location operator+(const Location& lhs, const Location& rhs) { - return Location(lhs.rect_.top + rhs.rect_.top, - lhs.rect_.left + rhs.rect_.left, - lhs.rect_.bottom + rhs.rect_.bottom, - lhs.rect_.right + rhs.rect_.right); + return {lhs.rect_.top + rhs.rect_.top, + lhs.rect_.left + rhs.rect_.left, + lhs.rect_.bottom + rhs.rect_.bottom, + lhs.rect_.right + rhs.rect_.right}; } Location operator-(const Location& lhs, const Location& rhs) { - return Location(lhs.rect_.top - rhs.rect_.top, - lhs.rect_.left - rhs.rect_.left, - lhs.rect_.bottom - rhs.rect_.bottom, - lhs.rect_.right - rhs.rect_.right); + return {lhs.rect_.top - rhs.rect_.top, + lhs.rect_.left - rhs.rect_.left, + lhs.rect_.bottom - rhs.rect_.bottom, + lhs.rect_.right - rhs.rect_.right}; } Location operator*(const double scaleFactor, const Location& rhs) { - return Location(scaleFactor * rhs.rect_.top, - scaleFactor * rhs.rect_.left, - scaleFactor * rhs.rect_.bottom, - scaleFactor * rhs.rect_.right); + return {scaleFactor * rhs.rect_.top, + scaleFactor * rhs.rect_.left, + scaleFactor * rhs.rect_.bottom, + scaleFactor * rhs.rect_.right}; } bool operator==(const Location& lhs, const Location& rhs) diff -Nru metview-5.17.4/metview/src/uPlot/Location.h metview-5.19.2/metview/src/uPlot/Location.h --- metview-5.17.4/metview/src/uPlot/Location.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Location.h 2023-07-15 08:28:47.000000000 +0000 @@ -137,7 +137,7 @@ // Print rectangle void Print() const; -protected: +private: // Checking values // void CheckNormalized (); // ensure box is between [0..1] diff -Nru metview-5.17.4/metview/src/uPlot/LocationLabelWidget.cc metview-5.19.2/metview/src/uPlot/LocationLabelWidget.cc --- metview-5.17.4/metview/src/uPlot/LocationLabelWidget.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/LocationLabelWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,95 @@ +/***************************** LICENSE START *********************************** + + Copyright 2023 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + +#include +#include +#include + +#include "LocationLabelWidget.h" +#include "CursorCoordinate.h" +#include "MvQMethods.h" +#include "MvQPlotView.h" + +namespace metview { +namespace uplot { + +LocationLabelWidget::LocationLabelWidget(QWidget* parent, MvQPlotView* view) : + QLabel(parent), view_(view) +{ + setProperty("type", "location"); + setText("Location"); + setFont(MvQ::findMonospaceFont(true)); + + viewAction_ = new QAction(this); + viewAction_->setText(tr("Show location label")); + viewAction_->setCheckable(true); + viewAction_->setChecked(true); + + connect(viewAction_, SIGNAL(toggled(bool)), + this, SLOT(showLabel(bool))); + + showLabel(true); +} + +void LocationLabelWidget::setLocation(const CursorCoordinate& coord) { + + if (isVisible()) { + QString t; + static QString invalidText("Cursor outside plot area"); + if (coord.isValid()) { + if (coord.type() == CursorCoordinate::LonLatType) { + QString x, y; +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) + x = QString::asprintf("%7.3f", coord.y()); + y = QString::asprintf("%8.3f", coord.x()); +#else + QString dummyStr; + x = dummyStr.sprintf("%7.3f", coord.y()); + y = dummyStr.sprintf("%8.3f", coord.x()); +#endif + t = "Lat: " + x + " Lon: " + y ; + + } else { + t = QString("X: %1 Y: %2").arg(coord.y(), 0, 'f', 3).arg(coord.x(), 0, 'f',3); + } + } else { + t = invalidText; + } + + if (t != text()) { + setText(t); + } + } +} + +void LocationLabelWidget::showLabel(bool st) +{ + setVisible(st); + // notify cursor data. When this label is hidden there is no need + // to track coordinates + view_->setEnableTrackCursorCoordinates(st); +} + +void LocationLabelWidget::writeSettings(QSettings& settings) +{ + settings.setValue("locationLabel", viewAction_->isChecked()); +} + +void LocationLabelWidget::readSettings(QSettings& settings) +{ + if (settings.value("locationLabel").isNull()) { + viewAction_->setChecked(true); + } + else { + viewAction_->setChecked(settings.value("locationLabel").toBool()); + } +} + +} // uplot +} // metview diff -Nru metview-5.17.4/metview/src/uPlot/LocationLabelWidget.h metview-5.19.2/metview/src/uPlot/LocationLabelWidget.h --- metview-5.17.4/metview/src/uPlot/LocationLabelWidget.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/LocationLabelWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,44 @@ +/***************************** LICENSE START *********************************** + + Copyright 2023 ECMWF and INPE. This software is distributed under the terms + of the Apache License version 2.0. In applying this license, ECMWF does not + waive the privileges and immunities granted to it by virtue of its status as + an Intergovernmental Organization or submit itself to any jurisdiction. + + ***************************** LICENSE END *************************************/ + + +#pragma once + +#include +#include + +class CursorCoordinate; +class QAction; +class MvQPlotView; + +namespace metview { +namespace uplot { + +class LocationLabelWidget : public QLabel +{ +Q_OBJECT +public: + LocationLabelWidget(QWidget*, MvQPlotView* view); + QAction* viewAction() const {return viewAction_;} + void writeSettings(QSettings& settings); + void readSettings(QSettings& settings); + +public slots: + void setLocation(const CursorCoordinate&); + +protected slots: + void showLabel(bool st); + +private: + MvQPlotView* view_{nullptr}; + QAction* viewAction_{nullptr}; +}; + +} // uplot +} // metview diff -Nru metview-5.17.4/metview/src/uPlot/MacroConverter.cc metview-5.19.2/metview/src/uPlot/MacroConverter.cc --- metview-5.17.4/metview/src/uPlot/MacroConverter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MacroConverter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -85,7 +85,7 @@ Cached DefaultMacroConverter::Convert(MvRequest& req, ObjectInfo* oi) { // Convert the request and return the object name - Cached duName = ObjectInfo::GenerateName(req); + Cached duName = ObjectInfo::GenerateName(req); Cached macroName = ObjectList::MacroName(req.getVerb()); oi->ConvertRequestToMacro(req, PUT_END, duName, macroName); @@ -106,7 +106,7 @@ MvRequest tmpReq = req; const char* name = tmpReq("_NAME"); - Cached duName = ObjectInfo::GenerateName(req); + Cached duName = ObjectInfo::GenerateName(req); // Usually, first request contains just the family part. // If this is the case then skip it @@ -141,7 +141,7 @@ // use a single algorithm for both MacroConverter and MacroEditor #if 1 // Get initial information - const char* name = req("_NAME"); + const char* name = req("_NAME"); std::string duName = (const char*)ObjectInfo::GenerateName(req); // First request contains just the family part, get the name and skip it @@ -164,7 +164,7 @@ // Copy command lines while (in.getline(buf, 1023)) { // Strip of empty and "#Importing ..." lines - if (strlen(buf) != 0 && strncmp("# Importing :", buf, 13)) + if (strlen(buf) != 0 && strncmp("# Importing :", buf, 13) != 0) oi->PutNewLine(buf); } in.close(); @@ -178,9 +178,9 @@ return duName.c_str(); #else - MvRequest tmpReq = req; - const char* name = req("_NAME"); - Cached duName = ObjectInfo::GenerateName(req); + MvRequest tmpReq = req; + const char* name = req("_NAME"); + Cached duName = ObjectInfo::GenerateName(req); Cached returnName = ObjectInfo::SpaceToUnderscore(duName); // First request contains just the family part, so skip it @@ -193,7 +193,7 @@ MvRequest defReq = ObjectList::CreateDefaultRequest(tmpReq.getVerb()); const char *f, *p1, *p2, *oper; - bool twoParams = false; + bool twoParams = false; std::string formula = " = "; std::string cp1, cp2; if (IsParameterSet(tmpReq, "PARAMETER_2")) { @@ -257,7 +257,7 @@ Cached returnName; Cached duName = ObjectInfo::GenerateName(req); - Cached path = ObjectInfo::ObjectPath(req); + Cached path = ObjectInfo::ObjectPath(req); // First request contains just the family part, so skip it req.advance(); @@ -270,7 +270,7 @@ if (!strcmp(curveType, "GRAPH")) { // Get the names for the curves and try to exand them. std::vector curveNames; - const char* name; + const char* name = nullptr; Cached oneName; for (int i = 0; i < req.countValues("CURVES"); i++) { req.getValue(name, "CURVES", i); @@ -331,7 +331,7 @@ else { while (in.getline(buf, 1023)) { // Strip of #Importing ... lines - if (strncmp("# Importing :", buf, 13)) + if (strncmp("# Importing :", buf, 13) != 0) oi->PutNewLine(buf); } in.close(); @@ -385,5 +385,5 @@ Cached EmptyMacroConverter::Convert(MvRequest& /*req*/, ObjectInfo* /*oi*/) { - return Cached(""); + return {""}; } diff -Nru metview-5.17.4/metview/src/uPlot/MacroConverter.h metview-5.19.2/metview/src/uPlot/MacroConverter.h --- metview-5.17.4/metview/src/uPlot/MacroConverter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MacroConverter.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ struct ConverterTraits { - typedef MacroConverter Type; + using Type = MacroConverter; static Type& DefaultObject(); }; @@ -34,14 +34,14 @@ Prototype(converterName, this) {} // Destructors - virtual ~MacroConverter() {} + ~MacroConverter() override = default; // Methods virtual Cached Convert(MvRequest&, ObjectInfo* oi) = 0; private: // No copy allowed - MacroConverter(const MacroConverter&); + MacroConverter(const MacroConverter&) = delete; MacroConverter& operator=(const MacroConverter&) { return *this; } }; @@ -51,9 +51,9 @@ DefaultMacroConverter(const Cached& name) : MacroConverter(name) {} - ~DefaultMacroConverter() {} + ~DefaultMacroConverter() override = default; - virtual Cached Convert(MvRequest&, ObjectInfo*); + Cached Convert(MvRequest&, ObjectInfo*) override; }; class ReadMacroConverter : public MacroConverter @@ -61,9 +61,9 @@ public: ReadMacroConverter(const Cached& name) : MacroConverter(name) {} - ~ReadMacroConverter() {} + ~ReadMacroConverter() override = default; - virtual Cached Convert(MvRequest&, ObjectInfo* oi); + Cached Convert(MvRequest&, ObjectInfo* oi) override; }; class FamilyMacroConverter : public MacroConverter @@ -71,9 +71,9 @@ public: FamilyMacroConverter(const Cached& name) : MacroConverter(name) {} - ~FamilyMacroConverter() {} + ~FamilyMacroConverter() override = default; - virtual Cached Convert(MvRequest&, ObjectInfo* oi); + Cached Convert(MvRequest&, ObjectInfo* oi) override; }; class CurveFamilyMacroConverter : public MacroConverter @@ -81,9 +81,9 @@ public: CurveFamilyMacroConverter(const Cached& name) : MacroConverter(name) {} - ~CurveFamilyMacroConverter() {} + ~CurveFamilyMacroConverter() override = default; - virtual Cached Convert(MvRequest&, ObjectInfo* oi); + Cached Convert(MvRequest&, ObjectInfo* oi) override; }; class FormulaFamilyMacroConverter : public MacroConverter @@ -91,9 +91,9 @@ public: FormulaFamilyMacroConverter(const Cached& name) : MacroConverter(name) {} - ~FormulaFamilyMacroConverter() {} + ~FormulaFamilyMacroConverter() override = default; - virtual Cached Convert(MvRequest&, ObjectInfo* oi); + Cached Convert(MvRequest&, ObjectInfo* oi) override; }; class ComputeMacroConverter : public MacroConverter @@ -101,9 +101,9 @@ public: ComputeMacroConverter(const Cached& name) : MacroConverter(name) {} - ~ComputeMacroConverter() {} + ~ComputeMacroConverter() override = default; - virtual Cached Convert(MvRequest&, ObjectInfo* oi); + Cached Convert(MvRequest&, ObjectInfo* oi) override; }; class DataMacroConverter : public MacroConverter @@ -111,9 +111,9 @@ public: DataMacroConverter(const Cached& name) : MacroConverter(name) {} - ~DataMacroConverter() {} + ~DataMacroConverter() override = default; - virtual Cached Convert(MvRequest&, ObjectInfo* oi); + Cached Convert(MvRequest&, ObjectInfo* oi) override; }; class EmptyMacroConverter : public MacroConverter @@ -121,7 +121,7 @@ public: EmptyMacroConverter(const Cached& name) : MacroConverter(name) {} - ~EmptyMacroConverter() {} + ~EmptyMacroConverter() override = default; - virtual Cached Convert(MvRequest&, ObjectInfo*); + Cached Convert(MvRequest&, ObjectInfo*) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/MacroVisitor.cc metview-5.19.2/metview/src/uPlot/MacroVisitor.cc --- metview-5.17.4/metview/src/uPlot/MacroVisitor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MacroVisitor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,7 @@ { // Create an appropriate fileName std::string pathName = ObjectInfo::ObjectFullPath(superpageRequest); - return std::string(MakeIconName(pathName.c_str(), "MacroFramework")); + return {MakeIconName(pathName.c_str(), "MacroFramework")}; } // -- Constructor @@ -76,8 +76,8 @@ // void MacroVisitor::WriteProlog() { - struct passwd* who = getpwuid(getuid()); - time_t when = time(nullptr); + struct passwd* who = getpwuid(getuid()); + time_t when = time(nullptr); const char* version = getenv("METVIEW_VERSION"); fprintf(filePtr_, "# Metview Macro - created from Display Window contents\n"); diff -Nru metview-5.17.4/metview/src/uPlot/MacroVisitor.h metview-5.19.2/metview/src/uPlot/MacroVisitor.h --- metview-5.17.4/metview/src/uPlot/MacroVisitor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MacroVisitor.h 2023-07-15 08:28:47.000000000 +0000 @@ -45,14 +45,14 @@ // #pragma once -#include +#include #include "MvRequest.h" #include "ObjectInfo.h" #include "Types.hpp" #include "Visitor.h" -typedef std::map MacroVisDefMap; +using MacroVisDefMap = std::map; class MacroVisitor : public Visitor { @@ -61,15 +61,15 @@ MacroVisitor(std::string&, const MvRequest&); // -- Destructor - ~MacroVisitor(); + ~MacroVisitor() override; // -- Creates a new fileName static std::string CreateFileName(const MvRequest&); // -- Visitor methods - virtual void Visit(SuperPage&); - virtual void Visit(Page&); - virtual void Visit(SubPage&); + void Visit(SuperPage&) override; + void Visit(Page&) override; + void Visit(SubPage&) override; private: void WriteProlog(); diff -Nru metview-5.17.4/metview/src/uPlot/MagicsGraphicsEngine.cc metview-5.19.2/metview/src/uPlot/MagicsGraphicsEngine.cc --- metview-5.17.4/metview/src/uPlot/MagicsGraphicsEngine.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MagicsGraphicsEngine.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,7 @@ ***************************** LICENSE END *************************************/ -#include +#include #include #include @@ -26,7 +26,7 @@ // class MagicsGEFactory class MagicsGEFactory : public GraphicsEngineFactory { - virtual GraphicsEngine* Build(Presentable& owner) + GraphicsEngine* Build(Presentable& owner) override { return new MagicsGraphicsEngine(owner); } @@ -79,7 +79,7 @@ } #endif -//U BEGIN +// U BEGIN Canvas* MagicsGraphicsEngine::MakeCanvas(Device& device, const Rectangle& rect, @@ -87,11 +87,11 @@ int subpageId) const { auto* xc = new Canvas(device, rect, size, subpageId); - ensure(xc != 0); + ensure(xc != nullptr); return xc; } -//U END +// U END // // Draw @@ -120,7 +120,7 @@ { // Draw the dataunit MvListCursor vdCursor; - vdCursor = visdefList.begin(); + vdCursor = visdefList.begin(); MvIcon& visdef = *(vdCursor); this->DrawDataUnit(dataUnit, dataInfoRequest, visdef); @@ -159,16 +159,16 @@ // Get visdefs related to each dimension MvIconList vdList; const char* verb = dataUnitReq.getVerb(); - bool vdDefault = false; + bool vdDefault = false; for (auto& i : vstr) { - MvIconList laux = visdefList; + MvIconList laux = visdefList; const char* caux = i.c_str(); // No valid visdef found in the list. Create a default visdef. if (!ObjectList::CheckValidVisDefList(verb, laux, caux)) { // Get the first default nD-visdef std::string lvd = (const char*)ObjectList::Find("dataunit", verb, caux); - size_t pos = lvd.find('/'); + size_t pos = lvd.find('/'); if (pos != std::string::npos) lvd = lvd.substr(0, pos); @@ -207,8 +207,8 @@ { // Translate METVIEW calls into MAGICS calls // Find a metview to magics translator and execute it - MvRequest vdRequest = visDef.Request(); - MvRequest duReq = dataUnit.Request(); + MvRequest vdRequest = visDef.Request(); + MvRequest duReq = dataUnit.Request(); MagicsTranslator& mt = MagicsTranslator::Find(duReq.getVerb()); MvRequest magicsDataRequest = mt.Execute(duReq, dataInfoRequest, vdRequest); @@ -227,19 +227,19 @@ // Magics is updated. // MvIcon temp = MvIcon(true); // viewRequest("_ID") = temp.Id(); - viewRequest("_ID") = owner_.Id(); + viewRequest("_ID") = owner_.Id(); viewRequest("_PRESENTABLE_ID") = owner_.Id(); // Call the magics translator to translate METVIEW calls // into MAGICS calls - MagicsTranslator& mt = MagicsTranslator::Find("PAGE"); + MagicsTranslator& mt = MagicsTranslator::Find("PAGE"); MvRequest pageRequest = mt.Execute(viewRequest); // Set Background colour if (strcmp(drawType_.c_str(), "BACKGROUND") == 0 || strcmp(drawType_.c_str(), "DATA") == 0) { const char* colour = viewRequest("SUBPAGE_BACKGROUND_COLOUR"); - if (colour != 0) + if (colour != nullptr) pageRequest("SUBPAGE_BACKGROUND_COLOUR") = colour; } @@ -253,7 +253,7 @@ int zoomNumberOfLevels = 0, zoomCurrentLevel = 0; owner_.ZoomInfo(zoomNumberOfLevels, zoomCurrentLevel); pageRequest("ZOOM_NUMBER_OF_LEVELS") = zoomNumberOfLevels; - pageRequest("ZOOM_CURRENT_LEVEL") = zoomCurrentLevel; + pageRequest("ZOOM_CURRENT_LEVEL") = zoomCurrentLevel; // Draw the new page pageRequest.rewind(); @@ -422,13 +422,13 @@ void MagicsGraphicsEngine::DrawPageHeader(Canvas& canvas) { MvRequest newRequest("MAGICS_ENGINE"); - newRequest("SUBPAGE_ID") = canvas.PresentableId(); + newRequest("SUBPAGE_ID") = canvas.PresentableId(); newRequest("SUPERPAGE_INDEX") = owner_.Parent()->PaperPageIndex(); - newRequest("TYPE") = "PAGEHEADER"; + newRequest("TYPE") = "PAGEHEADER"; MvRequest printerRequest = canvas.PrinterRequest(); - newRequest("PRINTER") = printerRequest; - serviceRequest_ = newRequest; + newRequest("PRINTER") = printerRequest; + serviceRequest_ = newRequest; this->EndPicture(); } @@ -440,7 +440,7 @@ // Call MAGICS to process the request MagPlusService::Instance().SetRequest ( fullRequest_ ); -#if 0 //D +#if 0 // D MvRequest newRequest ( "MAGICS_ENGINE" ); newRequest ("SUBPAGE_ID") = canvas.PresentableId (); @@ -464,11 +464,11 @@ double MagicsGraphicsEngine::ComputeAspectRatio(Canvas& canvas, MvRequest& req) { - double spwidth, spheight; + double spwidth = 0., spheight = 0.; // Retrieve canvas size - double ar = 1.; - double cwidth = canvas.GetWidth(); + double ar = 1.; + double cwidth = canvas.GetWidth(); double cheight = canvas.GetHeight(); if (cwidth == 0. || cheight == 0.) return ar; @@ -479,11 +479,11 @@ Presentable* pr = Root::Instance().FindBranch(canvas.PresentableId()); if (pr) { Presentable* sp = pr->FindSuperPage(); - spwidth = sp->Request()("CUSTOM_WIDTH"); - spheight = sp->Request()("CUSTOM_HEIGHT"); + spwidth = sp->Request()("CUSTOM_WIDTH"); + spheight = sp->Request()("CUSTOM_HEIGHT"); } else { - spwidth = req("_WIDTH"); + spwidth = req("_WIDTH"); spheight = req("_HEIGHT"); } if (spwidth == 0. || spheight == 0.) @@ -502,7 +502,7 @@ // For each icon, find a metview to magics translator and execute it MvListCursor iCursor; for (iCursor = iList.begin(); iCursor != iList.end(); ++iCursor) { - MvRequest idef = (*(iCursor)).Request(); + MvRequest idef = (*(iCursor)).Request(); MagicsTranslator& mt2 = MagicsTranslator::Find(idef.getVerb()); req += mt2.Execute(idef, du); } diff -Nru metview-5.17.4/metview/src/uPlot/MagicsGraphicsEngine.h metview-5.19.2/metview/src/uPlot/MagicsGraphicsEngine.h --- metview-5.17.4/metview/src/uPlot/MagicsGraphicsEngine.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MagicsGraphicsEngine.h 2023-07-15 08:28:47.000000000 +0000 @@ -61,10 +61,10 @@ MagicsGraphicsEngine(Presentable& owner); // Destructor - ~MagicsGraphicsEngine(); + ~MagicsGraphicsEngine() override; // Methods - virtual Canvas* MakeCanvas(Device&, const Rectangle&, const PaperSize&, int) const; + Canvas* MakeCanvas(Device&, const Rectangle&, const PaperSize&, int) const override; // Draws a dataUnit+visDef onto a device // REQUIRE: 1. dataUnit must provide a valid request, which contains @@ -73,7 +73,7 @@ // whithin the dataUnit (where applicable) // 3. List of Visdefs (1D and 2D) // 4. data unit n-dim flag: 0-not defined, 1-1D, 2-2D, 3-1D&2D - virtual void DrawDataVisDef(MvIcon&, MvRequest&, MvIconList&, int = 0); + void DrawDataVisDef(MvIcon&, MvRequest&, MvIconList&, int = 0) override; // Draws a dataUnit onto a device // REQUIRE: 1. dataUnit must provide a valid request, which contains @@ -81,25 +81,25 @@ // 2. dataUnitIndex indicates the location of the field/obs // whithin the dataUnit (where applicable) // 3. Device must have been pre-configured - virtual void DrawDataUnit(MvIcon&, MvRequest&, MvIcon&); + void DrawDataUnit(MvIcon&, MvRequest&, MvIcon&) override; - virtual void DrawNewPage(MvRequest&); - virtual void Draw(const MvRequest&, bool = false); + void DrawNewPage(MvRequest&) override; + void Draw(const MvRequest&, bool = false) override; - virtual void DrawProlog(); - virtual void DrawPageHeader(Canvas&); + void DrawProlog() override; + void DrawPageHeader(Canvas&) override; // virtual void DrawTrailer ( Canvas& ); //CHECK IF THIS IS STILL NEEDED - virtual void DrawTrailer(MvRequest&); + void DrawTrailer(MvRequest&) override; - virtual void StartPicture(const char*); - virtual void EndPicture(); + void StartPicture(const char*) override; + void EndPicture() override; // Translate METVIEW calls into MAGICS calls virtual void TranslateVisDefRequest(MvIconList&, MvRequest&, MvRequest&); private: - MvRequest serviceRequest_; //temporary request - MvRequest fullRequest_; //full request + MvRequest serviceRequest_; // temporary request + MvRequest fullRequest_; // full request std::string drawType_; double ComputeAspectRatio(Canvas& canvas, MvRequest&); diff -Nru metview-5.17.4/metview/src/uPlot/MagicsTranslator.cc metview-5.19.2/metview/src/uPlot/MagicsTranslator.cc --- metview-5.17.4/metview/src/uPlot/MagicsTranslator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MagicsTranslator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,13 +26,13 @@ AxisTranslator axisTranslatorInstance("PAXIS"); BufrTranslator bufrTranslatorInstance("BUFR"); CoastTranslator coast1TranslatorInstance("PCOAST"); -//CoastTranslator coast2TranslatorInstance ( "GEO_COASTLINE" ); -//CoastTranslator coast3TranslatorInstance ( "GEO_LAND_SHADE" ); -//CoastTranslator coast4TranslatorInstance ( "GEO_SEA_SHADE" ); -//CoastTranslator coast5TranslatorInstance ( "GEO_BOUNDARIES" ); -//CoastTranslator coast6TranslatorInstance ( "GEO_CITIES" ); -//CoastTranslator coast7TranslatorInstance ( "GEO_RIVERS" ); -//CoastTranslator coast8TranslatorInstance ( "GEO_GRID" ); +// CoastTranslator coast2TranslatorInstance ( "GEO_COASTLINE" ); +// CoastTranslator coast3TranslatorInstance ( "GEO_LAND_SHADE" ); +// CoastTranslator coast4TranslatorInstance ( "GEO_SEA_SHADE" ); +// CoastTranslator coast5TranslatorInstance ( "GEO_BOUNDARIES" ); +// CoastTranslator coast6TranslatorInstance ( "GEO_CITIES" ); +// CoastTranslator coast7TranslatorInstance ( "GEO_RIVERS" ); +// CoastTranslator coast8TranslatorInstance ( "GEO_GRID" ); ContTranslator contTranslatorInstance("PCONT"); GeopointsTranslator geopTranslatorInstance("GEOPOINTS"); GraphTranslator graphTranslatorInstance("PGRAPH"); @@ -60,7 +60,7 @@ VoidTranslator input5TranslatorInstance("INPUT_GEO_VECTORS"); VoidTranslator input6TranslatorInstance("INPUT_XY_BINNING"); VoidTranslator input7TranslatorInstance("INPUT_GEO_BINNING"); -//VoidTranslator input8TranslatorInstance("INPUT_XY_BOXPLOT"); +// VoidTranslator input8TranslatorInstance("INPUT_XY_BOXPLOT"); VoidTranslator input9TranslatorInstance("INPUT_XY_AREA"); InputBoxplotTranslator inputBoxplotTranslatorInstance("INPUT_XY_BOXPLOT"); VoidTranslator mcoastTranslatorInstance("MCOAST"); @@ -132,11 +132,11 @@ // Set the common parameters of all kind of grib data // Set the input file name and Magics internal parameters - const char* dataPath = dataUnitRequest("PATH"); - magicsRequest("GRIB_INPUT_TYPE") = "FILE"; - magicsRequest("GRIB_INPUT_FILE_NAME") = dataPath; + const char* dataPath = dataUnitRequest("PATH"); + magicsRequest("GRIB_INPUT_TYPE") = "FILE"; + magicsRequest("GRIB_INPUT_FILE_NAME") = dataPath; magicsRequest("GRIB_FILE_ADDRESS_MODE") = "BYTE_OFFSET"; - magicsRequest("GRIB_SPECIFICATION") = "OFF"; + magicsRequest("GRIB_SPECIFICATION") = "OFF"; metview::CopySomeParameters(dataUnitRequest, magicsRequest, "$METVIEW_"); // Set GRIB_* parameters selected by the user. @@ -248,7 +248,7 @@ BufrTranslator::Execute(const MvRequest& dataUnitRequest, const MvRequest& dataInfoRequest, const MvRequest& visdefRequest) { MvRequest magicsRequest; - const char* dataPath; + const char* dataPath = nullptr; // The real path is normally in the dataInfoRequest, // where the name of the generated file for this @@ -259,12 +259,12 @@ dataPath = dataUnitRequest("PATH"); magicsRequest.setVerb("BUFR"); - magicsRequest("OBS_INPUT_TYPE") = "FILE"; - magicsRequest("OBS_INPUT_FORMAT") = "BUFR"; + magicsRequest("OBS_INPUT_TYPE") = "FILE"; + magicsRequest("OBS_INPUT_FORMAT") = "BUFR"; magicsRequest("OBS_INPUT_FILE_NAME") = dataPath; magicsRequest("OBS_INPUT_FILE_UNIT") = 23; - magicsRequest("TEXT_LINE_1") = "Observations"; - magicsRequest("TEXT_LINE_COUNT") = 1; + magicsRequest("TEXT_LINE_1") = "Observations"; + magicsRequest("TEXT_LINE_COUNT") = 1; // Set to this BUFR dataunit request some specific parameters defined // in the associated visdef. This is a Magics requirement. @@ -275,9 +275,9 @@ magicsRequest("OBS_LEVEL_2") = (const char*)visdefRequest("OBS_LEVEL_2"); // Copy hidden parameters - magicsRequest("_NAME") = (const char*)dataUnitRequest("_NAME"); + magicsRequest("_NAME") = (const char*)dataUnitRequest("_NAME"); magicsRequest("_CLASS") = (const char*)dataUnitRequest("_CLASS"); - magicsRequest("_ID") = (const char*)dataUnitRequest("_ID"); + magicsRequest("_ID") = (const char*)dataUnitRequest("_ID"); return magicsRequest; } @@ -299,7 +299,7 @@ CoastTranslator::Execute(const MvRequest& mapviewRequest) { // Replace verb - const char* verb = mapviewRequest.getVerb(); + const char* verb = mapviewRequest.getVerb(); MvRequest magicsRequest = mapviewRequest; magicsRequest.setVerb("MCOAST"); @@ -352,8 +352,8 @@ } else { // Strip out the "GRIB_" and the "INPUT_FIELD_SUPPRESS" parts - metview::CopyAndRemoveParameters(visdefRequest, tmpRequest, "INPUT_FIELD_SUPPRESS"); - metview::CopyAndRemoveParameters(tmpRequest, magicsRequest, "GRIB_"); + metview::CopyAndRemoveParameters(visdefRequest, tmpRequest, "INPUT_FIELD_SUPPRESS"); + metview::CopyAndRemoveParameters(tmpRequest, magicsRequest, "GRIB_"); } // Handle GRID_SHADDING option: this is a Magics requiment. @@ -387,8 +387,8 @@ // Set layout MvRequest metviewRequest = viewRequest; // values needed to be updated internally MvRequest magicsRequest("PAGE"); - double width = metviewRequest("_WIDTH"); - double height = metviewRequest("_HEIGHT"); + double width = metviewRequest("_WIDTH"); + double height = metviewRequest("_HEIGHT"); magicsRequest("PAGE_X_LENGTH") = width; magicsRequest("PAGE_Y_LENGTH") = height; @@ -414,9 +414,9 @@ std::string sjson = (const char*)metviewRequest("_ZOOM_DEFINITION"); MagPlusService::Instance().decode(req, sjson); - magicsRequest("SUBPAGE_LOWER_LEFT_LATITUDE") = req("subpage_lower_left_latitude"); - magicsRequest("SUBPAGE_LOWER_LEFT_LONGITUDE") = req("subpage_lower_left_longitude"); - magicsRequest("SUBPAGE_UPPER_RIGHT_LATITUDE") = req("subpage_upper_right_latitude"); + magicsRequest("SUBPAGE_LOWER_LEFT_LATITUDE") = req("subpage_lower_left_latitude"); + magicsRequest("SUBPAGE_LOWER_LEFT_LONGITUDE") = req("subpage_lower_left_longitude"); + magicsRequest("SUBPAGE_UPPER_RIGHT_LATITUDE") = req("subpage_upper_right_latitude"); magicsRequest("SUBPAGE_UPPER_RIGHT_LONGITUDE") = req("subpage_upper_right_longitude"); magicsRequest("SUBPAGE_MAP_AREA_DEFINITION") = "CORNERS"; @@ -458,7 +458,7 @@ MvRequest req = findPredefArea(str_name); if (req) { - magicsRequest("SUBPAGE_MAP_PROJECTION") = req("subpage_map_projection"); + magicsRequest("SUBPAGE_MAP_PROJECTION") = req("subpage_map_projection"); magicsRequest("SUBPAGE_MAP_AREA_DEFINITION") = "CORNERS"; if (const char* chv = req("subpage_vertical_longitude")) { magicsRequest("SUBPAGE_MAP_VERTICAL_LONGITUDE") = chv; @@ -467,11 +467,11 @@ magicsRequest("SUBPAGE_MAP_HEMISPHERE") = chv; } - //we are not in zoom mode! + // we are not in zoom mode! if (!hasZoom) { - magicsRequest("SUBPAGE_LOWER_LEFT_LATITUDE") = req("subpage_lower_left_latitude"); - magicsRequest("SUBPAGE_LOWER_LEFT_LONGITUDE") = req("subpage_lower_left_longitude"); - magicsRequest("SUBPAGE_UPPER_RIGHT_LATITUDE") = req("subpage_upper_right_latitude"); + magicsRequest("SUBPAGE_LOWER_LEFT_LATITUDE") = req("subpage_lower_left_latitude"); + magicsRequest("SUBPAGE_LOWER_LEFT_LONGITUDE") = req("subpage_lower_left_longitude"); + magicsRequest("SUBPAGE_UPPER_RIGHT_LATITUDE") = req("subpage_upper_right_latitude"); magicsRequest("SUBPAGE_UPPER_RIGHT_LONGITUDE") = req("subpage_upper_right_longitude"); } } @@ -490,7 +490,7 @@ const char* projection = metviewRequest("MAP_PROJECTION"); MvRequest tmpReq; if (!projection) { - tmpReq = ObjectList::ExpandRequest(metviewRequest, EXPAND_DEFAULTS); + tmpReq = ObjectList::ExpandRequest(metviewRequest, EXPAND_DEFAULTS); projection = tmpReq("MAP_PROJECTION"); } if (projection) { @@ -509,9 +509,9 @@ // Translate AREA parameter const char* area = metviewRequest("AREA"); if (area) { - magicsRequest("SUBPAGE_LOWER_LEFT_LATITUDE") = (double)metviewRequest("AREA", 0); - magicsRequest("SUBPAGE_LOWER_LEFT_LONGITUDE") = (double)metviewRequest("AREA", 1); - magicsRequest("SUBPAGE_UPPER_RIGHT_LATITUDE") = (double)metviewRequest("AREA", 2); + magicsRequest("SUBPAGE_LOWER_LEFT_LATITUDE") = (double)metviewRequest("AREA", 0); + magicsRequest("SUBPAGE_LOWER_LEFT_LONGITUDE") = (double)metviewRequest("AREA", 1); + magicsRequest("SUBPAGE_UPPER_RIGHT_LATITUDE") = (double)metviewRequest("AREA", 2); magicsRequest("SUBPAGE_UPPER_RIGHT_LONGITUDE") = (double)metviewRequest("AREA", 3); } @@ -567,7 +567,7 @@ } } while (r.advance()); - return MvRequest(); + return {}; } @@ -585,11 +585,11 @@ // will use the Metview default values, these coordinates need to be added to the // request. if ((const char*)magicsRequest("TEXT_MODE") && strcmp((const char*)magicsRequest("TEXT_MODE"), "POSITIONAL") == 0) { - MvRequest expRequest = ObjectList::ExpandRequest(magicsRequest, EXPAND_DEFAULTS); + MvRequest expRequest = ObjectList::ExpandRequest(magicsRequest, EXPAND_DEFAULTS); magicsRequest("TEXT_BOX_X_POSITION") = expRequest("TEXT_BOX_X_POSITION"); magicsRequest("TEXT_BOX_Y_POSITION") = expRequest("TEXT_BOX_Y_POSITION"); - magicsRequest("TEXT_BOX_X_LENGTH") = expRequest("TEXT_BOX_X_LENGTH"); - magicsRequest("TEXT_BOX_Y_LENGTH") = expRequest("TEXT_BOX_Y_LENGTH"); + magicsRequest("TEXT_BOX_X_LENGTH") = expRequest("TEXT_BOX_X_LENGTH"); + magicsRequest("TEXT_BOX_Y_LENGTH") = expRequest("TEXT_BOX_Y_LENGTH"); } return magicsRequest; @@ -649,15 +649,15 @@ // Create Magics request from the input requests MvRequest magicsRequest("PGRIB"); - magicsRequest("GRIB_INPUT_TYPE") = "FILE"; - magicsRequest("GRIB_INPUT_FILE_NAME") = (const char*)gribReq("PATH"); + magicsRequest("GRIB_INPUT_TYPE") = "FILE"; + magicsRequest("GRIB_INPUT_FILE_NAME") = (const char*)gribReq("PATH"); magicsRequest("GRIB_FILE_ADDRESS_MODE") = "BYTE_OFFSET"; - magicsRequest("GRIB_WIND_MODE") = (const char*)dataUnitRequest("GRIB_WIND_MODE"); + magicsRequest("GRIB_WIND_MODE") = (const char*)dataUnitRequest("GRIB_WIND_MODE"); // Get grib dimension list int cnt = dataUnitRequest.iterInit("GRIB_DIMENSION"); - const char* str; - int i; + const char* str = nullptr; + int i = 0; for (i = 0; i < cnt; ++i) { dataUnitRequest.iterGetNextValue(str); magicsRequest.addValue("GRIB_DIMENSION", str); @@ -743,7 +743,7 @@ // Copy request MvRequest magicsRequest("PSYMB"); - metview::CopyAndRemoveParameters(visdefRequest, magicsRequest, "LEGEND_ENTRY"); + metview::CopyAndRemoveParameters(visdefRequest, magicsRequest, "LEGEND_ENTRY"); // Check LEGEND_ENTRY subrequest MvRequest legRequest = visdefRequest.getSubrequest("LEGEND_ENTRY"); @@ -760,9 +760,9 @@ MvRequest record = dataUnitRequest.getSubrequest("RECORD"); - const char* symbType = psymb("SYMBOL_TYPE"); + const char* symbType = psymb("SYMBOL_TYPE"); const char* tableMode = psymb("SYMBOL_TABLE_MODE"); - std::string type = "NUMBER"; + std::string type = "NUMBER"; // If SYMBOL_TYPE is set, use the value. If SYMBOL_TABLE_MODE is also // set, type needs to be number, whatever SYMBOL_TYPE is set to. @@ -777,9 +777,9 @@ geo.setValue("RECORD", record); // Copy hidden parameters - geo("_NAME") = (const char*)dataUnitRequest("_NAME"); + geo("_NAME") = (const char*)dataUnitRequest("_NAME"); geo("_CLASS") = (const char*)dataUnitRequest("_CLASS"); - geo("_ID") = (const char*)dataUnitRequest("_ID"); + geo("_ID") = (const char*)dataUnitRequest("_ID"); return geo; } @@ -849,7 +849,7 @@ return req; // Data file not provided - return MvRequest("EMPTY"); + return {"EMPTY"}; } ///////////////// Utility function, not normal translator @@ -862,8 +862,8 @@ if (!expanded) tmpRequest = ObjectList::ExpandRequest(tmpRequest, EXPAND_DEFAULTS); - magicsRequest("SUBPAGE_X_LENGTH") = width * ((double)tmpRequest("SUBPAGE_X_LENGTH") / 100); - magicsRequest("SUBPAGE_Y_LENGTH") = height * ((double)tmpRequest("SUBPAGE_Y_LENGTH") / 100); + magicsRequest("SUBPAGE_X_LENGTH") = width * ((double)tmpRequest("SUBPAGE_X_LENGTH") / 100); + magicsRequest("SUBPAGE_Y_LENGTH") = height * ((double)tmpRequest("SUBPAGE_Y_LENGTH") / 100); magicsRequest("SUBPAGE_X_POSITION") = width * ((double)tmpRequest("SUBPAGE_X_POSITION") / 100); magicsRequest("SUBPAGE_Y_POSITION") = height * ((double)tmpRequest("SUBPAGE_Y_POSITION") / 100); @@ -920,7 +920,7 @@ } else { MvLog().popup().warn() << "uPlot ThermoTranslator::Execute-> NETCDF_X_VARIABLE not implemented: " << svar; - return MvRequest("EMPTY"); + return {"EMPTY"}; } return magicsRequest; @@ -931,7 +931,7 @@ { assert(strcmp(req.getVerb(), "MTHERMOGRID") == 0); MvRequest magicsRequest = req; - const char* ch = magicsRequest("THERMO_GRID_LAYER_MODE"); + const char* ch = magicsRequest("THERMO_GRID_LAYER_MODE"); if (ch) { magicsRequest.unsetParam("THERMO_GRID_LAYER_MODE"); } @@ -943,18 +943,17 @@ MvRequest magReq("INPUT_BOXPLOT"); std::cout << "BOXPLOT TRANSLATOR" << std::endl; - static std::map params= { + static std::map params = { {"INPUT_X_VALUES", "BOXPLOT_POSITIONS"}, {"INPUT_DATE_X_VALUES", "BOXPLOT_DATE_POSITIONS"}, - {"INPUT_MINIMUM_VALUES","BOXPLOT_MINIMUM_VALUES"}, - {"INPUT_MAXIMUM_VALUES","BOXPLOT_MAXIMUM_VALUES"}, - {"INPUT_MEDIAN_VALUES","BOXPLOT_MEDIAN_VALUES"}, - {"INPUT_BOX_UPPER_VALUES","BOXPLOT_BOX_UPPER_VALUES"}, - {"INPUT_BOX_LOWER_VALUES","BOXPLOT_BOX_LOWER_VALUES"} - }; + {"INPUT_MINIMUM_VALUES", "BOXPLOT_MINIMUM_VALUES"}, + {"INPUT_MAXIMUM_VALUES", "BOXPLOT_MAXIMUM_VALUES"}, + {"INPUT_MEDIAN_VALUES", "BOXPLOT_MEDIAN_VALUES"}, + {"INPUT_BOX_UPPER_VALUES", "BOXPLOT_BOX_UPPER_VALUES"}, + {"INPUT_BOX_LOWER_VALUES", "BOXPLOT_BOX_LOWER_VALUES"}}; - for (auto it: params) { - metview::copyParam(inReq, magReq,it.first,it. second); + for (const auto& it : params) { + metview::copyParam(inReq, magReq, it.first, it.second); } return magReq; } diff -Nru metview-5.17.4/metview/src/uPlot/MagicsTranslator.h metview-5.19.2/metview/src/uPlot/MagicsTranslator.h --- metview-5.17.4/metview/src/uPlot/MagicsTranslator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MagicsTranslator.h 2023-07-15 08:28:47.000000000 +0000 @@ -46,7 +46,7 @@ struct MagicsTranslatorTraits { - typedef MagicsTranslator Type; + using Type = MagicsTranslator; static Type& DefaultObject(); }; @@ -58,11 +58,11 @@ Prototype(actionName, this) {} // Destructor - virtual ~MagicsTranslator(); + ~MagicsTranslator() override; // Translator functions - virtual MvRequest Execute(const MvRequest&) = 0; - virtual MvRequest Execute(const MvRequest&, const MvRequest&) = 0; + virtual MvRequest Execute(const MvRequest&) = 0; + virtual MvRequest Execute(const MvRequest&, const MvRequest&) = 0; virtual MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) = 0; }; @@ -74,17 +74,17 @@ MagicsTranslator(actionName) {} // Destructor - ~GribTranslator() {} + ~GribTranslator() override = default; - virtual MvRequest Execute(const MvRequest&) + MvRequest Execute(const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest&, const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&); + MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override; static MagicsTranslator& Instance(); // for the default object }; @@ -97,17 +97,17 @@ MagicsTranslator(actionName) {} // Destructor - ~BufrTranslator() {} + ~BufrTranslator() override = default; - virtual MvRequest Execute(const MvRequest&) + MvRequest Execute(const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest&, const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&); + MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override; }; class ObsTranslator : public MagicsTranslator @@ -118,14 +118,14 @@ MagicsTranslator(actionName) {} // Destructor - ~ObsTranslator() {} + ~ObsTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -139,14 +139,14 @@ MagicsTranslator(actionName) {} // Destructor - ~CoastTranslator() {} + ~CoastTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -160,14 +160,14 @@ MagicsTranslator(actionName) {} // Destructor - ~ContTranslator() {} + ~ContTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -181,14 +181,14 @@ MagicsTranslator(actionName) {} // Destructor - ~MContTranslator() {} + ~MContTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -202,14 +202,14 @@ MagicsTranslator(actionName) {} // Destructor - ~TextTranslator() {} + ~TextTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -223,10 +223,10 @@ MagicsTranslator(actionName) {} // Destructor - ~AxisTranslator() {} + ~AxisTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } @@ -244,14 +244,14 @@ MagicsTranslator(actionName) {} // -- Destructor - ~GraphTranslator() {} + ~GraphTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -265,14 +265,14 @@ MagicsTranslator(actionName) {} // Destructor - ~PageTranslator() {} + ~PageTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -292,17 +292,17 @@ MagicsTranslator(actionName) {} // -- Destructor - ~GribVectorsTranslator() {} + ~GribVectorsTranslator() override = default; - virtual MvRequest Execute(const MvRequest&) + MvRequest Execute(const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest&, const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&); + MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override; }; class WindTranslator : public MagicsTranslator @@ -313,14 +313,14 @@ MagicsTranslator(actionName) {} // Destructor - ~WindTranslator() {} + ~WindTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -334,14 +334,14 @@ MagicsTranslator(actionName) {} // Destructor - ~MWindTranslator() {} + ~MWindTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -355,17 +355,17 @@ MagicsTranslator(actionName) {} // Destructor - ~NetCDFTranslator() {} + ~NetCDFTranslator() override = default; - virtual MvRequest Execute(const MvRequest&) + MvRequest Execute(const MvRequest&) override { return MvRequest("EMPTY"); } - virtual MvRequest Execute(const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest&, const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&); + MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override; }; class VoidTranslator : public MagicsTranslator @@ -376,11 +376,11 @@ MagicsTranslator(actionName) {} // Destructor - ~VoidTranslator() {} + ~VoidTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest&, const MvRequest&); - virtual MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&); + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest&, const MvRequest&) override; + MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override; }; class VisDefTranslator : public MagicsTranslator @@ -391,14 +391,14 @@ MagicsTranslator(actionName) {} // Destructor - ~VisDefTranslator() {} + ~VisDefTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -412,17 +412,17 @@ MagicsTranslator(actionName) {} // Destructor - ~GeopointsTranslator() {} + ~GeopointsTranslator() override = default; - virtual MvRequest Execute(const MvRequest&) + MvRequest Execute(const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest&, const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&); + MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override; }; class SymbolTranslator : public MagicsTranslator @@ -433,14 +433,14 @@ MagicsTranslator(actionName) {} // Destructor - ~SymbolTranslator() {} + ~SymbolTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -454,14 +454,14 @@ MagicsTranslator(actionName) {} // Destructor - ~ImportTranslator() {} + ~ImportTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } @@ -475,16 +475,16 @@ MagicsTranslator(actionName) {} // Destructor - ~ThermoTranslator() {} + ~ThermoTranslator() override = default; - virtual MvRequest Execute(const MvRequest&, const MvRequest&); - virtual MvRequest Execute(const MvRequest&) + MvRequest Execute(const MvRequest&, const MvRequest&) override; + MvRequest Execute(const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } - virtual MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override { - return MvRequest("EMPTY"); + return {"EMPTY"}; } }; @@ -494,21 +494,21 @@ ThermoGridTranslator(const char* actionName) : MagicsTranslator(actionName) {} - ~ThermoGridTranslator() {} + ~ThermoGridTranslator() override = default; - MvRequest Execute(const MvRequest&, const MvRequest&) override { return MvRequest("EMPTY"); } + MvRequest Execute(const MvRequest&, const MvRequest&) override { return {"EMPTY"}; } MvRequest Execute(const MvRequest&) override; - MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override { return MvRequest("EMPTY"); } + MvRequest Execute(const MvRequest&, const MvRequest&, const MvRequest&) override { return {"EMPTY"}; } }; class InputBoxplotTranslator : public MagicsTranslator { public: using MagicsTranslator::MagicsTranslator; - ~InputBoxplotTranslator() = default; + ~InputBoxplotTranslator() override = default; MvRequest Execute(const MvRequest&) override; - MvRequest Execute(const MvRequest& req, const MvRequest&) override {return Execute(req);} + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return Execute(req); } MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return Execute(req); @@ -524,14 +524,14 @@ MagicsTranslator(actionName) {} // Destructor - ~TableTranslator() {} + ~TableTranslator() override = default; - virtual MvRequest Execute(const MvRequest&); - virtual MvRequest Execute(const MvRequest& req, const MvRequest&) + MvRequest Execute(const MvRequest&) override; + MvRequest Execute(const MvRequest& req, const MvRequest&) override { return this->Execute(req); } - virtual MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) + MvRequest Execute(const MvRequest& req, const MvRequest&, const MvRequest&) override { return this->Execute(req); } diff -Nru metview-5.17.4/metview/src/uPlot/MagPlusBatchService.h metview-5.19.2/metview/src/uPlot/MagPlusBatchService.h --- metview-5.17.4/metview/src/uPlot/MagPlusBatchService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MagPlusBatchService.h 2023-07-15 08:28:47.000000000 +0000 @@ -49,8 +49,8 @@ class MagPlusBatchService : public MagPlusService { public: - MagPlusBatchService() {} - ~MagPlusBatchService() {} + MagPlusBatchService() = default; + ~MagPlusBatchService() override = default; - void CallMagPlus(MvRequest&); + void CallMagPlus(MvRequest&) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/MagPlusInteractiveService.h metview-5.19.2/metview/src/uPlot/MagPlusInteractiveService.h --- metview-5.17.4/metview/src/uPlot/MagPlusInteractiveService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MagPlusInteractiveService.h 2023-07-15 08:28:47.000000000 +0000 @@ -53,9 +53,9 @@ public: MagPlusInteractiveService() : plotApplication_(0) {} - ~MagPlusInteractiveService() = default; + ~MagPlusInteractiveService() override = default; - void CallMagPlus(MvRequest&); + void CallMagPlus(MvRequest&) override; void setPlotApplication(uPlotBase* pa) { plotApplication_ = pa; } private: diff -Nru metview-5.17.4/metview/src/uPlot/MagPlusService.cc metview-5.19.2/metview/src/uPlot/MagPlusService.cc --- metview-5.17.4/metview/src/uPlot/MagPlusService.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MagPlusService.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,7 @@ ***************************** LICENSE END *************************************/ -#include +#include #include "MagPlusService.h" #include "PlotMod.h" @@ -45,7 +45,7 @@ { // Build request to be sent to ToolsPlus application MvRequest magReq = "MAGPLUS"; - magReq = magReq + req; + magReq = magReq + req; try { this->CallMagPlus(magReq); diff -Nru metview-5.17.4/metview/src/uPlot/MagPlusService.h metview-5.19.2/metview/src/uPlot/MagPlusService.h --- metview-5.17.4/metview/src/uPlot/MagPlusService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MagPlusService.h 2023-07-15 08:28:47.000000000 +0000 @@ -60,35 +60,35 @@ name_(name), index_(index), count_(-1) {} - virtual ~MvMagParam() {} + virtual ~MvMagParam() = default; - virtual operator double() const { return (double)request_(name_.c_str(), index_); } - operator string() const + operator double() const override { return (double)request_(name_.c_str(), index_); } + operator string() const override { const char* val = request_(name_.c_str(), index_); return (val) ? std::string(val) : std::string(""); } - operator int() const { return (int)request_(name_.c_str(), index_); } - operator long int() const { return (long int)request_(name_.c_str(), index_); } - MagParam& operator=(int i) + operator int() const override { return (int)request_(name_.c_str(), index_); } + operator long int() const override { return (long int)request_(name_.c_str(), index_); } + MagParam& operator=(int i) override { request_(name_.c_str(), index_) = i; count(-1); return *this; } - MagParam& operator=(long int i) + MagParam& operator=(long int i) override { request_(name_.c_str(), index_) = i; count(-1); return *this; } - MagParam& operator=(string s) + MagParam& operator=(string s) override { request_(name_.c_str(), index_) = s.c_str(); count(-1); return *this; } - MagParam& operator=(double d) + MagParam& operator=(double d) override { request_(name_.c_str(), index_) = d; count(-1); @@ -116,26 +116,26 @@ MvVectorMagParam(MvRequest& req, const std::string& name, int index = 0) : MvMagParam(req, name, index) { - values_ = nullptr; + values_ = nullptr; request* r = req; - len_ = 0; + len_ = 0; if (read_vector_from_request(r, &values_, &len_) != MV_VECTOR_READ_OK) { // error reading the vector file (could be that it's temporary and has been deleted) len_ = 0; } } - virtual ~MvVectorMagParam() + ~MvVectorMagParam() override { if (values_) free(values_); values_ = nullptr; - len_ = 0; + len_ = 0; } int count() { return len_; } - operator double() const { return values_[index_]; } + operator double() const override { return values_[index_]; } protected: double* values_; @@ -148,7 +148,7 @@ public: MvMagRequest(const MvRequest& request) : request_(request) {} - ~MvMagRequest() { freeParams(); } + ~MvMagRequest() override { freeParams(); } void freeParams() { @@ -164,7 +164,7 @@ auto param = parameters_.find(name); if (param == parameters_.end()) { bool addedVectorParam = false; - int count = request_.countValues(name.c_str()); + int count = request_.countValues(name.c_str()); // check if this is a vector of values - if so, we will // instantiate an MvVectorMagParam instead of an MvMagParam // in theory, we should be able to check whether there is a single value "#" @@ -172,10 +172,10 @@ // and visualise a Macro from the Desktop MvRequest subreq = request_(name.c_str(), 0); if (!subreq.isEmpty() && std::string(subreq.getVerb()) == "VECTOR") { - MvVectorMagParam* vecParam = new MvVectorMagParam(subreq, name); + auto* vecParam = new MvVectorMagParam(subreq, name); parameters_.insert(make_pair(name, vecParam)); addedVectorParam = true; - count = vecParam->count(); + count = vecParam->count(); } if (!addedVectorParam) parameters_.insert(make_pair(name, new MvMagParam(request_, name))); @@ -185,30 +185,30 @@ return param->second; } - MagParam& operator()(const std::string& name) const + MagParam& operator()(const std::string& name) const override { MvMagParam* param = ensureParamAdded(name); return *(param); } - void advance() + void advance() override { request_.advance(); } - std::string getVerb() const { return request_.getVerb(); } + std::string getVerb() const override { return request_.getVerb(); } - MagParam& operator()(const std::string& name, int i) const + MagParam& operator()(const std::string& name, int i) const override { MvMagParam* param = ensureParamAdded(name); param->index(i); return *(param); } - int countValues(const std::string& name) const + int countValues(const std::string& name) const override { MvMagParam* param = ensureParamAdded(name); - int count = param->count(); + int count = param->count(); if (count == -1) { count = request_.countValues(name.c_str()); param->count(count); @@ -216,20 +216,20 @@ return count; } - MagRequest& getSubRequest(const std::string& name) + MagRequest& getSubRequest(const std::string& name) override { return *(new MvMagRequest(request_.getSubrequest(name.c_str()))); } - operator bool() const { return request_; } + operator bool() const override { return request_; } - int countParameters() { return request_.countParameters(); } - int countValues(const std::string& name) { return request_.countValues(name.c_str()); } - std::string getParameter(int i) { return request_.getParameter(i); } - void print() { return request_.print(); } - void read(const std::string& file) { request_.read(file.c_str()); } + int countParameters() override { return request_.countParameters(); } + int countValues(const std::string& name) override { return request_.countValues(name.c_str()); } + std::string getParameter(int i) override { return request_.getParameter(i); } + void print() override { return request_.print(); } + void read(const std::string& file) override { request_.read(file.c_str()); } - MagRequest& justOneRequest() + MagRequest& justOneRequest() override { MvRequest sub = request_.justOneRequest(); return *(new MvMagRequest(sub)); @@ -241,7 +241,7 @@ mutable MvRequest request_; mutable std::map parameters_; }; -//public magics::MagicsObserver { +// public magics::MagicsObserver { class MagPlusService : public MvClient { public: @@ -251,11 +251,11 @@ static void Instance(MagPlusService*); // Destructor - ~MagPlusService() {} + ~MagPlusService() override = default; // Methods // Perform actions after receiving response from Magics - virtual void endOfTask(MvTask*); + void endOfTask(MvTask*) override; // virtual void endOfTask ( MvTask* ){} // Call MagPlus application to redraw the map on a specified device(s) diff -Nru metview-5.17.4/metview/src/uPlot/MapView.cc metview-5.19.2/metview/src/uPlot/MapView.cc --- metview-5.17.4/metview/src/uPlot/MapView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MapView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,9 +31,9 @@ class MapViewFactory : public PlotModViewFactory { // Virtual Constructor - Builds a new MapView - virtual PlotModView* Build(Page& page, - const MvRequest& contextRequest, - const MvRequest& setupRequest) + PlotModView* Build(Page& page, + const MvRequest& contextRequest, + const MvRequest& setupRequest) override { return new MapView(page, contextRequest, setupRequest); } @@ -62,12 +62,6 @@ #endif } -MapView::MapView(const MapView& old) : - PlotModView(old), - PlotModService(old) -{ -} - string MapView::Name() { @@ -106,7 +100,7 @@ } MvRequest request = dropRequest.justOneRequest(); - Cached verb = request.getVerb(); + Cached verb = request.getVerb(); if (ObjectList::IsDataUnit(verb) == true) { MvIcon dataUnit = dataBase.InsertDataUnit(request, Owner().Id()); duList.push_back(dataUnit); @@ -135,7 +129,7 @@ // Avoid this drop to be send to visualization // The result of the service call is the one that will // be send to the visualization procedure later - //Owner().NeedsRedrawing(false); + // Owner().NeedsRedrawing(false); } else if ((const char*)verb == PLOTSUPERPAGE) { context.AdvanceTo(PLOTSUPERPAGE); @@ -200,7 +194,7 @@ { ensure(dataUnit.Id() > 0); - int subpageId; + int subpageId = 0; MvIconDataBase& dataBase = Owner().IconDataBase(); // Build a new data decoder, which will provide information @@ -215,9 +209,9 @@ // retrieve the data offset and matching info // Pass this information to the page for matching // int dimFlag = 0; //FAMI20170210 maybe there is not need for this flag - bool swap; + bool swap = false; while (decoder->ReadNextData()) { - long offset = decoder->CurrentOffset(); + long offset = decoder->CurrentOffset(); long nextDataOffset = offset; MatchingInfo dataInfo = decoder->CreateMatchingInfo(); @@ -225,7 +219,7 @@ MvRequest iconRequest = dataInfo.Request(); if (metview::IsParameterSet(iconRequest, "MY_COMPANION")) { if (decoder->ReadNextData()) { - nextDataOffset = decoder->CurrentOffset(); + nextDataOffset = decoder->CurrentOffset(); MatchingInfo nextDataInfo = decoder->CreateMatchingInfo(); // Are they companions ? @@ -244,7 +238,7 @@ // Insert dataunit using the correct order of the offsets // (i.e. u/v not v/u). This is a Magics requirement. // dimFlag = dimFlag | 2; - bool flag; + bool flag = false; if (swap) flag = Owner().InsertDataUnit(dataUnit.Id(), nextDataOffset, offset, dataInfo, subpageId); else @@ -270,10 +264,10 @@ MvRequest decRequest = decoder->Request(); - //F TEMPORARY SOLUTION FOR VISUALISATION OF SATELLITE - //F IMAGES PRODUCED AT INPE (use Cylindrical projection) - //F if ( (int)decRequest ("_ORIGCENTRE") == 46 ) continue; - //F else { + // F TEMPORARY SOLUTION FOR VISUALISATION OF SATELLITE + // F IMAGES PRODUCED AT INPE (use Cylindrical projection) + // F if ( (int)decRequest ("_ORIGCENTRE") == 46 ) continue; + // F else { const char* repres = decRequest("REPRES"); if (ObjectList::IsImage(repres)) { @@ -293,7 +287,7 @@ } } } - //F } + // F } empty = false; } @@ -316,16 +310,16 @@ MvRequest newViewReq = ObjectList::CreateDefaultRequest("SATELLITEVIEW"); newViewReq("SUBPAGE_MAP_SUB_SAT_LONGITUDE") = decRequest("_IMAGE_MAP_SUB_SAT_LONGITUDE"); - newViewReq("INPUT_IMAGE_COLUMNS") = decRequest("_IMAGE_MAP_COLUMNS"); - newViewReq("INPUT_IMAGE_ROWS") = decRequest("_IMAGE_MAP_ROWS"); - newViewReq("SUBPAGE_MAP_INITIAL_COLUMN") = decRequest("_IMAGE_MAP_INITIAL_COLUMN"); - newViewReq("SUBPAGE_MAP_INITIAL_ROW") = decRequest("_IMAGE_MAP_INITIAL_ROW"); - newViewReq("SUBPAGE_MAP_SUB_SAT_X") = decRequest("_IMAGE_MAP_SUB_SAT_X"); - newViewReq("SUBPAGE_MAP_SUB_SAT_Y") = decRequest("_IMAGE_MAP_SUB_SAT_Y"); - newViewReq("SUBPAGE_MAP_X_EARTH_DIAMETER") = decRequest("_IMAGE_MAP_X_EARTH_DIAMETER"); - newViewReq("SUBPAGE_MAP_Y_EARTH_DIAMETER") = decRequest("_IMAGE_MAP_Y_EARTH_DIAMETER"); - newViewReq("SUBPAGE_MAP_GRID_ORIENTATION") = decRequest("_IMAGE_MAP_GRID_ORIENTATION"); - newViewReq("SUBPAGE_MAP_CAMERA_ALTITUDE") = decRequest("_IMAGE_MAP_CAMERA_ALTITUDE"); + newViewReq("INPUT_IMAGE_COLUMNS") = decRequest("_IMAGE_MAP_COLUMNS"); + newViewReq("INPUT_IMAGE_ROWS") = decRequest("_IMAGE_MAP_ROWS"); + newViewReq("SUBPAGE_MAP_INITIAL_COLUMN") = decRequest("_IMAGE_MAP_INITIAL_COLUMN"); + newViewReq("SUBPAGE_MAP_INITIAL_ROW") = decRequest("_IMAGE_MAP_INITIAL_ROW"); + newViewReq("SUBPAGE_MAP_SUB_SAT_X") = decRequest("_IMAGE_MAP_SUB_SAT_X"); + newViewReq("SUBPAGE_MAP_SUB_SAT_Y") = decRequest("_IMAGE_MAP_SUB_SAT_Y"); + newViewReq("SUBPAGE_MAP_X_EARTH_DIAMETER") = decRequest("_IMAGE_MAP_X_EARTH_DIAMETER"); + newViewReq("SUBPAGE_MAP_Y_EARTH_DIAMETER") = decRequest("_IMAGE_MAP_Y_EARTH_DIAMETER"); + newViewReq("SUBPAGE_MAP_GRID_ORIENTATION") = decRequest("_IMAGE_MAP_GRID_ORIENTATION"); + newViewReq("SUBPAGE_MAP_CAMERA_ALTITUDE") = decRequest("_IMAGE_MAP_CAMERA_ALTITUDE"); this->UpdateViewWithReq(newViewReq); } @@ -337,7 +331,7 @@ // Ensure coastlines exist MvRequest coastRequest = viewReq.getSubrequest("COASTLINES"); if (!coastRequest) { - coastRequest = ObjectList::UserDefaultRequest("MCOAST"); + coastRequest = ObjectList::UserDefaultRequest("MCOAST"); viewReq("COASTLINES") = coastRequest; } @@ -400,7 +394,7 @@ GraphicsEngine& ge = Owner().GetGraphicsEngine(); while (backList) { // Draw the layer info - MvRequest req = backList.justOneRequest(); + MvRequest req = backList.justOneRequest(); std::string icon_name = (const char*)req("_NAME") ? mbasename((const char*)req("_NAME")) : ""; Owner().DrawLayerInfo((int)req("_ID"), icon_name.c_str()); @@ -422,7 +416,7 @@ GraphicsEngine& ge = Owner().GetGraphicsEngine(); while (foreList) { // Draw the layer info - MvRequest req = foreList.justOneRequest(); + MvRequest req = foreList.justOneRequest(); std::string icon_name = (const char*)req("_NAME") ? mbasename((const char*)req("_NAME")) : ""; Owner().DrawLayerInfo((int)req("_ID"), icon_name.c_str()); @@ -474,7 +468,7 @@ bool MapView::CallService(const MvRequest& req, PmContext& context) { - MvRequest appRequest = req; + MvRequest appRequest = req; appRequest("_CONTEXT") = viewRequest_; // Find service name @@ -514,10 +508,10 @@ // Retrieve icon from the View bool iconDefault = false; - MvRequest req = viewRequest_.getSubrequest("COASTLINES"); + MvRequest req = viewRequest_.getSubrequest("COASTLINES"); if (!req) { // Create a default Coastlines - req = ObjectList::CreateDefaultRequest(MCOAST); + req = ObjectList::CreateDefaultRequest(MCOAST); iconDefault = true; } @@ -535,7 +529,7 @@ backReq = icon.Request(); // Add icon to the DataBase - int id = (iconDefault) ? Owner().FindSuperPage()->Id() : Owner().Id(); + int id = (iconDefault) ? Owner().FindSuperPage()->Id() : Owner().Id(); MvIconDataBase& dataBase = Owner().IconDataBase(); dataBase.InsertIcon(PRES_VISDEF_REL, id, icon); @@ -568,10 +562,10 @@ // Retrieve icon from the View bool iconDefault = false; - MvRequest req = viewRequest_.getSubrequest("COASTLINES"); + MvRequest req = viewRequest_.getSubrequest("COASTLINES"); if (!req) { // Create a default Coastlines - req = ObjectList::CreateDefaultRequest(MCOAST); + req = ObjectList::CreateDefaultRequest(MCOAST); iconDefault = true; } @@ -588,7 +582,7 @@ foreReq = icon.Request(); // Add icon to the DataBase - int id = iconDefault ? Owner().FindSuperPage()->Id() : Owner().Id(); + int id = iconDefault ? Owner().FindSuperPage()->Id() : Owner().Id(); MvIconDataBase& dataBase = Owner().IconDataBase(); dataBase.InsertIcon(PRES_VISDEF_REL, id, icon); diff -Nru metview-5.17.4/metview/src/uPlot/MapView.h metview-5.19.2/metview/src/uPlot/MapView.h --- metview-5.17.4/metview/src/uPlot/MapView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MapView.h 2023-07-15 08:28:47.000000000 +0000 @@ -49,11 +49,12 @@ public: // Constructors MapView(Page&, const MvRequest&, const MvRequest&); - MapView(const MapView&); + MapView(const MapView&) = default; + MapView& operator=(const MapView&) = delete; PlotModView* Clone() const override { return new MapView(*this); } // Destructor - ~MapView() {} + ~MapView() override = default; // Get the object name std::string Name() override; @@ -100,7 +101,4 @@ // Get background/foreground icons // const char* = "BACKGROUND" or "FOREGROUND" int RetrieveBackForeground(const char*, MvRequest&); - - // No assignment - MapView& operator=(const MapView&); }; diff -Nru metview-5.17.4/metview/src/uPlot/MatchingCriteria.cc metview-5.19.2/metview/src/uPlot/MatchingCriteria.cc --- metview-5.17.4/metview/src/uPlot/MatchingCriteria.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MatchingCriteria.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ overlayReq = ObjectList::CreateDefaultRequest("OVERLAY_CONTROL"); overlayReq = ObjectList::ExpandRequest(overlayReq, EXPAND_DEFAULTS); - int count = overlayReq.countParameters(); + int count = overlayReq.countParameters(); for (int i = 0; i < count; i++) { const char* param = overlayReq.getParameter(i); if (strncmp(param, "OVERLAY_", 8) == 0) { @@ -64,10 +64,10 @@ // companion) bool MatchingCriteria::IsPair(const MatchingInfo& arg1, const MatchingInfo& arg2, bool& swap) const { - MvRequest req1 = arg1.matchingRequest_; - MvRequest req2 = arg2.matchingRequest_; + MvRequest req1 = arg1.matchingRequest_; + MvRequest req2 = arg2.matchingRequest_; std::string companionExpected = (const char*)req1("MY_COMPANION"); - std::string parameter = (const char*)req2("PARAM"); + std::string parameter = (const char*)req2("PARAM"); // The elements are companions // Check if they are given in the correct order @@ -93,8 +93,8 @@ else if (mode == Cached("NEVER_OVERLAY")) return false; - int count = matchingRequest_.countParameters(); - Cached ON = "ON"; + int count = matchingRequest_.countParameters(); + Cached ON = "ON"; bool flagOn = false; for (int i = 0; i < count; i++) { Cached param = matchingRequest_.getParameter(i); @@ -102,7 +102,7 @@ if (matchingRequest_(param) == ON) { // This approach does not take into account date-time tolerance // and vector fields - flagOn = true; + flagOn = true; Cached lhsValue = lhs.matchingRequest_(param, 0); Cached rhsValue = rhs.matchingRequest_(param, 0); @@ -119,7 +119,7 @@ if (flagOn) return true; else - return false; //Never overlay + return false; // Never overlay } #if 0 diff -Nru metview-5.17.4/metview/src/uPlot/MvCallback.hpp metview-5.19.2/metview/src/uPlot/MvCallback.hpp --- metview-5.17.4/metview/src/uPlot/MvCallback.hpp 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvCallback.hpp 2023-07-15 08:28:47.000000000 +0000 @@ -48,9 +48,9 @@ class MvCallbackBase { public: - MvCallbackBase() {} + MvCallbackBase() = default; - virtual ~MvCallbackBase() {} + virtual ~MvCallbackBase() = default; virtual void ExecuteCallback(MvRequest&) = 0; }; @@ -59,7 +59,7 @@ template class MvCallback : public MvCallbackBase { - typedef void (T::*Procedure)(MvRequest&); + using Procedure = void (T::*)(MvRequest&); T& calledObject_; Procedure calledProc_; @@ -71,12 +71,12 @@ calledProc_(proc) {} // -- Destructor - virtual ~MvCallback() {} + ~MvCallback() override = default; // -- Methods // Perform a METVIEW-style callback - void ExecuteCallback(MvRequest& replyRequest) + void ExecuteCallback(MvRequest& replyRequest) override { (calledObject_.*calledProc_)(replyRequest); } diff -Nru metview-5.17.4/metview/src/uPlot/MvDecoder.cc metview-5.19.2/metview/src/uPlot/MvDecoder.cc --- metview-5.17.4/metview/src/uPlot/MvDecoder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvDecoder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,9 +41,7 @@ // Decoder::Decoder(const MvRequest&) : - metadataRequest_("EMPTY"), - offset_(0), - nextData_(false) + metadataRequest_("EMPTY") { } @@ -75,12 +73,12 @@ void Decoder::SetTitle(MvRequest& matchingRequest) { - const char* title; + const char* title = nullptr; if (!(title = metadataRequest_("MV_TITLE"))) title = metadataRequest_("TITLE"); if (title) { - matchingRequest("TEXT_LINE_1") = title; + matchingRequest("TEXT_LINE_1") = title; matchingRequest("TEXT_LINE_COUNT") = 1; } } diff -Nru metview-5.17.4/metview/src/uPlot/MvDecoder.h metview-5.19.2/metview/src/uPlot/MvDecoder.h --- metview-5.17.4/metview/src/uPlot/MvDecoder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvDecoder.h 2023-07-15 08:28:47.000000000 +0000 @@ -67,8 +67,8 @@ struct DecoderFactoryTraits { - typedef Decoder Type; - typedef const MvRequest& Parameter; + using Type = Decoder; + using Parameter = const MvRequest&; static Cached FactoryName(Parameter); static Type* DefaultObject(Parameter); }; @@ -81,8 +81,8 @@ Factory(name) {} }; -//typedef std::vector VariableNamesList; -//typedef std::vector DataVector; +// typedef std::vector VariableNamesList; +// typedef std::vector DataVector; class Decoder { @@ -105,7 +105,7 @@ virtual bool GetData(std::vector&, const char*) { return false; } virtual bool GetRequest(MvRequest&, const char*) { return false; } // for netcf decoder; - virtual Cached GetView() { return Cached(""); } + virtual Cached GetView() { return {""}; } // Overridden by decoders that need to update their request virtual bool UpdateDataRequest(MvRequest&) { return false; } @@ -141,9 +141,9 @@ // Members MvRequest metadataRequest_; // request which contains metadata info - long offset_; - bool nextData_; - double minX_, maxX_, minY_, maxY_; + long offset_{0}; + bool nextData_{false}; + double minX_{0.}, maxX_{0.}, minY_{0.}, maxY_{0.}; private: // No copy allowed diff -Nru metview-5.17.4/metview/src/uPlot/MvGribDecoder.cc metview-5.19.2/metview/src/uPlot/MvGribDecoder.cc --- metview-5.17.4/metview/src/uPlot/MvGribDecoder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvGribDecoder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ class GribDecoderFactory : public DecoderFactory { // Virtual Constructor - Builds a new GribDecoder - virtual Decoder* Build(const MvRequest& inRequest) + Decoder* Build(const MvRequest& inRequest) override { return new GribDecoder(inRequest); } @@ -99,7 +99,7 @@ matchingRequest("TIME") = buf; // we will later need to decide whether to apply automatic scaling or not - //ir matchingRequest("DERIVED") = metadataRequest_("DERIVED"); + // ir matchingRequest("DERIVED") = metadataRequest_("DERIVED"); // Is it an image field? const char* repres = metadataRequest_("REPRES"); @@ -113,15 +113,15 @@ field* ff = currentField_.libmars_field(); grib_get_string(ff->handle, "shortName", acc0, &nsize); - matchingRequest("PARAM") = acc0; + matchingRequest("PARAM") = acc0; matchingRequest("DATA_TYPE") = "GRIB"; // Has this parameter a companion? std::string pair, mode; - bool first_companion; + bool first_companion = false; ObjectList::GetCompanion(std::string(acc0), pair, mode, first_companion); if (pair != "no_pair") { - matchingRequest("MY_COMPANION") = pair.c_str(); + matchingRequest("MY_COMPANION") = pair.c_str(); matchingRequest("FIRST_COMPANION") = first_companion; if (!mode.empty()) matchingRequest("WIND_MODE") = mode.c_str(); diff -Nru metview-5.17.4/metview/src/uPlot/MvGribDecoder.h metview-5.19.2/metview/src/uPlot/MvGribDecoder.h --- metview-5.17.4/metview/src/uPlot/MvGribDecoder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvGribDecoder.h 2023-07-15 08:28:47.000000000 +0000 @@ -53,14 +53,14 @@ GribDecoder(const MvRequest& inRequest); // Destructor - virtual ~GribDecoder(); + ~GribDecoder() override; // Overridden methods from Decoder class // Goes to the next data and returns false if // there are no more fields - virtual bool ReadNextData(); + bool ReadNextData() override; - virtual MatchingInfo CreateMatchingInfo(); + MatchingInfo CreateMatchingInfo() override; private: // WARNING, fieldSetIterator_ should be declared AFTER diff -Nru metview-5.17.4/metview/src/uPlot/MvIcon.cc metview-5.19.2/metview/src/uPlot/MvIcon.cc --- metview-5.17.4/metview/src/uPlot/MvIcon.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvIcon.cc 2023-07-15 08:28:47.000000000 +0000 @@ -44,37 +44,23 @@ // --- This is the body class - MvIconRep MvIconRep::MvIconRep() : - iconId_(0), - parentId_(0), - myRequest_("EMPTY"), - visibility_(true), - transparency_(0), - order_(-1) + myRequest_("EMPTY") { - //Empty + // Empty } MvIconRep::MvIconRep(const std::string& iconName, const std::string& iconClass) : - parentId_(0), iconName_(iconName), - iconClass_(iconClass), - visibility_(true), - transparency_(0), - order_(-1) + iconClass_(iconClass) { - // Empty } MvIconRep::MvIconRep(const MvRequest& inRequest, bool idSave) : iconId_(++iconNextId_), - parentId_(0), - myRequest_(inRequest), - visibility_(true), - transparency_(0), - order_(-1) + myRequest_(inRequest) { - iconName_ = ObjectInfo::ObjectName(inRequest, "", iconId_); - iconClass_ = inRequest.getVerb(); + iconName_ = ObjectInfo::ObjectName(inRequest, "", iconId_); + iconClass_ = inRequest.getVerb(); iconFullPath_ = ObjectInfo::ObjectPath(inRequest); // Save iconId to the request @@ -83,11 +69,7 @@ } MvIconRep::MvIconRep(bool idSave) : - parentId_(0), - myRequest_("EMPTY"), - visibility_(true), - transparency_(0), - order_(-1) + myRequest_("EMPTY") { // Save iconId to the request if (idSave) { @@ -102,37 +84,35 @@ MvIconRep& MvIconRep::operator=(const MvIconRep& mvIconRep) { - if (this == &mvIconRep) - return *this; - - iconName_ = mvIconRep.iconName_; - iconClass_ = mvIconRep.iconClass_; - iconFullPath_ = mvIconRep.iconFullPath_; - iconId_ = mvIconRep.iconId_; - parentId_ = mvIconRep.parentId_; - - myRequest_ = mvIconRep.myRequest_; - - visibility_ = mvIconRep.visibility_, - transparency_ = mvIconRep.transparency_; - order_ = mvIconRep.order_; - + if (this != &mvIconRep) { + iconName_ = mvIconRep.iconName_; + iconClass_ = mvIconRep.iconClass_; + iconFullPath_ = mvIconRep.iconFullPath_; + iconId_ = mvIconRep.iconId_; + parentId_ = mvIconRep.parentId_; + + myRequest_ = mvIconRep.myRequest_; + + visibility_ = mvIconRep.visibility_, + transparency_ = mvIconRep.transparency_; + order_ = mvIconRep.order_; + } return *this; } MvIconRep::MvIconRep(const MvIconRep& mvIconRep) { - iconName_ = mvIconRep.iconName_; - iconClass_ = mvIconRep.iconClass_; + iconName_ = mvIconRep.iconName_; + iconClass_ = mvIconRep.iconClass_; iconFullPath_ = mvIconRep.iconFullPath_; - iconId_ = mvIconRep.iconId_; - parentId_ = mvIconRep.parentId_; + iconId_ = mvIconRep.iconId_; + parentId_ = mvIconRep.parentId_; myRequest_ = mvIconRep.myRequest_; - visibility_ = mvIconRep.visibility_, + visibility_ = mvIconRep.visibility_, transparency_ = mvIconRep.transparency_; - order_ = mvIconRep.order_; + order_ = mvIconRep.order_; } // Initialization of the static counter @@ -144,19 +124,19 @@ MvIcon::MvIcon() { - ptrIconRep_ = new MvIconRep; + ptrIconRep_ = new MvIconRep; ptrIconRep_->refCount_ = 1; } MvIcon::MvIcon(const std::string& iconName, const std::string& iconClass) { - ptrIconRep_ = new MvIconRep(iconName, iconClass); + ptrIconRep_ = new MvIconRep(iconName, iconClass); ptrIconRep_->refCount_ = 1; } MvIcon::MvIcon(bool idSave) { - ptrIconRep_ = new MvIconRep(idSave); + ptrIconRep_ = new MvIconRep(idSave); ptrIconRep_->refCount_ = 1; } @@ -165,7 +145,7 @@ // Initialises the reference counter MvIcon::MvIcon(const MvRequest& inRequest, bool idSave) { - ptrIconRep_ = new MvIconRep(inRequest, idSave); + ptrIconRep_ = new MvIconRep(inRequest, idSave); ptrIconRep_->refCount_ = 1; } @@ -185,12 +165,14 @@ MvIcon& MvIcon::operator=(const MvIcon& inIcon) { - inIcon.ptrIconRep_->refCount_++; + if (this != &inIcon) { + inIcon.ptrIconRep_->refCount_++; - if (--(ptrIconRep_->refCount_) <= 0) - delete ptrIconRep_; + if (--(ptrIconRep_->refCount_) <= 0) + delete ptrIconRep_; - ptrIconRep_ = inIcon.ptrIconRep_; + ptrIconRep_ = inIcon.ptrIconRep_; + } return *this; } diff -Nru metview-5.17.4/metview/src/uPlot/MvIconDataBase.cc metview-5.19.2/metview/src/uPlot/MvIconDataBase.cc --- metview-5.17.4/metview/src/uPlot/MvIconDataBase.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvIconDataBase.cc 2023-07-15 08:28:47.000000000 +0000 @@ -71,7 +71,7 @@ MvIcon tmpVisDef; bool found = false; - visdefList.clear(); //initialise list + visdefList.clear(); // initialise list // Retrieve the VisDefs associated to the DataUnit while (this->NextVisDefByDataUnitId(dataUnit.Id(), tmpVisDef)) { @@ -95,7 +95,7 @@ ++duvdRelationCursor_; // Retrieve the visdef - //return RetrieveVisDef(visdefId, theVisDef); + // return RetrieveVisDef(visdefId, theVisDef); return RetrieveIconFromList(DB_VISDEF, visdefId, theVisDef); } ++duvdRelationCursor_; @@ -129,7 +129,7 @@ MvIcon currentDataUnit; while (duvdCursor != dataUnitVisDefRelation_.end()) { // DataUnits have a unique icon id. Find the one on the list. - //RetrieveDataUnit((*duvdCursor).first,currentDataUnit); + // RetrieveDataUnit((*duvdCursor).first,currentDataUnit); RetrieveIconFromList(DB_DATAUNIT, (*duvdCursor).first, currentDataUnit); if (currentDataUnit.Id() == theDataUnit.Id() || @@ -141,7 +141,7 @@ ++duvdCursor; MvIcon visDef; - //RetrieveVisDef ( (*foundCursor).second, visDef ); + // RetrieveVisDef ( (*foundCursor).second, visDef ); RetrieveIconFromList(DB_VISDEF, (*foundCursor).second, visDef); // Do not remove if they are not of the same class @@ -221,7 +221,7 @@ MvIcon currentDataUnit; while (prduCursor != presentableDataUnitRelation_.end()) { - //RetrieveDataUnit((*prduCursor).second,currentDataUnit); + // RetrieveDataUnit((*prduCursor).second,currentDataUnit); RetrieveIconFromList(DB_DATAUNIT, (*prduCursor).second, currentDataUnit); if (currentDataUnit.Id() == theDataUnit.Id() || currentDataUnit.ParentId() == theDataUnit.Id()) { @@ -253,7 +253,7 @@ MvIcon currentDataUnit; while (prduCursor != presentableDataUnitRelation_.end()) { - //RetrieveDataUnit((*prduCursor).second,currentDataUnit); + // RetrieveDataUnit((*prduCursor).second,currentDataUnit); RetrieveIconFromList(DB_DATAUNIT, (*prduCursor).second, currentDataUnit); if ((currentDataUnit.Id() == theDataUnit.Id() || currentDataUnit.ParentId() == theDataUnit.Id()) && @@ -302,7 +302,7 @@ // Check if class is given MvIcon theVisDef; - //if (vd && RetrieveVisDef((*foundCursor).second,theVisDef)) + // if (vd && RetrieveVisDef((*foundCursor).second,theVisDef)) if (vd && RetrieveIconFromList(DB_VISDEF, (*foundCursor).second, theVisDef)) { // Do not remove if they are not of the same class if (!ObjectInfo::CheckVisDefClass(*vd, theVisDef.Request())) @@ -404,7 +404,7 @@ ++prvdRelationCursor_; // Retrieve the visdef - //return RetrieveVisDef(visdefId, theVisDef); + // return RetrieveVisDef(visdefId, theVisDef); return RetrieveIconFromList(DB_VISDEF, visdefId, theVisDef); } ++prvdRelationCursor_; @@ -459,7 +459,7 @@ if (presentableId > 0) { // Erase the segments to force redrawing Presentable* treeNode = Root::Instance().FindBranch(presentableId); - bool oldStatus = treeNode->RemoveData(); + bool oldStatus = treeNode->RemoveData(); treeNode->RemoveData(false); treeNode->RemoveIcon(newDataUnit); treeNode->RemoveData(oldStatus); @@ -479,19 +479,19 @@ require(nodeId > 0); require(dataUnit.Id() >= 0); - int id; - MvRelation* relation; // Pointer to avoid any copying of maps + int id = 0; + MvRelation* relation = nullptr; // Pointer to avoid any copying of maps // VisDefs that come after a DataUnit are assigned // to that DataUnit (or else they // are assigned to the presentable) // NB Don't check validity of drop. This is responsibility of caller. if (dataUnit.Id() > 0) { - id = dataUnit.Id(); + id = dataUnit.Id(); relation = &dataUnitVisDefRelation_; } else { - id = nodeId; + id = nodeId; relation = &presentableVisDefRelation_; } @@ -541,7 +541,7 @@ // Update icon information MvRequest req = theLayer.Request(); - req(param) = value; + req(param) = value; theLayer.SaveRequest(req); return true; @@ -556,7 +556,7 @@ // Update icon information MvRequest req = theLayer.Request(); - req(param) = value; + req(param) = value; theLayer.SaveRequest(req); return true; @@ -635,7 +635,7 @@ for (unsigned int i = 0; i < DB_COUNT__; i++) { std::cout << mlist[i] << std::endl; MvIconList* iconList = this->IconList(i); - auto lCursor = iconList->begin(); + auto lCursor = iconList->begin(); while (lCursor != iconList->end()) { std::cout << " " << (*lCursor).Id(); ++lCursor; @@ -652,7 +652,7 @@ std::cout << mrel[i] << std::endl; MvRelation* rel = this->IconRelation(i); - auto rCursor = rel->begin(); + auto rCursor = rel->begin(); while (rCursor != rel->end()) { std::cout << " " << (*rCursor).first; std::cout << " " << (*rCursor).second << std::endl; @@ -667,7 +667,7 @@ while (mCursor != presentableLayerRelation_.end()) { std::cout << " " << (*mCursor).first; MvIconList iconList = (*mCursor).second; - auto listCursor = iconList.begin(); + auto listCursor = iconList.begin(); while (listCursor != iconList.end()) { MvIcon tmpIcon = *listCursor; std::cout << tmpIcon.Id(); @@ -700,11 +700,11 @@ // Loop through the list to find a match bool found = false; - auto ii = list.begin(); + auto ii = list.begin(); for (; ii != list.end(); ii++) { - MvIcon currentIcon = *ii; + MvIcon currentIcon = *ii; MvRequest currentRequest = currentIcon.Request(); - const char* currentName = currentRequest("_NAME"); + const char* currentName = currentRequest("_NAME"); // Found a match on name. As the data units are propagated downwards // there may be more with same name. Check that this is the one @@ -713,7 +713,7 @@ if (iconId == 0 || (iconId > 0 && ExistsInRelation(relation, iconId, currentIcon.Id()))) { CreateLink(newRequest); currentIcon.SaveRequest(newRequest); - icon = currentIcon; + icon = currentIcon; found = true; break; } @@ -762,7 +762,7 @@ { // If there is no path, do no create a link const char* mpath = (const char*)(req("PATH")); - if (mpath == 0) + if (mpath == nullptr) return; // Check if the link has to be created @@ -906,7 +906,7 @@ if (bLayer) { MvLayer layer; layer.StackingOrder(index); - //layer.IconId(icon.Id()); + // layer.IconId(icon.Id()); MvIcon iconLayer(layer.Request(), true); // this->InsertMapIcon( ICON_LAYER_REL,icon.Id(),iconLayer,index ); this->InsertLayerIcon(iconRelId, iconLayer, index); @@ -931,7 +931,7 @@ layerList.push_back(layer); else if (index < 0) { bool found = false; - auto it = layerList.end(); + auto it = layerList.end(); for (int i = size; i != 0; --i) { --it; if (this->LayerStackingOrder((*it).Id()) != 999) { @@ -972,7 +972,7 @@ // Scan list of icons checking icons with same Class auto listCursor = iconList.begin(); while (listCursor != iconList.end()) { - MvIcon tmpIcon = *listCursor; + MvIcon tmpIcon = *listCursor; const char* iclass1 = tmpIcon.Request()("_CLASS"); const char* iclass2 = icon.Request()("_CLASS"); if (iclass1 && iclass2 && strcmp(iclass1, iclass2) == 0) { @@ -1017,14 +1017,14 @@ // if index < 0 then add it in the end but before foreground // otherwise, add it in the position indicated by index MvIconList* list = this->IconList(iconType); - int size = list->size(); + int size = list->size(); if (index == 0 || size == 0) list->push_front(icon); else if (index > size) list->push_back(icon); else if (index < 0) { bool found = false; - auto it = list->end(); + auto it = list->end(); for (int i = size; i != 0; --i) { --it; if (this->IconStackingOrder((*it).Id()) != 999) { @@ -1050,10 +1050,10 @@ // Get the associated iconType from the icon relation type variable int iconRelType = PRES_TEXT_REL; - int iconType = IconType(iconRelType); + int iconType = IconType(iconRelType); // Flag indicating if the input icon is TITLE or POSITIONAL - bool btitle = true; + bool btitle = true; MvRequest iconRequest = icon.Request(); if ((const char*)iconRequest("TEXT_MODE") && strcmp((const char*)iconRequest("TEXT_MODE"), "POSITIONAL") == 0) @@ -1065,7 +1065,7 @@ // Find the icon on the list that is Text-Title auto listCursor = iconList.begin(); while (listCursor != iconList.end()) { - MvIcon tmpIcon = *listCursor; + MvIcon tmpIcon = *listCursor; MvRequest tmpRequest = tmpIcon.Request(); if ((const char*)tmpRequest("TEXT_MODE") && strcmp((const char*)tmpRequest("TEXT_MODE"), "POSITIONAL") == 0) { @@ -1222,7 +1222,7 @@ { // Loop over all relations bool found = false; - int iconRelType; + int iconRelType = 0; for (unsigned int i = 0; i < REL_COUNT__; i++) { if (i == PRES_LAYER_REL || i == ICON_LAYER_REL) // ignore these 'special' relations continue; @@ -1230,7 +1230,7 @@ // Remove icon from relation if (this->RemoveIconFromRel(i, iconId)) { iconRelType = i; - found = true; + found = true; break; } } @@ -1365,7 +1365,7 @@ found = true; } - //else + // else ++relCursor; } @@ -1397,7 +1397,7 @@ require(iconId > 0); // Find the correspondent icon list - int iconType = this->FindIconTypeId(iconId); + int iconType = this->FindIconTypeId(iconId); MvIconList* iconList = this->IconList(iconType); if (iconList == nullptr) return false; @@ -1423,7 +1423,7 @@ // Loop over all icon list types for (int i = 0; i < DB_COUNT__; i++) { MvIconList* iconList = this->IconList(i); - auto lCursor = iconList->begin(); + auto lCursor = iconList->begin(); while (lCursor != iconList->end()) { if (id == (*lCursor).Id()) return i; @@ -1440,7 +1440,7 @@ // Loop over all icon list types for (unsigned int i = 0; i < DB_COUNT__; i++) { MvIconList* iconList = this->IconList(i); - auto lCursor = iconList->begin(); + auto lCursor = iconList->begin(); while (lCursor != iconList->end()) { if (id == (*lCursor).Id()) { icon = *lCursor; @@ -1459,7 +1459,7 @@ // Loop over all icon list types for (unsigned int i = 0; i < DB_COUNT__; i++) { MvIconList* iconList = this->IconList(i); - auto lCursor = iconList->begin(); + auto lCursor = iconList->begin(); while (lCursor != iconList->end()) { if (name == (*lCursor).IconName()) { icon = *lCursor; @@ -1481,7 +1481,7 @@ continue; MvRelation* rel = this->IconRelation(i); - auto rCursor = rel->begin(); + auto rCursor = rel->begin(); while (rCursor != rel->end()) { if (iconId == (*rCursor).second) return (*rCursor).first; @@ -1496,7 +1496,7 @@ // // Find the dataunit associated to this visdef bool found = false; - int duId; + int duId = 0; auto relCursor = dataUnitVisDefRelation_.begin(); while (relCursor != dataUnitVisDefRelation_.end()) { // Icon has a unique id; find the one on the list @@ -1511,7 +1511,7 @@ } if (!found) - return -1; //dataunit not found, which means presentable not found + return -1; // dataunit not found, which means presentable not found // Find the presentable associated to this dataunit relCursor = presentableDataUnitRelation_.begin(); @@ -1525,5 +1525,5 @@ ++relCursor; } - return -1; //presentable not found + return -1; // presentable not found } diff -Nru metview-5.17.4/metview/src/uPlot/MvIconDataBase.h metview-5.19.2/metview/src/uPlot/MvIconDataBase.h --- metview-5.17.4/metview/src/uPlot/MvIconDataBase.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvIconDataBase.h 2023-07-15 08:28:47.000000000 +0000 @@ -77,37 +77,37 @@ }; // Definitions for the Icon List -typedef std::list MvIconList; +using MvIconList = std::list; // Definitions for the Link List -typedef std::list MvLinkList; +using MvLinkList = std::list; // Definitions of the iterators that will loop through the lists -typedef MvIconList::iterator MvListCursor; +using MvListCursor = MvIconList::iterator; // Definition for a relation to store m:n relationships -typedef std::multimap MvRelation; +using MvRelation = std::multimap; // Definition for the pairs of entries in the relation -typedef MvRelation::value_type MvEntryPair; +using MvEntryPair = MvRelation::value_type; // Definition for the iterator that loops through the relation pairs -typedef MvRelation::iterator MvRelationCursor; +using MvRelationCursor = MvRelation::iterator; // Definition for a relation to store m relationships -typedef std::map MvMapRelation; +using MvMapRelation = std::map; // Definition for the pairs of entries in the MvMapRelation -typedef MvMapRelation::value_type MvMapEntryPair; +using MvMapEntryPair = MvMapRelation::value_type; // Definition for the iterator that loops through the MvMapRelation pairs -typedef MvMapRelation::iterator MvMapRelationCursor; +using MvMapRelationCursor = MvMapRelation::iterator; class MvIconDataBase { public: // Contructors - MvIconDataBase() {} + MvIconDataBase() = default; MvIconDataBase(const MvIconDataBase&); // Destructor @@ -226,11 +226,11 @@ bool RetrieveVisDefList(const MvIcon& dataUnit, MvIconList& visdefList); // Remove all visdefs associated to a data unit - bool RemoveAllVisDefsByDataUnit(MvIcon& dataUnit, const MvRequest* vd = 0); + bool RemoveAllVisDefsByDataUnit(MvIcon& dataUnit, const MvRequest* vd = nullptr); // Remove all visdefs associated to a data unit list // according to its class (if defined) - void RemoveAllVisDefsByDataUnitList(MvIconList& dataUnitList, const MvRequest* vd = 0); + void RemoveAllVisDefsByDataUnitList(MvIconList& dataUnitList, const MvRequest* vd = nullptr); // Remove Data Unit from the database void RemoveDataUnit(MvIcon& theDataUnit); @@ -245,7 +245,7 @@ // Remove all VisDefs, associated with a specific // presentable Id and for a given class (if presente), // from the database - void RemoveVisDef(const int presentableId, const MvRequest* vd = 0); + void RemoveVisDef(const int presentableId, const MvRequest* vd = nullptr); // Remove all VisDefs from the database void RemoveVisDef(); @@ -271,7 +271,7 @@ // Remove VisDefs associated to a presentable, given a // certain class (if selected) - void RemoveVisDefFromPresRel(const int presentableId, const MvRequest* vd = 0); + void RemoveVisDefFromPresRel(const int presentableId, const MvRequest* vd = nullptr); //-------------------------------------------------- diff -Nru metview-5.17.4/metview/src/uPlot/MvIcon.h metview-5.19.2/metview/src/uPlot/MvIcon.h --- metview-5.17.4/metview/src/uPlot/MvIcon.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvIcon.h 2023-07-15 08:28:47.000000000 +0000 @@ -60,15 +60,15 @@ MvIconRep(bool); // Destructor - ~MvIconRep() {} + ~MvIconRep() = default; // Copy Constructor and Operator = MvIconRep& operator=(const MvIconRep& mvIconRep); MvIconRep(const MvIconRep& mvIconRep); static int iconNextId_; - int iconId_; - int parentId_; + int iconId_{0}; + int parentId_{0}; std::string iconName_; std::string iconFullPath_; @@ -78,12 +78,12 @@ MvRequest svcRequest_; - int refCount_; // reference counter + int refCount_{0}; // reference counter // Layer info - bool visibility_; - int transparency_; // 0 - 100 - int order_; // stacking order: 0, 1, ... + bool visibility_{true}; + int transparency_{0}; // 0 - 100 + int order_{-1}; // stacking order: 0, 1, ... }; @@ -212,5 +212,5 @@ int StackingOrder() { return ptrIconRep_->order_; } private: - MvIconRep* ptrIconRep_; + MvIconRep* ptrIconRep_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/uPlot/MvLayer.cc metview-5.19.2/metview/src/uPlot/MvLayer.cc --- metview-5.17.4/metview/src/uPlot/MvLayer.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvLayer.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,11 +30,11 @@ MvLayer::MvLayer(const MvRequest& layerReq) { - id_ = (int)layerReq("_ID") ? (int)layerReq("_ID") : 0; + id_ = (int)layerReq("_ID") ? (int)layerReq("_ID") : 0; transparency_ = (int)layerReq("TRANSPARENCY") ? (int)layerReq("TRANSPARENCY") : 0; - visibility_ = (int)layerReq("VISIBILITY") ? (int)layerReq("VISIBILITY") : 0; - order_ = (int)layerReq("STACKING_ORDER") ? (int)layerReq("STACKING_ORDER") : -1; - name_ = (const char*)layerReq("_NAME") ? (const char*)layerReq("_NAME") : ""; + visibility_ = (int)layerReq("VISIBILITY") ? (int)layerReq("VISIBILITY") : 0; + order_ = (int)layerReq("STACKING_ORDER") ? (int)layerReq("STACKING_ORDER") : -1; + name_ = (const char*)layerReq("_NAME") ? (const char*)layerReq("_NAME") : ""; if ((const char*)layerReq("ICONS_ID")) { size_t count = layerReq.countValues("ICONS_ID"); @@ -48,11 +48,11 @@ MvLayer::Request() { MvRequest req("LAYER"); - req("TRANSPARENCY") = transparency_; - req("VISIBILITY") = visibility_; + req("TRANSPARENCY") = transparency_; + req("VISIBILITY") = visibility_; req("STACKING_ORDER") = order_; - req("_NAME") = name_.c_str(); - req("_ID") = id_; + req("_NAME") = name_.c_str(); + req("_ID") = id_; return req; } diff -Nru metview-5.17.4/metview/src/uPlot/MvMain.cc metview-5.19.2/metview/src/uPlot/MvMain.cc --- metview-5.17.4/metview/src/uPlot/MvMain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvMain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ Root::Create(); // Initialize Mars communication - marsinit(&argc, argv, 0, 0, 0); + marsinit(&argc, argv, nullptr, 0, nullptr); mvSetMarslogLevel(); ConfigLoader::init(); @@ -50,7 +50,7 @@ // uPlot is running stand alone. // First, find out the type of the input filename const char* filename = (const char*)argv[1]; - std::string stype = ScanFileType(filename); + std::string stype = ScanFileType(filename); if (stype == std::string("BAD")) { errorMessage = "<<< METVIEW ERROR >>>\n\n\nInput file type not recognised!\n\nFilename: "; errorMessage += std::string(filename) + "\n\nFile type: "; @@ -83,7 +83,7 @@ } } else { - //Read the initial input request saved by uPlotManager + // Read the initial input request saved by uPlotManager req.read(argv[1]); // Skip UPLOT_MANAGER request @@ -93,8 +93,8 @@ reqExists = true; -//DOES IT NEED TO TEST FOR INTERACTIVE MODE????? -// CHECK THIS CODE LATER WHEN THE EXPORT BUTTON IS ACTIVATED +// DOES IT NEED TO TEST FOR INTERACTIVE MODE????? +// CHECK THIS CODE LATER WHEN THE EXPORT BUTTON IS ACTIVATED #if 0 // Batch or Interactive mode const char *metviewMode = getenv("METVIEW_MODE"); @@ -146,7 +146,7 @@ { // Retrieve the processing mode std::string metviewMode = (const char*)getenv("METVIEW_MODE"); - std::string name = GetProcessName(metviewMode); + std::string name = GetProcessName(metviewMode); MvRequest req; bool reqExists; @@ -155,11 +155,11 @@ std::string errorMessage; bool ok = SetUplotEnv(argc, argv, metviewMode, req, reqExists, errorMessage); - //Initialise resorces from a static library (libMvQtGui) - //Initialise resorces from a static library (libMvQtGui) - // Q_INIT_RESOURCE(edit); - // Q_INIT_RESOURCE(window); - // Q_INIT_RESOURCE(keyDialog); + // Initialise resorces from a static library (libMvQtGui) + // Initialise resorces from a static library (libMvQtGui) + // Q_INIT_RESOURCE(edit); + // Q_INIT_RESOURCE(window); + // Q_INIT_RESOURCE(keyDialog); // Start uPlot interactively with Qt facilities uPlotApp app(argc, argv, name.c_str()); @@ -185,7 +185,7 @@ // Load the ui theme //--------------------------- - //MvQTheme::init(&app); + // MvQTheme::init(&app); // Instantiate uPlot Display Window uPlotBase* pw = new uPlot; @@ -201,15 +201,15 @@ // Call myself to execute the initial request // It needs to be execute after uPlot window has been created if (reqExists) - MvApplication::callService(name.c_str(), req, 0); + MvApplication::callService(name.c_str(), req, nullptr); // Show uPlot pw->show(); return app.exec(); - //DOES IT NEED TO TEST FOR INTERACTIVE MODE????? - // CHECK THIS CODE LATER WHEN THE EXPORT BUTTON IS ACTIVATED + // DOES IT NEED TO TEST FOR INTERACTIVE MODE????? + // CHECK THIS CODE LATER WHEN THE EXPORT BUTTON IS ACTIVATED #if 0 else @@ -226,5 +226,5 @@ } #endif - Root::ServerDead(0, 0); + Root::ServerDead(0, nullptr); } diff -Nru metview-5.17.4/metview/src/uPlot/MvMainGeoTool.cc metview-5.19.2/metview/src/uPlot/MvMainGeoTool.cc --- metview-5.17.4/metview/src/uPlot/MvMainGeoTool.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvMainGeoTool.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,14 +26,14 @@ Root::Create(); // Initialize Mars communication - marsinit(&argc, argv, 0, 0, 0); + marsinit(&argc, argv, nullptr, 0, nullptr); mvSetMarslogLevel(); // Get request to be processed if (argc > 1) { - //Check if the input request exists + // Check if the input request exists if (access(argv[1], F_OK) == 0) { - //Read the initial input request saved by uPlotManager + // Read the initial input request saved by uPlotManager req.read(argv[1]); req.print(); // Skip UPLOT_MANAGER request @@ -53,7 +53,7 @@ char name[64]; sprintf(name, "GeoTool%ld", (long int)getpid()); - return std::string(name); + return {name}; } int main(int argc, char** argv) @@ -87,13 +87,13 @@ double x = 14.8; double y = 10.5; - //double x = 29.6; - //double y = 21; + // double x = 29.6; + // double y = 21; pw->setPlotWidgetSize(x, y); // Call myself to process the request MvRequest req1 = pw->SuperPageRequest(); - MvApplication::callService(name.c_str(), req1, 0); + MvApplication::callService(name.c_str(), req1, nullptr); // Show uPlot pw->show(); diff -Nru metview-5.17.4/metview/src/uPlot/MvMainuPlotBatch.cc metview-5.19.2/metview/src/uPlot/MvMainuPlotBatch.cc --- metview-5.17.4/metview/src/uPlot/MvMainuPlotBatch.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvMainuPlotBatch.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ public: uPlotBatchService(const char* name) : MvService(name) {} - virtual ~uPlotBatchService() = default; + ~uPlotBatchService() override = default; uPlotBatchService(const uPlotBatchService&) = delete; ; @@ -39,12 +39,12 @@ MvTmpFile outFile(false); in("_OUT_REQ_FILE") = outFile.path().c_str(); - //When the request written into a file and contains a "." value we cannot - //read it because the request parser fails reporting a syntax error! - //So we need to make sure the request does not contain any "." values! + // When the request written into a file and contains a "." value we cannot + // read it because the request parser fails reporting a syntax error! + // So we need to make sure the request does not contain any "." values! - //TODO: the solution below in not generic and only fixes the _PATH = . - //case. On top of that "." in theory could be a valid value in a request! + // TODO: the solution below in not generic and only fixes the _PATH = . + // case. On top of that "." in theory could be a valid value in a request! MvRequest::replaceDotInPath(in); // Write the in request into a file @@ -66,7 +66,7 @@ marslog(LOG_INFO, "ret=%d", ret); if (ret != 0) { - out = MvRequest("ERROR"); + out = MvRequest("ERROR"); std::string msg = "uPlotBatch run failed with exit code: " + std::to_string(ret); // we do not use LOG_EROR here because in this case the error // message would appear twice in he macro editor console diff -Nru metview-5.17.4/metview/src/uPlot/MvQAreaSelection.cc metview-5.19.2/metview/src/uPlot/MvQAreaSelection.cc --- metview-5.17.4/metview/src/uPlot/MvQAreaSelection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQAreaSelection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,17 +22,17 @@ pen_ = QPen(QColor(0, 0, 255, 230), 2); pen_.setCosmetic(true); - brush_ = QBrush(QColor(164, 219, 255, 180)); + brush_ = QBrush(QColor(164, 219, 255, 180)); currentAction_ = NoAction; - zoomLayout_ = nullptr; - rect_ = QRectF(); + zoomLayout_ = nullptr; + rect_ = QRectF(); selectionPen_ = pen_; selectionPen_.setCosmetic(true); selectionPen_.setStyle(Qt::DotLine); - resizeId_ = -1; + resizeId_ = -1; physicalHandleSize_ = 8.; - handleSize_ = 8.; + handleSize_ = 8.; for (int i = 0; i < 8; i++) { handle_ << QRectF(0., 0., handleSize_, handleSize_); } @@ -47,7 +47,7 @@ { checkHandleSize(); - //qDebug() << "brect" << rect_; + // qDebug() << "brect" << rect_; return rect_.adjusted(-handleSize_ / 2., -handleSize_ / 2., handleSize_ / 2., handleSize_ / 2.); } @@ -59,7 +59,7 @@ painter->setBrush(brush_); painter->drawRect(rect_); - //Outline + // Outline if (currentAction_ == ResizeAction || currentAction_ == MoveAction || showHandles_) { painter->setPen(selectionPen_); @@ -71,7 +71,7 @@ painter->setBrush(QBrush()); painter->drawRect(rect_); - //Handlers + // Handlers if (showHandles_) { for (int i = 0; i < handle_.count(); i++) { QRectF r = handle_[i]; @@ -101,7 +101,7 @@ handleHover_ = -1; if (rect_.isNull()) { - //Get scene position + // Get scene position zoomRectOrigin_ = mapFromScene(plotView_->mapToScene(event->pos())); if ((zoomLayout_ = plotScene_->findProjectorItem(mapToScene(zoomRectOrigin_))) == nullptr) { @@ -115,10 +115,10 @@ } else { - float dh = handleSize_ / 2; + float dh = handleSize_ / 2; QRectF cRect = controlRect(); - //qDebug() << "crect" << cRect; + // qDebug() << "crect" << cRect; dragPos_ = mapFromScene(plotView_->mapToScene(event->pos())); @@ -126,14 +126,14 @@ cRect.adjusted(-dh, -dh, dh, dh).contains(dragPos_)) { QPointF xp = dragPos_ - cRect.topLeft(); - //qDebug() << "xp" << dragPos_<< xp << rect_.topLeft(); + // qDebug() << "xp" << dragPos_<< xp << rect_.topLeft(); updateHandles(); resizeId_ = -1; for (int i = 0; i < handle_.count(); i++) { - //qDebug() << "handle" << i << handle_[i]; - //If a handle is selected it starts a resize action + // qDebug() << "handle" << i << handle_[i]; + // If a handle is selected it starts a resize action if (handle_[i].contains(xp)) { resizeId_ = i; @@ -171,21 +171,21 @@ setCursor(QCursor(shape)); currentAction_ = ResizeAction; - //qDebug() << "resizeId" << resizeId_; + // qDebug() << "resizeId" << resizeId_; return; } } - //If no resize action it checks if the drag point is - //in the selection rentangle and starts a move action + // If no resize action it checks if the drag point is + // in the selection rentangle and starts a move action if (resizeId_ == -1 && cRect.contains(dragPos_)) { currentAction_ = MoveAction; setCursor(QCursor(Qt::SizeAllCursor)); } - //Otherwise unselect + // Otherwise unselect else { currentAction_ = NoAction; - dragPos_ = QPointF(); + dragPos_ = QPointF(); if (showHandles_) { showHandles_ = false; update(); @@ -194,7 +194,7 @@ } else { currentAction_ = NoAction; - dragPos_ = QPointF(); + dragPos_ = QPointF(); if (showHandles_) { showHandles_ = false; @@ -209,7 +209,7 @@ if (!activated_ || !acceptMouseEvents_) return; - //qDebug() << "mouseMove in area"; + // qDebug() << "mouseMove in area"; QPointF pos = mapFromScene(plotView_->mapToScene(event->pos())); @@ -231,9 +231,9 @@ else if (currentAction_ == ResizeAction) { QPointF dp = pos - dragPos_; - //Current control rect + // Current control rect QRectF rOri = controlRect(); - QRectF r = updateControlRect(currentAction_, dp); + QRectF r = updateControlRect(currentAction_, dp); if (r.isEmpty() || fabs(r.width()) <= 8. || fabs(r.height()) <= 8. || @@ -253,14 +253,14 @@ prepareGeometryChange(); updateItemByControlRect(r); - dragPos_ = pos; + dragPos_ = pos; showHandles_ = false; update(); } else if (currentAction_ == MoveAction) { QPointF dp = pos - dragPos_; - //qDebug() << "move" << dp << rect_; + // qDebug() << "move" << dp << rect_; QRectF r = updateControlRect(currentAction_, dp); @@ -270,7 +270,7 @@ prepareGeometryChange(); updateItemByControlRect(r); - dragPos_ = pos; + dragPos_ = pos; showHandles_ = false; update(); } @@ -278,7 +278,7 @@ if (showHandles_ == false) return; - QRectF r = controlRect(); //controlRect + QRectF r = controlRect(); // controlRect QPointF dp = pos - r.topLeft(); updateHandles(); @@ -328,11 +328,11 @@ getAreaGeoCorners(gp1, gp2); currentAction_ = NoAction; - zoomLayout_ = nullptr; + zoomLayout_ = nullptr; coordPoint_.clear(); coordPoint_ << gp1 << gp2; - //blLat,blLon,trLat,trLon + // blLat,blLon,trLat,trLon emit areaIsDefined(gp1.y(), gp1.x(), gp2.y(), gp2.x()); } else if (currentAction_ == ResizeAction) { @@ -344,24 +344,24 @@ fabs(r.width()) < 8. || fabs(r.height()) < 8. || r.width() < 0. || r.height() < 0.) { r = rect_; - //clearArea(); - //return; + // clearArea(); + // return; } prepareGeometryChange(); updateItemByControlRect(r); - //update(); + // update(); QPointF gp1, gp2; getAreaGeoCorners(gp1, gp2); currentAction_ = NoAction; - zoomLayout_ = nullptr; + zoomLayout_ = nullptr; coordPoint_.clear(); coordPoint_ << gp1 << gp2; dragPos_ = QPointF(); - //blLat,blLon,trLat,trLon + // blLat,blLon,trLat,trLon emit areaIsDefined(gp1.y(), gp1.x(), gp2.y(), gp2.x()); updateHandles(); @@ -384,12 +384,12 @@ getAreaGeoCorners(gp1, gp2); currentAction_ = NoAction; - zoomLayout_ = nullptr; + zoomLayout_ = nullptr; coordPoint_.clear(); coordPoint_ << gp1 << gp2; dragPos_ = QPointF(); - //blLat,blLon,trLat,trLon + // blLat,blLon,trLat,trLon emit areaIsDefined(gp1.y(), gp1.x(), gp2.y(), gp2.x()); updateHandles(); @@ -402,7 +402,7 @@ void MvQAreaSelection::setArea(double blLat, double blLon, double trLat, double trLon) { - //double west, double north, double east, double south) + // double west, double north, double east, double south) QPointF sp1, sp2; if (rect_.isEmpty()) { @@ -429,18 +429,18 @@ sp1 = mapFromScene(sp1); sp2 = mapFromScene(sp2); - //qDebug() << gp1 << gp2 << sp1 << sp2; + // qDebug() << gp1 << gp2 << sp1 << sp2; QRectF r = QRectF(sp1.x(), sp1.y(), sp2.x() - sp1.x(), sp2.y() - sp1.y()); if (r.width() < 0 || r.height() < 0) { if (rect_.isEmpty() == false) { getAreaGeoCorners(gp1, gp2); - //blLat,blLon,trLat,trLon + // blLat,blLon,trLat,trLon emit areaIsDefined(gp1.y(), gp1.x(), gp2.y(), gp2.x()); } return; } - //qDebug() << rect_; + // qDebug() << rect_; coordPoint_.clear(); coordPoint_ << gp1 << gp2; @@ -452,7 +452,7 @@ else { QPointF gp1, gp2; getAreaGeoCorners(gp1, gp2); - //blLat,blLon,trLat,trLon + // blLat,blLon,trLat,trLon emit areaIsDefined(gp1.y(), gp1.x(), gp2.y(), gp2.x()); } } @@ -477,7 +477,7 @@ if (coordPoint_.isEmpty() || rect_.isNull()) return; - //We need to find the projectorItem!! + // We need to find the projectorItem!! QPointF sp0, sp1; if ((zoomLayout_ = plotScene_->firstProjectorItem()) == nullptr) { @@ -488,7 +488,7 @@ QPointF gp0 = coordPoint_[0]; QPointF gp1 = coordPoint_[1]; - //qDebug() << coordPoint_; + // qDebug() << coordPoint_; if (zoomLayout_->containsGeoCoords(gp0) && zoomLayout_->containsGeoCoords(gp1)) { @@ -499,7 +499,7 @@ sp1 = mapFromScene(sp1); - //qDebug() << sp0 << sp1; + // qDebug() << sp0 << sp1; prepareGeometryChange(); rect_ = QRectF(sp0.x(), sp0.y(), sp1.x() - sp0.x(), sp1.y() - sp0.y()); @@ -518,18 +518,18 @@ rect_ = mapRectFromScene(zoomLayout_->mapRectToScene(zoomLayout_->boundingRect())); QPointF gp1, gp2; - getAreaGeoCorners(gp1, gp2); //this requires zoomLayout_ !!! + getAreaGeoCorners(gp1, gp2); // this requires zoomLayout_ !!! coordPoint_.clear(); coordPoint_ << gp1 << gp2; currentAction_ = NoAction; - zoomLayout_ = nullptr; - dragPos_ = QPointF(); + zoomLayout_ = nullptr; + dragPos_ = QPointF(); showHandles_ = false; update(); - //blLat,blLon,trLat,trLon + // blLat,blLon,trLat,trLon emit areaIsDefined(gp1.y(), gp1.x(), gp2.y(), gp2.x()); } } @@ -541,10 +541,10 @@ checkHandleSize(); float dh = handleSize_ / 2; - float w = r.width(); - float h = r.height(); + float w = r.width(); + float h = r.height(); - //Check handles!!! + // Check handles!!! handle_[0].moveTo(-dh, -dh); handle_[1].moveTo(-dh, h / 2. - dh); handle_[2].moveTo(-dh, h - dh); @@ -568,14 +568,14 @@ QRectF MvQAreaSelection::updateControlRect(CurrentAction action, QPointF& dp) { - //Current control rect + // Current control rect QRectF r = controlRect(); if (!zoomLayout_) { - return QRectF(); + return {}; } - //Plot area in local coordinates + // Plot area in local coordinates QRectF plotRect = mapRectFromScene(zoomLayout_->mapToScene(zoomLayout_->boundingRect()).boundingRect()); if (action == DefineAction) { @@ -629,15 +629,15 @@ } if (r.width() < 0) { - //r.setWidth(8.); + // r.setWidth(8.); r = rect_; } if (r.height() < 0) { - //r.setHeight(8.); + // r.setHeight(8.); r = rect_; } - //qDebug() << "RESIZE" << rect_ << r; + // qDebug() << "RESIZE" << rect_ << r; r = plotRect.intersected(r); } @@ -666,8 +666,8 @@ if (!zoomLayout_->containsSceneCoords(p1) || !zoomLayout_->containsSceneCoords(p2)) { - //qDebug() << "false"; - return QRectF(); + // qDebug() << "false"; + return {}; } return r; @@ -688,9 +688,9 @@ if (!zoomLayout_) return; - //Get geo coordinates of the bl and tr rect corners on the map. - //The y axis is inverted!! So we need tl and br corners of the - //qt rectangle!!!!!!! + // Get geo coordinates of the bl and tr rect corners on the map. + // The y axis is inverted!! So we need tl and br corners of the + // qt rectangle!!!!!!! QPointF sp1 = mapToScene(rect_.topLeft()); QPointF sp2 = mapToScene(rect_.bottomRight()); zoomLayout_->mapFromSceneToGeoCoords(sp1, gp1); diff -Nru metview-5.17.4/metview/src/uPlot/MvQAreaSelection.h metview-5.19.2/metview/src/uPlot/MvQAreaSelection.h --- metview-5.17.4/metview/src/uPlot/MvQAreaSelection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQAreaSelection.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,28 +22,28 @@ Q_OBJECT public: - MvQAreaSelection(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = 0); - ~MvQAreaSelection(); + MvQAreaSelection(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = nullptr); + ~MvQAreaSelection() override; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); - QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; + QRectF boundingRect() const override; void setArea(double, double, double, double); void clearArea(); void selectAllArea(); - void setActivated(bool); + void setActivated(bool) override; - void mousePressEventFromView(QMouseEvent*); - void mouseMoveEventFromView(QMouseEvent*); - void mouseReleaseEventFromView(QMouseEvent*); - void reset(); + void mousePressEventFromView(QMouseEvent*) override; + void mouseMoveEventFromView(QMouseEvent*) override; + void mouseReleaseEventFromView(QMouseEvent*) override; + void reset() override; signals: void areaIsDefined(double, double, double, double); void areaIsUndefined(); -protected: +private: enum CurrentAction { NoAction, diff -Nru metview-5.17.4/metview/src/uPlot/MvQCursorData.cc metview-5.19.2/metview/src/uPlot/MvQCursorData.cc --- metview-5.17.4/metview/src/uPlot/MvQCursorData.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQCursorData.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,8 @@ ***************************** LICENSE END *************************************/ -#include +#include +#include #include #include @@ -18,6 +19,7 @@ #include #include +#include "CursorCoordinate.h" #include "MvQCursorData.h" #include "MvQPlotView.h" #include "MvQTheme.h" @@ -37,6 +39,10 @@ textDoc_ = new QTextDocument(this); textDoc_->setDefaultStyleSheet(MvQTheme::htmlTableCss("cursor_data")); + + if (!activated_) { + hide(); + } } void MvQCursorData::setActivated(bool flag) @@ -54,13 +60,15 @@ void MvQCursorData::prepareForReset() { dataLayout_ = nullptr; - sceneItem_ = nullptr; + sceneItem_ = nullptr; } void MvQCursorData::reset() { - setData(cursorPos_); - update(); + if (activated_) { + adjustToScenePos(cursorPos_, true); + update(); + } } QRectF MvQCursorData::boundingRect() const @@ -75,7 +83,7 @@ painter->setRenderHint(QPainter::Antialiasing, true); painter->drawRoundedRect(boundingRect_.adjusted(1, 1, -1, -1), 5., 5.); - //Render text + // Render text painter->translate(0, boundingRect_.height()); painter->scale(1., -1.); textDoc_->drawContents(painter); @@ -90,7 +98,7 @@ } } -void MvQCursorData::changePositionMode(QPointF& cursor) +void MvQCursorData::changePositionMode(const QPointF& cursor) { if (positionMode_ == Anchored) { positionMode_ = FollowCursor; @@ -104,49 +112,49 @@ } } -void MvQCursorData::changeProbeMode(QPointF& /*cursor*/) -{ - if (probeMode_ == AnchoredProbe) { - probeMode_ = FollowCursorProbe; - } - else { - probeMode_ = AnchoredProbe; - } - - emit probeEnabled(probeMode_ == AnchoredProbe); -} - -void MvQCursorData::setCursorPos(QPointF& cursor) +void MvQCursorData::setCursorPos(const QPointF& cursor, bool forced) { cursorPos_ = cursor; if (positionMode_ == FollowCursor) { - //setPos(cursor+offsetFromCursor_-boundingRect_.topLeft()); setPos(cursor + offsetFromCursor_); - } - else if (probeMode_ == FollowCursorProbe) { + } else if (forced) { + setPos(cursor); + } else { update(); } - //update(); } -void MvQCursorData::setText(QPointF coord, QList layerData, QString nameX, QString nameY, bool hasDistance) +void MvQCursorData::setText(const CursorCoordinate& coord, QList layerData) { + QString nameX, nameY; + bool hasDistance = false; + double x = coord.x(), y=coord.y(); + if (coord.type() == CursorCoordinate::LonLatType) { + nameX = tr("Lat"); + nameY = tr("Lon"); + hasDistance = true; + std::swap(x, y); + } else { + nameX = tr("X"); + nameY = tr("Y"); + } + QString s; s += "
FrameRequest
"; s += ""; s += "
" + nameX + ""; - s += QString::number(coord.x(), 'f', 3); + s += QString::number(x, 'f', 3); s += "" + nameY + ""; - s += QString::number(coord.y(), 'f', 3); + s += QString::number(y, 'f', 3); s += "
"; bool collectedLayerExists = false; - bool hasValue = false; - bool hasScaledValue = false; - bool hasVector = false; + bool hasValue = false; + bool hasScaledValue = false; + bool hasVector = false; for (auto d : layerData) { if (d.collected()) { collectedLayerExists = true; @@ -156,7 +164,7 @@ hasScaledValue = true; if (!hasVector && d[0].size() > 0) { - //Get values + // Get values currentValues_.clear(); d[0].at(0)->visit(*this); @@ -179,13 +187,13 @@ s += "
"; s += ""; - //Create table header + // Create table header s += ""; if (hasValue) { int colSpan = 1; QString valueLabel("Value"); if (hasVector) { - colSpan = 2; + colSpan = 2; valueLabel = "Value(s)"; } @@ -203,14 +211,14 @@ s += ""; - //Loop for each layer + // Loop for each layer for (auto d : layerData) { if (d.collected() == false) continue; s += ""; - //Cell: layer name + // Cell: layer name QStringList lst = QString::fromStdString(d.name()).split("/"); if (!lst.isEmpty()) { QString layerName = lst.last(); @@ -221,8 +229,8 @@ s += ""; } - //We only check the first point in the collector (at present there - //must be only one point anyway!!) + // We only check the first point in the collector (at present there + // must be only one point anyway!!) if (d[0].size() == 0) { s += ""; if (hasValue) { @@ -239,7 +247,7 @@ else { ValuesCollectorData* data = d[0].at(0); - //Get values + // Get values if (d.hasValue()) { currentValues_.clear(); d[0].at(0)->visit(*this); @@ -258,11 +266,11 @@ units = unitsString(QString::fromStdString(d.scaledUnits())); if (data->missing()) { - valueStr = tr("Missing"); + valueStr = tr("Missing"); scaledTxt = valueStr; } else { - valueStr = formatNumber(value); + valueStr = formatNumber(value); scaledTxt = valueStr + units; } } @@ -270,33 +278,33 @@ value = data->value(); units = unitsString(QString::fromStdString(d.units())); if (data->missing()) { - valueStr = tr("Missing"); + valueStr = tr("Missing"); unscaledTxt = valueStr; } else { - valueStr = formatNumber(value); + valueStr = formatNumber(value); unscaledTxt = valueStr + units; } if (hasScaledValue) { if (d.scaled()) { s += ""; - //if(hasVector) s+=""; + // if(hasVector) s+=""; s += ""; if (hasVector) s += ""; } else { s += ""; - //if(hasVector) s+=""; + // if(hasVector) s+=""; s += ""; if (hasVector) s += ""; } } else { - //s+=""; - //if(hasVector) s+=""; + // s+=""; + // if(hasVector) s+=""; s += ""; if (hasVector) s += ""; @@ -323,18 +331,18 @@ } if (data->missing()) { - valueStr = tr("Missing"); + valueStr = tr("Missing"); value1Txt = valueStr; } else { - valueStr = formatNumber(value); + valueStr = formatNumber(value); value1Txt = valueStr + units[0]; } value = currentValues_[1]; if (data->missing()) { - valueStr = tr("Missing"); + valueStr = tr("Missing"); value2Txt = valueStr; } else { @@ -349,7 +357,7 @@ if (hasScaledValue) { - //s+=""; + // s+=""; s += ""; s += ""; s += ""; @@ -361,13 +369,19 @@ } } - //Cell: pos X - s += ""; + x = data->x(); + y = data->y(); + if (coord.type() == CursorCoordinate::LonLatType) { + std::swap(x, y); + + } + // Cell: pos X + s += ""; - //Cell: pos Y - s += ""; + // Cell: pos Y + s += ""; - //Cell: distance + // Cell: distance if (hasDistance) { s += ""; } @@ -403,27 +417,17 @@ } -void MvQCursorData::setData(QPointF pos) +void MvQCursorData::setData(const CursorCoordinate& coord, MgQLayoutItem* dataLayout) { - //Scene position - //QPointF pos = plotView_->mapToScene(event->pos()); - - MgQLayoutItem* dataLayout = 0; - - //Now if dataLayout_ is not null it should contain the point - if (plotScene_->identifyPos(pos, &sceneItem_, &dataLayout)) { - QPointF posM = pos; - QPointF coord; - if (pointInMagnifier_) { - posM = magnifierScenePos_ + (pos - magnifierScenePos_) / magnifierZoomFactor_; - } + // if dataLayout_ is not null it should contain the point + if (dataLayout != nullptr) { double searchRadiusX = 2.; double searchRadiusY = 2.; float plotScale = plotScene_->plotScale(); - double cx = dataLayout->coordRatioX(); - double cy = dataLayout->coordRatioY(); + double cx = dataLayout->coordRatioX(); + double cy = dataLayout->coordRatioY(); if (cx != 0.) { searchRadiusX = 20. / fabs(cx * plotScale); } @@ -431,95 +435,41 @@ searchRadiusY = 20. / fabs(cy * plotScale); } - //qDebug() << "searchRadius:" << cx << cy << plotScale << searchRadiusX << searchRadiusY; - - dataLayout->mapFromSceneToGeoCoords(posM, coord); - //cursorData_->setCoordinates(coord); - - /*QList posL; - QPointF projCoord; - dataLayout->mapFromSceneToProjectionCoords(pos,projCoord); - posL << projCoord;*/ + // qDebug() << "searchRadius:" << cx << cy << plotScale << searchRadiusX << searchRadiusY; QList posL; - posL << coord; + posL << QPointF(coord.x(), coord.y()); QList layerData; - - /*QList txtL; - foreach(QPointF pp,posL) - { - txtL << QStringList(); - } - - sceneItem_->collectLayerDataForCurrentStep(posL,txtL); - - setText(coord,txtL[0]); - - - emit positionChanged(txtL[0]);*/ - sceneItem_->collectLayerDataForCurrentStep(posL, layerData, searchRadiusX, searchRadiusY); - const Transformation& transformation = dataLayout->layout().transformation(); - QString nameX, nameY; - bool hasDistance = false; - switch (transformation.coordinateType()) { - case Transformation::GeoType: - nameX = tr("Lon"); - nameY = tr("Lat"); - hasDistance = true; - break; - case Transformation::XyType: - default: - nameX = tr("X"); - nameY = tr("Y"); - break; - } - - setText(coord, layerData, nameX, nameY, hasDistance); - - //emit positionChanged(coord,layerData); + setText(coord, layerData); } else { setText(); } } - void MvQCursorData::mousePressEventFromView(QMouseEvent* event) { if (activated_ && acceptMouseEvents_) { if (event->buttons() & Qt::LeftButton) { - //Get scene position + // Get scene position QPointF pos = plotView_->mapToScene(event->pos()); changePositionMode(pos); } - /*if(event->buttons() & Qt::MidButton) - { - //Get scene position - QPointF pos=plotView_->mapToScene(event->pos()); - changeProbeMode(pos); - }*/ } } void MvQCursorData::mouseMoveEventFromView(QMouseEvent* event) -{ - if (!activated_ || !acceptMouseEvents_) +{ + if ((!activated_ && !trackCoordinates_) || !acceptMouseEvents_) return; - //Scene position + // Scene position QPointF pos = plotView_->mapToScene(event->pos()); - - if (probeMode_ == FollowCursorProbe) { - setData(pos); - setCursorPos(pos); - } - else { - setCursorPos(pos); - } + adjustToScenePos(pos, true); } void MvQCursorData::mouseReleaseEventFromView(QMouseEvent* event) @@ -533,18 +483,17 @@ } -QString MvQCursorData::unitsString(QString val) +QString MvQCursorData::unitsString(QString val) const { - QString res; - - if (val == "m s**-1") - res = "m/s"; - else if (val == "deg c") - res = "°C"; - else if (val == "degrees") - res = "deg"; - else - res = val; + QString res = val; + static std::map units = {{"m s**-1", "m/s"}, + {"deg c", "°C"}, + {"degrees", "deg"}}; + + auto it = units.find(val); + if (it != units.end()) { + res = it->second; + } if (!res.isEmpty()) res = " (" + res + ")"; @@ -553,27 +502,30 @@ } -QString MvQCursorData::formatNumber(double value) +QString MvQCursorData::formatNumber(double value) const { QString valueStr; - double absValue = abs(value); - - if (trunc(value) == value) // is the number an integer? - valueStr = QString::number(value, 'f', 0); // - cut off the decimal places - else if (absValue < 0.000001 || // is the number very small? - absValue > 1000000000) // or very large? - valueStr = QString::number(value, 'e'); // - use scientific notation - else // otherwise - valueStr = QString::number(value, 'f'); // - use 6 decimal places (default) + double absValue = std::abs(value); + // is the number an integer? - cut off the decimal places + if (trunc(value) == value) { + valueStr = QString::number(value, 'f', 0); + // is the number very small? or very large? + } else if (absValue < 0.000001 || absValue > 1000000000) { + // - use scientific notation + valueStr = QString::number(value, 'e'); + } else { + // use 6 decimal places (default) + valueStr = QString::number(value, 'f'); + } return valueStr; } void MvQCursorData::setMagnifierInfo(bool pointInMag, QPointF magPos, float magZoomFactor) { - pointInMagnifier_ = pointInMag; - magnifierScenePos_ = magPos; + pointInMagnifier_ = pointInMag; + magnifierScenePos_ = magPos; magnifierZoomFactor_ = magZoomFactor; } @@ -593,3 +545,75 @@ currentValues_.push_back(data.speed()); currentValues_.push_back(data.direction()); } + +// detach from the cursor and move cursordata box to the middle of the viewport +void MvQCursorData::resetPosition() +{ + // we must switch to anchor mode + positionMode_ = Anchored; + QPointF pos; + + // get the middle point of the view + if (plotView_ != nullptr && plotView_->viewport() != nullptr) { + pos = plotView_->mapToScene(plotView_->viewport()->rect().center()); + } + + // show the data at this pos so that we get a full (i.e. non-empty) cursor data size + adjustToScenePos(pos, false); + + // using this size we move the centre of the cursor data rect to the + // centre of the view + auto br = boundingRect(); + QPointF delta(br.left() - br.center().x(), -br.height()); + pos = mapToParent(mapFromParent(pos) + delta); + adjustToScenePos(pos, false); + setCursorPos(pos, true); +} + +// extracts the coordinates at the cursor (scene) position +bool MvQCursorData::getCoordinates(const QPointF& scPos, QPointF& coord, MgQLayoutItem** dataLayout) +{ + // Now if dataLayout_ is not null it should contain the point + if (plotScene_->identifyPos(scPos, &sceneItem_, &(*dataLayout))) { + Q_ASSERT(*dataLayout != nullptr); + QPointF posM = scPos; + if (pointInMagnifier_) { + posM = magnifierScenePos_ + (scPos - magnifierScenePos_) / magnifierZoomFactor_; + } + + (*dataLayout)->mapFromSceneToGeoCoords(posM, coord); + return true; + } + return false; +} + +void MvQCursorData::adjustToScenePos(const QPointF& pos, bool changeItemPos) +{ + if (!trackCoordinates_ && !activated_) { + return; + } + + CursorCoordinate coord; + MgQLayoutItem* dataLayout = nullptr; + QPointF cPos; + if (getCoordinates(pos, cPos, &dataLayout)) { + const Transformation& transformation = dataLayout->layout().transformation(); + if (transformation.coordinateType() == Transformation::GeoType) { + coord = {cPos.x(), cPos.y(), CursorCoordinate::LonLatType}; + } else { + coord = {cPos.x(), cPos.y(), CursorCoordinate::XyType}; + } + } + + // notify other ui components about the coordinate + if (trackCoordinates_) { + emit coordinatesChanged(coord); + } + + if (activated_) { + setData(coord, dataLayout); + if (changeItemPos) { + setCursorPos(pos); + } + } +} diff -Nru metview-5.17.4/metview/src/uPlot/MvQCursorData.h metview-5.19.2/metview/src/uPlot/MvQCursorData.h --- metview-5.17.4/metview/src/uPlot/MvQCursorData.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQCursorData.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,6 +23,7 @@ class MgQLayoutItem; class MgQSceneItem; +class CursorCoordinate; class MvQCursorData : public MvQPlotItem, public ValuesCollectorVisitor { @@ -34,60 +35,54 @@ Anchored, FollowCursor }; - enum ProbeMode - { - AnchoredProbe, - FollowCursorProbe - }; - MvQCursorData(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = 0); - ~MvQCursorData() = default; + MvQCursorData(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = nullptr); + ~MvQCursorData() override = default; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); - QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; + QRectF boundingRect() const override; - void setActivated(bool); - void prepareForReset(); - void reset(); + void setActivated(bool) override; + void prepareForReset() override; + void reset() override; void setPositionMode(PositionMode); - void changePositionMode(QPointF&); - void changeProbeMode(QPointF&); - void setCursorPos(QPointF&); - void setText(QPointF, QList layerData, QString, QString, bool); - void setText(); + void changePositionMode(const QPointF&); + void setMagnifierInfo(bool, QPointF magScenePos = QPointF(), float magZoomFactor = 1.); + void resetPosition(); + void setTrackCoordinates(bool b) {trackCoordinates_=b;} - void mousePressEventFromView(QMouseEvent*); - void mouseMoveEventFromView(QMouseEvent*); - void mouseReleaseEventFromView(QMouseEvent*); + void mousePressEventFromView(QMouseEvent*) override; + void mouseMoveEventFromView(QMouseEvent*) override; + void mouseReleaseEventFromView(QMouseEvent*) override; void setZoomWasPerformedAfterMouseRelease(bool b) { zoomWasPerformedAfterMouseRelease_ = b; } - QString unitsString(QString); - - void visit(const ValuesCollectorData&); - void visit(const ValuesCollectorUVData&); - void visit(const ValuesCollectorSDData&); + void visit(const ValuesCollectorData&) override; + void visit(const ValuesCollectorUVData&) override; + void visit(const ValuesCollectorSDData&) override; signals: - void positionChanged(QPointF, QList); - void probeEnabled(bool); + void coordinatesChanged(const CursorCoordinate&); private: + void setCursorPos(const QPointF&, bool forced=false); + void setText(); void setText(QString); - QString formatNumber(double); - void setData(QPointF); + void setText(const CursorCoordinate& coord, QList layerData); + QString formatNumber(double) const; + void setData(const CursorCoordinate& coord, MgQLayoutItem* dataLayout); + QString unitsString(QString) const; + bool getCoordinates(const QPointF& scPos, QPointF& coord, MgQLayoutItem** dataLayout); + void adjustToScenePos(const QPointF& pos, bool changeItemPos); - QGraphicsScene* scene_; QString text_; - QPointF coordinates_; PositionMode positionMode_{FollowCursor}; QPointF offsetFromCursor_{20, 20}; QPointF cursorPos_; - ProbeMode probeMode_{FollowCursorProbe}; QRectF boundingRect_; QTextDocument* textDoc_{nullptr}; MgQLayoutItem* dataLayout_{nullptr}; @@ -97,4 +92,6 @@ float magnifierZoomFactor_{1.}; bool zoomWasPerformedAfterMouseRelease_{true}; std::vector currentValues_; + + bool trackCoordinates_{false}; }; diff -Nru metview-5.17.4/metview/src/uPlot/MvQDataWidget.cc metview-5.19.2/metview/src/uPlot/MvQDataWidget.cc --- metview-5.17.4/metview/src/uPlot/MvQDataWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQDataWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ auto* hb = new QHBoxLayout; hb->setContentsMargins(0, 0, 0, 0); previewLabel_ = new QLabel(this); - titleLabel_ = new QLabel(this); + titleLabel_ = new QLabel(this); titleLabel_->setWordWrap(true); titleLabel_->setProperty("type", "title"); @@ -56,7 +56,7 @@ layout->addLayout(hb); - //Top row + // Top row hb = new QHBoxLayout; hb->setContentsMargins(0, 0, 0, 0); layout->addLayout(hb); @@ -116,14 +116,14 @@ layer_ = layer; updateTitle(); int currentId = centralLayout_->currentIndex(); - metaLoaded_ = false; - dataLoaded_ = false; + metaLoaded_ = false; + dataLoaded_ = false; showContents(currentId); } void MvQDataWidget::clear() { - layer_ = nullptr; + layer_ = nullptr; metaLoaded_ = false; dataLoaded_ = false; updateTitle(); @@ -191,19 +191,20 @@ { clear(); - sceneItem_ = sceneItem; + sceneItem_ = sceneItem; MgQLayerItem* lastLayer = nullptr; - MgQLayerItem* layer = nullptr; + MgQLayerItem* layer = nullptr; - for (int i = sceneItem_->layerItems().count() - 1; i >= 0; i--) { - MgQLayerItem* item = sceneItem_->layerItems().at(i); - lastLayer = item; - if (lastSelectedLayerText_ == layerTitle(item)) { - layer = item; - break; + if (sceneItem_ != nullptr) { + for (int i = sceneItem_->layerItems().count() - 1; i >= 0; i--) { + MgQLayerItem* item = sceneItem_->layerItems().at(i); + lastLayer = item; + if (lastSelectedLayerText_ == layerTitle(item)) { + layer = item; + break; + } } } - if (!layer) layer = lastLayer; @@ -243,7 +244,7 @@ if (!lst.isEmpty()) return lst.last(); } - return QString(); + return {}; } @@ -267,7 +268,7 @@ QVariant val; - val = settings.value("id"); + val = settings.value("id"); QAbstractButton* tb = showBg_->button((val.isNull()) ? 0 : val.toInt()); if (tb) tb->click(); diff -Nru metview-5.17.4/metview/src/uPlot/MvQDataWidget.h metview-5.19.2/metview/src/uPlot/MvQDataWidget.h --- metview-5.17.4/metview/src/uPlot/MvQDataWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQDataWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,12 +33,12 @@ Q_OBJECT public: - MvQDataWidget(MgQPlotScene*, MvQPlotView*, QWidget* parent = 0); - ~MvQDataWidget(); + MvQDataWidget(MgQPlotScene*, MvQPlotView*, QWidget* parent = nullptr); + ~MvQDataWidget() override; void layersAreAboutToChange(); void reset(MgQSceneItem*); - //void resetLayerList(bool restoreCurrentItem = true); - //void resetLayerList(MgQLayerItem*); + // void resetLayerList(bool restoreCurrentItem = true); + // void resetLayerList(MgQLayerItem*); void writeSettings(QSettings&); void readSettings(QSettings&); @@ -52,8 +52,8 @@ void layerListRequested(); protected: - //MgQLayerItem* currentLayerFromList(); - //void setCurrentItemForLayerList(QString); + // MgQLayerItem* currentLayerFromList(); + // void setCurrentItemForLayerList(QString); void clear(); void updateTitle(); QString layerTitle(MgQLayerItem*) const; @@ -62,7 +62,7 @@ enum ContentsIndex { MetadataContentsIndex = 0, - DataContentsIndex = 1 + DataContentsIndex = 1 }; MgQSceneItem* sceneItem_; @@ -76,7 +76,7 @@ QToolButton* showMetaTb_; QToolButton* showDataTb_; QButtonGroup* showBg_; - //QListWidget* layerList_; + // QListWidget* layerList_; QString lastSelectedLayerText_; bool metaLoaded_; bool dataLoaded_; diff -Nru metview-5.17.4/metview/src/uPlot/MvQEcChartsDialog.cc metview-5.19.2/metview/src/uPlot/MvQEcChartsDialog.cc --- metview-5.17.4/metview/src/uPlot/MvQEcChartsDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQEcChartsDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ setLayout(vb); // Layer name text box - auto* hb1 = new QHBoxLayout(); + auto* hb1 = new QHBoxLayout(); auto* screenSelectionLabel = new QLabel(tr("Layer Name:"), this); hb1->addWidget(screenSelectionLabel); leLayerNameSelection_ = new QLineEdit(this); @@ -38,7 +38,7 @@ vb->addLayout(hb1); // Output file text box - auto* hb2 = new QHBoxLayout(); + auto* hb2 = new QHBoxLayout(); auto* outputFileNameLabel = new QLabel(tr("Output File Name:"), this); hb2->addWidget(outputFileNameLabel); leOutputFileNameSelection_ = new QLineEdit(this); @@ -80,7 +80,7 @@ void MvQEcChartsDialog::accept() { // Store the selections - layerName_ = getLayerName(); + layerName_ = getLayerName(); outputFileName_ = getOutputFileName(); QDialog::accept(); @@ -98,7 +98,7 @@ settings.endGroup(); - layerName_ = settings.value("layerName").toString().toStdString(); + layerName_ = settings.value("layerName").toString().toStdString(); outputFileName_ = settings.value("outputFileName").toString().toStdString(); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQEcChartsDialog.h metview-5.19.2/metview/src/uPlot/MvQEcChartsDialog.h --- metview-5.17.4/metview/src/uPlot/MvQEcChartsDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQEcChartsDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,8 @@ Q_OBJECT public: - MvQEcChartsDialog(int, int, QWidget* parent = 0); - ~MvQEcChartsDialog(); + MvQEcChartsDialog(int, int, QWidget* parent = nullptr); + ~MvQEcChartsDialog() override; // Get info from the user interface std::string getLayerName() @@ -34,10 +34,10 @@ } public slots: - void accept(); + void accept() override; protected: - void setVisible(bool b) + void setVisible(bool b) override { QDialog::setVisible(b); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureCommand.cc metview-5.19.2/metview/src/uPlot/MvQFeatureCommand.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureCommand.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureCommand.cc 2023-07-15 08:28:47.000000000 +0000 @@ -109,7 +109,7 @@ MvQFeatureCommandFactory(QString); MvQFeatureCommandFactory(const MvQFeatureFactory&) = delete; MvQFeatureCommandFactory& operator=(const MvQFeatureFactory&) = delete; - virtual ~MvQFeatureCommandFactory() = default; + virtual ~MvQFeatureCommandFactory() = default; virtual MvQFeatureCommand* make(MvQFeatureItemPtr item) = 0; static MvQFeatureCommand* create(QString name, MvQFeatureItemPtr item); @@ -145,7 +145,7 @@ MvQFeatureCommand* MvQFeatureCommandFactory::create(QString name, MvQFeatureItemPtr item) { MvQFeatureCommand* cmd = nullptr; - auto it = makers->find(name); + auto it = makers->find(name); if (it == makers->end()) { } else { @@ -164,7 +164,7 @@ class MvQFeatureCommand : public QUndoCommand { public: - MvQFeatureCommand(MvQFeatureItemList items, QString name, QUndoCommand* parent = 0); + MvQFeatureCommand(MvQFeatureItemList items, QString name, QUndoCommand* parent = nullptr); bool match(const QUndoCommand* other) const; protected: @@ -292,7 +292,7 @@ class MvQFeatureStyleCommand : public MvQFeatureCommand { public: - MvQFeatureStyleCommand(const MvRequest&, StyleEditInfo info, MvQFeatureItemPtr item, QUndoCommand* parent = 0); + MvQFeatureStyleCommand(const MvRequest&, StyleEditInfo info, MvQFeatureItemPtr item, QUndoCommand* parent = nullptr); void undo() override; void redo() override; bool mergeWith(const QUndoCommand* other) override; @@ -321,7 +321,7 @@ class MvQFeatureAddNodeCommand : public MvQFeatureCommand { public: - MvQFeatureAddNodeCommand(int nodeIndex, bool before, MvQFeatureItemPtr item, QUndoCommand* parent = 0); + MvQFeatureAddNodeCommand(int nodeIndex, bool before, MvQFeatureItemPtr item, QUndoCommand* parent = nullptr); void undo() override; void redo() override; @@ -333,7 +333,7 @@ class MvQFeatureRemoveNodeCommand : public MvQFeatureCommand { public: - MvQFeatureRemoveNodeCommand(int nodeIndex, MvQFeatureItemPtr item, QUndoCommand* parent = 0); + MvQFeatureRemoveNodeCommand(int nodeIndex, MvQFeatureItemPtr item, QUndoCommand* parent = nullptr); void undo() override; void redo() override; @@ -345,7 +345,7 @@ class MvQFeatureMoveNodeCommand : public MvQFeatureCommand { public: - MvQFeatureMoveNodeCommand(const QPointF& scenePos, int nodeIndex, bool start, MvQFeatureItemPtr item, QUndoCommand* parent = 0); + MvQFeatureMoveNodeCommand(const QPointF& scenePos, int nodeIndex, bool start, MvQFeatureItemPtr item, QUndoCommand* parent = nullptr); void undo() override; void redo() override; bool mergeWith(const QUndoCommand* other) override; @@ -361,7 +361,7 @@ class MvQFeatureMoveByCommand : public MvQFeatureCommand { public: - MvQFeatureMoveByCommand(const QPointF& delta, bool start, MvQFeatureItemList items, QUndoCommand* parent = 0); + MvQFeatureMoveByCommand(const QPointF& delta, bool start, MvQFeatureItemList items, QUndoCommand* parent = nullptr); void undo() override; void redo() override; bool mergeWith(const QUndoCommand* other) override; @@ -377,7 +377,7 @@ class MvQFeatureResizeCommand : public MvQFeatureCommand { public: - MvQFeatureResizeCommand(const QRectF& newRect, const QRectF& oriRect, bool start, MvQFeatureItemList items, QUndoCommand* parent = 0); + MvQFeatureResizeCommand(const QRectF& newRect, const QRectF& oriRect, bool start, MvQFeatureItemList items, QUndoCommand* parent = nullptr); void undo() override; void redo() override; bool mergeWith(const QUndoCommand* other) override; @@ -487,7 +487,7 @@ { if (firstCall_) { firstCall_ = false; - resItems_ = MvQFeatureHandler::Instance()->performDuplicate(items_); + resItems_ = MvQFeatureHandler::Instance()->performDuplicate(items_); } MvQFeatureHandler::Instance()->addToScene(resItems_); } @@ -955,7 +955,7 @@ MvQFeatureCommand(items, "resize", parent), start_(start) { - //bool validDelta = fabs(delta.x()) > 1E-10 || fabs(delta.y()) > 1E-10; + // bool validDelta = fabs(delta.x()) > 1E-10 || fabs(delta.y()) > 1E-10; for (auto item : items_) { oriGeom_ << item->getGeometry(); item->adjustSizeToSelector(newRect, oriRect); @@ -1094,7 +1094,7 @@ MgQLayoutItem* MvQFeatureHandler::layoutItemAt(const QPointF& scPos) const { - MgQSceneItem* sceneItem = nullptr; + MgQSceneItem* sceneItem = nullptr; MgQLayoutItem* layoutItem = nullptr; if (view_->plotScene_->identifyPos(scPos, &sceneItem, &layoutItem)) { layoutItem = sceneItem->firstProjectorItem(); @@ -1121,9 +1121,9 @@ void MvQFeatureHandler::currentLayout(MvQFeatureItemPtr item, MgQLayoutItem** layoutItem) const { - QPointF scPos = item->scenePos(); + QPointF scPos = item->scenePos(); MgQSceneItem* sceneItem = nullptr; - *layoutItem = nullptr; + *layoutItem = nullptr; if (view_->plotScene_->identifyPos(scPos, &sceneItem, layoutItem)) { *layoutItem = sceneItem->firstProjectorItem(); } @@ -1161,7 +1161,7 @@ } // add from json using the stored geocoordinates -void MvQFeatureHandler::registerToAddAtClick(WsType *wst) +void MvQFeatureHandler::registerToAddAtClick(WsType* wst) { init(); featureToAddAtClick_.reset(); @@ -1266,7 +1266,7 @@ if (const char* chPath = r("PATH")) { QJsonArray a; WsDecoder::readCollection(QString(chPath), a); - //MvLog().dbg() <<"array=" << a.size(); + // MvLog().dbg() <<"array=" << a.size(); if (a.size() > 0) { if (hasLayout()) { addFromJson(a); @@ -1331,7 +1331,7 @@ for (auto& item : items) { if (auto cl = MvQFeatureFactory::clone(item)) { QPointF offset(20, 20); - auto scPos = item->scenePos() + offset; + auto scPos = item->scenePos() + offset; MgQLayoutItem* layoutItem = nullptr; if (canBePastedToScene(cl, scPos, &layoutItem)) { if (first) { @@ -1343,7 +1343,7 @@ resItems << cl; } else { - //delete cl; + // delete cl; resItems << nullptr; } } @@ -1378,7 +1378,7 @@ if (auto item = MvQFeatureFactory::create(obj)) { MgQLayoutItem* layoutItem = nullptr; if (canBePastedToScene(item, scPos, &layoutItem)) { - //determine offset relative to paste scene position + // determine offset relative to paste scene position auto objScPos = WsDecoder::scenePos(obj); if (items.size() == 0) { firstScPos = objScPos; @@ -1447,7 +1447,7 @@ if (mimeData) { // if (mimeData->clipboardAction() == MvQFeatureMimeData::CopyAction) { if (true) { - auto ba = mimeData->data("metview/feature"); + auto ba = mimeData->data("metview/feature"); auto doc = QJsonDocument::fromJson(ba); paste(doc, scenePos); } @@ -1462,7 +1462,7 @@ #endif if (cmd.startsWith("extra:")) { // int idx = cmd.mid(6).toInt(); - //return (idx >=0 && idx < topLevelActions.size())?topLevelActions[idx]:nullptr; + // return (idx >=0 && idx < topLevelActions.size())?topLevelActions[idx]:nullptr; } else if (!cmd.isEmpty()) { if (cmd == "paste") { @@ -1758,7 +1758,6 @@ } } if (!a.isEmpty()) { - QJsonDocument doc; WsDecoder::toJsonCollection(a, doc); saveToDisk(doc); diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureCommandTarget.cc metview-5.19.2/metview/src/uPlot/MvQFeatureCommandTarget.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureCommandTarget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureCommandTarget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ void MvQFeatureCommandTarget::setTargetItem(MvQFeatureItemPtr item) { targetItem_ = item; - itemMode_ = "item"; + itemMode_ = "item"; if (targetItem_) { itemType_ = targetItem_->typeName(); } @@ -36,8 +36,8 @@ void MvQFeatureCommandTarget::setTargetNodeItem(MvQFeatureItemPtr item, int nodeIndex) { targetItem_ = item; - itemMode_ = "node"; - nodeIndex_ = nodeIndex; + itemMode_ = "node"; + nodeIndex_ = nodeIndex; if (targetItem_) { itemType_ = targetItem_->typeName(); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureCommandTarget.h metview-5.19.2/metview/src/uPlot/MvQFeatureCommandTarget.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureCommandTarget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureCommandTarget.h 2023-07-15 08:28:47.000000000 +0000 @@ -42,7 +42,7 @@ void setInSelector(bool b) { inSelector_ = b; } void addDisabledCommands(QStringList lst); -protected: +private: SelectionMode mode_{ContextMenuMode}; QString itemMode_{"-"}; QString itemType_{"-"}; diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureContextMenu.cc metview-5.19.2/metview/src/uPlot/MvQFeatureContextMenu.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureContextMenu.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureContextMenu.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ label_(label) { if (!name_.isEmpty() && label_.isEmpty()) { - label_ = name_.replace("_", " "); + label_ = name_.replace("_", " "); label_[0] = label_[0].toUpper(); } } @@ -65,12 +65,12 @@ std::vector v; r.getValue("visible_for", v, true); - for (auto s : v) { + for (const auto& s : v) { item->visible_for_ << QString::fromStdString(s); } r.getValue("not_visible_for", v, true); - for (auto s : v) { + for (const auto& s : v) { item->not_visible_for_ << QString::fromStdString(s); } items_.push_back(item); @@ -81,7 +81,7 @@ { QMenu menu; QMap subMenus; - //if (mode != "-" && type != "-") { + // if (mode != "-" && type != "-") { bool node = (sel.itemMode() == "node"); QWidgetAction* labelAc = nullptr; @@ -112,7 +112,7 @@ } else { // The menus will take ownership of the action - QAction* ac; + QAction* ac = nullptr; if (!item->parent_.isEmpty() && subMenus.contains(item->parent_)) { ac = subMenus[item->parent_]->addAction(""); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureContextMenu.h metview-5.19.2/metview/src/uPlot/MvQFeatureContextMenu.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureContextMenu.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureContextMenu.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,14 +26,14 @@ MvQFeatureMenuItem(bool node, QString name, QString label); MvQFeatureMenuItem(const MvQFeatureMenuItem&) = delete; MvQFeatureMenuItem& operator=(const MvQFeatureMenuItem&) = delete; - ~MvQFeatureMenuItem() = default; + ~MvQFeatureMenuItem() = default; static void add(const MvRequest& r); static void setupShortcut(QObject* receiver, QWidget* w, const std::string& view); static QString execute(const MvQFeatureCommandTarget& sel, QList extraActions, QPoint globalPos); static void init(); -protected: +private: QShortcut* createShortcut(QWidget* parent, const std::string& view); bool node_{false}; diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureCurveItem.cc metview-5.19.2/metview/src/uPlot/MvQFeatureCurveItem.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureCurveItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureCurveItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -69,13 +69,13 @@ bool MvQFeatureLineEdgeShape::update(const std::string& type, float angle, float len) { - //qDebug() << " MvQFeatureLineEdgeShape::update" << type.c_str() << angle << len; - bool changed = false; + // qDebug() << " MvQFeatureLineEdgeShape::update" << type.c_str() << angle << len; + bool changed = false; static const float eps = 1E-3; - changed = (type_ != type || fabs(angle_ - angle) > eps || fabs(length_ - len) > eps); + changed = (type_ != type || fabs(angle_ - angle) > eps || fabs(length_ - len) > eps); - type_ = type; - angle_ = angle; + type_ = type; + angle_ = angle; length_ = len; return (shape_.isEmpty()) ? true : changed; @@ -94,7 +94,7 @@ // Compute line slope and arrow angle in radians float theta = atan2(p2.y() - p1.y(), p2.x() - p1.x()); - float rad = MvSci::degToRad(angle_); + float rad = MvSci::degToRad(angle_); // Compute first point shape_.clear(); @@ -134,7 +134,7 @@ // magnifiy from centre QPolygonF pp; for (auto p : shape_) { - auto d = p - c; + auto d = p - c; auto norm = sqrt(pow((d.x()), 2) + pow((d.y()), 2)); auto unit = QPointF(0, 0); if (norm > 1E-9) { @@ -151,7 +151,7 @@ void MvQFeatureLineEdgeShape::adjustLineSize(QPolygonF& p, bool start) const { if (type_ == "FILLED_ARROW") { - int nel; + int nel = 0; if (start) { if ((nel = adjustLineSizeFA(p.cbegin(), p.cend())) < 0) return; @@ -224,10 +224,10 @@ curve_(curve) { Q_ASSERT(parentItem()); - float w = 8; - bRect_ = QRectF(-w / 2, -w / 2, w, w); + float w = 8; + bRect_ = QRectF(-w / 2, -w / 2, w, w); dataLayout_ = curve_->dataLayout(); - sceneId_ = curve_->sceneId(); + sceneId_ = curve_->sceneId(); // the parent is the curve. A child item always appears on the parent's z-level. We want to // show this item on top of the parent (the curve). It would be @@ -294,7 +294,7 @@ qDebug() << " selected (after):" << isSelected(); #endif dragPos_ = mapToParent(event->pos()); - inMove_ = false; + inMove_ = false; } void MvQFeatureCurvePointItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) @@ -303,9 +303,9 @@ qDebug() << "MvQFeatureCurvePointItem::mouseMoveEvent" << parentItem()->isSelected(); qDebug() << "parent selected:" << parentItem()->isSelected(); #endif - QPointF pp = mapToParent(event->pos()); + QPointF pp = mapToParent(event->pos()); QPointF scp = mapToScene(event->pos()); - float eps = 1E-3; + float eps = 1E-3; if (inMove_ || dragPos_.isNull() || (fabs(pp.x() - dragPos_.x()) > eps && fabs(pp.y() - dragPos_.y()) > eps)) { if (currentAction_ == PointEditAction || currentAction_ == NoAction) { @@ -328,7 +328,7 @@ currentAction_ = NoAction; } dragPos_ = QPointF(); - inMove_ = false; + inMove_ = false; } void MvQFeatureCurvePointItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) @@ -395,21 +395,21 @@ { double halo = 10; #ifdef MVQFEATURECURVE_DEBUG_ - //qDebug() << "containsInHalo" << pp << bRect_; + // qDebug() << "containsInHalo" << pp << bRect_; #endif return bRect_.adjusted(-halo, -halo, halo, halo).contains(mapFromParent(pp)); } -//void MvQFeatureCurvePointItem::adjustProjection() +// void MvQFeatureCurvePointItem::adjustProjection() //{ -// dataLayout_ = curve_->dataLayout(); -// sceneId_.clear(); -// outOfView_ = true; -// if (dataLayout_) { -// sceneId_ = dataLayout_->layout().id(); -// outOfView_ = false; -// } -//} +// dataLayout_ = curve_->dataLayout(); +// sceneId_.clear(); +// outOfView_ = true; +// if (dataLayout_) { +// sceneId_ = dataLayout_->layout().id(); +// outOfView_ = false; +// } +// } // Recompute the position of the item using the current geoCoord void MvQFeatureCurvePointItem::reproject(bool /*init*/) @@ -421,9 +421,9 @@ sceneId_.clear(); outOfView_ = true; if (dataLayout_) { - sceneId_ = dataLayout_->layout().id(); - outOfView_ = false; - QPointF scPos = parentItem()->mapToScene(pos()); + sceneId_ = dataLayout_->layout().id(); + outOfView_ = false; + QPointF scPos = parentItem()->mapToScene(pos()); hasValidGeoCoord_ = isValidPoint(geoCoord_); if (hasValidGeoCoord_) { // TODO: it is not guaranteed the pos is valid, since the coordinate might not @@ -458,15 +458,15 @@ MvQFeatureItem(feature), closed_(closed) { - linePen_ = MvQ::makePen("SOLID", 1, "BLACK"); - fillBrush_ = QBrush(QColor(55, 93, 160, 128)); + linePen_ = MvQ::makePen("SOLID", 1, "BLACK"); + fillBrush_ = QBrush(QColor(55, 93, 160, 128)); realZValue_ = zValue(); } void MvQFeatureCurveBaseItem::init(const QJsonObject& obj) { QJsonObject g = obj["geometry"].toObject(); - auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); + auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); for (int i = 0; i < gcLst.size(); i++) { auto pp = new MvQFeatureCurvePointItem(this); pp->setVisible(false); @@ -546,7 +546,7 @@ else { // reproject all the control points for (int i = 0; i < points_.count(); i++) { - //points_[i]->adjustProjection(); + // points_[i]->adjustProjection(); points_[i]->reproject(false); } } @@ -620,18 +620,18 @@ if (!points_.empty()) return; - //start point + // start point auto* p1 = new MvQFeatureCurvePointItem(this); p1->initAtGeoCoord(geoCoord_); - //second point + // second point auto* p2 = new MvQFeatureCurvePointItem(this); p2->initAtGeoCoord(geoCoord_); currentAction_ = CreationAction; points_ << p1 << p2; - //put the second point into move mode! + // put the second point into move mode! p2->enterCreateMode(); } @@ -653,18 +653,18 @@ return; } - //prev point + // prev point MvQFeatureCurvePointItem* p1 = points_.back(); p1->adjustGeoCoord(); - //next point + // next point auto* p2 = new MvQFeatureCurvePointItem(this); p2->initAtGeoCoord(p1->geoCoord()); currentAction_ = CreationAction; points_ << p2; - //put the second point into move mode + // put the second point into move mode p2->enterCreateMode(); } @@ -696,7 +696,7 @@ realZValue_ = zValue(); setZValue(topZValue_); - //qDebug() << "MvQFeatureCurveBaseItem::enterPointEdit"; + // qDebug() << "MvQFeatureCurveBaseItem::enterPointEdit"; currentAction_ = PointEditEnterAction; for (int i = 0; i < points_.count(); i++) { points_[i]->setVisible(true); @@ -709,7 +709,7 @@ // have started void MvQFeatureCurveBaseItem::startPointEdit() { - //qDebug() << "MvQFeatureCurveBaseItem::startPointEdit"; + // qDebug() << "MvQFeatureCurveBaseItem::startPointEdit"; if (currentAction_ == PointEditEnterAction) { currentAction_ = PointEditAction; } @@ -718,7 +718,7 @@ // leave the point edit mode void MvQFeatureCurveBaseItem::leavePointEdit() { - //qDebug() << "MvQFeatureCurveBaseItem::leavePointEdit"; + // qDebug() << "MvQFeatureCurveBaseItem::leavePointEdit"; currentAction_ = NoAction; for (int i = 0; i < points_.count(); i++) { points_[i]->setVisible(false); @@ -852,7 +852,7 @@ if (p == points_[0]) { // moves the origo to the new position of the first point QPointF scPos = mapToScene(p->pos()); - QPointF pos1 = parentItem()->mapFromScene(scPos); + QPointF pos1 = parentItem()->mapFromScene(scPos); QPointF delta = p->pos(); setPos(pos1); adjustGeoCoord(); @@ -888,8 +888,8 @@ int MvQFeatureCurveBaseItem::nodeForContextMenu(const QPointF& p) { for (int i = 0; i < points_.size(); i++) { - //qDebug() << "node" << i << points_[i]->isSelected(); - // if (points_[i]->isSelected() && points_[i]->containsInHalo(p)) { + // qDebug() << "node" << i << points_[i]->isSelected(); + // if (points_[i]->isSelected() && points_[i]->containsInHalo(p)) { if (points_[i]->containsInHalo(p)) { return i; } @@ -908,7 +908,7 @@ return; int otherIdx = -1; - //insert node before the selected node + // insert node before the selected node if (before) { otherIdx = nodeIdx - 1; if (closed_ && nodeIdx == 0) { @@ -998,8 +998,8 @@ if (points_.size() >= 2) { const auto xMM = std::minmax_element(curveX_.begin(), curveX_.end()); const auto yMM = std::minmax_element(curveY_.begin(), curveY_.end()); - minP = QPointF(*xMM.first, *yMM.first); - maxP = QPointF(*xMM.second, *yMM.second); + minP = QPointF(*xMM.first, *yMM.first); + maxP = QPointF(*xMM.second, *yMM.second); } return QRectF(minP, maxP); } @@ -1045,7 +1045,7 @@ void MvQFeatureCurveBaseItem::buildShape() { - auto d = 8; //symbolWidth_ + 4; + auto d = 8; // symbolWidth_ + 4; if (points_.size() >= 1) { buildShapeCore(curveX_, curveY_, d, d); } @@ -1137,7 +1137,7 @@ Qt::FlatCap, Qt::MiterJoin); } - bool oriFilled = isFilled(); + bool oriFilled = isFilled(); bool arrowChanged = false; if (closed_) { // Get other parameters @@ -1153,7 +1153,7 @@ else { // Set endpoint parameters double angle = (double)req_("ARROW_ANGLE"); - double len = (double)req_("ARROW_LENGTH"); + double len = (double)req_("ARROW_LENGTH"); req_.getValue("LINE_START_TYPE", val); bool changedStart = startPointShape_.update(val, angle, len); @@ -1234,13 +1234,13 @@ Q_ASSERT(points_.size() == delta.size()); // the points themselves define the item rect - //QRectF pRect = bRect_; + // QRectF pRect = bRect_; QRectF pRect = itemRect_; // horizontal resize // find resize center position - float dLeft = targetRect.left() - itemRect_.left(); + float dLeft = targetRect.left() - itemRect_.left(); float dRight = targetRect.right() - itemRect_.right(); float dTotal = fabs(dLeft) + fabs(dRight); @@ -1248,7 +1248,7 @@ float rcX = itemRect_.center().x() + fabs(dLeft / dTotal) * pRect.width() / 2. - fabs(dRight / dTotal) * pRect.width() / 2.; - float leftW = rcX - pRect.x(); + float leftW = rcX - pRect.x(); float rightW = pRect.width() - leftW; if (leftW < 0.) leftW = 0.; @@ -1277,15 +1277,15 @@ // vertical resize // find resize center position - float dTop = targetRect.top() - itemRect_.top(); + float dTop = targetRect.top() - itemRect_.top(); float dBottom = targetRect.bottom() - itemRect_.bottom(); - dTotal = fabs(dTop) + fabs(dBottom); + dTotal = fabs(dTop) + fabs(dBottom); if (dTotal > 1E-4) { float rcY = itemRect_.center().y() + fabs(dTop / dTotal) * pRect.height() / 2. - fabs(dBottom / dTotal) * pRect.height() / 2.; - float topH = rcY - pRect.y(); + float topH = rcY - pRect.y(); float bottomH = pRect.height() - topH; if (topH < 0.) topH = 0; @@ -1378,7 +1378,7 @@ { // moves the origo to the new position of the first point QPointF scPos0 = mapToScene(points_[0]->pos() + delta[0]); - QPointF pos0 = parentItem()->mapFromScene(scPos0); + QPointF pos0 = parentItem()->mapFromScene(scPos0); setPos(pos0); // the first point's postion is the origo @@ -1547,7 +1547,7 @@ QSizeF MvQFeaturePolylineItem::minSize() const { - return QSizeF(2 * halo() + 8, 2 * halo() + 8); + return {2 * halo() + 8, 2 * halo() + 8}; } //======================================== @@ -1642,7 +1642,7 @@ // reproject all the control points auto delta = geoCoord_ - points_[0]->geoCoord_; for (int i = 0; i < points_.count(); i++) { - //points_[i]->adjustProjection(); + // points_[i]->adjustProjection(); points_[i]->geoCoord_ += delta; points_[i]->reproject(false); } @@ -1670,7 +1670,7 @@ QPointF gc1 = computeGeoCoord(sc); // add delta - sc = parentItem()->mapToScene(parentItem()->mapFromScene(sc) + delta); + sc = parentItem()->mapToScene(parentItem()->mapFromScene(sc) + delta); QPointF gc2 = computeGeoCoord(sc); // get geo delta @@ -1902,17 +1902,18 @@ } // at this point all the geo and scene coords are valid + if (!sc.isEmpty()) { + // set the first point and the pos + points_[0]->setPos(QPointF(0, 0)); + points_[0]->geoCoord_ = gc[0]; + setPos(parentItem()->mapFromScene(sc[0])); + adjustGeoCoord(); - // set the first point and the pos - points_[0]->setPos(QPointF(0, 0)); - points_[0]->geoCoord_ = gc[0]; - setPos(parentItem()->mapFromScene(sc[0])); - adjustGeoCoord(); - - // determine the other points' positions - for (int i = 1; i < points_.count(); i++) { - points_[i]->setPos(mapFromScene(sc[i])); - points_[i]->geoCoord_ = gc[i]; + // determine the other points' positions + for (int i = 1; i < points_.count(); i++) { + points_[i]->setPos(mapFromScene(sc[i])); + points_[i]->geoCoord_ = gc[i]; + } } } @@ -1933,7 +1934,7 @@ if (points_.size() >= 2) { for (int i = 0; i < points_.size(); i++) { - int actIdx = i; + int actIdx = i; int nextIdx = (i < points_.size() - 1) ? (i + 1) : 0; curveX_.push_back(points_[actIdx]->pos().x()); curveY_.push_back(points_[actIdx]->pos().y()); @@ -2055,7 +2056,7 @@ #endif } - dx = c2.x() - c1.x(); + dx = c2.x() - c1.x(); segmentDx_[idx] = dx; #ifdef MVQFEATURECURVE_DEBUG_ @@ -2064,7 +2065,7 @@ } else { if (static_cast(segmentDx_.size()) > idx) { - segmentDx_[idx] = dx; + segmentDx_[idx] = dx; segmentAcrossDateLine_[idx] = false; } else { @@ -2170,7 +2171,7 @@ #endif for (int i = 0; i < 4; i++) { - auto p = new MvQFeatureCurvePointItem(this); + auto p = new MvQFeatureCurvePointItem(this); p->geoCoord_ = geoCoord_; p->setPos(QPointF(0, 0)); points_ << p; @@ -2190,18 +2191,18 @@ void MvQFeatureGeoQuadItem::adjustGeoShapeToDelta(QList delta, QList& gc) { int dMaxIndex = 0; - float dMax = -1; + float dMax = -1; // compute the new geocoord for each point for (int i = 0; i < points_.size(); i++) { float d = pow(delta[i].x(), 2) + pow(delta[i].y(), 2); if (d > dMax) { - dMax = d; + dMax = d; dMaxIndex = i; } QPointF scPos = mapToScene(points_[i]->pos() + delta[i]); QPointF gcPos; gcPos = points_[i]->computeGeoCoord(scPos); - //dataLayout_->mapFromSceneToGeoCoords(scPos, gcPos); + // dataLayout_->mapFromSceneToGeoCoords(scPos, gcPos); gc << gcPos; } @@ -2248,7 +2249,7 @@ for (int i = 0; i < points_.size(); i++) { if (points_[i] == p) { gc[i] = points_[i]->computeGeoCoord(); - idx = i; + idx = i; break; } } @@ -2268,8 +2269,8 @@ } else if (idx == 1) { firstChanged = true; - gc[0] = QPointF(gc[0].x(), gc[1].y()); - gc[2] = QPointF(gc[1].x(), gc[2].y()); + gc[0] = QPointF(gc[0].x(), gc[1].y()); + gc[2] = QPointF(gc[1].x(), gc[2].y()); } else if (idx == 2) { gc[3] = QPointF(gc[3].x(), gc[2].y()); @@ -2277,8 +2278,8 @@ } else if (idx == 3) { firstChanged = true; - gc[2] = QPointF(gc[2].x(), gc[3].y()); - gc[0] = QPointF(gc[3].x(), gc[0].y()); + gc[2] = QPointF(gc[2].x(), gc[3].y()); + gc[0] = QPointF(gc[3].x(), gc[0].y()); } // // generic case, used for resize // } else { @@ -2341,7 +2342,7 @@ pow(points_[i + 1]->pos().y() - points_[i]->pos().y(), 2)); sampleNum.push_back(std::max(5, static_cast(ds / sampleDs_))); #ifdef MVQFEATURECURVE_DEBUG_ - //qDebug() << "sampleNum" << sampleNum.back(); + // qDebug() << "sampleNum" << sampleNum.back(); #endif } } @@ -2364,7 +2365,7 @@ spline_ = SplineParam(xp, yp); size_t start = 0; - size_t num = xp.size() - 1; + size_t num = xp.size() - 1; if (closed_) { start = 1; num -= 1; @@ -2400,14 +2401,14 @@ { if (points_.size() >= 2) { if (before) { - int idx = 0; + int idx = 0; double t = 0.2; double x, y; spline_.eval(t, x, y); return points_[idx]->pos() + 2. * (points_[idx]->pos() - QPointF(x, y)); } else { - int idx = points_.size() - 1; + int idx = points_.size() - 1; double t = static_cast(idx) - 0.2; double x, y; spline_.eval(t, x, y); @@ -2442,12 +2443,12 @@ } spline_.eval(t, x, y); - return QPointF(x, y); + return {x, y}; } double MvQFeatureCurveItem::halo() const { - auto w = linePen_.width(); + auto w = linePen_.width(); double dw = (w <= 1) ? 0 : 1 + w / 2; return std::max(dw, symbolSize_.width() / 2.); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureCurveItem.h metview-5.19.2/metview/src/uPlot/MvQFeatureCurveItem.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureCurveItem.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureCurveItem.h 2023-07-15 08:28:47.000000000 +0000 @@ -146,7 +146,7 @@ virtual void buildShape(); void generateCurvePath(); virtual QPointF extrapolatePoint(bool before) const = 0; - virtual QPointF midPoint(int idx1, int idx2) const = 0; + virtual QPointF midPoint(int idx1, int idx2) const = 0; virtual void adjustPointsInResize(QList delta); virtual void adjustSelectorIfNeeded() const {} bool getRequestParameters() override; diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureFactory.cc metview-5.19.2/metview/src/uPlot/MvQFeatureFactory.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureFactory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureFactory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,7 +30,7 @@ Q_ASSERT(feature); MvQFeatureItemPtr item(nullptr); - auto type = feature->grItemType().toStdString(); + auto type = feature->grItemType().toStdString(); auto const it = makers->find(type); if (it != makers->end()) { item = (*it).second->make(feature); diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureFactory.h metview-5.19.2/metview/src/uPlot/MvQFeatureFactory.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureFactory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureFactory.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,7 +24,7 @@ MvQFeatureFactory(const std::string&); MvQFeatureFactory(const MvQFeatureFactory&) = delete; MvQFeatureFactory& operator=(const MvQFeatureFactory&) = delete; - virtual ~MvQFeatureFactory() = default; + virtual ~MvQFeatureFactory() = default; static MvQFeatureItemPtr create(WsType*); static MvQFeatureItemPtr create(const QJsonObject& d); diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureFrontItem.cc metview-5.19.2/metview/src/uPlot/MvQFeatureFrontItem.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureFrontItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureFrontItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,10 @@ #include "MvQMethods.h" #include "ObjectList.h" -static const std::string FCI_AT_THE_SURFACE = "SURFACE"; +static const std::string FCI_AT_THE_SURFACE = "SURFACE"; static const std::string FCI_ABOVE_THE_SURFACE = "UPPER"; -static const std::string FCI_FRONTOGENESIS = "FRONTOGENESIS"; -static const std::string FCI_FRONTOLYSIS = "FRONTOLYSIS"; +static const std::string FCI_FRONTOGENESIS = "FRONTOGENESIS"; +static const std::string FCI_FRONTOLYSIS = "FRONTOLYSIS"; //======================================== // @@ -30,13 +30,6 @@ // //======================================== -//MvQFeatureMetCurveItem::MvQFeatureMetCurveItem(const MvQFeatureMetCurveItem& o) : -// MvQFeatureCurveItem(o) -//{ -// front_type_ = o.front_type_; -// symbolSep_ = o.symbolSep_; -//} - MvQFeatureMetCurveItem::MvQFeatureMetCurveItem(WsType* feature) : MvQFeatureCurveItem(feature, false) { @@ -66,7 +59,7 @@ (const char*)req_("COLOUR")); // Set symbol parameters - symbolGap_ = (int)req_("SYMBOL_GAP"); + symbolGap_ = (int)req_("SYMBOL_GAP"); symbolWidth_ = (int)req_("SYMBOL_WIDTH"); symbolFacesLeft_ = (req_.getValue("SYMBOL_ORIENTATION", val, true) && val == "LEFT"); @@ -97,7 +90,7 @@ void MvQFeatureMetCurveItem::flipSymbolDirection() { - symbolFacesLeft_ = !symbolFacesLeft_; + symbolFacesLeft_ = !symbolFacesLeft_; req_("SYMBOL_ORIENTATION") = symbolFacesLeft_ ? "LEFT" : "RIGHT"; update(); } @@ -105,23 +98,23 @@ void MvQFeatureMetCurveItem::setFrontSubType(const std::string& subType) { if (subType == "surface") { - front_type_ = FCI_AT_THE_SURFACE; + front_type_ = FCI_AT_THE_SURFACE; req_("TYPE") = (const char*)FCI_AT_THE_SURFACE.c_str(); type_normal_ = true; } else if (subType == "upper") { - front_type_ = FCI_ABOVE_THE_SURFACE; + front_type_ = FCI_ABOVE_THE_SURFACE; req_("TYPE") = (const char*)FCI_ABOVE_THE_SURFACE.c_str(); type_normal_ = true; } else if (subType == "frontogenesis") { - front_type_ = FCI_FRONTOGENESIS; + front_type_ = FCI_FRONTOGENESIS; req_("TYPE") = (const char*)FCI_FRONTOGENESIS.c_str(); type_normal_ = false; makeCircle(symbolWidth_ / 4., 0., 8., symbolSep_); } else if (subType == "frontolysis") { - front_type_ = FCI_FRONTOLYSIS; + front_type_ = FCI_FRONTOLYSIS; req_("TYPE") = (const char*)FCI_FRONTOLYSIS.c_str(); type_normal_ = false; makeCross(symbolWidth_ / 4., symbolSep_); @@ -184,19 +177,19 @@ { // Orthogonal slope float offset = 0.01; // to avoid division by 0 - float slope = (p2.y() - p1.y() + offset) / (p2.x() - p1.x() + offset); + float slope = (p2.y() - p1.y() + offset) / (p2.x() - p1.x() + offset); float slope1 = -1 / slope; // Flag to rotate symbol - float an = atan2(p2.y() - p1.y() + offset, p2.x() - p1.x() + offset); + float an = atan2(p2.y() - p1.y() + offset, p2.x() - p1.x() + offset); float dirFactor = (symbolFacesLeft_) ? 1.0 : -1.0; - float signal = (an >= 0) ? -dirFactor : dirFactor; + float signal = (an >= 0) ? -dirFactor : dirFactor; // Line equation: Y = slope*X + b QPointF mpoint = (p1 + p2) / 2.; // middle point - float x = mpoint.x() + (signal * sqrt(pow(symbolWidth, 2) / + float x = mpoint.x() + (signal * sqrt(pow(symbolWidth, 2) / (1 + pow(slope1, 2)))); - float y = slope1 * (x - mpoint.x()) + mpoint.y(); + float y = slope1 * (x - mpoint.x()) + mpoint.y(); // Build symbol symb.clear(); @@ -216,19 +209,19 @@ float res, QVector& symb) { double radius = diameter / 2.; - double rs = radius * radius; + double rs = radius * radius; symb.clear(); for (double x = -radius; x <= radius; x += diameter / res) symb << QPointF(x + offsetX, sqrt(abs(rs - (x * x)))); - return QSizeF(diameter, radius); + return {diameter, radius}; } QSizeF MvQFeatureMetCurveItem::makeCircle(float diameter, float offsetX, float res, QVector& symb) { float radius = diameter / 2.; - float rs = radius * radius; + float rs = radius * radius; symb.clear(); for (double x = -radius; x <= radius; x += diameter / res) symb << QPointF(x + offsetX, sqrt(abs(rs - (x * x)))); @@ -236,7 +229,7 @@ for (double x = radius - (diameter / res); x >= -radius; x -= diameter / res) symb << QPointF(x + offsetX, -sqrt(abs(rs - (x * x)))); - return QSizeF(diameter, diameter); + return {diameter, diameter}; } void MvQFeatureMetCurveItem::makeHalfCircle(const QPointF& p1, @@ -270,7 +263,7 @@ symb << QPointF(-1, size); symb << QPointF(1, -size); - return QSizeF(size, size); + return {size, size}; } void MvQFeatureMetCurveItem::paintSeparator(QPainter* painter, @@ -427,7 +420,7 @@ void MvQFeatureMetCurveItem::init_line_segment() { - ds_ = 0.; + ds_ = 0.; ind_ = 0; } @@ -437,7 +430,7 @@ { float arclen, dist; startIndex_ = -1; - endIndex_ = -1; + endIndex_ = -1; while (ind_ < (static_cast(curveX_.size()) - 1)) { // get the arc length @@ -451,7 +444,7 @@ dist = 1. - ((ds_ - symbolGap) / arclen); linearInterpolation(ind_, dist, p1); startIndex_ = ind_; - ds_ = ds_ - symbolGap; + ds_ = ds_ - symbolGap; } } @@ -461,7 +454,7 @@ dist = 1. - ((ds_ - symbolWidth) / arclen); linearInterpolation(ind_, dist, p2); endIndex_ = ind_; - ds_ = ds_ - symbolWidth; + ds_ = ds_ - symbolWidth; } } @@ -511,7 +504,7 @@ // Draw line painter->setPen(linePen_); - //MvQ::drawPolyline(curveX_, curveY_, painter); + // MvQ::drawPolyline(curveX_, curveY_, painter); painter->drawPath(curvePath_); // Set paint parameters @@ -537,7 +530,7 @@ { // Draw curves, symbols and separators bool first_symbol = true; - int iStart1, iEnd1; + int iStart1 = 0, iEnd1 = 0; float segSize = 1.5; // small segment before semi-circle and after triangle QPointF p1, p2, pStart1, pEnd1, pStart2, pEnd2; QPointF pSep1, pSep2; @@ -557,7 +550,7 @@ return; iStart1 = startIndex_; - iEnd1 = endIndex_; + iEnd1 = endIndex_; // Create symbol if (!compute_next_line_segment(p1, p2, symbolWidth_, 0.)) @@ -758,7 +751,7 @@ { // Draw curves, symbols and separators bool first_symbol = true; - int iStart1, iEnd1; + int iStart1 = 0, iEnd1 = 0; float segSize = 1.5; // small segment before semi-circle and after triangle QPointF p1, p2, pStart1, pEnd1, pStart2, pEnd2; QPointF pSep1, pSep2; @@ -776,14 +769,14 @@ return; iStart1 = startIndex_; - iEnd1 = endIndex_; + iEnd1 = endIndex_; // Create half-circle if (!compute_next_line_segment(p1, p2, symbolWidth_, 0.)) return; makeHalfCircle(p1, p2, true, hs); - pEnd1 = p1; // adjust point + pEnd1 = p1; // adjust point QPointF p22 = p2; // to adjust the first point of the triangle // Create triangle @@ -845,8 +838,8 @@ (const char*)req_("WARM_COLOUR")); // Set symbol parameters - symbolGap_ = (int)req_("SYMBOL_GAP"); - symbolWidth_ = (int)req_("SYMBOL_WIDTH"); + symbolGap_ = (int)req_("SYMBOL_GAP"); + symbolWidth_ = (int)req_("SYMBOL_WIDTH"); symbolFacesLeft_ = (req_.getValue("SYMBOL_ORIENTATION", val, true) && val == "LEFT"); symbolBrushTr_ = MvQ::makeBrush("SOLID", (const char*)req_("COLD_COLOUR")); @@ -890,7 +883,7 @@ { // Draw curves and symbols bool first_symbol = true; - int iStart1, iEnd1; + int iStart1 = 0, iEnd1 = 0; float segSize = symbolGap_ / 2.; // half size each: semi-circle and triangle QPointF p1, p2, pStart1, pEnd1, pStart2, pEnd2; QVector hs, tr; @@ -902,7 +895,7 @@ // Adjust initial point (it has to be equal to the previous point) iStart1 = startIndex_; - iEnd1 = endIndex_; + iEnd1 = endIndex_; if (first_symbol) first_symbol = false; else @@ -913,14 +906,14 @@ return; makeHalfCircle(p1, p2, true, hs); - pEnd1 = p1; // adjust point + pEnd1 = p1; // adjust point QPointF p22 = p2; // to adjust the first point of the triangle // Create triangle if (!compute_next_line_segment(p1, p2, symbolWidth_, 0.)) return; - p1 = p22; // adjust point + p1 = p22; // adjust point symbolFacesLeft_ = !symbolFacesLeft_; makeTriangle(p1, p2, symbolWidth_, true, tr); symbolFacesLeft_ = !symbolFacesLeft_; @@ -958,9 +951,9 @@ void MvQFeatureQuasiStationaryItem::paint_fronto(QPainter* painter) { // Draw curves, symbols and separators - bool colourTag = true; + bool colourTag = true; bool first_symbol = true; - int iStart1, iEnd1; + int iStart1 = 0, iEnd1 = 0; float segSize = 1.5; // small segment before semi-circle and after triangle QPointF p1, p2, pStart1, pEnd1, pStart2, pEnd2; QPointF pSep1, pSep2; @@ -978,21 +971,21 @@ return; iStart1 = startIndex_; - iEnd1 = endIndex_; + iEnd1 = endIndex_; // Create half-circle if (!compute_next_line_segment(p1, p2, symbolWidth_, 0.)) return; makeHalfCircle(p1, p2, true, hs); - pEnd1 = p1; // adjust point + pEnd1 = p1; // adjust point QPointF p22 = p2; // to adjust the first point of the triangle // Create triangle if (!compute_next_line_segment(p1, p2, symbolWidth_, 0.)) return; - p1 = p22; // adjust point + p1 = p22; // adjust point symbolFacesLeft_ = !symbolFacesLeft_; makeTriangle(p1, p2, symbolWidth_, true, tr); symbolFacesLeft_ = !symbolFacesLeft_; @@ -1039,7 +1032,7 @@ MvQFeatureRidgeItem::MvQFeatureRidgeItem(WsType* feature) : MvQFeatureMetCurveItem(feature) { - front_type_ = "RIDGE"; + front_type_ = "RIDGE"; type_normal_ = true; } @@ -1059,7 +1052,7 @@ (const char*)req_("COLOUR")); // Set symbol parameters - symbolGap_ = 0.; + symbolGap_ = 0.; symbolFacesLeft_ = (req_.getValue("SYMBOL_ORIENTATION", val, true) && val == "LEFT"); symbolBrush_ = MvQ::makeBrush("SOLID", (const char*)req_("COLOUR")); @@ -1132,7 +1125,7 @@ (const char*)req_("COLOUR_2")); // Set symbol parameters - symbolGap_ = (int)req_("SYMBOL_GAP"); + symbolGap_ = (int)req_("SYMBOL_GAP"); symbolWidth_ = (int)req_("SYMBOL_WIDTH"); return true; @@ -1191,8 +1184,8 @@ (const char*)req_("COLOUR")); // Set symbol parameters - symbolGap_ = (int)req_("SYMBOL_GAP"); - symbolWidth_ = (int)req_("SYMBOL_WIDTH"); + symbolGap_ = (int)req_("SYMBOL_GAP"); + symbolWidth_ = (int)req_("SYMBOL_WIDTH"); symbolFacesLeft_ = (req_.getValue("SYMBOL_ORIENTATION", val, true) && val == "LEFT"); return true; @@ -1264,11 +1257,11 @@ { } -//MvQFeatureInstabilityShearLineItem::MvQFeatureInstabilityShearLineItem(const MvQFeatureInstabilityShearLineItem& o) : -// MvQFeatureMetCurveItem(o) +// MvQFeatureInstabilityShearLineItem::MvQFeatureInstabilityShearLineItem(const MvQFeatureInstabilityShearLineItem& o) : +// MvQFeatureMetCurveItem(o) //{ -// bShear_ = o.bShear_; -//} +// bShear_ = o.bShear_; +// } bool MvQFeatureInstabilityShearLineItem::getRequestParameters() { @@ -1284,10 +1277,10 @@ (const char*)req_("COLOUR")); // Set symbol parameters - symbolGap_ = (int)req_("LINE_GAP"); + symbolGap_ = (int)req_("LINE_GAP"); symbolWidth_ = (int)req_("LINE_LENGTH"); symbolBrush_ = MvQ::makeBrush("SOLID", (const char*)req_("COLOUR")); - diameter_ = (double)req_("CIRCLE_DIAMETER"); + diameter_ = (double)req_("CIRCLE_DIAMETER"); return true; } @@ -1383,12 +1376,12 @@ // Get input parameters // Set line parameters thickness_ = (int)req_("LINE_THICKNESS"); - linePen_ = MvQ::makePen("SOLID", thickness_, + linePen_ = MvQ::makePen("SOLID", thickness_, (const char*)req_("COLOUR")); // Get other parameters - width_ = (int)req_("WIDTH"); - intensity_ = (int)req_("INTENSITY"); + width_ = (int)req_("WIDTH"); + intensity_ = (int)req_("INTENSITY"); intensityGap_ = (int)req_("INTENSITY_GAP"); return true; @@ -1486,16 +1479,16 @@ vec_d /= sqrt(pow(vec_d.x(), 2) + pow(vec_d.y(), 2)); // normal vectors - auto vec_n_left = QPointF(-vec_d.y(), vec_d.x()); + auto vec_n_left = QPointF(-vec_d.y(), vec_d.x()); auto vec_n_right = QPointF(vec_d.y(), -vec_d.x()); // compute orthogonal line (line equation = y = mx + b) - float delta = 0.01; // to avoid division by 0 - auto p = p1 + ((p2 - p1) * offset); - QPointF pleft = p + width_ * vec_n_left; + float delta = 0.01; // to avoid division by 0 + auto p = p1 + ((p2 - p1) * offset); + QPointF pleft = p + width_ * vec_n_left; QPointF pright = p + width_ * vec_n_right; - float m = (pleft.y() - pright.y() + delta) / (pleft.x() - pright.x() + delta); - float b = pright.y() - (m * pright.x()); + float m = (pleft.y() - pright.y() + delta) / (pleft.x() - pright.x() + delta); + float b = pright.y() - (m * pright.x()); // B) Find the crossing points between the orthogonal lines and the // two parallels lines @@ -1548,7 +1541,7 @@ // Search the two neighbour points bool firsta = true; bool firstb = true; - bool found = false; + bool found = false; for (int j = index; j < vp.size(); j++) { if (vp[j].y() > ((vp[j].x() * slope) + b)) { if (firsta) diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureFrontItem.h metview-5.19.2/metview/src/uPlot/MvQFeatureFrontItem.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureFrontItem.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureFrontItem.h 2023-07-15 08:28:47.000000000 +0000 @@ -57,7 +57,7 @@ bool type_normal_{true}; bool symbolFacesLeft_{true}; - float symbolGap_; //pixels + float symbolGap_{0.}; // pixels QVector symbolSep_; // symbol separator int ind_{0}; // curve index diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureFwd.h metview-5.19.2/metview/src/uPlot/MvQFeatureFwd.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureFwd.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureFwd.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ #include class MvQFeatureItem; -using MvQFeatureItemPtr = std::shared_ptr; +using MvQFeatureItemPtr = std::shared_ptr; using MvQFeatureItemList = QList; class MvQFeatureTextItem; diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureImageItem.cc metview-5.19.2/metview/src/uPlot/MvQFeatureImageItem.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureImageItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureImageItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ #include "FontMetrics.h" -#include +#include //#define MVQFEATUREICON_DEBUG_ @@ -54,20 +54,21 @@ // the default size if (s.isEmpty() || s.width() == s.height()) { updateRect(30, 30); - } else { - Q_ASSERT(s.width()>=0); + } + else { + Q_ASSERT(s.width() >= 0); square_ = false; - hwRatio_ = static_cast(s.height())/static_cast(s.width()); - updateRect(30, 30.*hwRatio_); + hwRatio_ = static_cast(s.height()) / static_cast(s.width()); + updateRect(30, 30. * hwRatio_); } } void MvQFeatureImageItem::init(const QJsonObject& obj) { QJsonObject g = obj["geometry"].toObject(); - auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); + auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); if (!gcLst.isEmpty()) { - geoCoord_ = gcLst[0]; + geoCoord_ = gcLst[0]; hasValidGeoCoord_ = isValidPoint(geoCoord_); } else { @@ -114,8 +115,8 @@ // reduce the targetRect with the halo. We want to fit the itemRect into it!!! targetRect.adjust(halo(), halo(), -halo(), -halo()); - auto w = targetRect.width(); - auto h = targetRect.height(); + auto w = targetRect.width(); + auto h = targetRect.height(); itemRect_ = QRectF(-w / 2., -h / 2., w, h); #ifdef MVQFEATUREICON_DEBUG_ qDebug() << " -> itemRect:" << itemRect_ << "targetRect:" << targetRect; @@ -133,7 +134,7 @@ prepareGeometryChange(); setPos(geom.pos_); itemRect_ = geom.itemRect_; - bRect_ = itemRect_; + bRect_ = itemRect_; makePixmap(); adjustBRect(); adjustGeoCoord(); @@ -150,7 +151,7 @@ { prepareGeometryChange(); itemRect_ = QRectF(-width / 2., -height / 2., width, height); - bRect_ = itemRect_; + bRect_ = itemRect_; } void MvQFeatureImageItem::adjustBRect() @@ -198,8 +199,9 @@ if (iv > 0 && iv != static_cast(itemRect_.width())) { if (square_) { updateRect(iv, iv); - } else { - updateRect(iv, iv*hwRatio_); + } + else { + updateRect(iv, iv * hwRatio_); } } @@ -224,7 +226,7 @@ bool MvQFeatureCharImageItem::getRequestParameters() { -// MvLog().dbg() << MV_FN_INFO; + // MvLog().dbg() << MV_FN_INFO; Q_ASSERT(square_); @@ -241,7 +243,7 @@ // letter req_.getValue("CHARACTER", val); -// MvLog().dbg() << "letter=" << val; + // MvLog().dbg() << "letter=" << val; if (!val.empty()) { auto letter = QString::fromStdString(val).simplified(); if (letter.size() >= 0 && letter_ != letter[0]) { diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureItem.cc metview-5.19.2/metview/src/uPlot/MvQFeatureItem.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -150,7 +150,7 @@ MvQJson::toRequest(prop["style"].toObject(), r); if (r) { const char* verbRef = req_.getVerb(); - const char* verb = r.getVerb(); + const char* verb = r.getVerb(); if (verb && ((verbRef && strcmp(verb, verbRef) == 0) || strlen(verb) > 0)) { req_ = r; } @@ -242,11 +242,11 @@ if (dataLayout_) { if (init) { - outOfView_ = true; + outOfView_ = true; hasValidGeoCoord_ = false; if (isValidPoint(geoCoord_)) { hasValidGeoCoord_ = true; - outOfView_ = !dataLayout_->containsGeoCoords(geoCoord_); + outOfView_ = !dataLayout_->containsGeoCoords(geoCoord_); } } else if (hasValidGeoCoord_) { @@ -275,7 +275,7 @@ } } - outOfView_ = true; + outOfView_ = true; hasValidGeoCoord_ = false; show(); } @@ -285,11 +285,11 @@ { dataLayout_ = dataLayout; sceneId_.clear(); - outOfView_ = true; + outOfView_ = true; hasValidGeoCoord_ = false; inspectProjection(); if (dataLayout_) { - sceneId_ = dataLayout_->layout().id(); + sceneId_ = dataLayout_->layout().id(); QPointF scPosA = scPos; if (dataLayout_->containsSceneCoords(scPosA)) { outOfView_ = false; @@ -312,7 +312,7 @@ void MvQFeatureItem::initAtGeoCoord(QPointF geoCoord) { - geoCoord_ = geoCoord; + geoCoord_ = geoCoord; hasValidGeoCoord_ = isValidPoint(geoCoord_); if (dataLayout_ && hasValidGeoCoord_) { QPointF scPos; @@ -371,20 +371,20 @@ void MvQFeatureItem::checkLayoutOnMove() { MgQLayoutItem* layoutItem = nullptr; - QPointF scPos = parentItem()->mapToScene(pos()); + QPointF scPos = parentItem()->mapToScene(pos()); MvQFeatureHandler::Instance()->currentLayout(getptr(), &layoutItem); if (layoutItem) { if (layoutItem == dataLayout_) { if (outOfView_) { dataLayout_->mapFromSceneToGeoCoords(scPos, geoCoord_); if (isValidPoint(geoCoord_) && dataLayout_->containsGeoCoords(geoCoord_)) { - outOfView_ = false; + outOfView_ = false; hasValidGeoCoord_ = true; } } else { if (!isValidPoint(geoCoord_) || !dataLayout_->containsGeoCoords(geoCoord_)) { - outOfView_ = true; + outOfView_ = true; hasValidGeoCoord_ = !isValidPoint(geoCoord_); } } @@ -397,7 +397,7 @@ } else { if (!outOfView_) { - outOfView_ = true; + outOfView_ = true; hasValidGeoCoord_ = !isValidPoint(geoCoord_); } } @@ -423,7 +423,7 @@ << " event.pos:" << event->pos() << " event.pos(parent):" << mapToParent(event->pos()) << "typeName:" << typeName() << "isSelected:" << isSelected() << this; qDebug() << " zValue" << zValue(); #endif - dragPos_ = mapToParent(event->pos()); + dragPos_ = mapToParent(event->pos()); lastPressedPos_ = event->pos(); // this will make the item selected, and the selector will be notified QGraphicsItem::mousePressEvent(event); @@ -440,7 +440,7 @@ Q_ASSERT(!isPoint()); if (!isGeoLocked()) { auto evtPos = mapToParent(event->pos()); - auto delta = evtPos - dragPos_; + auto delta = evtPos - dragPos_; moveBy(delta); dragPos_ += delta; } @@ -477,7 +477,7 @@ QVariant MvQFeatureItem::itemChange(GraphicsItemChange change, const QVariant& value) { if (change == ItemSelectedHasChanged) { - //qDebug() << "MvQFeatureItem::itemChange" << typeName_ << isSelected() << this; + // qDebug() << "MvQFeatureItem::itemChange" << typeName_ << isSelected() << this; plotView_->itemSelected(this); return value; } @@ -525,7 +525,7 @@ // input rects are in parent's coordinates QRectF MvQFeatureItem::rectToSelector(QRectF rectNew, QRectF rectOri) { - //QRectF r = mapToParent(itemRect()).boundingRect(); + // QRectF r = mapToParent(itemRect()).boundingRect(); QRectF r = mapRectToParent(boundingRect()); #ifdef MVQFEATUREITEM_DEBUG_ @@ -535,11 +535,11 @@ if (keepAspectRatio_) { float hFactor = rectNew.height() / rectOri.height(); float wFactor = rectNew.width() / rectOri.width(); - float factor = std::min(hFactor, wFactor); + float factor = std::min(hFactor, wFactor); auto ratio = r.height() / r.width(); - auto w = factor * r.width(); //rectNew.width(); - auto h = w * ratio; + auto w = factor * r.width(); // rectNew.width(); + auto h = w * ratio; #ifdef MVQFEATUREITEM_DEBUG_ qDebug() << " ratio:" << ratio << "w:" << w << "h:" << h; #endif @@ -548,9 +548,9 @@ // w = h/ratio; // } - float top = rectNew.top() + (r.top() - rectOri.top()) * hFactor; + float top = rectNew.top() + (r.top() - rectOri.top()) * hFactor; float left = rectNew.left() + (r.left() - rectOri.left()) * wFactor; - auto a = QRectF(left, top, w, h); + auto a = QRectF(left, top, w, h); #ifdef MVQFEATUREITEM_DEBUG_ qDebug() << " ratio:" << ratio << "w:" << w << "h:" << h; qDebug() << " result:" << a; @@ -566,10 +566,10 @@ float wRatio = rectNew.width() / rectOri.width(); // see note about QRectF.right() and bottom() in the Qt docs! - float top = rectNew.top() + (r.top() - rectOri.top()) * hRatio; + float top = rectNew.top() + (r.top() - rectOri.top()) * hRatio; float bottom = rectNew.y() + rectNew.height() - (rectOri.bottom() - r.bottom()) * hRatio; - float left = rectNew.left() + (r.left() - rectOri.left()) * wRatio; - float right = rectNew.x() + rectNew.width() - (rectOri.right() - r.right()) * wRatio; + float left = rectNew.left() + (r.left() - rectOri.left()) * wRatio; + float right = rectNew.x() + rectNew.width() - (rectOri.right() - r.right()) * wRatio; auto a = QRectF(left, top, right - left, bottom - top); #ifdef MVQFEATUREITEM_DEBUG_ @@ -611,8 +611,8 @@ void MvQFeatureItem::styleEdited(MvRequest& req) { if (plotView_) { - auto *w = plotView_->window(); - if(w) { + auto* w = plotView_->window(); + if (w) { w->raise(); } } @@ -696,7 +696,7 @@ void MvQFeatureItem::adjustGeoLocked() { const char* ch = req_("GEOLOCK"); - geoLocked_ = ch && strcmp(ch, "ON") == 0; + geoLocked_ = ch && strcmp(ch, "ON") == 0; } double MvQFeatureItem::realZValue() const @@ -722,15 +722,15 @@ QSizeF MvQFeatureItem::minSize() const { - return QSizeF(8 + 2. * halo(), 8 + 2. * halo()); + return {8 + 2. * halo(), 8 + 2. * halo()}; } MvQFeatureGeometry MvQFeatureItem::getGeometry() const { MvQFeatureGeometry g; - g.bRect_ = bRect_; + g.bRect_ = bRect_; g.itemRect_ = itemRect_; - g.pos_ = pos(); + g.pos_ = pos(); g.geoCoord_ = g.geoCoord_; return g; } diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureItem.h metview-5.19.2/metview/src/uPlot/MvQFeatureItem.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureItem.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureItem.h 2023-07-15 08:28:47.000000000 +0000 @@ -110,7 +110,7 @@ // One exception is the control points of curve objects. They are only used internally in the // parent curve so for simplicity we only create and use raw pointers to them. - virtual ~MvQFeatureItem(); + ~MvQFeatureItem() override; MvQFeatureItem(const MvQFeatureItem&) = delete; MvQFeatureItem& operator=(const MvQFeatureItem&) = delete; @@ -151,7 +151,7 @@ virtual void moveBy(QPointF); virtual void moveTo(const MvQFeatureGeometry&); - virtual void resize(QRectF rect) = 0; + virtual void resize(QRectF rect) = 0; virtual void resizeTo(const MvQFeatureGeometry&) = 0; void adjustSizeToSelector(QRectF rectNew, QRectF rectOri); virtual void resizeFinished() {} diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureRibbonEditor.cc metview-5.19.2/metview/src/uPlot/MvQFeatureRibbonEditor.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureRibbonEditor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureRibbonEditor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -51,7 +51,7 @@ RibbonItemFactory(const std::string& name); RibbonItemFactory(const RibbonItemFactory&) = delete; RibbonItemFactory& operator=(const RibbonItemFactory&) = delete; - virtual ~RibbonItemFactory() = default; + virtual ~RibbonItemFactory() = default; virtual RibbonEditItem* make(const MvIconParameter& param, QLayout* layout, QWidget* parent, QString typeKey) = 0; static RibbonEditItem* create(const std::string& name, const MvIconParameter& param, QLayout* layout, QWidget* parent, QString typeKey); @@ -87,7 +87,7 @@ RibbonEditItem* RibbonItemFactory::create(const std::string& name, const MvIconParameter& param, QLayout* layout, QWidget* parent, QString typeKey) { RibbonEditItem* cmd = nullptr; - auto it = makers->find(name); + auto it = makers->find(name); if (it == makers->end()) { } else { @@ -128,7 +128,7 @@ font = QFont(); font.setPointSize(font.pointSize() - 1); auto fm = QFontMetrics(font); - h = fm.height() + 4; + h = fm.height() + 4; } //============================================= @@ -148,7 +148,7 @@ param_.scan(*this); Q_ASSERT(values_.count() == 2); if (values_[0] != "ON") { - onIndex_ = 1; + onIndex_ = true; } layout_->addWidget(tb_); @@ -186,7 +186,7 @@ std::string v; req.getValue(param_.name(), v, true); QString s = QString::fromStdString(v); - int idx = values_.indexOf(s); + int idx = values_.indexOf(s); if (idx != -1) { index_ = idx; } @@ -231,9 +231,9 @@ RibbonControlItem(param, layout, parent, typeKey) { QIcon ic(QPixmap(":uPlot/pen.svg")); - //ic.addPixmap(QPixmap(":uPlot/pen_off.svg"),QIcon::Normal,QIcon::On); + // ic.addPixmap(QPixmap(":uPlot/pen_off.svg"),QIcon::Normal,QIcon::On); tb_->setIcon(ic); - tooltipChecked_ = "Click to disable outline"; + tooltipChecked_ = "Click to disable outline"; tooltipUnchecked_ = "Click to enable outline"; tb_->setToolTip(tooltipUnchecked_); } @@ -242,10 +242,10 @@ RibbonControlItem(param, layout, parent, typeKey) { QIcon ic(QPixmap(":uPlot/paintcan.svg")); - //ic.addPixmap(QPixmap(":uPlot/paintcan_off.svg"),QIcon::Normal,QIcon::On); + // ic.addPixmap(QPixmap(":uPlot/paintcan_off.svg"),QIcon::Normal,QIcon::On); tb_->setIcon(ic); - tooltipChecked_ = "Click to disable fill"; + tooltipChecked_ = "Click to disable fill"; tooltipUnchecked_ = "Click to enable fill"; tb_->setToolTip(tooltipUnchecked_); } @@ -307,7 +307,7 @@ std::string v; req.getValue(param_.name(), v, true); QString s = QString::fromStdString(v); - int idx = values_.indexOf(s); + int idx = values_.indexOf(s); if (idx != -1) { index_ = idx; } @@ -336,7 +336,7 @@ const char* ch = param_.ribbon_size_range(); int m1 = 1, m2 = 100; // default range if (ch) { - auto s = QString(ch); + auto s = QString(ch); auto lst = s.split(":"); if (lst.size() == 2) { m1 = lst[0].toInt(); @@ -351,7 +351,7 @@ layout_->addWidget(spin_); QFont f; - int h; + int h = 0; fixedFontAndHeight(f, h); spin_->setFont(f); if (label_) { @@ -422,10 +422,10 @@ layout_->addWidget(cb_); QFont f; - int h; + int h = 0; fixedFontAndHeight(f, h); cb_->setFont(f); - //cb_->setFixedHeight(h); + // cb_->setFixedHeight(h); connect(cb_, SIGNAL(currentTextChanged(QString)), this, SLOT(valueChanged(QString))); @@ -469,7 +469,7 @@ ignoreChange_ = true; std::string v; req.getValue(param_.name(), v, true); - QString s = QString::fromStdString(v); + QString s = QString::fromStdString(v); bool found = false; for (int i = 0; i < cb_->count(); i++) { if (cb_->itemData(i).toString() == s) { @@ -488,14 +488,14 @@ { int ref = s.toInt(); if (ref > 0) { - int d = 10000; + int d = 10000; int idx = -1; for (int i = 0; i < cb_->count(); i++) { int v = cb_->itemData(i).toString().toInt(); if (v > 0) { auto dAct = abs(v - ref); if (dAct < d) { - d = dAct; + d = dAct; idx = i; } } @@ -555,7 +555,7 @@ RibbonFontStyleItem::RibbonFontStyleItem(const MvIconParameter& param, QLayout* layout, QWidget* parent, QString typeKey) : RibbonEditItem(param, layout, parent, typeKey) { - auto w = new QWidget(parent); + auto w = new QWidget(parent); auto hb = new QHBoxLayout(w); hb->setContentsMargins(0, 0, 0, 0); hb->setSpacing(0); @@ -642,7 +642,7 @@ RibbonTextAlignmentItem::RibbonTextAlignmentItem(const MvIconParameter& param, QLayout* layout, QWidget* parent, QString typeKey) : RibbonEditItem(param, layout, parent, typeKey) { - auto w = new QWidget(parent); + auto w = new QWidget(parent); auto hb = new QHBoxLayout(w); hb->setContentsMargins(0, 0, 0, 0); hb->setSpacing(0); @@ -693,7 +693,7 @@ std::string v; req.getValue(param_.name(), v, true); QString sv = QString::fromStdString(v); - int idx = keys_.indexOf(sv); + int idx = keys_.indexOf(sv); if (idx != -1) { auto b = bGroup_->button(idx); if (b) { @@ -707,7 +707,7 @@ { int i = bGroup_->checkedId(); if (i >= 0 && i < keys_.size()) { - std::string v = keys_[i].toStdString(); + std::string v = keys_[i].toStdString(); req(param_.name()) = v.c_str(); } } @@ -723,7 +723,7 @@ RibbonComboBoxItem(param, layout, parent, typeKey) { QFont f; - int h; + int h = 0; fixedFontAndHeight(f, h); cb_->setFont(f); cb_->setIconSize(QSize(60, h - 4)); @@ -741,7 +741,7 @@ for (int i = 0; i < cb_->count(); i++) { auto style = cb_->itemData(i).toString().toLower(); - auto pix = QPixmap(cb_->iconSize()); + auto pix = QPixmap(cb_->iconSize()); pix.fill(Qt::transparent); auto it = lineStyleDef.find(style); if (it != lineStyleDef.end()) { @@ -754,9 +754,9 @@ void RibbonLineStyleItem::renderLine(QPixmap* pix, Qt::PenStyle penStyle) { - int margin = 4; - auto h = pix->height(); - auto w = pix->width(); + int margin = 4; + auto h = pix->height(); + auto w = pix->width(); auto painter = QPainter(pix); painter.setPen(QPen(MvQTheme::colour("uplot", "ribbon_pen"), 2, penStyle)); painter.drawLine(margin, h / 2, w - margin, h / 2); @@ -773,7 +773,7 @@ { useClosest_ = true; QFont f; - int h; + int h = 0; fixedFontAndHeight(f, h); cb_->setFont(f); cb_->setIconSize(QSize(60, h - 4)); @@ -788,7 +788,7 @@ void RibbonLineWidthItem::loadPixmaps() { for (int i = 0; i < cb_->count(); i++) { - auto lw = cb_->itemData(i).toInt(); + auto lw = cb_->itemData(i).toInt(); auto pix = QPixmap(cb_->iconSize()); pix.fill(Qt::transparent); renderLine(&pix, lw); @@ -798,9 +798,9 @@ void RibbonLineWidthItem::renderLine(QPixmap* pix, int lw) { - int margin = 4; - auto h = pix->height(); - auto w = pix->width(); + int margin = 4; + auto h = pix->height(); + auto w = pix->width(); auto painter = QPainter(pix); painter.setPen(QPen(MvQTheme::colour("uplot", "ribbon_pen"), lw)); painter.drawLine(margin, h / 2, w - margin, h / 2); @@ -818,7 +818,7 @@ start_(start) { QFont f; - int h; + int h = 0; fixedFontAndHeight(f, h); cb_->setFont(f); cb_->setIconSize(QSize(35, h - 4)); @@ -829,7 +829,7 @@ { for (int i = 0; i < cb_->count(); i++) { auto style = cb_->itemData(i).toString().toLower(); - auto pix = QPixmap(cb_->iconSize()); + auto pix = QPixmap(cb_->iconSize()); pix.fill(Qt::transparent); renderLine(&pix, style); cb_->setItemIcon(i, QIcon(pix)); @@ -839,9 +839,9 @@ void RibbonLineStartEndItem::renderLine(QPixmap* pix, QString style) { - int margin = 4; - auto h = pix->height(); - auto w = pix->width(); + int margin = 4; + auto h = pix->height(); + auto w = pix->width(); auto painter = QPainter(pix); painter.setPen(QPen(MvQTheme::colour("uplot", "ribbon_pen"), 2)); float xp = w - margin; @@ -936,7 +936,7 @@ void RibbonColourItem::updateRequest(MvRequest& req) { - auto s = MvQPalette::toString(colour_); + auto s = MvQPalette::toString(colour_); req(param_.name()) = s.c_str(); } @@ -960,16 +960,16 @@ void RibbonColourItem::updatePixmap() { - int id = IconProvider::add(":/uPlot/pen.svg", "pen"); + int id = IconProvider::add(":/uPlot/pen.svg", "pen"); auto base = IconProvider::pixmap(id, 18); int w = 24; - pix_ = QPixmap(w, w); + pix_ = QPixmap(w, w); pix_.fill(Qt::transparent); - //pix_.fill(Qt::white); + // pix_.fill(Qt::white); QPainter p(&pix_); - //p.drawPixmap(3,1, base); - //QRect r(2, 18, w-4, 6); + // p.drawPixmap(3,1, base); + // QRect r(2, 18, w-4, 6); QRect r(4, 4, w - 8, w - 8); p.fillRect(r, colour_); tb_->setIcon(QIcon(pix_)); @@ -992,13 +992,13 @@ auto basePix = IconProvider::pixmap(basePixId_, 18); int w = 24; - pix_ = QPixmap(w, w); + pix_ = QPixmap(w, w); pix_.fill(Qt::transparent); - //pix_.fill(Qt::white); + // pix_.fill(Qt::white); QPainter p(&pix_); p.drawPixmap(3, 1, basePix); QRect r(2, 18, w - 4, 6); - //QRect r(4, 4, w-8, w-8); + // QRect r(4, 4, w-8, w-8); p.fillRect(r, colour_); tb_->setIcon(QIcon(pix_)); } @@ -1208,7 +1208,7 @@ layout_->setSpacing(2); QFont f; - int h; + int h = 0; RibbonEditItem::fixedFontAndHeight(f, h); setFont(f); setFixedHeight(h + 6); @@ -1296,7 +1296,7 @@ void MvQFeatureRibbonEditor::clearItems() { - QLayoutItem* child; + QLayoutItem* child = nullptr; while ((child = layout_->takeAt(0)) != nullptr) { delete child->widget(); delete child; @@ -1331,7 +1331,7 @@ void MvQFeatureRibbonEditor::next(const MvIconParameter& p) { if (const char* ch = p.ribbon_interface()) { - //qDebug() << " ribbon ->" << c; + // qDebug() << " ribbon ->" << c; std::string rt(ch); addItem(rt, p); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureRibbonEditor.h metview-5.19.2/metview/src/uPlot/MvQFeatureRibbonEditor.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureRibbonEditor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureRibbonEditor.h 2023-07-15 08:28:47.000000000 +0000 @@ -41,10 +41,10 @@ public: RibbonEditItem(const MvIconParameter& param, QLayout* layout, QWidget* parent, QString typeKey); - virtual ~RibbonEditItem() = default; + ~RibbonEditItem() override = default; virtual void setValue(const MvRequest& req) = 0; - virtual void updateRequest(MvRequest& req) = 0; + virtual void updateRequest(MvRequest& req) = 0; virtual void setControlParam(const std::string& rc) { controlParam_ = rc; } virtual void grey(bool) = 0; QString paramName() const { return name_; } @@ -351,7 +351,7 @@ Q_OBJECT public: MvQFeatureRibbonEditor(QWidget* parent); - ~MvQFeatureRibbonEditor(); + ~MvQFeatureRibbonEditor() override; void next(const MvIconParameter& p) override; void edit(MvQFeatureItemPtr feature); diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureSelector.cc metview-5.19.2/metview/src/uPlot/MvQFeatureSelector.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureSelector.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureSelector.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,20 +43,20 @@ public: MvQFeatureSelectorPoint(MvQFeatureSelector*, QString pixName, QString hoverPixName, double xDeltaFactor, double yDeltaFactor); - QRectF boundingRect() const; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); + QRectF boundingRect() const override; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; virtual void updatePosition() = 0; protected: - QVariant itemChange(GraphicsItemChange, const QVariant&); - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseMoveEvent(QGraphicsSceneMouseEvent*); - void mouseReleaseEvent(QGraphicsSceneMouseEvent*); - void hoverEnterEvent(QGraphicsSceneHoverEvent*); - void hoverLeaveEvent(QGraphicsSceneHoverEvent*); + QVariant itemChange(GraphicsItemChange, const QVariant&) override; + void mousePressEvent(QGraphicsSceneMouseEvent*) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent*) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override; + void hoverEnterEvent(QGraphicsSceneHoverEvent*) override; + void hoverLeaveEvent(QGraphicsSceneHoverEvent*) override; virtual void handleMouseMove(QPointF ep, QRectF& r) = 0; - MvQFeatureSelector* selector_; + MvQFeatureSelector* selector_{nullptr}; QRectF bRect_; bool hover_{false}; QBrush brush_; @@ -69,81 +69,105 @@ class MvQTopLeftFeatureSelectorPoint : public MvQFeatureSelectorPoint { public: - MvQTopLeftFeatureSelectorPoint(MvQFeatureSelector*); - void updatePosition() override; + explicit MvQTopLeftFeatureSelectorPoint(MvQFeatureSelector*); + void updatePosition() override { updatePositionInternal(); } protected: void handleMouseMove(QPointF ep, QRectF& r) override; + +private: + void updatePositionInternal(); }; class MvQTopMidFeatureSelectorPoint : public MvQFeatureSelectorPoint { public: - MvQTopMidFeatureSelectorPoint(MvQFeatureSelector*); - void updatePosition() override; + explicit MvQTopMidFeatureSelectorPoint(MvQFeatureSelector*); + void updatePosition() override { updatePositionInternal(); } protected: void handleMouseMove(QPointF ep, QRectF& r) override; + +private: + void updatePositionInternal(); }; class MvQTopRightFeatureSelectorPoint : public MvQFeatureSelectorPoint { public: - MvQTopRightFeatureSelectorPoint(MvQFeatureSelector*); - void updatePosition() override; + explicit MvQTopRightFeatureSelectorPoint(MvQFeatureSelector*); + void updatePosition() override { updatePositionInternal(); } protected: void handleMouseMove(QPointF ep, QRectF& r) override; + +private: + void updatePositionInternal(); }; class MvQRightMidFeatureSelectorPoint : public MvQFeatureSelectorPoint { public: - MvQRightMidFeatureSelectorPoint(MvQFeatureSelector*); - void updatePosition() override; + explicit MvQRightMidFeatureSelectorPoint(MvQFeatureSelector*); + void updatePosition() override { updatePositionInternal(); } protected: void handleMouseMove(QPointF ep, QRectF& r) override; + +private: + void updatePositionInternal(); }; class MvQBottomRightFeatureSelectorPoint : public MvQFeatureSelectorPoint { public: - MvQBottomRightFeatureSelectorPoint(MvQFeatureSelector*); - void updatePosition() override; + explicit MvQBottomRightFeatureSelectorPoint(MvQFeatureSelector*); + void updatePosition() override { updatePositionInternal(); } protected: void handleMouseMove(QPointF ep, QRectF& r) override; + +private: + void updatePositionInternal(); }; class MvQBottomMidFeatureSelectorPoint : public MvQFeatureSelectorPoint { public: - MvQBottomMidFeatureSelectorPoint(MvQFeatureSelector*); - void updatePosition() override; + explicit MvQBottomMidFeatureSelectorPoint(MvQFeatureSelector*); + void updatePosition() override { updatePositionInternal(); } protected: void handleMouseMove(QPointF ep, QRectF& r) override; + +private: + void updatePositionInternal(); }; class MvQBottomLeftFeatureSelectorPoint : public MvQFeatureSelectorPoint { public: - MvQBottomLeftFeatureSelectorPoint(MvQFeatureSelector*); - void updatePosition() override; + explicit MvQBottomLeftFeatureSelectorPoint(MvQFeatureSelector*); + void updatePosition() override { updatePositionInternal(); } protected: void handleMouseMove(QPointF ep, QRectF& r) override; + +private: + void updatePositionInternal(); }; class MvQLeftMidFeatureSelectorPoint : public MvQFeatureSelectorPoint { public: - MvQLeftMidFeatureSelectorPoint(MvQFeatureSelector*); - void updatePosition() override; + explicit MvQLeftMidFeatureSelectorPoint(MvQFeatureSelector*); + void updatePosition() override { updatePositionInternal(); } protected: void handleMouseMove(QPointF ep, QRectF& r) override; + +private: + void updatePositionInternal(); }; //======================================== @@ -158,12 +182,12 @@ { // The pixmap is always twice as large as the itemrect so that we can allow for the // scaling in the plot window (it can go up to 200% at the moment) - int rSize = 12; + int rSize = 12; int pixFactor = 4; - pix_ = MvQ::makePixmap(pixName, pixFactor * rSize, pixFactor * rSize); - pixHover_ = MvQ::makePixmap(hoverPixName, pixFactor * rSize, pixFactor * rSize); + pix_ = MvQ::makePixmap(pixName, pixFactor * rSize, pixFactor * rSize); + pixHover_ = MvQ::makePixmap(hoverPixName, pixFactor * rSize, pixFactor * rSize); - bRect_ = QRectF(0, 0, rSize, rSize); + bRect_ = QRectF(0, 0, rSize, rSize); double delta = rSize / 2; bRect_.moveTo(xDeltaFactor * delta, yDeltaFactor * delta); @@ -235,10 +259,10 @@ MvQTopLeftFeatureSelectorPoint::MvQTopLeftFeatureSelectorPoint(MvQFeatureSelector* selector) : MvQFeatureSelectorPoint(selector, ":/uPlot/cursor_bdiag.svg", ":/uPlot/cursor_bdiag_hover.svg", -2, -2) { - updatePosition(); + updatePositionInternal(); } -void MvQTopLeftFeatureSelectorPoint::updatePosition() +void MvQTopLeftFeatureSelectorPoint::updatePositionInternal() { QRectF r = selector_->boundingRect(); setPos(r.topLeft()); @@ -270,10 +294,10 @@ return; } - auto ratio = fabs(r.height() / r.width()); - double x = dp.x(); - double y = dp.y(); - bool grow = !(x >= 0. && y >= 0.); + auto ratio = fabs(r.height() / r.width()); + double x = dp.x(); + double y = dp.y(); + bool grow = !(x >= 0. && y >= 0.); double factor = (grow) ? -1.0 : 1.0; if (fabs(x) >= fabs(y)) { x = factor * fabs(x); @@ -302,10 +326,10 @@ MvQTopMidFeatureSelectorPoint::MvQTopMidFeatureSelectorPoint(MvQFeatureSelector* selector) : MvQFeatureSelectorPoint(selector, ":/uPlot/cursor_vert.svg", ":/uPlot/cursor_vert_hover.svg", -1, -2) { - updatePosition(); + updatePositionInternal(); } -void MvQTopMidFeatureSelectorPoint::updatePosition() +void MvQTopMidFeatureSelectorPoint::updatePositionInternal() { QRectF r = selector_->boundingRect(); setPos(r.center().x(), r.y()); @@ -330,10 +354,10 @@ MvQTopRightFeatureSelectorPoint::MvQTopRightFeatureSelectorPoint(MvQFeatureSelector* selector) : MvQFeatureSelectorPoint(selector, ":/uPlot/cursor_fdiag.svg", ":/uPlot/cursor_fdiag_hover.svg", 0, -2) { - updatePosition(); + updatePositionInternal(); } -void MvQTopRightFeatureSelectorPoint::updatePosition() +void MvQTopRightFeatureSelectorPoint::updatePositionInternal() { QRectF r = selector_->boundingRect(); setPos(r.left() + r.width(), r.top()); @@ -365,9 +389,9 @@ return; } auto ratio = fabs(r.height() / r.width()); - double x = dp.x(); - double y = dp.y(); - bool grow = !(x >= 0. && y < 0.); + double x = dp.x(); + double y = dp.y(); + bool grow = !(x >= 0. && y < 0.); if (fabs(x) >= fabs(y)) { if (grow) { x = -fabs(x); @@ -408,10 +432,10 @@ MvQRightMidFeatureSelectorPoint::MvQRightMidFeatureSelectorPoint(MvQFeatureSelector* selector) : MvQFeatureSelectorPoint(selector, ":/uPlot/cursor_horiz.svg", ":/uPlot/cursor_horiz_hover.svg", 0, -1) { - updatePosition(); + updatePositionInternal(); } -void MvQRightMidFeatureSelectorPoint::updatePosition() +void MvQRightMidFeatureSelectorPoint::updatePositionInternal() { QRectF r = selector_->boundingRect(); setPos(r.left() + r.width(), r.center().y()); @@ -436,10 +460,10 @@ MvQBottomRightFeatureSelectorPoint::MvQBottomRightFeatureSelectorPoint(MvQFeatureSelector* selector) : MvQFeatureSelectorPoint(selector, ":/uPlot/cursor_bdiag.svg", ":/uPlot/cursor_bdiag_hover.svg", 0, 0) { - updatePosition(); + updatePositionInternal(); } -void MvQBottomRightFeatureSelectorPoint::updatePosition() +void MvQBottomRightFeatureSelectorPoint::updatePositionInternal() { QRectF r = selector_->boundingRect(); setPos(r.left() + r.width(), r.top() + r.height()); @@ -471,10 +495,10 @@ return; } - auto ratio = fabs(r.height() / r.width()); - double x = dp.x(); - double y = dp.y(); - bool grow = !(x >= 0. && y >= 0.); + auto ratio = fabs(r.height() / r.width()); + double x = dp.x(); + double y = dp.y(); + bool grow = !(x >= 0. && y >= 0.); double factor = (grow) ? -1.0 : 1.0; if (fabs(x) >= fabs(y)) { x = factor * fabs(x); @@ -503,10 +527,10 @@ MvQBottomMidFeatureSelectorPoint::MvQBottomMidFeatureSelectorPoint(MvQFeatureSelector* selector) : MvQFeatureSelectorPoint(selector, ":/uPlot/cursor_vert.svg", ":/uPlot/cursor_vert_hover.svg", -1, 0) { - updatePosition(); + updatePositionInternal(); } -void MvQBottomMidFeatureSelectorPoint::updatePosition() +void MvQBottomMidFeatureSelectorPoint::updatePositionInternal() { QRectF r = selector_->boundingRect(); setPos(r.center().x(), r.top() + r.height()); @@ -531,10 +555,10 @@ MvQBottomLeftFeatureSelectorPoint::MvQBottomLeftFeatureSelectorPoint(MvQFeatureSelector* selector) : MvQFeatureSelectorPoint(selector, ":/uPlot/cursor_fdiag.svg", ":/uPlot/cursor_fdiag_hover.svg", -2, 0) { - updatePosition(); + updatePositionInternal(); } -void MvQBottomLeftFeatureSelectorPoint::updatePosition() +void MvQBottomLeftFeatureSelectorPoint::updatePositionInternal() { QRectF r = selector_->boundingRect(); setPos(r.left(), r.top() + r.height()); @@ -567,9 +591,9 @@ } auto ratio = fabs(r.height() / r.width()); - double x = dp.x(); - double y = dp.y(); - bool grow = !(x >= 0. && y < 0.); + double x = dp.x(); + double y = dp.y(); + bool grow = !(x >= 0. && y < 0.); if (fabs(x) >= fabs(y)) { if (grow) { x = -fabs(x); @@ -609,10 +633,10 @@ MvQLeftMidFeatureSelectorPoint::MvQLeftMidFeatureSelectorPoint(MvQFeatureSelector* selector) : MvQFeatureSelectorPoint(selector, ":/uPlot/cursor_horiz.svg", ":/uPlot/cursor_horiz_hover.svg", -2, -1) { - updatePosition(); + updatePositionInternal(); } -void MvQLeftMidFeatureSelectorPoint::updatePosition() +void MvQLeftMidFeatureSelectorPoint::updatePositionInternal() { QRectF r = selector_->boundingRect(); setPos(r.x(), r.center().y()); @@ -634,11 +658,11 @@ // //======================================== -class SelectorState +class SelectorState : public QObject { public: - SelectorState() = default; - virtual ~SelectorState() = default; + SelectorState() = default; + virtual ~SelectorState() override = default; virtual void setSelector(MvQFeatureSelector*) = 0; const QList& managedItems() const { return managedItems_; } virtual QList allItems() const { return managedItems_; } @@ -683,7 +707,7 @@ void handleMousePress(QGraphicsSceneMouseEvent*) override; void handleSelectionChanged(QList items) override; bool handleIdentifyCommandTarget(MvQFeatureCommandTarget* s) override; - //void handleRemoveAll() override; + // void handleRemoveAll() override; void handleItemStyleChanged(MvQFeatureItemPtr) override; }; @@ -726,7 +750,7 @@ void handleSelectionChanged(QList items) override; bool handleIdentifyCommandTarget(MvQFeatureCommandTarget* s) override; - //void handleRemoveAll() override; + // void handleRemoveAll() override; void handleClear() override; protected: @@ -782,7 +806,7 @@ selector_->hide(); selector_->controlPointUsed_ = false; selector_->controlPointMove_ = false; - selector_->dragPos_ = QPointF(); + selector_->dragPos_ = QPointF(); } void SelectorIdleState::handleSelectionChanged(QList items) @@ -909,7 +933,7 @@ { selector_ = selector; selector_->hide(); - //item->setSelected(false); + // item->setSelected(false); item_->enterPointEdit(); } @@ -935,7 +959,7 @@ bool SelectorPointEditState::handleIdentifyCommandTarget(MvQFeatureCommandTarget* s) { QPointF itemPos = item_->mapFromScene(s->scenePos()); - int nodeIndex = item_->nodeForContextMenu(itemPos); + int nodeIndex = item_->nodeForContextMenu(itemPos); if (nodeIndex != -1) { s->setInSelector(true); s->setTargetNodeItem(item_, nodeIndex); @@ -1001,7 +1025,7 @@ { selector_ = selector; selector_->hide(); - //item->setSelected(false); + // item->setSelected(false); item_->enterPointEdit(); } @@ -1088,13 +1112,13 @@ painter->drawRect(bRect_); #ifdef MVQ_FEATURE_DEV_MODE_ painter->setPen(Qt::red); - //painter->drawRect(mapRectFromParent(computeBRect())); + // painter->drawRect(mapRectFromParent(computeBRect())); #endif } else { for (auto item : managedItems()) { auto br = item->mapToParent(item->boundingRect()).boundingRect(); - br = mapFromParent(br).boundingRect(); + br = mapFromParent(br).boundingRect(); painter->drawRect(br); } } @@ -1143,12 +1167,12 @@ void MvQFeatureSelector::controlPointPressed(MvQFeatureSelectorPoint*) { - oriRect_ = bRect_; + oriRect_ = bRect_; controlPointUsed_ = true; controlPointMove_ = false; } -//Here rect is in item coordinates +// Here rect is in item coordinates void MvQFeatureSelector::controlPointMoved(MvQFeatureSelectorPoint*, QRectF rect) { if (!controlPointUsed_) @@ -1160,9 +1184,9 @@ if (rect.isValid()) { QRectF oriRect = mapRectToParent(bRect_); - auto xSign = (rect.left() - rect.right()) * (oriRect.left() - oriRect.right()); - auto ySign = (rect.top() - rect.bottom()) * (oriRect.top() - oriRect.bottom()); - auto mSize = minSize(); + auto xSign = (rect.left() - rect.right()) * (oriRect.left() - oriRect.right()); + auto ySign = (rect.top() - rect.bottom()) * (oriRect.top() - oriRect.bottom()); + auto mSize = minSize(); #ifdef MVQFEATURESELECTORITEM_DEBUG_ qDebug() << "xSign:" << xSign << "ySign:" << ySign << "mSize:" << mSize << "rectSize:" << rect.size(); #endif @@ -1174,7 +1198,7 @@ qDebug() << " bRect_(parent):" << oriRect << "rect:" << rect; #endif QPointF dp = rect.topLeft() - bRect_.topLeft(); - bRect_ = QRectF(0, 0, rect.width(), rect.height()); + bRect_ = QRectF(0, 0, rect.width(), rect.height()); setPos(pos() + dp); #ifdef MVQFEATURESELECTORITEM_DEBUG_ qDebug() << "dp:" << dp << "bRect:" << bRect_; @@ -1230,7 +1254,7 @@ void MvQFeatureSelector::registerMousePress(QGraphicsSceneMouseEvent* event) { - dragPos_ = mapToParent(event->pos()); + dragPos_ = mapToParent(event->pos()); currentMouseAction_ = MousePressedAction; } @@ -1246,8 +1270,8 @@ } QPointF prevPos = pos(); - auto evtPos = mapToParent(event->pos()); - auto delta = evtPos - dragPos_; + auto evtPos = mapToParent(event->pos()); + auto delta = evtPos - dragPos_; // we came here without having a mouse press event on the selector if (currentMouseAction_ == NoMouseAction) { @@ -1283,7 +1307,7 @@ void MvQFeatureSelector::mouseReleaseEvent(QGraphicsSceneMouseEvent*) { #ifdef MVQFEATURESELECTORITEM_DEBUG_ - //qDebug() << "MvQFeatureSelectorItem::mouseReleasEvent"; + // qDebug() << "MvQFeatureSelectorItem::mouseReleasEvent"; #endif if (controlPointUsed_) return; @@ -1331,10 +1355,10 @@ QList it; for (auto item : parentItem()->childItems()) { if (item->isSelected() && item->type() == MvQ::FeatureItemType) { - auto* f = static_cast(item); + auto* f = dynamic_cast(item); Q_ASSERT(f); if (!f->isPoint()) { - //if (f->currentAction_ != MvQFeatureItem::PointEditAction) { + // if (f->currentAction_ != MvQFeatureItem::PointEditAction) { #ifdef MVQFEATURESELECTORITEM_DEBUG_ qDebug() << " selected:" << f->typeName() << f; #endif @@ -1399,12 +1423,12 @@ QRectF br; if (managedItems().size() > 0) { auto item = managedItems()[0]; - QRectF p = item->boundingRect(); - br = item->mapToParent(p).boundingRect(); + QRectF p = item->boundingRect(); + br = item->mapToParent(p).boundingRect(); for (int i = 1; i < managedItems().count(); i++) { item = managedItems()[i]; - p = item->boundingRect(); - br = br.united(item->mapToParent(p).boundingRect()); + p = item->boundingRect(); + br = br.united(item->mapToParent(p).boundingRect()); } } return br; @@ -1423,7 +1447,7 @@ minSizeY = m.height(); } } - return QSizeF(minSizeX, minSizeY); + return {minSizeX, minSizeY}; } bool MvQFeatureSelector::identifyCommandTarget(MvQFeatureCommandTarget* s) @@ -1457,7 +1481,7 @@ std::cout << " MvQFeatureSelectorItem::transitionTo " << typeid(*state).name() << "\n"; #endif if (state_ != nullptr) { - delete state_; + state_->deleteLater(); } state_ = state; state_->setSelector(this); diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureSelector.h metview-5.19.2/metview/src/uPlot/MvQFeatureSelector.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureSelector.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureSelector.h 2023-07-15 08:28:47.000000000 +0000 @@ -73,13 +73,15 @@ void mousePressEvent(QGraphicsSceneMouseEvent*) override; void mouseMoveEvent(QGraphicsSceneMouseEvent*) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override; + +private: void createControlPoints(); void adjust(QRectF); QRectF computeBRect() const; QSizeF minSize() const; MvQFeatureItemList nonGeoLockedManagedItems() const; - MvQPlotView* view_; + MvQPlotView* view_{nullptr}; MvQFeatureHandler* handler_{nullptr}; QList controlPoints_; QRectF bRect_; diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureShapeItem.cc metview-5.19.2/metview/src/uPlot/MvQFeatureShapeItem.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureShapeItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureShapeItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -51,9 +51,9 @@ void MvQFeatureShapeItem::init(const QJsonObject& obj) { QJsonObject g = obj["geometry"].toObject(); - auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); + auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); if (!gcLst.isEmpty()) { - geoCoord_ = gcLst[0]; + geoCoord_ = gcLst[0]; hasValidGeoCoord_ = isValidPoint(geoCoord_); } else { @@ -123,8 +123,8 @@ #ifdef MVQFEATURESHAPE_DEBUG_ qDebug() << "ItemRect:" << itemRect_ << "pos:" << pos(); #endif - bRect_ = itemRect_; - width_ = itemRect_.width(); + bRect_ = itemRect_; + width_ = itemRect_.width(); height_ = itemRect_.height(); adjustBRect(); adjustGeoCoord(); @@ -137,9 +137,9 @@ prepareGeometryChange(); setPos(geom.pos_); itemRect_ = geom.itemRect_; - bRect_ = itemRect_; - width_ = itemRect_.width(); - height_ = itemRect_.height(); + bRect_ = itemRect_; + width_ = itemRect_.width(); + height_ = itemRect_.height(); adjustBRect(); adjustGeoCoord(); buildShape(); @@ -152,7 +152,7 @@ req_("WIDTH") = width_; } else { - req_("WIDTH") = width_; + req_("WIDTH") = width_; req_("HEIGHT") = height_; } broadcastRequestChanged(); @@ -284,8 +284,8 @@ } if (iv > 0 && iv != width_) { sizeChanged = true; - width_ = iv; - height_ = iv; + width_ = iv; + height_ = iv; } } else { @@ -293,8 +293,8 @@ int ih = (int)req_("HEIGHT"); if (iw > 0 && ih > 0 && (iw != width_ || ih != height_)) { sizeChanged = true; - width_ = iw; - height_ = ih; + width_ = iw; + height_ = ih; } } @@ -429,20 +429,20 @@ MvQFeaturePlacemarkerItem::MvQFeaturePlacemarkerItem(WsType* feature) : MvQFeatureShapeItem(feature) { - anchorPos_ = BottomCentreAnchor; + anchorPos_ = BottomCentreAnchor; keepAspectRatio_ = true; - width_ = 25; - height_ = 25; + width_ = 25; + height_ = 25; } -//MvQFeaturePlacemarkerItem::MvQFeaturePlacemarkerItem( -// const MvQFeaturePlacemarkerItem& o) : -// MvQFeatureShapeItem(o) +// MvQFeaturePlacemarkerItem::MvQFeaturePlacemarkerItem( +// const MvQFeaturePlacemarkerItem& o) : +// MvQFeatureShapeItem(o) //{ -// fillHole_ = o.fillHole_; -// holeBrush_ = o.holeBrush_; -// holePath_ = o.holePath_; -//} +// fillHole_ = o.fillHole_; +// holeBrush_ = o.holeBrush_; +// holePath_ = o.holePath_; +// } void MvQFeaturePlacemarkerItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*) { @@ -481,7 +481,7 @@ void MvQFeaturePlacemarkerItem::buildShape() { shapePath_ = QPainterPath(); - holePath_ = QPainterPath(); + holePath_ = QPainterPath(); // the origo is at the bottom-centre of the itemRect_! @@ -501,8 +501,8 @@ // Build the inner circle auto innerRadius = radius / 4.; - auto c = rect.center(); - auto innerRect = QRectF(c.x() - innerRadius, c.y() - innerRadius, 2 * innerRadius, 2 * innerRadius); + auto c = rect.center(); + auto innerRect = QRectF(c.x() - innerRadius, c.y() - innerRadius, 2 * innerRadius, 2 * innerRadius); if (fillHole_) { holePath_.addEllipse(innerRect); } @@ -545,12 +545,12 @@ req_.getValue("INNER_FILL", val); if (val == "" || val == "OFF") { holeBrush_ = QBrush(Qt::NoBrush); - fillHole_ = false; + fillHole_ = false; } else { holeBrush_ = MvQ::makeBrush("SOLID", (const char*)req_("INNER_FILL_COLOUR")); - fillHole_ = true; + fillHole_ = true; } // size @@ -565,8 +565,8 @@ } if (iv > 0 && iv != width_) { sizeChanged = true; - width_ = iv; - height_ = iv; + width_ = iv; + height_ = iv; } buildShape(); @@ -599,17 +599,17 @@ // coord and size must be extracted before the base-class // implementation is called QJsonObject g = obj["geometry"].toObject(); - auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); + auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); if (!gcLst.isEmpty()) { - geoCoord_ = gcLst[0]; + geoCoord_ = gcLst[0]; hasValidGeoCoord_ = isValidPoint(geoCoord_); } QJsonObject p = obj["properties"].toObject(); - auto w = p["width"].toInt(); - auto h = p["height"].toInt(); + auto w = p["width"].toInt(); + auto h = p["height"].toInt(); if (w > 0 && w < 5000 && h > 0 && h < 5000) { - width_ = w; + width_ = w; height_ = h; } MvQFeatureItem::init(obj); @@ -624,9 +624,9 @@ // g["coordinates"] = MvQJson::fromPointF(geoCoord()); // obj["geometry"] = g; - QJsonObject p = obj["properties"].toObject(); - p["width"] = width_; - p["height"] = height_; + QJsonObject p = obj["properties"].toObject(); + p["width"] = width_; + p["height"] = height_; obj["properties"] = p; } @@ -666,12 +666,12 @@ // reduce the targetRect with the halo. We want to fit the itemRect into it!!! targetRect.adjust(halo(), halo(), -halo(), -halo()); - auto w = targetRect.width(); - auto h = targetRect.height(); + auto w = targetRect.width(); + auto h = targetRect.height(); itemRect_ = QRectF(-w / 2., -h / 2., w, h); - bRect_ = itemRect_; - width_ = itemRect_.width(); - height_ = itemRect_.height(); + bRect_ = itemRect_; + width_ = itemRect_.width(); + height_ = itemRect_.height(); setPos(targetRectInParent.center()); adjustBRect(); adjustGeoCoord(); @@ -683,9 +683,9 @@ prepareGeometryChange(); setPos(geom.pos_); itemRect_ = geom.itemRect_; - bRect_ = itemRect_; - width_ = itemRect_.width(); - height_ = itemRect_.height(); + bRect_ = itemRect_; + width_ = itemRect_.width(); + height_ = itemRect_.height(); adjustBRect(); adjustGeoCoord(); buildShape(); @@ -757,9 +757,9 @@ { prepareGeometryChange(); itemRect_ = shapeBoundingRect(); - width_ = itemRect_.width(); - height_ = itemRect_.height(); - bRect_ = itemRect_; + width_ = itemRect_.width(); + height_ = itemRect_.height(); + bRect_ = itemRect_; } void MvQFeatureGeoShapeItem::adjustBRect() @@ -847,7 +847,7 @@ } if (shape_.size() == 4) { - width_ = fabs(shape_[1].x() - shape_[0].x()); + width_ = fabs(shape_[1].x() - shape_[0].x()); height_ = fabs(shape_[3].y() - shape_[0].y()); } } diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureTextItem.cc metview-5.19.2/metview/src/uPlot/MvQFeatureTextItem.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureTextItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureTextItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,7 +35,7 @@ #include "ObjectList.h" #include "WsDecoder.h" -#include +#include //#define MVQFEATURETEXT_DEBUG_ @@ -52,7 +52,7 @@ Q_ASSERT(item_); holderW_ = new MvQPanel(); - auto vb = new QVBoxLayout(holderW_); + auto vb = new QVBoxLayout(holderW_); vb->setContentsMargins(5, 5, 5, 5); QString sh = "QWidget {background-color: transparent;}"; @@ -166,7 +166,7 @@ item_->setTextFromEditor(text); } QSize eSize = item_->itemRect().size().toSize(); - auto wSize = eSize + QSize(2 * frame_, 2 * frame_); + auto wSize = eSize + QSize(2 * frame_, 2 * frame_); holderW_->resize(wSize); holderW_->setMaximumWidth(wSize.width() + 1); @@ -179,7 +179,7 @@ void MvQFeatureTextEditor::finish() { - //item_->setText( editor_->toPlainText()); + // item_->setText( editor_->toPlainText()); item_->textEditFinished(); } @@ -209,7 +209,7 @@ adjustAlignment(); QSize eSize = item_->itemRect().size().toSize(); - auto wSize = eSize + QSize(2 * frame_, 2 * frame_); + auto wSize = eSize + QSize(2 * frame_, 2 * frame_); holderW_->setMaximumWidth(wSize.width() + 1); holderW_->setMaximumHeight(wSize.height() + 1); editor_->setMaximumWidth(eSize.width() + 1); @@ -219,16 +219,16 @@ void MvQFeatureTextEditor::adjustAlignment() { - auto tc = editor_->textCursor(); + auto tc = editor_->textCursor(); auto oriTc = tc; tc.movePosition(QTextCursor::Start); editor_->setTextCursor(tc); editor_->setAlignment(item_->alignment()); - //qDebug() << "block=" << tc.blockNumber() << tc.block().text(); + // qDebug() << "block=" << tc.blockNumber() << tc.block().text(); while (tc.movePosition(QTextCursor::NextBlock, QTextCursor::MoveAnchor)) { editor_->setTextCursor(tc); editor_->setAlignment(item_->alignment()); - //qDebug() << "block=" << tc.blockNumber() << tc.block().text(); + // qDebug() << "block=" << tc.blockNumber() << tc.block().text(); } editor_->setTextCursor(oriTc); } @@ -316,9 +316,9 @@ void MvQFeatureTextItem::init(const QJsonObject& obj) { QJsonObject g = obj["geometry"].toObject(); - auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); + auto gcLst = MvQJson::toPointFList(g["coordinates"].toArray(), g["type"].toString()); if (!gcLst.isEmpty()) { - geoCoord_ = gcLst[0]; + geoCoord_ = gcLst[0]; hasValidGeoCoord_ = isValidPoint(geoCoord_); } else { @@ -329,7 +329,7 @@ WsDecoder::styleValue(obj, "WIDTH", w); WsDecoder::styleValue(obj, "HEIGHT", h); if (w > 0 && w < 10000 && h > 0 && h < 10000) { - textRect_ = QRectF(0, 0, w, h); + textRect_ = QRectF(0, 0, w, h); } MvQFeatureItem::init(obj); @@ -376,11 +376,11 @@ prepareGeometryChange(); // textRect_ is the at (0,0) !!! - auto w = targetRect.width(); - auto h = targetRect.height(); + auto w = targetRect.width(); + auto h = targetRect.height(); textRect_ = QRectF(0, 0, w, h); itemRect_ = textRect_.adjusted(-margin_, -margin_, margin_, margin_); - bRect_ = itemRect_; + bRect_ = itemRect_; setPos(targetRectInParent.bottomLeft() + QPointF(halo() + margin_, -halo() - margin_)); adjustBRect(); @@ -397,14 +397,14 @@ setPos(geom.pos_); itemRect_ = geom.itemRect_; textRect_ = itemRect_.adjusted(margin_, margin_, -margin_, -margin_); - bRect_ = itemRect_; + bRect_ = itemRect_; adjustBRect(); adjustGeoCoord(); } void MvQFeatureTextItem::resizeFinished() { - //auto tr = estimateTextRect(); + // auto tr = estimateTextRect(); } QPointF MvQFeatureTextItem::textPos() const @@ -434,7 +434,7 @@ if (init && textRect_.isValid()) { itemRect_ = textRect_.adjusted(-margin_, -margin_, margin_, margin_); - bRect_ = itemRect_; + bRect_ = itemRect_; } else { adjustText(); @@ -493,7 +493,7 @@ req_.getValue("FONT_UNDERLINE_STYLE", val); bool underline = (val == "ON"); - font_ = MvQ::makeFont(family, bold, italic, underline, fontSize); + font_ = MvQ::makeFont(family, bold, italic, underline, fontSize); fontPen_ = MvQ::makePen("SOLID", 1, (const char*)req_("FONT_COLOUR")); req_.getValue("TEXT_ALIGNMENT", val); @@ -512,7 +512,7 @@ // only the handler can call it void MvQFeatureTextItem::setText(QString t) { - text_ = t; + text_ = t; req_("TEXT") = text_.toStdString().c_str(); prepareGeometryChange(); @@ -575,7 +575,7 @@ // textRect_ is always the at (0,0) !!! itemRect_ = textRect_.adjusted(-margin_, -margin_, margin_, margin_); - bRect_ = itemRect_; + bRect_ = itemRect_; } QRectF MvQFeatureTextItem::estimateTextRect() const @@ -599,14 +599,14 @@ void MvQFeatureTextItem::textEditStarted(MvQFeatureTextEditor* editor) { inTextEdit_ = true; - editor_ = editor; + editor_ = editor; update(); } void MvQFeatureTextItem::textEditFinished() { inTextEdit_ = false; - editor_ = nullptr; + editor_ = nullptr; update(); setSelected(false); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureTextItem.h metview-5.19.2/metview/src/uPlot/MvQFeatureTextItem.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureTextItem.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureTextItem.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ { Q_OBJECT public: - MvQFeatureTextEditor(MvQFeatureTextItemPtr item, QGraphicsItem* parent = 0); + MvQFeatureTextEditor(MvQFeatureTextItemPtr item, QGraphicsItem* parent = nullptr); void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; QTextEdit* editor() const; diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureWidget.cc metview-5.19.2/metview/src/uPlot/MvQFeatureWidget.cc --- metview-5.17.4/metview/src/uPlot/MvQFeatureWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -133,7 +133,7 @@ QModelIndex MvQFeatureListModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } WsType* MvQFeatureListModel::indexToItem(const QModelIndex& index) const @@ -183,7 +183,7 @@ void MvQFeatureListView::resizeEvent(QResizeEvent* e) { -// MvLog().dbg() << MV_FN_INFO << "group=" << model()->index(0,0).data(Qt::UserRole).toString() << " cnt=" << model()->rowCount(); + // MvLog().dbg() << MV_FN_INFO << "group=" << model()->index(0,0).data(Qt::UserRole).toString() << " cnt=" << model()->rowCount(); if (autoAdjustHeight_ && model()->rowCount() >= 1) { QTimer::singleShot(0, this, SLOT(delayedAdjustHeight())); } @@ -193,7 +193,7 @@ void MvQFeatureListView::delayedAdjustHeight() { if (autoAdjustHeight_ && model()->rowCount() >= 1) { -// MvLog().dbg() << MV_FN_INFO << "group=" << model()->index(0,0).data(Qt::UserRole).toString(); + // MvLog().dbg() << MV_FN_INFO << "group=" << model()->index(0,0).data(Qt::UserRole).toString(); int maxY = 0; for (int i = 0; i < model()->rowCount(); i++) { auto vr = visualRect(model()->index(i, 0)); @@ -201,14 +201,14 @@ maxY = vr.y() + vr.height(); } } - auto r = visualRect(model()->index(0, 0)); + auto r = visualRect(model()->index(0, 0)); auto itemH = r.height(); int space = 4; if (model()->rowCount() > 1) { space = visualRect(model()->index(1, 0)).x() - (r.x() + r.width()); } - auto h = height(); + auto h = height(); auto scH = 0; if (horizontalScrollBar()) { if (horizontalScrollBar()->isVisible()) { @@ -264,7 +264,7 @@ // Types auto w = new QWidget(this); typeLayout_ = new QVBoxLayout(w); - typeLayout_->setContentsMargins(2,2,2,2); + typeLayout_->setContentsMargins(2, 2, 2, 2); typeLayout_->setAlignment(Qt::AlignTop); stackedW_->addWidget(w); @@ -272,7 +272,7 @@ storeW_ = new FeatureStoreWidget(this); stackedW_->addWidget(storeW_); - //TODO: do init in the right place + // TODO: do init in the right place WsType::init(WsType::PlotWindowMode); MvQFeatureMenuItem::init(); FeatureStore::Instance()->load(); @@ -294,7 +294,7 @@ typeLayout_->addWidget(labelPanel); if (grId != "wmo") { - auto model = new MvQFeatureListModel(QString::fromStdString(grId), this); + auto model = new MvQFeatureListModel(QString::fromStdString(grId), this); auto proxyModel = new MvQFeatureListProxyModel(QString::fromStdString(grId), this); proxyModel->setSourceModel(model); proxyModel->setDynamicSortFilter(true); @@ -374,7 +374,7 @@ this, SLOT(subGroupSelected(int))); - auto model = new MvQFeatureListModel(groupId, this); + auto model = new MvQFeatureListModel(groupId, this); proxyModel_ = new MvQFeatureListProxyModel(groupId, this); proxyModel_->setSourceModel(model); proxyModel_->setDynamicSortFilter(true); diff -Nru metview-5.17.4/metview/src/uPlot/MvQFeatureWidget.h metview-5.19.2/metview/src/uPlot/MvQFeatureWidget.h --- metview-5.17.4/metview/src/uPlot/MvQFeatureWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQFeatureWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,7 +32,7 @@ void setSubGroup(QString subGroup); protected: - bool filterAcceptsRow(int source_column, const QModelIndex& source_parent) const; + bool filterAcceptsRow(int source_column, const QModelIndex& source_parent) const override; QString group_; QString subGroup_; @@ -50,11 +50,11 @@ SubGroupRole = Qt::UserRole + 1 }; - int columnCount(const QModelIndex&) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + int columnCount(const QModelIndex&) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; WsType* indexToItem(const QModelIndex&) const; @@ -68,14 +68,14 @@ { Q_OBJECT public: - MvQFeatureListView(MvQFeatureListModel*, MvQFeatureListProxyModel*, bool, QWidget* parent = 0); + MvQFeatureListView(MvQFeatureListModel*, MvQFeatureListProxyModel*, bool, QWidget* parent = nullptr); protected slots: void slotClicked(const QModelIndex& current); void delayedAdjustHeight(); protected: - void resizeEvent(QResizeEvent* e); + void resizeEvent(QResizeEvent* e) override; MvQFeatureListModel* model_; MvQFeatureListProxyModel* proxyModel_; @@ -88,8 +88,8 @@ Q_OBJECT public: - explicit MvQWmoFeatureWidget(QString groupId, QWidget* parent = 0); - ~MvQWmoFeatureWidget() {} + explicit MvQWmoFeatureWidget(QString groupId, QWidget* parent = nullptr); + ~MvQWmoFeatureWidget() override = default; void writeSettings(QSettings& settings); void readSettings(QSettings& settings); @@ -108,8 +108,8 @@ { Q_OBJECT public: - explicit MvQFeatureWidget(QWidget* parent = 0); - ~MvQFeatureWidget() {} + explicit MvQFeatureWidget(QWidget* parent = nullptr); + ~MvQFeatureWidget() override = default; void writeSettings(QSettings& settings); void readSettings(QSettings& settings); @@ -120,9 +120,9 @@ protected: void buildGroup(const std::string& grId, const std::string& grLabel); - QVBoxLayout* typeLayout_{nullptr}; - QButtonGroup* controlTbGroup_{nullptr}; - FeatureStoreWidget* storeW_{nullptr}; - QStackedWidget* stackedW_{nullptr}; - MvQWmoFeatureWidget* wmoW_{nullptr}; + QVBoxLayout* typeLayout_{nullptr}; + QButtonGroup* controlTbGroup_{nullptr}; + FeatureStoreWidget* storeW_{nullptr}; + QStackedWidget* stackedW_{nullptr}; + MvQWmoFeatureWidget* wmoW_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerContentsIcon.cc metview-5.19.2/metview/src/uPlot/MvQLayerContentsIcon.cc --- metview-5.17.4/metview/src/uPlot/MvQLayerContentsIcon.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerContentsIcon.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,12 +32,12 @@ isData_(false) { // Initialise first variables - path_ = path; - type_ = type; - id_ = id; + path_ = path; + type_ = type; + id_ = id; calledFromMacro_ = fromMacro; - //qDebug() << "Constructor MvQLayerContentsIcon " << path_ << type_ << id_; + // qDebug() << "Constructor MvQLayerContentsIcon " << path_ << type_ << id_; QStringList lst = path_.split("/"); if (!lst.isEmpty()) @@ -63,24 +63,24 @@ std::string sclass = type_.toStdString(); if (ObjectList::IsDataUnit(sclass.c_str())) { canBeDeleted_ = true; - canBeEdited_ = false; - canBeSaved_ = false; + canBeEdited_ = false; + canBeSaved_ = false; canBeSavedAs_ = false; - isData_ = true; + isData_ = true; } else if (ObjectList::IsVisDef(sclass.c_str()) || ObjectList::IsVisDefText(sclass.c_str()) || ObjectList::IsVisDefLegend(sclass.c_str()) || ObjectList::IsVisDefImport(sclass.c_str())) { canBeDeleted_ = true; - canBeEdited_ = true; - canBeSaved_ = (name_[0] == '<' && name_[name_.size() - 1] == '>') ? false : true; + canBeEdited_ = true; + canBeSaved_ = (name_[0] == '<' && name_[name_.size() - 1] == '>') ? false : true; canBeSavedAs_ = true; } else if (ObjectList::IsVisDefCoastlines(sclass.c_str())) { canBeDeleted_ = true; - canBeEdited_ = false; - canBeSaved_ = false; + canBeEdited_ = false; + canBeSaved_ = false; canBeSavedAs_ = false; } else if (ObjectList::IsView(sclass.c_str())) { @@ -88,14 +88,14 @@ // disabled because the current version can not handle // embeded icons. Investigate the use of script mv_compress canBeDeleted_ = false; - canBeEdited_ = false; - canBeSaved_ = false; //( name_[0] == '<' && name_[name_.size()-1] == '>' ) ? false : true; + canBeEdited_ = false; + canBeSaved_ = false; //( name_[0] == '<' && name_[name_.size()-1] == '>' ) ? false : true; canBeSavedAs_ = false; } else { canBeDeleted_ = false; - canBeEdited_ = false; - canBeSaved_ = false; + canBeEdited_ = false; + canBeSaved_ = false; canBeSavedAs_ = false; } @@ -108,18 +108,18 @@ MvQLayerContentsIcon& MvQLayerContentsIcon::operator=(const MvQLayerContentsIcon& icon) { - path_ = icon.path_; - type_ = icon.type_; - id_ = icon.id_; - name_ = icon.name_; - pix_ = icon.pix_; + path_ = icon.path_; + type_ = icon.type_; + id_ = icon.id_; + name_ = icon.name_; + pix_ = icon.pix_; calledFromMacro_ = icon.calledFromMacro_; canBeDeleted_ = icon.canBeDeleted_; - canBeEdited_ = icon.canBeEdited_; - canBeSaved_ = icon.canBeSaved_; + canBeEdited_ = icon.canBeEdited_; + canBeSaved_ = icon.canBeSaved_; canBeSavedAs_ = icon.canBeSavedAs_; - isData_ = icon.isData_; + isData_ = icon.isData_; return *this; } @@ -145,7 +145,7 @@ // the original icon. // Get Presentable SuperPage and the DataBase - Presentable* pres = Root::Instance().FindSuperPage(); + Presentable* pres = Root::Instance().FindSuperPage(); MvIconDataBase& dataBase = pres->IconDataBase(); // Retrieve icon from the DataBase @@ -155,13 +155,13 @@ // Add parameter indicating the name of the uPlot Temporary Directory. // This will be used by the Desktop Editor - MvRequest req = mvIcon.Request(); + MvRequest req = mvIcon.Request(); std::string uTempDir = uPlotBase::tempDir(); if (uTempDir[uTempDir.size() - 1] == '/') // remove last '/' uTempDir = uTempDir.substr(0, uTempDir.size() - 1); - std::size_t ipos = uTempDir.find_last_of("/"); - std::string uTempName = (ipos != std::string::npos) ? uTempDir.substr(ipos + 1) : uTempDir; + std::size_t ipos = uTempDir.find_last_of("/"); + std::string uTempName = (ipos != std::string::npos) ? uTempDir.substr(ipos + 1) : uTempDir; req("_UPLOT_TEMP_DIR") = uTempName.c_str(); // Save information stored in the hidden parameters because, after this @@ -184,9 +184,9 @@ // Parameter _NAME is the full filename without the Metview user directory std::string userDir = GetUserDirectory(); // Metview user directory - std::size_t ipos = fname.find(userDir); - ipos = (ipos != std::string::npos) ? ipos + userDir.size() : 0; - req("_NAME") = fname.substr(ipos).c_str(); + std::size_t ipos = fname.find(userDir); + ipos = (ipos != std::string::npos) ? ipos + userDir.size() : 0; + req("_NAME") = fname.substr(ipos).c_str(); // If this is a default icon then remove the _DEFAULT parameter. // A new clone icon will be created in the temporary directory @@ -215,17 +215,17 @@ // Restore some hidden parameters that were saved in the function // "startEditor". Unfortunately, these parameters are not sent back // by the Desktop Editor - newIconRequest("_NAME_ORIGINAL") = nameOrg_.c_str(); - newIconRequest("_ID") = id_.toInt(); + newIconRequest("_NAME_ORIGINAL") = nameOrg_.c_str(); + newIconRequest("_ID") = id_.toInt(); newIconRequest("_CONTENTS_ICON_EDITED") = id_.toInt(); - newIconRequest("_CALLED_FROM_MACRO") = calledFromMacro_; + newIconRequest("_CALLED_FROM_MACRO") = calledFromMacro_; // Create a new drop request // Get the target Presentable (Page) id - int ivoid; // void variable + int ivoid = 0; // void variable MvRequest dropRequest("DROP"); - Presentable* pres = Root::Instance().FindSuperPage(); - dropRequest("DROP_ID") = pres->FindBranchIdByIconId(id_.toInt(), ivoid); + Presentable* pres = Root::Instance().FindSuperPage(); + dropRequest("DROP_ID") = pres->FindBranchIdByIconId(id_.toInt(), ivoid); dropRequest("_CONTENTS") = 1; dropRequest = dropRequest + newIconRequest; @@ -274,7 +274,7 @@ iconReq.save(fullPath.c_str()); // Notify everyone - //MvApplication::notifyIconModified(icon_.IconName(),icon_.IconClass()); + // MvApplication::notifyIconModified(icon_.IconName(),icon_.IconClass()); } } @@ -286,7 +286,7 @@ // Show dialog QString startDir; if (uPlotBase::owner()) { - startDir = QString::fromStdString(ObjectInfo::ObjectFullPath(uPlotBase::owner()->Request())); + startDir = QString::fromStdString(ObjectInfo::ObjectFullPath(uPlotBase::owner()->Request())); } MvQLayerDialog layerDialog(id_.toInt(), startDir); @@ -311,8 +311,8 @@ return fname; // Get path and filename - std::size_t pos = fname.find_last_of("/\\"); - std::string path = fname.substr(0, pos); + std::size_t pos = fname.find_last_of("/\\"); + std::string path = fname.substr(0, pos); std::string filename = fname.substr(pos + 1); // Remove suffix .icon from the filename diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerContentsIcon.h metview-5.19.2/metview/src/uPlot/MvQLayerContentsIcon.h --- metview-5.17.4/metview/src/uPlot/MvQLayerContentsIcon.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerContentsIcon.h 2023-07-15 08:28:47.000000000 +0000 @@ -52,7 +52,7 @@ bool canBeSavedAs() { return canBeSavedAs_; } bool isData() { return isData_; } -protected: +private: QString name_; QString path_; QString type_; @@ -68,8 +68,6 @@ int calledFromMacro_; // icon originated from a Macro - -private: std::string getPixmapPath(const std::string&); // Members related to the icon hidden parameters. diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerDataWidget.cc metview-5.19.2/metview/src/uPlot/MvQLayerDataWidget.cc --- metview-5.17.4/metview/src/uPlot/MvQLayerDataWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerDataWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,23 +33,23 @@ QWidget(parent), plotScene_(plotScene), plotView_(plotView), - sceneItem_(0), - layer_(0), - dataProbe_(0) + sceneItem_(nullptr), + layer_(nullptr), + dataProbe_(nullptr) { layout_ = new QVBoxLayout; layout_->setContentsMargins(0, 0, 0, 0); - //layout_->setSpacing(1); + // layout_->setSpacing(1); setLayout(layout_); - //Panels + // Panels panelLayout_ = new QStackedLayout; layout_->addLayout(panelLayout_); auto* emptyWidget = new QWidget(this); - auto* emptyVb = new QVBoxLayout(emptyWidget); - auto* label = new QLabel(tr("No data is available for this layer!"), this); + auto* emptyVb = new QVBoxLayout(emptyWidget); + auto* label = new QLabel(tr("No data is available for this layer!"), this); emptyVb->addWidget(label); emptyVb->addStretch(1); panelLayout_->addWidget(emptyWidget); @@ -57,7 +57,7 @@ QPair item(EmptyPanel, label); panels_ << item; - //Data probe + // Data probe auto* probeHb = new QHBoxLayout(); probeHb->setSpacing(1); @@ -94,9 +94,9 @@ probeLabel_->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); probeLabel_->setFrameShape(QFrame::Box); probeLabel_->setFrameShape(QFrame::StyledPanel); - //probeLabel_->setVisible(false); + // probeLabel_->setVisible(false); probeHb->addWidget(probeLabel_, 1); - //probeHb->addStretch(1); + // probeHb->addStretch(1); connect(probeTb_, SIGNAL(toggled(bool)), this, SLOT(slotProbe(bool))); @@ -138,14 +138,14 @@ // Create the panel //--------------------------------------------------------- - //Get metadata + // Get metadata MetaDataCollector md; md["_datatype"] = ""; - md["path"] = ""; + md["path"] = ""; md["hasMatrix"] = ""; layerMetaData(md); - //Get datatype and path + // Get datatype and path auto it = md.find("_datatype"); if (it == md.end()) { panelLayout_->setCurrentIndex(0); @@ -158,7 +158,7 @@ if (it != md.end()) dataPath = QString::fromStdString(it->second); - //Get data indexes + // Get data indexes DataIndexCollector info; sceneItem_->layerDataIndexForCurrentStep(layer_, info); if (info.dataIndex().size() <= 0) { @@ -166,7 +166,7 @@ return; } - //ODB + // ODB if (dataType == "ODB_geopoints") { loadOdb(dataPath, info); adjustDataProbe(); @@ -203,12 +203,12 @@ if (!layer_) return; - QWidget* panel = findIdlePanel(OdbPanel); - MvQOdbDataWidget* w = 0; + QWidget* panel = findIdlePanel(OdbPanel); + MvQOdbDataWidget* w = nullptr; if (!panel) { panel = new MvQOdbDataWidget(this); - w = static_cast(panel); - w->setMaxChunkSizeInMb(0); //we do not allow data chunks + w = dynamic_cast(panel); + w->setMaxChunkSizeInMb(0); // we do not allow data chunks panelLayout_->addWidget(panel); @@ -220,7 +220,7 @@ this, SLOT(slotSetIndex(int))); } else { - w = static_cast(panel); + w = dynamic_cast(panel); if (activePanels_.find(layer_) == activePanels_.end()) activePanels_[layer_] = panel; } @@ -253,9 +253,9 @@ if (b) { if (dataProbe_) { dataProbe_->setActivated(true); - //move to right position (using the stored coordinate) + // move to right position (using the stored coordinate) dataProbe_->updateScenePosition(); - //reload the selection + // reload the selection slotPointSelected(dataProbe_->coordinates()); } else { @@ -266,7 +266,7 @@ else { if (dataProbe_) { dataProbe_->setActivated(false); - //move to right position (using the stored coordiante) + // move to right position (using the stored coordiante) dataProbe_->updateScenePosition(); removeTmpFilterFromPanel(); } @@ -309,13 +309,13 @@ void MvQLayerDataWidget::adjustDataProbe() { if (dataProbe_ && dataProbe_->activated() && layoutItem_) { - //QRectF rect=layoutItem_->mapRectToScene(layoutItem_->boundingRect()); - //QPointF coord; - //layoutItem_->mapFromSceneToGeoCoords(rect.center(),coord); - - //dataProbe_->setCoordinates(dataProbe_->coordinates()); - //slotPointSelected(dataProbe_->coordinates()); - //slotPointSelected(dataProbe_->coordinates()); + // QRectF rect=layoutItem_->mapRectToScene(layoutItem_->boundingRect()); + // QPointF coord; + // layoutItem_->mapFromSceneToGeoCoords(rect.center(),coord); + + // dataProbe_->setCoordinates(dataProbe_->coordinates()); + // slotPointSelected(dataProbe_->coordinates()); + // slotPointSelected(dataProbe_->coordinates()); } } @@ -329,8 +329,8 @@ QPointF coord; layoutItem_->mapFromSceneToGeoCoords(rect.center(), coord); - dataProbe_ = new MvQPlaceMark(plotScene_, plotView_, 0); - //dataProbe_->setFlag(QGraphicsItem::ItemIgnoresTransformations); + dataProbe_ = new MvQPlaceMark(plotScene_, plotView_, nullptr); + // dataProbe_->setFlag(QGraphicsItem::ItemIgnoresTransformations); dataProbe_->setZValue(1.8); dataProbe_->setActivated(true); dataProbe_->setCoordinates(coord); @@ -343,7 +343,7 @@ this, SLOT(slotUpdateProbeLabel(QPointF))); plotView_->setDataProbe(dataProbe_); - //dataProbe_->setParentItem(plotScene_->annotationRootItem()); + // dataProbe_->setParentItem(plotScene_->annotationRootItem()); plotScene_->addItem(dataProbe_); } } @@ -351,10 +351,10 @@ void MvQLayerDataWidget::updateProbe() { /*if(dataProbe_ && dataProbe_->activated()) - { - dataProbe_->setCoordinates(dataProbe_->coordinates()); - updateProbeLabel(); - }*/ + { + dataProbe_->setCoordinates(dataProbe_->coordinates()); + updateProbeLabel(); + }*/ } void MvQLayerDataWidget::updateProbeLabel() @@ -414,13 +414,13 @@ if (type == EmptyPanel) return; - //Get the index for the position + // Get the index for the position double searchRadiusX = 2.; double searchRadiusY = 2.; float plotScale = plotScene_->plotScale(); - double cx = layoutItem_->coordRatioX(); - double cy = layoutItem_->coordRatioY(); + double cx = layoutItem_->coordRatioX(); + double cy = layoutItem_->coordRatioY(); if (cx != 0.) { searchRadiusX = 20. / fabs(cx * plotScale); @@ -440,7 +440,7 @@ sceneItem_->collectLayerDataForCurrentStep(layer_, vc); - //Pass the index to the panel widget + // Pass the index to the panel widget std::vector indexVec; if (vc.size() > 0 && vc[0].size() > 0) { for (unsigned int i = 0; i < vc[0].size(); i++) { @@ -470,7 +470,7 @@ sceneItem_->collectLayerDataForCurrentStep(layer_, vc); - //Pass the index to the panel widget + // Pass the index to the panel widget if (vc.size() > 0 && vc.at(0).size() > 0) { double x = vc.at(0).at(0)->x(); double y = vc.at(0).at(0)->y(); @@ -483,12 +483,12 @@ void MvQLayerDataWidget::setIndexForPanel(const std::vector& indexVec, PanelType type, QWidget* panel) { - //if(indexVec.empty()) + // if(indexVec.empty()) // return; if (type == OdbPanel) { #ifdef METVIEW_ODB_NEW - auto* data = static_cast(panel); + auto* data = dynamic_cast(panel); if (data) { if (isProbeFiltered()) { data->setTmpFilter(indexVec); @@ -563,7 +563,7 @@ } } - return 0; + return nullptr; } QWidget* MvQLayerDataWidget::findActivePanel(PanelType type) @@ -576,7 +576,7 @@ } } } - return 0; + return nullptr; } void MvQLayerDataWidget::clear() @@ -587,15 +587,15 @@ void MvQLayerDataWidget::reset(MgQSceneItem* sceneItem, MgQLayerItem* layer) { sceneItem_ = sceneItem; - layer_ = layer; + layer_ = layer; - //Save some data + // Save some data storePanelProperties(); activePanels_.clear(); setLayer(layer_); - layoutItem_ = 0; + layoutItem_ = nullptr; if (sceneItem_) { layoutItem_ = sceneItem_->firstProjectorItem(); @@ -627,7 +627,7 @@ QWidget* panel = findActivePanel(OdbPanel); if (panel) { #ifdef METVIEW_ODB_NEW - auto* data = static_cast(panel); + auto* data = dynamic_cast(panel); if (data) { visibleOdbColumns_ = data->visibleColumns(); } @@ -639,7 +639,7 @@ { settings.beginGroup("MvQLayerDataWidget"); - //Save some data + // Save some data storePanelProperties(); if (visibleOdbColumns_.count() > 0) { diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerDataWidget.h metview-5.19.2/metview/src/uPlot/MvQLayerDataWidget.h --- metview-5.17.4/metview/src/uPlot/MvQLayerDataWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerDataWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,8 @@ Q_OBJECT public: - MvQLayerDataWidget(MgQPlotScene*, MvQPlotView*, QWidget* parent = 0); - ~MvQLayerDataWidget(); + MvQLayerDataWidget(MgQPlotScene*, MvQPlotView*, QWidget* parent = nullptr); + ~MvQLayerDataWidget() override; void updateProbe(); void reset(MgQSceneItem*, MgQLayerItem*); @@ -49,7 +49,7 @@ void slotPointSelected(QPointF); void slotSetIndex(int); -protected: +private: enum PanelType { EmptyPanel, diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerDialog.cc metview-5.19.2/metview/src/uPlot/MvQLayerDialog.cc --- metview-5.17.4/metview/src/uPlot/MvQLayerDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,9 +41,9 @@ MvIconDataBase& dataBase = pres->IconDataBase(); if (dataBase.FindIcon(iconId_, mvIcon)) { // Save icon on disk - MvRequest iconReq = mvIcon.Request(); + MvRequest iconReq = mvIcon.Request(); std::string siconName = iconName.toStdString(); - std::string fullPath = MakeUserPath(siconName); + std::string fullPath = MakeUserPath(siconName); // Remove all hiden parameters before saving the icon metview::RemoveParameters(iconReq, "_"); diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerMetaDataWidget.cc metview-5.19.2/metview/src/uPlot/MvQLayerMetaDataWidget.cc --- metview-5.17.4/metview/src/uPlot/MvQLayerMetaDataWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerMetaDataWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,8 @@ MvQLayerMetaDataWidget::MvQLayerMetaDataWidget(QWidget* parent) : QWidget(parent), - sceneItem_(0), - layer_(0), + sceneItem_(nullptr), + layer_(nullptr), statsEnabled_(false), histoEnabled_(false), histoVisdefInitialIndex_(0) @@ -51,20 +51,20 @@ layout->setContentsMargins(0, 0, 0, 0); setLayout(layout); - //TextEdit + // TextEdit layerTe_ = new QTextEdit(this); layerTe_->setReadOnly(true); layerTe_->document()->setDefaultStyleSheet(MvQTheme::htmlTableCss()); layerTe_->setWordWrapMode(QTextOption::WordWrap); - //layerTe_->setLineWrapMode(QTextEdit::WidgetWidth); + // layerTe_->setLineWrapMode(QTextEdit::WidgetWidth); layout->addWidget(layerTe_, 1); - //Stats + histo row + // Stats + histo row auto* hb = new QHBoxLayout; layout->addLayout(hb); - //Stats button + // Stats button statsTb_ = new QToolButton(this); statsTb_->setText(tr("Stats")); statsTb_->setToolTip(tr("Statistics")); @@ -74,7 +74,7 @@ connect(statsTb_, SIGNAL(toggled(bool)), this, SLOT(slotStatsEnabled(bool))); - //Histogram button + // Histogram button histoTb_ = new QToolButton(this); histoTb_->setText(tr("Histogram")); histoTb_->setToolTip(tr("Histogram")); @@ -84,9 +84,9 @@ connect(histoTb_, SIGNAL(toggled(bool)), this, SLOT(slotHistoEnabled(bool))); - //QLabel *visdefLabel= new QLabel(tr("Histogram method:")); + // QLabel *visdefLabel= new QLabel(tr("Histogram method:")); - //ComboBox + // ComboBox histoVisdefCb_ = new QComboBox(this); histoVisdefCb_->setSizeAdjustPolicy(QComboBox::AdjustToContents); @@ -99,14 +99,14 @@ hb->addWidget(statsTb_); hb->addWidget(histoTb_); - //hb->addWidget(visdefLabel); + // hb->addWidget(visdefLabel); hb->addWidget(histoVisdefCb_); hb->addStretch(1); - //hb->addWidget(label,0,Qt::AlignRight); + // hb->addWidget(label,0,Qt::AlignRight); /*hb->addWidget(layerLabel); - hb->addWidget(layerCb_);*/ + hb->addWidget(layerCb_);*/ - //Meta-data key + // Meta-data key keyManager_ = new MvQKeyManager(MvQKeyManager::LayerType); keyManager_->loadProfiles(); } @@ -123,9 +123,9 @@ return; } - //Collect data + // Collect data MetaDataCollector infoMap; - infoMap["_datatype"] = ""; + infoMap["_datatype"] = ""; infoMap["_description"] = ""; layerMetaData(infoMap); @@ -135,7 +135,7 @@ QString txt("
Layer
---" + scaledTxt + "" + unscaledTxt + "" + unscaledTxt + "" + unscaledTxt + "" + value1Txt + "" + value2Txt + "" + QString::number(data->x(), 'f', 2) + "" + QString::number(x, 'f', 2) + "" + QString::number(data->y(), 'f', 2) + "" + QString::number(y, 'f', 2) + "" + QString::number(data->distance(), 'f', 2) + "
"); std::string dataType, description; - //Identifiy datatype + // Identifiy datatype auto it = infoMap.find("_datatype"); if (it != infoMap.end()) { dataType = "System::" + it->second; @@ -149,11 +149,11 @@ description = it->second; } - //qDebug() << "layer info"; - //for(map::iterator it=infoMap.begin(); it!= infoMap.end(); it++) - //qDebug() << it->first.c_str() << it->second.c_str(); + // qDebug() << "layer info"; + // for(map::iterator it=infoMap.begin(); it!= infoMap.end(); it++) + // qDebug() << it->first.c_str() << it->second.c_str(); - //Get key profile + // Get key profile MvKeyProfile* prof = keyManager_->findProfile(dataType); if (!prof) { @@ -164,12 +164,12 @@ infoMap.reset(); - //Find out the needed keys' list + // Find out the needed keys' list for (unsigned int i = 0; i < prof->size(); i++) { - QString key = QString::fromStdString(prof->at(i)->name()); + QString key = QString::fromStdString(prof->at(i)->name()); QString label = QString::fromStdString(prof->at(i)->shortName()); - std::string group = prof->at(i)->metaData("group"); + std::string group = prof->at(i)->metaData("group"); std::string source = prof->at(i)->metaData("source"); if (group == "stats" && !statsEnabled_) @@ -177,10 +177,10 @@ if (group == "histo" && !histoEnabled_) continue; - //Get keyType + // Get keyType std::string keyType = prof->at(i)->metaData("type"); - //qDebug() << key << "type:" << keyType.c_str(); + // qDebug() << key << "type:" << keyType.c_str(); if (keyType == "table") { foreach (QString s, QString::fromStdString(prof->at(i)->metaData("column")).split("/")) { @@ -212,13 +212,13 @@ } } - //infoMap.setMode(MetaDataCollector::Append); + // infoMap.setMode(MetaDataCollector::Append); layerMetaData(infoMap); - //Find out colspan for 2nd column + // Find out colspan for 2nd column int colSpan = getColSpan(prof, infoMap); - //The first row is always the layer type + // The first row is always the layer type if (!description.empty()) { addTextInfoRow("Layer type", description.c_str(), txt, colSpan); hasData = true; @@ -235,9 +235,9 @@ } } else { - //Loop through the profile items + // Loop through the profile items for (unsigned int i = 0; i < prof->size(); i++) { - QString key = QString::fromStdString(prof->at(i)->name()); + QString key = QString::fromStdString(prof->at(i)->name()); QString label = QString::fromStdString(prof->at(i)->shortName()); if (key == "_datatype" || key == "_layertype") @@ -258,18 +258,18 @@ } - //Get keyType + // Get keyType std::string keyType = prof->at(i)->metaData("type"); if (keyType == "table") { - std::string subType = prof->at(i)->metaData("subType"); - QStringList keyLst = QString::fromStdString(prof->at(i)->metaData("column")).split("/"); + std::string subType = prof->at(i)->metaData("subType"); + QStringList keyLst = QString::fromStdString(prof->at(i)->metaData("column")).split("/"); QStringList headerLst = QString::fromStdString(prof->at(i)->metaData("header")).split("/"); addTableInfoRow(label, keyLst, headerLst, QString::fromStdString(subType), infoMap, txt, colSpan); } else if (keyType == "list") { std::string subType = prof->at(i)->metaData("subType"); - QStringList keyLst = QString::fromStdString(prof->at(i)->metaData("item")).split("/"); + QStringList keyLst = QString::fromStdString(prof->at(i)->metaData("item")).split("/"); addListInfoRow(label, keyLst, QString::fromStdString(subType), infoMap, txt); } else if (keyType == "image") { @@ -277,16 +277,16 @@ if (subType == "histogram" && histoEnabled_) { QPixmap p = layerInfoImage("histo"); if (!p.isNull()) { - //txt+=""; - txt += ""; + // txt+=""; + txt += R"()"; QTextDocument* doc = layerTe_->document(); doc->addResource(QTextDocument::ImageResource, QUrl("histo.png"), p.toImage()); - //Histogram generation updates the infos so we need to get it again! + // Histogram generation updates the infos so we need to get it again! infoMap.reset(); layerMetaData(infoMap); - //qDebug() << "histo"; - //for(map::iterator it=infoMap.begin(); it!= infoMap.end(); it++) + // qDebug() << "histo"; + // for(map::iterator it=infoMap.begin(); it!= infoMap.end(); it++) // qDebug() << it->first.c_str() << it->second.c_str(); } } @@ -295,9 +295,9 @@ } } else if (keyType == "title") { - //string dep=prof->at(i)->metaData("dependency"); - //if(dep.empty() || - // (infoMap.find(dep) != infoMap.end() && !infoMap[dep].empty())) + // string dep=prof->at(i)->metaData("dependency"); + // if(dep.empty() || + // (infoMap.find(dep) != infoMap.end() && !infoMap[dep].empty())) //{ addTitleInfoRow(label, txt, colSpan); //} @@ -316,7 +316,7 @@ txt = tr("No meta data is available for this layer!"); } - //qDebug() << "txt:" << txt; + // qDebug() << "txt:" << txt; int oldScrollPos = layerTe_->verticalScrollBar()->value(); layerTe_->setHtml(txt); @@ -325,7 +325,7 @@ void MvQLayerMetaDataWidget::addTitleInfoRow(QString label, QString& info, int colSpan) { - info += ""; + info += R"("; } void MvQLayerMetaDataWidget::addTextInfoRow(QString label, QString key, const std::map& infoMap, QString& info, int colSpan) @@ -408,18 +408,18 @@ std::map::const_iterator it; - //Loop for the columns + // Loop for the columns QList keyVal; int rowNum = 0; foreach (QString key, keys) { - //qDebug() << "key" << key; + // qDebug() << "key" << key; it = infoMap.find(key.toStdString()); if (it == infoMap.end()) return; - //qDebug() << "key" << key << QString::fromStdString(it->second); + // qDebug() << "key" << key << QString::fromStdString(it->second); keyVal << QString::fromStdString(it->second).split("/"); - //Each column must have the same number of rows + // Each column must have the same number of rows if (rowNum == 0) rowNum = keyVal.back().count(); else if (rowNum != keyVal.back().count()) @@ -465,9 +465,9 @@ } const float fVal = keyVal[3].at(i).toFloat(); - int r = static_cast(fVal / maxVal * 70.); + int r = static_cast(fVal / maxVal * 70.); painter.fillRect(0, 0, 70 + 16, 15, QColor("#F9F9F9")); - //painter.fillRect(0,0,r,15,col); + // painter.fillRect(0,0,r,15,col); painter.setBrush(col); painter.drawRect(0, 0, 10, 14); @@ -476,7 +476,7 @@ painter.drawRect(16, 0, r - 1, 14); } - //Crate a deep copy of the image to add it to the document resources + // Crate a deep copy of the image to add it to the document resources QImage imgRes = img.copy(); QString imgName = "imgBar" + QString::number(i); @@ -499,13 +499,13 @@ info += ""; } } - //We need to stretch the last column + // We need to stretch the last column else { for (int i = 0; i < headers.count() - 1; i++) { info += ""; } - info += ""; } @@ -538,7 +538,7 @@ } else { info += ""; - info += ""; + info += R"("; if (headers.count() > 0) { foreach (QString s, headers) { @@ -562,7 +562,7 @@ int MvQLayerMetaDataWidget::getColSpan(MvKeyProfile* prof, const std::map& infoMap) { - //Find out colspan for 2nd column + // Find out colspan for 2nd column int colSpan = 1; for (unsigned int i = 0; i < prof->size(); i++) { std::string group = prof->at(i)->metaData("group"); @@ -624,28 +624,28 @@ QString MvQLayerMetaDataWidget::layerMetaData(QString key) { - if (!layer_) - return QString(); + if (!layer_ || !sceneItem_) + return {}; MetaDataCollector md; std::string keyStr = key.toStdString(); - md[keyStr] = ""; + md[keyStr] = ""; sceneItem_->layerMetaDataForCurrentStep(layer_, md); return QString::fromStdString(md[keyStr]); } -//AKA histogram +// AKA histogram QPixmap MvQLayerMetaDataWidget::layerInfoImage(QString /*key*/) { - if (!layer_) - return QPixmap(); + if (!layer_ || !sceneItem_) + return {}; QStringList lst = histoVisdefCb_->itemData(histoVisdefCb_->currentIndex()).toStringList(); QHash vdef; if (lst.count() == 2) { - vdef["visdefName"] = lst[0]; + vdef["visdefName"] = lst[0]; vdef["visdefClass"] = lst[1]; } @@ -714,7 +714,7 @@ if (sceneItem_) sceneItem_->layerIconsForCurrentStep(layer_, icons); - int lastIndex; + int lastIndex = 0; if (histoVisdefCb_->count() == 0) { lastIndex = histoVisdefInitialIndex_; @@ -744,7 +744,7 @@ if (visdefPixmaps_.find(vdefClass) == visdefPixmaps_.end()) { - Cached iconFileName = MakeIconPath(vdefClass.toStdString().c_str()); + Cached iconFileName = MakeIconPath(vdefClass.toStdString().c_str()); visdefPixmaps_[vdefClass] = QPixmap::fromImage(QImage((const char*)iconFileName, "xpm")).scaled(QSize(16, 16), Qt::KeepAspectRatio, Qt::SmoothTransformation); } histoVisdefCb_->setItemIcon(histoVisdefCb_->count() - 1, visdefPixmaps_[vdefClass]); @@ -761,7 +761,7 @@ histoVisdefCb_->setCurrentIndex(histoVisdefCb_->count() - 1); } - //Update data widget + // Update data widget updateData(); } @@ -773,6 +773,6 @@ void MvQLayerMetaDataWidget::reset(MgQSceneItem* sceneItem, MgQLayerItem* layer) { sceneItem_ = sceneItem; - layer_ = layer; + layer_ = layer; setLayer(layer_); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerMetaDataWidget.h metview-5.19.2/metview/src/uPlot/MvQLayerMetaDataWidget.h --- metview-5.17.4/metview/src/uPlot/MvQLayerMetaDataWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerMetaDataWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,8 +32,8 @@ Q_OBJECT public: - MvQLayerMetaDataWidget(QWidget* parent = 0); - ~MvQLayerMetaDataWidget(); + MvQLayerMetaDataWidget(QWidget* parent = nullptr); + ~MvQLayerMetaDataWidget() override; void reset(MgQSceneItem*, MgQLayerItem*); void setHistoEnabled(bool b) { histoTb_->setChecked(b); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerModel.cc metview-5.19.2/metview/src/uPlot/MvQLayerModel.cc --- metview-5.17.4/metview/src/uPlot/MvQLayerModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -47,50 +47,50 @@ QStyleOptionViewItem vopt(option); initStyleOption(&vopt, index); - const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); + const QStyle* style = vopt.widget ? vopt.widget->style() : QApplication::style(); const QWidget* widget = vopt.widget; - //int height=option.rect.height(); + // int height=option.rect.height(); - //vopt.text=QString(); - //vopt.icon=QIcon(); + // vopt.text=QString(); + // vopt.icon=QIcon(); - //We render everything with the default method + // We render everything with the default method style->drawControl(QStyle::CE_ItemViewItem, &vopt, painter, widget); - //Get current values from model - //QString txt=index.data(Qt::DisplayRole).toString(); - //QPixmap pixmap=index.data(Qt::DecorationRole).value(); - //QBrush bg=index.data(Qt::BackgroundRole).value(); + // Get current values from model + // QString txt=index.data(Qt::DisplayRole).toString(); + // QPixmap pixmap=index.data(Qt::DecorationRole).value(); + // QBrush bg=index.data(Qt::BackgroundRole).value(); - //Save painter state + // Save painter state painter->save(); - //Highlight - //if (option.state & QStyle::State_HasFocus) - // painter->fillRect(option.rect, option.palette.highlight()); + // Highlight + // if (option.state & QStyle::State_HasFocus) + // painter->fillRect(option.rect, option.palette.highlight()); - //QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator,&vopt, widget); + // QRect checkRect = style->subElementRect(QStyle::SE_ItemViewItemCheckIndicator,&vopt, widget); QRect iconRect = style->subElementRect(QStyle::SE_ItemViewItemDecoration, &vopt, widget); - //QRect textRect = style-> subElementRect(QStyle::SE_ItemViewItemText, &vopt, widget); + // QRect textRect = style-> subElementRect(QStyle::SE_ItemViewItemText, &vopt, widget); - //Draw icon border + // Draw icon border painter->setPen(QColor(230, 230, 230)); painter->drawRect(iconRect); - //Text + // Text /*QString text=index.data(Qt::DisplayRole).toString(); - QRect textRect(iconRect.x()+iconRect.width()+10,option.rect.y()+5, - option.rect.width()-(iconRect.x()+iconRect.width()+5)-10, height/2-5); - - painter->setPen(Qt::black); - painter->drawText(textRect,Qt::AlignLeft,text);*/ + QRect textRect(iconRect.x()+iconRect.width()+10,option.rect.y()+5, + option.rect.width()-(iconRect.x()+iconRect.width()+5)-10, height/2-5); - //Draw separator line + painter->setPen(Qt::black); + painter->drawText(textRect,Qt::AlignLeft,text);*/ + + // Draw separator line painter->setPen(QColor(230, 230, 230)); painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight()); - //Restore painter state + // Restore painter state painter->restore(); } else { @@ -121,7 +121,7 @@ MvQLayerModel::MvQLayerModel(MgQPlotScene* scene) : scene_(scene), - sceneItem_(0), + sceneItem_(nullptr), higlightedId_(-1), presentableId_(1) { @@ -153,16 +153,22 @@ void MvQLayerModel::resetLayers(MgQSceneItem* scenItem) { - sceneItem_ = scenItem; - presentableId_ = atoi(sceneItem_->layout().id().c_str()); - clearIcons(); - if (sceneItem_) { - layers_ = sceneItem_->layerItems(); + sceneItem_ = scenItem; + + if (sceneItem_ != nullptr) { + presentableId_ = atoi(sceneItem_->layout().id().c_str()); + clearIcons(); + if (sceneItem_) { + layers_ = sceneItem_->layerItems(); + } + else { + layers_.clear(); + } } else { + clearIcons(); layers_.clear(); } - endResetModel(); } @@ -186,7 +192,7 @@ return item; } } - return 0; + return nullptr; } int MvQLayerModel::rowToStackLevel(int row) @@ -205,7 +211,7 @@ if (!sceneItem_) return 0; - //Non-root + // Non-root if (parent.isValid()) { int id = parent.internalId(); if (idToLevel(id) == 0) { @@ -215,7 +221,7 @@ if (!layer) return 0; - int layerId = atoi(layer->layer().id().c_str()); + int layerId = atoi(layer->layer().id().c_str()); Presentable* pres = Root::Instance().FindSuperPage(); return pres->RetrieveNumberIconsFromLayer(layerId); #else @@ -231,7 +237,7 @@ return 0; } } - //Root + // Root else { return layers_.count(); } @@ -255,19 +261,19 @@ QVariant MvQLayerModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || index.column() != 0) - return QVariant(); + return {}; int id = index.internalId(); if (idToLevel(id) == 0) { MgQLayerItem* layer = rowToLayer(id); if (!layer) - return QVariant(); + return {}; if (role == Qt::CheckStateRole) { if (layer->layerVisibility() == true) - return QVariant(Qt::Checked); + return {Qt::Checked}; else - return QVariant(Qt::Unchecked); + return {Qt::Unchecked}; } else if (role == Qt::DisplayRole) { return label(layer, index.row(), index.column()); @@ -279,7 +285,7 @@ if (higlightedId_ == id) return QColor(230, 230, 230); else - return QVariant(); + return {}; } else if (role == VisibleRole) { return checkLayerVisibility(layer); @@ -289,14 +295,14 @@ return 0; } else if (idToLevel(id) == 1) { - int parentRow = idToParentRow(id); + int parentRow = idToParentRow(id); MgQLayerItem* layer = rowToLayer(parentRow); if (!layer) - return QVariant(); + return {}; MvQLayerContentsIcon* icon = layerIcon(layer, index.row()); if (!icon) - return QVariant(); + return {}; if (role == Qt::DisplayRole) { return icon->name(); @@ -315,20 +321,20 @@ } /*else if(role == Qt::ToolTipRole) - { - MgQLayerItem* layer=rowToLayer(index.row()); - - map::const_iterator it=layer->layer().getInfos().find("Desc"); - - if( it!= layer->layer().getInfos().end()) - { - return QString::fromStdString(it->second); - } + { + MgQLayerItem* layer=rowToLayer(index.row()); + + map::const_iterator it=layer->layer().getInfos().find("Desc"); + + if( it!= layer->layer().getInfos().end()) + { + return QString::fromStdString(it->second); + } - return QVariant(); - }*/ + return QVariant(); + }*/ - return QVariant(); + return {}; } bool MvQLayerModel::setData(const QModelIndex& index, const QVariant& value, int role) @@ -344,17 +350,17 @@ if (index.column() == 0) { if (role == Qt::CheckStateRole) { MgQLayerItem* layer = rowToLayer(index.row()); - bool checked = (value.toInt() == Qt::Checked) ? true : false; + bool checked = (value.toInt() == Qt::Checked) ? true : false; if (checked != layer->layerVisibility()) { layer->setLayerVisibility(checked); emit dataChanged(index, index); - //Notify the scene about the change in the layer status + // Notify the scene about the change in the layer status if (sceneItem_) sceneItem_->updateLayers(); - //emit layerUpdate(); + // emit layerUpdate(); emit layerVisibilityChanged(QString(layer->layer().id().c_str()), checked); return true; @@ -394,29 +400,28 @@ } } - return QString(); + return {}; } MvQLayerContentsIcon* MvQLayerModel::layerIcon(MgQLayerItem* layer, int index) const { if (index < 0 || !layer) - return 0; + return nullptr; // Retrieve icon if it is already cashed QHash >::const_iterator it = icons_.find(layer); if (it != icons_.end()) { if (index < it.value().count()) { - //qDebug() << "XXXXXXXXXXXX" << it.value().at(index->name() << it.value().at(index->type() << it.value().at(index->id(); + // qDebug() << "XXXXXXXXXXXX" << it.value().at(index->name() << it.value().at(index->type() << it.value().at(index->id(); return it.value().at(index); } } -#if 1 // Icons have not been cashed yet // Get list of icons related to this layer MvIconList iconList; - int layerId = atoi(layer->layer().id().c_str()); + int layerId = atoi(layer->layer().id().c_str()); Presentable* pres = Root::Instance().FindSuperPage(); pres->RetrieveIconsFromLayer(layerId, iconList); @@ -426,16 +431,16 @@ // a) data will be shown // b) visdef will be shown if it is connected to the data, // not to the presentable - int dataId = -1; + int dataId = -1; auto lCursor = iconList.begin(); while (lCursor != iconList.end()) { - //qDebug() << "YYYYYYYYY" << iconList.size() << (*lCursor).IconName() << (*lCursor).IconClass() << (*lCursor).Id(); - // Create icon structure + // qDebug() << "YYYYYYYYY" << iconList.size() << (*lCursor).IconName() << (*lCursor).IconClass() << (*lCursor).Id(); + // Create icon structure char sId[24]; sprintf(sId, "%d", (*lCursor).Id()); // Check if this icon came from a Macro - MvRequest req = (*lCursor).Request(); + MvRequest req = (*lCursor).Request(); bool fromMacro = false; if (((const char*)req("_APPL") && strcmp((const char*)req("_APPL"), "macro") == 0) || ((const char*)req("_CALLED_FROM_MACRO") && (int)req("_CALLED_FROM_MACRO") == 1)) @@ -451,31 +456,6 @@ icons_[layer] << icon; ++lCursor; } -#else - // Icons have not been cashed yet. - // Get list of icons related to this layer - MgQIconList icons; - sceneItem_->layerIconsForCurrentStep(layer, icons); - - // Copy icons to the class structure (i.e. cash them). - // For each icon add a tag indicating if it is to be shown. - // For example, if there is a data followed by a visdef then - // a) data will be shown - // b) visdef will be shown if it is connected to the data, - // not to the presentable - int dataId = -1; - for (int i = 0; i < icons.size(); i++) { - // Create icon structure - MvQLayerContentsIcon* icon = new MvQLayerContentsIcon(icons.at(i).name_, icons.at(i).class_, icons.at(i).id_); - - // Check if icon is to be shown - bool bvis = this->checkIconVisibility(icon, dataId); - icon->visibility(bvis); - - // Add icon to the list - icons_[layer] << icon; - } -#endif it = icons_.find(layer); if (it != icons_.end()) { @@ -483,7 +463,7 @@ return it.value().at(index); } - return 0; + return nullptr; } bool MvQLayerModel::showIcon(MvQLayerContentsIcon* icon) const @@ -495,9 +475,9 @@ bool MvQLayerModel::checkIconVisibility(MvQLayerContentsIcon* icon, int& dataId) const { // Get presentable Id related to this icon - int newDataId = -1; + int newDataId = -1; Presentable* pres = Root::Instance().FindSuperPage(); - int branchId = pres->FindBranchIdByIconId(icon->id().toInt(), newDataId); + int branchId = pres->FindBranchIdByIconId(icon->id().toInt(), newDataId); if (branchId != presentableId_) return false; // Icon does not belong to current presentable @@ -526,7 +506,7 @@ if (!layer) return false; - //qDebug() << layer->name(); + // qDebug() << layer->name(); // Do not show AXES layers std::string name = layer->name().toStdString(); @@ -539,34 +519,34 @@ MvQLayerContentsIcon* MvQLayerModel::indexToIcon(const QModelIndex& index) const { if (!index.isValid() || index.column() != 0) { - return 0; + return nullptr; } int id = index.internalId(); if (idToLevel(id) == 1) { - int parentRow = idToParentRow(id); + int parentRow = idToParentRow(id); MgQLayerItem* layer = rowToLayer(parentRow); if (!layer) - return 0; + return nullptr; return layerIcon(layer, index.row()); } - return 0; + return nullptr; } QModelIndex MvQLayerModel::index(int row, int column, const QModelIndex& parent) const { if (!sceneItem_ || row < 0 || column < 0 || parent.column() > 3) { - return QModelIndex(); + return {}; } - //Parent is non-root -> level-1 items: id is the parent row (number+1)*1000 + // Parent is non-root -> level-1 items: id is the parent row (number+1)*1000 if (parent.isValid()) { int id = (parent.row() + 1) * 1000; return createIndex(row, column, id); } - //Parent is root -> level-0 items: id is the row number + // Parent is root -> level-0 items: id is the row number else { return createIndex(row, column, row); } @@ -576,19 +556,19 @@ QModelIndex MvQLayerModel::parent(const QModelIndex& index) const { if (!index.isValid()) { - return QModelIndex(); + return {}; } int id = index.internalId(); if (idToLevel(id) == 0) { - return QModelIndex(); + return {}; } else { int parentRow = idToParentRow(id); return createIndex(parentRow, 0, parentRow); } - return QModelIndex(); + return {}; } int MvQLayerModel::idToLevel(int id) const @@ -615,7 +595,7 @@ MgQLayerItem* MvQLayerModel::layer(const QModelIndex& index) const { if (!index.isValid()) - return 0; + return nullptr; return rowToLayer(index.row()); } @@ -623,7 +603,7 @@ MgQLayerItem* MvQLayerModel::layerFromAnyLevel(const QModelIndex& index) const { if (!index.isValid()) - return 0; + return nullptr; int id = index.internalId(); if (idToLevel(id) == 1) // Icon level, get its parent (the layer level) @@ -658,10 +638,10 @@ return; MgQLayerItem* layer = rowToLayer(index.row()); - float alpha = 1. - static_cast(value) / 100.; + float alpha = 1. - static_cast(value) / 100.; layer->setLayerAlpha(alpha); - //Notify the scene about the change in the layer status + // Notify the scene about the change in the layer status if (sceneItem_) sceneItem_->updateLayers(); @@ -711,7 +691,7 @@ return; } - //This list for each stackLevel assigns the corresponding Layer item + // This list for each stackLevel assigns the corresponding Layer item QList stackLevel; for (int i = 0; i < layers_.count(); i++) { bool found = false; @@ -727,13 +707,13 @@ } } - //No simpy move the sorce index to the target!! + // No simpy move the sorce index to the target!! stackLevel.move(rowToStackLevel(sourceRow), rowToStackLevel(targetRow)); QList > stackingOrder; - //Reset the stacklevels for all the layer items!!! + // Reset the stacklevels for all the layer items!!! for (int i = 0; i < stackLevel.count(); i++) { stackLevel[i]->setStackLevel(i); stackingOrder << qMakePair(QString(stackLevel[i]->layer().id().c_str()), i); @@ -743,33 +723,33 @@ /* - layers_[i]->setStackLevel(stackLevel[i]); - } + layers_[i]->setStackLevel(stackLevel[i]); + } + + QList stackLevel; + foreach(MgQLayerItem *item, layers_) + { + stackLevel << item->stackLevel(); + } - QList stackLevel; - foreach(MgQLayerItem *item, layers_) - { - stackLevel << item->stackLevel(); - } - - stackLevel.move(rowToStackLevel(sourceRow),rowToStackLevel(targetRow)); - - for(int i=0; i < stackLevel.count(); i++) - { - layers_[i]->setStackLevel(stackLevel[i]); - } - - */ + stackLevel.move(rowToStackLevel(sourceRow),rowToStackLevel(targetRow)); - //Notify the scene about the change in the layer status + for(int i=0; i < stackLevel.count(); i++) + { + layers_[i]->setStackLevel(stackLevel[i]); + } + + */ + + // Notify the scene about the change in the layer status if (sceneItem_) sceneItem_->updateLayers(); - //layers_[0]->scene()->update(); + // layers_[0]->scene()->update(); - //reset(); NOT in Qt 5 + // reset(); NOT in Qt 5 beginResetModel(); endResetModel(); } @@ -804,7 +784,7 @@ return lst.last(); #endif - return QString(); + return {}; } @@ -814,62 +794,61 @@ if (!item) return; - //MetaDataCollector mdc=metaData; + // MetaDataCollector mdc=metaData; if (sceneItem_) sceneItem_->layerMetaDataForCurrentStep(item, md); - //metaData=mdc; + // metaData=mdc; } QString MvQLayerModel::layerMetaData(const QModelIndex& index, QString key) { MgQLayerItem* item = layer(index); - if (!item) - return QString(); + if (item == nullptr || sceneItem_ == nullptr) { + return {}; + } MetaDataCollector md; std::string keyStr = key.toStdString(); - md[keyStr] = ""; - + md[keyStr] = ""; sceneItem_->layerMetaDataForCurrentStep(item, md); - return QString::fromStdString(md[keyStr]); } /* -const std::map& MvQLayerModel::layerInfo(const QModelIndex& index) +const std::map& MvQLayerModel::layerInfo(const QModelIndex& index) { - static const std::map emptyMap; + static const std::map emptyMap; - MgQLayerItem* item=layer(index); - if(!item) - return emptyMap; + MgQLayerItem* item=layer(index); + if(!item) + return emptyMap; - return scene_->getLayerInfoForCurrentStep(item); + return scene_->getLayerInfoForCurrentStep(item); } -QString MvQLayerModel::layerInfo(const QModelIndex& index,QString key) +QString MvQLayerModel::layerInfo(const QModelIndex& index,QString key) { - MgQLayerItem* item=layer(index); + MgQLayerItem* item=layer(index); + + if(!item) + return QString(); - if(!item) - return QString(); + const std::map& itemInfo=scene_->getLayerInfoForCurrentStep(item); + //const std::map& itemInfo=item->layer().getInfos(); + if(!itemInfo.empty()) + { + map::const_iterator it=item->layer().getInfos().find(key.toStdString()); + if(it != itemInfo.end()) + { + return QString::fromStdString(it->second); + } + } - const std::map& itemInfo=scene_->getLayerInfoForCurrentStep(item); - //const std::map& itemInfo=item->layer().getInfos(); - if(!itemInfo.empty()) - { - map::const_iterator it=item->layer().getInfos().find(key.toStdString()); - if(it != itemInfo.end()) - { - return QString::fromStdString(it->second); - } - } - - return QString(); + return QString(); } */ @@ -913,7 +892,7 @@ if (!data->hasFormat("application/vnd.text.list")) return false; - int beginRow; + int beginRow = 0; if (row != -1) beginRow = row; else if (parent.isValid()) @@ -949,7 +928,7 @@ { higlightedId_ = id; - //Re-render + // Re-render emit dataChanged(index, index); } @@ -968,7 +947,7 @@ bool MvQLayerFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const { QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); - bool ret = sourceModel()->data(index, MvQLayerModel::VisibleRole).toBool(); + bool ret = sourceModel()->data(index, MvQLayerModel::VisibleRole).toBool(); return ret; } @@ -981,8 +960,8 @@ MvQLayerView::MvQLayerView(QWidget* parent) : QTreeView(parent), - model_(0), - filterModel_(0), + model_(nullptr), + filterModel_(nullptr), layerId_(-1) { setMouseTracking(true); // receives mouse move events even if no buttons are pressed @@ -991,7 +970,7 @@ void MvQLayerView::setLayerModel(MvQLayerModel* m, MvQLayerFilterModel* fm) { - model_ = m; + model_ = m; filterModel_ = fm; QTreeView::setModel(fm); } @@ -1018,7 +997,6 @@ { if ((event->proposedAction() == Qt::CopyAction || event->proposedAction() == Qt::MoveAction)) { - #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QModelIndex idx = this->indexAt(event->position().toPoint()); #else @@ -1089,12 +1067,12 @@ { // Get the layer name #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QModelIndex idx = this->indexAt(event->position().toPoint()); + QModelIndex idx = this->indexAt(event->position().toPoint()); #else - QModelIndex idx = this->indexAt(event->pos()); + QModelIndex idx = this->indexAt(event->pos()); #endif QModelIndex index = filterModel_->mapToSource(idx); - QString lname = model_->layerName(index); + QString lname = model_->layerName(index); if (lname.isEmpty()) { removeDropTarget(); return; diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerModel.h metview-5.19.2/metview/src/uPlot/MvQLayerModel.h --- metview-5.17.4/metview/src/uPlot/MvQLayerModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,10 +29,10 @@ class MvQLayerDelegate : public QStyledItemDelegate { public: - MvQLayerDelegate(QWidget* parent = 0); + MvQLayerDelegate(QWidget* parent = nullptr); void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; + const QModelIndex& index) const override; + QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; private: int itemHeight_; @@ -45,23 +45,23 @@ public: MvQLayerModel(MgQPlotScene*); - ~MvQLayerModel(); + ~MvQLayerModel() override; enum CustomItemRole { VisibleRole = Qt::UserRole + 1, - LevelRole = Qt::UserRole + 2 + LevelRole = Qt::UserRole + 2 }; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex&, const QVariant&, int role = Qt::EditRole); - //QVariant headerData(int,Qt::Orientation,int role = Qt::DisplayRole ) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex&, const QVariant&, int role = Qt::EditRole) override; + // QVariant headerData(int,Qt::Orientation,int role = Qt::DisplayRole ) const; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; // Layers functions QList& layers() { return layers_; } @@ -81,13 +81,13 @@ void moveTop(const QModelIndex& index); void moveBottom(const QModelIndex& index); - Qt::ItemFlags flags(const QModelIndex&) const; + Qt::ItemFlags flags(const QModelIndex&) const override; - Qt::DropActions supportedDropActions() const; - QStringList mimeTypes() const; - QMimeData* mimeData(const QModelIndexList&) const; + Qt::DropActions supportedDropActions() const override; + QStringList mimeTypes() const override; + QMimeData* mimeData(const QModelIndexList&) const override; bool dropMimeData(const QMimeData* data, Qt::DropAction action, - int row, int column, const QModelIndex& parent); + int row, int column, const QModelIndex& parent) override; void setTransparency(const QModelIndex&, int); int transparency(const QModelIndex&); @@ -145,9 +145,9 @@ class MvQLayerFilterModel : public QSortFilterProxyModel { public: - MvQLayerFilterModel(QObject* parent = 0); + MvQLayerFilterModel(QObject* parent = nullptr); - bool filterAcceptsRow(int, const QModelIndex&) const; + bool filterAcceptsRow(int, const QModelIndex&) const override; }; @@ -159,15 +159,15 @@ Q_OBJECT public: - explicit MvQLayerView(QWidget* parent = 0); + explicit MvQLayerView(QWidget* parent = nullptr); void setLayerModel(MvQLayerModel*, MvQLayerFilterModel*); protected: - void dragEnterEvent(QDragEnterEvent*); - void dragLeaveEvent(QDragLeaveEvent*); - void dragMoveEvent(QDragMoveEvent*); - void dropEvent(QDropEvent*); + void dragEnterEvent(QDragEnterEvent*) override; + void dragLeaveEvent(QDragLeaveEvent*) override; + void dragMoveEvent(QDragMoveEvent*) override; + void dropEvent(QDropEvent*) override; // Handle MvQDropTarget facility void checkDropTarget(QDropEvent*); diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerSuperPage.cc metview-5.19.2/metview/src/uPlot/MvQLayerSuperPage.cc --- metview-5.17.4/metview/src/uPlot/MvQLayerSuperPage.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerSuperPage.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,10 +36,10 @@ int MvQLayerSuperPageModel::columnCount(const QModelIndex& parent) const { - //if ( parent.isValid() ) - // qDebug() << "MvQLayerSuperPageModel::columnCount 0"; - //else - // qDebug() << "MvQLayerSuperPageModel::columnCount 1"; + // if ( parent.isValid() ) + // qDebug() << "MvQLayerSuperPageModel::columnCount 0"; + // else + // qDebug() << "MvQLayerSuperPageModel::columnCount 1"; return parent.isValid() ? 0 : 1; } @@ -57,46 +57,46 @@ if (role != Qt::DisplayRole && role != Qt::DecorationRole && role != Qt::ForegroundRole && role != Qt::UserRole && role != Qt::FontRole) - return QVariant(); + return {}; if (!index.isValid()) - return QVariant(); + return {}; if (index.row() < 0 || index.row() >= icons_.count()) - return QVariant(); + return {}; MvQLayerContentsIcon icon = icons_[index.row()]; - //qDebug() << "MvQLayerSuperPageModel::data " << icon.name() << icon.type() << icon.id(); + // qDebug() << "MvQLayerSuperPageModel::data " << icon.name() << icon.type() << icon.id(); switch (role) { - case Qt::DecorationRole: { //qDebug() << "DecorationRole"; + case Qt::DecorationRole: { // qDebug() << "DecorationRole"; return icon.pixmap(); } - case Qt::DisplayRole: { //qDebug() << "DisplayRole"; + case Qt::DisplayRole: { // qDebug() << "DisplayRole"; return icon.name(); } // case Qt::UserRole: // return icon->path(); - default: { //qDebug() << "default"; + default: { // qDebug() << "default"; break; } } - return QVariant(); + return {}; } QModelIndex MvQLayerSuperPageModel::index(int row, int column, const QModelIndex& /*parent */) const { - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } QModelIndex MvQLayerSuperPageModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } void MvQLayerSuperPageModel::setIcons(MvIconList& iconList) @@ -120,7 +120,7 @@ MvQLayerContentsIcon* MvQLayerSuperPageModel::indexToIcon(const QModelIndex& index) { - MvQLayerContentsIcon* icon = 0; + MvQLayerContentsIcon* icon = nullptr; if (!index.isValid() || index.column() < 0 || index.column() > icons_.count()) return icon; @@ -213,7 +213,7 @@ { foreach (QAction* ac, actions_) { delete ac; - ac = 0; + ac = nullptr; } } diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerViewLevel.cc metview-5.19.2/metview/src/uPlot/MvQLayerViewLevel.cc --- metview-5.17.4/metview/src/uPlot/MvQLayerViewLevel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerViewLevel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -54,17 +54,17 @@ if (role != Qt::DisplayRole && role != Qt::DecorationRole && role != Qt::ForegroundRole && role != Qt::UserRole && role != Qt::FontRole) - return QVariant(); + return {}; if (!index.isValid()) - return QVariant(); + return {}; if (index.row() < 0 || index.row() >= icons_.count()) - return QVariant(); + return {}; MvQLayerContentsIcon icon = icons_[index.row()]; - //qDebug() << "MvQLayerViewLevelModel::data " << icon.name() << icon.type() << icon.id(); + // qDebug() << "MvQLayerViewLevelModel::data " << icon.name() << icon.type() << icon.id(); switch (role) { case Qt::DecorationRole: { @@ -82,18 +82,18 @@ } } - return QVariant(); + return {}; } QModelIndex MvQLayerViewLevelModel::index(int row, int column, const QModelIndex& /*parent */) const { - return createIndex(row, column, (void*)0); + return createIndex(row, column, (void*)nullptr); } QModelIndex MvQLayerViewLevelModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } void MvQLayerViewLevelModel::setIcons(MvIconList& iconList) @@ -117,7 +117,7 @@ MvQLayerContentsIcon* MvQLayerViewLevelModel::indexToIcon(const QModelIndex& index) { - MvQLayerContentsIcon* icon = 0; + MvQLayerContentsIcon* icon = nullptr; if (!index.isValid() || index.column() < 0 || index.column() > icons_.count()) return icon; @@ -157,7 +157,7 @@ presentableId(presId); MvIconList iconList; if (!this->getIconsFromDB(presId, iconList)) - return; //presentable not found or no icons found + return; // presentable not found or no icons found // Update list of icons setIcons(iconList); @@ -166,7 +166,7 @@ int MvQLayerViewLevelModel::getIconsFromDB(int presId, MvIconList& iconList) { // Get Presentable associated to the input Id - Presentable* sp = Root::Instance().FindSuperPage(); + Presentable* sp = Root::Instance().FindSuperPage(); Presentable* pres = sp->FindBranch(presId); if (!pres) return 0; // presentable not found @@ -229,9 +229,9 @@ // Context menu createContextMenu(); setContextMenuPolicy(Qt::ActionsContextMenu); - //setContextMenuPolicy(Qt::CustomContextMenu); - //connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), - // this, SLOT(slotContextMenu(const QPoint&))); + // setContextMenuPolicy(Qt::CustomContextMenu); + // connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), + // this, SLOT(slotContextMenu(const QPoint&))); // Drag and Drop settings setMouseTracking(true); @@ -247,7 +247,7 @@ { foreach (QAction* ac, actions_) { delete ac; - ac = 0; + ac = nullptr; } } @@ -349,7 +349,7 @@ addAction(actionSave_); connect(actionSave_, SIGNAL(triggered()), this, SLOT(slotSave())); - //Insert Save As key + // Insert Save As key actionSaveAs_ = new QAction(this); actionSaveAs_->setObjectName(QString::fromUtf8("actionSaveAs")); actionSaveAs_->setText(tr("Save as ...")); diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerViewLevel.h metview-5.19.2/metview/src/uPlot/MvQLayerViewLevel.h --- metview-5.17.4/metview/src/uPlot/MvQLayerViewLevel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerViewLevel.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,15 +22,15 @@ public: // Constructors & destructors - MvQLayerViewLevelModel(QObject* parent = 0); - ~MvQLayerViewLevelModel(); + MvQLayerViewLevelModel(QObject* parent = nullptr); + ~MvQLayerViewLevelModel() override; // View-model functions - int columnCount(const QModelIndex&) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + int columnCount(const QModelIndex&) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; // Member functions // Initialize icon list @@ -75,8 +75,8 @@ Q_OBJECT public: - MvQLayerViewLevelView(MvQLayerViewLevelModel*, QWidget* parent = 0); - ~MvQLayerViewLevelView(); + MvQLayerViewLevelView(MvQLayerViewLevelModel*, QWidget* parent = nullptr); + ~MvQLayerViewLevelView() override; public slots: @@ -96,12 +96,12 @@ protected: - void currentChanged(const QModelIndex&, const QModelIndex&); + void currentChanged(const QModelIndex&, const QModelIndex&) override; - void dragEnterEvent(QDragEnterEvent*); - void dragLeaveEvent(QDragLeaveEvent*); - void dragMoveEvent(QDragMoveEvent*); - void dropEvent(QDropEvent*); + void dragEnterEvent(QDragEnterEvent*) override; + void dragLeaveEvent(QDragLeaveEvent*) override; + void dragMoveEvent(QDragMoveEvent*) override; + void dropEvent(QDropEvent*) override; void createContextMenu(); diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerWidget.cc metview-5.19.2/metview/src/uPlot/MvQLayerWidget.cc --- metview-5.17.4/metview/src/uPlot/MvQLayerWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,13 +43,13 @@ // Top level: model and view initializations spModel_ = new MvQLayerSuperPageModel(this); - spView_ = new MvQLayerSuperPageView(spModel_, this); + spView_ = new MvQLayerSuperPageView(spModel_, this); layerVb->addWidget(MvQ::makeLabelPanel(tr("Top Level"), this, -1)); layerVb->addWidget(spView_); // View level: model and view initializations vlModel_ = new MvQLayerViewLevelModel(this); - vlView_ = new MvQLayerViewLevelView(vlModel_, this); + vlView_ = new MvQLayerViewLevelView(vlModel_, this); layerVb->addWidget(MvQ::makeLabelPanel(tr("View Level"), this, -1)); layerVb->addWidget(vlView_); @@ -59,7 +59,7 @@ layerVb->addWidget(MvQ::makeLabelPanel(tr("Layer Level"), this, -1)); layerVb->addWidget(view_); - model_ = new MvQLayerModel(scene); + model_ = new MvQLayerModel(scene); filterModel_ = new MvQLayerFilterModel(this); filterModel_->setSourceModel(model_); view_->setLayerModel(model_, filterModel_); @@ -77,7 +77,7 @@ view_->setContextMenuPolicy(Qt::CustomContextMenu); connect(view_, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotContextMenu(const QPoint&))); - //Slider + // Slider auto* hb = new QHBoxLayout; layerVb->addLayout(hb); @@ -108,7 +108,7 @@ connect(trSpin_, SIGNAL(valueChanged(int)), this, SLOT(slotTrSpinValueChanged(int))); - //Buttons + // Buttons hb = new QHBoxLayout; layerVb->addLayout(hb); @@ -189,7 +189,7 @@ MgQLayerItem* MvQLayerWidget::currentLayer() { QModelIndex modelIndex = filterModel_->mapToSource(view_->currentIndex()); - int row = modelIndex.row(); + int row = modelIndex.row(); return model_->rowToLayer(row); } @@ -201,7 +201,7 @@ void MvQLayerWidget::slotSelectLayer(MgQLayerItem* layer) { - int row = model_->layerToRow(layer); + int row = model_->layerToRow(layer); QModelIndex index = filterModel_->mapFromSource(model_->index(row, 0)); slotSelectLayer(index); } @@ -276,7 +276,7 @@ void MvQLayerWidget::slotMoveUp() { QModelIndex modelIndex = filterModel_->mapToSource(view_->currentIndex()); - int row = modelIndex.row(); + int row = modelIndex.row(); model_->moveUp(modelIndex); @@ -291,7 +291,7 @@ QModelIndex modelIndex = filterModel_->mapToSource(view_->currentIndex()); model_->moveBottom(modelIndex); - int num = model_->rowCount(QModelIndex()); + int num = model_->rowCount(QModelIndex()); QModelIndex proxyIndex = filterModel_->mapFromSource(model_->index(num - 1, 0)); view_->setCurrentIndex(proxyIndex); @@ -301,7 +301,7 @@ void MvQLayerWidget::slotMoveDown() { QModelIndex modelIndex = filterModel_->mapToSource(view_->currentIndex()); - int row = modelIndex.row(); + int row = modelIndex.row(); model_->moveDown(modelIndex); @@ -409,15 +409,15 @@ auto* actionEdit = new QAction(this); actionEdit->setObjectName(QString::fromUtf8("actionEdit")); actionEdit->setText(tr("Edit in Plot")); - //QFont font = actionEdit->font(); - //font.setWeight(QFont::Bold); - //actionEdit->setFont(font); + // QFont font = actionEdit->font(); + // font.setWeight(QFont::Bold); + // actionEdit->setFont(font); actionEdit->setShortcut(QKeySequence(tr("Ctrl+E"))); actions.append(actionEdit); if (!icon->canBeEdited()) actionEdit->setEnabled(false); - //Insert Save key + // Insert Save key auto* actionSave = new QAction(this); actionSave->setObjectName(QString::fromUtf8("actionSave")); actionSave->setText(tr("Overwrite on disk")); @@ -426,7 +426,7 @@ if (!icon->canBeSaved()) actionSave->setEnabled(false); - //Insert Save As key + // Insert Save As key auto* actionSaveAs = new QAction(this); actionSaveAs->setObjectName(QString::fromUtf8("actionSaveAs")); actionSaveAs->setText(tr("Save as ...")); @@ -435,7 +435,7 @@ if (!icon->canBeSavedAs()) actionSaveAs->setEnabled(false); - //Insert Delete key + // Insert Delete key auto* actionDelete = new QAction(this); actionDelete->setObjectName(QString::fromUtf8("actionDelete")); actionDelete->setText(tr("Remove from Plot")); @@ -467,7 +467,7 @@ void MvQLayerWidget::layersAreAboutToChange() { - //Save expand state + // Save expand state QModelIndexList indexLst = model_->match(model_->index(0, 0), Qt::DisplayRole, "*", -1, Qt::MatchWildcard | Qt::MatchRecursive); @@ -485,29 +485,29 @@ /*void MvQLayerWidget::reset(MgQSceneItem *sceneItem,int layerIndex) { - model_->resetLayers(sceneItem); - - QModelIndex index=model_->index(layerIndex,0); - if(!index.isValid()) - { - index=model_->index(model_->rowCount()-1,0); - } - - if(index.isValid()) - { - slotSelectLayer(index); - } - else - { - slotCheckItemStatus(); - } + model_->resetLayers(sceneItem); + + QModelIndex index=model_->index(layerIndex,0); + if(!index.isValid()) + { + index=model_->index(model_->rowCount()-1,0); + } + + if(index.isValid()) + { + slotSelectLayer(index); + } + else + { + slotCheckItemStatus(); + } }*/ void MvQLayerWidget::reset(MgQSceneItem* sceneItem, MgQLayerItem* layer) { model_->resetLayers(sceneItem); - int row = model_->layerToRow(layer); + int row = model_->layerToRow(layer); QModelIndex index = filterModel_->mapFromSource(model_->index(row, 0)); if (index.isValid()) { // slotSelectLayer(index); @@ -517,7 +517,7 @@ slotCheckItemStatus(); } - //Try to restore the expand state + // Try to restore the expand state foreach (QModelIndex index, expandList_) { if (model_->hasChildren(index)) { QModelIndex proxyIndex = filterModel_->mapFromSource(index); @@ -528,7 +528,7 @@ void MvQLayerWidget::reset(MgQSceneItem* sceneItem) { - MgQLayerItem* layer = nullptr; + MgQLayerItem* layer = nullptr; MgQLayerItem* lastLayer = nullptr; if (sceneItem) { @@ -537,7 +537,7 @@ vlModel_->reset(presId); for (int i = sceneItem->layerItems().count() - 1; i >= 0; i--) { MgQLayerItem* item = sceneItem->layerItems().at(i); - lastLayer = item; + lastLayer = item; QString str(item->layer().name().c_str()); QStringList lst = str.split("/"); @@ -555,9 +555,9 @@ layer = lastLayer; } - //contentsLoaded_=false; + // contentsLoaded_=false; reset(sceneItem, layer); - //contentsLoaded_=true; + // contentsLoaded_=true; } @@ -573,22 +573,22 @@ return -1; - //Get the dataUinitId + // Get the dataUinitId /*MvIcon& dropIcon = cl->GetIconMain (); - Cached verbTarget = dropIcon.Request ().getVerb (); - if ( ObjectList::IsDataUnit ( verbTarget ) == true ) - set_value ( id->header, "_CONTENTS_DATAUNIT_ID", "%d", dropIcon.Id());*/ + Cached verbTarget = dropIcon.Request ().getVerb (); + if ( ObjectList::IsDataUnit ( verbTarget ) == true ) + set_value ( id->header, "_CONTENTS_DATAUNIT_ID", "%d", dropIcon.Id());*/ /*if(index.isValid()) - { - MgQLayerItem *layer=model_->rowToLayer(index.row()); - if(layer) - { - QString str(layer->layer().name().c_str()); - } - } - - */ + { + MgQLayerItem *layer=model_->rowToLayer(index.row()); + if(layer) + { + QString str(layer->layer().name().c_str()); + } + } + + */ } void MvQLayerWidget::slotIconDropped(const MvQDrop& source, const QModelIndex& target) @@ -601,7 +601,7 @@ } // Consistency check - int duId; + int duId = 0; if (!checkDroppedIcon(source, layer, duId)) { MvLog().popup().warn() << "Invalid icon drop! This icon cannot be applied to layer=" << layer->name(); return; @@ -722,7 +722,7 @@ dropRequest("ACTION") = 3; MvRequest subreq("DROP"); - subreq("DROP_ID") = model_->presentableId(); + subreq("DROP_ID") = model_->presentableId(); subreq("_CONTENTS") = 1; if (duId > 0) subreq("_CONTENTS_DATAUNIT_ID") = duId; @@ -793,7 +793,7 @@ dropRequest("ACTION") = 3; MvRequest subreq("DROP"); - subreq("DROP_ID") = spModel_->presentableId(); + subreq("DROP_ID") = spModel_->presentableId(); subreq("_CONTENTS") = 1; // if ( duId > 0 ) // subreq("_CONTENTS_DATAUNIT_ID") = duId; @@ -821,7 +821,7 @@ dropRequest("ACTION") = 3; MvRequest subreq("DROP"); - subreq("DROP_ID") = vlModel_->presentableId(); + subreq("DROP_ID") = vlModel_->presentableId(); subreq("_CONTENTS") = 1; // Create the dropped icons request @@ -847,7 +847,7 @@ // Get list of icons related to this layer duId = -1; MvIconList iconList; - int layerId = atoi(layer->layer().id().c_str()); + int layerId = atoi(layer->layer().id().c_str()); Presentable* pres = Root::Instance().FindSuperPage(); pres->RetrieveIconsFromLayer(layerId, iconList); if (iconList.empty()) @@ -856,13 +856,13 @@ // Get the target icon class by taking the first icon from the list. // If there is a dataUnit, it is the first in the list auto lCursor = iconList.begin(); - //qDebug() << iconList.size() << (*lCursor).IconName() << (*lCursor).IconClass() << (*lCursor).Id(); + // qDebug() << iconList.size() << (*lCursor).IconName() << (*lCursor).IconClass() << (*lCursor).Id(); std::string targetClass = (*lCursor).IconClass(); #else // Get the target icon class by taking the first icon from the list - duId = -1; + duId = -1; std::vector::const_iterator it = layer->layer().iconsBegin(); - assert(it != layer->layer().iconsEnd()); //must have at least one icon + assert(it != layer->layer().iconsEnd()); // must have at least one icon std::string targetClass = (*it).iconClass(); #endif @@ -870,7 +870,7 @@ // (e.g., READ and GRIB are both dataunits). std::string sourceClass; bool targetDu = ObjectList::IsDataUnit(targetClass.c_str()); - bool flag = true; + bool flag = true; for (int i = 0; i < source.iconNum(); i++) { sourceClass = source.iconClass(i).toStdString(); if (targetClass != sourceClass) { @@ -899,7 +899,7 @@ } // Exception accepted - duId = (*lCursor).Id(); //atoi((*it).iconId().c_str()); + duId = (*lCursor).Id(); // atoi((*it).iconId().c_str()); return true; } diff -Nru metview-5.17.4/metview/src/uPlot/MvQLayerWidget.h metview-5.19.2/metview/src/uPlot/MvQLayerWidget.h --- metview-5.17.4/metview/src/uPlot/MvQLayerWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLayerWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -38,7 +38,7 @@ public: MvQLayerContentsItemEditor(const Cached& name); - ~MvQLayerContentsItemEditor() {} + ~MvQLayerContentsItemEditor() = default; void EditedDefinition(MvRequest&); }; @@ -48,8 +48,8 @@ Q_OBJECT public: - MvQLayerWidget(MgQPlotScene*, QWidget* parent = 0); - ~MvQLayerWidget() {} + MvQLayerWidget(MgQPlotScene*, QWidget* parent = nullptr); + ~MvQLayerWidget() override = default; void layersAreAboutToChange(); void reset(MgQSceneItem*, MgQLayerItem*); void reset(MgQSceneItem*); diff -Nru metview-5.17.4/metview/src/uPlot/MvQLineSelection.cc metview-5.19.2/metview/src/uPlot/MvQLineSelection.cc --- metview-5.17.4/metview/src/uPlot/MvQLineSelection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLineSelection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,7 @@ ***************************** LICENSE END *************************************/ -#include +#include #include #include @@ -23,23 +23,23 @@ { pen_ = QPen(QColor(0, 0, 255, 230), 2); pen_.setCosmetic(true); - //pen_=QPen(QColor(103,140,168),2); - brush_ = QBrush(QColor(164, 219, 255, 180)); + // pen_=QPen(QColor(103,140,168),2); + brush_ = QBrush(QColor(164, 219, 255, 180)); currentAction_ = NoAction; - zoomLayout_ = nullptr; - line_ = QLine(); + zoomLayout_ = nullptr; + line_ = QLine(); arrowPen_ = QPen(QColor(0, 0, 0)); arrowPen_.setCosmetic(true); - //arrowBrush_=QBrush(QColor(103,140,168)); + // arrowBrush_=QBrush(QColor(103,140,168)); arrowBrush_ = QBrush(QColor(0, 0, 255)); selectionPen_ = QPen(QColor(0, 0, 0), 2); selectionPen_.setStyle(Qt::DotLine); selectionPen_.setCosmetic(true); - resizeId_ = -1; - handleSize_ = 8.; + resizeId_ = -1; + handleSize_ = 8.; physicalHandleSize_ = 8.; for (int i = 0; i < 2; i++) { handle_ << QRectF(0., 0., handleSize_, handleSize_); @@ -88,18 +88,18 @@ checkHandleSize(); /*painter->setBrush(startBrush_); - painter->drawEllipse(QRectF(line_.p1().x()-5,line_.p1().y()-5, - 10,10)); + painter->drawEllipse(QRectF(line_.p1().x()-5,line_.p1().y()-5, + 10,10)); - painter->setBrush(endBrush_); - painter->drawEllipse(QRectF(line_.p2().x()-5,line_.p2().y()-5, - 10,10)); - painter->setBrush(QBrush());*/ + painter->setBrush(endBrush_); + painter->drawEllipse(QRectF(line_.p2().x()-5,line_.p2().y()-5, + 10,10)); + painter->setBrush(QBrush());*/ painter->setRenderHint(QPainter::Antialiasing); painter->setBrush(QBrush()); - //Outline + // Outline if (currentAction_ == ResizeAction || currentAction_ == MoveAction || showHandles_) { painter->setPen(selectionPen_); @@ -109,21 +109,21 @@ } painter->drawLine(line_); - //Draw arrow + // Draw arrow QPolygonF arrow; QPointF cp((line_.p1().x() + line_.p2().x()) / 2., (line_.p1().y() + line_.p2().y()) / 2.); arrow << QPointF(0., 0.) << QPointF(-arrowSize_, arrowSize_ / 2.) << QPointF(-arrowSize_, -arrowSize_ / 2.); - //arrow.translate(cp); + // arrow.translate(cp); float angle = atan2f(line_.p2().y() - line_.p1().y(), line_.p2().x() - line_.p1().x()); angle = angle * 180. / M_PI; - //qDebug() << "angle" << angle*180./M_PI; + // qDebug() << "angle" << angle*180./M_PI; painter->setPen(arrowPen_); painter->setBrush(arrowBrush_); @@ -136,7 +136,7 @@ painter->setRenderHint(QPainter::Antialiasing, false); - //Handlers + // Handlers if (showHandles_) { for (int i = 0; i < handle_.count(); i++) { QRectF r = handle_[i]; @@ -165,7 +165,7 @@ handleHover_ = -1; if (line_.isNull()) { - //Get item position + // Get item position lineOrigin_ = mapFromScene(plotView_->mapToScene(event->pos())); if ((zoomLayout_ = plotScene_->findProjectorItem(mapToScene(lineOrigin_))) == nullptr) { @@ -180,10 +180,10 @@ } else { - //float dh=handleSize_/2; - //QRectF cRect=controlRect(); + // float dh=handleSize_/2; + // QRectF cRect=controlRect(); - //qDebug() << "crect" << cRect; + // qDebug() << "crect" << cRect; dragPos_ = mapFromScene(plotView_->mapToScene(event->pos())); @@ -194,7 +194,7 @@ resizeId_ = -1; for (int i = 0; i < handle_.count(); i++) { - //If a handle is selected it starts a resize action + // If a handle is selected it starts a resize action if (handle_[i].contains(xp)) { resizeId_ = i; @@ -203,21 +203,21 @@ setCursor(QCursor(shape)); currentAction_ = ResizeAction; - //qDebug() << "resizeId" << resizeId_; + // qDebug() << "resizeId" << resizeId_; return; } } - //If no resize action it checks if the drag point is - //in the selection rentangle and starts a move action + // If no resize action it checks if the drag point is + // in the selection rentangle and starts a move action if (resizeId_ == -1) { currentAction_ = MoveAction; setCursor(QCursor(Qt::SizeAllCursor)); } - //Otherwise unselect + // Otherwise unselect else { currentAction_ = NoAction; - dragPos_ = QPointF(); + dragPos_ = QPointF(); if (showHandles_) { showHandles_ = false; update(); @@ -226,7 +226,7 @@ } else { currentAction_ = NoAction; - dragPos_ = QPointF(); + dragPos_ = QPointF(); if (showHandles_) { showHandles_ = false; @@ -241,7 +241,7 @@ if (!activated_ || !acceptMouseEvents_) return; - //qDebug() << "mouseMove in area"; + // qDebug() << "mouseMove in area"; QPointF pos = mapFromScene(plotView_->mapToScene(event->pos())); if (currentAction_ == DefineAction) { @@ -274,8 +274,8 @@ ln = QLineF(line_.p1(), p); prepareGeometryChange(); - line_ = ln; - dragPos_ = pos; + line_ = ln; + dragPos_ = pos; showHandles_ = false; update(); } @@ -285,7 +285,7 @@ prepareGeometryChange(); line_.translate(dp); - dragPos_ = pos; + dragPos_ = pos; showHandles_ = false; update(); } @@ -334,7 +334,7 @@ line_ = QLineF(lineOrigin_, p2); update(); - //Get geo coordinates of rect corners + // Get geo coordinates of rect corners QPointF sp1 = line_.p1(); QPointF sp2 = line_.p2(); QPointF gp1, gp2; @@ -342,7 +342,7 @@ zoomLayout_->mapFromSceneToGeoCoords(mapToScene(sp2), gp2); currentAction_ = NoAction; - zoomLayout_ = nullptr; + zoomLayout_ = nullptr; coordPoint_.clear(); coordPoint_ << gp1 << gp2; @@ -372,9 +372,9 @@ prepareGeometryChange(); line_ = ln; - //update(); + // update(); - //Get geo coordinates of rect corners + // Get geo coordinates of rect corners QPointF sp1 = line_.p1(); QPointF sp2 = line_.p2(); QPointF gp1, gp2; @@ -382,8 +382,8 @@ zoomLayout_->mapFromSceneToGeoCoords(mapToScene(sp2), gp2); currentAction_ = NoAction; - zoomLayout_ = nullptr; - dragPos_ = QPointF(); + zoomLayout_ = nullptr; + dragPos_ = QPointF(); coordPoint_.clear(); coordPoint_ << gp1 << gp2; @@ -409,8 +409,8 @@ zoomLayout_->mapFromSceneToGeoCoords(mapToScene(sp2), gp2); currentAction_ = NoAction; - zoomLayout_ = nullptr; - dragPos_ = QPointF(); + zoomLayout_ = nullptr; + dragPos_ = QPointF(); coordPoint_.clear(); coordPoint_ << gp1 << gp2; @@ -426,7 +426,7 @@ void MvQLineSelection::setLine(double lat1, double lon1, double lat2, double lon2) { - //double west, double north, double east, double south) + // double west, double north, double east, double south) double x1 = lon1; double y1 = lat1; @@ -501,7 +501,7 @@ if (coordPoint_.isEmpty() || line_.isNull()) return; - //We need to find the projectorItem!! + // We need to find the projectorItem!! QPointF sp0, sp1; if ((zoomLayout_ = plotScene_->firstProjectorItem()) == nullptr) { @@ -513,7 +513,7 @@ QPointF gp0 = coordPoint_[0]; QPointF gp1 = coordPoint_[1]; - //qDebug() << coordPoint_; + // qDebug() << coordPoint_; if (zoomLayout_->containsGeoCoords(gp0) && zoomLayout_->containsGeoCoords(gp1)) { @@ -567,8 +567,8 @@ checkHandleSize(); float dh = handleSize_ / 2.; - float w = line_.p2().x() - line_.p1().x(); - float h = line_.p2().y() - line_.p1().y(); + float w = line_.p2().x() - line_.p1().x(); + float h = line_.p2().y() - line_.p1().y(); handle_[0].moveTo(-dh, -dh); handle_[1].moveTo(w - dh, h - dh); } @@ -590,7 +590,7 @@ return; } - //Plot area in scene coordinates + // Plot area in scene coordinates QRectF plotRect = mapRectFromScene(zoomLayout_->mapToScene(zoomLayout_->boundingRect()).boundingRect()); if (p2.x() > plotRect.right()) { @@ -613,39 +613,39 @@ dp = QPointF(); } - //Plot area in scene coordinates - //QRectF plotRect=zoomLayout_->mapToScene(zoomLayout_->boundingRect()).boundingRect(); + // Plot area in scene coordinates + // QRectF plotRect=zoomLayout_->mapToScene(zoomLayout_->boundingRect()).boundingRect(); - //qDebug() << "delta" << dp; + // qDebug() << "delta" << dp; QLineF r = line_.translated(dp); - //qDebug() << "translated" << r; + // qDebug() << "translated" << r; QPointF p1 = r.p1(); checkEndPoint(p1); QPointF delta1 = p1 - r.p1(); - //qDebug() << "1 p/delta" << p1 << delta1; + // qDebug() << "1 p/delta" << p1 << delta1; r.translate(delta1); dp = dp + delta1; - //qDebug() << r << dp; + // qDebug() << r << dp; QPointF p2 = r.p2(); checkEndPoint(p2); QPointF delta2 = p2 - r.p2(); - //qDebug() << "2 p/delta" << p2 << delta2; + // qDebug() << "2 p/delta" << p2 << delta2; r.translate(p2 - r.p2()); dp = dp + delta2; - //qDebug() << "dp" << dp; + // qDebug() << "dp" << dp; } bool MvQLineSelection::checkPointInLineArea(QPointF& p) @@ -661,7 +661,7 @@ double rlen = sqrt(r.x() * r.x() + r.y() * r.y()); double dlen = sqrt(d.x() * d.x() + d.y() * d.y()); - //scalar product + // scalar product double sp = d.x() * r.x() + d.y() * r.y(); double dp; @@ -669,12 +669,12 @@ dp = dlen; else { double dpr = sp / rlen; - dp = sqrt(dlen * dlen - dpr * dpr); + dp = sqrt(dlen * dlen - dpr * dpr); } if (fabs(dp) < maxd) { - QPointF d2 = p - p2; - double lsp = d.x() * d2.x() + d.y() * d2.y(); + QPointF d2 = p - p2; + double lsp = d.x() * d2.x() + d.y() * d2.y(); double d2len = sqrt(d2.x() * d2.x() + d2.y() * d2.y()); if (lsp > 0 && dlen > maxd && d2len > maxd) { return false; @@ -689,7 +689,7 @@ void MvQLineSelection::checkHandleSize() const { handleSize_ = physicalHandleSize_ / parentItem()->scale(); - arrowSize_ = 10. / parentItem()->scale(); + arrowSize_ = 10. / parentItem()->scale(); for (int i = 0; i < 2; i++) { handle_[i].setWidth(handleSize_); diff -Nru metview-5.17.4/metview/src/uPlot/MvQLineSelection.h metview-5.19.2/metview/src/uPlot/MvQLineSelection.h --- metview-5.17.4/metview/src/uPlot/MvQLineSelection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQLineSelection.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,21 +22,21 @@ Q_OBJECT public: - MvQLineSelection(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = 0); - ~MvQLineSelection(); + MvQLineSelection(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = nullptr); + ~MvQLineSelection() override; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); - QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; + QRectF boundingRect() const override; void setLine(double, double, double, double); void clearLine(); - void setActivated(bool); + void setActivated(bool) override; - void mousePressEventFromView(QMouseEvent*); - void mouseMoveEventFromView(QMouseEvent*); - void mouseReleaseEventFromView(QMouseEvent*); - void reset(); + void mousePressEventFromView(QMouseEvent*) override; + void mouseMoveEventFromView(QMouseEvent*) override; + void mouseReleaseEventFromView(QMouseEvent*) override; + void reset() override; void changeDirection(); signals: diff -Nru metview-5.17.4/metview/src/uPlot/MvQMagnifier.cc metview-5.19.2/metview/src/uPlot/MvQMagnifier.cc --- metview-5.17.4/metview/src/uPlot/MvQMagnifier.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQMagnifier.cc 2023-07-15 08:28:47.000000000 +0000 @@ -9,7 +9,7 @@ #include "MvQMagnifier.h" -#include +#include #include #include @@ -29,10 +29,8 @@ MvQMagnifierSlider::MvQMagnifierSlider(QList& values, int actIndex, QColor colour) { actCellIndex_ = actIndex; - cellHeight_ = 13.; - cellWidth_ = 6.; - handlerSize_ = cellWidth_ + 4; - panelWidth_ = cellWidth_ + 10; + handlerSize_ = cellWidth_ + 4; + panelWidth_ = cellWidth_ + 10; for (int i = 0; i < values.count(); i++) { int lightFactor = 100 + static_cast(100. * static_cast(i) / static_cast(values.count())); @@ -48,7 +46,7 @@ cellSweepAngle_ = (180. / M_PI) * cellHeight_ / radius_; cellBarStartAngle_ = 180. - cells_.count() * cellSweepAngle_ / 2.; - cellBarEndAngle_ = cellBarStartAngle_ + cells_.count() * cellSweepAngle_; + cellBarEndAngle_ = cellBarStartAngle_ + cells_.count() * cellSweepAngle_; cellBarSweepAngle_ = cellBarEndAngle_ - cellBarStartAngle_; cellInnerRadius_ = radius_ + (panelWidth_ - cellWidth_) / 2.; @@ -65,7 +63,7 @@ void MvQMagnifierSlider::handlerCentre(float& cx, float& cy) { - float r = (cellInnerRadius_ + cellOuterRadius_) / 2.; + float r = (cellInnerRadius_ + cellOuterRadius_) / 2.; float an = actCellAngle(); cx = r * cos(an * M_PI / 180.); @@ -74,7 +72,7 @@ bool MvQMagnifierSlider::checkPointInHandler(float x, float y) { - float r = (cellInnerRadius_ + cellOuterRadius_) / 2.; + float r = (cellInnerRadius_ + cellOuterRadius_) / 2.; float an = actCellAngle(); float cx = r * cos(an * M_PI / 180.); @@ -85,7 +83,7 @@ bool MvQMagnifierSlider::checkPointInCell(float x, float y, int& index) { - index = -1; + index = -1; float dist = sqrt(x * x + y * y); if (dist >= panelInnerRadius_ && dist <= panelOuterRadius_) { float angle = atan2f(y, x) * 180. / M_PI; @@ -134,13 +132,13 @@ float b = (xc + dx) * (xc + dx) + (yc + dy) * (yc + dy); float c = dx * dx + dy * dy; - float dfi = (a + b - c) / (2. * sqrt(a * b)); - dfi = acos(dfi) * 180. / M_PI; + float dfi = (a + b - c) / (2. * sqrt(a * b)); + dfi = acos(dfi) * 180. / M_PI; float angle = actCellAngle() + ((dy < 0) ? 1 : -1) * dfi; index = static_cast((cellBarEndAngle_ - angle) / cellSweepAngle_); - //qDebug() << x << y << xc << yc << dfi << index; + // qDebug() << x << y << xc << yc << dfi << index; if (index >= 0 && index < cells_.count() && index != actCellIndex_) { return true; @@ -159,7 +157,7 @@ { float PI = 3.1415926535; - float an = 0.; + float an = 0.; float an_step = 2. * PI / ptNum_; for (int i = 0; i < ptNum_; i++) { coeffCos_.push_back(cos(an)); @@ -174,42 +172,42 @@ { frameWidth_ = innerFrameWidth_ + outerFrameWidth_; - //Default geometry + // Default geometry centreX_ = radius_ + 250.; centreY_ = radius_ + 250.; - //Init factor scales + // Init factor scales QList factors; - MvQMagnifierSlider* slider; + MvQMagnifierSlider* slider = nullptr; - //Set text magnification factors + // Set text magnification factors factors << 1.5 << 2. << 2.5 << 3. << 3.5 << 4.; slider = new MvQMagnifierSlider(factors, 1, QColor(Qt::red)); slider->setGeometry(radius_); - //slider->setHandlerSize(handlerPixmap_->width()); + // slider->setHandlerSize(handlerPixmap_->width()); sliders_[TextMode] = slider; - //Set data magnification factors + // Set data magnification factors factors.clear(); factors << 2. << 5. << 10. << 25.; slider = new MvQMagnifierSlider(factors, 1, QColor(Qt::red)); slider->setGeometry(radius_); - //slider->setHandlerSize(handlerPixmap_->width()); + // slider->setHandlerSize(handlerPixmap_->width()); sliders_[DataMode] = slider; - //Slider handler pixmap + // Slider handler pixmap QPixmap pxm(QString::fromUtf8(":/uPlot/magnifier_handler")); handlerPixmap_ = new QPixmap(pxm.scaledToWidth(slider->handlerSize(), Qt::SmoothTransformation)); //!! actSlider_ = sliders_[magnifierMode_]; - //Set frame data - frames_.push_back(MagnifierFrameData(6., 20., 150., 60)); - frames_.push_back(MagnifierFrameData(6., 150., 300., 80)); - frames_.push_back(MagnifierFrameData(6., 300., 1000., 100)); + // Set frame data + frames_.emplace_back(6., 20., 150., 60); + frames_.emplace_back(6., 150., 300., 80); + frames_.emplace_back(6., 300., 1000., 100); device_ = new QImage(823, 630, QImage::Format_RGB888); - //device_= new QPixmap(823,630); + // device_= new QPixmap(823,630); painter_ = new QPainter(device_); setPos(centreX_, centreY_); @@ -241,8 +239,8 @@ bool MvQMagnifier::checkPointInMagnifier(const QPointF& pos) { - float dx = pos.x() - centreX_; - float dy = pos.y() - centreY_; + float dx = pos.x() - centreX_; + float dy = pos.y() - centreY_; float dist = sqrt(dx * dx + dy * dy); if (dist < radius_) { @@ -253,20 +251,20 @@ MvQMagnifier::MagnifierPointType MvQMagnifier::identifyPoint(const QPointF& point) { - //qDebug() << point; + // qDebug() << point; - //If it is the first time + // If it is the first time if (centreX_ < -99999.) { centreX_ = point.x(); centreY_ = point.y(); } - float dx = point.x(); //-centreX_; - float dy = point.y(); //-centreY_; + float dx = point.x(); //-centreX_; + float dy = point.y(); //-centreY_; float dist = sqrt(dx * dx + dy * dy); - int index; + int index = 0; if (actSlider_->checkPointInHandler(dx, dy)) { return SliderHandlerPoint; } @@ -274,8 +272,8 @@ if (actSlider_->actCellIndex() != index) { actSlider_->setActCellIndex(index); reset(); - //updateMagnifierState(); - //update(); + // updateMagnifierState(); + // update(); emit factorChanged(); return SliderCellPoint; } @@ -310,7 +308,7 @@ { float zoom = actSlider_->actFactorValue(); QPointF cp(centreX_, centreY_); - //return cp+(scPos-cp)/zoom; + // return cp+(scPos-cp)/zoom; return (scPos - cp) * zoom + cp; } @@ -351,24 +349,24 @@ QList itemList = dataScene_->items(sourceRect, Qt::IntersectsItemBoundingRect); foreach (QGraphicsItem* item, itemList) { item->setFlag(QGraphicsItem::ItemHasNoContents, false); - //qDebug() << it->childItems().count() << it->parentItem()->data(0); - //if( it->childItems().count() != 0) + // qDebug() << it->childItems().count() << it->parentItem()->data(0); + // if( it->childItems().count() != 0) // qDebug() << " " << it->childItems().at(0)->childItems().count(); } /*QList itemList = dataScene_->items(sourceRect, Qt::IntersectsItemBoundingRect); - qDebug() << "rendered items:" << itemList.count(); - foreach(QGraphicsItem *it,itemList) - { - qDebug() << it->childItems().count() << it->parentItem()->data(0); - if( it->childItems().count() != 0) - qDebug() << " " << it->childItems().at(0)->childItems().count(); - }*/ + qDebug() << "rendered items:" << itemList.count(); + foreach(QGraphicsItem *it,itemList) + { + qDebug() << it->childItems().count() << it->parentItem()->data(0); + if( it->childItems().count() != 0) + qDebug() << " " << it->childItems().at(0)->childItems().count(); + }*/ dataScene_->render(painter_, targetRect, sourceRect); } - //device_->save("/var/tmp/dummy-user/demo.png"); + // device_->save("/var/tmp/dummy-user/demo.png"); QPainterPath path; path.addEllipse(-radius_, -radius_, 2. * radius_, 2. * radius_); @@ -413,15 +411,15 @@ float anStartInner, anEndInner, anSweepInner; float an, totalRotation; - //Panel + // Panel QPainterPath panel; - rad1 = actSlider_->panelInnerRadius(); - rad2 = actSlider_->panelOuterRadius(); - anStart = actSlider_->cellBarStartAngle(); - anSweep = actSlider_->cellBarSweepAngle(); + rad1 = actSlider_->panelInnerRadius(); + rad2 = actSlider_->panelOuterRadius(); + anStart = actSlider_->cellBarStartAngle(); + anSweep = actSlider_->cellBarSweepAngle(); anStartInner = anStart - (180. / M_PI) * 10. / rad1; - anEndInner = anStart + anSweep + (180. / M_PI) * 10. / rad1; + anEndInner = anStart + anSweep + (180. / M_PI) * 10. / rad1; anSweepInner = anEndInner - anStartInner; panel.moveTo(rad1 * cos(anStartInner / 180. * M_PI), @@ -438,11 +436,11 @@ painter->setBrush(panelGradient); painter->drawPath(panel); - //Cells + // Cells QPainterPath cell; - rad1 = actSlider_->cellInnerRadius(); - rad2 = actSlider_->cellOuterRadius(); + rad1 = actSlider_->cellInnerRadius(); + rad2 = actSlider_->cellOuterRadius(); anStart = -actSlider_->cellSweepAngle(); anSweep = actSlider_->cellSweepAngle(); createRingSlice(cell, anStart, anSweep, rad1, rad2); @@ -452,7 +450,7 @@ painter->rotate(an); totalRotation = an; for (int i = actSlider_->cellNum() - 1; i >= 0; i--) { - //qDebug() << slider_->cellColour(i); + // qDebug() << slider_->cellColour(i); painter->setBrush(actSlider_->cellColour(i)); painter->drawPath(cell); painter->rotate(-anSweep); @@ -519,14 +517,14 @@ } #endif - //Handler + // Handler painter->rotate(360. - actSlider_->actCellAngle()); painter->drawPixmap((actSlider_->cellInnerRadius() + actSlider_->cellOuterRadius()) / 2. - handlerPixmap_->width() / 2., -handlerPixmap_->height() / 2., *handlerPixmap_); - //painter->setBrush(Qt::blue); - //painter->drawEllipse(QPointF((slider_->cellInnerRadius() + slider_->cellOuterRadius())/2.,0), + // painter->setBrush(Qt::blue); + // painter->drawEllipse(QPointF((slider_->cellInnerRadius() + slider_->cellOuterRadius())/2.,0), // slider_->handlerSize()/2.,slider_->handlerSize()/2.); } @@ -558,43 +556,43 @@ r = actSlider_->panelOuterRadius(); QRectF f(-r, -r, 2. * r, 2. * r); - //qDebug() << "br"; // << f << rect() << mapRectFromParent(rect()); + // qDebug() << "br"; // << f << rect() << mapRectFromParent(rect()); return f; } bool MvQMagnifier::contains(const QPointF& point) const { - //qDebug() << "contains" << point; + // qDebug() << "contains" << point; bool b = QGraphicsItem::contains(point); - //qDebug() << "contains" << point << b; + // qDebug() << "contains" << point << b; return b; } void MvQMagnifier::mousePressEventFromView(QMouseEvent* event) { - //qDebug() << "magnifier press" << event->pos(); - //qDebug() << identifyPoint(event->pos()); + // qDebug() << "magnifier press" << event->pos(); + // qDebug() << identifyPoint(event->pos()); QPointF pos = mapFromScene(plotView_->mapToScene(event->pos())); switch (identifyPoint(pos)) { case LensPoint: setSelected(true); magnifierAction_ = MoveAction; - dragPos_ = pos; + dragPos_ = pos; break; case FramePoint: setSelected(true); magnifierAction_ = ResizeAction; - //qDebug() << "Frame selected"; + // qDebug() << "Frame selected"; break; case SliderCellPoint: magnifierAction_ = NoAction; - //qDebug() << "Cell selected"; + // qDebug() << "Cell selected"; break; case SliderHandlerPoint: - magnifierAction_ = HandlerAction; + magnifierAction_ = HandlerAction; actCellIndexAtHandlerActionStart_ = actSlider_->actCellIndex(); - //qDebug() << "Handler selected"; + // qDebug() << "Handler selected"; break; default: magnifierAction_ = NoAction; @@ -604,7 +602,7 @@ void MvQMagnifier::mouseMoveEventFromView(QMouseEvent* event) { - //qDebug() << "magnifier move" << mapToScene(event->pos()); + // qDebug() << "magnifier move" << mapToScene(event->pos()); if ((event->buttons() & Qt::LeftButton) == 0) return; @@ -621,13 +619,13 @@ else if (magnifierAction_ == ResizeAction) { float dist = sqrt(pow(centreX_ - pos.x(), 2) + pow(centreY_ - pos.y(), 2)); - //qDebug() << "dist" << dist; + // qDebug() << "dist" << dist; float maxRadius = (device_->width() < device_->height()) ? device_->width() / 2 : device_->height() / 2; - //qDebug() << "maxrad" << maxRadius; + // qDebug() << "maxrad" << maxRadius; - //Check if magnifying glass is inside window and size is not too small + // Check if magnifying glass is inside window and size is not too small if (dist >= minRadius_ && dist <= maxRadius) { radius_ = dist; } @@ -643,7 +641,7 @@ update(); } else if (magnifierAction_ == HandlerAction) { - int index; + int index = 0; if (actSlider_->shiftHandler(pos.x() - centreX_, pos.y() - centreY_, index)) { actSlider_->setActCellIndex(index); reset(); @@ -689,9 +687,9 @@ void MvQMagnifier::prepareForReset() { - //Clear the graphics contents of the data node - //remove it from the local scene and add it back to the - //main scene + // Clear the graphics contents of the data node + // remove it from the local scene and add it back to the + // main scene if (magnifierMode_ == DataMode) { if (dataScene_ != nullptr && dataItem_ != nullptr) { @@ -706,11 +704,11 @@ void MvQMagnifier::reset() { if (magnifierMode_ == DataMode) { - //float zoom=actSlider_->actFactorValue(); + // float zoom=actSlider_->actFactorValue(); if (!dataScene_) { dataScene_ = new QGraphicsScene; - dataItem_ = nullptr; + dataItem_ = nullptr; } if (dataItem_ != nullptr) { @@ -721,8 +719,8 @@ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - //To be implemented!!! - //dataItem_=plotScene_->updateMagnifier(zoom); + // To be implemented!!! + // dataItem_=plotScene_->updateMagnifier(zoom); dataItem_ = nullptr; if (dataItem_) { diff -Nru metview-5.17.4/metview/src/uPlot/MvQMagnifier.h metview-5.19.2/metview/src/uPlot/MvQMagnifier.h --- metview-5.17.4/metview/src/uPlot/MvQMagnifier.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQMagnifier.h 2023-07-15 08:28:47.000000000 +0000 @@ -68,27 +68,27 @@ void handlerCentre(float&, float&); public: - float radius_; - float actCellIndex_; - float handlerSize_; - - //Cell item - float cellSweepAngle_; - float cellWidth_; - float cellHeight_; - float cellInnerRadius_; - float cellOuterRadius_; - - //All the cells - float cellBarStartAngle_; - float cellBarEndAngle_; - float cellBarSweepAngle_; + float radius_{1.}; + float actCellIndex_{0}; + float handlerSize_{0.}; + + // Cell item + float cellSweepAngle_{0.}; + float cellWidth_{6}; + float cellHeight_{13}; + float cellInnerRadius_{0.}; + float cellOuterRadius_{0.}; + + // All the cells + float cellBarStartAngle_{0.}; + float cellBarEndAngle_{0.}; + float cellBarSweepAngle_{0.}; QList cells_; - //Panel - float panelWidth_; - float panelInnerRadius_; - float panelOuterRadius_; + // Panel + float panelWidth_{0.}; + float panelInnerRadius_{0.}; + float panelOuterRadius_{0.}; }; @@ -126,18 +126,18 @@ OuterScenePoint }; - MvQMagnifier(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = 0); - ~MvQMagnifier(); + MvQMagnifier(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = nullptr); + ~MvQMagnifier() override; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); - QRectF boundingRect() const; - bool contains(const QPointF&) const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; + QRectF boundingRect() const override; + bool contains(const QPointF&) const override; void render(QPainter* painter); - void setActivated(bool); - void prepareForReset(); - void reset(); + void setActivated(bool) override; + void prepareForReset() override; + void reset() override; MagnifierAction magnifierAction() { return magnifierAction_; } float zoomFactor() { return actSlider_->actFactorValue(); } bool checkPointInMagnifier(const QPointF&); @@ -145,9 +145,9 @@ QPointF sceneToMagnifiedPos(const QPointF&); QPointF magnifiedToScenePos(const QPointF&); - void mousePressEventFromView(QMouseEvent*); - void mouseMoveEventFromView(QMouseEvent*); - void mouseReleaseEventFromView(QMouseEvent*); + void mousePressEventFromView(QMouseEvent*) override; + void mouseMoveEventFromView(QMouseEvent*) override; + void mouseReleaseEventFromView(QMouseEvent*) override; signals: void factorChanged(); @@ -194,17 +194,17 @@ float minRadius_{50.}; float innerFrameWidth_{3.}; float outerFrameWidth_{7.}; - float frameWidth_; - float centreX_; - float centreY_; - int minX_; - int maxX_; - int minY_; - int maxY_; - int refX_; - int refY_; - int prevX_; - int prevY_; + float frameWidth_{0.}; + float centreX_{0.}; + float centreY_{0.}; + int minX_{0}; + int maxX_{0}; + int minY_{0}; + int maxY_{0}; + int refX_{0}; + int refY_{0}; + int prevX_{0}; + int prevY_{0}; bool pointInMagnifier_{false}; bool mouseInLens_{false}; diff -Nru metview-5.17.4/metview/src/uPlot/MvQOdbStatModel.cc metview-5.19.2/metview/src/uPlot/MvQOdbStatModel.cc --- metview-5.17.4/metview/src/uPlot/MvQOdbStatModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQOdbStatModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,13 +42,13 @@ /*void MvQOdbStatModel::layersAreAboutToChange() { - beginResetModel(); + beginResetModel(); } void MvQOdbStatModel::resetLayers() { - layers_=scene_->layerNodes(); - endResetModel(); + layers_=scene_->layerNodes(); + endResetModel(); }*/ @@ -86,11 +86,11 @@ else if (role == Qt::BackgroundRole) { if (data_.at(index.row())->isLoaded()) { if (index.row() % 2 == 0) - //return QBrush(QColor(70,180,40)); - //return QBrush(QColor(92,206,113)); + // return QBrush(QColor(70,180,40)); + // return QBrush(QColor(92,206,113)); return QColor("#FFE6BF"); else - //return QBrush(QColor(187,238,202)); + // return QBrush(QColor(187,238,202)); return QColor("#FFF2DE"); } else { diff -Nru metview-5.17.4/metview/src/uPlot/MvQOdbStatModel.h metview-5.19.2/metview/src/uPlot/MvQOdbStatModel.h --- metview-5.17.4/metview/src/uPlot/MvQOdbStatModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQOdbStatModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,24 +18,25 @@ class MvQOdbStatDelegate : public QStyledItemDelegate { public: - MvQOdbStatDelegate(QWidget* parent = 0); + MvQOdbStatDelegate(QWidget* parent = nullptr); void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; + const QModelIndex& index) const override; }; class MvQOdbStatModel : public QAbstractItemModel { public: - MvQOdbStatModel(){}; + MvQOdbStatModel() = default; + ; - int columnCount(const QModelIndex& parent = QModelIndex()) const; - int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; - QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; + QVariant headerData(int, Qt::Orientation, int role = Qt::DisplayRole) const override; - QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex&) const; + QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex&) const override; void setData(QList); diff -Nru metview-5.17.4/metview/src/uPlot/MvQOdbTableView.cc metview-5.19.2/metview/src/uPlot/MvQOdbTableView.cc --- metview-5.17.4/metview/src/uPlot/MvQOdbTableView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQOdbTableView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,64 +18,53 @@ MvQOdbTableView::MvQOdbTableView(QWidget* parent) : QGraphicsView(parent) { - //Table graph - tableOffsetX_ = 15; - tableWidth_ = 70; - tableGapX_ = 12; - tableOffsetY_ = 15; - tableHeight_ = 15; - tableGapY_ = 12; - - odb_ = 0; - tablePixmap_ = 0; } - void MvQOdbTableView::init(MvQOdbMetaData* odb, QString table) { - odb_ = odb; + odb_ = odb; selectedTable_ = table; - //Number of rows and cols in graph + // Number of rows and cols in graph int nx, ny; odb_->getTreePosRange(nx, ny); nx += 1; - //ny+=1; + // ny+=1; - //Compute the area occupied by the graph + // Compute the area occupied by the graph int w = 2 * tableOffsetX_ + nx * tableWidth_ + (nx - 1) * tableGapX_; int h = 2 * tableOffsetY_ + ny * tableHeight_ + (ny - 1) * tableGapY_; - graphWidth_ = w; + graphWidth_ = w; graphHeight_ = h; int dw, dh, pw, ph; - //adjustPixmapSizeToView(width(),height(),dw,dh); + // adjustPixmapSizeToView(width(),height(),dw,dh); adjustPixmapSizeToView(w, h, dw, dh); pw = w + dw; ph = h + dh; - //pw=width()+dw; - //ph=height()+dh; + // pw=width()+dw; + // ph=height()+dh; - //Create the pixmap + // Create the pixmap tablePixmap_ = new QPixmap(pw, ph); - //Scene rect + // Scene rect setSceneRect(0, 0, pw, ph); - //Create a scene for the table graph + // Create a scene for the table graph OdbTableScene* scene = new OdbTableScene; - //Add scene to the graphics view + // Add scene to the graphics view setScene(scene); - //Mouse press event in scene goes to + // Mouse press event in scene goes to connect(scene, SIGNAL(mousePressed(int, int)), this, SLOT(mousePressedInTableGraph(int, int))); setCacheMode(QGraphicsView::CacheBackground); - //setBackgroundBrush(*tablePixmap_); + // setBackgroundBrush(*tablePixmap_); renderTableGraph(); @@ -85,12 +74,12 @@ void MvQOdbTableView::renderTableGraph() { - //QPixmap *pixmap = new QPixmap(600,400); + // QPixmap *pixmap = new QPixmap(600,400); QPainter painter(tablePixmap_); painter.setRenderHint(QPainter::Antialiasing, false); - //QLinearGradient grad(0,0,100,100); + // QLinearGradient grad(0,0,100,100); QLinearGradient grad(0, 0, tablePixmap_->width(), tablePixmap_->height()); grad.setColorAt(0, QColor::fromRgb(255, 242, 222)); @@ -100,9 +89,9 @@ // Define clear color and clear the display painter.fillRect(0, 0, tablePixmap_->width(), tablePixmap_->height(), QBrush(grad)); - //QBrush(Qt::white, Qt::SolidPattern)); + // QBrush(Qt::white, Qt::SolidPattern)); - //Render net + // Render net int xp, yp; painter.setPen(QPen(QColor(213, 209, 217), 0.5, Qt::SolidLine, Qt::RoundCap)); @@ -120,7 +109,7 @@ painter.setPen(QPen(Qt::black, 0.5, Qt::SolidLine, Qt::RoundCap)); - //Draw the graph + // Draw the graph QMapIterator it(odb_->tables()); while (it.hasNext()) { @@ -141,7 +130,7 @@ painter.setFont(QFont("Helvetica [Cronyx]", 8)); painter.setRenderHint(QPainter::TextAntialiasing, true); - //painter.setFont(QFont("Sans Serif", 7)); + // painter.setFont(QFont("Sans Serif", 7)); it.toFront(); while (it.hasNext()) { @@ -156,7 +145,7 @@ painter.fillRect(xp - tableWidth_ / 2., yp - tableHeight_ / 2., tableWidth_, tableHeight_, QBrush(gradient)); - //QBrush(QColor(255,64,105), Qt::SolidPattern)); + // QBrush(QColor(255,64,105), Qt::SolidPattern)); } else { QLinearGradient gradient(xp, yp - tableHeight_ / 2., @@ -166,14 +155,14 @@ painter.fillRect(xp - tableWidth_ / 2., yp - tableHeight_ / 2., tableWidth_, tableHeight_, QBrush(gradient)); - //QBrush(QColor(119,215,196), Qt::SolidPattern)); + // QBrush(QColor(119,215,196), Qt::SolidPattern)); } painter.drawRect(xp - tableWidth_ / 2., yp - tableHeight_ / 2., tableWidth_, tableHeight_); if (it.value()->name() == selectedTable_) { - //painter.setPen(QPen(Qt::white, 0.5, Qt::SolidLine, Qt::RoundCap)); + // painter.setPen(QPen(Qt::white, 0.5, Qt::SolidLine, Qt::RoundCap)); } @@ -186,12 +175,12 @@ if (it.value()->name() == selectedTable_) { - //painter.setPen(QPen(Qt::black, 0.5, Qt::SolidLine, Qt::RoundCap)); + // painter.setPen(QPen(Qt::black, 0.5, Qt::SolidLine, Qt::RoundCap)); } } /*graphicsView_table->setCacheMode(QGraphicsView::CacheBackground); - graphicsView_table->resetCachedContent();*/ + graphicsView_table->resetCachedContent();*/ setBackgroundBrush(*tablePixmap_); } @@ -267,7 +256,7 @@ delete tablePixmap_; tablePixmap_ = new QPixmap(pw + dw, ph + dh); - //setBackgroundBrush(*tablePixmap_); + // setBackgroundBrush(*tablePixmap_); setSceneRect(0, 0, pw + dw, ph + dh); diff -Nru metview-5.17.4/metview/src/uPlot/MvQOdbTableView.h metview-5.19.2/metview/src/uPlot/MvQOdbTableView.h --- metview-5.17.4/metview/src/uPlot/MvQOdbTableView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQOdbTableView.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ Q_OBJECT public: - MvQOdbTableView(QWidget* parent = 0); + MvQOdbTableView(QWidget* parent = nullptr); void init(MvQOdbMetaData*, QString); void renderTableGraph(); void centreTableGraph(); @@ -34,23 +34,23 @@ protected: void getTablePos(int, int, int&, int&); bool setSelectedTable(int, int); - void resizeEvent(QResizeEvent*); + void resizeEvent(QResizeEvent*) override; void adjustPixmapSizeToView(int, int, int&, int&); - MvQOdbMetaData* odb_; + MvQOdbMetaData* odb_{nullptr}; - int tableOffsetX_; - int tableOffsetY_; - int tableWidth_; - int tableHeight_; - int tableGapX_; - int tableGapY_; - int graphWidth_; - int graphHeight_; + int tableOffsetX_{15}; + int tableOffsetY_{15}; + int tableWidth_{70}; + int tableHeight_{15}; + int tableGapX_{12}; + int tableGapY_{12}; + int graphWidth_{70}; + int graphHeight_{15}; QString selectedTable_; - QPixmap* tablePixmap_; + QPixmap* tablePixmap_{nullptr}; }; @@ -59,11 +59,11 @@ Q_OBJECT public: - OdbTableScene(QGraphicsScene* parent = 0); + OdbTableScene(QGraphicsScene* parent = nullptr); signals: void mousePressed(int, int); protected: - void mousePressEvent(QGraphicsSceneMouseEvent*); + void mousePressEvent(QGraphicsSceneMouseEvent*) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/MvQPlaceMark.cc metview-5.19.2/metview/src/uPlot/MvQPlaceMark.cc --- metview-5.17.4/metview/src/uPlot/MvQPlaceMark.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPlaceMark.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,7 +21,7 @@ #include "MgQPlotScene.h" #include "MgQLayoutItem.h" -#include +#include #define METVIEW_MULTIPAGE @@ -420,11 +420,11 @@ magnifier_(nullptr) { currentAction_ = NoAction; - dataLayout_ = nullptr; - coordinates_ = QPointF(0., 0.); + dataLayout_ = nullptr; + coordinates_ = QPointF(0., 0.); - //pix_=QPixmap::fromImage(pm_->pixmap().toImage().mirrored(false,true)); - //pix_=QPixmap::fromImage(img.mirrored(false,true)); + // pix_=QPixmap::fromImage(pm_->pixmap().toImage().mirrored(false,true)); + // pix_=QPixmap::fromImage(img.mirrored(false,true)); pix_ = QPixmap(QString::fromUtf8(":/uPlot/data_probe.svg")); anchor_ = CentreAnchor; @@ -434,7 +434,7 @@ else boundingRect_ = QRectF(-pix_.width() / 2., -pix_.height() / 2., pix_.width(), pix_.height()); - outOfPlot_ = true; + outOfPlot_ = true; highlighted_ = false; } @@ -447,18 +447,18 @@ void MvQPlaceMark::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*o*/, QWidget* /*w*/) { - //if(outOfPlot_) + // if(outOfPlot_) // return; float sx = painter->transform().m11(); float sy = painter->transform().m22(); - //bool clipping=(painter->clipRegion().isEmpty())?false:true; + // bool clipping=(painter->clipRegion().isEmpty())?false:true; - //qDebug() << "clip" << painter->clipRegion(); - //qDebug() << "scaling" << sx; + // qDebug() << "clip" << painter->clipRegion(); + // qDebug() << "scaling" << sx; - //QRect clipRect=painter->clipRegion().boundingRect(); + // QRect clipRect=painter->clipRegion().boundingRect(); if (1) { QTransform tr = painter->transform(); @@ -474,25 +474,25 @@ painter->drawPixmap(boundingRect_, pix_, pix_.rect()); - //painter->setPen(QColor(255,255,255)); - //painter->drawPoint(0,0); + // painter->setPen(QColor(255,255,255)); + // painter->drawPoint(0,0); - //painter->translate(QPointF(5,5)); + // painter->translate(QPointF(5,5)); /*painter->scale(1.,-1.); - painter->setPen(Qt::white); - painter->setBrush(Qt::white); - painter->drawText(QPointF(0,0),text_);*/ + painter->setPen(Qt::white); + painter->setBrush(Qt::white); + painter->drawText(QPointF(0,0),text_);*/ } void MvQPlaceMark::setPixmapColour(QColor /*col*/) { /*QImage img=pm_->pixmap().toImage().mirrored(false,true); - QPainter painter(&img); - //painter.setBrush(QColor(255,0,0,190,140)); - painter.setCompositionMode(QPainter::CompositionMode_SourceIn); - painter.fillRect(img.rect(),col); - pix_=QPixmap::fromImage(img); - update();*/ + QPainter painter(&img); + //painter.setBrush(QColor(255,0,0,190,140)); + painter.setCompositionMode(QPainter::CompositionMode_SourceIn); + painter.fillRect(img.rect(),col); + pix_=QPixmap::fromImage(img); + update();*/ } void MvQPlaceMark::setScenePosition(QPointF /*scPos*/) @@ -575,11 +575,11 @@ QPointF lPos = mapFromScene(plotView_->mapToScene(event->pos())); if (!boundingRect_.contains(lPos)) { currentAction_ = NoAction; - dragPos_ = QPointF(); + dragPos_ = QPointF(); return; } - dragPos_ = plotView_->mapToScene(event->pos()); + dragPos_ = plotView_->mapToScene(event->pos()); currentAction_ = MoveAction; } } @@ -590,8 +590,8 @@ return; if (currentAction_ == MoveAction) { - QPointF posM = plotView_->mapToScene(event->pos()); - QPointF dp = posM - dragPos_; + QPointF posM = plotView_->mapToScene(event->pos()); + QPointF dp = posM - dragPos_; QPointF newPos = QGraphicsObject::pos() + dp; QPointF realPos = newPos; @@ -612,7 +612,7 @@ } setPos(newPos); dragPos_ = posM; - //update(); + // update(); emit beingMoved(cr); } @@ -624,7 +624,7 @@ return; if (currentAction_ == MoveAction) { - QPointF newPos = QGraphicsObject::pos(); + QPointF newPos = QGraphicsObject::pos(); QPointF realPos = newPos; if (magnifier_ && magnifier_->activated()) { @@ -650,7 +650,7 @@ void MvQPlaceMark::updateVisibility() { /*if(pm_->isOutOfPlot()== false) - setVisible(pm_->isVisible());*/ + setVisible(pm_->isVisible());*/ } void MvQPlaceMark::reset(MgQLayoutItem* dataLayout) @@ -668,7 +668,7 @@ QPointF MvQPlaceMark::checkScenePosInMagnifier(const QPointF& scPos) { - //qDebug() << "magpos" << magnifier_->identifyScenePoint(scPos); + // qDebug() << "magpos" << magnifier_->identifyScenePoint(scPos); QPointF pos = scPos; if (magnifier_ && magnifier_->activated()) { @@ -696,7 +696,7 @@ QPointF MvQPlaceMark::checkMagnifiedPosInMagnifier(const QPointF& magPos) { - //qDebug() << "magpos" << magnifier_->identifyScenePoint(scPos); + // qDebug() << "magpos" << magnifier_->identifyScenePoint(scPos); QPointF pos = magPos; if (magnifier_ && magnifier_->activated()) { diff -Nru metview-5.17.4/metview/src/uPlot/MvQPlaceMark.h metview-5.19.2/metview/src/uPlot/MvQPlaceMark.h --- metview-5.17.4/metview/src/uPlot/MvQPlaceMark.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPlaceMark.h 2023-07-15 08:28:47.000000000 +0000 @@ -217,17 +217,17 @@ BottomCentreAnchor }; - MvQPlaceMark(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = 0); - ~MvQPlaceMark(); + MvQPlaceMark(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = nullptr); + ~MvQPlaceMark() override; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); - QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; + QRectF boundingRect() const override; - void setActivated(bool); + void setActivated(bool) override; - void mousePressEventFromView(QMouseEvent*); - void mouseMoveEventFromView(QMouseEvent*); - void mouseReleaseEventFromView(QMouseEvent*); + void mousePressEventFromView(QMouseEvent*) override; + void mouseMoveEventFromView(QMouseEvent*) override; + void mouseReleaseEventFromView(QMouseEvent*) override; CurrentAction currentAction() { return currentAction_; } @@ -243,7 +243,7 @@ void updateVisibility(); void reset(MgQLayoutItem*); - void reset() {} + void reset() override {} void setMagnifier(MvQMagnifier*); signals: diff -Nru metview-5.17.4/metview/src/uPlot/MvQPlotItem.h metview-5.19.2/metview/src/uPlot/MvQPlotItem.h --- metview-5.17.4/metview/src/uPlot/MvQPlotItem.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPlotItem.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,7 +19,7 @@ class MvQPlotItem : public QGraphicsObject { public: - MvQPlotItem(MgQPlotScene* scene, MvQPlotView* view, QGraphicsItem* parent = 0) : + MvQPlotItem(MgQPlotScene* scene, MvQPlotView* view, QGraphicsItem* parent = nullptr) : QGraphicsObject(parent), plotScene_(scene), plotView_(view), @@ -41,9 +41,9 @@ MvQPlotView* plotView() const { return plotView_; } protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent*) {} - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*) {} - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*) {} + void mousePressEvent(QGraphicsSceneMouseEvent*) override {} + void mouseMoveEvent(QGraphicsSceneMouseEvent*) override {} + void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override {} MgQPlotScene* plotScene_; MvQPlotView* plotView_; diff -Nru metview-5.17.4/metview/src/uPlot/MvQPlotView.cc metview-5.19.2/metview/src/uPlot/MvQPlotView.cc --- metview-5.17.4/metview/src/uPlot/MvQPlotView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPlotView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -62,12 +62,14 @@ plotScene_ = static_cast(scene); resetTransform(); - //translate(0,height); + // translate(0,height); scale(1., -1); setAcceptDrops(true); MvQFeatureHandler::Instance()->setView(this); + + createCursorData(); } void MvQPlotView::slotSetEnableZoom(bool flag) @@ -86,7 +88,7 @@ else { if (!zoom_) { zoom_ = new MvQZoom(plotScene_, this, nullptr); - //zoom_->setVisible(true); + // zoom_->setVisible(true); zoom_->setZValue(2.5); plotScene_->addItem(zoom_); @@ -120,14 +122,14 @@ return; else { magnifier_->setActivated(false); - //magnifier_->operationEnd(); + // magnifier_->operationEnd(); } } else { emit zoomIsEnabledProgramatically(false); if (!magnifier_) { magnifier_ = new MvQMagnifier(plotScene_, this, nullptr); - //zoom_->setVisible(true); + // zoom_->setVisible(true); magnifier_->setZValue(1.5); plotScene_->addItem(magnifier_); @@ -139,7 +141,7 @@ } magnifier_->setActivated(true); - //magnifier_->operationBegin(); + // magnifier_->operationBegin(); } slotMagnifierChanged(); @@ -150,12 +152,33 @@ if (!magnifier_) return; - //Update dataprobe + // Update dataprobe if (dataProbe_ && dataProbe_->activated()) { dataProbe_->setMagnifier(magnifier_); } } +void MvQPlotView::createCursorData() +{ + if (!cursorData_) { + cursorData_ = new MvQCursorData(plotScene_, this, nullptr); + cursorData_->setVisible(true); + cursorData_->setZValue(2.); + plotScene_->addItem(cursorData_); + + connect(cursorData_, SIGNAL(coordinatesChanged(const CursorCoordinate&)), + this, SIGNAL(cursorDataCoordsChanged(const CursorCoordinate&))); + } +} + +void MvQPlotView::setEnableTrackCursorCoordinates(bool b) +{ + // coordinate tracing in cursor data servers the location label. + // It can be enabled even when the cursor data is not active/visible. + createCursorData(); + cursorData_->setTrackCoordinates(b); +} + void MvQPlotView::slotSetEnableCursorData(bool flag) { if (cursorData_ && flag == cursorData_->activated()) @@ -169,20 +192,19 @@ } } else { - if (!cursorData_) { - cursorData_ = new MvQCursorData(plotScene_, this, nullptr); - cursorData_->setVisible(true); - cursorData_->setZValue(2.); - plotScene_->addItem(cursorData_); - - connect(cursorData_, SIGNAL(positionChanged(QPointF, QList)), - this, SIGNAL(cursorDataChanged(QPointF, QList))); - } - + createCursorData(); + Q_ASSERT(cursorData_ != nullptr); cursorData_->setActivated(true); } } +void MvQPlotView::slotResetCursorData() +{ + if (cursorData_ && cursorData_->activated()) { + cursorData_->resetPosition(); + } +} + void MvQPlotView::slotSetEnableAreaSelection(bool flag) { if (area_ && flag == area_->activated()) @@ -435,12 +457,12 @@ void MvQPlotView::mousePressEvent(QMouseEvent* event) { bool eventProcessed = false; - QPointF scenePos = mapToScene(event->pos()); + QPointF scenePos = mapToScene(event->pos()); if (sceneIsBeingSelected_) { viewport()->unsetCursor(); sceneIsBeingSelected_ = false; - QPointF sPos = mapToScene(event->pos()); + QPointF sPos = mapToScene(event->pos()); emit sceneSelected(sPos); return; } @@ -459,15 +481,15 @@ MvQMagnifier::MagnifierAction magnifierAction = MvQMagnifier::NoAction; - //Zoom and magnifier are exclusive! + // Zoom and magnifier are exclusive! - //First comes the zoom if it is active + // First comes the zoom if it is active if (zoom_ && zoom_->activated()) { zoom_->mousePressEventFromView(event); return; } - //Then we check if the dataProbe is selected + // Then we check if the dataProbe is selected if (dataProbe_ && dataProbe_->activated()) { // QPointF pos = mapToScene(event->pos()); dataProbe_->mousePressEventFromView(event); @@ -476,23 +498,23 @@ } } - //If there is no zoom and the dataProbe is not selected tries the magnifier + // If there is no zoom and the dataProbe is not selected tries the magnifier if (magnifier_ && magnifier_->activated()) { magnifier_->mousePressEventFromView(event); magnifierAction = magnifier_->magnifierAction(); } - //We continuew with the ... + // We continuew with the ... - //area selection + // area selection if (area_ && area_->activated()) { area_->mousePressEventFromView(event); } - //line selection + // line selection else if (line_ && line_->activated()) { line_->mousePressEventFromView(event); } - //point selection + // point selection else if (point_ && point_->activated()) { point_->mousePressEventFromView(event); } @@ -521,10 +543,10 @@ #endif } - //Cursor data can be active both for zoom and magnifier. - //If the mousepress event triggered some actions in the magnifier - //then we ignore this event for the cursor data. - if (cursorData_ && cursorData_->activated() && + // Cursor data can be active both for zoom and magnifier. + // If the mousepress event triggered some actions in the magnifier + // then we ignore this event for the cursor data. + if (cursorData_ && magnifierAction == MvQMagnifier::NoAction && (!zoom_ || zoom_->activated() == false)) { cursorData_->mousePressEventFromView(event); @@ -536,11 +558,11 @@ void MvQPlotView::mouseMoveEvent(QMouseEvent* event) { - if (cursorData_ && cursorData_->activated()) { + if (cursorData_) { QPointF pos = mapToScene(event->pos()); - //If the cursor is inside tha magnifier cursor data has to - //be notified know about the magnifier geometry. + // If the cursor is inside tha magnifier cursor data has to + // be notified to know about the magnifier geometry. if (magnifier_ && magnifier_->activated() && magnifier_->checkPointInMagnifier(pos)) { cursorData_->setMagnifierInfo(true, magnifier_->pos(), magnifier_->zoomFactor()); @@ -605,7 +627,7 @@ QGraphicsView::mouseReleaseEvent(event); } - if (cursorData_ && cursorData_->activated()) { + if (cursorData_) { cursorData_->setZoomWasPerformedAfterMouseRelease(zoomStatus); cursorData_->mouseReleaseEventFromView(event); } @@ -673,9 +695,9 @@ #endif MvQFeatureCommandTarget sel(MvQFeatureCommandTarget::ShortcutMode); sel.eval(mapToScene(mapFromGlobal(QCursor::pos()))); - //featureSelection(&sel); + // featureSelection(&sel); MvQFeatureHandler::Instance()->runCommand(sel, cmd); - //runCommand(sel, cmd); + // runCommand(sel, cmd); } } @@ -740,9 +762,9 @@ void MvQPlotView::setMvPlotSize(double /*width*/, double /*height*/) { - //resetTransform(); - //translate(0,height); - //scale(1.,-1); + // resetTransform(); + // translate(0,height); + // scale(1.,-1); - //setSceneRect(0,0,width*2,height*2); + // setSceneRect(0,0,width*2,height*2); } diff -Nru metview-5.17.4/metview/src/uPlot/MvQPlotView.h metview-5.19.2/metview/src/uPlot/MvQPlotView.h --- metview-5.17.4/metview/src/uPlot/MvQPlotView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPlotView.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,6 +21,7 @@ class MvKeyProfile; +class CursorCoordinate; class MvQAreaSelection; class MvQCursorData; class MvQDrop; @@ -53,7 +54,7 @@ public: explicit MvQPlotView(QGraphicsScene*, QWidget* parent = nullptr); - ~MvQPlotView() = default; + ~MvQPlotView() override = default; void resetBegin(); void resetEnd(); void setMvPlotSize(double, double); @@ -67,12 +68,15 @@ void setFeatureInfoWidget(QPlainTextEdit*); void initFeatureInterface(); void enterFeatureAddMode(); + void createCursorData(); + void setEnableTrackCursorCoordinates(bool b); public slots: void slotSetEnableZoom(bool); void slotSetEnableMagnifier(bool); void slotMagnifierChanged(); void slotSetEnableCursorData(bool); + void slotResetCursorData(); void slotSetEnableAreaSelection(bool); void slotSetEnableLineSelection(bool); void slotSetEnablePointSelection(bool); @@ -102,27 +106,27 @@ void contextMenuEventHappened(const QPoint&, const QPointF&); void resizeEventHappened(const QSize&); void zoomActionStarted(MgQSceneItem*); - void cursorDataChanged(QPointF, QList); + void cursorDataCoordsChanged(const CursorCoordinate&); void iconDropped(const MvQDrop&, QPoint); void addRibbonEditor(QWidget*); protected: - void mouseDoubleClickEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void mousePressEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); - void contextMenuEvent(QContextMenuEvent*); - void resizeEvent(QResizeEvent*); - void dragEnterEvent(QDragEnterEvent*); - void dragMoveEvent(QDragMoveEvent*); - void dropEvent(QDropEvent*); - void keyPressEvent(QKeyEvent* event); + void mouseDoubleClickEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent* event) override; + void mousePressEvent(QMouseEvent* event) override; + void mouseReleaseEvent(QMouseEvent* event) override; + void contextMenuEvent(QContextMenuEvent*) override; + void resizeEvent(QResizeEvent*) override; + void dragEnterEvent(QDragEnterEvent*) override; + void dragMoveEvent(QDragMoveEvent*) override; + void dropEvent(QDropEvent*) override; + void keyPressEvent(QKeyEvent* event) override; void removeFeatureTextEditor(); void leaveFeatureAddMode(); MgQPlotScene* plotScene_; - //Zoom + // Zoom MvQZoom* zoom_{nullptr}; MvQMagnifier* magnifier_{nullptr}; MvQCursorData* cursorData_{nullptr}; @@ -132,7 +136,7 @@ bool sceneIsBeingSelected_{false}; MvQPlaceMark* dataProbe_{nullptr}; - //features + // features bool inFeatureAddMode_{false}; MvQFeatureRibbonEditor* featureRibbonEditor_{nullptr}; }; diff -Nru metview-5.17.4/metview/src/uPlot/MvQPointSelection.cc metview-5.19.2/metview/src/uPlot/MvQPointSelection.cc --- metview-5.17.4/metview/src/uPlot/MvQPointSelection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPointSelection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -7,7 +7,7 @@ ***************************** LICENSE END *************************************/ -#include +#include #include #include @@ -23,20 +23,20 @@ { pen_ = QPen(QColor(0, 0, 255, 230), 2); pen_.setCosmetic(true); - brush_ = QBrush(QColor(0, 0, 255, 180)); + brush_ = QBrush(QColor(0, 0, 255, 180)); hoverBrush_ = QBrush(QColor(164, 219, 255, 150)); currentAction_ = NoAction; - zoomLayout_ = nullptr; - point_ = QPointF(); - pointDefined_ = false; + zoomLayout_ = nullptr; + point_ = QPointF(); + pointDefined_ = false; - //selectionPen_=QPen(QColor(0,0,0),2); - //selectionPen_.setCosmetic(true); + // selectionPen_=QPen(QColor(0,0,0),2); + // selectionPen_.setCosmetic(true); - selectorSize_ = 32.; + selectorSize_ = 32.; physicalSelectorSize_ = 32.; - hover_ = false; + hover_ = false; } MvQPointSelection::~MvQPointSelection() = default; @@ -59,7 +59,7 @@ QBrush brush; - //Hover + // Hover if (hover_) { brush = hoverBrush_; } @@ -74,15 +74,15 @@ float x = point_.x(); float y = point_.y(); - QRectF rIn = QRectF(x - d / 4., y - d / 4., d / 2., d / 2.); + QRectF rIn = QRectF(x - d / 4., y - d / 4., d / 2., d / 2.); QRectF rOut = QRectF(x - d, y - d, d * 2., d * 2.); painter->drawEllipse(rIn); painter->setBrush(QBrush()); painter->drawEllipse(rOut); - //painter->drawLine(x-d,y,x+d,y); - //painter->drawLine(x,y-d,x,y+d); + // painter->drawLine(x-d,y,x+d,y); + // painter->drawLine(x,y-d,x,y+d); } void MvQPointSelection::mousePressEventFromView(QMouseEvent* event) @@ -95,7 +95,7 @@ hover_ = false; if (!pointDefined_) { - //Get item position + // Get item position QPointF p = mapFromScene(plotView_->mapToScene(event->pos())); if ((zoomLayout_ = plotScene_->findProjectorItem(mapToScene(p))) == nullptr) { @@ -104,7 +104,7 @@ else { currentAction_ = NoAction; - point_ = p; + point_ = p; pointDefined_ = true; setVisible(true); @@ -121,8 +121,8 @@ else { dragPos_ = mapFromScene(plotView_->mapToScene(event->pos())); - //Checks if the drag point is - //in the selection rentangle and starts a move action + // Checks if the drag point is + // in the selection rentangle and starts a move action if ((zoomLayout_ = plotScene_->firstProjectorItem()) != nullptr && checkPointInSelector(dragPos_) == true) { currentAction_ = MoveAction; @@ -131,7 +131,7 @@ } else { currentAction_ = NoAction; - dragPos_ = QPointF(); + dragPos_ = QPointF(); } } } @@ -155,7 +155,7 @@ } else if (event->buttons() == Qt::NoButton) { bool oriHover = hover_; - hover_ = false; + hover_ = false; if (checkPointInSelector(pos)) { hover_ = true; @@ -186,9 +186,9 @@ zoomLayout_->mapFromSceneToGeoCoords(mapToScene(sp), gp); currentAction_ = NoAction; - zoomLayout_ = nullptr; - dragPos_ = QPointF(); - coordPoint_ = gp; + zoomLayout_ = nullptr; + dragPos_ = QPointF(); + coordPoint_ = gp; emit pointIsDefined(gp.y(), gp.x()); @@ -200,7 +200,7 @@ void MvQPointSelection::setPoint(double lat, double lon) { - //double west, double north, double east, double south) + // double west, double north, double east, double south) double x = lon; double y = lat; @@ -227,14 +227,14 @@ sp = mapFromScene(sp); prepareGeometryChange(); - point_ = sp; - coordPoint_ = gp; + point_ = sp; + coordPoint_ = gp; pointDefined_ = true; update(); } else { pointDefined_ = true; - QPointF sp = point_; + QPointF sp = point_; sp = mapToScene(sp); @@ -249,10 +249,10 @@ { currentAction_ = NoAction; prepareGeometryChange(); - point_ = QPointF(); + point_ = QPointF(); pointDefined_ = false; - coordPoint_ = point_; - hover_ = false; + coordPoint_ = point_; + hover_ = false; update(); emit pointIsUndefined(); } @@ -266,7 +266,7 @@ if (!pointDefined_) return; - //We need to find the projectorItem!! + // We need to find the projectorItem!! QPointF sp; if ((zoomLayout_ = plotScene_->firstProjectorItem()) == nullptr) { @@ -277,15 +277,15 @@ QPointF gp = coordPoint_; - //qDebug() << coordPoint_; + // qDebug() << coordPoint_; if (zoomLayout_->containsGeoCoords(gp)) { zoomLayout_->mapFromGeoToSceneCoords(gp, sp); sp = mapFromScene(sp); prepareGeometryChange(); - point_ = sp; - coordPoint_ = gp; + point_ = sp; + coordPoint_ = gp; pointDefined_ = true; update(); } @@ -316,7 +316,7 @@ return; } - //Plot area in scene coordinates + // Plot area in scene coordinates QRectF plotRect = mapRectFromScene(zoomLayout_->mapToScene(zoomLayout_->boundingRect()).boundingRect()); if (p.x() > plotRect.right()) { diff -Nru metview-5.17.4/metview/src/uPlot/MvQPointSelection.h metview-5.19.2/metview/src/uPlot/MvQPointSelection.h --- metview-5.17.4/metview/src/uPlot/MvQPointSelection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPointSelection.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,21 +22,21 @@ Q_OBJECT public: - MvQPointSelection(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = 0); - ~MvQPointSelection(); + MvQPointSelection(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = nullptr); + ~MvQPointSelection() override; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); - QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; + QRectF boundingRect() const override; void setPoint(double, double); void clearPoint(); - void setActivated(bool); + void setActivated(bool) override; - void mousePressEventFromView(QMouseEvent*); - void mouseMoveEventFromView(QMouseEvent*); - void mouseReleaseEventFromView(QMouseEvent*); - void reset(); + void mousePressEventFromView(QMouseEvent*) override; + void mouseMoveEventFromView(QMouseEvent*) override; + void mouseReleaseEventFromView(QMouseEvent*) override; + void reset() override; signals: void pointIsDefined(double, double); diff -Nru metview-5.17.4/metview/src/uPlot/MvQProgressBarPanel.cc metview-5.19.2/metview/src/uPlot/MvQProgressBarPanel.cc --- metview-5.17.4/metview/src/uPlot/MvQProgressBarPanel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQProgressBarPanel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ // Create progress bar progressBar_ = new QProgressBar(this); - acToolBar_ = new QWidgetAction(this); + acToolBar_ = new QWidgetAction(this); acToolBar_->setDefaultWidget(progressBar_); acToolBar_->setVisible(false); toolBar->addAction(acToolBar_); diff -Nru metview-5.17.4/metview/src/uPlot/MvQProgressBarPanel.h metview-5.19.2/metview/src/uPlot/MvQProgressBarPanel.h --- metview-5.17.4/metview/src/uPlot/MvQProgressBarPanel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQProgressBarPanel.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,12 +20,12 @@ // Q_OBJECT //put it back if it needs to use signal/slot public: - MvQProgressBarPanel(QToolBar*, QWidget* parent = 0); + MvQProgressBarPanel(QToolBar*, QWidget* parent = nullptr); - ~MvQProgressBarPanel(); + ~MvQProgressBarPanel() override; void setRange(int, int); - void setVisible(bool); + void setVisible(bool) override; void reset(); void setValue(int); diff -Nru metview-5.17.4/metview/src/uPlot/MvQProgressItem.cc metview-5.19.2/metview/src/uPlot/MvQProgressItem.cc --- metview-5.17.4/metview/src/uPlot/MvQProgressItem.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQProgressItem.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,13 +20,13 @@ font_->setPointSize(26); fontMetrics_ = new QFontMetrics(*font_); - //fontPen_=QPen(Qt::white); - //fontBrush_=QBrush(Qt::white); + // fontPen_=QPen(Qt::white); + // fontBrush_=QBrush(Qt::white); - fontPen_ = QPen(); + fontPen_ = QPen(); fontBrush_ = QBrush(); - bgPen_ = QPen(QColor(255, 255, 255, 190)); + bgPen_ = QPen(QColor(255, 255, 255, 190)); bgBrush_ = QBrush(QColor(120, 120, 120, 190)); } @@ -53,7 +53,7 @@ painter->drawRect(rect_); - //Render text + // Render text painter->translate(rect_.width() / 2, rect_.height() / 2); painter->scale(1., -1.); painter->drawText(0, 0, QObject::tr("Loading ...")); diff -Nru metview-5.17.4/metview/src/uPlot/MvQProgressManager.cc metview-5.19.2/metview/src/uPlot/MvQProgressManager.cc --- metview-5.17.4/metview/src/uPlot/MvQProgressManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQProgressManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -84,7 +84,7 @@ // Get the most recent file QFileInfoList list = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs, QDir::Time); - QString fileName = list.first().absoluteFilePath(); + QString fileName = list.first().absoluteFilePath(); // Wait until filesize has not been changed for 1 second int size1 = 0; @@ -94,7 +94,7 @@ sleep(1); QFileInfo finfo(fileName); size2 = finfo.size(); - //qDebug() << "Slept 1 second" << size1 << size2; + // qDebug() << "Slept 1 second" << size1 << size2; if (size1 == size2) break; } @@ -104,6 +104,6 @@ size1 = size2; QFileInfo finfo(fileName); size2 = finfo.size(); - //qDebug() << "Slept 500miliseconds" << size1 << size2; + // qDebug() << "Slept 500miliseconds" << size1 << size2; } } diff -Nru metview-5.17.4/metview/src/uPlot/MvQProgressManager.h metview-5.19.2/metview/src/uPlot/MvQProgressManager.h --- metview-5.17.4/metview/src/uPlot/MvQProgressManager.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQProgressManager.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,9 @@ Q_OBJECT public: - MvQProgressManager(int, MvQProgressBarPanel* pbp = 0, QWidget* parent = 0); + MvQProgressManager(int, MvQProgressBarPanel* pbp = nullptr, QWidget* parent = nullptr); - ~MvQProgressManager(); + ~MvQProgressManager() override; QFileSystemWatcher* getWatcher() { @@ -33,7 +33,7 @@ watcher_ = watcher; } - void setVisible(bool); + void setVisible(bool) override; void waitFileCreation(); diff -Nru metview-5.17.4/metview/src/uPlot/MvQPushButton.cc metview-5.19.2/metview/src/uPlot/MvQPushButton.cc --- metview-5.17.4/metview/src/uPlot/MvQPushButton.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPushButton.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,7 +36,7 @@ void MvQPushButton::init() { orientation_ = Qt::Horizontal; - mirrored_ = false; + mirrored_ = false; } Qt::Orientation MvQPushButton::orientation() const @@ -136,8 +136,8 @@ opt.state |= QStyle::State_On; if (!isFlat() && !isDown()) opt.state |= QStyle::State_Raised; - opt.text = text(); - opt.icon = icon(); + opt.text = text(); + opt.icon = icon(); opt.iconSize = iconSize(); return opt; } diff -Nru metview-5.17.4/metview/src/uPlot/MvQPushButton.h metview-5.19.2/metview/src/uPlot/MvQPushButton.h --- metview-5.17.4/metview/src/uPlot/MvQPushButton.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQPushButton.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,10 @@ class MvQPushButton : public QPushButton { public: - MvQPushButton(QWidget* parent = 0); - MvQPushButton(const QString& text, QWidget* parent = 0); - MvQPushButton(const QIcon& icon, const QString& text, QWidget* parent = 0); - ~MvQPushButton(); + MvQPushButton(QWidget* parent = nullptr); + MvQPushButton(const QString& text, QWidget* parent = nullptr); + MvQPushButton(const QIcon& icon, const QString& text, QWidget* parent = nullptr); + ~MvQPushButton() override; Qt::Orientation orientation() const; void setOrientation(Qt::Orientation orientation); @@ -26,11 +26,11 @@ bool mirrored() const; void setMirrored(bool mirrored); - QSize sizeHint() const; - QSize minimumSizeHint() const; + QSize sizeHint() const override; + QSize minimumSizeHint() const override; protected: - void paintEvent(QPaintEvent* event); + void paintEvent(QPaintEvent* event) override; private: QStyleOptionButton getStyleOption() const; diff -Nru metview-5.17.4/metview/src/uPlot/MvQStepModel.cc metview-5.19.2/metview/src/uPlot/MvQStepModel.cc --- metview-5.17.4/metview/src/uPlot/MvQStepModel.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQStepModel.cc 2023-07-15 08:28:47.000000000 +0000 @@ -53,13 +53,13 @@ void MvQStepModel::setStepData(MgQSceneItem* data) { stepData_ = data; - //endResetModel(); + // endResetModel(); } QVariant MvQStepModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { - return QVariant(); + return {}; } if (role == Qt::BackgroundRole) { @@ -71,7 +71,7 @@ // return QColor("#FFF2DE"); } else { - return {}; //QBrush(Qt::white); + return {}; // QBrush(Qt::white); } } diff -Nru metview-5.17.4/metview/src/uPlot/MvQStepModel.h metview-5.19.2/metview/src/uPlot/MvQStepModel.h --- metview-5.17.4/metview/src/uPlot/MvQStepModel.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQStepModel.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,9 @@ class MvQStepDelegate : public QStyledItemDelegate { public: - MvQStepDelegate(QWidget* parent = 0); + MvQStepDelegate(QWidget* parent = nullptr); void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; + const QModelIndex& index) const override; }; @@ -35,7 +35,7 @@ public: MvQStepModel(QObject*); - QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const override; MgQSceneItem* stepData() { return stepData_; } @@ -46,7 +46,7 @@ void stepCacheStateChanged(); protected: - //QString label( const int,const int) const; + // QString label( const int,const int) const; private: MgQSceneItem* stepData_; diff -Nru metview-5.17.4/metview/src/uPlot/MvQStepWidget.cc metview-5.19.2/metview/src/uPlot/MvQStepWidget.cc --- metview-5.17.4/metview/src/uPlot/MvQStepWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQStepWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -44,27 +44,27 @@ auto* layout = new QVBoxLayout; setLayout(layout); - //Create model + // Create model model_ = new MvQStepModel(this); sortModel_ = new MvQKeyProfileSortFilterModel(this); sortModel_->setSourceModel(model_); sortModel_->setDynamicSortFilter(true); - //Create view + // Create view view_ = new MvQKeyProfileTree(this); view_->setModels(model_, sortModel_); connect(view_, SIGNAL(selectionChanged(QModelIndex)), this, SIGNAL(selectionChanged(QModelIndex))); - //The profile was altered via the treeview headings + // The profile was altered via the treeview headings connect(view_, SIGNAL(profileChanged(bool, int)), this, SLOT(adjustProfile(bool, int))); layout->addWidget(view_); - //Buttons at the bottom + // Buttons at the bottom auto* hb = new QHBoxLayout; @@ -78,10 +78,10 @@ connect(tbEdit, SIGNAL(clicked()), this, SLOT(slotManageKeyProfiles())); - //Combo box - //We will add items + signal/slots later in "init"! + // Combo box + // We will add items + signal/slots later in "init"! auto* keyLabel = new QLabel(tr("Key profile:")); - keyCombo_ = new QComboBox; + keyCombo_ = new QComboBox; keyLabel->setBuddy(keyCombo_); hb->addWidget(keyLabel); @@ -102,13 +102,13 @@ { scene_ = scene; - model_->setStepData(scene_->currentSceneItem()); //Just to have something!!! + model_->setStepData(scene_->currentSceneItem()); // Just to have something!!! //---------------------------------- // Initilaize the key profile list //--------------------------------- - //disconnect(keyCombo_,SIGNAL(currentIndexChanged(int)),this,SLOT(loadKeyProfile(int))); + // disconnect(keyCombo_,SIGNAL(currentIndexChanged(int)),this,SLOT(loadKeyProfile(int))); int currentProfileIndex = 0; for (unsigned int i = 0; i < keyManager_->data().size(); i++) { @@ -127,10 +127,10 @@ connect(keyCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLoadKeyProfile(int))); - //Select the first element + // Select the first element keyCombo_->setCurrentIndex(currentProfileIndex); - //Get all keys + // Get all keys std::vector allKeyProf; keyManager_->loadAllKeys(allKeyProf); for (auto& it : allKeyProf) { @@ -144,7 +144,7 @@ // Initilaize the key profile list //--------------------------------- - //disconnect(keyCombo_,SIGNAL(currentIndexChanged(int)),this,SLOT(loadKeyProfile(int))); + // disconnect(keyCombo_,SIGNAL(currentIndexChanged(int)),this,SLOT(loadKeyProfile(int))); int currentProfileIndex = 0; for (unsigned int i = 0; i < keyManager_->data().size(); i++) { @@ -163,10 +163,10 @@ connect(keyCombo_, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLoadKeyProfile(int))); - //Select the first element + // Select the first element keyCombo_->setCurrentIndex(currentProfileIndex); - //Get all keys + // Get all keys std::vector allKeyProf; keyManager_->loadAllKeys(allKeyProf); for (auto& it : allKeyProf) { @@ -194,22 +194,22 @@ void MvQStepWidget::reloadKeyProfile() { - //set the keyboard focus to the view! + // set the keyboard focus to the view! view_->setFocus(); if (MvKeyProfile* profDef = model_->keyProfile()) { - //Clone the profile + // Clone the profile MvKeyProfile* prof = profDef->clone(); - //Load data into the profile + // Load data into the profile collectKeyProfileData(prof); - //Update message tree. The model takes ownership of the profile. + // Update message tree. The model takes ownership of the profile. model_->setKeyProfile(prof); } } -//It is called when a new request sent to magics is finsihed +// It is called when a new request sent to magics is finsihed void MvQStepWidget::reset(MgQSceneItem* sceneItem) { activeScene_ = sceneItem; @@ -219,13 +219,13 @@ reloadKeyProfile(); } -//Collect the metadata into the profile. +// Collect the metadata into the profile. void MvQStepWidget::collectKeyProfileData(MvKeyProfile* prof) { if (!prof) return; - //At this point the profile is not yet added to the model. + // At this point the profile is not yet added to the model. Q_ASSERT(model_->keyProfile() != prof); QStringList keys; @@ -249,7 +249,7 @@ prof->clearKeyData(); - //Get metadata + // Get metadata auto* metaData = new MgQStepMetaData(keys); if (activeScene_) @@ -257,7 +257,7 @@ for (int i = 0; i < keys.count(); i++) { MvKey* kd = prof->at(i); - int step = 1; + int step = 1; foreach (QString str, metaData->stepData(i)) { if (str.endsWith('\n')) { str.remove(str.size() - 1, 1); @@ -266,13 +266,15 @@ if (keys[i] == "MV_Frame" || keys[i] == "MV_Index") { if (kd->valueType() == MvKey::IntType) { kd->addValue(step); - } else { + } + else { kd->addValue(MvVariant(QString::number(step).toStdString())); } } else if (keys[i] == "MV_Value") { kd->addValue(std::string()); - } else { + } + else { kd->addValue(str.toStdString()); } @@ -346,13 +348,13 @@ if (!profDef) return; - //Clone the profile + // Clone the profile MvKeyProfile* prof = profDef->clone(); - //Load data into the profile + // Load data into the profile collectKeyProfileData(prof); - //Update message tree. The model takes ownership of the profile. + // Update message tree. The model takes ownership of the profile. model_->setKeyProfile(prof); @@ -372,10 +374,10 @@ emit keyProfileChanged(model_->keyProfile()); } -//The profile was modified via the treeview headings +// The profile was modified via the treeview headings void MvQStepWidget::adjustProfile(bool reload, int selectedRow) { - //emit statusMessage(tr("Reload key profile ...")); + // emit statusMessage(tr("Reload key profile ...")); if (reload) { if (selectedRow == -1) @@ -417,7 +419,7 @@ if (current > item->stepNum() - 1) current = current % item->stepNum(); - //We just load it and do not render it into the pixmap cache!!! + // We just load it and do not render it into the pixmap cache!!! item->setCurrentStep(current, false); } } @@ -429,7 +431,7 @@ return -1; } - //Get the original (unsorted) model index for the step num + // Get the original (unsorted) model index for the step num QModelIndex index = sortModel_->mapToSource(sortModel_->index(sortedStep, 0)); int step = index.row(); @@ -458,9 +460,9 @@ if (!activeScene_) return -1; - int currentStep = activeScene_->currentStep(); + int currentStep = activeScene_->currentStep(); QModelIndex index = sortModel_->mapFromSource(model_->index(currentStep, 0)); - int sortedStep = index.row(); + int sortedStep = index.row(); return sortedStep; } @@ -472,10 +474,10 @@ int currentStep = activeScene_->currentStep(); // QModelIndex src=model_->index(currentStep,0); - QModelIndex index = sortModel_->mapFromSource(model_->index(currentStep, 0)); + QModelIndex index = sortModel_->mapFromSource(model_->index(currentStep, 0)); QModelIndex current = view_->currentIndex(); - //qDebug() << model_->currentStep() << src << index; + // qDebug() << model_->currentStep() << src << index; if (index.row() != current.row()) { view_->setCurrentIndex(index); } @@ -498,14 +500,14 @@ MvQKeyManager::KeyType type = MvQKeyManager::FrameType; - //Create a tmp copy of the whole manager (no data - //values, just key descriptions) + // Create a tmp copy of the whole manager (no data + // values, just key descriptions) MvQKeyManager* tmpManager = keyManager_->clone(); MvQKeyDialog profDialog(dialogTitle, type, tmpManager, keyCombo_->currentIndex(), allKeys_); if (profDialog.exec() == QDialog::Accepted) { - //Save the current profile name + // Save the current profile name std::string currentProfName = keyCombo_->currentText().toStdString(); #if 0 messageModel_->keyProfileIsAboutToChange(); @@ -514,14 +516,14 @@ keyManager_->update(tmpManager); keyManager_->saveProfiles(); - disconnect(keyCombo_, SIGNAL(currentIndexChanged(int)), 0, 0); + disconnect(keyCombo_, SIGNAL(currentIndexChanged(int)), nullptr, nullptr); - //Clear the profile list + // Clear the profile list keyCombo_->clear(); - //resetMessageHeader(); + // resetMessageHeader(); - int i = 0; + int i = 0; int index = -1; for (auto it = keyManager_->data().begin(); it != keyManager_->data().end(); it++) { keyCombo_->addItem(QString((*it)->name().c_str())); @@ -545,7 +547,7 @@ Q_ASSERT(keyCombo_->currentIndex() >= 0 && keyCombo_->currentIndex() < static_cast(keyManager_->data().size())); - //We load the profile directly + // We load the profile directly loadKeyProfile(keyManager_->data().at(keyCombo_->currentIndex())); connect(keyCombo_, SIGNAL(currentIndexChanged(int)), diff -Nru metview-5.17.4/metview/src/uPlot/MvQStepWidget.h metview-5.19.2/metview/src/uPlot/MvQStepWidget.h --- metview-5.17.4/metview/src/uPlot/MvQStepWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQStepWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,8 @@ Q_OBJECT public: - MvQStepWidget(QWidget* parent = 0); - ~MvQStepWidget(); + MvQStepWidget(QWidget* parent = nullptr); + ~MvQStepWidget() override; MvQKeyProfileTree* view() { return view_; } void init(MgQPlotScene*, QString); diff -Nru metview-5.17.4/metview/src/uPlot/MvQVideoDialog.cc metview-5.19.2/metview/src/uPlot/MvQVideoDialog.cc --- metview-5.17.4/metview/src/uPlot/MvQVideoDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQVideoDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,32 +20,32 @@ MvQVideoDialog::MvQVideoDialog(QWidget* parent) : QFileDialog(parent, "MvQVideo") { - //setAttribute(Qt::WA_DeleteOnClose); + // setAttribute(Qt::WA_DeleteOnClose); // Set widget mode behaviour to "Save As" this->setAcceptMode(QFileDialog::AcceptSave); // Restore previous gui settings /*QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS,"uPlotMvQVideoDialog"); - settings.beginGroup("main"); + settings.beginGroup("main"); selectFile(settings.value("fileName").toString()); - QStringList fout = settings.value("formats").toStringList(); - settings.endGroup();*/ + QStringList fout = settings.value("formats").toStringList(); + settings.endGroup();*/ // Set filter options to select which files to be shown this->setFilter(tr("All Files (*.*);;Images (*.gif *.tar)")); // Get the main layout QGridLayout* mainLayout = static_cast(layout()); - int row = mainLayout->rowCount(); - int col = mainLayout->columnCount(); + int row = mainLayout->rowCount(); + int col = mainLayout->columnCount(); // Build label for the Output format QLabel* label = new QLabel(this); label->setText("Output formats:"); mainLayout->addWidget(label, row, 0); - formats_["Animated gif (*.gif)"] = "gif"; + formats_["Animated gif (*.gif)"] = "gif"; formats_["Png frame set in a tar file"] = "tar"; formatCombo_ = new QComboBox(this); @@ -61,29 +61,29 @@ { // Save current gui settings /*QSettings settings(MVQ_QSETTINGS_DEFAULT_ARGS,"uPlotMvQVideoDialog"); - settings.beginGroup("main"); + settings.beginGroup("main"); settings.setValue("fileName",selectedFiles()); - QStringList formats = comboBox_->getSelectedValues(); - if ( formats.size() ) - settings.setValue("formats",formats); - else - settings.setValue("formats","PS"); - settings.endGroup();*/ + QStringList formats = comboBox_->getSelectedValues(); + if ( formats.size() ) + settings.setValue("formats",formats); + else + settings.setValue("formats","PS"); + settings.endGroup();*/ - //delete comboBox_; + // delete comboBox_; } // Callback from the SAVE button void MvQVideoDialog::accept() { QString filename = selectedFiles().at(0); - QString format = formats_[formatCombo_->currentText()]; + QString format = formats_[formatCombo_->currentText()]; hide(); emit sendInfo(filename, format); - //done(0); + // done(0); } void MvQVideoDialog::reject() diff -Nru metview-5.17.4/metview/src/uPlot/MvQVideoDialog.h metview-5.19.2/metview/src/uPlot/MvQVideoDialog.h --- metview-5.17.4/metview/src/uPlot/MvQVideoDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQVideoDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,15 +20,15 @@ Q_OBJECT public: - MvQVideoDialog(QWidget* parent = 0); - ~MvQVideoDialog(); + MvQVideoDialog(QWidget* parent = nullptr); + ~MvQVideoDialog() override; signals: void sendInfo(QString, QString); public slots: - void accept(); - void reject(); + void accept() override; + void reject() override; private: QComboBox* formatCombo_; diff -Nru metview-5.17.4/metview/src/uPlot/MvQWeatherRoomDialog.cc metview-5.19.2/metview/src/uPlot/MvQWeatherRoomDialog.cc --- metview-5.17.4/metview/src/uPlot/MvQWeatherRoomDialog.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQWeatherRoomDialog.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,10 +31,10 @@ MvQVideoWallCellInfo::MvQVideoWallCellInfo(double x, double y, double w, double h, int number) { - x_ = x; - y_ = y; - w_ = w; - h_ = h; + x_ = x; + y_ = y; + w_ = w; + h_ = h; number_ = number; } @@ -269,14 +269,14 @@ // Find out the layout design (shape and number of cells) by // looping each cell and looking for colspan and rowspan - int totalRows = 0; // must take into account the rowspans - int totalCols = 0; // must take into account the colspans - int r = 0; + int totalRows = 0; // must take into account the rowspans + int totalCols = 0; // must take into account the colspans + int r = 0; ptree const& layout = itLayout->second; for (ptree::const_iterator itRows = layout.begin(); itRows != layout.end(); ++itRows) { // For each tag in the current cell ptree const& row = itRows->second; - int c = 0; + int c = 0; for (ptree::const_iterator itCols = row.begin(); itCols != row.end(); ++itCols) { int colSpan = itCols->second.get("colspan", 1); int rowSpan = itCols->second.get("rowspan", 1); @@ -293,14 +293,14 @@ } // Build the Qt layout by looping each cell for the second time - int cellNumber = -1; + int cellNumber = -1; double rowHeight = 1.0 / totalRows; - double currentY = 0.0; + double currentY = 0.0; for (ptree::const_iterator itRows = layout.begin(); itRows != layout.end(); ++itRows) { ptree const& row = itRows->second; - double colWidth = 1.0 / totalCols; - double currentX = 0.0; + double colWidth = 1.0 / totalCols; + double currentX = 0.0; // For each tag in the current cell for (ptree::const_iterator itCols = row.begin(); itCols != row.end(); ++itCols) { @@ -375,7 +375,7 @@ if (imgR.canRead()) { imgR.setScaledSize(QSize(size, size)); QImage img = imgR.read(); - pix_ = QPixmap::fromImage(img); + pix_ = QPixmap::fromImage(img); } QImageReader imgRs(":/uPlot/wall_screen_selected.svg"); @@ -442,7 +442,7 @@ void MvQVideoWallWidget::updateCellSelection(const QString& selection) { int screenNum = selection.toInt(); - current_ = screenNum - 1; + current_ = screenNum - 1; update(); } @@ -489,8 +489,8 @@ // Wall combo QVBoxLayout* vb = new QVBoxLayout(); setLayout(vb); - QLabel* label = new QLabel(tr("Video wall:"), this); - wallCb_ = new QComboBox(this); + QLabel* label = new QLabel(tr("Video wall:"), this); + wallCb_ = new QComboBox(this); QHBoxLayout* hb = new QHBoxLayout(); hb->addWidget(label); hb->addWidget(wallCb_, 1); @@ -503,17 +503,17 @@ connect(wallCb_, SIGNAL(currentIndexChanged(int)), this, SLOT(updateWallSelection(int))); wallCb_->addItem("No wall"); - //Cell selector + // Cell selector cellSelector_ = new MvQVideoWallWidget(this); vb->addWidget(cellSelector_, 1); cellSelector_->setWall(nullptr); cellSelector_->setEnabled(false); // Cell selection text box (for if the layout plot is not sufficient) - QHBoxLayout* hb2 = new QHBoxLayout(); + QHBoxLayout* hb2 = new QHBoxLayout(); QLabel* screenSelectionLabel = new QLabel(tr("Cell:"), this); hb2->addWidget(screenSelectionLabel); - leCellSelection_ = new QLineEdit(this); + leCellSelection_ = new QLineEdit(this); QValidator* intValidator = new QIntValidator(1, 100, this); leCellSelection_->setValidator(intValidator); hb2->addWidget(leCellSelection_); @@ -527,7 +527,7 @@ leCellSelection_, SLOT(setText(const QString&))); // Frame selection - //buildFrameSelection(vb); + // buildFrameSelection(vb); // Buttonbox QDialogButtonBox* buttonBox = new QDialogButtonBox(this); @@ -579,7 +579,7 @@ // Get the wall index. Previous one if exists or the first one by default int lastWallIndex = wallServer_->wallInfoIndexFromName(lastWall_); if (lastWallIndex < 0) { - lastCell_ = 1; // default value + lastCell_ = 1; // default value lastWallIndex = 0; } diff -Nru metview-5.17.4/metview/src/uPlot/MvQWeatherRoomDialog.h metview-5.19.2/metview/src/uPlot/MvQWeatherRoomDialog.h --- metview-5.17.4/metview/src/uPlot/MvQWeatherRoomDialog.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQWeatherRoomDialog.h 2023-07-15 08:28:47.000000000 +0000 @@ -57,7 +57,8 @@ class MvQVideoWallInfo { public: - MvQVideoWallInfo(){}; + MvQVideoWallInfo() = default; + ; std::vector& cellInfos() { return cellInfos_; } QString& name() { return name_; } @@ -89,7 +90,7 @@ Q_OBJECT public: - MvQVideoWallServer(QObject* parent = 0); + MvQVideoWallServer(QObject* parent = nullptr); MvQVideoWallInfo* wallInfo() { return wallInfo_; } void createWallLayout(int); @@ -131,7 +132,7 @@ Q_OBJECT public: - MvQVideoWallWidget(QWidget* parent = 0); + MvQVideoWallWidget(QWidget* parent = nullptr); void setWall(MvQVideoWallInfo* info); int current() const { return current_; } @@ -144,8 +145,8 @@ void selectionChanged(const QString&); protected: - void paintEvent(QPaintEvent*); - void mousePressEvent(QMouseEvent*); + void paintEvent(QPaintEvent*) override; + void mousePressEvent(QMouseEvent*) override; private: bool select(QPoint); @@ -162,8 +163,8 @@ Q_OBJECT public: - MvQWeatherRoomDialog(int, int, QWidget* parent = 0); - ~MvQWeatherRoomDialog(); + MvQWeatherRoomDialog(int, int, QWidget* parent = nullptr); + ~MvQWeatherRoomDialog() override; // Get info from the user interface int getCell(); @@ -175,10 +176,10 @@ void updateWallServerSelector(); void updateWallLayoutSelector(); void updateWallSelection(int); - void accept(); + void accept() override; protected: - void setVisible(bool); + void setVisible(bool) override; void readSettings(); void writeSettings(); diff -Nru metview-5.17.4/metview/src/uPlot/MvQZoom.cc metview-5.19.2/metview/src/uPlot/MvQZoom.cc --- metview-5.17.4/metview/src/uPlot/MvQZoom.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQZoom.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,10 +20,10 @@ MvQZoom::MvQZoom(MgQPlotScene* scene, MvQPlotView* view, QGraphicsItem* parent) : MvQPlotItem(scene, view, parent) { - pen_ = QPen(QColor(110, 110, 110), 2); - brush_ = QBrush(QColor(230, 230, 230, 180)); - currentAction_ = NoAction; - zoomLayout_ = nullptr; + pen_ = QPen(QColor(110, 110, 110), 2); + brush_ = QBrush(QColor(230, 230, 230, 180)); + currentAction_ = NoAction; + zoomLayout_ = nullptr; zoomWasPerformedAfterMouseRelease_ = false; } @@ -31,7 +31,7 @@ QRectF MvQZoom::boundingRect() const { - //return zoomRect_.adjusted(-2,-2,2,-2); + // return zoomRect_.adjusted(-2,-2,2,-2); return zoomRect_; } @@ -52,7 +52,7 @@ { if (activated_ && acceptMouseEvents_ && event->buttons() & Qt::LeftButton) { - //Get scene position + // Get scene position zoomRectOrigin_ = plotView_->mapToScene(event->pos()); MgQSceneItem* sceneItem = nullptr; @@ -60,7 +60,7 @@ if (plotScene_->identifyPos(zoomRectOrigin_, &sceneItem, &zoomLayout_)) { currentAction_ = ZoomAction; - //Set geometry + // Set geometry zoomRect_.setRect(zoomRectOrigin_.x(), zoomRectOrigin_.y(), 0, 0); setVisible(true); @@ -78,7 +78,7 @@ if (activated_ && acceptMouseEvents_ && currentAction_ == ZoomAction) { QPointF pos = plotView_->mapToScene(event->pos()); - QPointF dp = pos - zoomRectOrigin_; + QPointF dp = pos - zoomRectOrigin_; if (dp.x() <= 0. || dp.y() >= 0.) return; @@ -87,7 +87,7 @@ return; prepareGeometryChange(); - //zoomRect_=QRectF(zoomRectOrigin_, pos); + // zoomRect_=QRectF(zoomRectOrigin_, pos); zoomRect_ = QRectF(zoomRectOrigin_.x(), pos.y(), dp.x(), -dp.y()); // qDebug() << "zoom update" << isVisible() << boundingRect(); @@ -101,42 +101,42 @@ if (activated_ && acceptMouseEvents_ && currentAction_ == ZoomAction) { QPointF pos = plotView_->mapToScene(event->pos()); - QPointF dp = pos - zoomRectOrigin_; + QPointF dp = pos - zoomRectOrigin_; - //Rubberband rect in scene coordinates - //QRectF rect(zoomRectOrigin_,pos); + // Rubberband rect in scene coordinates + // QRectF rect(zoomRectOrigin_,pos); QRectF rect(zoomRectOrigin_.x(), pos.y(), dp.x(), -dp.y()); if (dp.x() <= 0. || dp.y() >= 0. || fabs(rect.width()) <= 8. || fabs(rect.height()) <= 8.) { setVisible(false); - //plotScene_->removeItem(rubberBand_); + // plotScene_->removeItem(rubberBand_); - //Reset zoom data - currentAction_ = NoAction; + // Reset zoom data + currentAction_ = NoAction; zoomWasPerformedAfterMouseRelease_ = false; - zoomLayout_ = nullptr; + zoomLayout_ = nullptr; } else { - //Get geo coordinates of rect corners + // Get geo coordinates of rect corners QPointF sp1 = zoomRect_.topLeft(); QPointF sp2 = zoomRect_.bottomRight(); - //zoomLayout_->mapFromSceneToGeoCoords(sp1,gp1); - //zoomLayout_->mapFromSceneToGeoCoords(sp2,gp2); + // zoomLayout_->mapFromSceneToGeoCoords(sp1,gp1); + // zoomLayout_->mapFromSceneToGeoCoords(sp2,gp2); std::string trDef = zoomLayout_->mapFromSceneToTransformationDefinition(sp1, sp2); QString layoutId(zoomLayout_->layout().id().c_str()); setVisible(false); - //Reset zoom data - currentAction_ = NoAction; + // Reset zoom data + currentAction_ = NoAction; zoomWasPerformedAfterMouseRelease_ = true; - zoomLayout_ = nullptr; + zoomLayout_ = nullptr; // qDebug() << "zoom def:" << QString(trDef.c_str()); - //Perform the zoom + // Perform the zoom emit zoomRectangleIsDefined(layoutId.toStdString(), trDef); } } diff -Nru metview-5.17.4/metview/src/uPlot/MvQZoom.h metview-5.19.2/metview/src/uPlot/MvQZoom.h --- metview-5.17.4/metview/src/uPlot/MvQZoom.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQZoom.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,14 +32,14 @@ }; MvQZoom(MgQPlotScene*, MvQPlotView*, QGraphicsItem* parent = nullptr); - ~MvQZoom(); + ~MvQZoom() override; - void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*); - QRectF boundingRect() const; + void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) override; + QRectF boundingRect() const override; - void mousePressEventFromView(QMouseEvent*); - void mouseMoveEventFromView(QMouseEvent*); - void mouseReleaseEventFromView(QMouseEvent*); + void mousePressEventFromView(QMouseEvent*) override; + void mouseMoveEventFromView(QMouseEvent*) override; + void mouseReleaseEventFromView(QMouseEvent*) override; CurrentAction currentAction() { return currentAction_; } bool zoomWasPerformedAfterMouseRelease() { return zoomWasPerformedAfterMouseRelease_; } diff -Nru metview-5.17.4/metview/src/uPlot/MvQZoomStackWidget.cc metview-5.19.2/metview/src/uPlot/MvQZoomStackWidget.cc --- metview-5.17.4/metview/src/uPlot/MvQZoomStackWidget.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQZoomStackWidget.cc 2023-07-15 08:28:47.000000000 +0000 @@ -37,7 +37,7 @@ float w = img.width(); float h = img.height(); - //We copy the image into a pixmap with the maximum size of 92x46 + // We copy the image into a pixmap with the maximum size of 92x46 float hMax = pixSize_.height() - 6; float wMax = 2 * hMax; QPixmap pix; @@ -48,19 +48,19 @@ pix = QPixmap::fromImage(img).scaledToHeight(hMax, Qt::SmoothTransformation); } - //Define the pixmap rectangle - int pw = pix.width(); - int ph = pix.height(); + // Define the pixmap rectangle + int pw = pix.width(); + int ph = pix.height(); int pdy = (pixSize_.height() - ph) / 2; - //int pdx = (pixSize_.width() - pw) / 2; + // int pdx = (pixSize_.width() - pw) / 2; int pdx = 3; QRect pixRect(pdx, pdy, pw, ph); - //We create a 60x60 pixmap with white background + // We create a 60x60 pixmap with white background pixmap_ = QPixmap(pixSize()); pixmap_.fill(MvQTheme::colour("uplot", "zoomstack_bg")); - //Paint the image pixmap into the middle + // Paint the image pixmap into the middle QPainter painter(&pixmap_); painter.drawPixmap(pixRect, pix); } @@ -73,12 +73,12 @@ MvQZoomStackData::MvQZoomStackData(QString grLayoutId) : grLayoutId_(grLayoutId) { - //Initially we do not have levels - levelNum_ = 0; - actLevel_ = -1; + // Initially we do not have levels + levelNum_ = 0; + actLevel_ = -1; selectedLevel_ = -1; - //levelPreviewWidth_=180; + // levelPreviewWidth_=180; levelPreviewWidth_ = 100; } @@ -95,19 +95,19 @@ } levels_.clear(); - levelNum_ = 0; - actLevel_ = -1; + levelNum_ = 0; + actLevel_ = -1; selectedLevel_ = -1; } int MvQZoomStackData::update(int levelNum, int actLevel, MgQLayoutItem* item) { - //Get the new number of levels + // Get the new number of levels int levelNumOri = levelNum_; int actLevelOri = actLevel_; - //int selectedLevel=-1; + // int selectedLevel=-1; levelNum_ = levelNum; actLevel_ = actLevel; @@ -123,19 +123,19 @@ if (levelNum_ <= 0) { clear(); - //The gui is not enabled yet - //enabled_=false; + // The gui is not enabled yet + // enabled_=false; - //Clear the preview textures - //clear(); + // Clear the preview textures + // clear(); - //Save the preview map into a texture + // Save the preview map into a texture if (levelNum_ == 0 && actLevel_ == -1) { if (levels_.count() == 0) // && currentLayout_ != 0) { auto* level = new MvQZoomStackLevel; generatePreview(level, item); - //level->tb()->setChecked(true); + // level->tb()->setChecked(true); levels_.push_back(level); selectedLevel_ = 0; } @@ -147,14 +147,14 @@ return selectedLevel_; } else { - //enabled_=true; + // enabled_=true; } - //If the levelNum or the current level has changed. + // If the levelNum or the current level has changed. if (levelNumOri != levelNum_ || actLevelOri != actLevel_) { - //focusedLevel_=-1; + // focusedLevel_=-1; - //If there are less levels + // If there are less levels if (levelNumOri > levelNum_) { for (int i = levelNumOri - 1; i >= levelNum_; i--) { MvQZoomStackLevel* level = levels_.back(); @@ -166,7 +166,7 @@ selectedLevel_ = levels_.count() - 1; } - //If there are more levels + // If there are more levels else if (levelNumOri < levelNum_) { auto* level = new MvQZoomStackLevel; generatePreview(level, item); @@ -174,8 +174,8 @@ selectedLevel_ = levels_.count() - 1; } - //If the level num is the same. If the actLevel is the last one we - //regenerate the preview + // If the level num is the same. If the actLevel is the last one we + // regenerate the preview else { selectedLevel_ = actLevel_; if (actLevel_ == levelNum_ - 1) { @@ -189,55 +189,55 @@ void MvQZoomStackData::generatePreview(MvQZoomStackLevel* level, MgQLayoutItem* qln) { - if (qln == 0) + if (qln == nullptr) return; - //Get the preview layout's scene rectangle. We increase the width and - //height a bit so that the rendered image could contain the whole frame + // Get the preview layout's scene rectangle. We increase the width and + // height a bit so that the rendered image could contain the whole frame QRectF sourceRect = qln->sceneBoundingRect(); sourceRect.adjust(0., 0., 5., 5.); - //Define the size of the device where the preview plot will be rendered + // Define the size of the device where the preview plot will be rendered float tw = levelPreviewWidth_; - float w = sourceRect.width(); - float h = sourceRect.height(); - float r = tw / w; + float w = sourceRect.width(); + float h = sourceRect.height(); + float r = tw / w; float th = h * r; if (th > levelPreviewWidth_) { th = levelPreviewWidth_; - r = th / h; + r = th / h; tw = w * r; } - //Create the device. We double the needed size for later smooth recaling! + // Create the device. We double the needed size for later smooth recaling! QImage device = QImage(tw * 2, th * 2, QImage::Format_RGB888); - //Set the target rect + // Set the target rect QRectF targetRect(0, 0, device.width(), device.height()); - //Create the painter + // Create the painter auto* painter = new QPainter(&device); - //Fill the target device with with colour + // Fill the target device with with colour painter->fillRect(0, 0, device.width(), device.height(), QBrush(Qt::white)); - //Render the item into the device + // Render the item into the device qln->scene()->render(painter, targetRect, sourceRect); - //Rescale the device to the needed side with smooth transformation. Then mirror it horizontally. + // Rescale the device to the needed side with smooth transformation. Then mirror it horizontally. QImage img = device.scaledToWidth(tw, Qt::SmoothTransformation).mirrored(false, true); - //Now we can set the preview! + // Now we can set the preview! level->setImage(img); } bool MvQZoomStackData::setActLevel(int level) { if (level >= 0 && level < levelNum_ && level != actLevel_) { - actLevel_ = level; + actLevel_ = level; selectedLevel_ = actLevel_; return true; } @@ -314,7 +314,7 @@ QModelIndex MvQZoomStackModel::parent(const QModelIndex& /*index*/) const { - return QModelIndex(); + return {}; } //========================= @@ -335,7 +335,7 @@ view_->setSpacing(2); view_->setSelectionMode(QAbstractItemView::NoSelection); view_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - //view_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // view_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view_->setModel(model_); vb->addWidget(view_, 1); @@ -373,7 +373,7 @@ } } - //Remove unused scenes from the zoomstack + // Remove unused scenes from the zoomstack foreach (QString id, page_.keys()) { if (idLst.indexOf(id) == -1) { delete page_[id]; @@ -386,7 +386,7 @@ if (MgQLayoutItem* zoomLayout = activeScene_->firstProjectorItem()) { int levelNum = zoomLayout->layout().zoomLevels(); int actLevel = zoomLayout->layout().zoomCurrentLevel(); - QString id = QString::fromStdString(zoomLayout->layout().id()); + QString id = QString::fromStdString(zoomLayout->layout().id()); if (changeActiveScene) { if (!page_.contains(id)) { @@ -423,12 +423,12 @@ void MvQZoomStackWidget::managePreviewLayout(MvQZoomStackData* page, int levelNum, int actLevel) { if (page) { - //Find preview layout in the scene and remove it + // Find preview layout in the scene and remove it MgQPreviewLayoutItem* previewLayout = activeScene_->previewLayoutItem(); if (previewLayout) { plotScene_->removeItem(previewLayout); - //Create a new scene and add the previewLayout to it! + // Create a new scene and add the previewLayout to it! auto* previewScene = new QGraphicsScene; previewScene->addItem(previewLayout); previewLayout->setVisible(true); @@ -440,10 +440,10 @@ void MvQZoomStackWidget::adjustViewSize() { - auto px = MvQZoomStackLevel::pixSize(); - int row = model_->rowCount(); - int maxRow = 5; - int viewH = px.height() * row + 2 * row * view_->spacing(); + auto px = MvQZoomStackLevel::pixSize(); + int row = model_->rowCount(); + int maxRow = 5; + int viewH = px.height() * row + 2 * row * view_->spacing(); int maxViewH = px.height() * maxRow + 2 * maxRow * view_->spacing(); if (viewH > maxViewH) { @@ -456,7 +456,7 @@ MvQZoomStackData* MvQZoomStackWidget::pageData(MgQSceneItem* item) { if (!item) - return 0; + return nullptr; MgQLayoutItem* zoomLayout = item->firstProjectorItem(); if (zoomLayout) { @@ -466,7 +466,7 @@ } } - return 0; + return nullptr; } void MvQZoomStackWidget::slotStepUp() @@ -475,7 +475,7 @@ return; if (currentLevel() >= 1) { - int level = currentLevel() - 1; + int level = currentLevel() - 1; skipUpdate_ = true; slotStepTo(level); skipUpdate_ = false; @@ -489,7 +489,7 @@ skipUpdate_ = true; if (currentLevel() >= 0 && currentLevel() < levelNum() - 1) { - int level = currentLevel() + 1; + int level = currentLevel() + 1; skipUpdate_ = true; slotStepTo(level); skipUpdate_ = false; diff -Nru metview-5.17.4/metview/src/uPlot/MvQZoomStackWidget.h metview-5.19.2/metview/src/uPlot/MvQZoomStackWidget.h --- metview-5.17.4/metview/src/uPlot/MvQZoomStackWidget.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/MvQZoomStackWidget.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,7 +26,7 @@ class MvQZoomStackLevel { public: - MvQZoomStackLevel() {} + MvQZoomStackLevel() = default; void setImage(QImage&); const QPixmap& pixmap() const { return pixmap_; } static QSize pixSize() { return pixSize_; } @@ -42,7 +42,7 @@ Q_OBJECT public: MvQZoomStackData(QString); - ~MvQZoomStackData(); + ~MvQZoomStackData() override; int update(int, int, MgQLayoutItem*); void clear(); @@ -97,7 +97,7 @@ public: MvQZoomStackWidget(MgQPlotScene*, QWidget* parent = nullptr); - ~MvQZoomStackWidget(); + ~MvQZoomStackWidget() override; void reset(MgQSceneItem*, bool); MvQZoomStackData* pageData(MgQSceneItem*); diff -Nru metview-5.17.4/metview/src/uPlot/NewpageAction.h metview-5.19.2/metview/src/uPlot/NewpageAction.h --- metview-5.17.4/metview/src/uPlot/NewpageAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/NewpageAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -47,11 +47,11 @@ PlotModAction(name) {} // Destructor - ~NewpageAction() {} + ~NewpageAction() override = default; // Methods static PlotModAction& Instance(); // Overriden from Base Class (PlotModAction) - virtual void Execute(PmContext& context); + void Execute(PmContext& context) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/ObjectInfo.cc metview-5.19.2/metview/src/uPlot/ObjectInfo.cc --- metview-5.17.4/metview/src/uPlot/ObjectInfo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ObjectInfo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ #include "MacroConverter.h" #include "MvIcon.h" -using ExpandedMap = std::map; +using ExpandedMap = std::map; using ExpandedIterator = ExpandedMap::iterator; NamesMap ObjectInfo::namesMap_; @@ -47,10 +47,10 @@ { // Initializations ExpandedMap expandedMap; - int id = 1; + int id = 1; MvRequest tmpRequest = inRequest; - int count = inRequest.countParameters(); - int i; + int count = inRequest.countParameters(); + int i = 0; // Compute maximum parameters length names int size = MaximumParameterNameLength(inRequest); @@ -59,7 +59,7 @@ for (i = 0; i < count; i++) { const char* param = inRequest.getParameter(i); - const char* value = 0; + const char* value = nullptr; inRequest.getValue(value, param, 0); if (!value) { // No value, so check if there is a subrequest @@ -83,7 +83,7 @@ MvRequest subRequest; if (strcmp(value, "#") == 0) // Subrequest { - subRequest = inRequest.getSubrequest(param); + subRequest = inRequest.getSubrequest(param); bool subExpanded = false; Cached varName; @@ -92,8 +92,8 @@ std::string fullName = MakeUserPath((const char*)subRequest("_NAME")); if (FileCanBeOpened(fullName.c_str(), "r")) { Cached returnName = Convert(subRequest); - if (strcmp(returnName, "")) { - varName = returnName; + if (strcmp(returnName, "") != 0) { + varName = returnName; subExpanded = true; } } @@ -130,7 +130,7 @@ subRequest("_NAME") = tmpName.c_str(); Cached returnName = Convert(subRequest); - if (strcmp(returnName, "")) { + if (strcmp(returnName, "") != 0) { tmpRequest.unsetParam(param); expandedMap[param] = returnName; } @@ -156,7 +156,7 @@ count = tmpRequest.countParameters(); for (i = 0; i < count; i++) { const char* param = tmpRequest.getParameter(i); - int n = tmpRequest.countValues(param); + int n = tmpRequest.countValues(param); Cached valueList; // is there more than one value ? @@ -172,7 +172,7 @@ valueList = valueList + Cached(","); // add a new value to the list - const char* val = 0; + const char* val = nullptr; tmpRequest.getValue(val, param, j); valueList = valueList + FormatValue(val, param, macroName); } @@ -194,7 +194,7 @@ } // At last print out the fields that has been expanded - int j = 0; + int j = 0; auto ii = expandedMap.begin(); for (; ii != expandedMap.end(); ii++, j++) { Cached comma = ","; @@ -316,7 +316,7 @@ void ObjectInfo::WriteDescription(FILE* filePtr) { - require(filePtr != 0); + require(filePtr != nullptr); auto line = description_.begin(); @@ -365,18 +365,18 @@ if (ObjectList::CalledFromMacro(request) == true) { // Macro should give us the fully qualified path const char* mvPath = request("_MACRO"); - path = Cached(mdirname(mvPath)); + path = Cached(mdirname(mvPath)); } else { // Obtain the fully qualified path to the object const char* mvPath = request("_NAME"); - path = MakeUserPath(mdirname(mvPath)).c_str(); + path = MakeUserPath(mdirname(mvPath)).c_str(); } // Try to open a directory - if failed, set the path to METVIEW_USER_DIR - DIR* metDir = 0; - if ((metDir = opendir((const char*)path)) == 0) + DIR* metDir = nullptr; + if ((metDir = opendir((const char*)path)) == nullptr) path = getenv("METVIEW_USER_DIRECTORY"); else closedir(metDir); @@ -388,15 +388,15 @@ ObjectInfo::ObjectFullPath(const MvRequest& request) { std::string path; - DIR* metDir = 0; + DIR* metDir = nullptr; // In certain cases, _PATH contains file name, it shouldn't but ..... const char* mPath = (const char*)request("_PATH"); if (mPath) { // Try to open a directory - if ((metDir = opendir(mPath)) != 0) { + if ((metDir = opendir(mPath)) != nullptr) { closedir(metDir); - return std::string(mPath); + return {mPath}; } // _PATH is not a directory, maybe it contains file name. @@ -408,18 +408,18 @@ else if (ObjectList::CalledFromMacro(request) == true) { // Macro should give us the fully qualified path mPath = (const char*)request("_MACRO"); - path = (const char*)mdirname(mPath); + path = (const char*)mdirname(mPath); } else if ((const char*)request("_CWD")) path = (const char*)request("_CWD"); else { // Obtain the fully qualified path to the object mPath = (const char*)request("_NAME"); - path = MakeUserPath(mdirname(mPath)); + path = MakeUserPath(mdirname(mPath)); } // Try to open a directory - if failed, set the path to METVIEW_USER_DIR - if ((metDir = opendir(path.c_str())) == 0) + if ((metDir = opendir(path.c_str())) == nullptr) path = (const char*)getenv("METVIEW_USER_DIRECTORY"); else closedir(metDir); @@ -452,7 +452,7 @@ Cached objName; // Initialise name of the object - if (objType == 0 || !strcmp(objType, "")) + if (objType == nullptr || !strcmp(objType, "")) objName = (const char*)request.getVerb(); else objName = objType; @@ -469,7 +469,7 @@ else { // Obtain the name of the object const char* mvName = request("_NAME"); - if (mvName == 0) { + if (mvName == nullptr) { if (id == 0 && updateId) id = GenerateId(objName); @@ -580,7 +580,7 @@ Cached ObjectInfo::SpaceToUnderscore(const char* nameWithSpaces) { - int len = strlen(nameWithSpaces); + int len = strlen(nameWithSpaces); char* nameWithUnderscores = (char*)malloc(len + 1); for (int i = 0; i < len; i++) { @@ -622,13 +622,13 @@ // Visdefs in Metview 3 and Metview 4 have the same name apart from // the first character (M for Metview 4 and P for Metview 3) if (strcmp(&class1[1], &class2[1]) == 0) - return true; //different classes + return true; // different classes // Check if they are companions if (ObjectList::AreCompanions(class1, class2)) return true; -#if 0 //FAMI1110 Metview 4 does not do ISOTACHS yet +#if 0 // FAMI1110 Metview 4 does not do ISOTACHS yet //If it is PCONT, then check for Data_transformation if ( ObjectList::IsVisDefContour(class1) ) { @@ -655,7 +655,7 @@ while (req) { // Select converter - std::string iconClass = (const char*)ObjectInfo::IconClass(req); + std::string iconClass = (const char*)ObjectInfo::IconClass(req); MacroConverter& converter = MacroConverter::Find(iconClass.c_str()); // Convert an ascii file that is not a LLMATRIX @@ -710,14 +710,14 @@ ObjectInfo::FileName(const MvRequest& req) { // Build first filename guess: _PATH & _NAME - std::string name = (const char*)ObjectInfo::ObjectName(req, "", 0, false, false); - std::string path = ObjectInfo::ObjectFullPath(req); + std::string name = (const char*)ObjectInfo::ObjectName(req, "", 0, false, false); + std::string path = ObjectInfo::ObjectFullPath(req); std::string fileName = path + ((path[path.size() - 1] == '/') ? name : "/" + name); if (FileCanBeOpened(fileName.c_str(), "r")) return fileName; // Build second filename guess: METVIEW_USER_DIRECTORY & _NAME - path = (const char*)getenv("METVIEW_USER_DIRECTORY"); + path = (const char*)getenv("METVIEW_USER_DIRECTORY"); fileName = path + ((path[path.size() - 1] == '/') ? name : "/" + name); if (FileCanBeOpened(fileName.c_str(), "r")) return fileName; @@ -745,13 +745,13 @@ bool addQuotes = false; // Multiple lines - if (strstr(val, "\n") != 0) { - char* pch; + if (strstr(val, "\n") != nullptr) { + char* pch = nullptr; int len = strlen(val); if (len > 0) { char* buff = (char*)calloc(len + 1, sizeof(char)); sprintf(buff, "%s", val); - pch = strtok(buff, "\n"); + pch = strtok(buff, "\n"); sval = sval + "\"" + pch + " \""; while (pch != nullptr) { @@ -765,7 +765,7 @@ free(buff); } - return Cached(sval.c_str()); + return {sval.c_str()}; } // Single line @@ -792,7 +792,7 @@ if (addQuotes) sval += "\""; - return Cached(sval.c_str()); + return {sval.c_str()}; } int ObjectInfo::MaximumParameterNameLength(MvRequest& inRequest) diff -Nru metview-5.17.4/metview/src/uPlot/ObjectInfo.h metview-5.19.2/metview/src/uPlot/ObjectInfo.h --- metview-5.17.4/metview/src/uPlot/ObjectInfo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ObjectInfo.h 2023-07-15 08:28:47.000000000 +0000 @@ -53,8 +53,8 @@ class MvIcon; class MvRequest; -typedef std::list CachedList; -typedef std::map NamesMap; +using CachedList = std::list; +using NamesMap = std::map; class ObjectInfo { @@ -100,7 +100,7 @@ MacroConversion lastComma, Cached varName, Cached macroName, std::set skip = std::set(), - bool onlySub = false); + bool onlySub = false); // Converts a data unit to macro syntax Cached ConvertDataUnitToMacro(MvIcon& dataUnit); @@ -157,7 +157,7 @@ static std::string FileName(const MvRequest&); // Destructor - virtual ~ObjectInfo() {} + virtual ~ObjectInfo() = default; private: CachedList description_; diff -Nru metview-5.17.4/metview/src/uPlot/ObjectList.cc metview-5.19.2/metview/src/uPlot/ObjectList.cc --- metview-5.17.4/metview/src/uPlot/ObjectList.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ObjectList.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,56 +22,56 @@ static MvRequest objectList = mars.setup; // hides the global "mars.setup" /* - MvRequest reqObj = mars.setup; // hides the global "mars.setup" + MvRequest reqObj = mars.setup; // hides the global "mars.setup" - // Reads uPlot resources - std::string filename(getenv("METVIEW_DIR_SHARE")); - filename += "/etc/uPlotTable"; - MvRequest uPlotRes; - uPlotRes.read(filename.c_str()); + // Reads uPlot resources + std::string filename(getenv("METVIEW_DIR_SHARE")); + filename += "/etc/uPlotTable"; + MvRequest uPlotRes; + uPlotRes.read(filename.c_str()); #if 0 int i = 0; objectList.save("/tmp/dummy-user/data/ObjectList.txt"); objectList.rewind(); - while ( objectList ) - { - i++; - objectList.advance(); - } - COUT << "Number total resources = " << i << std::endl; + while ( objectList ) + { + i++; + objectList.advance(); + } + COUT << "Number total resources = " << i << std::endl; - i = 0; + i = 0; uPlotRes.save("/tmp/dummy-user/data/uPlotTable.txt"); - uPlotRes.rewind(); - while ( uPlotRes ) - { - i++; - uPlotRes.advance(); - } - COUT << "Number total resources = " << i << std::endl; + uPlotRes.rewind(); + while ( uPlotRes ) + { + i++; + uPlotRes.advance(); + } + COUT << "Number total resources = " << i << std::endl; i = 0; objectList.rewind(); uPlotRes.rewind(); objectList = objectList + uPlotRes; objectList.rewind(); - while ( objectList ) - { - i++; - objectList.advance(); - } - COUT << "Number total resources = " << i << std::endl; + while ( objectList ) + { + i++; + objectList.advance(); + } + COUT << "Number total resources = " << i << std::endl; objectList.rewind(); objectList.save("/tmp/dummy-user/data/ObjectList1.txt"); #else // Merge Mars setup and uPlot object list - reqObj.rewind(); - uPlotRes.rewind(); - reqObj = reqObj + uPlotRes; - static MvRequest objectList = reqObj; + reqObj.rewind(); + uPlotRes.rewind(); + reqObj = reqObj + uPlotRes; + static MvRequest objectList = reqObj; #endif */ return objectList; @@ -91,7 +91,7 @@ objectList.advance(); } - return MvRequest("EMPTY"); + return {"EMPTY"}; } // Function similar to Find, but if the request associated to this "verb" @@ -109,7 +109,7 @@ // Try to find if "sclass" is defined in the "children" parameter MvRequest& objectList = ObjectList::Instance(); objectList.rewind(); - int i; + int i = 0; while (objectList) { if (strcmp(objectList.getVerb(), name) == 0) { if ((const char*)objectList("children")) { @@ -122,7 +122,7 @@ objectList.advance(); } - return MvRequest("EMPTY"); + return {"EMPTY"}; } int ObjectList::FindAll(const Cached& name, MvRequest& list) @@ -174,7 +174,7 @@ ObjectList::Find(const Cached& name, const Cached& sclass, const Cached& param) { MvRequest oneRequest = Find(name, sclass); - Cached listValues = (const char*)oneRequest(param); + Cached listValues = (const char*)oneRequest(param); Cached oneValue; for (int i = 1; i < oneRequest.countValues(param); i++) { oneRequest.getValue(oneValue, param, i); @@ -192,17 +192,17 @@ ObjectList::FindPlusChildren(const std::string& sname, const std::string& sclass, const std::string& sparam) { // Value founded - const char* cname = sname.c_str(); + const char* cname = sname.c_str(); const char* cclass = sclass.c_str(); const char* cparam = sparam.c_str(); - const char* str = (const char*)Find(cname, cclass, cparam); + const char* str = (const char*)Find(cname, cclass, cparam); if (str) - return std::string(str); + return {str}; // Try to find if "sclass" is defined in the "children" parameter MvRequest& objectList = ObjectList::Instance(); objectList.rewind(); - int i, j; + int i = 0, j = 0; std::string sout; while (objectList) { if (strcmp(objectList.getVerb(), cname) == 0) { @@ -288,7 +288,7 @@ MvRequest ObjectList::FindReqService(const char* classe, const char* action) { - const char* cval; + const char* cval = nullptr; bool found = false; // Find all requests associate to "class" @@ -311,7 +311,7 @@ reqAll.advance(); } - return MvRequest(); + return {}; } std::string @@ -322,7 +322,7 @@ if (req) return std::string(req("service")); - return std::string(""); + return {}; } // -- METHOD : @@ -464,11 +464,11 @@ // Data contains 1-D data if (dimFlag & 1) - vstr.push_back("1D_VISDEF"); + vstr.emplace_back("1D_VISDEF"); // Data contains 2D data if (dimFlag & 2) - vstr.push_back("2D_VISDEF"); + vstr.emplace_back("2D_VISDEF"); } @@ -480,7 +480,7 @@ const char* requestFileName = Find("object", name)("default_name"); // Get the filename full path - std::string tt = MakeUserPrefPath(requestFileName); + std::string tt = MakeUserPrefPath(requestFileName); const char* filename = tt.c_str(); // Do we have a preference ? @@ -522,7 +522,7 @@ // Determine the default path for the icon // Find the file which contains the request std::string fullName = MakeUserDefPath(requestFileName); - std::string path = mdirname(fullName.c_str()); + std::string path = mdirname(fullName.c_str()); // Create a new request and read its contents // for the file in the default directory @@ -556,9 +556,9 @@ ObjectList::ExpandRequest(const MvRequest& reqst, long expandFlag) { // Expand the request against the METVIEW definition file - MvRequest objectDef = Find("object", reqst.getVerb()); + MvRequest objectDef = Find("object", reqst.getVerb()); Cached rulesFileName = objectDef("rules_file"); - Cached defFileName = objectDef("definition_file"); + Cached defFileName = objectDef("definition_file"); if (expandFlag == 0) expandFlag = objectDef("expand"); @@ -585,7 +585,7 @@ MvRequest expRequest = ObjectList::ExpandRequest(request, expandFlag); // Add hidden parameters - expRequest("_CLASS") = requestName; + expRequest("_CLASS") = requestName; expRequest("_DEFAULT") = true; // Add parameter _NAME, including the path if it is given @@ -710,10 +710,10 @@ // -- OUTPUT : true/false bool ObjectList::IsVisDefIsotachs(const MvRequest& request) { - //If it is PCONT, then check for Data_transformation + // If it is PCONT, then check for Data_transformation if (IsVisDefContour(request.getVerb())) { const char* data = (const char*)request("CONTOUR_DATA_TRANSFORMATION"); - if (!data) //no information about data_transformation + if (!data) // no information about data_transformation return false; if (strcmp(data, ISOTACHS) == 0) @@ -865,14 +865,14 @@ while (objectList) { if (objectList.getVerb() == comp) { if ((const char*)objectList("class") == param) { - pair = (const char*)objectList("friend"); - mode = (const char*)objectList("mode") ? (const char*)objectList("mode") : ""; + pair = (const char*)objectList("friend"); + mode = (const char*)objectList("mode") ? (const char*)objectList("mode") : ""; first = true; return; } else if ((const char*)objectList("friend") == param) { - pair = (const char*)objectList("class"); - mode = (const char*)objectList("mode") ? (const char*)objectList("mode") : ""; + pair = (const char*)objectList("class"); + mode = (const char*)objectList("mode") ? (const char*)objectList("mode") : ""; first = false; return; } @@ -880,8 +880,8 @@ objectList.advance(); } - pair = "no_pair"; - mode = ""; + pair = "no_pair"; + mode = ""; first = false; return; } diff -Nru metview-5.17.4/metview/src/uPlot/ObjectList.h metview-5.19.2/metview/src/uPlot/ObjectList.h --- metview-5.17.4/metview/src/uPlot/ObjectList.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ObjectList.h 2023-07-15 08:28:47.000000000 +0000 @@ -74,7 +74,7 @@ static bool CheckValidVisDef(const char*, const char*, const char*); static bool CheckValidVisDef(const char*, const char*, int = 0); - static bool CheckValidVisDefList(const char*, MvIconList&, const char* = 0); + static bool CheckValidVisDefList(const char*, MvIconList&, const char* = nullptr); static void VisDefNDimFlags(int, std::vector&); @@ -85,12 +85,12 @@ // Create a request in case there isn't one. // expandFlag = 0 means use the expand flag value from the ObjectList. - static MvRequest CreateDefaultRequest(const char*, int expandFlag = 0, const char* path = 0); + static MvRequest CreateDefaultRequest(const char*, int expandFlag = 0, const char* path = nullptr); // Check objects static bool IsDataUnit(const Cached&); static bool IsImage(const char*); - static bool IsService(const char*, const char* action = 0, bool context = false); + static bool IsService(const char*, const char* action = nullptr, bool context = false); static bool IsDefaultValue(MvRequest&, const char*); static bool IsWindow(const Cached&); static bool IsView(const Cached&); diff -Nru metview-5.17.4/metview/src/uPlot/OutputFormatAction.cc metview-5.19.2/metview/src/uPlot/OutputFormatAction.cc --- metview-5.17.4/metview/src/uPlot/OutputFormatAction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/OutputFormatAction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -42,8 +42,8 @@ // else //SCREEN newreqdev("OUTPUT_FULLNAME") = reqdev("FILE_NAME"); - reqdev = newreqdev; - req("OUTPUT_DEVICES") = newreqdev; + reqdev = newreqdev; + req("OUTPUT_DEVICES") = newreqdev; } #endif @@ -57,7 +57,7 @@ std::string name = (const char*)reqdev("OUTPUT_FULLNAME"); if (!name.empty() && name[0] != '/') // UNIX environment { - name = (string)req("_CWD") + "/" + name; // absolute path + name = (string)req("_CWD") + "/" + name; // absolute path reqdev("OUTPUT_FULLNAME") = name.c_str(); } } @@ -67,7 +67,7 @@ std::string name = (const char*)reqdev("OUTPUT_NAME"); if (!name.empty() && name[0] != '/') // UNIX environment { - name = (string)req("_CWD") + "/" + name; // absolute path + name = (string)req("_CWD") + "/" + name; // absolute path reqdev("OUTPUT_NAME") = name.c_str(); } } diff -Nru metview-5.17.4/metview/src/uPlot/OutputFormatAction.h metview-5.19.2/metview/src/uPlot/OutputFormatAction.h --- metview-5.17.4/metview/src/uPlot/OutputFormatAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/OutputFormatAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -47,9 +47,9 @@ PlotModAction(name) {} // Destructor - ~OutputFormatAction() {} + ~OutputFormatAction() override = default; // Methods // Overriden from PlotModAction - virtual void Execute(PmContext& context); + void Execute(PmContext& context) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/Page.cc metview-5.19.2/metview/src/uPlot/Page.cc --- metview-5.17.4/metview/src/uPlot/Page.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Page.cc 2023-07-15 08:28:47.000000000 +0000 @@ -52,9 +52,9 @@ } else { // Initialize the bounding box in geodetic coordinates - double lat1 = viewRequest("AREA", 0); + double lat1 = viewRequest("AREA", 0); double long1 = viewRequest("AREA", 1); - double lat2 = viewRequest("AREA", 2); + double lat2 = viewRequest("AREA", 2); double long2 = viewRequest("AREA", 3); area = Location(lat2, long1, lat1, long2); @@ -65,7 +65,7 @@ viewRequest("AREA") += area.Top(); viewRequest("AREA") += area.Right(); - double vertLong = proj.get()->CheckOriginLongitude(); + double vertLong = proj.get()->CheckOriginLongitude(); viewRequest("MAP_VERTICAL_LONGITUDE") = vertLong; } // Flag to indicate that this is a default area. This will be used by the zoom scheme @@ -73,15 +73,15 @@ viewRequest("_DEFAULT_AREA") = "YES"; } - myRequest_("VIEW") = viewRequest; + myRequest_("VIEW") = viewRequest; pageRequest("VIEW") = viewRequest; } // Create a new view request if there isn't any if (!viewClass || ObjectList::IsView(viewClass) == false) { - viewRequest = ObjectList::CreateDefaultRequest(DEFAULTVIEW.c_str(), EXPAND_NO_DEFAULT); + viewRequest = ObjectList::CreateDefaultRequest(DEFAULTVIEW.c_str(), EXPAND_NO_DEFAULT); pageRequest("VIEW") = viewRequest; - myRequest_("VIEW") = viewRequest; + myRequest_("VIEW") = viewRequest; } // Create a view associated to the page @@ -187,10 +187,10 @@ bool Page::InsertDataUnit(int dataUnitId, long offset, long offset2, MatchingInfo& dataInfo, int& subPageId) { - require(myView_.get() != 0); + require(myView_.get() != nullptr); // Initialise variables - SubPage* subpage = 0; // pointer to subpage + SubPage* subpage = nullptr; // pointer to subpage // Start at the beginning of the list MvChildIterator child; @@ -324,7 +324,7 @@ if (found) { // Remove all drawings related to the DataUnit, // but not the DataUnit itself - removeData_ = false; + removeData_ = false; MvIcon dataUnit = du; this->RemoveIcon(dataUnit); removeData_ = true; @@ -367,7 +367,7 @@ { // Remove drawings MvRequest req = icon.Request(); - Cached verb = req.getVerb(); + Cached verb = req.getVerb(); if (ObjectList::IsVisDef(verb) || ObjectList::IsDataUnit(verb) || ObjectList::IsVisDefText(verb)) { @@ -382,8 +382,8 @@ // Remove PText annotation if (ObjectList::IsVisDefText(verb)) { - //U if ( verb == ANNOTATION ) - //U this->EraseForeDraw (); + // U if ( verb == ANNOTATION ) + // U this->EraseForeDraw (); } myView_->Reset(req); @@ -423,12 +423,12 @@ r("_CONTEXT") = myView_->ViewRequest(); - r("_CLASS") = "WMSCLIENT"; - r("_ACTION") = "update"; - r("_SERVICE") = "WmsClient"; + r("_CLASS") = "WMSCLIENT"; + r("_ACTION") = "update"; + r("_SERVICE") = "WmsClient"; r("_USELOGWINDOW") = "1"; - int error; + int error = 0; MvRequest result = MvApplication::waitService("wmsclient", r, error); if (result && error == 0) { @@ -446,12 +446,12 @@ { // Retrieve zoom stack structure ZoomStacks* stacks = this->GetZoomStacks(); - if (stacks == 0) + if (stacks == nullptr) return; std::string zoomInfo; - //If zoom level is 0 then send the original message to Magics + // If zoom level is 0 then send the original message to Magics if (izoom == 0) { // Set zoom stack index to 0 stacks->Current(izoom); @@ -466,7 +466,7 @@ (*myView_).ViewRequest()("_ZOOM_DEFINITION") = zoomInfo.c_str(); } - //Update some dataUnits for the new area + // Update some dataUnits for the new area this->UpdateDataForZoom(zoomInfo); } @@ -478,7 +478,7 @@ // Retrieve zoom stack structure ZoomStacks* stacks = this->GetZoomStacks(); - if (stacks == 0) + if (stacks == nullptr) return; // Save new coordinates @@ -502,12 +502,12 @@ // Retrieve stack ZoomStacks* stacks = this->GetZoomStacks(); - if (stacks == 0) + if (stacks == nullptr) return; // Get values zoomNumberOfLevels = stacks->Size(); - zoomCurrentLevel = stacks->Current(); + zoomCurrentLevel = stacks->Current(); } void Page::DescribeYourself(ObjectInfo& description) @@ -531,7 +531,7 @@ description.ConvertRequestToMacro(myRequest, PUT_LAST_COMMA, MacroName().c_str(), "plot_page", skipSet); // Include the view information - int size = description.MaximumParameterNameLength(myRequest); + int size = description.MaximumParameterNameLength(myRequest); std::string viewName = myView_->MacroName(); description.FormatLine("VIEW", viewName.c_str(), "", size); @@ -550,7 +550,7 @@ subpageRequest = ObjectList::ExpandRequest(subpageRequest, EXPAND_DEFAULTS); Presentable* subpage = new SubPage(subpageRequest); - ensure(subpage != 0); + ensure(subpage != nullptr); // Insert the subpage in the superpage's child list this->Insert(subpage); @@ -558,9 +558,9 @@ } else { while (sub) { - MvRequest r = sub.justOneRequest(); + MvRequest r = sub.justOneRequest(); Presentable* subpage = new SubPage(r); - ensure(subpage != 0); + ensure(subpage != nullptr); this->Insert(subpage); sub.advance(); visibleCount_++; @@ -582,13 +582,13 @@ revertedChildList.reverse(); // Get Last and previous to last in child list - auto j = revertedChildList.begin(); - Presentable* lastSubPage = *j; + auto j = revertedChildList.begin(); + Presentable* lastSubPage = *j; Presentable* previousSubPage = *(++j); // Save DeviceData and Canvas of the last SubPage that owns a canvas - DeviceData* savedDevDat = 0; - Canvas* savedCanvas = 0; + DeviceData* savedDevDat = nullptr; + Canvas* savedCanvas = nullptr; if (((signed int)childList_.size() == visibleCount_) && (lastSubPage != subpage)) { savedCanvas = &(lastSubPage->GetCanvas()); @@ -613,7 +613,7 @@ // If previous SubPage owns the canvas // Save and disconnect device data - DeviceData* deviceData = 0; + DeviceData* deviceData = nullptr; if (previousSubPage->GetDeviceData()) deviceData = previousSubPage->ReleaseDeviceData(); @@ -640,7 +640,7 @@ } // Get next set of SubPages - lastSubPage = previousSubPage; + lastSubPage = previousSubPage; previousSubPage = *(++j); } @@ -653,7 +653,7 @@ void Page::RemovePageFromDataBase() { // Verify if my Parent is still alive - if (myParent_ == 0) + if (myParent_ == nullptr) return; // Retrieve the Icon Data Base @@ -686,7 +686,7 @@ int nrVisible = visibleCount_; MvChildIterator child; - int i; + int i = 0; for (child = childList_.begin(), i = 1; child != childList_.end(); ++child, i++) { @@ -694,7 +694,7 @@ break; } - int paperPageNumber; + int paperPageNumber = 0; if (myParent_->PrintAll()) { paperPageNumber = ((i - 1) / nrVisible) + myParent_->PageIndex(); } @@ -713,7 +713,7 @@ Canvas* Page::GetNextCanvas(MvRequest& subpageReq) { - Canvas* canvas = 0; + Canvas* canvas = nullptr; MvChildIterator child; for (child = childList_.begin(); child != childList_.end(); ++child) { if (!(*child)->HasData()) @@ -729,7 +729,7 @@ for (int i = 0; i < index; i++) child++; } - canvas = &((*child)->GetCanvas()); + canvas = &((*child)->GetCanvas()); subpageReq = (*child)->Request(); return canvas; @@ -751,7 +751,7 @@ bool found = false; MvChildIterator child; for (child = childList_.begin(); child != childList_.end(); ++child) { - auto* subpage = (SubPage*)(*child); + auto* subpage = dynamic_cast(*child); if (subpage->CheckValidVisDefWithIcl(dataUnit, vdRequest, dataUnitList, iflag)) found = true; } @@ -793,7 +793,7 @@ // Update internal Request MvRequest presReq = Request(); - presReq("VIEW") = reqView; + presReq("VIEW") = reqView; SetRequest(presReq); // Update View resquest at myview structure diff -Nru metview-5.17.4/metview/src/uPlot/Page.h metview-5.19.2/metview/src/uPlot/Page.h --- metview-5.17.4/metview/src/uPlot/Page.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Page.h 2023-07-15 08:28:47.000000000 +0000 @@ -59,7 +59,7 @@ Presentable* Clone() const override { return new Page(*this); } // Destructor - ~Page(); + ~Page() override; // Methods // Overriden from Presentable class @@ -67,7 +67,7 @@ // Return my name std::string Name() override; - bool IsVisible() override {return true;} + bool IsVisible() override { return true; } // Draw me and all my children void Draw() override; @@ -110,7 +110,7 @@ #endif // Zoom request given a new location to be added to the stack - //virtual void ZoomRequest ( const Location& zoomCoord ); + // virtual void ZoomRequest ( const Location& zoomCoord ); // Zoom request given an index from the stack void ZoomRequest(int izoom); @@ -122,7 +122,7 @@ void ZoomInfo(int& zoomNumberOfLevels, int& zoomCurrentLevel) override; // Replace the geographical area and plot the result - //virtual void ReplaceArea ( const Location& zoomCoord, int zoom=-1 ); + // virtual void ReplaceArea ( const Location& zoomCoord, int zoom=-1 ); // Generate a description of the page void DescribeYourself(ObjectInfo&) override; @@ -141,16 +141,28 @@ // Update Page's size #endif - void SetContentsDataUnit(int dataUnitId) override { dataUnitId_ = dataUnitId;} - int ContentsDataUnit() const override { return dataUnitId_; } + void SetContentsDataUnit(int dataUnitId) override + { + dataUnitId_ = dataUnitId; + } + int ContentsDataUnit() const override + { + return dataUnitId_; + } - virtual std::string MacroPlotIndexName(bool = true) override + std::string MacroPlotIndexName(bool = true) override { return myParent_->MacroPlotIndexName(true); } - void SetDropShouldStay(bool drop) override { dropShouldStay_ = drop; } - bool DropShouldStay() const override { return dropShouldStay_; } + void SetDropShouldStay(bool drop) override + { + dropShouldStay_ = drop; + } + bool DropShouldStay() const override + { + return dropShouldStay_; + } // Local methods // Insert a new data unit (used in response to a drop action) @@ -206,7 +218,10 @@ #endif // Return number of visible subpages - int NumberOfVisible() { return visibleCount_; } + int NumberOfVisible() + { + return visibleCount_; + } // Location GetDrawingArea () // { return drawingArea_; } @@ -214,8 +229,8 @@ // void SetDrawingArea ( Location drawingArea ) // { drawingArea_ = drawingArea; } - //U void EraseBackDraw (); - //U void EraseForeDraw (); + // U void EraseBackDraw (); + // U void EraseForeDraw (); // Set/Get the projection associated to the canvas void SetProjection(const MvRequest& viewRequest) override; @@ -301,7 +316,7 @@ virtual void UpdateView(const MvRequest&); protected: - //Update certain data units for the new area + // Update certain data units for the new area virtual void UpdateDataForZoom(const std::string& zoomInfo); private: diff -Nru metview-5.17.4/metview/src/uPlot/PaperSize.h metview-5.19.2/metview/src/uPlot/PaperSize.h --- metview-5.17.4/metview/src/uPlot/PaperSize.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PaperSize.h 2023-07-15 08:28:47.000000000 +0000 @@ -50,7 +50,7 @@ height_(height) {} // Destructor - ~PaperSize() {} + ~PaperSize() = default; double GetWidth() const { diff -Nru metview-5.17.4/metview/src/uPlot/PlotAction.cc metview-5.19.2/metview/src/uPlot/PlotAction.cc --- metview-5.17.4/metview/src/uPlot/PlotAction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotAction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -8,7 +8,7 @@ ***************************** LICENSE END *************************************/ // -//PlotAction class +// PlotAction class // #include "PlotAction.h" @@ -21,7 +21,7 @@ // The request constains all the information to be sent to Magics // Just needs to add the output devices MvRequest fullReq = PlotMod::Instance().OutputFormat()("OUTPUT_DEVICES"); - fullReq = fullReq + context.InRequest(); + fullReq = fullReq + context.InRequest(); // Call MAGICS to process the request MagPlusService::Instance().SetRequest(fullReq); @@ -43,7 +43,7 @@ system(rm.str().c_str()); } else if (strcmp((const char*)info("DESTINATION"), MVPREVIEW) == 0) { - //add code later + // add code later } // Advance to the end the input context diff -Nru metview-5.17.4/metview/src/uPlot/PlotAction.h metview-5.19.2/metview/src/uPlot/PlotAction.h --- metview-5.17.4/metview/src/uPlot/PlotAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -47,9 +47,9 @@ PlotModAction(name) {} // Destructor - ~PlotAction() {} + ~PlotAction() override = default; // Methods // Overriden from PlotModAction - virtual void Execute(PmContext& context); + void Execute(PmContext& context) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/PlotModAction.h metview-5.19.2/metview/src/uPlot/PlotModAction.h --- metview-5.17.4/metview/src/uPlot/PlotModAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -54,7 +54,7 @@ struct ActionTraits { - typedef PlotModAction Type; + using Type = PlotModAction; static Type& DefaultObject(); }; @@ -66,17 +66,17 @@ Prototype(actionName, this) {} // Destructor - virtual ~PlotModAction() {} + ~PlotModAction() override = default; // Methods virtual void Execute(PmContext&) = 0; private: // No copy allowed - PlotModAction(const PlotModAction&); + PlotModAction(const PlotModAction&) = delete; PlotModAction& operator=(const PlotModAction&) { return *this; } // Friends - //friend std::ostream& operator<<(std::ostream& ostr, const PlotModAction& act) + // friend std::ostream& operator<<(std::ostream& ostr, const PlotModAction& act) // { act.print(ostr); return ostr; } }; diff -Nru metview-5.17.4/metview/src/uPlot/PlotModBatch.cc metview-5.19.2/metview/src/uPlot/PlotModBatch.cc --- metview-5.17.4/metview/src/uPlot/PlotModBatch.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModBatch.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,8 +13,8 @@ PlotModBatch::PlotModBatch() { - isInteractive_ = false; - isWindow_ = false; + isInteractive_ = false; + isWindow_ = false; plotDestination_ = MVFILE; - printerName_ = ""; + printerName_ = ""; } diff -Nru metview-5.17.4/metview/src/uPlot/PlotModBuilder.cc metview-5.19.2/metview/src/uPlot/PlotModBuilder.cc --- metview-5.17.4/metview/src/uPlot/PlotModBuilder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModBuilder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -37,14 +37,14 @@ viewName = ObjectList::Find("request", verb, "view"); if ((const char*)viewName) { - int slen = (const char*)viewName ? strlen(viewName) : 0; + int slen = (const char*)viewName ? strlen(viewName) : 0; char* upName = new char[slen + 1]; for (int i = 0; i < slen; i++) upName[i] = toupper(viewName[i]); upName[slen] = 0; - viewName = upName; + viewName = upName; delete[] upName; } diff -Nru metview-5.17.4/metview/src/uPlot/PlotModBuilder.h metview-5.19.2/metview/src/uPlot/PlotModBuilder.h --- metview-5.17.4/metview/src/uPlot/PlotModBuilder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModBuilder.h 2023-07-15 08:28:47.000000000 +0000 @@ -64,7 +64,7 @@ struct BuilderTraits { - typedef PlotModBuilder Type; + using Type = PlotModBuilder; static Type& DefaultObject(); }; @@ -76,13 +76,13 @@ Prototype(builderName, this) {} // Destructor - virtual ~PlotModBuilder() {} + ~PlotModBuilder() override = default; // Methods virtual Presentable* Execute(PmContext&) = 0; virtual Cached GetView(PmContext&); // Friends - //friend std::ostream& operator<<(std::ostream& ostr, const PlotModBuilder& bld) + // friend std::ostream& operator<<(std::ostream& ostr, const PlotModBuilder& bld) //{ return ostr << bld.Name(); } }; diff -Nru metview-5.17.4/metview/src/uPlot/PlotMod.cc metview-5.19.2/metview/src/uPlot/PlotMod.cc --- metview-5.17.4/metview/src/uPlot/PlotMod.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotMod.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ #include "MvLog.h" #include "MvMiscellaneous.h" -#include +#include PlotMod* PlotMod::plotModInstance_ = nullptr; @@ -48,7 +48,7 @@ // Only updates the plot environment if the request // comes from Macro. Otherwise, keeps the current status. if (calledFromMacro) { - calledFromMacro_ = calledFromMacro; + calledFromMacro_ = calledFromMacro; calledFirstFromMacro_ = calledFromMacro; } @@ -82,7 +82,7 @@ MvRequest req("PRINTER_MANAGER"); MvRequest gldriverReq(MVSCREEN_DRIVER); gldriverReq("DESTINATION") = MVSCREEN; - req("OUTPUT_DEVICES") = gldriverReq; + req("OUTPUT_DEVICES") = gldriverReq; return req; } @@ -91,17 +91,17 @@ PlotMod::OutputFormatInfo() { MvRequest info("OUTPUTINFO"); - info("DESTINATION") = plotDestination_.c_str(); - info("PRINTER_NAME") = printerName_.c_str(); + info("DESTINATION") = plotDestination_.c_str(); + info("PRINTER_NAME") = printerName_.c_str(); info("NUMBER_COPIES") = (int)outFormat_("NUMBER_COPIES"); - MvRequest subReq = outFormat_.getSubrequest("OUTPUT_DEVICES"); + MvRequest subReq = outFormat_.getSubrequest("OUTPUT_DEVICES"); if (subReq) { if ((const char*)subReq("OUTPUT_NAME")) info("FILE_NAME") = subReq("OUTPUT_NAME"); else if ((const char*)subReq("OUTPUT_FULLNAME")) info("FILE_NAME") = subReq("OUTPUT_FULLNAME"); else - info("FILE_NAME") = "defaultFilename"; //default filename + info("FILE_NAME") = "defaultFilename"; // default filename } return info; @@ -173,7 +173,7 @@ #endif // Timming functions -//Starts and names the session +// Starts and names the session void PlotMod::watchStart(const char* txt) { if (watch_) { diff -Nru metview-5.17.4/metview/src/uPlot/PlotModConst.h metview-5.19.2/metview/src/uPlot/PlotModConst.h --- metview-5.17.4/metview/src/uPlot/PlotModConst.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModConst.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,59 +28,59 @@ const short MAX_LEGENDS_PACKAGE = 5; // Data Requests -static std::string GRIB = "GRIB"; +static std::string GRIB = "GRIB"; static std::string NETCDF = "NETCDF"; -static std::string BUFR = "BUFR"; +static std::string BUFR = "BUFR"; // Page visualization Definitions -static Cached MCOAST = "MCOAST"; -static Cached PCOAST = "PCOAST"; -static std::string MTEXT = "MTEXT"; -static std::string PTEXT = "PTEXT"; -static std::string MLEGEND = "MLEGEND"; -static Cached MAXIS = "MAXIS"; -static Cached PAXIS = "PAXIS"; -static Cached ANNOTATION = "ANNOTATION"; -static std::string MIMPORT = "MIMPORT"; -static std::string GEOLAYERS = "GEOLAYERS"; +static Cached MCOAST = "MCOAST"; +static Cached PCOAST = "PCOAST"; +static std::string MTEXT = "MTEXT"; +static std::string PTEXT = "PTEXT"; +static std::string MLEGEND = "MLEGEND"; +static Cached MAXIS = "MAXIS"; +static Cached PAXIS = "PAXIS"; +static Cached ANNOTATION = "ANNOTATION"; +static std::string MIMPORT = "MIMPORT"; +static std::string GEOLAYERS = "GEOLAYERS"; static std::string MTHERMOGRID = "MTHERMOGRID"; static std::string MTAYLORGRID = "MTAYLOR"; // Data Visualization Definitions -static Cached MCONT = "MCONT"; -static Cached PCONT = "PCONT"; -static Cached MGRAPH = "MGRAPH"; -static Cached PGRAPH = "PGRAPH"; -static Cached MWIND = "MWIND"; -static Cached PWIND = "PWIND"; -static Cached MSYMB = "MSYMB"; -static Cached PSYMB = "PSYMB"; -static Cached PTACH = "PTACH"; -static Cached ISOTACHS = "ISOTACHS"; +static Cached MCONT = "MCONT"; +static Cached PCONT = "PCONT"; +static Cached MGRAPH = "MGRAPH"; +static Cached PGRAPH = "PGRAPH"; +static Cached MWIND = "MWIND"; +static Cached PWIND = "PWIND"; +static Cached MSYMB = "MSYMB"; +static Cached PSYMB = "PSYMB"; +static Cached PTACH = "PTACH"; +static Cached ISOTACHS = "ISOTACHS"; static std::string MTHERMO = "MTHERMO"; // Command Definitions -static Cached DEVICEDRIVER = "DEVICE_DRIVER"; +static Cached DEVICEDRIVER = "DEVICE_DRIVER"; static std::string PLOTSUPERPAGE = "PLOT_SUPERPAGE"; -static Cached PLOTPAGE = "PLOT_PAGE"; -static Cached PAGES = "PAGES"; -static std::string NEWPAGE = "NEWPAGE"; +static Cached PLOTPAGE = "PLOT_PAGE"; +static Cached PAGES = "PAGES"; +static std::string NEWPAGE = "NEWPAGE"; // Others static Cached ON = "ON"; // Views -static const std::string MAPVIEW = "MAPVIEW"; -static const std::string GEOVIEW = "GEOVIEW"; +static const std::string MAPVIEW = "MAPVIEW"; +static const std::string GEOVIEW = "GEOVIEW"; static const std::string CARTESIANVIEW = "CARTESIANVIEW"; -static const std::string DEFAULTVIEW = "GEOVIEW"; -static const std::string THERMOVIEW = "THERMOVIEW"; +static const std::string DEFAULTVIEW = "GEOVIEW"; +static const std::string THERMOVIEW = "THERMOVIEW"; // Output devices -static const char* const MVPRINTER = "PRINTER"; -static const char* const MVSCREEN = "SCREEN"; -static const char* const MVPREVIEW = "PREVIEW"; -static const char* const MVFILE = "FILE"; +static const char* const MVPRINTER = "PRINTER"; +static const char* const MVSCREEN = "SCREEN"; +static const char* const MVPREVIEW = "PREVIEW"; +static const char* const MVFILE = "FILE"; static const char* const MVSCREEN_DRIVER = "QTOUTPUT"; // Weather features/symbols diff -Nru metview-5.17.4/metview/src/uPlot/PlotMod.h metview-5.19.2/metview/src/uPlot/PlotMod.h --- metview-5.17.4/metview/src/uPlot/PlotMod.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotMod.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,14 +23,14 @@ static void Instance(PlotMod*); PlotMod(); - virtual ~PlotMod() = default; + ~PlotMod() override = default; // Returns running mode: true: interactive, false: batch bool IsInteractive() { return isInteractive_; } // Window mode functions - bool IsWindow(const char*); //Check a given driver - bool IsWindow() const { return isWindow_; } //Inquire current status + bool IsWindow(const char*); // Check a given driver + bool IsWindow() const { return isWindow_; } // Inquire current status // Check/initialize request came from a Macro void CalledFromMacro(bool flag) { calledFromMacro_ = flag; } @@ -55,7 +55,7 @@ bool isMagicsErrorIgnored() const { return magicsErrorIgnored_; } bool setMagicsErrorIgnored(bool b) { - auto prev = magicsErrorIgnored_; + auto prev = magicsErrorIgnored_; magicsErrorIgnored_ = b; return prev; } diff -Nru metview-5.17.4/metview/src/uPlot/PlotModInteractive.cc metview-5.19.2/metview/src/uPlot/PlotModInteractive.cc --- metview-5.17.4/metview/src/uPlot/PlotModInteractive.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModInteractive.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,10 @@ PlotModInteractive::PlotModInteractive() { - isInteractive_ = true; - isWindow_ = true; + isInteractive_ = true; + isWindow_ = true; plotDestination_ = MVSCREEN; - printerName_ = ""; + printerName_ = ""; } void PlotModInteractive::addWeatherSymbol(const MvRequest& r) diff -Nru metview-5.17.4/metview/src/uPlot/PlotModService.cc metview-5.19.2/metview/src/uPlot/PlotModService.cc --- metview-5.17.4/metview/src/uPlot/PlotModService.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModService.cc 2023-07-15 08:28:47.000000000 +0000 @@ -39,7 +39,7 @@ void PlotModService::endOfTask(MvTask* task) { MvServiceTask* serviceTask = (PlotModTask*)task; - MvRequest replyRequest = serviceTask->getReply(); + MvRequest replyRequest = serviceTask->getReply(); if (serviceTask->getError() == 0) { // Get the parent data unit id. @@ -51,10 +51,10 @@ view_->InsertDataRequest(replyRequest); // Register drawing task - int pageId = view_->Owner().Id(); + int pageId = view_->Owner().Id(); Presentable* pageNode = Root::Instance().FindBranch(pageId); pageNode->HasDrawTask(true); - pageNode->DrawTask(); //Draw + pageNode->DrawTask(); // Draw } else { MvLog().popup().warn() << "Error from " << serviceName_; diff -Nru metview-5.17.4/metview/src/uPlot/PlotModService.h metview-5.19.2/metview/src/uPlot/PlotModService.h --- metview-5.17.4/metview/src/uPlot/PlotModService.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModService.h 2023-07-15 08:28:47.000000000 +0000 @@ -55,20 +55,20 @@ PlotModService(const PlotModService&); // -- Destructor - ~PlotModService(); + ~PlotModService() override; void ServiceName(const char* name) { serviceName_ = name; } - virtual void progress(const char* msg) + void progress(const char* msg) override { msg_.append(msg); } // Perform actions after receiving response from service - virtual void endOfTask(MvTask*); + void endOfTask(MvTask*) override; protected: std::string serviceName_; diff -Nru metview-5.17.4/metview/src/uPlot/PlotModTask.h metview-5.19.2/metview/src/uPlot/PlotModTask.h --- metview-5.17.4/metview/src/uPlot/PlotModTask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModTask.h 2023-07-15 08:28:47.000000000 +0000 @@ -46,7 +46,7 @@ const MvRequest& outRequest); // -- Destructor - ~PlotModTask(); // Change to virtual if base class + ~PlotModTask() override; // Change to virtual if base class // -- Convertors // None diff -Nru metview-5.17.4/metview/src/uPlot/PlotModView.cc metview-5.19.2/metview/src/uPlot/PlotModView.cc --- metview-5.17.4/metview/src/uPlot/PlotModView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,12 +24,12 @@ #include "MvLog.h" // Initialization of factory map -PlotModViewFactory::FactoryMap* PlotModViewFactory::factoryMap_ = 0; +PlotModViewFactory::FactoryMap* PlotModViewFactory::factoryMap_ = nullptr; PlotModViewFactory::PlotModViewFactory(const Cached& factoryName) : name_(factoryName) { - if (factoryMap_ == 0) + if (factoryMap_ == nullptr) factoryMap_ = new PlotModViewFactory::FactoryMap(); (*factoryMap_)[name_] = this; @@ -48,7 +48,7 @@ // name of the factory to be called and // which contains the name of the service to be called (e.g. CrossSection) MvRequest setupRequest = ObjectList::Find("view", viewClass); - Cached factoryName = setupRequest("name"); + Cached factoryName = setupRequest("name"); // Call the virtual constructor associated with the factory name auto i = factoryMap_->find(factoryName); @@ -102,15 +102,15 @@ UpdateView(); // Retrieve sizes e location information - Presentable* sp = Owner().FindSuperPage(); - PaperSize spSize = sp->GetMySize(); //SuperPage size - Rectangle myLoc = Owner().GetLocation(); //Page location - PaperSize mySize = Owner().GetMySize(); //Page size + Presentable* sp = Owner().FindSuperPage(); + PaperSize spSize = sp->GetMySize(); // SuperPage size + Rectangle myLoc = Owner().GetLocation(); // Page location + PaperSize mySize = Owner().GetMySize(); // Page size // Metview origin coordinates is top left corner // Magics origin coordinates is lower left corner - viewRequest_("_WIDTH") = mySize.GetWidth(); - viewRequest_("_HEIGHT") = mySize.GetHeight(); + viewRequest_("_WIDTH") = mySize.GetWidth(); + viewRequest_("_HEIGHT") = mySize.GetHeight(); viewRequest_("_X_ORIGIN") = spSize.GetWidth() * myLoc.left; viewRequest_("_Y_ORIGIN") = spSize.GetHeight() - (spSize.GetHeight() * myLoc.bottom); @@ -118,7 +118,7 @@ ge.DrawNewPage(viewRequest_); } -#if 0 //D +#if 0 // D void PlotModView::DrawFrame ( Canvas& canvas ) { @@ -160,9 +160,9 @@ MvIcon dataUnit; for (j = drawPriorMap.begin(); j != drawPriorMap.end(); ++j) { // Get DataObject node - int currentDO = ((*j).second).first; // Get DataObject ID + int currentDO = ((*j).second).first; // Get DataObject ID Presentable* treeNode = Root::Instance().FindBranch(currentDO); - if (treeNode == 0) { + if (treeNode == nullptr) { MvLog().popup().err() << "PlotModView::CommonDraw -> treeNode == 0"; return; } @@ -217,13 +217,13 @@ MvIconList duList; // Get all data units and resend them to plotmod. - //dataBase.DataUnitListByPresentableId(Owner().Id(), duList); + // dataBase.DataUnitListByPresentableId(Owner().Id(), duList); dataBase.RetrieveIcon(PRES_DATAUNIT_REL, Owner().Id(), duList); MvListCursor ii; for (ii = duList.begin(); ii != duList.end(); ii++) { MvIcon currentIcon = *ii; - MvRequest req = currentIcon.Request(); + MvRequest req = currentIcon.Request(); MvRequest dropRequest("DROP"); dropRequest("DROP_ID") = Owner().Id(); @@ -237,8 +237,8 @@ // No need to create a new link. Use the current one, provides // that it will not be deleted when cleaning the old data req("_CREATE_LINK") = Cached("NO"); - dropRequest = dropRequest + req; - MvApplication::callService("uPlot", dropRequest, 0); + dropRequest = dropRequest + req; + MvApplication::callService("uPlot", dropRequest, nullptr); } // Clean out data @@ -247,8 +247,8 @@ Owner().InitMatching(); // Erase drawings - //U Owner().EraseBackDraw(); - //U Owner().EraseForeDraw(); + // U Owner().EraseBackDraw(); + // U Owner().EraseForeDraw(); // Owner().EraseDraw(); // Redraw this page @@ -266,27 +266,27 @@ MvListCursor ii; MvRequest defaultReq = ObjectList::CreateDefaultRequest(verb); - int count = compare.countParameters(); + int count = compare.countParameters(); for (ii = tmpList.begin(); ii != tmpList.end(); ii++) { - bool match = true; - MvIcon currentvd = *ii; + bool match = true; + MvIcon currentvd = *ii; MvRequest currentreq = currentvd.Request(); int defaultvd = currentreq("_DEFAULT"); if (defaultvd) { - //currentvd.SaveRequest(compare); + // currentvd.SaveRequest(compare); usingDefault = true; - match = true; + match = true; } else { // Check that all values in compare request are either the same as in currentReq, or if // currentReq value not set, that it is the default for (int i = 0; i < count; i++) { - const char* param = compare.getParameter(i); + const char* param = compare.getParameter(i); const char* testValue = compare(param); - const char* value = currentreq(param); - const char* defValue = defaultReq(param); + const char* value = currentreq(param); + const char* defValue = defaultReq(param); compare.getValue(testValue, param, 0); currentreq.getValue(value, param, 0); @@ -306,7 +306,7 @@ void PlotModView::Owner(Page& xx) { - owner_ = &xx; + owner_ = &xx; pageId_ = xx.Id(); } @@ -359,7 +359,7 @@ } MvRequest request = dropRequest.justOneRequest(); - Cached verb = request.getVerb(); + Cached verb = request.getVerb(); // Update view (if applicable) if (ObjectList::IsView(verb)) diff -Nru metview-5.17.4/metview/src/uPlot/PlotModView.h metview-5.19.2/metview/src/uPlot/PlotModView.h --- metview-5.17.4/metview/src/uPlot/PlotModView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotModView.h 2023-07-15 08:28:47.000000000 +0000 @@ -65,7 +65,7 @@ class PlotModViewFactory { protected: - typedef std::map > FactoryMap; + using FactoryMap = std::map>; static FactoryMap* factoryMap_; Cached name_; @@ -79,7 +79,7 @@ static PlotModView* Make(Page&, MvRequest& viewRequest); // Keep compiler happy - virtual ~PlotModViewFactory() {} + virtual ~PlotModViewFactory() = default; }; class PlotModView @@ -137,7 +137,7 @@ virtual bool UpdateView() { return true; } // Replace the current geographical area - //virtual void ReplaceArea ( const Location&, int /* izoom=-1 */ ) {} + // virtual void ReplaceArea ( const Location&, int /* izoom=-1 */ ) {} // Sets up the drawing area virtual void DrawNewPage(); @@ -167,7 +167,7 @@ void ParentDataUnitId(int parentDataUnitId) { viewRequest_("_PARENT_DATAUNIT_ID") = parentDataUnitId; - parentDataUnitId_ = parentDataUnitId; + parentDataUnitId_ = parentDataUnitId; } int ParentDataUnitId() { return parentDataUnitId_; } diff -Nru metview-5.17.4/metview/src/uPlot/PlotPageBuilder.cc metview-5.19.2/metview/src/uPlot/PlotPageBuilder.cc --- metview-5.17.4/metview/src/uPlot/PlotPageBuilder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotPageBuilder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,7 +41,7 @@ // Check if request is a PLOTSUPERPAGE MvRequest contextReq = context.InRequest(); - const char* verb = contextReq.getVerb(); + const char* verb = contextReq.getVerb(); Presentable* superpage = nullptr; MvRequest defaultSuperPage; @@ -75,7 +75,7 @@ { // Check internal parameter _NAME . It may be used later (e.g. automatic macro generation) const char* fullName = (const char*)contextReq("_NAME"); - const char* path = nullptr; + const char* path = nullptr; if (fullName) path = mdirname(fullName); @@ -87,8 +87,8 @@ else if (ObjectList::IsView(verb)) // View { // Create default page and add view to this request. - MvRequest pageRequest = ObjectList::CreateDefaultRequest("PLOT_PAGE"); - pageRequest("VIEW") = contextReq.justOneRequest(); + MvRequest pageRequest = ObjectList::CreateDefaultRequest("PLOT_PAGE"); + pageRequest("VIEW") = contextReq.justOneRequest(); defaultSuperPage("PAGES") = pageRequest; } @@ -100,11 +100,11 @@ Cached viewName = GetView(context); if ((const char*)viewName) { MvRequest viewRequest = ObjectList::CreateDefaultRequest(viewName); - pageRequest("VIEW") = viewRequest; + pageRequest("VIEW") = viewRequest; } defaultSuperPage("PAGES") = pageRequest; - skipReq = false; + skipReq = false; } else skipReq = false; diff -Nru metview-5.17.4/metview/src/uPlot/PlotPageBuilder.h metview-5.19.2/metview/src/uPlot/PlotPageBuilder.h --- metview-5.17.4/metview/src/uPlot/PlotPageBuilder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PlotPageBuilder.h 2023-07-15 08:28:47.000000000 +0000 @@ -43,7 +43,7 @@ PlotModBuilder(name) {} // Destructor - ~PlotPageBuilder() {} + ~PlotPageBuilder() override = default; // Methods static PlotPageBuilder& Instance(); @@ -51,7 +51,7 @@ // Overriden from PlotModBuilder class // Builds the superpage and its children // Return a pointer to the node which has been created - virtual Presentable* Execute(PmContext&); + Presentable* Execute(PmContext&) override; private: // No copy allowed diff -Nru metview-5.17.4/metview/src/uPlot/PmContext.cc metview-5.19.2/metview/src/uPlot/PmContext.cc --- metview-5.17.4/metview/src/uPlot/PmContext.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PmContext.cc 2023-07-15 08:28:47.000000000 +0000 @@ -84,13 +84,13 @@ DropX((double)inRequest_("DROP_X")); DropY((double)inRequest_("DROP_Y")); - //PlotMod::Instance().watchStart("PmContext"); + // PlotMod::Instance().watchStart("PmContext"); while (inRequest_) { // Enquire the Action name // There is an action type associated to each // incoming request, as defined by the PlotModTable const char* actionName = ObjectList::Find("request", inRequest_.getVerb(), "action"); - PlotModAction& action = PlotModAction::Find(actionName); + PlotModAction& action = PlotModAction::Find(actionName); // Each action advances the request action.Execute(*this); diff -Nru metview-5.17.4/metview/src/uPlot/PmContext.h metview-5.19.2/metview/src/uPlot/PmContext.h --- metview-5.17.4/metview/src/uPlot/PmContext.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PmContext.h 2023-07-15 08:28:47.000000000 +0000 @@ -75,10 +75,10 @@ void AddToReply(const MvRequest&); // Set the presentable - //void SetCurrentPresentable ( Presentable* ); + // void SetCurrentPresentable ( Presentable* ); // Find out the current presentable - //Presentable* GetCurrentPresentable ( ); + // Presentable* GetCurrentPresentable ( ); // Execute the request void Execute(); @@ -118,7 +118,7 @@ protected: // Destructor - virtual ~PmContext(); + ~PmContext() override; private: // No copy allowed @@ -130,9 +130,10 @@ MvProtocol& proto_; - //Presentable* presentable_; + // Presentable* presentable_; Cached firstDataView_; - double dropX_, dropY_; + double dropX_{0.}; + double dropY_{0.}; }; diff -Nru metview-5.17.4/metview/src/uPlot/PmGeneralProjection.cc metview-5.19.2/metview/src/uPlot/PmGeneralProjection.cc --- metview-5.17.4/metview/src/uPlot/PmGeneralProjection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PmGeneralProjection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,7 +34,7 @@ // class PmMercatorProjectionFactory - builds PmMercator projections class PmMercatorProjectionFactory : public PmProjectionFactory { - virtual PmProjection* Build(const MvRequest& reqst) + PmProjection* Build(const MvRequest& reqst) override { return new PmMercator(reqst); } @@ -51,7 +51,7 @@ // // PmMercator projection PmMercator::PmMercator(const MvRequest& viewRequest) : - PmGeneralProjection(viewRequest) //PmGeneralProjection ( "MERCATOR" ) + PmGeneralProjection(viewRequest) // PmGeneralProjection ( "MERCATOR" ) { // Initialize vertical longitude GPlon0 = viewRequest("MAP_VERTICAL_LONGITUDE"); @@ -67,7 +67,7 @@ // GEODETIC TO MERCATOR COORDINATES Point PmMercator ::LL2PC(Point& ptll) { - double equad, //Squared eccentricity + double equad, // Squared eccentricity aux1, // Ancillary variables aux2, aux3, aux4, aux5, aux6, ptllx, ptlly; @@ -78,31 +78,31 @@ equad -= Pflt * Pflt; double a1, a2, a3; - a1 = tan(ptlly / (double)2); - a2 = 1. + a1; - a3 = 1. - a1; + a1 = tan(ptlly / (double)2); + a2 = 1. + a1; + a3 = 1. - a1; aux1 = a2 / a3; a1 = equad * equad / 4.; a1 += equad; - a2 = equad * equad * equad / 8.; - a3 = sin(ptlly); + a2 = equad * equad * equad / 8.; + a3 = sin(ptlly); aux2 = (a1 + a2) * a3; - a1 = equad * equad / 12.; - a2 = equad * equad * equad / 16.; - a3 = sin((double)3 * ptlly); + a1 = equad * equad / 12.; + a2 = equad * equad * equad / 16.; + a3 = sin((double)3 * ptlly); aux3 = (a1 + a2) * a3; - a1 = equad * equad * equad / 80.; - a2 = sin((double)5 * ptlly); + a1 = equad * equad * equad / 80.; + a2 = sin((double)5 * ptlly); aux4 = a1 * a2; aux5 = cos(GPstlat1); a1 = sin(GPstlat1); a1 *= a1; a1 *= equad; - a2 = sqrt((double)1 - a1); + a2 = sqrt((double)1 - a1); aux6 = 1. / a2; ptllx = Prd * (ptllx - GPlon0) * aux5 * aux6; @@ -117,7 +117,7 @@ // MERCATOR TO GEODETIC COORDINATES Point PmMercator ::PC2LL(Point& ptpc) { - double equad, //Squared eccentricity + double equad, // Squared eccentricity pi, // PII value t, // Ancillary variables xx, aux1, aux2, aux3, aux4, aux5, ptpcx, ptpcy; @@ -134,32 +134,32 @@ a1 = sin(GPstlat1); a1 *= a1; a1 *= equad; - a2 = sqrt((double)1 - a1); - aux2 = 1. / a2; + a2 = sqrt((double)1 - a1); + aux2 = 1. / a2; ptpcx = ptpcx / (aux1 * aux2); ptpcy = ptpcy / (aux1 * aux2); - t = exp(-ptpcy / Prd); - xx = pi / 2. - 2. * atan(t); + t = exp(-ptpcy / Prd); + xx = pi / 2. - 2. * atan(t); a1 = equad / 2.; a1 += 5. * equad * equad / 24.; a1 += equad * equad * equad / 12.; - a2 = sin((double)4 * atan(t)); + a2 = sin((double)4 * atan(t)); aux3 = a1 * a2; a1 = 7. * equad * equad / 48.; a1 += 29. * equad * equad * equad / 240.; - a2 = sin((double)8 * atan(t)); + a2 = sin((double)8 * atan(t)); aux4 = -a1 * a2; - a1 = 7. * equad * equad * equad / 120.; - a2 = sin((double)12 * atan(t)); + a1 = 7. * equad * equad * equad / 120.; + a2 = sin((double)12 * atan(t)); aux5 = a1 * a2; ptpcy = xx + aux3 + aux4 + aux5; ptpcx = ptpcx / Prd + GPlon0; - return (Point(ptpcx, ptpcy)); + return {ptpcx, ptpcy}; } double @@ -205,7 +205,7 @@ (geodCoord_.Right() != x2) || (geodCoord_.Bottom() != y1) || (geodCoord_.Top() != y2)) { - flag = false; + flag = false; geodCoord_ = Location(y2, x1, y1, x2); } @@ -218,7 +218,7 @@ // class PmCylindProjectionFactory - builds PmCylindrical projections class PmCylindProjectionFactory : public PmProjectionFactory { - virtual PmProjection* Build(const MvRequest& reqst) + PmProjection* Build(const MvRequest& reqst) override { return new PmCylindEquid(reqst); } @@ -254,7 +254,7 @@ ptllx = Prd * (ptllx - GPlon0) * cos(GPstlat1); ptlly = Prd * ptlly; - return (Point(ptllx, ptlly)); + return {ptllx, ptlly}; } // EQUIDISTANT CYLINDRICAL TO GEODETIC COORDINATES @@ -266,7 +266,7 @@ ptpcy = ptpcy / Prd; ptpcx = GPlon0 + ptpcx / (Prd * cos(GPstlat1)); - return (Point(ptpcx, ptpcy)); + return {ptpcx, ptpcy}; } double @@ -294,8 +294,8 @@ // Check if direction is ok (S -> N) if (y2 < y1) { double aux = y2; - y2 = y1; - y1 = aux; + y2 = y1; + y1 = aux; } else if (y2 == y1) { y1 = -90.; @@ -317,7 +317,7 @@ (geodCoord_.Right() != x2) || (geodCoord_.Bottom() != y1) || (geodCoord_.Top() != y2)) { - flag = false; + flag = false; geodCoord_ = Location(y2, x1, y1, x2); } @@ -331,7 +331,7 @@ // class PmPolarProjectionFactory : public PmProjectionFactory { - virtual PmProjection* Build(const MvRequest& reqst) + PmProjection* Build(const MvRequest& reqst) override { return new PmPolarStereo(reqst); } @@ -382,7 +382,7 @@ // k0 = 0.994; // Standard parallel 80.1 degrees k0 = 0.933; // Standard parallel 60 degrees - e = sqrt((double)2 * Pflt - pow(Pflt, (double)2)); + e = sqrt((double)2 * Pflt - pow(Pflt, (double)2)); pi = 4. * atan((double)1); ptlly *= GPhemis; @@ -391,12 +391,12 @@ lon0 *= DEG_TO_RAD; aux1 = (1. - e * sin(ptlly)) / (1. + e * sin(ptlly)); - t = tan((pi / 4.) - (ptlly / 2.)) / pow(aux1, (e / (double)2)); + t = tan((pi / 4.) - (ptlly / 2.)) / pow(aux1, (e / (double)2)); aux2 = pow(((double)1 + e), ((double)1 + e)); aux3 = pow(((double)1 - e), ((double)1 - e)); - ro = 2. * Prd * k0 * t / sqrt(aux2 * aux3); + ro = 2. * Prd * k0 * t / sqrt(aux2 * aux3); - aux1 = ro * sin(ptllx - lon0); + aux1 = ro * sin(ptllx - lon0); ptlly = -ro * cos(ptllx - lon0); aux1 *= GPhemis; ptlly *= GPhemis; @@ -406,7 +406,7 @@ ptlly *= GPhemis; } - return (Point(aux1, ptlly)); + return {aux1, ptlly}; } // POLAR STEREOGRAPHIC TO GEODETIC COORDINATES @@ -425,10 +425,10 @@ py = (double)ptpc.Y(); // k0 = 0.994; // Standard parallel 80.1 degrees - k0 = 0.933; // Standard parallel 60 degrees - pi = 4. * atan((double)1); + k0 = 0.933; // Standard parallel 60 degrees + pi = 4. * atan((double)1); equad = 2. * Pflt - pow(Pflt, (double)2); - e = sqrt(equad); + e = sqrt(equad); if (GPhemis == -1) { px *= GPhemis; @@ -438,11 +438,11 @@ lon0 = (GPhemis == 1) ? GPlon0 : -GPlon0; lon0 *= DEG_TO_RAD; - ro = sqrt(px * px + py * py); + ro = sqrt(px * px + py * py); aux1 = pow(((double)1 + e), ((double)1 + e)); aux2 = pow(((double)1 - e), ((double)1 - e)); - t = (ro * sqrt(aux1 * aux2)) / (2. * Prd * k0); - xx = pi / 2. - 2. * atan(t); + t = (ro * sqrt(aux1 * aux2)) / (2. * Prd * k0); + xx = pi / 2. - 2. * atan(t); aux3 = equad / 2. + 5. * equad * equad / 24. + equad * equad * equad / 12.; aux4 = 7. * equad * equad / 48. + 29. * equad * equad * equad / 240.; aux5 = 7. * equad * equad * equad / 120.; @@ -497,13 +497,13 @@ if (geodCoord_.Top() * GPhemis < -20.) { geodCoord_ = Location(-20. * GPhemis, geodCoord_.Left(), geodCoord_.Bottom(), geodCoord_.Right()); - flag = false; + flag = false; } if (geodCoord_.Bottom() * GPhemis < -20.) { geodCoord_ = Location(geodCoord_.Top(), geodCoord_.Left(), -20. * GPhemis, geodCoord_.Right()); - flag = false; + flag = false; } Point llPointLL(geodCoord_.Left() * DEG_TO_RAD, geodCoord_.Bottom() * DEG_TO_RAD); @@ -532,8 +532,8 @@ (urPointPC.X() > rmPointPC.X())) { geodCoord_ = Location(-20. * GPhemis, -45. * GPhemis, -20. * GPhemis, 135. * GPhemis); - GPlon0 = 0; - flag = false; + GPlon0 = 0; + flag = false; } area = geodCoord_; @@ -561,21 +561,21 @@ // // PmLambert projection PmLambert::PmLambert(const MvRequest& viewRequest) : - PmGeneralProjection(viewRequest) //PmGeneralProjection ( "LAMBERT" ) + PmGeneralProjection(viewRequest) // PmGeneralProjection ( "LAMBERT" ) { // Initialize some parameters - GPlon0 = viewRequest("SUBPAGE_MAP_CENTRE_LONGITUDE"); - GPlat0 = (double)viewRequest("SUBPAGE_MAP_CENTRE_LATITUDE") * DEG_TO_RAD; + GPlon0 = viewRequest("SUBPAGE_MAP_CENTRE_LONGITUDE"); + GPlat0 = (double)viewRequest("SUBPAGE_MAP_CENTRE_LATITUDE") * DEG_TO_RAD; GPstlat1 = (double)viewRequest("SUBPAGE_MAP_STANDARD_LATITUDE_1") * DEG_TO_RAD; GPstlat2 = (double)viewRequest("SUBPAGE_MAP_STANDARD_LATITUDE_2") * DEG_TO_RAD; - LScale = (double)viewRequest("SUBPAGE_MAP_SCALE"); + LScale = (double)viewRequest("SUBPAGE_MAP_SCALE"); // Calculate the projection coordinates this->CalculateProjectionCoord(); } // GEODETIC TO LAMBERT COORDINATES -Point PmLambert ::LL2PC(Point&) //ptll +Point PmLambert ::LL2PC(Point&) // ptll { #if 0 double equad, // Squared eccentricity @@ -615,11 +615,11 @@ return(Point(ptllx,ptlly)); #endif - return (Point(0., 0.)); + return {0., 0.}; } // LAMBERT TO GEODETIC COORDINATES -Point PmLambert ::PC2LL(Point&) //ptpc +Point PmLambert ::PC2LL(Point&) // ptpc { #if 0 double equad, // Squared eccentricity @@ -668,13 +668,13 @@ return (Point(ptpcx,ptpcy)); #endif - return (Point(0., 0.)); + return {0., 0.}; } double PmLambert::CheckOriginLongitude() { - //Add code later + // Add code later return 0.; } @@ -682,7 +682,7 @@ // class PmOceanSectionProjectionFactory - builds PmOceanSection projections class PmOceanSectionProjectionFactory : public PmProjectionFactory { - virtual PmProjection* Build(const MvRequest& reqst) + PmProjection* Build(const MvRequest& reqst) override { return new PmOceanSection(reqst); } @@ -699,7 +699,7 @@ // // PmOceanSection projection PmOceanSection::PmOceanSection(const MvRequest& viewRequest) : - PmGeneralProjection(viewRequest) //PmGeneralProjection ( "OCEAN_SECTION" ) + PmGeneralProjection(viewRequest) // PmGeneralProjection ( "OCEAN_SECTION" ) { this->CalculateProjectionCoord(); } @@ -707,21 +707,21 @@ // GEODETIC TO OCEAN_SECTION COORDINATES Point PmOceanSection ::LL2PC(Point&) { - //Add code later - return (Point(0., 0.)); + // Add code later + return {0., 0.}; } // OCEAN_SECTION TO GEODETIC COORDINATES Point PmOceanSection ::PC2LL(Point&) { - //Add code later - return (Point(0., 0.)); + // Add code later + return {0., 0.}; } double PmOceanSection::CheckOriginLongitude() { - //Add code later + // Add code later return 0.; } @@ -729,7 +729,7 @@ // class PmAitoffProjectionFactory - builds PmAitoff projections class PmAitoffProjectionFactory : public PmProjectionFactory { - virtual PmProjection* Build(const MvRequest& reqst) + PmProjection* Build(const MvRequest& reqst) override { return new PmAitoff(reqst); } @@ -746,7 +746,7 @@ // // PmAitoff projection PmAitoff::PmAitoff(const MvRequest& viewRequest) : - PmGeneralProjection(viewRequest) //PmGeneralProjection ( "AITOFF" ) + PmGeneralProjection(viewRequest) // PmGeneralProjection ( "AITOFF" ) { // Initialize vertical longitude GPlon0 = viewRequest("MAP_VERTICAL_LONGITUDE"); @@ -758,13 +758,13 @@ // GEODETIC TO AITOFF COORDINATES Point PmAitoff ::LL2PC(Point&) { - //Add code later - return (Point(0., 0.)); + // Add code later + return {0., 0.}; } // AITOFF TO GEODETIC COORDINATES Point PmAitoff ::PC2LL(Point&) { - //Add code later - return (Point(0., 0.)); + // Add code later + return {0., 0.}; } diff -Nru metview-5.17.4/metview/src/uPlot/PmGeneralProjection.h metview-5.19.2/metview/src/uPlot/PmGeneralProjection.h --- metview-5.17.4/metview/src/uPlot/PmGeneralProjection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PmGeneralProjection.h 2023-07-15 08:28:47.000000000 +0000 @@ -63,7 +63,7 @@ // Activates object of type PmGeneralProjection with the // current projection. - ~PmGeneralProjection() {} + ~PmGeneralProjection() override = default; // Empty destructor. friend bool operator==(PmGeneralProjection& a, PmGeneralProjection& b); @@ -156,7 +156,7 @@ // Precondition: // s must be a valid latitude ([0,pi/2] or [0,-pi/2]) - virtual Point LL2PC(Point& p) = 0; + Point LL2PC(Point& p) override = 0; // Pure virtual method that transforms geodetic into // projection coordinates. // Description: @@ -173,7 +173,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]) - virtual Point PC2LL(Point& p) = 0; + Point PC2LL(Point& p) override = 0; // Pure virtual method that transforms projection into // geodetic coordinates. // Description: @@ -305,9 +305,9 @@ printf("\nHemisphere=%d OriginLat=%lf OriginLongi=%lf StdLatOne=%lf ERad=%lf EFlt=%lf", GPhemis, GPlat0, GPlon0, GPstlat1, Prd, Pflt); } - virtual bool CheckGeodeticCoordinates(Location&); + bool CheckGeodeticCoordinates(Location&) override; - virtual double CheckOriginLongitude() = 0; + double CheckOriginLongitude() override = 0; }; // @@ -345,11 +345,11 @@ PmMercator(const MvRequest& reqst); // Constructor from a request - ~PmMercator() {} + ~PmMercator() override = default; // Empty destructor - virtual Point LL2PC(Point& p); + Point LL2PC(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms geodetic into PmMercator // coordinates. @@ -362,7 +362,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]). - virtual Point PC2LL(Point& p); + Point PC2LL(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms Mercator into geodetic // coordinates. @@ -374,7 +374,7 @@ // X and Y Mercator coordinates must be both valid, // within their typical range. - virtual bool CheckGeodeticCoordinates(Location&); + bool CheckGeodeticCoordinates(Location&) override; virtual double CheckOriginLongitude(); }; @@ -416,10 +416,10 @@ PmCylindEquid(const MvRequest& reqst); // Constructor from a request - ~PmCylindEquid() {} + ~PmCylindEquid() override = default; // Empty destructor - virtual Point LL2PC(Point& p); + Point LL2PC(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms geodetic into Equidistant // Cylindrical coordinates. @@ -432,7 +432,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]). - virtual Point PC2LL(Point& p); + Point PC2LL(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms Equidistant Cylindrical into // geodetic coordinates. @@ -444,9 +444,9 @@ // X and Y Equidistant Cylindrical coordinates must // be both valid, within their typical range. - virtual bool CheckGeodeticCoordinates(Location&); + bool CheckGeodeticCoordinates(Location&) override; - virtual double CheckOriginLongitude(); + double CheckOriginLongitude() override; }; // @@ -487,10 +487,10 @@ PmPolarStereo(const MvRequest& reqst); // Constructor from a request - ~PmPolarStereo() {} + ~PmPolarStereo() override = default; // Empty destructor. - virtual Point LL2PC(Point& p); + Point LL2PC(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms geodetic into Polar // Stereographic coordinates. @@ -503,7 +503,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]). - virtual Point PC2LL(Point& p); + Point PC2LL(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms Polar Stereographic into // geodetic coordinates. @@ -515,9 +515,9 @@ // X and Y Polar Stereographic coordinates must // be both valid, within their typical range. - virtual bool CheckGeodeticCoordinates(Location&); + bool CheckGeodeticCoordinates(Location&) override; - virtual double CheckOriginLongitude() + double CheckOriginLongitude() override { return OriginLongitude(); } @@ -562,10 +562,10 @@ PmLambert(const MvRequest& reqst); // Constructor from a request. - ~PmLambert() {} + ~PmLambert() override = default; // Empty destructor. - virtual Point LL2PC(Point& p); + Point LL2PC(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms geodetic into PmLambert // coordinates. @@ -578,7 +578,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]). - virtual Point PC2LL(Point& p); + Point PC2LL(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms Lambert into geodetic // coordinates. @@ -590,9 +590,9 @@ // X and Y Lambert coordinates must be both valid, // within their typical range. - virtual double CheckOriginLongitude(); + double CheckOriginLongitude() override; - bool CanDoZoom() + bool CanDoZoom() override { return true; } @@ -631,10 +631,10 @@ PmAitoff(const MvRequest& reqst); // Constructor from a request - ~PmAitoff() {} + ~PmAitoff() override = default; // Empty destructor - virtual Point LL2PC(Point& p); + Point LL2PC(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms geodetic into PmAitoff // coordinates. @@ -647,7 +647,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]). - virtual Point PC2LL(Point& p); + Point PC2LL(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms Aitoff into geodetic // coordinates. @@ -659,12 +659,12 @@ // X and Y Aitoff coordinates must be both valid, // within their typical range. - virtual double CheckOriginLongitude() + double CheckOriginLongitude() override { return OriginLongitude(); } - bool CanDoZoom() + bool CanDoZoom() override { return false; } @@ -703,11 +703,11 @@ PmOceanSection(const MvRequest& reqst); // Constructor from a request. - ~PmOceanSection() {} + ~PmOceanSection() override = default; // Empty destructor. - virtual Point LL2PC(Point& p); + Point LL2PC(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms geodetic into PmOceanSection // coordinates. @@ -720,7 +720,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]). - virtual Point PC2LL(Point& p); + Point PC2LL(Point& p) override; // This implementation of a pure virtual method defined in // PmGeneralProjection transforms OceanSection into geodetic // coordinates. @@ -732,9 +732,9 @@ // X and Y OceanSection coordinates must be both valid, // within their typical range. - virtual double CheckOriginLongitude(); + double CheckOriginLongitude() override; - bool CanDoZoom() + bool CanDoZoom() override { return false; } diff -Nru metview-5.17.4/metview/src/uPlot/PmIndividualProjection.cc metview-5.19.2/metview/src/uPlot/PmIndividualProjection.cc --- metview-5.17.4/metview/src/uPlot/PmIndividualProjection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PmIndividualProjection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,7 +13,7 @@ // class PmCartesianViewProjectionFactory - builds PmCartesianView projection class PmCartesianViewProjectionFactory : public PmProjectionFactory { - virtual PmProjection* Build(const MvRequest& reqst) + PmProjection* Build(const MvRequest& reqst) override { return new PmCartesianView(reqst); } @@ -39,26 +39,26 @@ // GEODETIC TO CARTESIANVIEW COORDINATES Point PmCartesianView::LL2PC(Point&) { - //Add code later - return (Point(0., 0.)); + // Add code later + return {0., 0.}; } // CARTESIANVIEW TO GEODETIC COORDINATES Point PmCartesianView ::PC2LL(Point&) { - //Add code later - return (Point(0., 0.)); + // Add code later + return {0., 0.}; } double PmCartesianView::CheckOriginLongitude() { - //Add code later + // Add code later return 0.; } bool PmCartesianView::CheckGeodeticCoordinates(Location&) { - //Add code later + // Add code later return true; } diff -Nru metview-5.17.4/metview/src/uPlot/PmIndividualProjection.h metview-5.19.2/metview/src/uPlot/PmIndividualProjection.h --- metview-5.17.4/metview/src/uPlot/PmIndividualProjection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PmIndividualProjection.h 2023-07-15 08:28:47.000000000 +0000 @@ -12,7 +12,7 @@ // PmIndividualProjection // // .AUTHOR: -//Fernando Ii +// Fernando Ii // // .SUMMARY: // Provides methods that are required to handle specific map projections. @@ -41,7 +41,7 @@ PmCartesianView(const MvRequest& reqst); // Normal constructor from a request - ~PmCartesianView() {} + ~PmCartesianView() override = default; // Empty destructor friend bool operator==(PmCartesianView& a, PmCartesianView& b); @@ -54,7 +54,7 @@ // TRUE: Objects are equal; // FALSE: Objects are different. - virtual Point LL2PC(Point& p); + Point LL2PC(Point& p) override; // Pure virtual method that transforms geodetic into // projection coordinates. // Description: @@ -71,7 +71,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]) - virtual Point PC2LL(Point& p); + Point PC2LL(Point& p) override; // Pure virtual method that transforms projection into // geodetic coordinates. // Description: @@ -87,7 +87,7 @@ // X and Y projection coordinates must be both valid, // within the typical range of each projection class. - virtual bool CheckGeodeticCoordinates(Location&); + bool CheckGeodeticCoordinates(Location&) override; - virtual double CheckOriginLongitude(); + double CheckOriginLongitude() override; }; diff -Nru metview-5.17.4/metview/src/uPlot/PmProjection.cc metview-5.19.2/metview/src/uPlot/PmProjection.cc --- metview-5.17.4/metview/src/uPlot/PmProjection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PmProjection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -106,7 +106,7 @@ Cached projectionName = reqst("MAP_PROJECTION"); if (!projectionName) { MvRequest tmpReq = ObjectList::ExpandRequest(reqst, EXPAND_DEFAULTS); - projectionName = tmpReq("MAP_PROJECTION"); + projectionName = tmpReq("MAP_PROJECTION"); } return projectionName; @@ -128,20 +128,20 @@ // Get the projection name. If it does not exist in the request, // expand the request to search for the default projection name MvRequest tmpReq = viewRequest; - Pname = tmpReq("MAP_PROJECTION"); + Pname = tmpReq("MAP_PROJECTION"); if (!Pname) { tmpReq = ObjectList::ExpandRequest(viewRequest, EXPAND_DEFAULTS); - Pname = tmpReq("MAP_PROJECTION"); + Pname = tmpReq("MAP_PROJECTION"); } // Default values for radius and flatness - Prd = EARTHRADIUS; + Prd = EARTHRADIUS; Pflt = EARTHFLATNESS; // Initialize the bounding box in geodetic coordinates - double lat1 = tmpReq("AREA", 0); + double lat1 = tmpReq("AREA", 0); double long1 = tmpReq("AREA", 1); - double lat2 = tmpReq("AREA", 2); + double lat2 = tmpReq("AREA", 2); double long2 = tmpReq("AREA", 3); Location geodeticCoord(lat2, long1, lat1, long2); @@ -185,13 +185,13 @@ Point projUpperRight(box.Right(), box.Top()); // Calculate the coordinates in geodetic coordinates - Point geodLowerLeft = this->PC2LL(projLowerLeft); + Point geodLowerLeft = this->PC2LL(projLowerLeft); Point geodUpperRight = this->PC2LL(projUpperRight); - return Location(geodUpperRight.Y() * RAD_TO_DEG, - geodLowerLeft.X() * RAD_TO_DEG, - geodLowerLeft.Y() * RAD_TO_DEG, - geodUpperRight.X() * RAD_TO_DEG); + return {geodUpperRight.Y() * RAD_TO_DEG, + geodLowerLeft.X() * RAD_TO_DEG, + geodLowerLeft.Y() * RAD_TO_DEG, + geodUpperRight.X() * RAD_TO_DEG}; } // @@ -209,13 +209,13 @@ box.Top() * DEG_TO_RAD); // Calculate the coordinates in geodetic coordinates - Point projLowerLeft = this->LL2PC(geodLowerLeft); + Point projLowerLeft = this->LL2PC(geodLowerLeft); Point projUpperRight = this->LL2PC(geodUpperRight); - return Location(projUpperRight.Y(), - projLowerLeft.X(), - projLowerLeft.Y(), - projUpperRight.X()); + return {projUpperRight.Y(), + projLowerLeft.X(), + projLowerLeft.Y(), + projUpperRight.X()}; } void PmProjection::CalculateProjectionCoord() @@ -227,7 +227,7 @@ geodCoord_.Top() * DEG_TO_RAD); // Calculate the box in projection coordinates - Point projLowerLeft = this->LL2PC(geodLowerLeft); + Point projLowerLeft = this->LL2PC(geodLowerLeft); Point projUpperRight = this->LL2PC(geodUpperRight); Location projCoord(projUpperRight.Y(), diff -Nru metview-5.17.4/metview/src/uPlot/PmProjection.h metview-5.19.2/metview/src/uPlot/PmProjection.h --- metview-5.17.4/metview/src/uPlot/PmProjection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/PmProjection.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,14 +15,14 @@ #include "Factory.hpp" #include "Location.h" -const Cached MERCATOR = "MERCATOR"; -const Cached CYLINDRICAL = "CYLINDRICAL"; -const Cached POLAR = "POLAR_STEREOGRAPHIC"; -const Cached SATELLITE = "SATELLITE"; -const Cached SPACEVIEW = "SPACEVIEW"; +const Cached MERCATOR = "MERCATOR"; +const Cached CYLINDRICAL = "CYLINDRICAL"; +const Cached POLAR = "POLAR_STEREOGRAPHIC"; +const Cached SATELLITE = "SATELLITE"; +const Cached SPACEVIEW = "SPACEVIEW"; const Cached OCEANSECTION = "OCEAN_SECTION"; -const Cached AITOFF = "AITOFF"; -const Cached LAMBERT = "LAMBERT"; +const Cached AITOFF = "AITOFF"; +const Cached LAMBERT = "LAMBERT"; enum PROJECTIONID { @@ -37,23 +37,23 @@ CartesianViewId }; -const short PDATUM = 0x1; +const short PDATUM = 0x1; const short PHEMISPHERE = 0x2; -const short PLATITUDE = 0x4; -const short PLONGITUDE = 0x8; -const short PFIRSTLAT = 0x10; -const short PSECDLAT = 0x20; +const short PLATITUDE = 0x4; +const short PLONGITUDE = 0x8; +const short PFIRSTLAT = 0x10; +const short PSECDLAT = 0x20; const short NORTH = 1; const short SOUTH = -1; -const double EARTHRADIUS = 6378160.; // Int. Astronomical Union - 1965 +const double EARTHRADIUS = 6378160.; // Int. Astronomical Union - 1965 const double EARTHFLATNESS = 1. / 297.; const double DEG_TO_RAD = M_PI / 180.; const double RAD_TO_DEG = 180. / M_PI; -const double SCALE_THSD = 1. / 1000.; // 10**(-3) +const double SCALE_THSD = 1. / 1000.; // 10**(-3) const double SCALE_MILLION = 1. / 1000000.; // 10**(-6) (scale factor used in GRIB ) // Class Device Factory - clones a new Device on Request @@ -61,8 +61,8 @@ struct PmProjectionFactoryTraits { - typedef PmProjection Type; - typedef const MvRequest& Parameter; + using Type = PmProjection; + using Parameter = const MvRequest&; static Cached FactoryName(Parameter); static Type* DefaultObject(Parameter); }; diff -Nru metview-5.17.4/metview/src/uPlot/Preferences.h metview-5.19.2/metview/src/uPlot/Preferences.h --- metview-5.17.4/metview/src/uPlot/Preferences.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Preferences.h 2023-07-15 08:28:47.000000000 +0000 @@ -51,7 +51,7 @@ Preferences(const Preferences&); // Destructor - ~Preferences() {} + ~Preferences() = default; // Class Members void Owner(Presentable& xx) { owner_ = &xx; } diff -Nru metview-5.17.4/metview/src/uPlot/Presentable.cc metview-5.19.2/metview/src/uPlot/Presentable.cc --- metview-5.17.4/metview/src/uPlot/Presentable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Presentable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ Presentable::Presentable() : myRequest_(), presentableId_(treeNodeCounter_++), - myParent_(0), + myParent_(nullptr), myLocation_(0., 0., 1., 1.), hasMatch_(false), matchingInfo_(MvRequest("EMPTY")), @@ -58,7 +58,7 @@ Presentable::Presentable(const MvRequest& inRequest) : myRequest_(inRequest), presentableId_(treeNodeCounter_++), - myParent_(0), + myParent_(nullptr), myLocation_(inRequest), hasMatch_(false), matchingInfo_(MvRequest("EMPTY")), @@ -80,7 +80,7 @@ Presentable::Presentable(const Presentable& old) : myRequest_(old.myRequest_), presentableId_(treeNodeCounter_++), - myParent_(0), + myParent_(nullptr), myLocation_(old.myLocation_), hasMatch_(old.hasMatch_), matchingInfo_(old.matchingInfo_), @@ -98,12 +98,12 @@ // as this copy constructor is at the moment // for non-interactive devices. Consequently, device // data is not copied. - //Childlist will be rebuilt in DuplicateChildren function. + // Childlist will be rebuilt in DuplicateChildren function. } void Presentable::SetRequest(const MvRequest& in) { - myRequest_ = in; + myRequest_ = in; myLocation_ = in; } @@ -214,7 +214,7 @@ // Before deletion, make the parent point to NULL // This is necessary because otherwise the top // statement would generate a recursive call - (*child)->myParent_ = 0; //Don't get called back + (*child)->myParent_ = nullptr; // Don't get called back // Create a temporary pointer to store the child's address Presentable* pt = (*child); @@ -257,8 +257,8 @@ void Presentable::Insert(Presentable* p) { - require(p != 0); - require(p->myParent_ == 0); + require(p != nullptr); + require(p->myParent_ == nullptr); // Test if child is at a lower depth than parent childList_.push_back(p); @@ -275,7 +275,7 @@ void Presentable::Remove(Presentable* p) { - require(p != 0); + require(p != nullptr); require(p->myParent_ == this); // Am I his father ?? // Test if child is at a lower depth than parent @@ -287,7 +287,7 @@ // The child no longer has a father // (a.k.a. "abandon the child") - p->myParent_ = 0; + p->myParent_ = nullptr; // Notify the change NotifyObservers(); @@ -433,7 +433,7 @@ // Remove Data Units MvIconList duList; - //if ( iconDataBase.DataUnitListByPresentableId ( this->Id(), duList ) ) + // if ( iconDataBase.DataUnitListByPresentableId ( this->Id(), duList ) ) if (iconDataBase.RetrieveIcon(PRES_DATAUNIT_REL, this->Id(), duList)) { MvListCursor duCursor; for (duCursor = duList.begin(); duCursor != duList.end(); ++duCursor) { @@ -445,7 +445,7 @@ // Remove PTexts MvIconList ptList; - //if ( iconDataBase.TextListByPresentableId ( this->Id(), ptList ) ) + // if ( iconDataBase.TextListByPresentableId ( this->Id(), ptList ) ) if (iconDataBase.RetrieveIcon(PRES_TEXT_REL, this->Id(), ptList)) { MvListCursor ptCursor; for (ptCursor = ptList.begin(); ptCursor != ptList.end(); ++ptCursor) { @@ -577,16 +577,16 @@ if (treeNodeId == presentableId_) return (Presentable*)this; - Presentable* node = 0; + Presentable* node = nullptr; // Look at the descendents MvChildConstIterator child; for (child = childList_.begin(); child != childList_.end(); ++child) { - if ((node = (*child)->FindBranch(treeNodeId)) != 0) + if ((node = (*child)->FindBranch(treeNodeId)) != nullptr) return (Presentable*)node; } - return 0; + return nullptr; } // -- METHOD : FindBranchesByRequest @@ -615,7 +615,7 @@ // Find the presentable Id related to the icon Id int presId = iconDataBase.FindPresentableId(iconId, dataId); if (presId < 0) - return 0; + return nullptr; // Find the presentable related to the given node id Presentable* pres = this->FindBranch(presId); @@ -669,13 +669,13 @@ void Presentable::PendingDrawingsAdd() { - require(myParent_ != 0); + require(myParent_ != nullptr); myParent_->PendingDrawingsAdd(); } void Presentable::PendingDrawingsRemove() { - require(myParent_ != 0); + require(myParent_ != nullptr); myParent_->PendingDrawingsRemove(); } @@ -721,16 +721,16 @@ // NDIM_FLAG = 0 (no check), 1 (1-D data), 2 (2-D data). bool Presentable::DefaultVisDefList(const char* className, MvIconList& visdefList, int ndim_flag, int type) { - require(className != 0); + require(className != nullptr); bool usingDefault = false; - bool found = false; + bool found = false; // Retrieve the Icon Data Base MvIconDataBase& iconDataBase = this->IconDataBase(); // Try to find a visdef associated to the presentable - visdefList.clear(); //initialise list + visdefList.clear(); // initialise list if (type == GETBYVISDEF) { MvIconList tmpList; iconDataBase.RetrieveIcon(PRES_VISDEF_REL, presentableId_, tmpList); @@ -749,8 +749,8 @@ // If not found, try to find Visdefs up in the tree if (!found) usingDefault = myParent_->DefaultVisDefList(className, visdefList, ndim_flag, type); - else //If Visdef(s) are found, check if there is at least one valid. - { //Be careful, only make this check if type is GETBYDATAUNIT + else // If Visdef(s) are found, check if there is at least one valid. + { // Be careful, only make this check if type is GETBYDATAUNIT if (type != GETBYVISDEF && !ObjectList::CheckValidVisDefList(className, visdefList)) usingDefault = myParent_->DefaultVisDefList(className, visdefList, ndim_flag, type); } @@ -802,7 +802,7 @@ if (!dataBase.RetrieveIcon(DATAUNIT_VISDEF_REL, icon.Id(), iconList)) { // Visdef connected to the dataunit not found. Go up the tree. // Find presentable branch related to the dataunit - int dummy; + int dummy = 0; Presentable* pres = this->FindBranchByIconId(icon.Id(), dummy); pres->DefaultVisDefList(icon.IconClass(), iconList); } @@ -953,7 +953,7 @@ DeviceData* Presentable::ReleaseDeviceData() { - require(deviceData_.get() != 0); + require(deviceData_.get() != nullptr); return deviceData_.release(); } @@ -964,14 +964,14 @@ GraphicsEngine& Presentable::GetGraphicsEngine() const { - require(myParent_ != 0); + require(myParent_ != nullptr); return myParent_->GetGraphicsEngine(); } PlotModView& Presentable::GetView() const { - require(myParent_ != 0); + require(myParent_ != nullptr); return myParent_->GetView(); } @@ -982,7 +982,7 @@ Canvas& Presentable::GetCanvas() const { - require(myParent_ != 0); + require(myParent_ != nullptr); return myParent_->GetCanvas(); } @@ -1009,7 +1009,7 @@ DrawingPriority& Presentable::GetDrawPriority() { - require(myParent_ != 0); + require(myParent_ != nullptr); return myParent_->GetDrawPriority(); } @@ -1081,9 +1081,9 @@ Rectangle rect = child.GetLocation(); double height = size.GetHeight() * (rect.bottom - rect.top); - double width = size.GetWidth() * (rect.right - rect.left); + double width = size.GetWidth() * (rect.right - rect.left); - return PaperSize(width, height); + return {width, height}; } #if 0 @@ -1152,7 +1152,7 @@ std::string ptextDrops; MvListCursor lCursor; for (lCursor = iconList.begin(); lCursor != iconList.end(); ++lCursor) { - MvIcon icon = *lCursor; + MvIcon icon = *lCursor; MvRequest iconRequest = icon.Request(); // Skip icon according to its status @@ -1170,7 +1170,7 @@ // Save icon name and its stacking order info std::string sdesc = (const char*)myDescription.Convert(iconRequest); - ptextDrops = ptextDrops + ", " + sdesc; + ptextDrops = ptextDrops + ", " + sdesc; } // 2) Describe Legends @@ -1182,7 +1182,7 @@ first = true; std::string mlegDrops; for (lCursor = iconList.begin(); lCursor != iconList.end(); ++lCursor) { - MvIcon icon = *lCursor; + MvIcon icon = *lCursor; MvRequest iconRequest = icon.Request(); // Skip icon according to its status @@ -1200,7 +1200,7 @@ // Save icon name and its stacking order info std::string sdesc = (const char*)myDescription.Convert(iconRequest); - mlegDrops = mlegDrops + ", " + sdesc; + mlegDrops = mlegDrops + ", " + sdesc; } // 3) Describe isolated Visdefs (not connected to the data) @@ -1223,7 +1223,7 @@ while (du != iconList.end()) { // If dataunit is not visible then process the next one MvIcon currentDataUnit = *du; - int visible = dataBase.IconVisibility(currentDataUnit.Id()); + int visible = dataBase.IconVisibility(currentDataUnit.Id()); if (visible != 1) { ++du; continue; @@ -1264,7 +1264,7 @@ { // Describe priority DrawingPriority& pageDrawPriority = this->GetDrawPriority(); - std::string priorName = pageDrawPriority.DescribeYourself(myDescription, MacroName()); + std::string priorName = pageDrawPriority.DescribeYourself(myDescription, MacroName()); if (!priorName.empty()) listDrops = ptextDrops + mlegDrops + listDrops + "," + priorName; @@ -1356,10 +1356,10 @@ // Loop over visdefs bool found = false; - auto vd = visdefList.begin(); + auto vd = visdefList.begin(); while (vd != visdefList.end()) { // Skip visdef which is target not to be plotted - MvIcon currentvd = *vd; + MvIcon currentvd = *vd; MvRequest currentvdRequest = currentvd.Request(); if ((const char*)currentvdRequest("_SKIP_MACRO") || (const char*)currentvdRequest("_DEFAULT")) { ++vd; @@ -1371,7 +1371,7 @@ std::string visDefName; if (ii == vdMap.end()) { myDescription.PutNewLine(""); - visDefName = myDescription.Convert(currentvdRequest); + visDefName = myDescription.Convert(currentvdRequest); vdMap[currentvd.Id()] = visDefName; } else @@ -1382,7 +1382,7 @@ if ((dataUnit.Id() == 0 || CheckValidVisDef(dataUnit, currentvdRequest)) && addToDrops && dataBase.IconVisibility(currentvd.Id())) { - found = true; + found = true; listDrops = listDrops + std::string(", ") + visDefName; } ++vd; @@ -1393,21 +1393,21 @@ int Presentable::PageIndex() { - ensure(myParent_ != 0); + ensure(myParent_ != nullptr); return myParent_->PageIndex(); } int Presentable::PaperPageIndex() const { - ensure(myParent_ != 0); + ensure(myParent_ != nullptr); return myParent_->PaperPageIndex(); } void Presentable::PaperPageIndexV1(int paperPageIndex) { - ensure(myParent_ != 0); + ensure(myParent_ != nullptr); myParent_->PaperPageIndexV1(paperPageIndex); } @@ -1490,7 +1490,7 @@ void Presentable::DrawLayerInfo(const int iconRelId, const char* name) { // Retrieve the Graphics Engine and the data base info - GraphicsEngine& ge = GetGraphicsEngine(); + GraphicsEngine& ge = GetGraphicsEngine(); MvIconDataBase& dataBase = IconDataBase(); // Call the Graphics Engine to store the Layer info. @@ -1544,7 +1544,7 @@ // Get data unit list MvIconList* iconList = iconDataBase.IconList(DB_DATAUNIT); - auto lCursor = iconList->begin(); + auto lCursor = iconList->begin(); if (lCursor == iconList->end()) { // No data unit available return; @@ -1552,12 +1552,12 @@ // Process only the first data unit // Revise this later if the whole list of data units is required - //while (lCursor != iconList->end()) + // while (lCursor != iconList->end()) { // Build a new data decoder, which will provide information // about the data std::unique_ptr decoder(DecoderFactory::Make((*lCursor).Request())); - ensure(decoder.get() != 0); + ensure(decoder.get() != nullptr); // Read data headers (one by one) while (decoder->ReadNextData()) { @@ -1583,14 +1583,14 @@ // MAP_LAYER_MODE can modify it!!! // 2) replace the ones defined in the Page level - bool exclusive; // true: dropped icon; false: icon came from Macro + bool exclusive = false; // true: dropped icon; false: icon came from Macro MvRequest backReq, foreReq; MvIconDataBase& dataBase = IconDataBase(); // Icon from a Macro if (calledFromMacro) { std::string name; - exclusive = false; + exclusive = false; bool foreground = foundDU; const char* layerMode = (const char*)coastRequest("MAP_LAYER_MODE"); @@ -1614,8 +1614,8 @@ // Set tags and update request names std::string fname; - fname = name + "(FG)"; - foreReq("_NAME") = fname.c_str(); + fname = name + "(FG)"; + foreReq("_NAME") = fname.c_str(); foreReq("_PLOTTING_ORDER") = "FOREGROUND"; } else { @@ -1672,7 +1672,7 @@ if ((const char*)backReq("_NAME")) name = (const char*)backReq("_NAME"); name += "(BG)"; - backReq("_NAME") = name.c_str(); + backReq("_NAME") = name.c_str(); backReq("_PLOTTING_ORDER") = "BACKGROUND"; return; @@ -1682,7 +1682,7 @@ // there is a sea/land shade to be drawn on the background. } else { - bool draw = false; + bool draw = false; const char* onoff = (const char*)req("MAP_COASTLINE_LAND_SHADE"); if (onoff && strcmp(onoff, "ON") == 0) draw = true; @@ -1694,13 +1694,13 @@ // Set Coastline to be drawn on the background if (draw) { // By default Boundaries, Cities and Rivers are plotted on the Foreground - backReq = req; + backReq = req; backReq("MAP_BOUNDARIES") = "OFF"; - backReq("MAP_CITIES") = "OFF"; - backReq("MAP_RIVERS") = "OFF"; + backReq("MAP_CITIES") = "OFF"; + backReq("MAP_RIVERS") = "OFF"; // Unset other drawings - backReq("MAP_GRID") = "OFF"; + backReq("MAP_GRID") = "OFF"; backReq("MAP_LABEL") = "OFF"; // Set background tag and update icon name @@ -1708,7 +1708,7 @@ if ((const char*)backReq("_NAME")) name = (const char*)backReq("_NAME"); name += "(BG)"; - backReq("_NAME") = name.c_str(); + backReq("_NAME") = name.c_str(); backReq("_PLOTTING_ORDER") = "BACKGROUND"; } } @@ -1723,7 +1723,7 @@ if (layerMode && strcmp(layerMode, "BACKGROUND") == 0) { return; - //The whole coastlines icon is rendered into the foreground + // The whole coastlines icon is rendered into the foreground } else if (layerMode && strcmp(layerMode, "FOREGROUND") == 0) { foreReq = req; @@ -1732,7 +1732,7 @@ name = std::string(nch); } name += "(FG)"; - foreReq("_NAME") = name.c_str(); + foreReq("_NAME") = name.c_str(); foreReq("_PLOTTING_ORDER") = "FOREGROUND"; // Split mode!!! @@ -1741,7 +1741,7 @@ // they were previously drawn on the Background by default. } else { - foreReq = req; + foreReq = req; const char* onoff = (const char*)req("MAP_COASTLINE_LAND_SHADE"); if (onoff && strcmp(onoff, "ON") == 0) foreReq("MAP_COASTLINE_LAND_SHADE") = "OFF"; @@ -1755,7 +1755,7 @@ if ((const char*)foreReq("_NAME")) name = (const char*)foreReq("_NAME"); name += "(FG)"; - foreReq("_NAME") = name.c_str(); + foreReq("_NAME") = name.c_str(); foreReq("_PLOTTING_ORDER") = "FOREGROUND"; } } @@ -1776,7 +1776,7 @@ // If icon is a coastline delete its companion MvRequest iconReq = icon.Request(); - std::string verb = (const char*)iconReq.getVerb(); + std::string verb = (const char*)iconReq.getVerb(); if (ObjectList::IsVisDefCoastlines(verb.c_str())) { // Get icon name std::string name = (const char*)iconReq("_NAME"); diff -Nru metview-5.17.4/metview/src/uPlot/Presentable.h metview-5.19.2/metview/src/uPlot/Presentable.h --- metview-5.17.4/metview/src/uPlot/Presentable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Presentable.h 2023-07-15 08:28:47.000000000 +0000 @@ -66,9 +66,9 @@ class Presentable; class ObjectInfo; -typedef std::map > DrawPriorMap; +using DrawPriorMap = std::map>; -typedef std::map MacroVisDefMap; +using MacroVisDefMap = std::map; enum { @@ -251,7 +251,7 @@ virtual void DrawChildren(); // Store the Layer info - virtual void DrawLayerInfo(const int, const char* name = 0); + virtual void DrawLayerInfo(const int, const char* name = nullptr); virtual void DrawText() {} @@ -413,7 +413,7 @@ virtual Page* InsertOnePage(MvRequest&) { // "Should not be here" << std::endl; - return 0; + return nullptr; } // Sets redrawing flags and does AddTask if needed @@ -423,7 +423,7 @@ // Dealing with Export plotting virtual bool ExportPlot(MvRequest*, bool = false) { return false; } - virtual MvRequest ExportToEcCharts() { return MvRequest(); } + virtual MvRequest ExportToEcCharts() { return {}; } // Dealing with Print plotting virtual void PrintFile(MvRequest&) {} @@ -457,9 +457,9 @@ Location myLocation_; // position of the presentable // Definition for the tree hierarchy of the Presentable class - typedef std::list MvChildList; - typedef std::list::iterator MvChildIterator; - typedef std::list::const_iterator MvChildConstIterator; + using MvChildList = std::list; + using MvChildIterator = std::list::iterator; + using MvChildConstIterator = std::list::const_iterator; MvChildList childList_; // list of children bool hasMatch_; // indicates that a object has been matched diff -Nru metview-5.17.4/metview/src/uPlot/Root.cc metview-5.19.2/metview/src/uPlot/Root.cc --- metview-5.17.4/metview/src/uPlot/Root.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Root.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,7 +23,7 @@ Root::Root() { - install_exit_proc(Root::ServerDead, 0); + install_exit_proc(Root::ServerDead, nullptr); } void Root::ServerDead(int, void*) @@ -39,7 +39,7 @@ bool Root::DefaultVisDefList(const char* className, MvIconList& visdefList, int ndim_flag, int type) { // Pre-condition - require(className != 0); + require(className != nullptr); visdefList.clear(); // visdefList should be empty // Get the default VisDef given its input class name @@ -59,14 +59,14 @@ std::string str = (const char*)ObjectList::DefaultVisDefClass(className); // Add all valid default visdefs to the list - size_t ip1, ip2, ip; + size_t ip1 = 0, ip2 = 0, ip = 0; ip1 = 0; do { // Get visdef name - ip = str.find('/', ip1); - ip2 = (ip != std::string::npos) ? (ip - ip1) : ip; + ip = str.find('/', ip1); + ip2 = (ip != std::string::npos) ? (ip - ip1) : ip; std::string str1 = str.substr(ip1, ip2); - ip1 = ip2 + 1; + ip1 = ip2 + 1; // Accept all valid visdefs if (!ObjectList::CheckValidVisDef(className, str1.c_str(), ndim_flag)) @@ -76,7 +76,7 @@ MvRequest visdefRequest = ObjectList::UserDefaultRequest(str1.c_str()); // Now we have all the information to create the VisDef - MvIcon newVisDef(visdefRequest, 1); + MvIcon newVisDef(visdefRequest, true); // Insert the visdef into the list visdefList.push_back(newVisDef); @@ -120,8 +120,8 @@ Presentable* Root::FindSuperPage(int index) { - Presentable* sp = 0; - int nr = NrOfChildren(); + Presentable* sp = nullptr; + int nr = NrOfChildren(); // Indicate to build a new superpage if (HasReceivedNewpage() || nr == 0 || index > (nr - 1)) { @@ -148,7 +148,7 @@ // Before deletion, make the parent point to NULL // This is necessary because otherwise the top // statement would generate a recursive call - (*child)->Parent(0); //Don't get called back + (*child)->Parent(nullptr); // Don't get called back // Create a temporary pointer to store the child's address Presentable* pt = (*child); @@ -235,7 +235,7 @@ // uPlot Contents manager). if (!modeClear) { MvRequest inReq = iconReq; - auto* sp = (SuperPage*)this->FindSuperPage(); + auto* sp = (SuperPage*)this->FindSuperPage(); sp->SortRequest(inReq, iconReq); } diff -Nru metview-5.17.4/metview/src/uPlot/Root.h metview-5.19.2/metview/src/uPlot/Root.h --- metview-5.17.4/metview/src/uPlot/Root.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Root.h 2023-07-15 08:28:47.000000000 +0000 @@ -63,12 +63,12 @@ // Create the instance static void Create() { - if (rootInstance_ == 0) + if (rootInstance_ == nullptr) rootInstance_ = new Root(); } // Destructor - ~Root() {} + ~Root() override = default; // Cleanup function static void ServerDead(int, void*); diff -Nru metview-5.17.4/metview/src/uPlot/SatelliteProjection.cc metview-5.19.2/metview/src/uPlot/SatelliteProjection.cc --- metview-5.17.4/metview/src/uPlot/SatelliteProjection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SatelliteProjection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ class SatelliteProjectionFactory : public PmProjectionFactory { - virtual PmProjection* Build(const MvRequest& reqst) + PmProjection* Build(const MvRequest& reqst) override { return new Satellite(reqst); } @@ -103,7 +103,7 @@ } /************************************************************************ - GEODETIC COORDINATES TO SATELLITE PROJECTION + GEODETIC COORDINATES TO SATELLITE PROJECTION *************************************************************************/ Point Satellite ::LL2PC(Point& ptll) { @@ -114,13 +114,13 @@ yla = (double)ptll.Y(); // Cartesian geocentric coordinates - xlo = xlo - SPlo0; - yla = yla - SPla0; + xlo = xlo - SPlo0; + yla = yla - SPla0; equad = 2. * Pflt - pow(Pflt, (double)2); - n = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)); - x = n * cos(yla) * cos(xlo); - y = n * cos(yla) * sin(xlo); - z = (n * (1 - equad)) * sin(yla); + n = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)); + x = n * cos(yla) * cos(xlo); + y = n * cos(yla) * sin(xlo); + z = (n * (1 - equad)) * sin(yla); // Field of view angles dp = atan(y / (SPrs - x)); @@ -130,11 +130,11 @@ if (x < 0.0) { col = MAXFLOAT; lin = MAXFLOAT; - return (Point(col, lin)); + return {col, lin}; } else { Rd2 = Prd * Prd; - Rm = Prd * (1 - Pflt); + Rm = Prd * (1 - Pflt); Rm2 = Rm * Rm; Rs2 = SPrs * SPrs; @@ -155,7 +155,7 @@ if (fabs(x - x1) > 1.0) { col = MAXFLOAT; lin = MAXFLOAT; - return (Point(col, lin)); + return {col, lin}; } } @@ -174,11 +174,11 @@ resy = tan(SPri) * (SPrs - Prd); // return (Point(col*resx,-(lin*resy))); - return (Point(col * resx, (SPnrows - lin) * resy)); + return {col * resx, (SPnrows - lin) * resy}; } /************************************************************************ - SATELLITE PROJECTION TO GEODETIC COORDINATES + SATELLITE PROJECTION TO GEODETIC COORDINATES ************************************************************************/ Point Satellite ::PC2LL(Point& ptpc) { @@ -207,7 +207,7 @@ // Cartesian coordinates Rd2 = Prd * Prd; - Rm = Prd * (1 - Pflt); + Rm = Prd * (1 - Pflt); Rm2 = Rm * Rm; Rs2 = SPrs * SPrs; @@ -223,7 +223,7 @@ // yla = MAXFLOAT; xlo = 90 * DEG_TO_RAD; yla = 180 * DEG_TO_RAD; - return (Point(xlo, yla)); + return {xlo, yla}; } x1 = (-b + sqrt(v)) / (2. * a); @@ -249,15 +249,15 @@ yla = asin(aux); do { - n = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)); + n = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)); yla = atan((z + n * equad * sin(yla)) / sqrt(x * x + y * y)); - d = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)) - n; + d = Prd / sqrt((double)1 - equad * pow(sin(yla), (double)2)) - n; } while (fabs(d) > 0.001); xlo = atan(y / x) + SPlo0; yla = yla + SPla0; - return (Point(xlo, yla)); + return {xlo, yla}; } void Satellite::CalculateProjectionCoord() @@ -265,10 +265,10 @@ double resx = tan(SPrj) * (SPrs - Prd); double resy = tan(SPri) * (SPrs - Prd); - Location projCoord(SPnrows * resy, //projUpperRight.Y(), - 0.0, //projLowerLeft.X(), - 0.0, //projLowerLeft.Y(), - SPncols * resx); //projUpperRight.X() ); + Location projCoord(SPnrows * resy, // projUpperRight.Y(), + 0.0, // projLowerLeft.X(), + 0.0, // projLowerLeft.Y(), + SPncols * resx); // projUpperRight.X() ); // Store the projection coordinates for later use projCoord_ = projCoord; diff -Nru metview-5.17.4/metview/src/uPlot/SatelliteProjection.h metview-5.19.2/metview/src/uPlot/SatelliteProjection.h --- metview-5.17.4/metview/src/uPlot/SatelliteProjection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SatelliteProjection.h 2023-07-15 08:28:47.000000000 +0000 @@ -49,21 +49,21 @@ class Satellite : public PmProjection { - double SPri; // IFOV along y axis (rad); - double SPrj; // IFOV along x axis (rad); - double SPis; // Sub-satellite Y coordinate (m); - double SPjs; // Sub-satellite X coordinate (m); - double SPla0; // Sub-satellite latitude (rad); - double SPlo0; // Sub-satellite longitude (rad); - double SPrs; // Radius of satellite orbit (m); - double SPscn; // Scanning mode: 0 (WE/NS), 1 (SN/EW) - double SPyaw; // Orientation or yaw angle (rad). - - int SProw0; // Image initial row - int SPcol0; // Map initial column - int SPnrows; // Input image rows - int SPncols; // Input image columns - int SPgrid; // Map Grid orientation + double SPri{0.}; // IFOV along y axis (rad); + double SPrj{0.}; // IFOV along x axis (rad); + double SPis{0.}; // Sub-satellite Y coordinate (m); + double SPjs{0.}; // Sub-satellite X coordinate (m); + double SPla0{0.}; // Sub-satellite latitude (rad); + double SPlo0{0.}; // Sub-satellite longitude (rad); + double SPrs{0.}; // Radius of satellite orbit (m); + double SPscn{0.}; // Scanning mode: 0 (WE/NS), 1 (SN/EW) + double SPyaw{0.}; // Orientation or yaw angle (rad). + + int SProw0{0}; // Image initial row + int SPcol0{0}; // Map initial column + int SPnrows{0}; // Input image rows + int SPncols{0}; // Input image columns + int SPgrid{0}; // Map Grid orientation Cached SPglobal; // IMAGE_SUBAREA_SELECTION (ON/OFF) @@ -72,7 +72,7 @@ Satellite(const MvRequest& reqst); // Empty constructor. - ~Satellite() {} + ~Satellite() override = default; // Empty destructor. friend bool operator==(Satellite& a, Satellite& b); @@ -261,7 +261,7 @@ // Updates the latitude of the first standard parallel. // Not implemented yet - virtual Point LL2PC(Point& p); + Point LL2PC(Point& p) override; // This implementation of a pure virtual method defined in // Projection transforms geodetic into Satellite projection // coordinates. @@ -274,7 +274,7 @@ // ([0,pi/2] or [0,-pi/2]) and a valid longitude // ([0,pi] or [0,-pi]). - virtual Point PC2LL(Point& p); + Point PC2LL(Point& p) override; // This implementation of a pure virtual method defined in // Projection transforms Satellite projection into geodetic // coordinates. @@ -286,7 +286,7 @@ // X and Y Satellite projection coordinates must be // both valid, within their typical range. - virtual void CalculateProjectionCoord(); + void CalculateProjectionCoord() override; // Calculate the bounding box in projection coordinates // (internal function ) // Input: @@ -294,9 +294,9 @@ // Output: // projCoord_ : bounding box in projection coordinates - virtual bool CheckGeodeticCoordinates(Location&); + bool CheckGeodeticCoordinates(Location&) override; - virtual double CheckOriginLongitude() + double CheckOriginLongitude() override { return OriginLongitude(); } diff -Nru metview-5.17.4/metview/src/uPlot/ShareTargets.cc metview-5.19.2/metview/src/uPlot/ShareTargets.cc --- metview-5.17.4/metview/src/uPlot/ShareTargets.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ShareTargets.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,7 @@ #include /* -------------------------------------------------- - * ShareTargetManager - the registry of share targets + * ShareTargetManager - the registry of share targets * -------------------------------------------------- */ ShareTargetManager* ShareTargetManager::instance_ = nullptr; @@ -39,7 +39,7 @@ } /* --------------------------------------------------------- - * ShareTarget - the base class of each type of share target + * ShareTarget - the base class of each type of share target * --------------------------------------------------------- */ ShareTarget::ShareTarget(const std::string& name, const std::string& icon) : @@ -52,14 +52,13 @@ } /* ------------------------------------------------------ - * GlobeShareTarget - specific share target for the globe + * GlobeShareTarget - specific share target for the globe * ------------------------------------------------------ */ //#ifdef MV_SHARE_GLOBE_BUILD GlobeShareTarget::GlobeShareTarget(QObject* parent) : QObject(parent), - ShareTarget("Weather Globe", "globe.svg"), - class_("GLOBE") + ShareTarget("Weather Globe", "globe.svg") { } @@ -111,14 +110,14 @@ // Get the prefix path (METVIEW_USER_DIRECTORY) and check it againt the filename std::string userDir = GetUserDirectory(); - std::string path = mdirname((const char*)reqOut("_NAME")); - std::size_t found = path.find(userDir); + std::string path = mdirname((const char*)reqOut("_NAME")); + std::size_t found = path.find(userDir); if (found != std::string::npos) path = path.substr(userDir.size()); // remove the prefix path // Compose the filename std::string filename = path + '/' + name; - reqOut("_NAME") = filename.c_str(); + reqOut("_NAME") = filename.c_str(); // Call Metview user interface's editor CallGenAppService(*this, &GlobeShareTarget::edited, reqOut); @@ -150,9 +149,9 @@ } // Read input parameters from the dialog - out_fname_ = (const char*)reqUser("OUTPUT_GLOBE_FILE_NAME"); + out_fname_ = (const char*)reqUser("OUTPUT_GLOBE_FILE_NAME"); out_image_width_ = (int)reqUser("OUTPUT_GLOBE_IMAGE_WIDTH"); - out_frame_rate_ = (const char*)reqUser("OUTPUT_GLOBE_FRAME_RATE"); + out_frame_rate_ = (const char*)reqUser("OUTPUT_GLOBE_FRAME_RATE"); // Create a temporary directory to store the animation files // This directory will be deleted at the end @@ -208,13 +207,13 @@ reqPlot_("SUPER_PAGE_Y_LENGTH") = 50; } else if (strcmp(reqPlot_.getVerb(), "PAGE") == 0) { - reqPlot_("PAGE_X_LENGTH") = 100; - reqPlot_("PAGE_Y_LENGTH") = 50; + reqPlot_("PAGE_X_LENGTH") = 100; + reqPlot_("PAGE_Y_LENGTH") = 50; reqPlot_("PAGE_X_POSITION") = 0; reqPlot_("PAGE_Y_POSITION") = 0; - reqPlot_("SUBPAGE_X_LENGTH") = 100; - reqPlot_("SUBPAGE_Y_LENGTH") = 50; + reqPlot_("SUBPAGE_X_LENGTH") = 100; + reqPlot_("SUBPAGE_Y_LENGTH") = 50; reqPlot_("SUBPAGE_X_POSITION") = 0; reqPlot_("SUBPAGE_Y_POSITION") = 0; } @@ -226,10 +225,10 @@ std::string fullfname = tmp_path_ + "/" + out_fname_ + ".png"; MvRequest devReq("PNGOUTPUT"); devReq("OUTPUT_FULLNAME") = (const char*)(fullfname.c_str()); - devReq("OUTPUT_WIDTH") = out_image_width_; + devReq("OUTPUT_WIDTH") = out_image_width_; // devReq("OUTPUT_NAME_FIRST_PAGE_NUMBER") = "OFF"; MvRequest outReq("PRINTER_MANAGER"); - outReq("DESTINATION") = MVFILE; + outReq("DESTINATION") = MVFILE; outReq("OUTPUT_DEVICES") = devReq; reqPlot_ = outReq + reqPlot_; @@ -239,7 +238,7 @@ { // Define output and input filenames std::string out_fullname = out_dir_ + "/" + out_fname_ + ".mp4"; - std::string in_fname = tmp_path_ + "/" + out_fname_ + "*.png"; + std::string in_fname = tmp_path_ + "/" + out_fname_ + "*.png"; // Call external function to create the animation std::string cmd = "ffmpeg -y -framerate " + out_frame_rate_ + " -f image2 -pattern_type glob -i \'"; diff -Nru metview-5.17.4/metview/src/uPlot/ShareTargets.h metview-5.19.2/metview/src/uPlot/ShareTargets.h --- metview-5.17.4/metview/src/uPlot/ShareTargets.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ShareTargets.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,8 @@ virtual std::string& name() { return name_; } virtual std::string& icon() { return icon_; } - virtual bool dialog(MvRequest&, MvQProgressManager* pm = 0) = 0; - virtual void customisePlotRequest() = 0; + virtual bool dialog(MvRequest&, MvQProgressManager* pm = nullptr) = 0; + virtual void customisePlotRequest() = 0; protected: MvRequest reqPlot_; // plotting requests @@ -47,7 +47,7 @@ class ShareTargetManager : public std::vector { public: - ShareTargetManager() {} + ShareTargetManager() = default; ~ShareTargetManager(); static ShareTargetManager* instance(); @@ -67,24 +67,24 @@ Q_OBJECT public: - GlobeShareTarget(QObject* parent = 0); - ~GlobeShareTarget(); + GlobeShareTarget(QObject* parent = nullptr); + ~GlobeShareTarget() override; - bool dialog(MvRequest&, MvQProgressManager* pm = 0); + bool dialog(MvRequest&, MvQProgressManager* pm = nullptr) override; void edited(MvRequest&); - void customisePlotRequest(); + void customisePlotRequest() override; public slots: bool upload(); void fileChanged(const QString&); private: - std::string class_; // class name ("GLOBE") + std::string class_{"GLOBE"}; std::string tmp_path_; // temporary path where the png files will be generated std::string out_dir_; // directory where the output file mp4 will be created std::string out_fname_; // output file name std::string out_frame_rate_; // output frame rate - int out_image_width_; // output image width + int out_image_width_{256}; // output image width }; //#endif diff -Nru metview-5.17.4/metview/src/uPlot/SimpleDecoder.cc metview-5.19.2/metview/src/uPlot/SimpleDecoder.cc --- metview-5.17.4/metview/src/uPlot/SimpleDecoder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SimpleDecoder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ class SimpleDecoderFactory : public DecoderFactory { // Virtual Constructor - Builds a new SimpleDecoder - virtual Decoder* Build(const MvRequest& inRequest) + Decoder* Build(const MvRequest& inRequest) override { return new SimpleDecoder(inRequest); } @@ -37,7 +37,7 @@ Decoder(dataUnitRequest) { metadataRequest_ = dataUnitRequest; - nextData_ = true; + nextData_ = true; } SimpleDecoder::~SimpleDecoder() = default; diff -Nru metview-5.17.4/metview/src/uPlot/SimpleDecoder.h metview-5.19.2/metview/src/uPlot/SimpleDecoder.h --- metview-5.17.4/metview/src/uPlot/SimpleDecoder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SimpleDecoder.h 2023-07-15 08:28:47.000000000 +0000 @@ -48,13 +48,13 @@ SimpleDecoder(const MvRequest& inRequest); // Destructor - virtual ~SimpleDecoder(); + ~SimpleDecoder() override; // Overridden methods from Decoder class // Returns true first time it's called - virtual bool ReadNextData(); + bool ReadNextData() override; - virtual MatchingInfo CreateMatchingInfo(); + MatchingInfo CreateMatchingInfo() override; private: // No copy allowed diff -Nru metview-5.17.4/metview/src/uPlot/SkipAction.h metview-5.19.2/metview/src/uPlot/SkipAction.h --- metview-5.17.4/metview/src/uPlot/SkipAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SkipAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -46,11 +46,11 @@ PlotModAction(name) {} // Destructor - ~SkipAction() {} + ~SkipAction() override = default; // Methods static PlotModAction& Instance(); // Overriden from Base Class (PlotModAction) - virtual void Execute(PmContext& context); + void Execute(PmContext& context) override; }; diff -Nru metview-5.17.4/metview/src/uPlot/Spline.cc metview-5.19.2/metview/src/uPlot/Spline.cc --- metview-5.17.4/metview/src/uPlot/Spline.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Spline.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,10 +18,10 @@ xp_(x), yp_(y) { assert(xp_.size() == yp_.size()); - assert(xp_.size() >= 2); //we need at least 3 points for a cubic spline + assert(xp_.size() >= 2); // we need at least 3 points for a cubic spline size_t n = x.size(); - //points must be sorted by xp!!! + // points must be sorted by xp!!! // creates the tridiagonal matrix to be solved std::vector lower(n, 0.); @@ -35,18 +35,18 @@ h[i] = xp_[i] - xp_[i - 1]; } - lower[0] = 0.; - lower[n - 1] = 0.; - upper[0] = 0.; - upper[n - 1] = 0.; - diagonal[0] = 2.; + lower[0] = 0.; + lower[n - 1] = 0.; + upper[0] = 0.; + upper[n - 1] = 0.; + diagonal[0] = 2.; diagonal[n - 1] = 2.; for (size_t i = 1; i < n - 1; i++) { - lower[i] = h[i] / 3.; - upper[i] = h[i + 1] / 3.; + lower[i] = h[i] / 3.; + upper[i] = h[i + 1] / 3.; diagonal[i] = 2.0 * (h[i + 1] + h[i]) / 3.0; - rhs[i] = ((yp_[i + 1] - yp_[i]) / h[i + 1] - (yp_[i] - yp_[i - 1]) / h[i]); + rhs[i] = ((yp_[i + 1] - yp_[i]) / h[i + 1] - (yp_[i] - yp_[i - 1]) / h[i]); } // compute the spline coefficients @@ -60,7 +60,7 @@ coeffC_[i] = (yp_[i + 1] - yp_[i]) / h[i + 1] - (2.0 * coeffB_[i] + coeffB_[i + 1]) * h[i + 1] / 3.; } - double vh = h[n - 1]; + double vh = h[n - 1]; coeffA_[n - 1] = 0.0; coeffC_[n - 1] = 3.0 * coeffA_[n - 2] * vh * vh + 2.0 * coeffB_[n - 2] * vh + coeffC_[n - 2]; } @@ -72,7 +72,7 @@ return 0.; } - int idx = -1; + int idx = -1; const double delta = 1E-5; if (fabs(x - xp_[0]) < delta) { idx = 0; @@ -118,10 +118,10 @@ X = P; // Forward pass - int i = 0; + int i = 0; double denominator = b[i]; - P[i] = -c[i] / denominator; - Q[i] = d[i] / denominator; + P[i] = -c[i] / denominator; + Q[i] = d[i] / denominator; for (i = 1; i < n; i++) { denominator = b[i] + a[i] * P[i - 1]; if (fabs(denominator) < SMALL) @@ -143,7 +143,7 @@ const std::vector& yp) { assert(xp.size() == yp.size()); - assert(xp.size() >= 2); //we need at least 3 points for a cubic spline + assert(xp.size() >= 2); // we need at least 3 points for a cubic spline std::vector t(xp.size()); for (size_t i = 0; i < t.size(); i++) { diff -Nru metview-5.17.4/metview/src/uPlot/Spline.h metview-5.19.2/metview/src/uPlot/Spline.h --- metview-5.17.4/metview/src/uPlot/Spline.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Spline.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,7 +15,7 @@ class Spline { public: - Spline() {} + Spline() = default; Spline(const std::vector& x, const std::vector& y); double eval(double x) const; @@ -37,7 +37,7 @@ class SplineParam { public: - SplineParam() {} + SplineParam() = default; SplineParam(const std::vector& x, const std::vector& y); diff -Nru metview-5.17.4/metview/src/uPlot/SubPage.cc metview-5.19.2/metview/src/uPlot/SubPage.cc --- metview-5.17.4/metview/src/uPlot/SubPage.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SubPage.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ SubPage::SubPage(MvRequest& subpageRequest) : Presentable(subpageRequest), - subpageCanvas_(0), + subpageCanvas_(nullptr), visitInBackground_(false), hasTitleDraw_(false) { @@ -35,7 +35,7 @@ long offset2, const MatchingInfo& dataInfo) : Presentable(subpageRequest), - subpageCanvas_(0), + subpageCanvas_(nullptr), visitInBackground_(false), hasTitleDraw_(false) { @@ -44,7 +44,7 @@ // Create a new DataObject Presentable* dataObj = new DataObject(dataunitId, offset, offset2, dataInfo.Request()); - ensure(dataObj != 0); + ensure(dataObj != nullptr); // Insert the data object as a child of the subpage this->Insert(dataObj); @@ -55,7 +55,7 @@ SubPage::SubPage(const SubPage& old) : Presentable(old), - subpageCanvas_(0), + subpageCanvas_(nullptr), visitInBackground_(false), hasTitleDraw_(false) { @@ -79,7 +79,7 @@ void SubPage::InsertDataUnit(int dataunitId, long offset, long offset2, const MatchingInfo& dataInfo) { // If data unit already exists -> append it. - DataObject* dob = 0; + DataObject* dob = nullptr; MvChildIterator child; for (child = childList_.begin(); child != childList_.end(); ++child) { dob = (DataObject*)(*child); @@ -90,7 +90,7 @@ // New Data Unit // Create a data object which will store ONE field Presentable* dataObj = new DataObject(dataunitId, offset, offset2, dataInfo.Request()); - ensure(dataObj != 0); + ensure(dataObj != nullptr); // Put the data object into the subpage this->Insert(dataObj); @@ -108,7 +108,7 @@ void SubPage::RemoveIcon(MvIcon& icon) { - DataObject* dataObj = 0; + DataObject* dataObj = nullptr; MvChildIterator child; Canvas& canvas = this->GetCanvas(); @@ -121,13 +121,13 @@ } else if (ObjectList::IsDataUnit(verb)) { MvIconDataBase& iconDataBase = this->IconDataBase(); - child = childList_.begin(); + child = childList_.begin(); while (child != childList_.end()) { dataObj = (DataObject*)(*child); MvIcon dataUnit; MvChildIterator foundChild; - //iconDataBase.RetrieveDataUnit( dataObj->DataUnitId(), dataUnit); + // iconDataBase.RetrieveDataUnit( dataObj->DataUnitId(), dataUnit); iconDataBase.RetrieveIconFromList(DB_DATAUNIT, dataObj->DataUnitId(), dataUnit); if (dataUnit.Id() == icon.Id() || dataUnit.ParentId() == icon.Id()) { @@ -136,7 +136,7 @@ // dataObj->EraseDraw(); if (myParent_->RemoveData()) iconDataBase.RemoveDataUnitFromPresRel(dataUnit, this->Id()); - //D canvas.RemoveForAll ( this->Id (),"999TITLETEXT" ); + // D canvas.RemoveForAll ( this->Id (),"999TITLETEXT" ); if (myParent_->RemoveData()) childList_.erase(foundChild); } @@ -160,10 +160,10 @@ DrawPriorMap::iterator j; - DataObject* dataObj = 0; + DataObject* dataObj = nullptr; MvChildIterator child; for (child = childList_.begin(); child != childList_.end(); ++child) { - dataObj = (DataObject*)(*child); + dataObj = (DataObject*)(*child); DrawPriorMap tmpDrawPriorMap = dataObj->DrawPriority(); for (j = tmpDrawPriorMap.begin(); j != tmpDrawPriorMap.end(); ++j) drawPriorMap->insert(*j); @@ -228,7 +228,7 @@ // FAMI 29/09/2010 Review Paper page number algorithm // int paperPageNumber = myParent_->PaperPageNumber ( this->Id() ); -#if 0 ///SYLVIE +#if 0 /// SYLVIE if ( paperPageNumber == -1 ) { HasDrawTask ( false ); @@ -242,7 +242,7 @@ this->DrawPageHeader (); // Use incremented PaperPageIndex } } -#endif //SYLVIE +#endif // SYLVIE // Retrieve the graphics engine GraphicsEngine& ge = this->GetGraphicsEngine(); @@ -398,7 +398,7 @@ // Draw all texts MvListCursor vdCursor; for (vdCursor = textList.begin(); vdCursor != textList.end(); ++vdCursor) { - MvIcon oneIcon = *(vdCursor); + MvIcon oneIcon = *(vdCursor); MvRequest textRequest = oneIcon.Request(); // Draw the layer @@ -424,7 +424,7 @@ // Draw legend MvRequest legRequest = legIcon.Request(); - GraphicsEngine& ge = this->GetGraphicsEngine(); + GraphicsEngine& ge = this->GetGraphicsEngine(); ge.Draw(legRequest, true); } @@ -443,7 +443,7 @@ MvListCursor vdCursor; for (vdCursor = importList.begin(); vdCursor != importList.end(); ++vdCursor) { MvIcon oneIcon = *(vdCursor); - MvRequest req = oneIcon.Request(); + MvRequest req = oneIcon.Request(); // Draw the layer DrawLayerInfo((int)req("_ID")); @@ -473,7 +473,7 @@ this->PendingDrawingsAdd(); } -void SubPage::DrawTrailer() //CHECK IF THIS IS STILL NEEDED +void SubPage::DrawTrailer() // CHECK IF THIS IS STILL NEEDED { // Retrieve the graphics engine // GraphicsEngine& ge = this->GetGraphicsEngine(); @@ -500,17 +500,17 @@ Canvas& SubPage::GetCanvas() const { - ensure(subpageCanvas_ != 0); + ensure(subpageCanvas_ != nullptr); // Select this presentable sector in the canvas - //D subpageCanvas_->PresentableId ( presentableId_ ); + // D subpageCanvas_->PresentableId ( presentableId_ ); return *subpageCanvas_; } bool SubPage::CheckCanvas() { - return (subpageCanvas_ != 0 ? true : false); + return (subpageCanvas_ != nullptr ? true : false); } #if 0 @@ -561,8 +561,8 @@ { // Canvas& canvas = this->GetCanvas (); - //U return ( canvas.ShowPresentableId () == this->Id () ); - return true; //U revise this function later + // U return ( canvas.ShowPresentableId () == this->Id () ); + return true; // U revise this function later } #if 0 @@ -618,7 +618,7 @@ if (generate) { struct timeval t; gettimeofday(&t, nullptr); - id = t.tv_sec + t.tv_usec; + id = t.tv_sec + t.tv_usec; pictureIdMap_[typeName] = id; } else { @@ -667,10 +667,10 @@ return true; MvIconDataBase& dataBase = IconDataBase(); - bool found = false; + bool found = false; for (auto& child : childList_) { // Get dataUnit object - auto* dataObj = (DataObject*)child; + auto* dataObj = dynamic_cast(child); // Get corresponding dataunit icon from the DataBase MvIcon currentdu; diff -Nru metview-5.17.4/metview/src/uPlot/SubPage.h metview-5.19.2/metview/src/uPlot/SubPage.h --- metview-5.17.4/metview/src/uPlot/SubPage.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SubPage.h 2023-07-15 08:28:47.000000000 +0000 @@ -57,7 +57,7 @@ Presentable* Clone() const override { return new SubPage(*this); } // Destructor - ~SubPage(); + ~SubPage() override; // Methods // Overriden from Presentable class @@ -81,7 +81,7 @@ void DrawPageHeader() override; // Finalize drawing - void DrawTrailer() override; //CHECK IF THIS IS STILL NEEDED + void DrawTrailer() override; // CHECK IF THIS IS STILL NEEDED void DrawTrailerWithReq(MvRequest&) override; // Accept a visitor @@ -118,11 +118,11 @@ void SetVisibility(bool) override; bool IsVisible() override; - //virtual void DescribeData ( MvRequest& ); - // Add to request SubPage dataunit icons with dataobject requests + // virtual void DescribeData ( MvRequest& ); + // Add to request SubPage dataunit icons with dataobject requests - //virtual Cached DescribeMatchingInfo (); - // Describes Matching info in the "DATE TIME LEVEL PARAM" format + // virtual Cached DescribeMatchingInfo (); + // Describes Matching info in the "DATE TIME LEVEL PARAM" format // Check if there is any Visdef associated with the input Dataunit. // This also includes Visdefs that are associated with the children of the Dataunit. @@ -139,6 +139,6 @@ bool visitInBackground_; bool hasTitleDraw_; - typedef std::map PictureIdMap; + using PictureIdMap = std::map; PictureIdMap pictureIdMap_; // for synchronization problems }; diff -Nru metview-5.17.4/metview/src/uPlot/SuperPage.cc metview-5.19.2/metview/src/uPlot/SuperPage.cc --- metview-5.17.4/metview/src/uPlot/SuperPage.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SuperPage.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,7 +29,7 @@ int SuperPage::nrSuperPages_ = 0; #ifndef NOMETVIEW_QT -uPlotBase* SuperPage::plotApplication_ = 0; +uPlotBase* SuperPage::plotApplication_ = nullptr; #endif SuperPage::SuperPage(const MvRequest& superpageRequest) : @@ -61,9 +61,9 @@ MvRequest newpageRequest = pagesRequest.justOneRequest(); // Create a new page - //Presentable* page = new Page ( newpageRequest ); + // Presentable* page = new Page ( newpageRequest ); Page* page = new Page(newpageRequest); - ensure(page != 0); + ensure(page != nullptr); // Insert the page in the superpage's child list this->InsertOnePageInner(page); @@ -73,11 +73,11 @@ } // Store my size - double width = superpageRequest("CUSTOM_WIDTH"); + double width = superpageRequest("CUSTOM_WIDTH"); double height = superpageRequest("CUSTOM_HEIGHT"); if (width <= 0 || height <= 0) { // default A4 landscape - width = 29.7; + width = 29.7; height = 21.0; } size_ = PaperSize(width, height); @@ -132,7 +132,7 @@ { nrSuperPages_--; - //This code was disabled for METV-2744 + // This code was disabled for METV-2744 #if 0 // If called from macro, we don't need to keep PlotMod artificially alive any more. if (nrSuperPages_ == 0 && !PlotMod::Instance().IsInteractive()) @@ -163,8 +163,8 @@ MvRequest pageReply("DROP"); pageReply.setValue("DROP_ID", (*child)->Id()); - //If the superpage has been called from a Macro, - // then it needs to ask Macro to notify when finished. + // If the superpage has been called from a Macro, + // then it needs to ask Macro to notify when finished. if (PlotMod::Instance().CalledFromMacro() && k++ == 0) pageReply("_NOTIFY") = "NEWPAGE"; @@ -207,7 +207,7 @@ // Icons dropped in the Super Page. // Icons not handled here will be send to // the children (e.g. dataunit) - bool vdReplace = true; + bool vdReplace = true; MvRequest dropRequest = context.InRequest(); MvRequest remainingReq; while (dropRequest) { @@ -368,8 +368,8 @@ MvRequest sp("SUPERPAGE"); sp("SUPER_PAGE_X_LENGTH") = size_.GetWidth(); sp("SUPER_PAGE_Y_LENGTH") = size_.GetHeight(); - sp("_ID") = temp.Id(); - sp("_PRESENTABLE_ID") = this->Id(); + sp("_ID") = temp.Id(); + sp("_PRESENTABLE_ID") = this->Id(); fullReq += sp; // Get all page requests @@ -394,10 +394,10 @@ // Build pairs MvIconDataBase& dataBase = this->IconDataBase(); - bool sorted = true; - int index = 0; - float order = -1.; - float delta = 0.001; + bool sorted = true; + int index = 0; + float order = -1.; + float delta = 0.001; const std::string slayer("LAYER"); in.rewind(); while (in) { @@ -412,7 +412,7 @@ // Remove this code when Magics starting using _PRESENTABLE_ID and _ID properly. if ((const char*)req("_PRESENTABLE_ID")) { // Create a new pair - order = order + delta; + order = order + delta; mymap[order] = index; // Next interation @@ -450,7 +450,7 @@ // If it is not available, e.g. value=-1, then apply a computed value, // which should allow this request to retain its position in the stack. int stack = dataBase.IconStackingOrder(req("_ID")); - order = (stack != -1) ? (float)stack : order + delta; + order = (stack != -1) ? (float)stack : order + delta; // Create a new pair mymap[order] = index; @@ -470,15 +470,15 @@ } // First check: if there is a need to sort the input request - if (sorted) { + if (sorted && !mymap.empty()) { // It means that all icons have visibility tag = true, // but still needs to check if the stacking order has changed. - int index1, index2; - it = mymap.begin(); + int index1 = 0; + it = mymap.begin(); index1 = it->second; it++; while (it != mymap.end()) { - index2 = it->second; + int index2 = it->second; if (index2 < index1) { sorted = false; break; @@ -510,7 +510,7 @@ // Build an output request sorted by the plotting order out.clean(); - int i; + int i = 0; for (it = mymap.begin(); it != mymap.end(); ++it) { // Position the list of requests to the target one in.rewind(); @@ -672,7 +672,7 @@ std::string SuperPage::MacroPlotIndexName(bool useIndex) { - int index; + int index = 0; if (useIndex) index = pageIndex_++; else @@ -732,7 +732,7 @@ skipSet); // Print the page list - int size = myDescription.MaximumParameterNameLength(myRequest_); + int size = myDescription.MaximumParameterNameLength(myRequest_); std::string pageList = ListMyPages(); myDescription.FormatLine("PAGES", pageList.c_str(), "", size); @@ -986,7 +986,7 @@ // Create printer request MvRequest printerReq("PRINTER_MANAGER"); - printerReq("DESTINATION") = MVFILE; + printerReq("DESTINATION") = MVFILE; printerReq("OUTPUT_DEVICES") = inReq; // Redraw in order to get the latest icon status (transparency, @@ -1005,18 +1005,18 @@ // Call uPlotBatch (syncronous or asyncronous) to do the job if (sync) { - int err; + int err = 0; MvApplication::waitService("uPlotBatch", newReq, err); if (err) return false; } else - MvApplication::callService("uPlotBatch", newReq, 0); + MvApplication::callService("uPlotBatch", newReq, nullptr); return true; } -//typedef std::map ecVisDefMap; +// typedef std::map ecVisDefMap; MvRequest SuperPage::ExportToEcCharts() @@ -1046,7 +1046,7 @@ while (plotReq) { // Process Visdefs MvRequest request = plotReq.justOneRequest(); - const char* verb = request.getVerb(); + const char* verb = request.getVerb(); if (ObjectList::IsVisDef(verb) || ObjectList::IsVisDefText(verb) || ObjectList::IsVisDefLegend(verb) || @@ -1059,8 +1059,8 @@ // Formula, Simple Formula, Grib Filter, ... else if (ObjectList::IsDataUnit(verb) || strcmp(verb, "PGRIB") == 0) { - ecReq = ecReq + request; - std::string iclass = (const char*)ObjectInfo::IconClass(request); + ecReq = ecReq + request; + std::string iclass = (const char*)ObjectInfo::IconClass(request); std::string fileName = ObjectInfo::FileName(request); if (!IsBinaryOrMissingFile(fileName.c_str())) { MvRequest fileReq; @@ -1103,7 +1103,7 @@ driverReq("OUTPUT_PDF_SCALE") = 0.96; // Create printer request - MvRequest printerReq = req; + MvRequest printerReq = req; printerReq("OUTPUT_DEVICES") = driverReq; // Redraw in order to get the latest icon status (transparency, @@ -1121,7 +1121,7 @@ MvRequest newReq = printerReq + fullReq; // Call uPlotBatch to do the job - MvApplication::callService("uPlotBatch", newReq, 0); + MvApplication::callService("uPlotBatch", newReq, nullptr); return; } @@ -1134,7 +1134,7 @@ // Check if the request is a PAGE request // If it does not exist, create one PAGE request const char* pageVerb = pagesRequest.getVerb(); - if (strcmp(pageVerb, PLOTPAGE)) + if (strcmp(pageVerb, PLOTPAGE) != 0) pagesRequest = ObjectList::CreateDefaultRequest("PLOT_PAGE"); // Create a new Page @@ -1144,7 +1144,7 @@ // Create a new page Page* page = new Page(newpageRequest); - ensure(page != 0); + ensure(page != nullptr); // Insert the page in the superpage's child list this->InsertOnePageInner(page); diff -Nru metview-5.17.4/metview/src/uPlot/SuperPage.h metview-5.19.2/metview/src/uPlot/SuperPage.h --- metview-5.17.4/metview/src/uPlot/SuperPage.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/SuperPage.h 2023-07-15 08:28:47.000000000 +0000 @@ -60,7 +60,7 @@ Presentable* Clone() const override { return new SuperPage(*this); } // Destructor - ~SuperPage(); + ~SuperPage() override; // Methods // Overriden from Presentable class @@ -76,7 +76,7 @@ bool PrintAll() override; // Return my Name - virtual std::string Name() override; + std::string Name() override; // virtual Cached SuperPageName() // { return this->Name(); } @@ -103,7 +103,7 @@ void DrawProlog() override; void DrawTrailerWithReq(MvRequest&) override; - bool IsVisible() override {return true;} + bool IsVisible() override { return true; } // Implements the visitor pattern void Visit(Visitor& v) override; @@ -160,7 +160,7 @@ bool RetrieveLegend(MvIcon&) override; // Zoom methods - //virtual void ZoomRequest ( int id, const Location& zoomCoord ); + // virtual void ZoomRequest ( int id, const Location& zoomCoord ); void ZoomRequestByDef(int id, const std::string&) override; void ZoomRequestByLevel(int id, int izoom) override; diff -Nru metview-5.17.4/metview/src/uPlot/Task.h metview-5.19.2/metview/src/uPlot/Task.h --- metview-5.17.4/metview/src/uPlot/Task.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Task.h 2023-07-15 08:28:47.000000000 +0000 @@ -52,7 +52,7 @@ class TaskBase; -typedef std::list PendingTaskList; +using PendingTaskList = std::list; class TaskBase { @@ -96,7 +96,7 @@ class Task : public TaskBase { T& calledObject_; - typedef void (T::*Procedure)(); + using Procedure = void (T::*)(); Procedure calledProc_; public: @@ -105,7 +105,7 @@ calledProc_(proc) {} // Execute - calls object->procedure - virtual void Execute() + void Execute() override { (calledObject_.*calledProc_)(); } diff -Nru metview-5.17.4/metview/src/uPlot/ThermoView.cc metview-5.19.2/metview/src/uPlot/ThermoView.cc --- metview-5.17.4/metview/src/uPlot/ThermoView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ThermoView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,8 @@ #include "MvLog.h" // Thermo types -static const std::string THERMOTEPHI = "TEPHIGRAM"; -static const std::string THERMOSKEWT = "SKEW_T"; +static const std::string THERMOTEPHI = "TEPHIGRAM"; +static const std::string THERMOSKEWT = "SKEW_T"; static const std::string THERMOEMAGRAM = "EMAGRAM"; // Thermo data types @@ -26,7 +26,7 @@ std::map m; m["GRIB"] = "GRIB_THERMO"; m["BUFR"] = "BUFR_THERMO"; - m["ODB"] = "ODB_THERMO"; + m["ODB"] = "ODB_THERMO"; return m; } @@ -69,7 +69,7 @@ string ThermoView::Name() { - int id = Owner().Id(); + int id = Owner().Id(); std::string name = (const char*)ObjectInfo::ObjectName(viewRequest_, "ThermoView", id); return name; @@ -132,15 +132,15 @@ // copy the remaining ones to the new View if ((const char*)viewRequest_("PAGE_FRAME") && strcmp((const char*)viewRequest_("PAGE_FRAME"), "OFF") == 0) - metview::RemoveParameters(viewRequest_, "PAGE_FRAME"); + metview::RemoveParameters(viewRequest_, "PAGE_FRAME"); if ((const char*)viewRequest_("PAGE_ID_LINE") && strcmp((const char*)viewRequest_("PAGE_ID_LINE"), "OFF") == 0) - metview::RemoveParameters(viewRequest_, "PAGE_ID_LINE"); + metview::RemoveParameters(viewRequest_, "PAGE_ID_LINE"); if ((const char*)viewRequest_("SUBPAGE_FRAME") && strcmp((const char*)viewRequest_("SUBPAGE_FRAME"), "OFF") == 0) - metview::RemoveParameters(viewRequest_, "SUBPAGE_FRAME"); + metview::RemoveParameters(viewRequest_, "SUBPAGE_FRAME"); metview::CopySomeParameters(viewRequest_, cartView, "PAGE"); metview::CopySomeParameters(viewRequest_, cartView, "SUBPAGE"); @@ -201,10 +201,10 @@ Root::Instance().Refresh(false); // Redraw this page - //Owner().RedrawIfWindow(); - //Owner().NotifyObservers(); + // Owner().RedrawIfWindow(); + // Owner().NotifyObservers(); - //Owner().InitZoomStacks(); + // Owner().InitZoomStacks(); return true; } @@ -235,7 +235,7 @@ // b) thermogrid: update the View // c) thermoview: update the View MvRequest dropRequest = context.InRequest(); - bool first = true; + bool first = true; while (dropRequest) { // Data unit std::string verb = dropRequest.getVerb(); @@ -276,12 +276,12 @@ } else { MvRequest gr("MTHERMOGRID"); - gr("THERMO_ISOTHERM_GRID") = "OFF"; - gr("THERMO_ISOBAR_GRID") = "OFF"; - gr("THERMO_DRY_ADIABATIC_GRID") = "OFF"; + gr("THERMO_ISOTHERM_GRID") = "OFF"; + gr("THERMO_ISOBAR_GRID") = "OFF"; + gr("THERMO_DRY_ADIABATIC_GRID") = "OFF"; gr("THERMO_SATURATED_ADIABATIC_GRID") = "OFF"; - gr("THERMO_MIXING_RATIO_GRID") = "OFF"; - viewRequest_("THERMO_GRID") = gr; + gr("THERMO_MIXING_RATIO_GRID") = "OFF"; + viewRequest_("THERMO_GRID") = gr; } } @@ -332,37 +332,37 @@ { // Build a list of parameters to be checked std::vector vparam; - vparam.push_back("POINT_SELECTION"); + vparam.emplace_back("POINT_SELECTION"); if ((const char*)req1("COORDINATES")) - vparam.push_back("COORDINATES"); + vparam.emplace_back("COORDINATES"); if ((const char*)req1("THRESHOLD")) - vparam.push_back("THRESHOLD"); + vparam.emplace_back("THRESHOLD"); if ((const char*)req1("AREA_AVERAGE")) - vparam.push_back("AREA_AVERAGE"); + vparam.emplace_back("AREA_AVERAGE"); if ((const char*)req1("STATION")) - vparam.push_back("STATION"); + vparam.emplace_back("STATION"); if ((const char*)req1("WMO_NAME")) - vparam.push_back("WMO_NAME"); + vparam.emplace_back("WMO_NAME"); if ((const char*)req1("WMO_IDENT")) - vparam.push_back("WMO_IDENT"); + vparam.emplace_back("WMO_IDENT"); if ((const char*)req1("WIGOS_SERIES")) - vparam.push_back("WIGOS_SERIES"); + vparam.emplace_back("WIGOS_SERIES"); if ((const char*)req1("WIGOS_ISSUER")) - vparam.push_back("WIGOS_ISSUER"); + vparam.emplace_back("WIGOS_ISSUER"); if ((const char*)req1("WIGOS_ISSUE_NUMBER")) - vparam.push_back("WIGOS_ISSUE_NUMBER"); + vparam.emplace_back("WIGOS_ISSUE_NUMBER"); if ((const char*)req1("WIGOS_LOCAL_NAME")) - vparam.push_back("WIGOS_LOCAL_NAME"); + vparam.emplace_back("WIGOS_LOCAL_NAME"); if ((const char*)req1("POINT_EXTRACTION")) - vparam.push_back("POINT_EXTRACTION"); + vparam.emplace_back("POINT_EXTRACTION"); - vparam.push_back("DEW_POINT_FORMULATION"); - vparam.push_back("TEMPERATURE_PARAM"); - vparam.push_back("SPECIFIC_HUMIDITY_PARAM"); - vparam.push_back("LNSP_PARAM"); - vparam.push_back("U_WIND_PARAM"); - vparam.push_back("V_WIND_PARAM"); + vparam.emplace_back("DEW_POINT_FORMULATION"); + vparam.emplace_back("TEMPERATURE_PARAM"); + vparam.emplace_back("SPECIFIC_HUMIDITY_PARAM"); + vparam.emplace_back("LNSP_PARAM"); + vparam.emplace_back("U_WIND_PARAM"); + vparam.emplace_back("V_WIND_PARAM"); // Check one by one because we want to know which one is different return req1.checkParameters(req2, vparam, param); diff -Nru metview-5.17.4/metview/src/uPlot/ThermoView.h metview-5.19.2/metview/src/uPlot/ThermoView.h --- metview-5.17.4/metview/src/uPlot/ThermoView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ThermoView.h 2023-07-15 08:28:47.000000000 +0000 @@ -66,7 +66,7 @@ ThermoView(const ThermoView&); PlotModView* Clone() const override { return new ThermoView(*this); } - ~ThermoView() {} + ~ThermoView() override = default; std::string Name() override; void DrawBackground() override {} diff -Nru metview-5.17.4/metview/src/uPlot/uPlotApp.cc metview-5.19.2/metview/src/uPlot/uPlotApp.cc --- metview-5.17.4/metview/src/uPlot/uPlotApp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/uPlotApp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ // InstallResources(); // Register this service - registerTMvServe(*this, 0, "_UPLOT_MANAGER_ID", true); + registerTMvServe(*this, nullptr, "_UPLOT_MANAGER_ID", true); } // Serve Method diff -Nru metview-5.17.4/metview/src/uPlot/uPlotBase.cc metview-5.19.2/metview/src/uPlot/uPlotBase.cc --- metview-5.17.4/metview/src/uPlot/uPlotBase.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/uPlotBase.cc 2023-07-15 08:28:47.000000000 +0000 @@ -81,7 +81,7 @@ #define PLACEMARK -Presentable* uPlotBase::owner_ = 0; +Presentable* uPlotBase::owner_ = nullptr; string uPlotBase::uPlotTempDir_ = ""; @@ -115,12 +115,12 @@ wroomSync_ = false; #endif - //Find out screen resolution + // Find out screen resolution int res = screenResolutionInDpi(); - //resize(1020,720); + // resize(1020,720); - oriPlotWidthInCm_ = -1.; + oriPlotWidthInCm_ = -1.; oriPlotHeightInCm_ = -1.; //--------------------- @@ -178,7 +178,7 @@ uPlotBase::~uPlotBase() { - owner_ = 0; + owner_ = nullptr; // Delete temporary directory Path path(tempDir()); @@ -187,17 +187,17 @@ void uPlotBase::setupViewActions() { - QAction* action; + QAction* action = nullptr; //------------------ // Resize //------------------ - //Plot size combo + // Plot size combo sizeCombo_ = new QComboBox; - sizeMinValue_ = 10; - sizeMaxValue_ = 200; + sizeMinValue_ = 10; + sizeMaxValue_ = 200; sizeValueStep_ = 10; predefSizeValues_ << uPlotBase::FitToWindow << uPlotBase::FitToWidth << uPlotBase::FitToHeight << 50 << 75 << 100 << 150 << 200; @@ -222,7 +222,7 @@ sizeCombo_->setItemData(sizeCombo_->count() - 1, val, Qt::UserRole); } - //sizeCombo_->setCurrentIndex(4); + // sizeCombo_->setCurrentIndex(4); action = new QAction(this); action->setText(tr("Decrease size")); @@ -255,7 +255,7 @@ void uPlotBase::setupZoomActions() { - //Zoom + // Zoom auto* actionZoom = new QAction(this); actionZoom->setObjectName(QString::fromUtf8("actionZoom")); actionZoom->setCheckable(true); @@ -263,29 +263,29 @@ icon.addPixmap(QPixmap(QString::fromUtf8(":/uPlot/zoom.svg")), QIcon::Normal, QIcon::Off); actionZoom->setIcon(icon); actionZoom->setText(tr("&Zoom")); - //controlActions_.push_back(actionZoom); + // controlActions_.push_back(actionZoom); - //Up + // Up actionZoomUp_ = new QAction(this); actionZoomUp_->setObjectName(QString::fromUtf8("actionZoomStackUp")); QIcon iconUp; iconUp.addPixmap(QPixmap(QString::fromUtf8(":/uPlot/zoom_out.svg")), QIcon::Normal, QIcon::Off); actionZoomUp_->setIcon(iconUp); - //actionUp->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp)); + // actionUp->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp)); actionZoomUp_->setText(tr("Zoom &out")); actionZoomUp_->setShortcut(tr("Ctrl+Up")); - //Down + // Down actionZoomDown_ = new QAction(this); actionZoomDown_->setObjectName(QString::fromUtf8("actionZoomStackUp")); QIcon iconDown; iconDown.addPixmap(QPixmap(QString::fromUtf8(":/uPlot/zoom_in.svg")), QIcon::Normal, QIcon::Off); actionZoomDown_->setIcon(iconDown); - //actionDown->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown)); + // actionDown->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown)); actionZoomDown_->setText(tr("Zoom &in")); actionZoomDown_->setShortcut(tr("Ctrl+Down")); - //Zoomstack + // Zoomstack auto* zoomStackPb = new QToolButton; QIcon icon11; icon11.addPixmap(QPixmap(QString::fromUtf8(":/uPlot/zoom_stack.svg")), QIcon::Normal, QIcon::Off); @@ -294,27 +294,27 @@ zoomStackPb->setPopupMode(QToolButton::InstantPopup); zoomStackPb->setObjectName("zoomStackPb"); - //QMenu *zoomStackMenu = new QMenu("&ZoomStack"); + // QMenu *zoomStackMenu = new QMenu("&ZoomStack"); zoomStackWidget_ = new MvQZoomStackWidget(plotScene_); - auto wa = new QWidgetAction(this); + auto wa = new QWidgetAction(this); wa->setDefaultWidget(zoomStackWidget_); zoomStackPb->addAction(wa); - //zoomStackPb->setMenu(zoomStackWidget_); + // zoomStackPb->setMenu(zoomStackWidget_); - //QWidgetAction *wa = new QWidgetAction(zoomStackMenu); - //wa->setDefaultWidget(zoomStackWidget_); - //zoomStackMenu->addAction(wa); + // QWidgetAction *wa = new QWidgetAction(zoomStackMenu); + // wa->setDefaultWidget(zoomStackWidget_); + // zoomStackMenu->addAction(wa); - //Zoomstack combo - //zoomStackWidget_ = new MvQZoomStackWidget(plotScene_); + // Zoomstack combo + // zoomStackWidget_ = new MvQZoomStackWidget(plotScene_); - //Separator - //QAction *actionSep=new QAction(this); - //actionSep->setSeparator(true); + // Separator + // QAction *actionSep=new QAction(this); + // actionSep->setSeparator(true); - //Zoom button + // Zoom button connect(actionZoom, SIGNAL(toggled(bool)), plotView_, SLOT(slotSetEnableZoom(bool))); @@ -336,7 +336,7 @@ menuItems_[menuType].push_back(new MvQMenuItem(actionZoom)); menuItems_[menuType].push_back(new MvQMenuItem(actionZoomUp_)); //!!! menuItems_[menuType].push_back(new MvQMenuItem(actionZoomDown_)); //!!! - //menuItems_["zoom"].push_back(new MvQMenuItem(actionSep)); + // menuItems_["zoom"].push_back(new MvQMenuItem(actionSep)); menuItems_[menuType].push_back(new MvQMenuItem(zoomStackPb)); } @@ -356,9 +356,9 @@ void uPlotBase::setupContextMenuActions() { - QAction* action; + QAction* action = nullptr; - //Up + // Up action = new QAction(this); action->setObjectName(QString::fromUtf8("actionContextZoomStackUp")); QIcon iconUp; @@ -368,7 +368,7 @@ action->setShortcut(tr("Ctrl+Up")); actionContextZoomUp_ = action; - //Down + // Down action = new QAction(this); action->setObjectName(QString::fromUtf8("actionContextZoomStackUp")); QIcon iconDown; @@ -382,7 +382,7 @@ action->setObjectName(QString::fromUtf8("actionContextSelectScene")); QIcon icon; icon.addPixmap(QPixmap(QString::fromUtf8(":/uPlot/player_play.svg")), QIcon::Normal, QIcon::Off); - //action->setIcon(icon); + // action->setIcon(icon); action->setText(tr("&Select as active scene")); actionContextSelectScene_ = action; } @@ -411,22 +411,22 @@ i++; tt.advance(); } - //COUT << "Number total resources = " << i << std::endl; + // COUT << "Number total resources = " << i << std::endl; } void uPlotBase::setPlot(float hor, float ver) { if (oriPlotWidthInCm_ < 0) { - oriPlotWidthInCm_ = hor; + oriPlotWidthInCm_ = hor; oriPlotHeightInCm_ = ver; } // Set drawing area size - //float hsize = floorf((75.*1./2.54) * hor); - //float vsize = floorf((75.*1./2.54) * ver); + // float hsize = floorf((75.*1./2.54) * hor); + // float vsize = floorf((75.*1./2.54) * ver); - //plotScene_->setSceneRect(0,0,hsize,vsize); - //plotView_->setMvPlotSize(hsize,vsize); + // plotScene_->setSceneRect(0,0,hsize,vsize); + // plotView_->setMvPlotSize(hsize,vsize); } void uPlotBase::slotProcessDropInView(const MvQDrop& drop, QPoint pos) @@ -443,7 +443,7 @@ sPageId = activeScene_->layout().id(); if (sPageId.empty()) { MgQLayoutItem* projItem = activeScene_->firstProjectorItem(); - sPageId = projItem->layout().id(); + sPageId = projItem->layout().id(); } } @@ -459,7 +459,7 @@ MvRequest subreq("DROP"); subreq("DROP_ID") = pageId; - subreq("DROP_X") = 12.; + subreq("DROP_X") = 12.; if (drop.iconNum() > 0) { subreq.setValue("ICON_NAME", drop.iconPath(0).toStdString().c_str()); @@ -469,7 +469,7 @@ } } - subreq("DROP_Y") = 4.2; + subreq("DROP_Y") = 4.2; subreq("_REGISTER_TRAILER") = 1; req("HEADER") = subreq; @@ -479,18 +479,18 @@ Presentable* pres = owner_->FindBranch(pageId); if (pres) { MvRequest reqView = pres->GetView().ViewRequest(); - req("_CONTEXT") = reqView; + req("_CONTEXT") = reqView; } - //Safety solution + // Safety solution else { MvRequest reqView = owner_->Request()("PAGES"); - reqView = reqView("VIEW"); - req("_CONTEXT") = reqView; + reqView = reqView("VIEW"); + req("_CONTEXT") = reqView; } } - //qDebug() << "DROP REQUEST"; - //req.print(); + // qDebug() << "DROP REQUEST"; + // req.print(); // Send drop request to the appropriate function emit sendDropRequest(&req); @@ -551,11 +551,11 @@ void uPlotBase::slotPerformZoom(const std::string& sid, const std::string& def) { - //Location stores the bottom-left,top-right corners. - //Its constructor is requeres the following order: - //top,left,bottom,right + // Location stores the bottom-left,top-right corners. + // Its constructor is requeres the following order: + // top,left,bottom,right - //Change active scene if needed before performing the zoom + // Change active scene if needed before performing the zoom if (activeScene_) { MgQLayoutItem* projItem = activeScene_->firstProjectorItem(); if (projItem && projItem->layout().id() != sid) { @@ -569,7 +569,7 @@ } } - //Location zoomCoord(tr_y,bl_x,bl_y,tr_x); + // Location zoomCoord(tr_y,bl_x,bl_y,tr_x); int id = QString(sid.c_str()).toInt(); owner_->ZoomRequestByDef(id, def); } @@ -577,17 +577,17 @@ void uPlotBase::slotStepCacheStateChanged() { - //Layer model will be reset since as new animation step is cached - //new layers might have added to the scene - //layerWidget_->model()->layersAreAboutToChange(); - - //Notify the scene about the unique layers's status. This will set the - //status of all the new layers to the correct values - //plotScene_->updateLayers(layerWidget_->model()->layers()); - - //Pass the new list of unique layers to the layer model andplacemark_ - //finish its resetting - //layerWidget_->model()->setLayers(plotScene_->uniqueLayers()); + // Layer model will be reset since as new animation step is cached + // new layers might have added to the scene + // layerWidget_->model()->layersAreAboutToChange(); + + // Notify the scene about the unique layers's status. This will set the + // status of all the new layers to the correct values + // plotScene_->updateLayers(layerWidget_->model()->layers()); + + // Pass the new list of unique layers to the layer model andplacemark_ + // finish its resetting + // layerWidget_->model()->setLayers(plotScene_->uniqueLayers()); } @@ -618,7 +618,7 @@ // Pops up a messagebox, which will start the execution of the // export request if (delayedExportDialogRequest_) { - //delayedExportDialogRequest_.print(); + // delayedExportDialogRequest_.print(); ExportMessageBox msgBox(this); msgBox.exec(); delayedExportDialogRequest_ = MvRequest(); @@ -723,7 +723,7 @@ // Define output device. Create a temporary file. wroomFormat_ = "pdf"; devReq.setVerb("PDFOUTPUT"); - std::string fName = marstmp(); + std::string fName = marstmp(); devReq("OUTPUT_FULLNAME") = fName.c_str(); } #endif @@ -757,8 +757,8 @@ jFile << " \"base_time\" : ["; for (i = 0; i < count; i++) { req.getValue(ddate, "DATE", i); - req.getValue(dtime, "TIME", i); //time format: HHMM - ddate += dtime / 2400; //fraction of 24hs + req.getValue(dtime, "TIME", i); // time format: HHMM + ddate += dtime / 2400; // fraction of 24hs MvDate date(ddate); date.Format("yyyy-mm-ddTHH:MM:SSZ", cbuf); jFile << "\"" << cbuf << "\""; @@ -847,7 +847,7 @@ painter.scale(1.,-1.); //plot directions: W->E and S->N plotScene_->render(&painter); -#else //lpr printing +#else // lpr printing QPrintDialog printDialog; QPrinter* pr = printDialog.printer(); @@ -876,19 +876,19 @@ // Get printer parameters std::string name = pr->printerName().toLocal8Bit().constData(); -//TODO: use proper enum instead of int! +// TODO: use proper enum instead of int! #if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0) - int orientation = pr->pageLayout().orientation(); //0-portrait, 1-landscape + int orientation = pr->pageLayout().orientation(); // 0-portrait, 1-landscape #else - int orientation = pr->orientation(); //0-portrait, 1-landscape + int orientation = pr->orientation(); // 0-portrait, 1-landscape #endif - int numCopies = pr->copyCount(); + int numCopies = pr->copyCount(); // Create printer request MvRequest printerReq("PRINTER_MANAGER"); - printerReq("DESTINATION") = MVPRINTER; - printerReq("PRINTER_NAME") = name.c_str(); - printerReq("ORIENTATION") = orientation; + printerReq("DESTINATION") = MVPRINTER; + printerReq("PRINTER_NAME") = name.c_str(); + printerReq("ORIENTATION") = orientation; printerReq("NUMBER_COPIES") = numCopies; // Get print range parameters @@ -926,7 +926,7 @@ // Process export calling Magics // Set the environment to upload the result later - MvRequest reqExp = setExportVariables(&delayedExportDialogRequest_); + MvRequest reqExp = setExportVariables(&delayedExportDialogRequest_); delayedExportDialogRequest_ = MvRequest(); // Ask my owner to recreate the plot and save it accordingly @@ -964,7 +964,7 @@ fn += "." + format; QSizeF sourceSize = plotScene_->sceneRect().size(); - auto sourceRatio = sourceSize.height() / sourceSize.width(); + auto sourceRatio = sourceSize.height() / sourceSize.width(); // Initialise output format object if (format == "pdf") { @@ -978,7 +978,7 @@ QPainter painter(&pdfWriter); painter.setRenderHint(QPainter::Antialiasing, true); painter.translate(0, painter.viewport().height()); - painter.scale(1., -1.); //plot directions: W->E and S->N + painter.scale(1., -1.); // plot directions: W->E and S->N #if 0 plotScene_->render(&painter); @@ -1019,11 +1019,11 @@ { if (!preq) { MvLog().popup().err() << "Export: Internal Error: empty Display Window"; - return *preq; + return {}; } // This version only allows the ANIMATED_GIT_OUTPUT format - MvRequest req = *preq; + MvRequest req = *preq; export_format_ = (const char*)req.getVerb(); if (export_format_ != "ANIMATED_GIF_OUTPUT") return req; @@ -1036,7 +1036,7 @@ std::string name = mbasename(export_fname_.c_str()); export_tmp_path_ = CreateTmpPath(name.c_str()); -#if 0 //FAMI20200319 ProgressManager removed +#if 0 // FAMI20200319 ProgressManager removed // Define directories/files to be watched if (pm_) { pm_->setVisible(false); @@ -1067,7 +1067,7 @@ // Show progress bar pm_->setVisible(true); -#endif //FAMI20200319 +#endif // FAMI20200319 // Define temporary output device // A postscript file will be generated first and then converted @@ -1100,18 +1100,18 @@ // Read the selected output format request from the Metview/Defaults // directory. If not found, create a default request MvRequest reqOut = ObjectList::UserDefaultRequest(export_format_.c_str()); - reqOut = ObjectList::ExpandRequest(reqOut, EXPAND_DEFAULTS); + reqOut = ObjectList::ExpandRequest(reqOut, EXPAND_DEFAULTS); // Define parameters: output/input filenames, image looping std::string ofname = export_fname_ + ".gif"; std::string ifname = export_tmp_path_ + "/" + mbasename(export_fname_.c_str()) + ".ps"; - int nloops = 1; + int nloops = 1; if (strcmp((const char*)reqOut("OUTPUT_CONTINUOUS_LOOPING"), "YES") == 0) nloops = 999; // Check if ps files is completed std::string data; - FILE* stream; + FILE* stream = nullptr; const int max_buffer = 256; char buffer[max_buffer]; std::string ctail("tail -1 "); @@ -1135,9 +1135,9 @@ } } - //TODO: move this command into a shell script - // Postscript file has been generated - // Call external function convert to create the animated gif + // TODO: move this command into a shell script + // Postscript file has been generated + // Call external function convert to create the animated gif std::stringstream out, err; std::ostringstream cmd; cmd << "convert -delay " << (const char*)reqOut("OUTPUT_DELAY") << " -rotate " << (int)reqOut("OUTPUT_ROTATE") << " -resize " << (int)reqOut("OUTPUT_WIDTH") << " -loop " << nloops << " " @@ -1148,7 +1148,7 @@ metview::shellCommand(cmd.str(), out, err); if (!err.str().empty()) { QString message = tr("Export Error: ") + tr(err.str().c_str()); - QMessageBox::warning(0, tr("Metview"), message); + QMessageBox::warning(nullptr, tr("Metview"), message); DeletePath(export_tmp_path_.c_str()); // delete temporary directory } @@ -1156,7 +1156,7 @@ DeletePath(export_tmp_path_.c_str()); } -#if 0 //FAMII20200319 ProgressBar removed +#if 0 // FAMII20200319 ProgressBar removed void uPlotBase::fileChangedExport(const QString& fname) { // Send a popup window message @@ -1202,7 +1202,7 @@ text[MvQAbout::MagicsVersion] = magicsVersion; #if defined(METVIEW_ODB) - const char* odc_ver; + const char* odc_ver = nullptr; odc_version(&odc_ver); text[MvQAbout::OdcVersion] = odc_ver; #endif @@ -1223,7 +1223,7 @@ void uPlotBase::slotResizeEvent(const QSize&) { int index = sizeCombo_->currentIndex(); - int id = sizeCombo_->itemData(index, Qt::UserRole).toInt(); + int id = sizeCombo_->itemData(index, Qt::UserRole).toInt(); if (id == FitToWindow || id == FitToWidth || id == FitToHeight) { changeSize(id); } @@ -1236,12 +1236,12 @@ void uPlotBase::slotSizeDown() { - int scalingId; + int scalingId = 0; int id = sizeCombo_->itemData(sizeCombo_->currentIndex(), Qt::UserRole).toInt(); if (id == FitToWindow || id == FitToWidth || id == FitToHeight) { float scaling = currentSizeRatio(); - scalingId = static_cast(scaling * 100.); + scalingId = static_cast(scaling * 100.); } else { scalingId = id; @@ -1256,12 +1256,12 @@ void uPlotBase::slotSizeUp() { - int scalingId; + int scalingId = 0; int id = sizeCombo_->itemData(sizeCombo_->currentIndex(), Qt::UserRole).toInt(); if (id == FitToWindow || id == FitToWidth || id == FitToHeight) { float scaling = currentSizeRatio(); - scalingId = static_cast(scaling * 100.); + scalingId = static_cast(scaling * 100.); } else { scalingId = id; @@ -1276,7 +1276,7 @@ void uPlotBase::setCustomSize(int sizeId) { - //If custom size item is not available in the combobox we add one to it + // If custom size item is not available in the combobox we add one to it if (customSizeItemIndex_ >= sizeCombo_->count()) { sizeCombo_->addItem(QString::number(sizeId) + "%", sizeId); } @@ -1318,10 +1318,10 @@ return; } - QSize size = plotView_->maximumViewportSize(); + QSize size = plotView_->maximumViewportSize(); float wRatio = size.width() / sceneRect.width(); float hRatio = size.height() / sceneRect.height(); - scaling = (wRatio < hRatio) ? wRatio : hRatio; + scaling = (wRatio < hRatio) ? wRatio : hRatio; if (scaling < 0.95 || scaling > 1.05) { plotScene_->setPlotScale(scaling, MgQPlotScene::RelativeToCurrentSize); @@ -1333,9 +1333,9 @@ return; } - QSize size = plotView_->maximumViewportSize(); + QSize size = plotView_->maximumViewportSize(); float wRatio = size.width() / sceneRect.width(); - scaling = wRatio; + scaling = wRatio; if (scaling < 0.95 || scaling > 1.05) { plotScene_->setPlotScale(scaling, MgQPlotScene::RelativeToCurrentSize); @@ -1347,9 +1347,9 @@ return; } - QSize size = plotView_->maximumViewportSize(); + QSize size = plotView_->maximumViewportSize(); float hRatio = size.height() / sceneRect.height(); - scaling = hRatio; + scaling = hRatio; if (scaling < 0.95 || scaling > 1.05) { plotScene_->setPlotScale(scaling, MgQPlotScene::RelativeToCurrentSize); @@ -1358,8 +1358,8 @@ else if (sizeId >= 10 && sizeId <= 200) { scaling = static_cast(sizeId) * 0.01; - //float w=oriPlotWidthInCm_*scaling; - //float h=oriPlotHeightInCm_*scaling; + // float w=oriPlotWidthInCm_*scaling; + // float h=oriPlotHeightInCm_*scaling; plotScene_->setPlotScale(scaling, MgQPlotScene::RelativeToOriSize); @@ -1376,15 +1376,15 @@ emit plotScaleChanged(); - //GraphicsEngine& ge = owner_->GetGraphicsEngine(); - //owner_->ResizeRequest(w,h); + // GraphicsEngine& ge = owner_->GetGraphicsEngine(); + // owner_->ResizeRequest(w,h); } void uPlotBase::updateResizeActionState() { int index = sizeCombo_->currentIndex(); - int id = sizeCombo_->itemData(index, Qt::UserRole).toInt(); - int sizeId; + int id = sizeCombo_->itemData(index, Qt::UserRole).toInt(); + int sizeId = 0; if (index < 0) return; @@ -1421,23 +1421,23 @@ actions << actionRedo_ << actionUndo_; } - //If there is only one scene + // If there is only one scene if (plotScene_->sceneItems().count() <= 1) { actions << actionZoomUp_ << actionZoomDown_; - //More than one scene: check which scene is clicked + // More than one scene: check which scene is clicked } else { item = plotScene_->findSceneItem(scenePos); if (item) { - //Context menu triggered from the active scene + // Context menu triggered from the active scene if (item == activeScene_) { actions << actionZoomUp_ << actionZoomDown_; - //Context menu triggered from a non-active scene + // Context menu triggered from a non-active scene } else { actions << actionContextSelectScene_ << actionContextZoomUp_ << actionContextZoomDown_; - //Set the status of the context zoom actions + // Set the status of the context zoom actions MvQZoomStackData* zoomData = zoomStackWidget_->pageData(item); if (zoomData) { int levelNum = zoomData->levelNum(); @@ -1474,12 +1474,12 @@ } else if (ac == actionContextZoomUp_) { slotSetActiveScene(item); - //Now this scene is active. We can use the original zoomUp action!! + // Now this scene is active. We can use the original zoomUp action!! actionZoomUp_->trigger(); } else if (ac == actionContextZoomDown_) { slotSetActiveScene(item); - //Now this scene is active. We can use the original zoomDown action!! + // Now this scene is active. We can use the original zoomDown action!! actionZoomDown_->trigger(); } else if (ac == actionRedo_) { diff -Nru metview-5.17.4/metview/src/uPlot/uPlotBase.h metview-5.19.2/metview/src/uPlot/uPlotBase.h --- metview-5.17.4/metview/src/uPlot/uPlotBase.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/uPlotBase.h 2023-07-15 08:28:47.000000000 +0000 @@ -64,8 +64,8 @@ friend class ExportMessageBox; public: - uPlotBase(QWidget* parent = 0); - virtual ~uPlotBase(); + uPlotBase(QWidget* parent = nullptr); + ~uPlotBase() override; void setPlot(float hor, float ver); void setPlotWidgetSize(float hor, float ver); @@ -75,7 +75,7 @@ MgQPlotScene* plotScene() { return plotScene_; } virtual void newRequestForDriversBegin() = 0; - virtual void newRequestForDriversEnd() = 0; + virtual void newRequestForDriversEnd() = 0; virtual void progressMessage(const std::string&) {} void processContentsRequest(MvRequest&); @@ -85,11 +85,11 @@ owner_ = &owner; } - static Presentable* owner() {return owner_;} + static Presentable* owner() { return owner_; } std::string currentWorkDir() const; - virtual MvRequest SuperPageRequest() { return MvRequest(); } + virtual MvRequest SuperPageRequest() { return {}; } void tempDir(std::string& dir) { @@ -152,10 +152,10 @@ void updateZoomActionState(); void updateResizeActionState(); - virtual bool setDropTarget(QPoint) = 0; + virtual bool setDropTarget(QPoint) = 0; virtual bool setDropTargetInView(QPoint) = 0; - virtual int currentStep() = 0; - virtual int stepNum() = 0; + virtual int currentStep() = 0; + virtual int stepNum() = 0; void setCustomSize(int); float currentSizeRatio(); @@ -166,7 +166,7 @@ virtual void loadFinished() {} virtual void writeSettings() = 0; - virtual void readSettings() = 0; + virtual void readSettings() = 0; static Presentable* owner_; @@ -179,33 +179,33 @@ MvQPlotView* plotView_{nullptr}; MgQPlotScene* plotScene_{nullptr}; - //Zoom + // Zoom MvQZoomStackWidget* zoomStackWidget_{nullptr}; QAction* actionZoomUp_{nullptr}; QAction* actionZoomDown_{nullptr}; - //Paste + // Paste QAction* actionPaste_{nullptr}; - //Symbols + // Symbols QUndoStack* undoStack_{nullptr}; QAction* actionRedo_{nullptr}; QAction* actionUndo_{nullptr}; - //Context menu + // Context menu QAction* actionContextSelectScene_{nullptr}; QAction* actionContextZoomUp_{nullptr}; QAction* actionContextZoomDown_{nullptr}; - //Active scene + // Active scene MgQSceneItem* activeScene_{nullptr}; std::string prevActiveSceneId_; - //Size + // Size enum SizeOptions { FitToWindow = -1, - FitToWidth = -2, + FitToWidth = -2, FitToHeight = -3 }; QAction* actionSizeDown_{nullptr}; @@ -223,7 +223,10 @@ // Weather room void uploadWeatherRoom(const std::string&); void outputDeviceWeatherRoom(MvRequest&); - bool syncWeatherRoom() { return wroomSync_; } + bool syncWeatherRoom() + { + return wroomSync_; + } bool wroomSync_; // flag indicating if a plot should be sent to the video wall int wroomCell_; // cell number @@ -238,7 +241,7 @@ // Export animated gif MvRequest setExportVariables(MvRequest*); - //MvQProgressManager* pm_ {0}; // progress manager + // MvQProgressManager* pm_ {0}; // progress manager std::string export_format_; // output format std::string export_fname_; // output path+filename std::string export_tmp_path_; // temporary path to store temporary files diff -Nru metview-5.17.4/metview/src/uPlot/uPlotBatchApp.cc metview-5.19.2/metview/src/uPlot/uPlotBatchApp.cc --- metview-5.17.4/metview/src/uPlot/uPlotBatchApp.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/uPlotBatchApp.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,9 +30,9 @@ app_(o->app_), outReqPath_(o->outReqPath_) {} - MvTransaction* cloneSelf() { return new uPlotBatchTransaction(this); } + MvTransaction* cloneSelf() override { return new uPlotBatchTransaction(this); } - void callback(MvRequest& in); + void callback(MvRequest& in) override; private: uPlotBatchApp* app_; @@ -44,7 +44,7 @@ { public: uPlotBatchApp(int& ac, char** av, const char* name, const std::string&); - virtual ~uPlotBatchApp() = default; + ~uPlotBatchApp() override = default; uPlotBatchApp(const uPlotBatchApp&) = delete; uPlotBatchApp& operator=(const uPlotBatchApp&) = delete; @@ -80,7 +80,7 @@ // } // Get error message(s) - const char* msg; + const char* msg = nullptr; int n = 0; while ((msg = getMessage(n++))) { if (n == 1) @@ -126,7 +126,7 @@ context->Attach(); // It is a new call, so it first needs to clean the previous structure - //Root::Instance().Clean(); + // Root::Instance().Clean(); // Execute the context context->Execute(); @@ -179,8 +179,8 @@ // Create application. The appname must be unique! uPlotBatchApp app(argc, argv, appName.c_str(), outPath); - //Calls itself with the input request - MvApplication::callService(appName.c_str(), in, 0); + // Calls itself with the input request + MvApplication::callService(appName.c_str(), in, nullptr); app.run(); } diff -Nru metview-5.17.4/metview/src/uPlot/uPlot.cc metview-5.19.2/metview/src/uPlot/uPlot.cc --- metview-5.17.4/metview/src/uPlot/uPlot.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/uPlot.cc 2023-07-15 08:28:47.000000000 +0000 @@ -38,8 +38,8 @@ #include "MgQRootItem.h" #include "MgQSceneItem.h" +#include "CursorCoordinate.h" #include "ExportDialog.h" - #include "MvQAbout.h" #include "MvQApplication.h" #include "MvQDataWidget.h" @@ -58,6 +58,7 @@ #include "MvQMethods.h" #include "LayerControlWidget.h" +#include "LocationLabelWidget.h" #include "MvKeyProfile.h" #include "MagPlusService.h" @@ -82,11 +83,11 @@ setWindowTitle("Metview - uPlot"); - //Initial size + // Initial size setInitialSize(1100, 700); #ifdef METVIEW_WEATHER_ROOM - //Check if weather room is enabled + // Check if weather room is enabled if (char* wr = getenv("MV_WEATHER_ROOM")) { if (strcmp(wr, "1") == 0) weatherRoom_ = true; @@ -106,11 +107,11 @@ stepWidget_ = new MvQStepWidget; - //connect(stepWidget_->view(),SIGNAL(activated(QModelIndex)), + // connect(stepWidget_->view(),SIGNAL(activated(QModelIndex)), connect(stepWidget_->view(), SIGNAL(selectionChanged(QModelIndex)), this, SLOT(slotStepTo(QModelIndex))); - //TODO: figure out if the connect can have any usgae + // TODO: figure out if the connect can have any usgae #if 0 connect(stepWidget_, SIGNAL(keyProfileChanged(MvKeyProfile*)), plotView_, SLOT(slotFrameProfileChanged(MvKeyProfile*))); @@ -158,15 +159,15 @@ // Control widget //----------------------------------- - controlWidget_ = new QWidget(this); + controlWidget_ = new QWidget(this); auto* controlLayout = new QVBoxLayout; controlLayout->setContentsMargins(0, 0, 0, 0); controlWidget_->setLayout(controlLayout); // Scene selection sceneWidget_ = new QWidget(this); - auto* label = new QLabel(tr("Active scene:"), this); - sceneCb_ = new MvQSceneComboBox(this); + auto* label = new QLabel(tr("Active scene:"), this); + sceneCb_ = new MvQSceneComboBox(this); auto* hb = new QHBoxLayout; sceneWidget_->setLayout(hb); @@ -186,14 +187,14 @@ connect(sceneCb_, SIGNAL(cursorLeft()), this, SLOT(slotNotHighlightScene())); - //Control tab containing the widgets defined above + // Control tab containing the widgets defined above controlTab_ = new QTabWidget(this); controlLayout->addWidget(controlTab_, 1); controlTab_->addTab(stepWidget_, tr("Frames")); controlTab_->addTab(layerControlWidget_, tr("Layers")); - //controlTab_->addTab(layerWidget_, tr("Layers")); - //controlTab_->addTab(dataWidget_, tr("Data")); + // controlTab_->addTab(layerWidget_, tr("Layers")); + // controlTab_->addTab(dataWidget_, tr("Data")); controlTab_->addTab(symbolWidget_, tr("Symbols")); @@ -204,16 +205,16 @@ #ifdef MVQ_FEATURE_DEV_MODE_ // Feature edit - //auto featureDevW = new QWidget(this); + // auto featureDevW = new QWidget(this); // auto featureDevVb = new QVBoxLayout(featureDevW); // featureDevVb->setContentsMargins(0,0,0,0); auto featureInfoW = new QPlainTextEdit(this); plotView_->setFeatureInfoWidget(featureInfoW); - //featureDevVb->addWidget(featureInfoW); + // featureDevVb->addWidget(featureInfoW); auto undoStackView = new QUndoView(undoStack_, this); - //featureDevVb->addWidget(undoStackView); + // featureDevVb->addWidget(undoStackView); auto* devTab = new QTabWidget(this); devTab->addTab(undoStackView, tr("History")); @@ -227,11 +228,11 @@ stepWidget_->init(plotScene_, ""); - //Plot rescale + // Plot rescale connect(this, SIGNAL(plotScaleChanged()), this, SLOT(slotPlotScaleChanged())); - //Setup the actions + // Setup the actions setupFileActions(); setupShareActions(); setupViewActions(); @@ -262,22 +263,22 @@ mainSplitter_->addWidget(controlWidget_); mainSplitter_->setCollapsible(1, false); - //Define the whole lot as central widget + // Define the whole lot as central widget setCentralWidget(mainSplitter_); - //Read qt geometry settings + // Read qt geometry settings readSettings(); } uPlot::~uPlot() { - //Save qt geometry settings + // Save qt geometry settings writeSettings(); } void uPlot::setupFileActions() { - //Print + // Print auto* actionPrint = new QAction(this); actionPrint->setObjectName(QString::fromUtf8("actionPrint")); QIcon icon; @@ -286,7 +287,7 @@ actionPrint->setText(tr("&Print")); actionPrint->setShortcut(tr("Ctrl+P")); - //Export + // Export auto* actionExport = new QAction(this); actionExport->setObjectName(QString::fromUtf8("actionExport")); QIcon icon1; @@ -295,7 +296,7 @@ actionExport->setText(tr("&Export")); actionExport->setShortcut(tr("Ctrl+S")); - //Generate Macro + // Generate Macro auto* actionMacro = new QAction(this); actionMacro->setObjectName(QString::fromUtf8("actionMacro")); QIcon icon2; @@ -304,11 +305,11 @@ actionMacro->setText(tr("Generate &Macro")); actionMacro->setShortcut(tr("Ctrl+M")); - //Exit + // Exit /*QAction* actionExit = new QAction(this); actionExit->setObjectName(QString::fromUtf8("actionExit")); - actionExit->setText(tr("Exit")); - fileActions_.push_back(actionExit);*/ + actionExit->setText(tr("Exit")); + fileActions_.push_back(actionExit);*/ connect(actionExport, SIGNAL(triggered()), this, SLOT(slotLoadExportDialog())); @@ -331,7 +332,7 @@ MvQMainWindow::MenuType menuType = MvQMainWindow::ShareMenu; #ifdef METVIEW_WEATHER_ROOM - //Weather room connection + // Weather room connection if (weatherRoom_) { // Add video wall export action QAction* actionWroom = new QAction(this); @@ -410,7 +411,7 @@ void uPlot::setupToolsActions() { - //Magnfier + // Magnfier auto* actionMagnifier = new QAction(this); actionMagnifier->setObjectName(QString::fromUtf8("actionMagnifier")); actionMagnifier->setCheckable(true); @@ -419,7 +420,7 @@ actionMagnifier->setIcon(icon3); actionMagnifier->setText(tr("&Magnifier")); - //Cursor data + // Cursor data auto* actionCursorData = new QAction(this); actionCursorData->setObjectName(QString::fromUtf8("actionCursorData")); actionCursorData->setCheckable(true); @@ -428,7 +429,12 @@ actionCursorData->setIcon(icon1); actionCursorData->setText(tr("&Cursor data")); - //Antialias + // reset cursor data + auto* actionCursorDataReset = new QAction(this); + actionCursorDataReset->setObjectName(QString::fromUtf8("actionCursorDataReset")); + actionCursorDataReset->setText(tr("&Reset cursor data")); + + // Antialias actionAntialias_ = new QAction(this); actionAntialias_->setObjectName(QString::fromUtf8("actionAntialias")); actionAntialias_->setCheckable(true); @@ -443,17 +449,24 @@ actionAntialias_->setText(tr("Antialias")); actionAntialias_->setShortcut(tr("Ctrl+L")); - //Magnifier + // Magnifier connect(actionMagnifier, SIGNAL(toggled(bool)), plotView_, SLOT(slotSetEnableMagnifier(bool))); connect(plotView_, SIGNAL(magnifierIsEnabledProgramatically(bool)), actionMagnifier, SLOT(setChecked(bool))); - //Cursor data + // Cursor data connect(actionCursorData, SIGNAL(toggled(bool)), plotView_, SLOT(slotSetEnableCursorData(bool))); + connect(actionCursorDataReset, SIGNAL(triggered()), + plotView_, SLOT(slotResetCursorData())); + + connect(plotView_, SIGNAL(cursorDataCoordsChanged(CursorCoordinate)), + locationLabel_, SLOT(setLocation(CursorCoordinate))); + + connect(actionAntialias_, SIGNAL(toggled(bool)), this, SLOT(slotEnableAntialias(bool))); @@ -461,14 +474,15 @@ menuItems_[menuType].push_back(new MvQMenuItem(actionMagnifier)); menuItems_[menuType].push_back(new MvQMenuItem(actionCursorData)); + menuItems_[menuType].push_back(new MvQMenuItem(actionCursorDataReset, MvQMenuItem::MenuTarget)); menuItems_[menuType].push_back(new MvQMenuItem(actionAntialias_)); } void uPlot::setupViewActions() { - QAction* action; + QAction* action = nullptr; - //Sidebar + // Sidebar actionControlPanel_ = new QAction(this); actionControlPanel_->setObjectName(QString::fromUtf8("actionControlPanel")); actionControlPanel_->setCheckable(true); @@ -478,7 +492,7 @@ icon2.addPixmap(QPixmap(QString::fromUtf8(":/uPlot/sidebar.svg")), QIcon::Normal, QIcon::Off); actionControlPanel_->setIcon(icon2); - //Active scene highlight + // Active scene highlight action = new QAction(this); action->setObjectName(QString::fromUtf8("actionHighlightScene")); QIcon icon4; @@ -498,36 +512,45 @@ auto* sep = new QAction(this); sep->setSeparator(true); + auto* sep1 = new QAction(this); + sep1->setSeparator(true); + + //location - visible when created + locationLabel_ = new metview::uplot::LocationLabelWidget(this, plotView_); + statusBar()->addPermanentWidget(locationLabel_); + MvQMainWindow::MenuType menuType = MvQMainWindow::ViewMenu; menuItems_[menuType].push_back(new MvQMenuItem(actionControlPanel_)); menuItems_[menuType].push_back(new MvQMenuItem(actionHighlightScene_)); menuItems_[menuType].push_back(new MvQMenuItem(sep)); + menuItems_[menuType].push_back(new MvQMenuItem(locationLabel_->viewAction(), MvQMenuItem::MenuTarget)); + menuItems_[menuType].push_back(new MvQMenuItem(sep1)); uPlotBase::setupViewActions(); } void uPlot::setupAnimationActions() { - //Play + // Play actionPlay_ = new QAction(this); actionPlay_->setObjectName(QString::fromUtf8("actionPlay")); QIcon icon5; icon5.addPixmap(QPixmap(QString::fromUtf8(":/uPlot/player_play.svg")), QIcon::Normal, QIcon::Off); actionPlay_->setIcon(icon5); actionPlay_->setText(tr("&Play")); - //animationActions_.push_back(actionPlay_); + // animationActions_.push_back(actionPlay_); - //Stop + // Stop actionStop_ = new QAction(this); actionStop_->setObjectName(QString::fromUtf8("actionStop")); QIcon icon6; icon6.addPixmap(QPixmap(QString::fromUtf8(":/uPlot/player_stop.svg")), QIcon::Normal, QIcon::Off); actionStop_->setIcon(icon6); actionStop_->setText(tr("&Stop")); - //animationActions_.push_back(actionStop_); + // animationActions_.push_back(actionStop_); - //Prev + // Prev actionPrevious_ = new QAction(this); actionPrevious_->setObjectName(QString::fromUtf8("actionPrevious")); QIcon icon8; @@ -535,9 +558,9 @@ actionPrevious_->setIcon(icon8); actionPrevious_->setText(tr("P&revious")); actionPrevious_->setShortcut(tr("Left")); - //animationActions_.push_back(actionPrevious_); + // animationActions_.push_back(actionPrevious_); - //Next + // Next actionNext_ = new QAction(this); actionNext_->setObjectName(QString::fromUtf8("actionNext")); QIcon icon7; @@ -545,9 +568,9 @@ actionNext_->setIcon(icon7); actionNext_->setText(tr("&Next")); actionNext_->setShortcut(tr("Right")); - //animationActions_.push_back(actionNext_); + // animationActions_.push_back(actionNext_); - //First + // First actionFirst_ = new QAction(this); actionFirst_->setObjectName(QString::fromUtf8("actionFirst")); QIcon icon9; @@ -555,9 +578,9 @@ actionFirst_->setIcon(icon9); actionFirst_->setText(tr("&First")); actionFirst_->setShortcut(tr("Home")); - //animationActions_.push_back(actionFirst_); + // animationActions_.push_back(actionFirst_); - //Last + // Last actionLast_ = new QAction(this); actionLast_->setObjectName(QString::fromUtf8("actionLast")); QIcon icon10; @@ -565,7 +588,7 @@ actionLast_->setIcon(icon10); actionLast_->setText(tr("&Last")); actionLast_->setShortcut(tr("End")); - //animationActions_.push_back(actionLast_); + // animationActions_.push_back(actionLast_); connect(actionPlay_, SIGNAL(triggered()), @@ -587,7 +610,7 @@ this, SLOT(slotToLast())); - //Animation speed + // Animation speed float fval[] = {0.5, 0.7, 1, 1.5, 2, 3, 4, 5, 10}; for (float& i : fval) { speed_.push_back(i); @@ -621,11 +644,11 @@ speedLabel_ = new QLabel; speedLabel_->setText("Speed: 1 fr/s"); - //toolBarAnimation->addWidget(speedLabel_); + // toolBarAnimation->addWidget(speedLabel_); - //QVBoxLayout *vl = new QVBoxLayout; - //vl->addWidget(speedSlider_); - //vl->addWidget(speedLabel_); + // QVBoxLayout *vl = new QVBoxLayout; + // vl->addWidget(speedSlider_); + // vl->addWidget(speedLabel_); auto* wa = new QWidgetAction(menuSpeed); wa->setDefaultWidget(speedSlider_); @@ -639,7 +662,7 @@ connect(speedSlider_, SIGNAL(valueChanged(int)), this, SLOT(slotSetSpeed(int))); - //Active scene highlight + // Active scene highlight auto* action = new QAction(this); action->setObjectName(QString::fromUtf8("actionAnimatedScenes")); QIcon icon4; @@ -676,12 +699,12 @@ void uPlot::setupEditActions() { - //redo + // redo actionRedo_ = undoStack_->createRedoAction(this, tr("&Redo")); actionRedo_->setShortcuts(QKeySequence::Redo); actionRedo_->setIcon(QPixmap(":/uPlot/redo.svg")); - //undo + // undo actionUndo_ = undoStack_->createUndoAction(this, tr("&Undo")); actionUndo_->setShortcuts(QKeySequence::Undo); actionUndo_->setIcon(QPixmap(":/uPlot/undo.svg")); @@ -695,9 +718,9 @@ void uPlot::setupProgressBarActions() { - //TODO: This should one be visible when we use it!!!! - //TODO: should be created via a the menuIt ems mechanism - // Create a toolbar to handle the progress bar + // TODO: This should one be visible when we use it!!!! + // TODO: should be created via a the menuIt ems mechanism + // Create a toolbar to handle the progress bar auto progressToolbar = new QToolBar("Progress bar Toolbar", this); progressToolbar->setObjectName("progressbar"); @@ -709,22 +732,22 @@ bool uPlot::setDropTarget(QPoint globalPos) { - MgQSceneItem* item = 0; + MgQSceneItem* item = nullptr; QPointF scenePos = plotView_->mapToScene(plotView_->mapFromGlobal(globalPos)); /*if(layerWidget_->layerAtGlobalPos(globalPos) != -1) - { - return false; - } - else - { - if(activeScene_) - { - if(activeScene_->sceneBoundingRect().contains(scenePos)) - return true; - } - }*/ + { + return false; + } + else + { + if(activeScene_) + { + if(activeScene_->sceneBoundingRect().contains(scenePos)) + return true; + } + }*/ if (activeScene_) { if (activeScene_->sceneBoundingRect().contains(scenePos)) @@ -745,7 +768,7 @@ bool uPlot::setDropTargetInView(QPoint pos) { - MgQSceneItem* item = 0; + MgQSceneItem* item = nullptr; QPointF scenePos = plotView_->mapToScene(pos); @@ -770,30 +793,30 @@ { plotScene_->saveStateBeforeNewRequest(); - //Frames + // Frames stepWidget_->stepDataIsAboutToChange(); - //Layer contents + // Layer contents layerWidget_->layersAreAboutToChange(); - //Layer data + // Layer data dataWidget_->layersAreAboutToChange(); - //Magnifier + // Magnifier plotView_->resetBegin(); if (activeScene_) { prevActiveSceneId_ = activeScene_->layout().id(); if (prevActiveSceneId_.empty()) { MgQLayoutItem* projItem = activeScene_->firstProjectorItem(); - prevActiveSceneId_ = projItem->layout().id(); + prevActiveSceneId_ = projItem->layout().id(); } } else { prevActiveSceneId_.clear(); } - activeScene_ = 0; + activeScene_ = nullptr; controlWidget_->setEnabled(false); @@ -805,7 +828,7 @@ { controlWidget_->setEnabled(true); - //Select the active scene + // Select the active scene if (!activeScene_) { if (!prevActiveSceneId_.empty()) { foreach (MgQSceneItem* item, plotScene_->sceneItems()) { @@ -828,31 +851,31 @@ } } - //Resize without rendering!! + // Resize without rendering!! changeSize(sizeCombo_->itemData(sizeCombo_->currentIndex(), Qt::UserRole).toInt(), false); - //Load steps/layers and generate layer thumbnails - No rendering at this point! - //It tries to set the current step for all the scenes! - //The current step should be correctly set at least for the active scene. + // Load steps/layers and generate layer thumbnails - No rendering at this point! + // It tries to set the current step for all the scenes! + // The current step should be correctly set at least for the active scene. plotScene_->updateAfterNewRequest(); - //Zoom stack - generate thumbnail for the new area + // Zoom stack - generate thumbnail for the new area zoomStackWidget_->reset(activeScene_, false); updateZoomActionState(); - //Layer contents + // Layer contents layerWidget_->reset(activeScene_); - //Layer data - will set the current step for the data widgets! + // Layer data - will set the current step for the data widgets! dataWidget_->reset(activeScene_); - //Update scene combobox + // Update scene combobox if (plotScene_->sceneItems().count() <= 1) { sceneWidget_->hide(); sceneCb_->clear(); } else { - //Scene combo + // Scene combo sceneCb_->clear(); for (int i = 0; i < plotScene_->sceneItems().count(); i++) { sceneCb_->addItem(tr("Scene ") + QString::number(i + 1)); @@ -864,7 +887,7 @@ sceneWidget_->show(); } - //Generate animated scenes list + // Generate animated scenes list if (plotScene_->sceneItems().count() <= 1) { animatedScenes_.clear(); } @@ -873,32 +896,32 @@ slotAnimatedScenes(actionAnimatedScenes_->isChecked()); } - //Frames - no rendering!! - //At this point the current step should be correctly set for the active scene!! + // Frames - no rendering!! + // At this point the current step should be correctly set for the active scene!! // non of these updates can call resetEnd() ignoreResetEnd_ = true; stepWidget_->reset(activeScene_); if (activeScene_) { - //Update the view + // Update the view stepWidget_->setViewToCurrentStep(); - //Set the correct step for the aminated scenes. No rendering involved! + // Set the correct step for the aminated scenes. No rendering involved! stepWidget_->updateStepForScenes(animatedScenes_); } - //Animation buttons + // Animation buttons updateAnimationActionState(); - //NOW RENDER IT! We render the whole scene into the pixmap cache at this point! + // NOW RENDER IT! We render the whole scene into the pixmap cache at this point! plotScene_->sceneItemChanged(); - //Update magnifier, cursordata etc + // Update magnifier, cursordata etc ignoreResetEnd_ = false; plotView_->resetEnd(); - //Udate scene selection + // Udate scene selection if (plotScene_->sceneItems().count() <= 1) { actionHighlightScene_->setEnabled(false); } @@ -910,7 +933,7 @@ loadFinished(); - //Emit a signal that the plot window has been updated + // Emit a signal that the plot window has been updated emit plotWindowUpdated(); } @@ -1076,17 +1099,17 @@ void uPlot::slotSelectActiveScene() { - //actionSelectScene_->setEnabled(false); - //plotView_->slotSelectScene(); + // actionSelectScene_->setEnabled(false); + // plotView_->slotSelectScene(); } void uPlot::slotActiveSceneSelected(QPointF /*scenePos*/) { - //MgQSceneItem *item=plotScene_->findSceneItem(scenePos); + // MgQSceneItem *item=plotScene_->findSceneItem(scenePos); - //setActiveScene(item); - //identifyScene(item); - //actionSelectScene_->setEnabled(true); + // setActiveScene(item); + // identifyScene(item); + // actionSelectScene_->setEnabled(true); } void uPlot::slotHighlightActiveScene(bool bval) @@ -1123,7 +1146,7 @@ activeScene_ = activeScene; - //Zoom stack + // Zoom stack zoomStackWidget_->reset(activeScene_, true); updateZoomActionState(); @@ -1133,20 +1156,20 @@ dataWidget_->layersAreAboutToChange(); dataWidget_->reset(activeScene_); - //stepWidget_->stepDataIsAboutToChange(); + // stepWidget_->stepDataIsAboutToChange(); stepWidget_->reset(activeScene_); slotHighlightActiveScene(actionHighlightScene_->isChecked()); - //Remove the highlight rectangle activated by the scene combo box! + // Remove the highlight rectangle activated by the scene combo box! slotNotHighlightScene(); updateAnimationActionState(); sceneCb_->setCurrentIndex(plotScene_->sceneItems().indexOf(activeScene)); - //Emit a signal that the plot windows has been updated - //emit plotWindowUpdated(); ??????????????? + // Emit a signal that the plot windows has been updated + // emit plotWindowUpdated(); ??????????????? } @@ -1162,14 +1185,14 @@ void uPlot::slotNotHighlightScene() { - plotScene_->highlightSceneItemForBrief(0, false); + plotScene_->highlightSceneItemForBrief(nullptr, false); } void uPlot::slotLayerUpdate() { - //Notify the scene about the change in the layer status - //plotScene_->updateLayers(layerWidget_->model()->layers()); + // Notify the scene about the change in the layer status + // plotScene_->updateLayers(layerWidget_->model()->layers()); plotScene_->update(); } @@ -1232,7 +1255,7 @@ void uPlot::slotLayerStackingOrderChanged(QList > lorder) { for (auto& i : lorder) { - int id = i.first.toInt(); + int id = i.first.toInt(); int value = i.second; owner_->UpdateLayerStackingOrder(id, value); } @@ -1276,6 +1299,8 @@ settings.setValue("highlightScene", actionHighlightScene_->isChecked()); settings.setValue("animatedScenes", actionAnimatedScenes_->isChecked()); + locationLabel_->writeSettings(settings); + settings.setValue("sizeIndex", sizeCombo_->currentIndex()); int sizeId = sizeCombo_->itemData(sizeCombo_->currentIndex(), Qt::UserRole).toInt(); settings.setValue("sizeId", sizeId); @@ -1296,7 +1321,8 @@ if (settings.contains("mainSplitter")) { mainSplitter_->restoreState(settings.value("mainSplitter").toByteArray()); - } else { + } + else { Q_ASSERT(mainSplitter_->count() == 2); if (mainSplitter_->count() == 2) { int w = size().width(); @@ -1304,10 +1330,11 @@ auto sLst = mainSplitter_->sizes(); if (w > 800) { sLst[1] = 250; - sLst[0] = w-250; - } else { - sLst[1] = w/4; - sLst[0] = w-w/4; + sLst[0] = w - 250; + } + else { + sLst[1] = w / 4; + sLst[0] = w - w / 4; } mainSplitter_->setSizes(sLst); } @@ -1345,6 +1372,8 @@ actionAnimatedScenes_->setChecked(settings.value("animatedScenes").toBool()); } + locationLabel_->readSettings(settings); + if (settings.value("sizeIndex").isNull()) { sizeCombo_->setCurrentIndex(5); } @@ -1380,7 +1409,7 @@ return; // Get the specific share target selected by the user - QVariant qv = ac->data(); + QVariant qv = ac->data(); ShareTarget* st = ShareTargetManager::instance()->at(qv.toInt()); // Create progress manager @@ -1396,3 +1425,4 @@ st->dialog(req, pm); #endif } + diff -Nru metview-5.17.4/metview/src/uPlot/uPlot.h metview-5.19.2/metview/src/uPlot/uPlot.h --- metview-5.17.4/metview/src/uPlot/uPlot.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/uPlot.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,6 +31,7 @@ class QVBoxLayout; class QWidgetAction; +class CursorCoordinate; class ExportDialog; class MgQPlotScene; class MgQSceneItem; @@ -43,15 +44,22 @@ class MvQTreeView; class MvQZoomStackWidget; class LayerControlWidget; +class LocationLabelWidget; + +namespace metview { +namespace uplot { + class LocationLabelWidget; +} +} class MvQSceneComboBox : public QComboBox { Q_OBJECT public: - MvQSceneComboBox(QWidget* parent = 0) : + MvQSceneComboBox(QWidget* parent = nullptr) : QComboBox(parent) {} - void hidePopup(); + void hidePopup() override; signals: void cursorLeft(); }; @@ -61,8 +69,8 @@ Q_OBJECT public: - uPlot(QWidget* parent = 0); - ~uPlot(); + uPlot(QWidget* parent = nullptr); + ~uPlot() override; void newRequestForDriversBegin() override; void newRequestForDriversEnd() override; @@ -134,7 +142,7 @@ QAction* actionAntialias_; QAction* actionControlPanel_; - //Animation control + // Animation control QAction* actionPlay_; QAction* actionStop_; QAction* actionNext_; @@ -154,6 +162,8 @@ QWidget* sceneWidget_; bool ignoreResetEnd_{false}; + metview::uplot::LocationLabelWidget *locationLabel_{nullptr}; + // MvQProgressItem* progressItem_; // Progress Bar diff -Nru metview-5.17.4/metview/src/uPlot/uPlotManager.cc metview-5.19.2/metview/src/uPlot/uPlotManager.cc --- metview-5.17.4/metview/src/uPlot/uPlotManager.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/uPlotManager.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,8 +13,8 @@ #include #include #include -#include -#include +#include +#include #include "uPlotService.hpp" #include "MvMiscellaneous.h" @@ -58,8 +58,8 @@ // MetviewTask.cc) receives an empty request. It would work if Request r // has the contents of variable out below. // - //out = in; - //out.setVerb("METZOOM"); + // out = in; + // out.setVerb("METZOOM"); uPlotService::Instance().CallMetZoom(in, out); } @@ -100,7 +100,7 @@ // Add services not listed in the uPlotTable std::vector svcNotInTable = {"UPLOT_MANAGER", "MCOAST", "MTEXT", "MLEGEND"}; - for (auto cls : svcNotInTable) { + for (const auto& cls : svcNotInTable) { services[cls] = std::make_shared(cls.c_str()); } diff -Nru metview-5.17.4/metview/src/uPlot/uPlotService.cc metview-5.19.2/metview/src/uPlot/uPlotService.cc --- metview-5.17.4/metview/src/uPlot/uPlotService.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/uPlotService.cc 2023-07-15 08:28:47.000000000 +0000 @@ -55,7 +55,7 @@ // Set filename to be used by uPlot to store the output request std::ostringstream appName; appName << "uPlotManager" << (long int)getpid(); - std::string name = MakeTmpPath(appName.str().c_str()); + std::string name = MakeTmpPath(appName.str().c_str()); uPlotRequest("_UPLOT_MANAGER_ID") = (const char*)name.c_str(); // Save request to be processed by uPlot @@ -69,7 +69,7 @@ out.setVerb("REPLY"); char* desktop = getenv("MV_DESKTOP_NAME"); - if (desktop == 0) { + if (desktop == nullptr) { out.setVerb("ERROR"); out("MESSAGE") = "uPlotService-> MV_DESKTOP_NAME is not defined!"; return; @@ -95,7 +95,7 @@ if (!GRIB_DEFINITION_PATH_ENV.empty()) { cmd += "export GRIB_DEFINITION_PATH=" + GRIB_DEFINITION_PATH_ENV + ";"; } - //cmd+="xterm -iconic -e /usr/local/apps/totalview/tv8.14.0-16/bin/tv8 $METVIEW_BIN/uPlot -a " + std::string(ftemp) + " $METVIEW_QT_APPLICATION_FLAGS &"; + // cmd+="xterm -iconic -e /usr/local/apps/totalview/tv8.14.0-16/bin/tv8 $METVIEW_BIN/uPlot -a " + std::string(ftemp) + " $METVIEW_QT_APPLICATION_FLAGS &"; cmd += "$metview_command $METVIEW_BIN/uPlot " + std::string(ftemp) + " $METVIEW_QT_APPLICATION_FLAGS &"; system(cmd.c_str()); @@ -110,7 +110,7 @@ // called uPlotManager, for example Desktop. In this case, Desktop will // know if the icon needs to be turned green or red. int wait_time = 1; - int ntimes = 10; + int ntimes = 10; for (int i = 0; i < ntimes; i++) { struct stat buffer; if (stat(name.c_str(), &buffer) == 0) { @@ -122,11 +122,11 @@ } #else MvRequest req("DYNSERVICE"); - req("name") = "uPlot"; + req("name") = "uPlot"; req("fullname") = "Display Module"; - long pid = getpid(); - req("id") = pid; - req("cmd") = "env LD_LIBRARY_PATH=$MAGPLUS_HOME/lib:$LD_LIBRARY_PATH $metview_command $METVIEW_BIN/uPlot -stylesheet $METVIEW_DIR_SHARE/app-defaults/metview.qss -graphicssystem raster"; + long pid = getpid(); + req("id") = pid; + req("cmd") = "env LD_LIBRARY_PATH=$MAGPLUS_HOME/lib:$LD_LIBRARY_PATH $metview_command $METVIEW_BIN/uPlot -stylesheet $METVIEW_DIR_SHARE/app-defaults/metview.qss -graphicssystem raster"; req = req + uPlotRequest; @@ -143,15 +143,15 @@ { // If error, send a message and return if (task->getError() != 0) { - //int i = 0; - //const char* msg = 0; - //while ( msg = task->getMessage (i++ ) ) + // int i = 0; + // const char* msg = 0; + // while ( msg = task->getMessage (i++ ) ) - //COUT << "uPlot endOfTask-> Failed to run uPlotService" << std::endl; + // COUT << "uPlot endOfTask-> Failed to run uPlotService" << std::endl; } // Retrieve the reply request - auto* serviceTask = (MvServiceTask*)task; + auto* serviceTask = dynamic_cast(task); MvRequest replyRequest = serviceTask->getReply(); @@ -175,16 +175,16 @@ // req("_UPLOT_MANAGER_ID") = (const char*)name.c_str(); /* - // Plotting procedure relies on parameter _CLASS being defined - std::string verb; - if ( (const char*)req("_CLASS") ) - verb = (const char*)req("_CLASS"); - else - { - out.setVerb("ERROR"); - out("MESSAGE") = "MetZoom error: input request not recognised"; - return; - } + // Plotting procedure relies on parameter _CLASS being defined + std::string verb; + if ( (const char*)req("_CLASS") ) + verb = (const char*)req("_CLASS"); + else + { + out.setVerb("ERROR"); + out("MESSAGE") = "MetZoom error: input request not recognised"; + return; + } */ // Input request: update verb and save it in the METVIEW_TMP directory // If in the future we change the verb to MetZoom then we need diff -Nru metview-5.17.4/metview/src/uPlot/VertProfView.cc metview-5.19.2/metview/src/uPlot/VertProfView.cc --- metview-5.17.4/metview/src/uPlot/VertProfView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/VertProfView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -65,7 +65,7 @@ // Translate Levels interval viewReq("BOTTOM_LEVEL") = (double)req("BOTTOM_PRESSURE"); - viewReq("TOP_LEVEL") = (double)req("TOP_PRESSURE"); + viewReq("TOP_LEVEL") = (double)req("TOP_PRESSURE"); // Translate axes parameters viewReq.setValue("LEVEL_AXIS", req.getSubrequest("PRESSURE_AXIS")); @@ -103,7 +103,7 @@ string VertProfView::Name() { - int id = Owner().Id(); + int id = Owner().Id(); std::string name = (const char*)ObjectInfo::ObjectName(viewRequest_, "VProfileView", id); return name; @@ -187,7 +187,7 @@ cartView("X_AUTOMATIC") = "on"; else { cartView("X_AUTOMATIC") = "OFF"; - int nvals = viewRequest_.countValues("X_MIN_MAX"); + int nvals = viewRequest_.countValues("X_MIN_MAX"); if (nvals != 0 && nvals != 2) ierror = true; else { @@ -206,16 +206,16 @@ xValuesAuto_ = true; // it seems that this is no longer needed - //if ( (const char*)viewRequest_("_DATAATTACHED") && - //strcmp((const char*)viewRequest_("_DATAATTACHED"),"YES") == 0 ) + // if ( (const char*)viewRequest_("_DATAATTACHED") && + // strcmp((const char*)viewRequest_("_DATAATTACHED"),"YES") == 0 ) cartView("X_AUTOMATIC") = "ON"; } else if (sx1 == "AUTO" || sx2 == "AUTO") ierror = true; else { - xValuesAuto_ = false; - xMin_ = viewRequest_("X_MIN_MAX", 0); - xMax_ = viewRequest_("X_MIN_MAX", 1); + xValuesAuto_ = false; + xMin_ = viewRequest_("X_MIN_MAX", 0); + xMax_ = viewRequest_("X_MIN_MAX", 1); cartView("X_MIN") = xMin_; cartView("X_MAX") = xMax_; } @@ -229,16 +229,16 @@ // Translate Y coordinates if (axisAuto) { - cartView("Y_AUTOMATIC") = "on"; + cartView("Y_AUTOMATIC") = "on"; cartView("Y_AUTOMATIC_REVERSE") = yReverse_.c_str(); } else { cartView("Y_AUTOMATIC") = "OFF"; - cartView("Y_MIN") = yMin_; - cartView("Y_MAX") = yMax_; + cartView("Y_MIN") = yMin_; + cartView("Y_MAX") = yMax_; } - const char* log = viewRequest_("VERTICAL_SCALING"); + const char* log = viewRequest_("VERTICAL_SCALING"); cartView("Y_AXIS_TYPE") = (log && strcmp(log, "LOG") == 0) ? "logarithmic" : "REGULAR"; // Translate axes definitions @@ -274,11 +274,11 @@ { // Build a list of parameters to be checked std::vector params; - params.push_back("INPUT_MODE"); + params.emplace_back("INPUT_MODE"); if ((const char*)req1("POINT")) - params.push_back("POINT"); + params.emplace_back("POINT"); else - params.push_back("AREA"); + params.emplace_back("AREA"); // Call a function to perform the consistency check return req1.checkParameters(req2, params); diff -Nru metview-5.17.4/metview/src/uPlot/Visitor.h metview-5.19.2/metview/src/uPlot/Visitor.h --- metview-5.17.4/metview/src/uPlot/Visitor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/Visitor.h 2023-07-15 08:28:47.000000000 +0000 @@ -48,11 +48,9 @@ class Visitor { public: - // Contructors - Visitor() {} - - // Destructor - virtual ~Visitor() {} + Visitor() = default; + virtual ~Visitor() = default; + Visitor(const Visitor&) = delete; // Visitor methods virtual void Visit(SuperPage&) = 0; @@ -67,6 +65,5 @@ private: // No copy allowed - Visitor(const Visitor&); - Visitor& operator=(const Visitor&) { return *this; } + Visitor& operator=(const Visitor&) = default; }; diff -Nru metview-5.17.4/metview/src/uPlot/XDevice.cc metview-5.19.2/metview/src/uPlot/XDevice.cc --- metview-5.17.4/metview/src/uPlot/XDevice.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/XDevice.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,7 @@ // class XDeviceFactory - builds X Devices class XDeviceFactory : public DeviceFactory { - virtual Device* Build(const MvRequest& deviceRequest) + Device* Build(const MvRequest& deviceRequest) override { return new XDevice(deviceRequest); } @@ -58,15 +58,15 @@ return; // Canvas already created GraphicsEngine& ge = subpage.GetGraphicsEngine(); - //U XCanvas* canvas = ge.MakeXCanvas ( *this, spw, + // U XCanvas* canvas = ge.MakeXCanvas ( *this, spw, Canvas* canvas = ge.MakeCanvas(*this, subpage.GetLocation(), subpage.GetMySize(), subpage.Id()); ensure(canvas != nullptr); - //U subpage.SetDeviceData ( spw ); + // U subpage.SetDeviceData ( spw ); subpage.SetCanvas(canvas); - //U spw->SetCanvas ( canvas ); - //FAMI SetTranslations( (*canvas), spw ); + // U spw->SetCanvas ( canvas ); + // FAMI SetTranslations( (*canvas), spw ); - //FAMI subpage.SetVisibility ( true ); - //U spw->Manage(); + // FAMI subpage.SetVisibility ( true ); + // U spw->Manage(); } diff -Nru metview-5.17.4/metview/src/uPlot/XDevice.h metview-5.19.2/metview/src/uPlot/XDevice.h --- metview-5.17.4/metview/src/uPlot/XDevice.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/XDevice.h 2023-07-15 08:28:47.000000000 +0000 @@ -52,12 +52,12 @@ XDevice(const MvRequest& deviceRequest); // Destructor - ~XDevice(); // Change to virtual if base class + ~XDevice() override; // Change to virtual if base class // Visitor methods - virtual void Visit(SuperPage&); - virtual void Visit(Page&); - virtual void Visit(SubPage&); + void Visit(SuperPage&) override; + void Visit(Page&) override; + void Visit(SubPage&) override; private: // No copy allowed diff -Nru metview-5.17.4/metview/src/uPlot/XSectView.cc metview-5.19.2/metview/src/uPlot/XSectView.cc --- metview-5.17.4/metview/src/uPlot/XSectView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/XSectView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -65,12 +65,12 @@ // Translate Levels interval viewReq("BOTTOM_LEVEL") = (double)req("BOTTOM_PRESSURE"); - viewReq("TOP_LEVEL") = (double)req("TOP_PRESSURE"); + viewReq("TOP_LEVEL") = (double)req("TOP_PRESSURE"); // Copy Wind parameters - viewReq("WIND_PARALLEL") = (const char*)req("WIND_PARALLEL"); + viewReq("WIND_PARALLEL") = (const char*)req("WIND_PARALLEL"); viewReq("WIND_PERPENDICULAR") = (const char*)req("WIND_PERPENDICULAR"); - viewReq("WIND_INTENSITY") = (const char*)req("WIND_INTENSITY"); + viewReq("WIND_INTENSITY") = (const char*)req("WIND_INTENSITY"); // Translate Vertical scaling parameter viewReq("VERTICAL_SCALING") = (const char*)req("PRESSURE_LEVEL_AXIS"); @@ -100,15 +100,9 @@ SetVariables(viewRequest, true); } -XSectView::XSectView(const XSectView& old) : - CommonXSectView(old), - yReverse_(old.yReverse_) -{ -} - string XSectView::Name() { - int id = Owner().Id(); + int id = Owner().Id(); std::string name = (const char*)ObjectInfo::ObjectName(viewRequest_, "XSectionView", id); return name; @@ -171,9 +165,9 @@ if (axisAuto) cartView("X_AUTOMATIC") = "on"; else { - cartView("X_AUTOMATIC") = "off"; - cartView("X_MIN_LATITUDE") = latMin_; - cartView("X_MAX_LATITUDE") = latMax_; + cartView("X_AUTOMATIC") = "off"; + cartView("X_MIN_LATITUDE") = latMin_; + cartView("X_MAX_LATITUDE") = latMax_; cartView("X_MIN_LONGITUDE") = lonMin_; cartView("X_MAX_LONGITUDE") = lonMax_; } @@ -181,7 +175,7 @@ // Translate Y coordinates if (axisAuto) { - cartView("Y_AUTOMATIC") = "on"; + cartView("Y_AUTOMATIC") = "on"; cartView("Y_AUTOMATIC_REVERSE") = yReverse_.c_str(); } else { @@ -233,10 +227,10 @@ { // Build a list of parameters to be checked std::vector params; - params.push_back("LINE"); - params.push_back("WIND_PARALLEL"); - params.push_back("WIND_PERPENDICULAR"); - params.push_back("WIND_INTENSITY"); + params.emplace_back("LINE"); + params.emplace_back("WIND_PARALLEL"); + params.emplace_back("WIND_PERPENDICULAR"); + params.emplace_back("WIND_INTENSITY"); // Call a function to perform the consistency check return req1.checkParameters(req2, params); diff -Nru metview-5.17.4/metview/src/uPlot/XSectView.h metview-5.19.2/metview/src/uPlot/XSectView.h --- metview-5.17.4/metview/src/uPlot/XSectView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/XSectView.h 2023-07-15 08:28:47.000000000 +0000 @@ -54,7 +54,7 @@ class XSectViewFactory : public PlotModViewFactory { // -- Virtual Constructor - Builds a new XSectView - virtual PlotModView* Build(Page&, const MvRequest&, const MvRequest&); + PlotModView* Build(Page&, const MvRequest&, const MvRequest&) override; public: // Constructors @@ -69,7 +69,7 @@ class XSectViewM3Factory : public PlotModViewFactory { // -- Virtual Constructor - Builds a new XSectView - virtual PlotModView* Build(Page&, const MvRequest&, const MvRequest&); + PlotModView* Build(Page&, const MvRequest&, const MvRequest&) override; // Translate Metview 3 view request to Metview 4 MvRequest Translate(const MvRequest&); @@ -87,11 +87,12 @@ public: // -- Constructors XSectView(Page&, const MvRequest&, const MvRequest&); - XSectView(const XSectView&); + XSectView(const XSectView&) = default; + XSectView& operator=(const XSectView&) = delete; PlotModView* Clone() const override { return new XSectView(*this); } // -- Destructor - ~XSectView() {} + ~XSectView() override = default; // -- Methods // -- Overriden from CommonXSectView class @@ -117,9 +118,6 @@ // Save some data specific to some DataApplication void ApplicationInfo(const MvRequest&) override; - // No assignment - XSectView& operator=(const XSectView&); - // Variables members std::string yReverse_; // Y axis direction: "on"/"off" }; diff -Nru metview-5.17.4/metview/src/uPlot/ZoomStacks.cc metview-5.19.2/metview/src/uPlot/ZoomStacks.cc --- metview-5.17.4/metview/src/uPlot/ZoomStacks.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/uPlot/ZoomStacks.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,7 +12,7 @@ ZoomStacks::ZoomStacks() : zoomIndex_(-1) { - //empty constructor + // empty constructor } ZoomStacks::~ZoomStacks() = default; diff -Nru metview-5.17.4/metview/src/Vapor/gribToVapor.cc metview-5.19.2/metview/src/Vapor/gribToVapor.cc --- metview-5.17.4/metview/src/Vapor/gribToVapor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Vapor/gribToVapor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,7 +10,7 @@ #include #include -#include +#include #include "grib_api.h" @@ -32,36 +32,35 @@ int toVapor(const std::string& fgrib, const std::string& fvapor) { - FILE* fp; - FILE* fpOut; + FILE* fp = nullptr; + FILE* fpOut = nullptr; grib_handle* gh = nullptr; - int err = 0; + int err = 0; - double* value = nullptr; + double* value = nullptr; float* valueOut = nullptr; - size_t valNum = 0; + size_t valNum = 0; const int MAX_VAL_LEN = 64; - size_t vlen; + size_t vlen = 0; char cval[MAX_VAL_LEN]; - //Open grib file for reading + // Open grib file for reading fp = fopen(fgrib.c_str(), "r"); if (!fp) { std::cout << "Cannot open grib file: " << fgrib << std::endl; return 1; } - - //Open output file + // Open output file fpOut = fopen(fvapor.c_str(), "w+"); if (!fpOut) { std::cout << "Cannot open output file: " << fvapor << std::endl; + fclose(fp); return 1; } - - //Get messages form the file + // Get messages form the file int cnt = 0; while ((gh = grib_handle_new_from_file(nullptr, fp, &err)) != nullptr) { if (!gh) { @@ -69,7 +68,7 @@ return 1; } - //Grid type + // Grid type std::string gridType; vlen = MAX_VAL_LEN; if (grib_get_string(gh, "gridType", cval, &vlen) == GRIB_SUCCESS) { @@ -84,8 +83,8 @@ GRIB_CHECK(grib_get_string(gh, "shortName", cval, &vlen), nullptr); std::string shortName(cval); - //Get grid dimensions - long nx, ny; + // Get grid dimensions + long nx = 0, ny = 0; std::cout << "message: " << cnt << std::endl; GRIB_CHECK(grib_get_long(gh, "Ni", &nx), nullptr); @@ -93,16 +92,16 @@ std::cout << nx << " " << ny << std::endl; - //Allocate array for values - size_t num; + // Allocate array for values + size_t num = 0; grib_get_size(gh, "values", &num); if (num != static_cast(nx * ny)) { std::cout << "No values found" << std::endl; return 1; } else if (valNum == 0) { - valNum = num; - value = new double[num]; + valNum = num; + value = new double[num]; valueOut = new float[num]; } else if (num != valNum) { @@ -110,7 +109,7 @@ return 1; } - //Read values + // Read values if (grib_get_double_array(gh, "values", value, &valNum) != 0) { delete[] value; delete[] valueOut; @@ -118,14 +117,14 @@ return 1; } - //Check if data should be rearranged - long iScan, jScan; - long jOrder; - - //GRIB_CHECK(grib_get_double(gh,"latitudeOfFirstGridPointInDegrees",&lat1),0); - //GRIB_CHECK(grib_get_double(gh,"longitudeOfFirstGridPointInDegrees",&lon1),0); - //GRIB_CHECK(grib_get_double(gh,"latitudeOfLastGridPointInDegrees",&lat2),0); - //GRIB_CHECK(grib_get_double(gh,"longitudeOfLastGridPointInDegrees",&lon2),0); + // Check if data should be rearranged + long iScan = 0, jScan = 0; + long jOrder = 0; + + // GRIB_CHECK(grib_get_double(gh,"latitudeOfFirstGridPointInDegrees",&lat1),0); + // GRIB_CHECK(grib_get_double(gh,"longitudeOfFirstGridPointInDegrees",&lon1),0); + // GRIB_CHECK(grib_get_double(gh,"latitudeOfLastGridPointInDegrees",&lat2),0); + // GRIB_CHECK(grib_get_double(gh,"longitudeOfLastGridPointInDegrees",&lon2),0); GRIB_CHECK(grib_get_long(gh, "iScansPositively", &iScan), nullptr); GRIB_CHECK(grib_get_long(gh, "jScansPositively", &jScan), nullptr); @@ -133,7 +132,7 @@ std::cout << "nx=" << nx << " ny=" << ny << " iScan=" << iScan << " jScan=" << jScan << " jOrder=" << jOrder << std::endl; - //i-direction scan + // i-direction scan if (jOrder == 0) { if (iScan == 1 && jScan == 0) { for (unsigned int j = 0; j < ny; j++) @@ -165,7 +164,7 @@ valueOut[i] /= 9.81; - //Write out fields + // Write out fields fwrite(valueOut, 4, valNum, fpOut); grib_handle_delete(gh); diff -Nru metview-5.17.4/metview/src/Vapor/VaporPrepare.cc metview-5.19.2/metview/src/Vapor/VaporPrepare.cc --- metview-5.17.4/metview/src/Vapor/VaporPrepare.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Vapor/VaporPrepare.cc 2023-07-15 08:28:47.000000000 +0000 @@ -142,7 +142,7 @@ { int currentValue = fromValue; - resVal = vals[0]; + resVal = vals[0]; currentValue += byValue; while (currentValue <= toValue) { std::stringstream sst; @@ -165,15 +165,15 @@ } /*if(isDate) - { - std::string s; - if(getDate(resVal,s,parMv)) - { - resVal=s; - } - else - resVal.clear(); - }*/ + { + std::string s; + if(getDate(resVal,s,parMv)) + { + resVal=s; + } + else + resVal.clear(); + }*/ if (!resVal.empty()) { @@ -228,12 +228,12 @@ double trVal; float nx = (area[2] - area[0]) / grid[1]; - trVal = trunc(nx); + trVal = trunc(nx); if (nx != trVal || static_cast(static_cast(trVal)) != trVal) return false; float ny = (area[3] - area[1]) / grid[0]; - trVal = trunc(ny); + trVal = trunc(ny); if (ny != trVal || static_cast(static_cast(trVal)) != trVal) return false; @@ -247,7 +247,7 @@ std::string errTxt; err = false; - //Add outpath + // Add outpath std::string outPath; if (!in.getPath("VAPOR_OUTPUT_PATH", outPath, true)) { setError(0, "VaporPrepare-> parameter VAPOR_OUTPUT_PATH not defined"); @@ -282,25 +282,25 @@ std::string errTxt; - //Add outpath + // Add outpath std::string outPath; if (!in.getPath("VAPOR_OUTPUT_PATH", outPath, true)) { setError(1, "VaporPrepare-> parameter VAPOR_OUTPUT_PATH not defined"); return; } - //Add vdf filename + // Add vdf filename std::string vdfName; VAPOR_CHK(getParamValue(vdfName, in, "VAPOR_VDF_NAME")); std::string logFile(marstmp()); std::string vdfFile = outPath + "/" + vdfName + ".vdf"; - std::string cmd = vaporScript + " \"" + vdfFile + "\" \"" + logFile + "\""; + std::string cmd = vaporScript + " \"" + vdfFile + "\" \"" + logFile + "\""; int ret = system(cmd.c_str()); - //If the script failed read log file and - //write it into LOG_EROR + // If the script failed read log file and + // write it into LOG_EROR if (ret == -1 || WEXITSTATUS(ret) != 0) { std::ifstream in(logFile.c_str()); std::string line; @@ -341,7 +341,7 @@ std::vector param; std::string str, errTxt; - //Add outpath + // Add outpath std::string outPath; if (!in.getPath("VAPOR_OUTPUT_PATH", outPath, true)) { setError(1, "VaporPrepare-> parameter VAPOR_OUTPUT_PATH not defined"); @@ -349,7 +349,7 @@ } param.push_back(outPath); - //Add vdf filename + // Add vdf filename std::string vdfName; VAPOR_CHK(getParamValue(vdfName, in, "VAPOR_VDF_NAME")); param.push_back(vdfName); @@ -360,18 +360,18 @@ // //============================== - //Add reuse(check) input status + // Add reuse(check) input status std::string reuseVdf; VAPOR_CHK(getParamValue(str, in, "VAPOR_REUSE_VDF")); param.push_back((str == "ON") ? "1" : "0"); - //Add refinement level + // Add refinement level std::string refLevel; VAPOR_CHK(getParamValue(refLevel, in, "VAPOR_REFINEMENT_LEVEL")); param.push_back(refLevel); - //Add vertical grid type + // Add vertical grid type std::string vGrid; VAPOR_CHK(getParamValue(vGrid, in, "VAPOR_VERTICAL_GRID_TYPE")); param.push_back(vGrid); @@ -381,7 +381,7 @@ VAPOR_CHK(getParamValue(hVar, in, "VAPOR_ELEVATION_PARAM")); param.push_back(hVar); - //Add min-max vertical coordinate + // Add min-max vertical coordinate std::string vMin; VAPOR_CHK(getParamValue(vMin, in, "VAPOR_BOTTOM_COORDINATE")); param.push_back(vMin); @@ -391,18 +391,18 @@ param.push_back(vMax); } - //Add are selection + // Add are selection std::string areaSelect; VAPOR_CHK(getParamValue(areaSelect, in, "VAPOR_AREA_SELECTION")); param.push_back((areaSelect == "INTERPOLATE") ? "1" : "0"); if (areaSelect == "INTERPOLATE") { - //Add area + // Add area std::string area; VAPOR_CHK(getParamValue(area, in, "VAPOR_AREA")); param.push_back(area); - //Add grid resolution + // Add grid resolution std::string grid; VAPOR_CHK(getParamValue(grid, in, "VAPOR_GRID")); param.push_back(grid); @@ -413,22 +413,22 @@ } } - //Add steps numbers + // Add steps numbers std::string stepParams; VAPOR_CHK(getParamValue(stepParams, in, "VAPOR_STEP_NUMBER")); param.push_back(stepParams); - //Add surf params + // Add surf params std::string surfParams; VAPOR_CHK(getParamValue(surfParams, in, "VAPOR_2D_PARAMS", true)); param.push_back(surfParams); - //Add upper params + // Add upper params std::string upperParams; VAPOR_CHK(getParamValue(upperParams, in, "VAPOR_3D_PARAMS")); param.push_back(upperParams); - //Create tmp dir for vapor + // Create tmp dir for vapor std::string tmpPath; if (!metview::createWorkDir("vapor", tmpPath, errTxt)) { setError(1, "VaporPrepare-> %s", errTxt.c_str()); @@ -436,14 +436,14 @@ } param.push_back(tmpPath); - //Add perparation mode + // Add perparation mode std::string inputMode; VAPOR_CHK(getParamValue(inputMode, in, "VAPOR_INPUT_MODE")); param.push_back(inputMode); - //Add input files + // Add input files if (inputMode == "ICON") { - //Add mars expver + // Add mars expver std::vector gribFiles; VAPOR_CHK(getInputFiles(gribFiles, in, "VAPOR_INPUT_DATA")); for (auto& gribFile : gribFiles) @@ -452,24 +452,24 @@ else { } - //Build request to be sent to Macro + // Build request to be sent to Macro MvRequest req("MACRO"); std::string processName = MakeProcessName("VaporPrepare"); MvRequest macroReq("MACRO"); - req("PATH") = vaporMacro.c_str(); - req("_CLASS") = "MACRO"; + req("PATH") = vaporMacro.c_str(); + req("_CLASS") = "MACRO"; req("_ACTION") = "execute"; - req("_REPLY") = processName.c_str(); + req("_REPLY") = processName.c_str(); - //Define argument list for the macro! + // Define argument list for the macro! for (auto& it : param) { req.addValue("_ARGUMENTS", it.c_str()); } - //Run macro + // Run macro int error; - //marslog(LOG_INFO,"Execute macro: %s",vaporMacro.c_str()); + // marslog(LOG_INFO,"Execute macro: %s",vaporMacro.c_str()); MvRequest reply = MvApplication::waitService("macro", req, error); std::string logFile = tmpPath + "/m_log.txt"; @@ -479,8 +479,8 @@ marslog(LOG_INFO, "---------------------------"); marslog(LOG_INFO, " %s", logFile.c_str()); - //const char* myname = reply("_REPLY"); - //MvApplication::callService(myname,reply,0); + // const char* myname = reply("_REPLY"); + // MvApplication::callService(myname,reply,0); } else { std::ifstream in(errFile.c_str()); @@ -499,11 +499,11 @@ setError(1, "VaporPrepare-> Failed to perform VAPOR Prepare!"); return; } - //reply.print(); + // reply.print(); - out = MvRequest("VAPOR_INPUT"); + out = MvRequest("VAPOR_INPUT"); out("INPUT_DATA_PATH") = outPath.c_str(); - //out("AVAILABLE_FILE_PATH")=fAvailable.c_str(); + // out("AVAILABLE_FILE_PATH")=fAvailable.c_str(); } @@ -514,12 +514,12 @@ // Get user action mode const char* modeC = (const char*)in("_ACTION"); - std::string mode = "execute"; + std::string mode = "execute"; if (modeC) mode = std::string(modeC); if (mode == "visualise") { - bool err = false; + bool err = false; bool hasVdf = vdfExists(in, err); if (err) { diff -Nru metview-5.17.4/metview/src/Velstr/Velstr.cc metview-5.19.2/metview/src/Velstr/Velstr.cc --- metview-5.17.4/metview/src/Velstr/Velstr.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Velstr/Velstr.cc 2023-07-15 08:28:47.000000000 +0000 @@ -51,7 +51,7 @@ MvFieldSet fset(grib); // field set MvFieldSetIterator fsiter(fset); // field set iterator MvField field; // auxiliary field - int nfields; // number of fields + int nfields = 0; // number of fields // Get fields diff -Nru metview-5.17.4/metview/src/Velstr/velstr-exFortran.cc metview-5.19.2/metview/src/Velstr/velstr-exFortran.cc --- metview-5.17.4/metview/src/Velstr/velstr-exFortran.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Velstr/velstr-exFortran.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,7 +11,7 @@ //-- from obsolete files velstr.F, dvvalid.F, and bppsmth.F. The old //-- Fortran code has been left here for possible verifications. (090820/vk) -#include +#include #include #include "Velstr.h" @@ -202,7 +202,7 @@ END #endif -//CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC +// CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC //_____________________________________________________________________________ #if 0 SUBROUTINE DVTOVS(P,K1,KTIN,KTOUT) @@ -258,35 +258,35 @@ void Velstr::convert_DVTOVS(grib_handle* gh, int trunc_out) { - const double earth = 6.371e6; + const double earth = 6.371e6; const double earths = -earth * earth; size_t len = 0; //-- data values count - int ret = grib_get_size(gh, "values", &len); + int ret = grib_get_size(gh, "values", &len); badRetVal(ret, "grib_get_size", "Velstr::convert_DVTOVS"); auto* data = new double[len]; //-- get data values - ret = grib_get_double_array(gh, "values", data, &len); + ret = grib_get_double_array(gh, "values", data, &len); badRetVal(ret, "grib_get_double_array", "Velstr::convert_DVTOVS"); long truncIn = 0; //-- get truncation - ret = grib_get_long(gh, "pentagonalResolutionParameterJ", &truncIn); + ret = grib_get_long(gh, "pentagonalResolutionParameterJ", &truncIn); badRetVal(ret, "grib_get_long", "Velstr::convert_DVTOVS"); - int jmuaf = (trunc_out + 1) * (trunc_out + 2) + 1; + int jmuaf = (trunc_out + 1) * (trunc_out + 2) + 1; auto* dummy = new double[jmuaf]; - dummy[0] = 0; + dummy[0] = 0; for (int n = 1; n < jmuaf; ++n) { dummy[n] = earths / (double)(n * (n + 1)); } - int itinp1 = truncIn + 1; + int itinp1 = truncIn + 1; int itoutp1 = trunc_out + 1; - int i = 0; - int ii = 0; + int i = 0; + int ii = 0; for (int m = 0; m < itoutp1; ++m) { for (int n = m; n < itoutp1; ++n) { - data[ii] = dummy[n] * data[i]; + data[ii] = dummy[n] * data[i]; data[ii + 1] = dummy[n] * data[i + 1]; i += 2; ii += 2; @@ -301,7 +301,7 @@ ret = grib_set_double_array(gh, "values", data, ii); badRetVal(ret, "grib_set_double_array", "Velstr::convert_DVTOVS"); - //trunc = trunc_out; + // trunc = trunc_out; delete[] data; delete[] dummy; return; @@ -347,7 +347,7 @@ char charBuf[cBUFLEN + 1]; size_t len = cBUFLEN; //-- is spectral or not? - int ret = grib_get_string(gh, "gridType", charBuf, &len); + int ret = grib_get_string(gh, "gridType", charBuf, &len); badRetVal(ret, "grib_get_string/gridType", "Velstr::isValidData_DVVALID"); if (std::string(charBuf) != cSPECTRAL) { @@ -355,7 +355,7 @@ return false; } - long param; + long param = 0; ret = grib_get_long(gh, "mars.param", ¶m); badRetVal(ret, "grib_get_long/mars.param", "Velstr::isValidData_DVVALID"); @@ -432,15 +432,15 @@ bool Velstr::smooth_BPPSMTH(grib_handle* gh) { size_t len = 0; //-- data values count - int ret = grib_get_size(gh, "values", &len); + int ret = grib_get_size(gh, "values", &len); badRetVal(ret, "grib_get_size", "Velstr::smooth_BPPSMTH"); auto* data = new double[len]; //-- get data values - ret = grib_get_double_array(gh, "values", data, &len); + ret = grib_get_double_array(gh, "values", data, &len); badRetVal(ret, "grib_get_double_array", "Velstr::smooth_BPPSMTH"); long truncIn = 0; //-- get truncation - ret = grib_get_long(gh, "pentagonalResolutionParameterJ", &truncIn); + ret = grib_get_long(gh, "pentagonalResolutionParameterJ", &truncIn); badRetVal(ret, "pentagonalResolutionParameterJ", "Velstr::smooth_BPPSMTH"); //-- prepare smoothing stuff @@ -451,16 +451,16 @@ long itinp1 = truncIn; //-- NPREL4 auto* dummy = new double[itinp1]; //-- compute final smoothing coefficients - dummy[0] = 1.0; + dummy[0] = 1.0; for (int n = 1; n < itinp1; ++n) { dummy[n] = exp(fltcons * pow((double)(n * (n + 1)), Vmfltexp)); } - int i = 0; //-- do the smoothing + int i = 0; //-- do the smoothing int ii = 0; for (int m = 0; m < itinp1; ++m) for (int n = m; n < itinp1; ++n) { - data[ii] = dummy[n] * data[i]; + data[ii] = dummy[n] * data[i]; data[ii + 1] = dummy[n] * data[i + 1]; i += 2; ii += 2; @@ -478,11 +478,11 @@ void Velstr::scaleData(grib_handle* gh) { size_t len = 0; //-- data values count - int ret = grib_get_size(gh, "values", &len); + int ret = grib_get_size(gh, "values", &len); badRetVal(ret, "grib_get_size", "Velstr::scaleData"); auto* data = new double[len]; //-- get data values - ret = grib_get_double_array(gh, "values", data, &len); + ret = grib_get_double_array(gh, "values", data, &len); badRetVal(ret, "grib_get_double_array", "Velstr::scaleData"); sendProgress("Output data scaled"); @@ -501,7 +501,7 @@ bool Velstr::checkOutputTruncation(grib_handle* gh) { long truncIn = 0; //-- get truncation - int ret = grib_get_long(gh, "pentagonalResolutionParameterJ", &truncIn); + int ret = grib_get_long(gh, "pentagonalResolutionParameterJ", &truncIn); badRetVal(ret, "pentagonalResolutionParameterJ", "Velstr::smooth_BPPSMTH"); if (Vtrunc > truncIn) { diff -Nru metview-5.17.4/metview/src/Velstr/Velstr.h metview-5.19.2/metview/src/Velstr/Velstr.h --- metview-5.17.4/metview/src/Velstr/Velstr.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/Velstr/Velstr.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,8 @@ public: Velstr(const char* a) : MvService(a) {} - ~Velstr() {} - void serve(MvRequest&, MvRequest&); + ~Velstr() override = default; + void serve(MvRequest&, MvRequest&) override; virtual bool GetData(MvRequest&) = 0; bool GetDataGen(MvRequest&); @@ -50,7 +50,7 @@ public: Velpot(const char* a) : Velstr(a) {} - virtual bool GetData(MvRequest&); + bool GetData(MvRequest&) override; }; @@ -59,7 +59,7 @@ public: Streamfn(const char* a) : Velstr(a) {} - virtual bool GetData(MvRequest&); + bool GetData(MvRequest&) override; }; /* VELSTR_H */ diff -Nru metview-5.17.4/metview/src/XSection/Average.cc metview-5.19.2/metview/src/XSection/Average.cc --- metview-5.17.4/metview/src/XSection/Average.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/Average.cc 2023-07-15 08:28:47.000000000 +0000 @@ -127,7 +127,7 @@ // Compute number of points int Average::computeGeographicalPoints(ApplicationInfo& appInfo, MvField*) { - double x1, x2, y1, y2; + double x1 = 0., x2 = 0., y1 = 0., y2 = 0.; appInfo.getAreaLine(x1, x2, y1, y2); int numberNS = (int)(fabs((appInfo.Y1() - appInfo.Y2()) / appInfo.GridNS()) + 0.0000001) + 1; // avoid precision errors @@ -149,9 +149,9 @@ { // Get initial info MvFieldExpander x(field); - int i; + int i = 0; int npoint = appInfo.NrPoints(); - double X1, X2, Y1, Y2; + double X1 = 0., X2 = 0., Y1 = 0., Y2 = 0.; appInfo.getAreaLine(X1, X2, Y1, Y2); // Average over area @@ -179,7 +179,7 @@ { // Create netCDF data request MvRequest xs("NETCDF"); - xs("PATH") = ncName_.c_str(); + xs("PATH") = ncName_.c_str(); xs("TEMPORARY") = 1; std::string dims = XS_VARTIME + ":0"; @@ -187,13 +187,13 @@ // Create NetCDF output request std::string varname = getNetcdfVarname(parInfo->ParamName()).c_str(); MvRequest out1("NETCDF_XY_MATRIX"); - out1("NETCDF_DATA") = xs; - out1("NETCDF_MISSING_ATTRIBUTE") = "_FillValue"; - out1("NETCDF_VALUE_VARIABLE") = varname.c_str(); - out1("NETCDF_Y_VARIABLE") = getNetcdfLevelVarname(varname).c_str(); - out1("NETCDF_X_VARIABLE") = (inputMode_ == AVERAGE_NS) ? "lon" : "lat"; + out1("NETCDF_DATA") = xs; + out1("NETCDF_MISSING_ATTRIBUTE") = "_FillValue"; + out1("NETCDF_VALUE_VARIABLE") = varname.c_str(); + out1("NETCDF_Y_VARIABLE") = getNetcdfLevelVarname(varname).c_str(); + out1("NETCDF_X_VARIABLE") = (inputMode_ == AVERAGE_NS) ? "lon" : "lat"; out1("NETCDF_DIMENSION_SETTING_METHOD") = "index"; - out1("NETCDF_DIMENSION_SETTING") = dims.c_str(); + out1("NETCDF_DIMENSION_SETTING") = dims.c_str(); // Add information to help the Macro Converter to translate // the output request to a Macro code @@ -210,8 +210,8 @@ if ((const char*)origReq_("DIRECTION")) viewReq("DIRECTION") = origReq_("DIRECTION"); - viewReq("_CLASS") = "MXAVERAGEVIEW"; - viewReq("_DEFAULT") = true; + viewReq("_CLASS") = "MXAVERAGEVIEW"; + viewReq("_DEFAULT") = true; viewReq("_DATAATTACHED") = "YES"; if (appInfo.levelType() != cML_UKMO_ND && appInfo.levelType() != XS_ML_GHBC) // UK MetOffice model levels and GHBC fields are 'upside-down' @@ -221,8 +221,8 @@ // Also, add the visualisation and original requests as hidden parameters. // These may be used later to help the visualisation of the netcdf data. if (!isVisualise(appInfo)) { - xs("_VIEW") = view_.c_str(); - xs("_VISUALISE") = out1; + xs("_VIEW") = view_.c_str(); + xs("_VISUALISE") = out1; xs("_VIEW_REQUEST") = viewReq; return xs; } @@ -260,7 +260,7 @@ (x1 < 0) ? -x1 : x1, (x1 < 0) ? "W" : "E", (x2 < 0) ? -x2 : x2, (x2 < 0) ? "W" : "E"); } - else //AVERAGE_NS + else // AVERAGE_NS { double y1 = appInfo.Y1(); double y2 = appInfo.Y2(); @@ -271,7 +271,7 @@ (y2 < 0) ? -y2 : y2, (y2 < 0) ? "S" : "N"); } - return std::string(titlestr); + return {titlestr}; } //------------------------------------------------------------------------- diff -Nru metview-5.17.4/metview/src/XSection/Average.h metview-5.19.2/metview/src/XSection/Average.h --- metview-5.17.4/metview/src/XSection/Average.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/Average.h 2023-07-15 08:28:47.000000000 +0000 @@ -36,26 +36,26 @@ // Get geographical coordinates and application parameters bool getCoordinates(MvRequest&, ApplicationInfo&); - bool getAppParameters(MvRequest&, ApplicationInfo&); + bool getAppParameters(MvRequest&, ApplicationInfo&) override; - bool generateData(ApplicationInfo&, ParamMap&, MvNetCDF&, MvField&, const std::string&); + bool generateData(ApplicationInfo&, ParamMap&, MvNetCDF&, MvField&, const std::string&) override; // Create output request - MvRequest createOutputRequest(ApplicationInfo&, ParamInfo*); + MvRequest createOutputRequest(ApplicationInfo&, ParamInfo*) override; - int computeGeographicalPoints(ApplicationInfo&, MvField* = 0); + int computeGeographicalPoints(ApplicationInfo&, MvField* = nullptr) override; - bool fillValues(ApplicationInfo&, MvField&, double*); + bool fillValues(ApplicationInfo&, MvField&, double*) override; - bool fieldConsistencyCheck(MvField&, double, double, double, double); + bool fieldConsistencyCheck(MvField&, double, double, double, double) override; // Check if parameters between two requests are consistent - bool consistencyCheck(MvRequest&, MvRequest&); + bool consistencyCheck(MvRequest&, MvRequest&) override; private: - std::string titleVariable(ApplicationInfo&, ParamInfo*); + std::string titleVariable(ApplicationInfo&, ParamInfo*) override; - int inputMode_; // AVERAGE_NS/AVERAGE_EW + int inputMode_{0}; // AVERAGE_NS/AVERAGE_EW }; //--------------------------------------------------------------------- @@ -66,5 +66,5 @@ AverageM3() : Average("PM_AVERAGE") {} - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; diff -Nru metview-5.17.4/metview/src/XSection/CrossS.cc metview-5.19.2/metview/src/XSection/CrossS.cc --- metview-5.17.4/metview/src/XSection/CrossS.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/CrossS.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,7 +28,7 @@ #include "CrossS.h" #include "MvException.h" -#include "assert.h" +#include #include #include @@ -63,14 +63,14 @@ { moduleLabel_ = "CrossSection-> "; Xsect::init(); - windProjection_ = NoWindProjection; - windMode_ = NoWindMode; + windProjection_ = NoWindProjection; + windMode_ = NoWindMode; useWindIntensity_ = false; - outputMode_ = ScalarOutput; - oroColour_ = "CYAN"; - wScaling_ = -100; - wMode_ = Mv3VerticalVelocity; - plotVar_ = nullptr; + outputMode_ = ScalarOutput; + oroColour_ = "CYAN"; + wScaling_ = -100; + wMode_ = Mv3VerticalVelocity; + plotVar_ = nullptr; } bool CrossS::getCoordinates(MvRequest& in, ApplicationInfo& appInfo) @@ -158,10 +158,10 @@ } if (appInfo.extrapolateGHBC()) { if (const char* ch = in("VERTICAL_COORDINATE_EXTRAPOLATE_MODE")) { - appInfo.setExtrapolateGHBCMode((strcmp(ch, "CONSTANT") == 0)?ConstantExtrapolation:LinearExtrapolation); + appInfo.setExtrapolateGHBCMode((strcmp(ch, "CONSTANT") == 0) ? ConstantExtrapolation : LinearExtrapolation); } if (const char* ch = in("VERTICAL_COORDINATE_EXTRAPOLATE_FIXED_SIGN")) { - appInfo.setExtrapolateGHBCFixedSign((strcmp(ch, "ON") == 0)?true:false); + appInfo.setExtrapolateGHBCFixedSign((strcmp(ch, "ON") == 0) ? true : false); } } @@ -201,8 +201,8 @@ } if ((const char*)in("LEVEL_LIST")) { - double val; - int cnt = in.iterInit("LEVEL_LIST"); + double val = 0.; + int cnt = in.iterInit("LEVEL_LIST"); std::vector lslist; lslist.reserve(cnt); for (int i = 0; i < cnt; ++i) { @@ -221,7 +221,7 @@ if ((const char*)in("VERTICAL_SCALING")) { std::string vs = (const char*)in("VERTICAL_SCALING"); - bool bvs = (vs == "LINEAR") ? true : false; + bool bvs = (vs == "LINEAR") ? true : false; appInfo.vLinearScaling(bvs); } @@ -316,24 +316,37 @@ if (windMode_ == Wind2DMode && (!useWindIntensity_ && windProjection_ == NoWindProjection && needVectorOutput_)) { - assert(par->Parameter() == std::max({U_FIELD, V_FIELD})); + if (par->Parameter() != std::max({U_FIELD, V_FIELD})) { + throw MvException(moduleLabel_ + "wrong GRIB parameterId=" + std::to_string(par->Parameter()) + + " in Wind2DMode"); + } + outputMode_ = determineWindOutputMode(); assert(outputMode_ == VectorOutput); return wind2DValues(appInfo, params, cdf, key, field); } else if (windMode_ == Wind2DMode) { - assert(par->Parameter() == std::max({U_FIELD, V_FIELD})); + if (par->Parameter() != std::max({U_FIELD, V_FIELD})) { + throw MvException(moduleLabel_ + "wrong GRIB parameterId=" + std::to_string(par->Parameter()) + + " in Wind2DMode"); + } outputMode_ = determineWindOutputMode(); assert(outputMode_ == ScalarOutput); return wind2DValues(appInfo, params, cdf, key, field); } else if (windMode_ == Wind3DMode) { - assert(par->Parameter() == std::max({U_FIELD, V_FIELD, W_FIELD})); + if (par->Parameter() != std::max({U_FIELD, V_FIELD, W_FIELD})) { + throw MvException(moduleLabel_ + "wrong GRIB parameterId=" + std::to_string(par->Parameter()) + + " in Wind3DMode"); + } outputMode_ = determineWindOutputMode(); return wind3DValues(appInfo, params, cdf, key, field); } else if (windMode_ == Wind3DWithTMode) { - assert(par->Parameter() == std::max({U_FIELD, V_FIELD, W_FIELD, T_FIELD})); + if (par->Parameter() != std::max({U_FIELD, V_FIELD, W_FIELD, T_FIELD})) { + throw MvException(moduleLabel_ + "wrong GRIB parameterId=" + std::to_string(par->Parameter()) + + " in Wind3DMode"); + } outputMode_ = determineWindOutputMode(); return wind3DValues(appInfo, params, cdf, key, field); } @@ -394,17 +407,17 @@ bool CrossS::generateLNSP(ApplicationInfo& appInfo, MvNetCDF& cdf, ParamInfo* par) { // Get initial info - double low = appInfo.tohPa(appInfo.topLevel()); - double high = appInfo.tohPa(appInfo.bottomLevel()); + double low = appInfo.tohPa(appInfo.topLevel()); + double high = appInfo.tohPa(appInfo.bottomLevel()); int nrPoints = appInfo.NrPoints(); // Add/update LNSP and auxiliary variables to the netCDF // These auxiliary variables will be used to plot the orography std::string varname = Xsect::getNetcdfVarname(par->ParamName()); // varname is LNSP - MvNcVar* ncx1 = cdf.getVariable("orography_x_values"); - MvNcVar* ncy1 = cdf.getVariable("orography_y1_values"); - MvNcVar* ncy2 = cdf.getVariable("orography_y2_values"); - MvNcVar* ncln = cdf.getVariable(varname); + MvNcVar* ncx1 = cdf.getVariable("orography_x_values"); + MvNcVar* ncy1 = cdf.getVariable("orography_y1_values"); + MvNcVar* ncy2 = cdf.getVariable("orography_y2_values"); + MvNcVar* ncln = cdf.getVariable(varname); if (!ncx1 || !ncy1 || !ncy2 || !ncln) // Create new variables { ntime_ = -1; @@ -415,7 +428,7 @@ values_ndim.push_back(nrPoints); std::vector values_sdim; values_sdim.push_back(XS_VARTIME); - values_sdim.push_back("npoints"); + values_sdim.emplace_back("npoints"); // Create LNSP variable if (!ncln) { @@ -462,8 +475,8 @@ auto* y2_values = new double[nrPoints]; // Get X values - const std::vector& lon = (appInfo.haveLonsForPlotting()) ? appInfo.getLongitudeForPlotting() : appInfo.getLongitude(); - const std::vector& lat = (appInfo.haveLatsForPlotting()) ? appInfo.getLatitudeForPlotting() : appInfo.getLatitude(); + const std::vector& lon = (appInfo.haveLonsForPlotting()) ? appInfo.getLongitudeForPlotting() : appInfo.getLongitude(); + const std::vector& lat = (appInfo.haveLatsForPlotting()) ? appInfo.getLatitudeForPlotting() : appInfo.getLatitude(); const std::vector& x_values = (lon[0] == lon[1]) ? lat : lon; // Compute Y values @@ -472,8 +485,8 @@ y1_values[i] = high; else { double w = appInfo.tohPa(exp(splin[i])); - w = MAX(low, w); - w = MIN(high, w); + w = MAX(low, w); + w = MIN(high, w); y1_values[i] = w; } y2_values[i] = high; @@ -516,7 +529,7 @@ if (par_u->Levels().size() != par_v->Levels().size()) { throw MvException(moduleLabel_ + "number of levels for u and v must be the same! " + - std::to_string(par_u->Levels().size()) + " != " + std::to_string(par_v->Levels().size())); + std::to_string(par_u->Levels().size()) + " != " + std::to_string(par_v->Levels().size())); } // Wind speed @@ -559,7 +572,7 @@ // Create variable 'levels' std::string levname = this->getNetcdfLevelVarname(varname); - MvNcVar* nclevels = cdf.getVariable(levname); + MvNcVar* nclevels = cdf.getVariable(levname); // Create variable 'levels' if (!nclevels) { @@ -614,7 +627,7 @@ // Write level values to the netCDF nclevels->setCurrent(ntime_); - //Pa -> hPa + // Pa -> hPa if (appInfo.levelType() == XS_PL || appInfo.levelType() == XS_ML_LNSP) { for (int j = 0; j < nrLevels; j++) { y_values[j] = appInfo.tohPa(y_values[j]); @@ -672,7 +685,7 @@ // Create variable 'levels' std::string levname = this->getNetcdfLevelVarname(varname); - MvNcVar* nclevels = cdf.getVariable(levname); + MvNcVar* nclevels = cdf.getVariable(levname); // Create variable 'levels' if (!nclevels) { @@ -727,7 +740,7 @@ // Write level values to the netCDF nclevels->setCurrent(ntime_); - //Pa -> hPa + // Pa -> hPa if (appInfo.levelType() == XS_PL || appInfo.levelType() == XS_ML_LNSP) { for (int j = 0; j < nrLevels; j++) { y_values[j] = appInfo.tohPa(y_values[j]); @@ -747,7 +760,7 @@ //--------------------------------------- size_t y_values_size_ori = y_values.size(); - size_t cp_size_ori = cp.size(); + size_t cp_size_ori = cp.size(); if (!appInfo.computeLevelMatrixValues(params, key, par_v, y_values, cp, field)) { setError(1, "CrossS::wind2DValues --> Could not find the requested field for v wind component! key=%s", key.c_str()); @@ -828,12 +841,12 @@ if (par_u->Levels().size() != par_v->Levels().size()) { throw MvException(moduleLabel_ + "number of levels for u and v must be the same! " + - std::to_string(par_u->Levels().size()) + " != " + std::to_string(par_v->Levels().size())); + std::to_string(par_u->Levels().size()) + " != " + std::to_string(par_v->Levels().size())); } if (par_u->Levels().size() != par_w->Levels().size()) { throw MvException(moduleLabel_ + "number of levels for u and w must be the same! " + - std::to_string(par_u->Levels().size()) + " != " + std::to_string(par_w->Levels().size())); + std::to_string(par_u->Levels().size()) + " != " + std::to_string(par_w->Levels().size())); } // Create a structure for the result/horizontal component @@ -857,7 +870,7 @@ // hydrostatic computation: omega to w } else if (wMode_ == ComputedVerticalVelocity) { - ParamInfo* par_t = nullptr; + ParamInfo* par_t = nullptr; ParamInfo* par_lnsp = nullptr; if (windMode_ == Wind3DWithTMode) { par_t = appInfo.getParamInfo(params, T_FIELD, key); @@ -918,7 +931,7 @@ // Create variable 'levels' // this depends on the output mode! std::string levname = this->getNetcdfLevelVarname(varname); - MvNcVar* nclevels = cdf.getVariable(levname); + MvNcVar* nclevels = cdf.getVariable(levname); // Create variable 'levels' if (!nclevels) { @@ -972,7 +985,7 @@ // Write level values to the netCDF nclevels->setCurrent(ntime_); - //Pa -> hPa + // Pa -> hPa if (appInfo.levelType() == XS_PL || appInfo.levelType() == XS_ML_LNSP) { for (int j = 0; j < nrLevels; j++) { y_values[j] = appInfo.tohPa(y_values[j]); @@ -995,7 +1008,7 @@ assert(windProjection_ == ParallelWindProjection && !useWindIntensity_); size_t y_values_size_ori = y_values.size(); - size_t cp_size_ori = cp.size(); + size_t cp_size_ori = cp.size(); // interpolate w result onto the output levels if (!appInfo.computeLevelMatrixValues(params, key, par_w, y_values, cp, field)) { @@ -1017,7 +1030,7 @@ // Get/create the netCDF variable (y_component) varname = this->getNetcdfYComponentVarname(); - //ncvy = this->getNetcdfVariable(cdf, varname, appInfo, varname, par_w); + // ncvy = this->getNetcdfVariable(cdf, varname, appInfo, varname, par_w); // Create netCDF variable ncv = cdf.getVariable(varname); @@ -1203,14 +1216,14 @@ LevelMap lmap_u = par_u->Levels(); LevelMap lmap_v = par_v->Levels(); auto uu = lmap_u.begin(), vv = lmap_v.begin(); - double *uValues, *vValues; + double *uValues = nullptr, *vValues = nullptr; assert(lmap_u.size() == lmap_v.size()); - int nrPoints = appInfo.NrPoints(); + int nrPoints = appInfo.NrPoints(); auto* valuesuv = new double[nrPoints]; - double ansin = appInfo.Ansin(); - double ancos = appInfo.Ancos(); + double ansin = appInfo.Ansin(); + double ancos = appInfo.Ancos(); for (; uu != lmap_u.end() && vv != lmap_v.end(); uu++, vv++) { uValues = (*uu).second->XValues(); @@ -1254,19 +1267,19 @@ LevelMap lmap_u = par_u->Levels(); LevelMap lmap_v = par_v->Levels(); LevelMap lmap_w = par_w->Levels(); - auto uu = lmap_u.begin(); - auto vv = lmap_v.begin(); - auto ww = lmap_w.begin(); + auto uu = lmap_u.begin(); + auto vv = lmap_v.begin(); + auto ww = lmap_w.begin(); assert(lmap_u.size() == lmap_v.size()); assert(lmap_u.size() == lmap_w.size()); double *uValues = nullptr, *vValues = nullptr, *wValues = nullptr; - int nrPoints = appInfo.NrPoints(); + int nrPoints = appInfo.NrPoints(); auto* valuesuv = new double[nrPoints]; - double ansin = appInfo.Ansin(); - double ancos = appInfo.Ancos(); + double ansin = appInfo.Ansin(); + double ancos = appInfo.Ancos(); for (; uu != lmap_u.end() && vv != lmap_v.end() && ww != lmap_w.end(); uu++, vv++, ww++) { uValues = (*uu).second->XValues(); @@ -1313,7 +1326,7 @@ int CrossS::computeGeographicalPoints(ApplicationInfo& appInfo, MvField* field) { // Compute distance - double x1, x2, y1, y2; + double x1 = 0., x2 = 0., y1 = 0., y2 = 0.; appInfo.getAreaLine(x1, x2, y1, y2); double dellat = ABS(y2 - y1), dellon = ABS(x2 - x1); @@ -1340,7 +1353,7 @@ MvFieldExpander x(field); // Get number of points and lat/long interpolation points - int npoint = appInfo.NrPoints(); + int npoint = appInfo.NrPoints(); const std::vector& lat = appInfo.getLatitude(); const std::vector& lon = appInfo.getLongitude(); @@ -1348,13 +1361,13 @@ // Interpolatate along XS line for (i = 0; i < npoint; i++) { double val = field.interpolateAt(lon[i], lat[i]); - vals[i] = (val >= DBL_MAX) ? XMISSING_VALUE : val; + vals[i] = (val >= DBL_MAX) ? XMISSING_VALUE : val; } } else { for (i = 0; i < npoint; i++) { double val = field.nearestGridpoint(lon[i], lat[i], false); - vals[i] = (val >= DBL_MAX) ? XMISSING_VALUE : val; + vals[i] = (val >= DBL_MAX) ? XMISSING_VALUE : val; } } @@ -1365,7 +1378,7 @@ { // Create netCDF data request MvRequest xs("NETCDF"); - xs("PATH") = ncName_.c_str(); + xs("PATH") = ncName_.c_str(); xs("TEMPORARY") = 1; std::string dims = XS_VARTIME + ":0"; @@ -1373,27 +1386,27 @@ // Create NetCDF output request std::string varname = getNetcdfVarname(parInfo->ParamName()).c_str(); MvRequest out1("NETCDF_XY_MATRIX"); - out1("NETCDF_DATA") = xs; - out1("NETCDF_MISSING_ATTRIBUTE") = "_FillValue"; - out1("NETCDF_VALUE_VARIABLE") = varname.c_str(); - out1("NETCDF_Y_VARIABLE") = getNetcdfLevelVarname(varname).c_str(); + out1("NETCDF_DATA") = xs; + out1("NETCDF_MISSING_ATTRIBUTE") = "_FillValue"; + out1("NETCDF_VALUE_VARIABLE") = varname.c_str(); + out1("NETCDF_Y_VARIABLE") = getNetcdfLevelVarname(varname).c_str(); out1("NETCDF_DIMENSION_SETTING_METHOD") = "index"; - out1("NETCDF_DIMENSION_SETTING") = dims.c_str(); + out1("NETCDF_DIMENSION_SETTING") = dims.c_str(); - double X1, X2, Y1, Y2; + double X1 = 0., X2 = 0., Y1 = 0., Y2 = 0.; appInfo.getAreaLine(X1, X2, Y1, Y2); // across the pole? if (X1 == X2) { - const std::string latsVar = (appInfo.haveLatsForPlotting()) ? XS_VARLATPLOT : XS_VARLAT; - const std::string lonsVar = (appInfo.haveLonsForPlotting()) ? XS_VARLONPLOT : XS_VARLON; - out1("NETCDF_X_VARIABLE") = latsVar.c_str(); + const std::string latsVar = (appInfo.haveLatsForPlotting()) ? XS_VARLATPLOT : XS_VARLAT; + const std::string lonsVar = (appInfo.haveLonsForPlotting()) ? XS_VARLONPLOT : XS_VARLON; + out1("NETCDF_X_VARIABLE") = latsVar.c_str(); out1("NETCDF_X_AUXILIARY_VARIABLE") = lonsVar.c_str(); out1("NETCDF_X_GEOLINE_CONVENTION") = "latlon"; } else { - out1("NETCDF_X_VARIABLE") = "lon"; + out1("NETCDF_X_VARIABLE") = "lon"; out1("NETCDF_X_AUXILIARY_VARIABLE") = "lat"; out1("NETCDF_X_GEOLINE_CONVENTION") = "lonlat"; } @@ -1414,23 +1427,23 @@ // Add the orography curve visualiser if (appInfo.haveLNSP() && (appInfo.levelType() == XS_ML_LNSP || appInfo.levelType() == XS_PL)) { MvRequest out_orog("NETCDF_XY_POINTS"); - out_orog("NETCDF_DATA") = xs; - out_orog("NETCDF_Y_VARIABLE") = "orography_y2_values"; - out_orog("NETCDF_Y2_VARIABLE") = "orography_y1_values"; - out_orog("NETCDF_X_VARIABLE") = "orography_x_values"; - out_orog("NETCDF_X2_VARIABLE") = "orography_x_values"; //"orography_x2_values"; - out_orog("NETCDF_MISSING_ATTRIBUTE") = "_FillValue"; + out_orog("NETCDF_DATA") = xs; + out_orog("NETCDF_Y_VARIABLE") = "orography_y2_values"; + out_orog("NETCDF_Y2_VARIABLE") = "orography_y1_values"; + out_orog("NETCDF_X_VARIABLE") = "orography_x_values"; + out_orog("NETCDF_X2_VARIABLE") = "orography_x_values"; //"orography_x2_values"; + out_orog("NETCDF_MISSING_ATTRIBUTE") = "_FillValue"; out_orog("NETCDF_DIMENSION_SETTING_METHOD") = "index"; - out_orog("NETCDF_DIMENSION_SETTING") = dims.c_str(); - out_orog("_SKIP_MACRO") = 1; // tell MacroConverter to ignore this request + out_orog("NETCDF_DIMENSION_SETTING") = dims.c_str(); + out_orog("_SKIP_MACRO") = 1; // tell MacroConverter to ignore this request // create Graph Plotting subrequest // OBS: itt should use a definition from the Default folder MvRequest visdefReq("MGRAPH"); - visdefReq("GRAPH_TYPE") = "AREA"; + visdefReq("GRAPH_TYPE") = "AREA"; visdefReq("GRAPH_SHADE_COLOUR") = oroColour_.c_str(); - visdefReq("_CLASS") = "MGRAPH"; - out_orog = out_orog + visdefReq; + visdefReq("_CLASS") = "MGRAPH"; + out_orog = out_orog + visdefReq; // Create an empty request. // This is very important because it indicates to uPlot that this @@ -1461,8 +1474,8 @@ if ((const char*)origReq_("WIND_INTENSITY")) viewReq("WIND_INTENSITY") = origReq_("WIND_INTENSITY"); - viewReq("_CLASS") = "MXSECTIONVIEW"; - viewReq("_DEFAULT") = true; + viewReq("_CLASS") = "MXSECTIONVIEW"; + viewReq("_DEFAULT") = true; viewReq("_DATAATTACHED") = "YES"; if (appInfo.levelType() != cML_UKMO_ND && appInfo.levelType() != XS_ML_GHBC) // UK MetOffice model levels and GHBC fields are 'upside-down' @@ -1475,8 +1488,8 @@ // Also, add the visualisation and original requests as hidden parameters. // These may be used later to help the visualisation of the netcdf data. if (!isVisualise(appInfo)) { - xs("_VIEW") = view_.c_str(); - xs("_VISUALISE") = out1; + xs("_VIEW") = view_.c_str(); + xs("_VISUALISE") = out1; xs("_VIEW_REQUEST") = viewReq; return xs; } @@ -1527,13 +1540,13 @@ par->ExpVerTitle().c_str()); } - return std::string(titlestr); + return {titlestr}; } std::string CrossS::getNetcdfLevelVarname(std::string& varname) { if (outputMode_ == VectorOutput) - return std::string("lev"); + return {"lev"}; return Xsect::getNetcdfLevelVarname(varname); } diff -Nru metview-5.17.4/metview/src/XSection/CrossS.h metview-5.19.2/metview/src/XSection/CrossS.h --- metview-5.17.4/metview/src/XSection/CrossS.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/CrossS.h 2023-07-15 08:28:47.000000000 +0000 @@ -36,20 +36,20 @@ // Get geographical coordinates and application parameters bool getCoordinates(MvRequest&, ApplicationInfo&); - bool getAppParameters(MvRequest&, ApplicationInfo&); + bool getAppParameters(MvRequest&, ApplicationInfo&) override; - bool generateData(ApplicationInfo&, ParamMap&, MvNetCDF&, MvField&, const std::string&); + bool generateData(ApplicationInfo&, ParamMap&, MvNetCDF&, MvField&, const std::string&) override; // Create output request - MvRequest createOutputRequest(ApplicationInfo&, ParamInfo*); + MvRequest createOutputRequest(ApplicationInfo&, ParamInfo*) override; // Check if parameters between two requests are consistent - bool consistencyCheck(MvRequest&, MvRequest&); + bool consistencyCheck(MvRequest&, MvRequest&) override; - int computeGeographicalPoints(ApplicationInfo&, MvField*); + int computeGeographicalPoints(ApplicationInfo&, MvField*) override; - bool fillValues(ApplicationInfo&, MvField&, double*); - ParamInfo* plotVariable(ApplicationInfo& appInfo, ParamMap& params); + bool fillValues(ApplicationInfo&, MvField&, double*) override; + ParamInfo* plotVariable(ApplicationInfo& appInfo, ParamMap& params) override; private: enum WindProjectionMode @@ -77,12 +77,12 @@ ComputedVerticalVelocity }; - void init(); + void init() override; bool generateXsectData(ApplicationInfo&, ParamMap&, MvNetCDF&, MvField&, const std::string&); bool generateLNSP(ApplicationInfo&, MvNetCDF&, ParamInfo*); bool wind2DValues(ApplicationInfo&, ParamMap&, MvNetCDF&, const std::string&, MvField&); bool wind3DValues(ApplicationInfo&, ParamMap&, MvNetCDF&, const std::string&, MvField&); - void setHorCompFlags(bool, bool, bool, bool); + void setHorCompFlags(bool, bool, bool, bool) override; OutputMode determineWindOutputMode() const; #if 0 @@ -93,23 +93,23 @@ void computeWind3D(ApplicationInfo& appInfo, ParamInfo& par_uv, ParamInfo* par_u, ParamInfo* par_v, ParamInfo* par_w); - std::string titleVariable(ApplicationInfo&, ParamInfo*); + std::string titleVariable(ApplicationInfo&, ParamInfo*) override; // Get netCDF level variable name - std::string getNetcdfLevelVarname(std::string&); + std::string getNetcdfLevelVarname(std::string&) override; // Get netCDF variable name - std::string getNetcdfVarname(const std::string&); + std::string getNetcdfVarname(const std::string&) override; - WindProjectionMode windProjection_; - WindMode windMode_; - bool useWindIntensity_; + WindProjectionMode windProjection_{NoWindProjection}; + WindMode windMode_{NoWindMode}; + bool useWindIntensity_{false}; bool needVectorOutput_{false}; - OutputMode outputMode_; - std::string oroColour_; - double wScaling_; - VerticalVelocityMode wMode_; - ParamInfo* plotVar_; + OutputMode outputMode_{ScalarOutput}; + std::string oroColour_{"CYAN"}; + double wScaling_{-100.}; + VerticalVelocityMode wMode_{Mv3VerticalVelocity}; + ParamInfo* plotVar_{nullptr}; }; //--------------------------------------------------------------------------------- @@ -123,5 +123,5 @@ CrossSM3() : CrossS("PM_XSECT") {} - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; diff -Nru metview-5.17.4/metview/src/XSection/MvXsectFrame.cc metview-5.19.2/metview/src/XSection/MvXsectFrame.cc --- metview-5.17.4/metview/src/XSection/MvXsectFrame.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/MvXsectFrame.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,7 +14,7 @@ #include "MvException.h" -#include +#include #include #include #include @@ -52,7 +52,7 @@ std::string ParamInfo::ExpVerTitle() { if (expver_ == "_") //-- missing ExpVer is stored as "_" - return std::string(""); + return {""}; else return std::string("Expver ") + expver_; } @@ -70,19 +70,19 @@ auto ii = levels_.find(lev); if (ii == levels_.end()) { levels_[lev] = new LevelInfo(flev); - ii = levels_.find(lev); + ii = levels_.find(lev); } else { if ((*ii).second->xvalues_) { delete[](*ii).second->xvalues_; - (*ii).second->xvalues_ = 0; + (*ii).second->xvalues_ = nullptr; } - //TODO: check if it is needed to multiply by 100 + // TODO: check if it is needed to multiply by 100 if ((*ii).second->yvalue_ >= XMISSING_VALUE) (*ii).second->yvalue_ = flev; } - if ((*ii).second->xvalues_ == 0) + if ((*ii).second->xvalues_ == nullptr) (*ii).second->xvalues_ = new double[n]; double* xx = (*ii).second->xvalues_; @@ -95,7 +95,7 @@ LevelIterator ii; for (ii = levels_.begin(); ii != levels_.end(); ii++) { double flev = atof((*ii).first.c_str()); - (*ii).second->UpdateLevel((scaleToPa)?ApplicationInfo::toPa(flev):flev); + (*ii).second->UpdateLevel((scaleToPa) ? ApplicationInfo::toPa(flev) : flev); } } @@ -107,14 +107,14 @@ MvDate ParamInfo::ReferenceDate() { - double tt = date_ + time_ / 2400.; //YYYYMMDD + HHMM - return MvDate(tt); + double tt = date_ + time_ / 2400.; // YYYYMMDD + HHMM + return {tt}; } MvDate ParamInfo::VerificationDate() { - double tt = date_ + time_ / 2400. + step_ / 24.; //YYYYMMDD + HHMM + HH - return MvDate(tt); + double tt = date_ + time_ / 2400. + step_ / 24.; // YYYYMMDD + HHMM + HH + return {tt}; } double* ParamInfo::getOneLevelValues(const std::string& clev) @@ -122,7 +122,7 @@ // Find the input level auto ll = levels_.find(clev); if (ll == levels_.end()) - return 0; + return nullptr; return (*ll).second->XValues(); } @@ -136,11 +136,12 @@ class TargetLevelItem { friend class TargetLevelMaker; + public: - TargetLevelItem()=default; - void addValue(double val) {vals_.push_back(val);} + TargetLevelItem() = default; + void addValue(double val) { vals_.push_back(val); } void compute(); - bool isEmpty() const {return vals_.size() == 0;} + bool isEmpty() const { return vals_.size() == 0; } private: std::vector vals_; @@ -152,14 +153,14 @@ void TargetLevelItem::compute() { - if (vals_.size() >0) { - min_ = *std::min_element(vals_.begin(),vals_.end()); - max_ = *std::max_element(vals_.begin(),vals_.end()); - mean_ = std::accumulate(vals_.begin(), vals_.end(), 0.0) / vals_.size(); - std::for_each (vals_.begin(), vals_.end(), [this](const double d) { + if (vals_.size() > 0) { + min_ = *std::min_element(vals_.begin(), vals_.end()); + max_ = *std::max_element(vals_.begin(), vals_.end()); + mean_ = std::accumulate(vals_.begin(), vals_.end(), 0.0) / static_cast(vals_.size()); + std::for_each(vals_.begin(), vals_.end(), [this](const double d) { stdev_ += std::pow(d - mean_, 2); }); - stdev_ = std::sqrt(stdev_ / vals_.size()); + stdev_ = std::sqrt(stdev_ / static_cast(vals_.size())); } } @@ -172,17 +173,18 @@ class TargetLevelMaker { public: - TargetLevelMaker(int levelNum) : levels_(levelNum) {} + TargetLevelMaker(int levelNum) : + levels_(levelNum) {} void add(double v, int level); void addDeltaFromMinMax(std::vector& vals) const; void getMeans(std::vector&); void getAdaptive(std::vector&); - double minVal() const {return minVal_;} - double maxVal() const {return maxVal_;} + double minVal() const { return minVal_; } + double maxVal() const { return maxVal_; } private: void compute(); - void addTargetVal(std::vector &res, double startVal, double endVal, int num) const; + void addTargetVal(std::vector& res, double startVal, double endVal, int num) const; bool computed_{false}; std::vector levels_; @@ -202,11 +204,11 @@ } } -void TargetLevelMaker::addTargetVal(std::vector &res, double startVal, double endVal, int num) const +void TargetLevelMaker::addTargetVal(std::vector& res, double startVal, double endVal, int num) const { - double incr = (endVal - startVal)/(num+1); - for(int i=0; i < num; i++) { - res.push_back(startVal+i*incr); + double incr = (endVal - startVal) / (num + 1); + for (int i = 0; i < num; i++) { + res.push_back(startVal + i * incr); } } @@ -214,7 +216,7 @@ { if (!vals.empty()) { double deltaFirst = fabs(vals[0] - vals[1]); - double deltaLast = fabs(vals[vals.size() - 1] - vals[vals.size() - 2]); + double deltaLast = fabs(vals[vals.size() - 1] - vals[vals.size() - 2]); if (vals[0] < vals[1]) { vals.insert(vals.begin(), minVal_ - deltaFirst); vals.push_back(maxVal_ + deltaLast); @@ -229,11 +231,12 @@ void TargetLevelMaker::compute() { if (!computed_) { - for (auto &v: levels_) { + for (auto& v : levels_) { v.compute(); } levels_.erase(std::remove_if(levels_.begin(), levels_.end(), - [](auto v) { return v.isEmpty(); }), levels_.end()); + [](auto v) { return v.isEmpty(); }), + levels_.end()); computed_ = true; } } @@ -241,7 +244,7 @@ void TargetLevelMaker::getMeans(std::vector& res) { compute(); - for (auto &v: levels_) { + for (auto& v : levels_) { assert(!v.isEmpty()); res.push_back(v.mean_); } @@ -251,7 +254,7 @@ { compute(); -# if 0 +#if 0 int i=0; for (auto &v: levels_) { double delta = (i==0)?0:(v.mean_-levels_[i-1].mean_); @@ -264,11 +267,10 @@ // check if the level mean is representative, i.e. the spread is narrow enough (0,1) std::vector levRep; - for (std::size_t i=0; i < levels_.size(); i++) { + for (std::size_t i = 0; i < levels_.size(); i++) { assert(!levels_[i].isEmpty()); - double delta = (i == 0)?std::fabs(levels_[i].mean_ - levels_[i+1].mean_): - std::fabs(levels_[i].mean_ - levels_[i-1].mean_); - levRep.push_back(levels_[i].stdev_< delta); + double delta = (i == 0) ? std::fabs(levels_[i].mean_ - levels_[i + 1].mean_) : std::fabs(levels_[i].mean_ - levels_[i - 1].mean_); + levRep.push_back(levels_[i].stdev_ < delta); } bool ascending = levels_.front().mean_ < levels_.back().mean_; @@ -276,20 +278,20 @@ // find levels with large spread at the front int frontIdx = -1; int backIdx = -1; - for (std::size_t i=0; i < levels_.size(); i++) { + for (std::size_t i = 0; i < levels_.size(); i++) { if (levRep[i] == 1) { - if (i>0) { - frontIdx = i; + if (i > 0) { + frontIdx = static_cast(i); } break; } } // find levels with large spread at the back - for (std::size_t i=levels_.size()-1; i >= 0; i--) { + for (std::size_t i = levels_.size() - 1; i >= 0; i--) { if (levRep[i] == 1) { - if (i < levels_.size()-1) { - backIdx = i; + if (i < levels_.size() - 1) { + backIdx = static_cast(i); } break; } @@ -300,31 +302,32 @@ // intervals via the whole range if (frontIdx == -1 && backIdx == -1) { - double startVal = (ascending)?levels_.front().min_:levels_.back().min_; - double endVal = (ascending)?levels_.back().max_:levels_.front().max_; - int num = std::max(static_cast(levels_.size())+5, 10); + double startVal = (ascending) ? levels_.front().min_ : levels_.back().min_; + double endVal = (ascending) ? levels_.back().max_ : levels_.front().max_; + int num = std::max(static_cast(levels_.size()) + 5, 10); addTargetVal(res, startVal, endVal, num); - } else { + } + else { // intervals at front if (frontIdx != -1) { - double startVal = (ascending)?levels_.front().min_:levels_.front().max_; - double endVal = levels_[frontIdx-1].mean_; - int num = std::max(static_cast(frontIdx+2), 10); + double startVal = (ascending) ? levels_.front().min_ : levels_.front().max_; + double endVal = levels_[frontIdx - 1].mean_; + int num = std::max(static_cast(frontIdx + 2), 10); addTargetVal(res, startVal, endVal, num); } // means in the middle - std::size_t midStart = (frontIdx>-1)?frontIdx:0; - std::size_t midEnd = (backIdx>-1)?backIdx:levels_.size()-1; - for (std::size_t i=midStart; i <= midEnd; i++) { + std::size_t midStart = (frontIdx > -1) ? frontIdx : 0; + std::size_t midEnd = (backIdx > -1) ? backIdx : levels_.size() - 1; + for (std::size_t i = midStart; i <= midEnd; i++) { res.push_back(levels_[i].mean_); } // intervals at back if (backIdx != -1) { - double startVal = levels_[backIdx+1].mean_; - double endVal = (ascending)?levels_.back().max_:levels_.back().min_; - int num = std::max(static_cast(levels_.size()-backIdx+2), 10); + double startVal = levels_[backIdx + 1].mean_; + double endVal = (ascending) ? levels_.back().max_ : levels_.back().min_; + int num = std::max(static_cast(levels_.size() - backIdx + 2), 10); addTargetVal(res, startVal, endVal, num); } } @@ -336,33 +339,6 @@ // //===================================================== -ApplicationInfo::ApplicationInfo() : - x1_(0), - x2_(0), - y1_(0), - y2_(0), - gridNS_(0), - gridEW_(0), - topLevel_(0), - bottomLevel_(0), - nrPoints_(0), - nInputLevels_(0), - nOutputLevels_(0), - levType_(XS_PL), - viaPole_(false), - haveLatsForPlotting_(false), - haveLonsForPlotting_(false), - haveLNSP_(false), - haveGHBC_(false), - paramGHBC_(-991), - hor_point_("INTERPOLATE"), - interpolate_(false), - uiLSType_("FROM_DATA"), - uiLSCount_(100), - uiVLinearScaling_(true) -{ -} - void ApplicationInfo::determineLevelType(bool isML, bool isPL) { // isML and isPL are both true if a fieldset contains LNSP and PL data. This is the @@ -370,16 +346,21 @@ if (haveGHBC()) { if (isML && !isPL) { levType_ = XS_ML_GHBC; - } else { + } + else { levType_ = XS_GHBC; } - } else if (this->haveLNSP() && isML && !isPL) { + } + else if (this->haveLNSP() && isML && !isPL) { levType_ = XS_ML_LNSP; - } else if (isML && !isPL) { + } + else if (isML && !isPL) { levType_ = XS_ML; - } else if (isPL && (!isML || this->haveLNSP())) { + } + else if (isPL && (!isML || this->haveLNSP())) { levType_ = XS_PL; - } else { + } + else { levType_ = XS_ASIS; } @@ -407,8 +388,8 @@ double factor = 100.; topLevel_ *= factor; bottomLevel_ *= factor; - for (std::size_t i=0; i < uiLSList_.size(); i++) { - uiLSList_[i] *= factor; + for (double& i : uiLSList_) { + i *= factor; } } } @@ -473,8 +454,8 @@ // Compute initial coordinates via pole if (viaPole()) { - double lat_k_prev = y1_; //-- xsect line over a pole - bool overThePole = false; + double lat_k_prev = y1_; //-- xsect line over a pole + bool overThePole = false; double original_dy = dy; for (int k = 1; k < nrPoints_; k++) { @@ -549,28 +530,28 @@ // select only the nearest points to the original grid points MvLocation loc(lat_[0], lon_[0]); MvLocation loc2 = field->nearestGridPointLocation(loc); - double distmin = loc.distanceInMeters(loc2); + double distmin = loc.distanceInMeters(loc2); std::vector lat2; std::vector lon2; - double distc; // current distance in meters - int index = 0; // index of the closest location + double distc = 0.; // current distance in meters + int index = 0; // index of the closest location for (int k = 1; k < nrPoints_; k++) { MvLocation loc(lat_[k], lon_[k]); MvLocation loc1 = field->nearestGridPointLocation(loc); - distc = loc.distanceInMeters(loc1); + distc = loc.distanceInMeters(loc1); if (loc1.longitude() != loc2.longitude() || loc1.latitude() != loc2.latitude()) { lat2.push_back(lat_[index]); lon2.push_back(lon_[index]); - loc2 = loc1; - index = k; + loc2 = loc1; + index = k; distmin = distc; } else { // Save the smallest distance if (distc < distmin) { distmin = distc; - index = k; + index = k; } } } @@ -580,7 +561,7 @@ lon2.push_back(lon_[index]); // Update coordinates and total number of points - nrPoints_ = npoints = lat2.size(); + nrPoints_ = npoints = static_cast(lat2.size()); lon_.clear(); lat_.clear(); lon_ = lon2; @@ -596,17 +577,17 @@ return; } - int i; - double lpa, pk; - LevelInfo *firstlev, *nextlev; + int i = 0; + double lpa = 0., pk = 0.; + LevelInfo *firstlev = nullptr, *nextlev = nullptr; int nrLevels = this->outputLevels(); cp.clear(); - cp.reserve(nrLevels * nrPoints_); + cp.reserve(static_cast(nrLevels) * static_cast(nrPoints_)); for (int k = 0; k < nrLevels; k++) { // Invert Model level data, except for UKMO - //kmodel = (levType_ == cML_UKMO_ND) ? k : (nrLevels)-k-1; + // kmodel = (levType_ == cML_UKMO_ND) ? k : (nrLevels)-k-1; - //pk = GetInterpolatedYValue(k); + // pk = GetInterpolatedYValue(k); pk = yvals[k]; if (findPressure(param->Levels(), pk, firstlev, nextlev)) { @@ -614,9 +595,9 @@ if (levType_) lpa = (pk - firstlev->YValue()) / (nextlev->YValue() - firstlev->YValue()); else - //if ( logax_ ) - // lpa = ( pk - firstlev->YValue()) / (nextlev->YValue() - firstlev->YValue()); - //else + // if ( logax_ ) + // lpa = ( pk - firstlev->YValue()) / (nextlev->YValue() - firstlev->YValue()); + // else lpa = log(pk / firstlev->YValue()) / log(nextlev->YValue() / firstlev->YValue()); double* xvals = firstlev->XValues(); @@ -624,8 +605,9 @@ for (i = 0; i < nrPoints_; i++) { if (xvals[i] < XMISSING_VALUE && xnext[i] < XMISSING_VALUE) { - cp.push_back(xvals[i] + (xnext[i] - xvals[i]) * lpa); //replace k with kmodel - } else { + cp.push_back(xvals[i] + (xnext[i] - xvals[i]) * lpa); // replace k with kmodel + } + else { cp.push_back(XMISSING_VALUE); // replace k with kmodel } } @@ -654,12 +636,12 @@ // Allocate memory for the output data int nrLevels = outputLevels(); cp.clear(); - cp.reserve(nrLevels * nrPoints_); + cp.reserve(static_cast(nrLevels) * static_cast(nrPoints_)); // Main loop - double lpa; - LevelInfo *firstlev, *nextlev; - double firstval, nextval; + double lpa = 0.; + LevelInfo *firstlev = nullptr, *nextlev = nullptr; + double firstval = 0., nextval = 0.; for (int k = 0; k < nrLevels; k++) { double pk = yvals[k]; @@ -709,30 +691,30 @@ return; } - double lpa, vcVal1, vcVal2; - LevelInfo *parLev1, *parLev2; + double lpa = 0., vcVal1 = 0., vcVal2 = 0.; + LevelInfo *parLev1 = nullptr, *parLev2 = nullptr; int nrLevels = outputLevels(); cp.clear(); - cp.reserve(nrLevels * nrPoints_); + cp.reserve(static_cast(nrLevels) * static_cast(nrPoints_)); assert(nrLevels >= 2); #if 0 bool doLog = false; #endif - //loop for the target levels + // loop for the target levels for (int k = 0; k < nrLevels; k++) { double level = yvals[k]; // target vertical coordinate level #if 0 doLog = (level < 600); if (doLog) std::cout << level << std::endl; #endif - //loop for the xs line points + // loop for the xs line points for (int i = 0; i < nrPoints_; i++) { #if 0 if (doLog) std::cout << " (" << i << ")" << std::endl; #endif bool needExtrapolation = false; - //find the bounding input vc levels for the target level + // find the bounding input vc levels for the target level if (findModelPressureGHBC(param->Levels(), paramGHBC->Levels(), level, i, parLev1, parLev2, vcVal1, vcVal2, needExtrapolation)) { #if 0 @@ -742,18 +724,20 @@ #endif if (parLev1->XValues()[i] < XMISSING_VALUE && parLev2->XValues()[i] < XMISSING_VALUE) { lpa = (level - vcVal1) / (vcVal2 - vcVal1); - double rv =parLev1->XValues()[i] + (parLev2->XValues()[i] - parLev1->XValues()[i]) * lpa; + double rv = parLev1->XValues()[i] + (parLev2->XValues()[i] - parLev1->XValues()[i]) * lpa; if (needExtrapolation && extrapolateGHBCMode_ == LinearExtrapolation && extrapolateGHBCFixedSign_) { assert(extrapolateGHBCMode_ == LinearExtrapolation); - if (parLev1->XValues()[i]*rv <= 0) { + if (parLev1->XValues()[i] * rv <= 0) { rv = 0.; } } cp.push_back(rv); - } else { + } + else { cp.push_back(XMISSING_VALUE); } - } else { + } + else { #if 0 if (doLog) { std::cout << " not found " << std::endl; @@ -763,13 +747,12 @@ } } } - } bool ApplicationInfo::findPressure(LevelMap& lmap, double value, LevelInfo*& l1, LevelInfo*& l2) { - auto ii = lmap.begin(); - LevelInfo *tmp1 = (*ii).second, *tmp2; + auto ii = lmap.begin(); + LevelInfo *tmp1 = (*ii).second, *tmp2 = nullptr; ii++; for (; ii != lmap.end(); ii++) { @@ -791,8 +774,8 @@ double& val1, double& val2) { auto ii = lmap.begin(); - double tmpval1, tmpval2; - LevelInfo *tmpl1, *tmpl2; + double tmpval1 = 0., tmpval2 = 0.; + LevelInfo *tmpl1 = nullptr, *tmpl2 = nullptr; tmpl1 = (*ii).second; ii++; @@ -801,24 +784,24 @@ // desired pressure above (in the atmosphere) the top (first) level in the data? if (value < tmpval1) { val1 = tmpval1; - l1 = tmpl1; + l1 = tmpl1; return false; } for (; ii != lmap.end(); ii++) { - tmpl2 = (*ii).second; + tmpl2 = (*ii).second; tmpval2 = field.meanML_to_Pressure_bySP(splin, (int)(tmpl2->YValue())); if (isWithinRange(tmpval1, tmpval2, value)) { - l1 = tmpl1; - l2 = tmpl2; + l1 = tmpl1; + l2 = tmpl2; val1 = tmpval1; val2 = tmpval2; return true; } - tmpl1 = tmpl2; + tmpl1 = tmpl2; tmpval1 = tmpval2; } @@ -829,24 +812,24 @@ bool ApplicationInfo::findModelPressureGHBC(LevelMap& parLevels, LevelMap& vcLevels, double level, int xsPointIdx, LevelInfo*& parLev1, LevelInfo*& parLev2, - double& vcVal1, double& vcVal2, bool &needExtrapolation) + double& vcVal1, double& vcVal2, bool& needExtrapolation) { auto itParLev = parLevels.begin(); - auto itVcLev = vcLevels.begin(); + auto itVcLev = vcLevels.begin(); auto actParLev1 = (*itParLev).second; - auto actVcLev1 = (*itVcLev).second; - vcVal1 = actVcLev1->XValues()[xsPointIdx]; + auto actVcLev1 = (*itVcLev).second; + vcVal1 = actVcLev1->XValues()[xsPointIdx]; itParLev++; itVcLev++; - auto actParLev2 = (*itParLev).second; - auto actVcLev2 = (*itVcLev).second; - vcVal2 = actVcLev2->XValues()[xsPointIdx]; + auto actParLev2 = (*itParLev).second; + auto actVcLev2 = (*itVcLev).second; + vcVal2 = actVcLev2->XValues()[xsPointIdx]; bool vcAscending = vcVal1 < vcVal2; needExtrapolation = false; - //this will allow extrapolation at top/bottom + // this will allow extrapolation at top/bottom if (extrapolateGHBC_) { if (!vcAscending) { assert(vcVal2 < vcVal1); @@ -855,7 +838,8 @@ if (extrapolateGHBCMode_ == ConstantExtrapolation) { parLev1 = actParLev1; parLev2 = parLev1; - } else { + } + else { parLev1 = actParLev1; parLev2 = actParLev2; } @@ -869,7 +853,8 @@ if (extrapolateGHBCMode_ == ConstantExtrapolation) { parLev1 = actParLev1; parLev2 = parLev1; - } else { + } + else { parLev1 = actParLev1; parLev2 = actParLev2; } @@ -890,23 +875,24 @@ if (itVcLev != vcLevels.end()) { actParLev1 = actParLev2; - vcVal1 = vcVal2; + vcVal1 = vcVal2; actParLev2 = (*itParLev).second; - actVcLev2 = (*itVcLev).second; - vcVal2 = actVcLev2->XValues()[xsPointIdx]; + actVcLev2 = (*itVcLev).second; + vcVal2 = actVcLev2->XValues()[xsPointIdx]; } } - //this will allow extrapolation at top/bottom + // this will allow extrapolation at top/bottom if (extrapolateGHBC_) { if (!vcAscending) { - assert(vcVal2 < vcVal1); + assert(vcVal2 < vcVal1); if (level < vcVal2) { needExtrapolation = true; if (extrapolateGHBCMode_ == ConstantExtrapolation) { parLev2 = actParLev2; parLev1 = parLev2; - } else { + } + else { parLev1 = actParLev1; parLev2 = actParLev2; } @@ -920,7 +906,8 @@ if (extrapolateGHBCMode_ == ConstantExtrapolation) { parLev2 = actParLev2; parLev1 = parLev2; - } else { + } + else { parLev1 = actParLev1; parLev2 = actParLev2; } @@ -936,13 +923,13 @@ void ApplicationInfo::scaleVerticalVelocity_mv3(ParamInfo* par) { LevelMap lmap = par->Levels(); - auto ii = lmap.begin(); + auto ii = lmap.begin(); // Compute distance double dellat = ABS(y2_ - y1_), dellon = ABS(x2_ - x1_); - double latm = (y1_ + y2_) / 2.; + double latm = (y1_ + y2_) / 2.; double dellona = dellon * cos(cCDR * latm); - double dist = 110442.3 * sqrt(dellat * dellat + dellona * dellona); + double dist = 110442.3 * sqrt(dellat * dellat + dellona * dellona); double hscale = 21. / dist; double vscale = 12. / ((bottomLevel_ - topLevel_)); @@ -951,7 +938,7 @@ vscale = 12. / (100 * 1000); double factor = -vscale / hscale; - double* values; + double* values = nullptr; for (; ii != lmap.end(); ii++) { values = (*ii).second->XValues(); @@ -968,12 +955,12 @@ void ApplicationInfo::computeVerticalVelocity(ParamInfo* parW, ParamInfo* parT, ParamInfo* parLnsp, MvField& field, double factor) { LevelMap lmap_w = parW->Levels(); - auto ww = lmap_w.begin(); + auto ww = lmap_w.begin(); double* wValues = nullptr; - double* splin = nullptr; + double* splin = nullptr; - const double Rd = 287.058; //Gas constant - const double g = 9.81; // gravitational acceleration + const double Rd = 287.058; // Gas constant + const double g = 9.81; // gravitational acceleration const double t0 = 273.16; // reference temperature // we have the values on the cross section line but have not @@ -998,8 +985,8 @@ if (parT) { LevelMap lmap_t = parT->Levels(); - auto tt = lmap_t.begin(); - double* tValues; + auto tt = lmap_t.begin(); + double* tValues = nullptr; for (; ww != lmap_w.end() && tt != lmap_t.end(); ww++, tt++) { wValues = (*ww).second->XValues(); @@ -1041,9 +1028,9 @@ void ApplicationInfo::scaleVerticalVelocity(ParamInfo* par, double factor) { LevelMap lmap = par->Levels(); - auto ii = lmap.begin(); + auto ii = lmap.begin(); - double* values; + double* values = nullptr; for (; ii != lmap.end(); ii++) { values = (*ii).second->XValues(); for (int i = 0; i < nrPoints_; i++) { @@ -1061,7 +1048,7 @@ assert(splin); for (int i = 0; i < nrPoints_; i++) { if (splin[i] < XMISSING_VALUE) { - p[i] = field.meanML_to_Pressure_byLNSP(splin[i], level); + p[i] = field.meanML_to_Pressure_byLNSP(splin[i], static_cast(level)); } else { p[i] = XMISSING_VALUE; @@ -1069,7 +1056,7 @@ } } else if (levType_ == XS_PL) { - //we need Pa units + // we need Pa units double p_val = level; for (int i = 0; i < nrPoints_; i++) { p[i] = p_val; @@ -1085,15 +1072,15 @@ void ApplicationInfo::setMinMaxLevels(double P1, double P2, int nlevel) { bottomLevel_ = P1; - topLevel_ = P2; + topLevel_ = P2; nInputLevels_ = nlevel; } void ApplicationInfo::getMinMaxLevels(double& P1, double& P2, int& nlevel) { - P1 = bottomLevel_; - P2 = topLevel_; + P1 = bottomLevel_; + P2 = topLevel_; nlevel = nInputLevels_; } @@ -1161,11 +1148,11 @@ std::vector& cp, MvField& field) { // Get parameter info - auto ii = params.find(key); + auto ii = params.find(key); ParamInfo* par = (*ii).second; // Compute values - double* splin = 0; + double* splin = nullptr; if (levType_ == XS_ML_LNSP) { // Get LNSP values ParamInfo* parLnsp = this->getParamInfo(params, LNSP_FIELD, key); @@ -1212,7 +1199,7 @@ MvField& field) { // Get parameter info - auto ii = params.find(key); + auto ii = params.find(key); ParamInfo* par = (*ii).second; return computeLevelMatrixValues(params, key, par, y_values, cp, field); @@ -1269,20 +1256,23 @@ this->computeLevelInfo(par, vals); else this->computeLevelInfoFromData(par, vals, splin, field, false); - } else if (uiLSType_ == "ADAPTIVE") { + } + else if (uiLSType_ == "ADAPTIVE") { if (splin == nullptr) this->computeLevelInfo(par, vals); else this->computeLevelInfoFromData(par, vals, splin, field, true); - } else if (uiLSType_ == "COUNT") { + } + else if (uiLSType_ == "COUNT") { LevelMap lmap = par->Levels(); nInputLevels_ = lmap.size(); this->computeLevelInfoWithCount(vals); - } else { + } + else { assert(uiLSType_ == "LEVEL_LIST"); - vals = this->levelList(); + vals = this->levelList(); nOutputLevels_ = vals.size(); - nInputLevels_ = vals.size(); + nInputLevels_ = vals.size(); } } @@ -1290,7 +1280,7 @@ { // Get levels LevelMap lmap = par->Levels(); - int nrLevels = lmap.size(); + int nrLevels = lmap.size(); vals.clear(); vals.reserve(nrLevels); for (auto& jj : lmap) @@ -1314,11 +1304,11 @@ // Part A: compute "average" levels LevelMap lmap = par->Levels(); - int nrLevels = lmap.size(); + int nrLevels = lmap.size(); vals.clear(); TargetLevelMaker target(nrLevels); - int levelIdx =0; + int levelIdx = 0; for (auto& jj : lmap) { LevelInfo* lInfo = jj.second; @@ -1332,7 +1322,8 @@ if (!useAdaptive) { target.getMeans(vals); - } else { + } + else { target.getAdaptive(vals); } @@ -1346,7 +1337,7 @@ // Assume that the visualisation will be in the Log space too uiVLinearScaling_ = false; - nInputLevels_ = nrLevels; + nInputLevels_ = nrLevels; nOutputLevels_ = vals.size(); return nOutputLevels_; @@ -1360,8 +1351,8 @@ // Compute equally separated levels if (uiVLinearScaling_) { - double zdp = (bottomLevel_- topLevel_) / double(uiLSCount_ - 1); - for (int i = 0; i < uiLSCount_-1; i++) { + double zdp = (bottomLevel_ - topLevel_) / double(uiLSCount_ - 1); + for (int i = 0; i < uiLSCount_ - 1; i++) { vals.push_back(topLevel_ + i * zdp); } vals.push_back(bottomLevel_); @@ -1369,13 +1360,12 @@ // Compute levels using a log scaling else { double logBottomLevel = log(bottomLevel_); - double logTopLevel = log(topLevel_); - double zdp = (logBottomLevel - logTopLevel) / double(uiLSCount_ - 1); - for (int i = 0; i < uiLSCount_-1; i++) { + double logTopLevel = log(topLevel_); + double zdp = (logBottomLevel - logTopLevel) / double(uiLSCount_ - 1); + for (int i = 0; i < uiLSCount_ - 1; i++) { vals.push_back(exp(logTopLevel + i * zdp)); } - vals.push_back(logBottomLevel); - + vals.push_back(bottomLevel_); } nOutputLevels_ = uiLSCount_; @@ -1389,28 +1379,31 @@ // Compute the levels according to the parameters given in the user interface if (uiLSType_ == "FROM_DATA") { this->computeLevelInfoGHBCFromData(par, vals, false); - } else if (uiLSType_ == "ADAPTIVE") { + } + else if (uiLSType_ == "ADAPTIVE") { this->computeLevelInfoGHBCFromData(par, vals, true); - } else if (uiLSType_ == "COUNT") { + } + else if (uiLSType_ == "COUNT") { LevelMap lmap = par->Levels(); nInputLevels_ = lmap.size(); this->computeLevelInfoWithCount(vals); - } else { + } + else { assert(uiLSType_ == "LEVEL_LIST"); - vals = this->levelList(); + vals = this->levelList(); nOutputLevels_ = vals.size(); - nInputLevels_ = vals.size(); + nInputLevels_ = vals.size(); } } void ApplicationInfo::computeLevelInfoGHBCFromData(ParamInfo* par, std::vector& vals, bool useAdaptive) { LevelMap lmap = par->Levels(); - int nrLevels = lmap.size(); + int nrLevels = lmap.size(); vals.clear(); TargetLevelMaker target(nrLevels); - int levelIdx =0; + int levelIdx = 0; for (auto& jj : lmap) { LevelInfo* lInfo = jj.second; for (int i = 0; i < nrPoints_; i++) { @@ -1422,12 +1415,13 @@ levelIdx++; } - //Compute the average vertical coordinate value for each input GHBC level - //along the cross section line. The result is one coordinate value per level. + // Compute the average vertical coordinate value for each input GHBC level + // along the cross section line. The result is one coordinate value per level. if (!useAdaptive) { target.getMeans(vals); - // The output levels are determined with an adaptive technique - } else { + // The output levels are determined with an adaptive technique + } + else { target.getAdaptive(vals); } @@ -1435,10 +1429,10 @@ nInputLevels_ = nOutputLevels_ = nrLevels; // for extrapolation add min and max to levels - //NOTE: for bounded vertical coordinates (eg. pressure > 0) - //we have to be sure the added levels are valid! The problem is - //that we do not know anything about the nature of the vertical - //coordinate (since it is "generic"). + // NOTE: for bounded vertical coordinates (eg. pressure > 0) + // we have to be sure the added levels are valid! The problem is + // that we do not know anything about the nature of the vertical + // coordinate (since it is "generic"). if (extrapolateGHBC_ && nrLevels > 1) { target.addDeltaFromMinMax(vals); nOutputLevels_ = vals.size(); @@ -1455,13 +1449,13 @@ cp.reserve(lmap.size() * nrPoints_); for (ii = lmap.begin(); ii != lmap.end(); ii++) #else - int nrY = NrYValues(par); - int k = nrY - 1; // the index of the first level to set - int kinc = -1; // the amount to increment the level index by + int nrY = NrYValues(par); + int k = nrY - 1; // the index of the first level to set + int kinc = -1; // the amount to increment the level index by if (levType_ == cML_UKMO_ND) // UK Met Office model levels are 'upside-down' { - k = 0; + k = 0; kinc = 1; } @@ -1541,14 +1535,13 @@ void ApplicationInfo::setVerticalInterpolationFlag() { - if (levType_ == XS_ML_LNSP || levType_ == XS_ML_GHBC || levType_ == XS_GHBC) - interpolate_ = true; - else if (uiLSType_ == "COUNT" || uiLSType_ == "LEVEL_LIST") + if (levType_ == XS_ML_LNSP || levType_ == XS_ML_GHBC || levType_ == XS_GHBC || + uiLSType_ == "COUNT" || uiLSType_ == "LEVEL_LIST") { interpolate_ = true; - else + } + else { interpolate_ = false; - - return; + } } void ApplicationInfo::setVerticalInterpolationFlag(bool flag) @@ -1582,7 +1575,7 @@ std::string newKey = os.str(); // Get paraminfo - ParamInfo* par; + ParamInfo* par = nullptr; try { par = this->getParamInfo(params, newKey); if (par) @@ -1609,7 +1602,7 @@ void ApplicationInfo::levelList(std::vector& list) { - uiLSList_ = list; - topLevel_ = list[0]; + uiLSList_ = list; + topLevel_ = list[0]; bottomLevel_ = list[list.size() - 1]; } diff -Nru metview-5.17.4/metview/src/XSection/MvXsectFrame.h metview-5.19.2/metview/src/XSection/MvXsectFrame.h --- metview-5.17.4/metview/src/XSection/MvXsectFrame.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/MvXsectFrame.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,34 +29,38 @@ // cML_UKMO_ND = n; // UKMO New Dynamics - defined elsewhere enum { - XS_ML, //ECMWF model levels, no lnsp specified - XS_PL, //Pressure levels - XS_ML_LNSP, //ECMWF model levels with lnsp, otput will be pressure - XS_ML_GHBC, //User specified vertical coordinate fields with model levels - XS_GHBC, //User specified vertical coordinate fields not on model levels - XS_ASIS //level as is (not falling into any other category) + XS_ML, // ECMWF model levels, no lnsp specified + XS_PL, // Pressure levels + XS_ML_LNSP, // ECMWF model levels with lnsp, otput will be pressure + XS_ML_GHBC, // User specified vertical coordinate fields with model levels + XS_GHBC, // User specified vertical coordinate fields not on model levels + XS_ASIS // level as is (not falling into any other category) }; -enum ExtrapolateMode {ConstantExtrapolation, LinearExtrapolation}; +enum ExtrapolateMode +{ + ConstantExtrapolation, + LinearExtrapolation +}; const double cCDR = atan(1.0) / 45.0; //-- conversion factor Degrees->Radians //-- atan(1)/45 = (PI/4)/45 = PI/180 -const std::string XS_VARLEVEL = "nlev"; -const std::string XS_VARTIME = "time"; -const std::string XS_VARLAT = "lat"; -const std::string XS_VARLON = "lon"; +const std::string XS_VARLEVEL = "nlev"; +const std::string XS_VARTIME = "time"; +const std::string XS_VARLAT = "lat"; +const std::string XS_VARLON = "lon"; const std::string XS_VARLATPLOT = "lat_for_plot"; const std::string XS_VARLONPLOT = "lon_for_plot"; //-- Q&D trick: still use global vars //-- but let them be non-const! #ifdef INITIALISE_HERE -int U_FIELD = 131; -int V_FIELD = 132; -int W_FIELD = 135; +int U_FIELD = 131; +int V_FIELD = 132; +int W_FIELD = 135; int LNSP_FIELD = 152; -int T_FIELD = 130; +int T_FIELD = 130; #else extern int U_FIELD; extern int V_FIELD; @@ -89,10 +93,7 @@ } LevelInfo(double lev) : - xvalues_(nullptr) - { - yvalue_ = lev; - } + xvalues_(nullptr), yvalue_(lev) {} LevelInfo() : xvalues_(nullptr), @@ -112,8 +113,8 @@ } }; -typedef std::map LevelMap; -typedef LevelMap::iterator LevelIterator; +using LevelMap = std::map; +using LevelIterator = LevelMap::iterator; // Info about a parameter at one date, time and step. @@ -188,10 +189,10 @@ LevelMap levels_; }; -typedef std::map ParamMap; -typedef ParamMap::iterator ParamIterator; -typedef std::pair ParamInsertPair; -typedef std::pair ParamPair; +using ParamMap = std::map; +using ParamIterator = ParamMap::iterator; +using ParamInsertPair = std::pair; +using ParamPair = std::pair; //------------------------------ General info for application. @@ -199,8 +200,7 @@ class ApplicationInfo { public: - // Constructor - ApplicationInfo(); + ApplicationInfo() = default; double topLevel() { return topLevel_; } double bottomLevel() { return bottomLevel_; } @@ -251,8 +251,8 @@ void getMinMaxLevels(double&, double&, int&); void outputLevels(int n) { nOutputLevels_ = n; } int outputLevels() { return nOutputLevels_; } - static double tohPa(double v) {return v/100.;} - static double toPa(double v) {return v*100.;} + static double tohPa(double v) { return v / 100.; } + static double toPa(double v) { return v * 100.; } // Get level values void getLevelValues(ParamInfo*, std::vector&); @@ -260,8 +260,8 @@ // Compute indexes levels (vertical values) void computeLevelInfoUI(ParamInfo*, std::vector&, double*, MvField&); // from UI - int computeLevelInfoWithCount(std::vector&); // compute equal separated levels - void computeLevelInfoGHBC(ParamInfo*, std::vector&); // model level & GHBC + int computeLevelInfoWithCount(std::vector&); // compute equal separated levels + void computeLevelInfoGHBC(ParamInfo*, std::vector&); // model level & GHBC bool computeLevelMatrixValues(ParamMap&, const std::string&, ParamInfo*, std::vector&, std::vector&, MvField&); bool computeLevelMatrixValues(ParamMap&, const std::string&, std::vector&, std::vector&, MvField&); @@ -310,8 +310,8 @@ void setGHBC(int iparam) { paramGHBC_ = iparam; } void setGHBCExtrapolate(bool b) { extrapolateGHBC_ = b; } bool extrapolateGHBC() const { return extrapolateGHBC_; } - void setExtrapolateGHBCMode(ExtrapolateMode m) {extrapolateGHBCMode_ = m;} - void setExtrapolateGHBCFixedSign(bool b) {extrapolateGHBCFixedSign_ = b;} + void setExtrapolateGHBCMode(ExtrapolateMode m) { extrapolateGHBCMode_ = m; } + void setExtrapolateGHBCFixedSign(bool b) { extrapolateGHBCFixedSign_ = b; } bool isGHBC(int iparam) const { return iparam == paramGHBC_; } int GHBC() { return paramGHBC_; } @@ -339,43 +339,43 @@ private: double GetInterpolatedYValue(int); - int computeLevelInfo(ParamInfo*, std::vector&); // model/pressure level - int computeLevelInfoFromData(ParamInfo*, std::vector&, double*, MvField&, bool useSampling); // model level & LNSP + int computeLevelInfo(ParamInfo*, std::vector&); // model/pressure level + int computeLevelInfoFromData(ParamInfo*, std::vector&, double*, MvField&, bool useSampling); // model level & LNSP void computeLevelInfoGHBCFromData(ParamInfo*, std::vector&, bool useAdaptive); - double x1_, x2_, y1_, y2_; - double gridNS_, gridEW_; - double topLevel_, bottomLevel_; + double x1_{0.}, x2_{0.}, y1_{0.}, y2_{0.}; + double gridNS_{0.}, gridEW_{0.}; + double topLevel_{0.}, bottomLevel_{0.}; double levelValueFactor_{1.}; - int nrPoints_; // number of horizontal points - int nInputLevels_; // number of input data model/pressure levels - int nOutputLevels_; // number of output levels (may be different than nInputLevels_) - int ntimes_; // number of times - int levType_; // level type data, e.g., XS_ML/XS_PL/XS_ML_LNSP/XS_ML_GHBC - bool viaPole_; - bool haveLatsForPlotting_; - bool haveLonsForPlotting_; - bool haveLNSP_; - bool haveGHBC_; // vertical coordinates flag - int paramGHBC_; // vertical coordinate parameter + int nrPoints_{0}; // number of horizontal points + int nInputLevels_{0}; // number of input data model/pressure levels + int nOutputLevels_{0}; // number of output levels (may be different than nInputLevels_) + int ntimes_{0}; // number of times + int levType_{XS_PL}; // level type data, e.g., XS_ML/XS_PL/XS_ML_LNSP/XS_ML_GHBC + bool viaPole_{false}; + bool haveLatsForPlotting_{false}; + bool haveLonsForPlotting_{false}; + bool haveLNSP_{false}; + bool haveGHBC_{false}; // vertical coordinates flag + int paramGHBC_{-991}; // vertical coordinate parameter bool extrapolateGHBC_{false}; ExtrapolateMode extrapolateGHBCMode_{ConstantExtrapolation}; bool extrapolateGHBCFixedSign_{true}; std::string actionMode_; // e.g. "examine"/"save"/"execute"/... - int procType_; // processing type + int procType_{0}; // processing type - std::string hor_point_; // horizontal point mode - std::vector lat_; // geographical coordinates + std::string hor_point_{"INTERPOLATE"}; // horizontal point mode + std::vector lat_; // geographical coordinates std::vector lon_; std::vector latForPlotting_; // used when line is over a pole and Magics cannot plot the lat co-ordinates std::vector lonForPlotting_; // used when line is over a pole and Magics cannot plot the lon co-ordinates - bool interpolate_; // vertical interpolation flag + bool interpolate_{false}; // vertical interpolation flag // Parameters from the User Interface - std::string uiLSType_; // level selection type: FROM_DATA, COUNT, LEVEL_LIST - int uiLSCount_; // level selection count - std::vector uiLSList_; // level list - bool uiVLinearScaling_; // vertical scaling: [true=LINEAR, false=LOG] + std::string uiLSType_{"FROM_DATA"}; // level selection type: FROM_DATA, COUNT, LEVEL_LIST + int uiLSCount_{100}; // level selection count + std::vector uiLSList_; // level list + bool uiVLinearScaling_{true}; // vertical scaling: [true=LINEAR, false=LOG] }; diff -Nru metview-5.17.4/metview/src/XSection/Vprofile.cc metview-5.19.2/metview/src/XSection/Vprofile.cc --- metview-5.17.4/metview/src/XSection/Vprofile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/Vprofile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -62,13 +62,13 @@ bool Vprofile::getCoordinates(MvRequest& in, ApplicationInfo& appInfo) { // Get input values - double X1, X2, Y1, Y2; + double X1 = 0., X2 = 0., Y1 = 0., Y2 = 0.; if (strcmp(in("INPUT_MODE"), "AREA") == 0) { inputMode_ = VP_AREA; - Y1 = in("AREA", 0); - X1 = in("AREA", 1); - Y2 = in("AREA", 2); - X2 = in("AREA", 3); + Y1 = in("AREA", 0); + X1 = in("AREA", 1); + Y2 = in("AREA", 2); + X2 = in("AREA", 3); // Check coordinates if (!checkCoordinates(X1, Y1, X2, Y2)) @@ -97,9 +97,9 @@ if ((const char*)in("OUTPUT_MODE") && strcmp(in("OUTPUT_MODE"), "RTTOV") == 0) { // Get RTTOV parameters - outputMode_ = VP_RTTOV; - waterType_ = (const char*)in("WATER_TYPE") ? (int)in("WATER_TYPE") : 0; - cloudTP_ = (const char*)in("CLOUD_TOP_PRESSURE") ? (double)in("CLOUD_TOP_PRESSURE") : 0.; + outputMode_ = VP_RTTOV; + waterType_ = (const char*)in("WATER_TYPE") ? (int)in("WATER_TYPE") : 0; + cloudTP_ = (const char*)in("CLOUD_TOP_PRESSURE") ? (double)in("CLOUD_TOP_PRESSURE") : 0.; cloudFraction_ = (const char*)in("CLOUD_FRACTION") ? (double)in("CLOUD_FRACTION") : 0.; } @@ -146,12 +146,12 @@ // check to guarantee that all parameters have the same number of levels. bool found = false; int modlev = appInfo.levelType(); - int nlevelM; + int nlevelM = 0; std::vector y_values; for (auto& param : params) { // Retrieve the levels info LevelMap lmap = param.second->Levels(); - int nlevel = lmap.size(); + int nlevel = static_cast(lmap.size()); // Ignore it if level Type is of type Surface or LNSP if (nlevel == 1) @@ -174,7 +174,7 @@ y_values.push_back(jj.second->YValue() / 100.); } - found = true; + found = true; nlevelM = nlevel; } else { @@ -188,7 +188,7 @@ } // Add the 'levels' variable to the netCDF - std::vector levels_dimsize(1, y_values.size()); + std::vector levels_dimsize(1, static_cast(y_values.size())); std::vector levels_name(1, XS_VARLEVEL); MvNcVar* nclevels = cdf.addVariable(levels_name[0], ncDouble, levels_dimsize, levels_name); nclevels->addAttribute("long_name", "Atmospheric Levels"); @@ -214,16 +214,16 @@ double val = appInfo.Y1(); std::vector coord_ndim(1, 1); std::string coord_name = XS_VARLAT; - MvNcVar* nccoord = cdf.addVariable(coord_name, ncDouble, coord_ndim, coord_sdim); + MvNcVar* nccoord = cdf.addVariable(coord_name, ncDouble, coord_ndim, coord_sdim); nccoord->addAttribute("long_name", "latitude"); nccoord->addAttribute("units", "degrees_north"); nccoord->put(&val, 1); // Add Longitude value coord_sdim[0] = (outputMode_ == VP_RTTOV) ? XS_VARTIME : XS_VARLON; - val = appInfo.X1(); - coord_name = XS_VARLON; - nccoord = cdf.addVariable(coord_name, ncDouble, coord_ndim, coord_sdim); + val = appInfo.X1(); + coord_name = XS_VARLON; + nccoord = cdf.addVariable(coord_name, ncDouble, coord_ndim, coord_sdim); nccoord->addAttribute("long_name", "longitude"); nccoord->addAttribute("units", "degrees_east"); nccoord->put(&val, 1); @@ -278,7 +278,7 @@ // Add Cloud TopPressure variable vname = "p_cloudtop_scs"; - ncx = cdf.addVariable(vname, ncDouble, values_ndim, values_sdim); + ncx = cdf.addVariable(vname, ncDouble, values_ndim, values_sdim); ncx->addAttribute("long_name", "Cloud Top Pressure (Simple Cloud Scheme)"); ncx->addAttribute("units", "hPa"); ncx->addAttribute("_FillValue", XMISSING_VALUE); @@ -286,7 +286,7 @@ // Add Cloud Fraction variable vname = "cloud_fraction_scs"; - ncx = cdf.addVariable(vname, ncDouble, values_ndim, values_sdim); + ncx = cdf.addVariable(vname, ncDouble, values_ndim, values_sdim); ncx->addAttribute("long_name", "Cloud Fraction (Simple Clooud Scheme)"); ncx->addAttribute("units", "0-1"); ncx->addAttribute("_FillValue", XMISSING_VALUE); @@ -334,7 +334,7 @@ } // Get level values - int i, nlevels = 0; + int i = 0, nlevels = 0; double* vlevels = nullptr; ParamIterator ii; for (ii = params.begin(); ii != params.end(); ii++) { @@ -344,9 +344,9 @@ // Get levels LevelMap lmap = (*ii).second->Levels(); - nlevels = lmap.size(); - vlevels = new double[nlevels]; - i = 0; + nlevels = lmap.size(); + vlevels = new double[nlevels]; + i = 0; for (auto& jj : lmap) vlevels[i++] = jj.second->YValue(); @@ -368,7 +368,7 @@ ncx->addAttribute("_FillValue", XMISSING_VALUE); // Get LNSP values, compute pressure and update the netcdf file - int ntimes = 0; + int ntimes = 0; auto* values = new double[nlevels]; for (ii = params.begin(); ii != params.end(); ii++) { // Find LNSP field @@ -377,10 +377,10 @@ // Retrieve the levels info (single dimension) LevelMap lmap = (*ii).second->Levels(); - auto jj = lmap.begin(); - double lnsp = ((*jj).second->XValues())[0]; + auto jj = lmap.begin(); + double lnsp = ((*jj).second->XValues())[0]; for (i = 0; i < nlevels; i++) { - values[i] = field.meanML_to_Pressure_byLNSP(lnsp, vlevels[i]); + values[i] = field.meanML_to_Pressure_byLNSP(lnsp, static_cast(vlevels[i])); } // Add 'levels' values to the netCDF @@ -391,9 +391,9 @@ // Release memory delete[] vlevels; - vlevels = 0; + vlevels = nullptr; delete[] values; - values = 0; + values = nullptr; // Check consistency if (appInfo.NTimes() != ntimes) { @@ -407,13 +407,13 @@ bool Vprofile::generateQ2(MvNetCDF& cdf, ApplicationInfo& appInfo, ParamMap& params) { // Get input fields: two meter temperature, LNSP, two meter dewpoint temperature - int ntimes = appInfo.NTimes(); - auto* tmt = new double[ntimes]; - auto* lnsp = new double[ntimes]; - auto* tmdt = new double[ntimes]; + int ntimes = appInfo.NTimes(); + auto* tmt = new double[ntimes]; + auto* lnsp = new double[ntimes]; + auto* tmdt = new double[ntimes]; auto* values = new double[ntimes]; int i2t = 0, ilnsp = 0, i2d = 0, icount = 0; - double* pt; + double* pt = nullptr; for (auto& param : params) { if (param.second->ParamName() == "2t") pt = &tmt[i2t++]; @@ -426,13 +426,17 @@ // Retrieve the levels info (single dimension) LevelMap lmap = param.second->Levels(); - auto jj = lmap.begin(); - *pt = ((*jj).second->XValues())[0]; + auto jj = lmap.begin(); + *pt = ((*jj).second->XValues())[0]; icount++; } // Check consistency if (icount / 3 != ntimes) { + delete[] tmt; + delete[] lnsp; + delete[] tmdt; + delete[] values; setError(1, "Vprofile-> Number of 2t/lnsp/2d fields not consistent with other fields"); return false; } @@ -454,13 +458,9 @@ // Release memory delete[] tmt; - tmt = 0; delete[] lnsp; - lnsp = 0; delete[] tmdt; - tmdt = 0; delete[] values; - values = 0; return true; } @@ -468,14 +468,14 @@ bool Vprofile::generateOrography(MvNetCDF& cdf, ApplicationInfo& appInfo, ParamMap& params) { // Get input field: geopotential surface - int ntimes = appInfo.NTimes(); + int ntimes = appInfo.NTimes(); auto* values = new double[ntimes]; - int icount = 0; + int icount = 0; for (auto& param : params) { if (param.second->ParamName() == "z" && param.second->LevelType() == "sfc") { // Retrieve the levels info (single dimension) - LevelMap lmap = param.second->Levels(); - auto jj = lmap.begin(); + LevelMap lmap = param.second->Levels(); + auto jj = lmap.begin(); values[icount] = ((*jj).second->XValues())[0] / 9.81; // g (gravitation acceleration) icount++; } @@ -500,7 +500,7 @@ // Release memory delete[] values; - values = 0; + values = nullptr; return true; } @@ -508,12 +508,11 @@ bool Vprofile::generateSurftype(MvNetCDF& cdf, ApplicationInfo& appInfo, ParamMap& params) { // Get input fields: LSM and CI (Sea Ice Cover) - int ntimes = appInfo.NTimes(); - auto* lsm = new double[ntimes]; - auto* ci = new double[ntimes]; - auto* values = new double[ntimes]; + int ntimes = appInfo.NTimes(); + auto* lsm = new double[ntimes]; + auto* ci = new double[ntimes]; int ilsm = 0, ici = 0, icount = 0; - double* pt; + double* pt = nullptr; for (auto& param : params) { if (param.second->ParamName() == "lsm") pt = &lsm[ilsm++]; @@ -524,8 +523,8 @@ // Retrieve the levels info (single dimension) LevelMap lmap = param.second->Levels(); - auto jj = lmap.begin(); - *pt = ((*jj).second->XValues())[0]; + auto jj = lmap.begin(); + *pt = ((*jj).second->XValues())[0]; icount++; } @@ -533,11 +532,11 @@ if (icount / 2 != ntimes) { delete[] lsm; delete[] ci; - delete[] values; setError(1, "Vprofile-> Number of lsm/ci fields not consistent with other fields"); return false; } + auto* values = new double[ntimes]; // Compute Surface Type field for (int i = 0; i < ntimes; i++) { if (lsm[i] == 0.) { @@ -582,12 +581,12 @@ verb = "NETCDF"; MvRequest xs(verb.c_str()); - xs("PATH") = ncName_.c_str(); + xs("PATH") = ncName_.c_str(); xs("TEMPORARY") = 1; // Create netCDF output request MvRequest out1("NETCDF_XY_POINTS"); - out1("NETCDF_DATA") = xs; + out1("NETCDF_DATA") = xs; out1("NETCDF_Y_VARIABLE") = XS_VARLEVEL.c_str(); out1("NETCDF_X_VARIABLE") = parInfo->ParamName().c_str(); @@ -612,8 +611,8 @@ viewReq.addValue("POINT", (double)origReq_("POINT", 1)); } - viewReq("_CLASS") = "MVPROFILEVIEW"; - viewReq("_DEFAULT") = true; + viewReq("_CLASS") = "MVPROFILEVIEW"; + viewReq("_DEFAULT") = true; viewReq("_DATAATTACHED") = "YES"; if (appInfo.levelType() != cML_UKMO_ND && appInfo.levelType() != XS_ML_GHBC) // UK MetOffice model levels and GHBC fields are 'upside-down' @@ -623,8 +622,8 @@ // Also, add the visualisation and original requests as hidden parameters. // These may be used later to help the visualisation of the netcdf data. if (!isVisualise(appInfo)) { - xs("_VIEW") = view_.c_str(); - xs("_VISUALISE") = out1; + xs("_VIEW") = view_.c_str(); + xs("_VISUALISE") = out1; xs("_VIEW_REQUEST") = viewReq; return xs; } @@ -646,7 +645,7 @@ // Add/update Parameter to the netCDF std::string varname = this->getNetcdfVarname(par->ParamName()); - MvNcVar* ncx = cdf.getVariable(varname); + MvNcVar* ncx = cdf.getVariable(varname); if (!ncx) // Create a new variable { ntime_ = 0; @@ -669,10 +668,10 @@ } // Retrieve xvalues - LevelMap lmap = par->Levels(); - int nlevels = lmap.size(); + LevelMap lmap = par->Levels(); + int nlevels = lmap.size(); auto* x_values = new double[nlevels]; - int i = 0; + int i = 0; for (auto& jj : lmap) x_values[i++] = (jj.second->XValues())[0]; @@ -696,7 +695,7 @@ MvFieldExpander x(field); // Get data value - double X1, X2, Y1, Y2; + double X1 = 0., X2 = 0., Y1 = 0., Y2 = 0.; appInfo.getAreaLine(X1, X2, Y1, Y2); if (inputMode_ == VP_POINT) vals[0] = field.interpolateAt(X1, Y1); @@ -719,7 +718,7 @@ bool Vprofile::fieldConsistencyCheck(MvField& field, ApplicationInfo& appInfo) { if (inputMode_ == VP_GRIDPOINT) { - double X1, X2, Y1, Y2; + double X1 = 0., X2 = 0., Y1 = 0., Y2 = 0.; appInfo.getAreaLine(X1, X2, Y1, Y2); MvLocation nearestGridPoint = field.nearestGridPointLocation(MvLocation(Y1, X1)); if (nearestGridPoint.ok()) { @@ -745,7 +744,7 @@ par->ParamLongName().c_str(), par->Date(), par->Time(), par->Step(), par->ExpVerTitle().c_str(), appInfo.Y1(), appInfo.X1(), appInfo.Y2(), appInfo.X2()); - return std::string(titlestr); + return {titlestr}; } diff -Nru metview-5.17.4/metview/src/XSection/Vprofile.h metview-5.19.2/metview/src/XSection/Vprofile.h --- metview-5.17.4/metview/src/XSection/Vprofile.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/Vprofile.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,41 +34,41 @@ Vprofile(); Vprofile(const char* kw); - bool writeLevelInfoNetcdf(MvNetCDF&, ApplicationInfo&, ParamMap&, MvField*, double*); - bool writeGeoCoordsNetcdf(MvNetCDF&, ApplicationInfo&); - bool writeGlobalAttributesNetcdf(MvNetCDF&, ParamMap&, ApplicationInfo&); - bool generateExtraData(MvNetCDF&, ApplicationInfo&, ParamMap&, MvFieldSetIterator&); + bool writeLevelInfoNetcdf(MvNetCDF&, ApplicationInfo&, ParamMap&, MvField*, double*) override; + bool writeGeoCoordsNetcdf(MvNetCDF&, ApplicationInfo&) override; + bool writeGlobalAttributesNetcdf(MvNetCDF&, ParamMap&, ApplicationInfo&) override; + bool generateExtraData(MvNetCDF&, ApplicationInfo&, ParamMap&, MvFieldSetIterator&) override; bool generateDerivedData(MvNetCDF&, ApplicationInfo&, ParamMap&, MvFieldSetIterator&); bool generatePressureFromLNSP(MvNetCDF&, ApplicationInfo&, ParamMap&, MvFieldSetIterator&); bool generateQ2(MvNetCDF&, ApplicationInfo&, ParamMap&); bool generateOrography(MvNetCDF&, ApplicationInfo&, ParamMap&); bool generateSurftype(MvNetCDF&, ApplicationInfo&, ParamMap&); - bool generateData(ApplicationInfo&, ParamMap&, MvNetCDF&, MvField&, const std::string&); + bool generateData(ApplicationInfo&, ParamMap&, MvNetCDF&, MvField&, const std::string&) override; // Get geogrpahical coordinates and application parameters bool getCoordinates(MvRequest&, ApplicationInfo&); - bool getAppParameters(MvRequest&, ApplicationInfo&); + bool getAppParameters(MvRequest&, ApplicationInfo&) override; // Create output request - MvRequest createOutputRequest(ApplicationInfo&, ParamInfo*); + MvRequest createOutputRequest(ApplicationInfo&, ParamInfo*) override; - int computeGeographicalPoints(ApplicationInfo&, MvField* = 0); + int computeGeographicalPoints(ApplicationInfo&, MvField* = nullptr) override; - bool fillValues(ApplicationInfo&, MvField&, double*); + bool fillValues(ApplicationInfo&, MvField&, double*) override; - bool fieldConsistencyCheck(MvField&, ApplicationInfo&); + bool fieldConsistencyCheck(MvField&, ApplicationInfo&) override; // Check if parameters between two requests are consistent - bool consistencyCheck(MvRequest&, MvRequest&); + bool consistencyCheck(MvRequest&, MvRequest&) override; - std::string titleVariable(ApplicationInfo&, ParamInfo*); + std::string titleVariable(ApplicationInfo&, ParamInfo*) override; private: - int inputMode_; // VP_POINT/VP_GRIDPOINT/VP_AREA/VP_AREA2 - int outputMode_; // VP_NORMAL/VP_RTTOV + int inputMode_{0}; // VP_POINT/VP_GRIDPOINT/VP_AREA/VP_AREA2 + int outputMode_{0}; // VP_NORMAL/VP_RTTOV // RTTOV specific parameters - double waterType_, cloudTP_, cloudFraction_; + double waterType_{0.}, cloudTP_{0.}, cloudFraction_{0.}; }; //--------------------------------------------------------------------- @@ -79,5 +79,5 @@ VprofileM3() : Vprofile("PM_VPROF") {} - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; }; diff -Nru metview-5.17.4/metview/src/XSection/Xsect.cc metview-5.19.2/metview/src/XSection/Xsect.cc --- metview-5.17.4/metview/src/XSection/Xsect.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/Xsect.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,6 +29,7 @@ #include "Xsect.h" +#include #include #include "Average.h" @@ -47,8 +48,8 @@ // will have to reset things between each request void Xsect::init() { - ncName_ = "toto.nc"; - ntime_ = 0; + ncName_ = "toto.nc"; + ntime_ = 0; geoIndexVar_ = XS_VARLON; } @@ -102,8 +103,8 @@ MvField field = iter(); // Retrieve initial info - double X1, X2, Y1, Y2; - double north, south, east, west; + double X1 = 0., X2 = 0., Y1 = 0., Y2 = 0.; + double north = 0., south = 0., east = 0., west = 0.; // TODO: figure oiut why this call sets the levelType_ this->getInitialFieldInfo(field, appInfo, north, south, east, west); appInfo.getAreaLine(X1, X2, Y1, Y2); @@ -129,20 +130,20 @@ std::string keystr; bool foundU = false, foundV = false, foundW = false, foundT = false; bool foundGHBC = false; - int iparam, idate, itime, istep; - const char* expver = 0; + int iparam = 0, idate = 0, itime = 0, istep = 0; + const char* expver = nullptr; iter.rewind(); while ((field = iter())) { // Retrieve info from the field request - MvRequest rq = field.getRequest(); - iparam = rq("PARAM"); + MvRequest rq = field.getRequest(); + iparam = rq("PARAM"); const char* levc = rq("LEVELIST"); - std::string lev = (levc) ? levc : ""; - istep = rq("STEP"); - idate = rq.getBaseDate(); - itime = rq("TIME"); - expver = rq("EXPVER"); - isML = field.isModelLevel(); + std::string lev = (levc) ? levc : ""; + istep = rq("STEP"); + idate = rq.getBaseDate(); + itime = rq("TIME"); + expver = rq("EXPVER"); + isML = field.isModelLevel(); if (!isML) isPL = field.isPressureLevel(); @@ -172,7 +173,7 @@ if (appInfo.isLNSP(iparam)) appInfo.haveLNSP(true); else - //appInfo.haveGHBC(true); + // appInfo.haveGHBC(true); foundGHBC = true; // Calculate values along the transection line @@ -195,8 +196,8 @@ // Insert ParamInfo and the 'level' values ParamInsertPair inserted = params.insert(ParamPair(keystr, par)); - ParamInfo* pp = (*(inserted.first)).second; - pp->Level(xint, lev, npoint, 1.); + ParamInfo* pp = (*(inserted.first)).second; + pp->Level(xint, lev, npoint, true); pp->ExpVer(expver ? expver : "_"); } else { @@ -218,11 +219,11 @@ // Insert ParamInfo and only the 'level'info (not the values) ParamInsertPair inserted = params.insert(ParamPair(keystr, par)); - ParamInfo* pp = (*(inserted.first)).second; + ParamInfo* pp = (*(inserted.first)).second; pp->AddLevel(lev); pp->ExpVer(expver ? expver : "_"); } - } //end while (first loop) + } // end while (first loop) if (appInfo.haveGHBC() && !foundGHBC) { setError(1, "Xsect-> No verical coordinate field (paramId=%d) found in input!", appInfo.GHBC()); @@ -256,8 +257,8 @@ // TODO: Review usints handling in minmax computations!! // Update min/max vertical axis values and number of levels - int nlevel; - double pBottom, pTop; + int nlevel = 0; + double pBottom = 0., pTop = 0.; appInfo.getMinMaxLevels(pBottom, pTop, nlevel); if (this->updateTopBottomLevels(appInfo, params, iter, pBottom, pTop, nlevel)) appInfo.setMinMaxLevels(pBottom, pTop, nlevel); @@ -266,7 +267,7 @@ MvNetCDF netcdf; iter.rewind(); field = iter(); - int ntimes; + int ntimes = 0; if (!this->initialiseNetcdf(netcdf, params, appInfo, ntimes, field, xint)) { deleteAuxiliaryMemory(xint, params); return false; @@ -276,7 +277,7 @@ appInfo.NTimes(ntimes); // Initialize variables - std::string lastKey = "FIRSTFIELD"; + std::string lastKey = "FIRSTFIELD"; int currentGenerated = 0, lastNrGenerated = -1; MvField lastField; @@ -294,11 +295,11 @@ while ((field = iter())) { currentGenerated++; MvRequest r = field.getRequest(); - iparam = r("PARAM"); - idate = r.getBaseDate(); - itime = r("TIME"); - istep = r("STEP"); - expver = r("EXPVER"); + iparam = r("PARAM"); + idate = r.getBaseDate(); + itime = r("TIME"); + istep = r("STEP"); + expver = r("EXPVER"); // No need to process GHBC fields if (appInfo.isGHBC(iparam)) @@ -306,7 +307,7 @@ // Update level info accordingly const char* clevc = r("LEVELIST"); - std::string clev = (clevc) ? clevc : ""; + std::string clev = (clevc) ? clevc : ""; if (clev.empty() || clev != "0" || field.levelTypeString() == cML_UKMO_ND_STR) { double myLevel = field.level(); if (field.levelTypeString() == cML_UKMO_ND_STR) @@ -351,7 +352,7 @@ lastNrGenerated = currentGenerated; } - lastKey = keystr; + lastKey = keystr; lastField = field; } // end while (second loop) @@ -410,14 +411,15 @@ { // TODO: improve this condition check!!!!! // Only computes min/max if bottom and top levels are not initialized - if (pTop || pBottom) + const double eps = 1e-8; + if (std::fabs(pTop) > eps || std::fabs(pBottom) > eps) return false; // Find the min/max levels for the first parameter that // is not LNSP or a surface field. It assumes that the // remaining fields have the same number of levels. - double p; - pTop = 50000000.; + double p = 0.; + pTop = 50000000.; pBottom = -50000000.; ParamIterator ii; LevelMap lmap; @@ -433,11 +435,11 @@ continue; } - lmap = par->Levels(); + lmap = par->Levels(); nlevel = lmap.size(); for (jj = lmap.begin(); jj != lmap.end(); jj++) { - p = (*jj).second->YValue(); - pTop = MIN(pTop, p); + p = (*jj).second->YValue(); + pTop = MIN(pTop, p); pBottom = MAX(pBottom, p); } break; @@ -450,12 +452,12 @@ while ((field = iter())) { // Retrieve info from the field MvRequest rq = field.getRequest(); - int iparam = rq("PARAM"); + int iparam = rq("PARAM"); if (appInfo.isLNSP(iparam)) { double lnspMax = field.getGribKeyValueDouble("maximum"); double lnspMin = field.getGribKeyValueDouble("minimum"); - pTop = field.meanML_to_Pressure_byLNSP(lnspMin, pTop); - pBottom = field.meanML_to_Pressure_byLNSP(lnspMax, pBottom); + pTop = field.meanML_to_Pressure_byLNSP(lnspMin, pTop); + pBottom = field.meanML_to_Pressure_byLNSP(lnspMax, pBottom); break; } } @@ -470,7 +472,7 @@ // "not visualise" or "prepare" (in certain cases), then // send back the "netCDF" request std::string actionMode = appInfo.actionMode(); - int procType = appInfo.processType(); + int procType = appInfo.processType(); if (actionMode != "visualise" && !(actionMode == "prepare" && procType == XS_DATA_MODULE_DROPPED) && !(actionMode == "prepare" && procType == XS_DATA_DROPPED)) @@ -511,7 +513,7 @@ // Retrieve xsectdata parameters if exist, e.g. if a xs/av/vpata module // was dropped into a view or if it was called to be processed - const char* verb = (const char*)in("_VERB"); + const char* verb = (const char*)in("_VERB"); bool moduleDropped = this->isDataModuleDropped(verb); // Check the type of input request to be processed @@ -575,14 +577,14 @@ // Update coordinates if (X1 > X2) { double W = X1; - X1 = X2; - X2 = W; + X1 = X2; + X2 = W; } if (Y2 > Y1) { double W = Y1; - Y1 = Y2; - Y2 = W; + Y1 = Y2; + Y2 = W; } if (X1 == X2 && Y1 == Y2) { @@ -596,14 +598,14 @@ void Xsect::getInitialFieldInfo(MvField& field, ApplicationInfo& appInfo, double& north, double& south, double& east, double& west) { // Get area and grid from the field - north = field.north(); - south = field.south(); - east = field.east(); - west = field.west(); + north = field.north(); + south = field.south(); + east = field.east(); + west = field.west(); double Grid_ns = field.gridNS(); //-- may return cValueNotGiven! double Grid_ew = field.gridWE(); //-- may return cValueNotGiven! - //appInfo.setGlobe(North,South,East,West); + // appInfo.setGlobe(North,South,East,West); appInfo.Grid(Grid_ns, Grid_ew); // TODO: make absolutley sure this code is not needed!! @@ -635,7 +637,7 @@ if (view_ == sview) return viewRequest; - return MvRequest(); + return {}; } bool Xsect::consistencyCheck(ParamMap& params, ApplicationInfo& appInfo) @@ -676,11 +678,11 @@ { // Loop through all parameters std::vector stepS; - int idNew; - bool first = true; - int ntimesNew = 0; - auto ii = params.begin(); - int id = (*ii).second->Parameter(); // parameter id + int idNew = 0; + bool first = true; + int ntimesNew = 0; + auto ii = params.begin(); + int id = (*ii).second->Parameter(); // parameter id MvDate refDate = (*ii).second->ReferenceDate(); while (ii != params.end()) { // Accumulate and check time consistency @@ -689,7 +691,7 @@ if (first) { // Save number of times ntimes = ntimesNew; - first = false; + first = false; } else { // Check time consistency @@ -699,13 +701,13 @@ } } ntimesNew = 0; - id = idNew; + id = idNew; } else if (first) // Add new time to the list { MvDate newDate = (*ii).second->VerificationDate(); - double diff = (newDate - refDate); - int step = (int)(diff * 86400.); //seconds + double diff = (newDate - refDate); + int step = (int)(diff * 86400.); // seconds stepS.push_back(step); } ntimesNew++; @@ -779,7 +781,7 @@ bool Xsect::writeGeoCoordsNetcdf(MvNetCDF& cdf, ApplicationInfo& appInfo) { // Compute lat/long interpolation points - int npoint = appInfo.NrPoints(); + int npoint = appInfo.NrPoints(); const std::vector& lon = appInfo.getLongitude(); const std::vector& lat = appInfo.getLatitude(); @@ -793,7 +795,7 @@ // Add Longitude value coord_sdim[0] = XS_VARLON; - nccoord = cdf.addVariable(coord_sdim[0], ncDouble, coord_ndim, coord_sdim); + nccoord = cdf.addVariable(coord_sdim[0], ncDouble, coord_ndim, coord_sdim); nccoord->addAttribute("long_name", "longitude"); nccoord->addAttribute("units", "degrees_east"); nccoord->put(lon, (long)npoint); @@ -802,8 +804,8 @@ if (appInfo.viaPole()) { if (appInfo.haveLatsForPlotting()) { const std::vector& latForPlotting = appInfo.getLatitudeForPlotting(); - coord_sdim[0] = XS_VARLATPLOT; - nccoord = cdf.addVariable(coord_sdim[0], ncDouble, coord_ndim, coord_sdim); + coord_sdim[0] = XS_VARLATPLOT; + nccoord = cdf.addVariable(coord_sdim[0], ncDouble, coord_ndim, coord_sdim); nccoord->addAttribute("long_name", "latitude_plot"); nccoord->addAttribute("units", "degrees_north"); nccoord->put(latForPlotting, (long)npoint); @@ -811,8 +813,8 @@ if (appInfo.haveLonsForPlotting()) { const std::vector& lonForPlotting = appInfo.getLongitudeForPlotting(); - coord_sdim[0] = XS_VARLONPLOT; - nccoord = cdf.addVariable(coord_sdim[0], ncDouble, coord_ndim, coord_sdim); + coord_sdim[0] = XS_VARLONPLOT; + nccoord = cdf.addVariable(coord_sdim[0], ncDouble, coord_ndim, coord_sdim); nccoord->addAttribute("long_name", "longitude_plot"); nccoord->addAttribute("units", "degrees_east"); nccoord->put(lonForPlotting, (long)npoint); @@ -834,16 +836,16 @@ } // Get parameter info - auto ii = params.find(key); + auto ii = params.find(key); ParamInfo* par = (*ii).second; // Add/update variable to the netCDF - int nrLevels = appInfo.outputLevels(); - int nrPoints = appInfo.NrPoints(); + int nrLevels = appInfo.outputLevels(); + int nrPoints = appInfo.NrPoints(); std::string varname = this->getNetcdfVarname(par->ParamName()); std::string levname = this->getNetcdfLevelVarname(varname); - MvNcVar* nclevels = cdf.getVariable(levname); - MvNcVar* ncv = cdf.getVariable(varname); + MvNcVar* nclevels = cdf.getVariable(levname); + MvNcVar* ncv = cdf.getVariable(varname); if (!ncv || !nclevels) // Create new variables { ntime_ = -1; @@ -859,9 +861,9 @@ // Create variable 'levels' if (!nclevels) { std::string levname = getNetcdfLevelVarname(varname); - nclevels = cdf.addVariable(levname, ncDouble, values_ndim, values_sdim); + nclevels = cdf.addVariable(levname, ncDouble, values_ndim, values_sdim); nclevels->addAttribute("long_name", "Atmospheric Levels"); - if (appInfo.levelType() == XS_PL || appInfo.levelType() == XS_ML_LNSP) { + if (appInfo.levelType() == XS_PL || appInfo.levelType() == XS_ML_LNSP) { nclevels->addAttribute("units", "hPa"); nclevels->addAttribute("positive", "down"); } @@ -880,7 +882,7 @@ } // Write level values to tne netCDF file - int i; + int i = 0; ntime_++; nclevels->setCurrent(ntime_); @@ -913,11 +915,11 @@ { // RTTOV specific if (name == "skt") - return std::string("t_skin"); + return {"t_skin"}; // Netcdf only accepts variable name starting with a alphabetic letter // Copy initial numbers - unsigned int j = 0, i; + unsigned int j = 0, i = 0; std::string snum; for (i = 0; i < name.size(); i++) { if (isalpha(name[i])) @@ -954,8 +956,8 @@ MvRequest Xsect::createOutputRequest(MvRequest& in) { // Create NetCDF output request - MvRequest data = in.getSubrequest("DATA"); - MvRequest out1 = data.getSubrequest("_VISUALISE"); + MvRequest data = in.getSubrequest("DATA"); + MvRequest out1 = data.getSubrequest("_VISUALISE"); MvRequest viewReq = data.getSubrequest("_VIEW_REQUEST"); data.unsetParam("_VISUALISE"); // to avoid duplication of info data.unsetParam("_VIEW_REQUEST"); // to avoid duplication of info @@ -974,7 +976,7 @@ // Delete auxiliary array if (xint) { delete[] xint; - xint = 0; + xint = nullptr; } // Free memory for parameters @@ -1065,8 +1067,8 @@ const char* caux = origReq_.getVerb(); MvRequest oreq(caux); oreq("_MACRO_DECODE_TAG") = 1; // extra info for the Macro Converter - oreq("_CLASS") = (const char*)origReq_("_CLASS") ? (const char*)origReq_("_CLASS") : caux; - oreq("_VERB") = (const char*)origReq_("_VERB") ? (const char*)origReq_("_VERB") : caux; + oreq("_CLASS") = (const char*)origReq_("_CLASS") ? (const char*)origReq_("_CLASS") : caux; + oreq("_VERB") = (const char*)origReq_("_VERB") ? (const char*)origReq_("_VERB") : caux; if (strcmp((const char*)oreq("_CLASS"), "RETRIEVE") == 0 || strcmp((const char*)oreq("_CLASS"), "GRIB") == 0) { MvRequest retReq = origReq_("DATA"); diff -Nru metview-5.17.4/metview/src/XSection/Xsect.h metview-5.19.2/metview/src/XSection/Xsect.h --- metview-5.17.4/metview/src/XSection/Xsect.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/src/XSection/Xsect.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,7 +31,7 @@ { public: // Entry point routine - void serve(MvRequest&, MvRequest&); + void serve(MvRequest&, MvRequest&) override; // Process grib data and build all data structures bool processData(MvRequest&, ApplicationInfo&, MvRequest&); @@ -50,7 +50,7 @@ bool initialiseNetcdf(MvNetCDF&, ParamMap&, ApplicationInfo&, int&, MvField&, double*); // Write level info to the Netcdf structure - virtual bool writeLevelInfoNetcdf(MvNetCDF&, ApplicationInfo&, ParamMap&, MvField* = 0, double* = 0) + virtual bool writeLevelInfoNetcdf(MvNetCDF&, ApplicationInfo&, ParamMap&, MvField* = nullptr, double* = nullptr) { return true; } @@ -86,14 +86,14 @@ virtual MvRequest createOutputRequest(MvRequest&); // Compute number and geographical points - virtual int computeGeographicalPoints(ApplicationInfo&, MvField* = 0) = 0; + virtual int computeGeographicalPoints(ApplicationInfo&, MvField* = nullptr) = 0; protected: // Constructor Xsect(const char* kw); // Destructor - ~Xsect() = default; + ~Xsect() override = default; virtual void init(); void getInitialFieldInfo(MvField&, ApplicationInfo&, double&, double&, double&, double&); Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/flexpart_bwd.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/flexpart_bwd.grib differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/flexpart_conc_fwd.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/flexpart_conc_fwd.grib differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/flexpart_flux_fwd.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/flexpart_flux_fwd.grib differ diff -Nru metview-5.17.4/metview/test/data/flextra_res_multi.txt metview-5.19.2/metview/test/data/flextra_res_multi.txt --- metview-5.17.4/metview/test/data/flextra_res_multi.txt 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/data/flextra_res_multi.txt 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,354 @@ + 42 Number of header lines +********************************************************************* +* * +* FLEXTRA MODEL OUTPUT * +* FOR ECMWF WINDFIELDS * +* * +********************************************************************* +* * +* TIME OF COMPUTATION: Fri Jan 27 14:55:44 2012 * +* * +********************************************************************* +* * +* TYPE OF TRAJECTORIES: 3-DIMENSIONAL * +* * +********************************************************************* +* * +* INTEGRATION SCHEME: PETTERSSEN * +* INTERPOLATION METHOD: IDEAL * +* * +* SPATIAL CFL CRITERION: 2.00 * +* TEMPORAL CFL CRITERION: 2.00 * +* * +********************************************************************* +* * +* START POINT COMMENT: Katla * +* MODEL RUN COMMENT: FLEXTRA * +* * +********************************************************************* +* * +* INFORMATION ON WIND FIELDS USED FOR COMPUTATIONS: * +* * +* NORMAL INTERVAL BETWEEN WIND FIELDS: 21600 SECONDS * +* MAXIMUM INTERVAL BETWEEN WIND FIELDS: 43200 SECONDS * +* * +* NUMBER OF VERTICAL LEVELS: 91 92 * +* * +* MOTHER DOMAIN: * +* LONGITUDE RANGE: -60.00 TO 50.00 GRID DISTANCE: 1.00 * +* LATITUDE RANGE: 20.00 TO 90.00 GRID DISTANCE: 1.00 * +* * +********************************************************************* + +DATE: 20120111 TIME: 30000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8677 829.5 1512.0 1088.3 0.292 278.2 0.00E+00 + 10800 -13.3063 63.5992 0.8992 902.6 847.4 848.1 0.138 277.5 0.00E+00 + 21600 -7.6374 63.4449 0.9005 903.5 837.0 837.0 0.161 277.8 0.00E+00 + 32400 -2.0160 63.1638 0.8763 879.4 1049.6 1049.5 0.188 278.3 0.00E+00 + 43200 3.2851 63.0128 0.8558 858.0 1236.6 1236.7 0.247 280.0 0.00E+00 + 54000 8.7149 63.1078 0.7996 767.7 2074.1 1704.9 0.188 282.0 0.00E+00 + 64800 14.2910 62.7328 0.7616 719.9 2555.7 2040.2 0.167 283.8 0.00E+00 + 75600 18.2208 62.3399 0.7433 739.4 2344.5 2306.8 0.179 283.7 0.00E+00 + 86400 21.4933 62.4022 0.7278 722.9 2489.0 2458.0 0.163 283.6 0.00E+00 + 97200 24.8885 62.5768 0.7472 731.2 2381.8 2228.9 0.213 283.3 0.00E+00 + 108000 27.9038 62.7651 0.7291 717.3 2516.6 2412.2 0.265 283.8 0.00E+00 + 118800 30.4272 63.0468 0.7286 712.5 2554.9 2401.5 0.252 283.5 0.00E+00 + 129600 32.4093 63.4755 0.7226 704.9 2624.5 2451.6 0.316 283.5 0.00E+00 + 140400 33.7897 64.0346 0.7063 694.4 2726.5 2626.8 0.324 283.8 0.00E+00 + 151200 34.5431 64.7086 0.6984 690.3 2763.6 2716.2 0.362 283.6 0.00E+00 + 162000 34.5109 65.3356 0.7099 702.5 2629.7 2596.1 0.364 283.1 0.00E+00 + 172800 33.3879 65.8888 0.7090 697.3 2686.0 2592.5 0.333 283.7 0.00E+00 + 183600 31.0452 66.3628 0.7070 690.8 2753.7 2590.6 0.325 283.0 0.00E+00 + 194400 27.9341 66.6295 0.6953 676.0 2933.5 2699.4 0.375 283.0 0.00E+00 + 205200 24.7241 66.3514 0.6642 657.3 3163.1 3064.1 0.364 283.3 0.00E+00 + 216000 21.7482 65.3932 0.6408 639.1 3394.9 3338.2 0.309 283.5 0.00E+00 + 226800 19.2114 63.7349 0.6443 636.3 3456.1 3277.9 0.309 283.6 0.00E+00 + 237600 17.5497 61.4444 0.6283 630.2 3543.4 3506.6 0.354 283.4 0.00E+00 + 248400 16.4128 58.7767 0.6452 647.0 3376.9 3324.3 0.339 283.3 0.00E+00 + 259200 15.8823 56.2876 0.6547 658.7 3268.9 3236.1 0.335 283.1 0.00E+00 +DATE: 20120111 TIME: 60000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8678 830.5 1512.0 1088.3 0.253 278.6 0.00E+00 + 10800 -14.5195 63.4691 0.8885 892.6 940.0 941.1 0.248 277.5 0.00E+00 + 21600 -10.3865 63.3966 0.8983 901.9 855.9 856.3 0.171 277.8 0.00E+00 + 32400 -6.4084 63.1591 0.8809 883.3 1007.8 1007.9 0.212 278.3 0.00E+00 + 43200 -2.6669 62.9103 0.8566 857.3 1224.4 1224.1 0.374 279.4 0.00E+00 + 54000 0.8544 62.6162 0.8700 869.2 1103.4 1103.3 0.380 279.2 0.00E+00 + 64800 3.7569 62.2113 0.8803 877.2 1011.3 1011.7 0.500 279.6 0.00E+00 + 75600 5.6844 61.6558 0.8474 807.7 1653.9 1272.6 0.651 282.4 0.00E+00 + 86400 7.0488 60.8337 0.8795 789.7 1813.1 952.7 0.581 281.7 0.00E+00 + 97200 8.4028 59.7551 0.8995 800.8 1707.7 795.3 0.518 284.3 0.00E+00 + 108000 9.0069 58.2196 0.8397 829.2 1444.2 1387.8 0.419 284.0 0.00E+00 + 118800 9.7219 56.5697 0.7519 750.2 2263.4 2234.5 0.588 284.8 0.00E+00 + 129600 11.9442 54.8476 0.7142 716.4 2644.9 2627.4 0.444 285.1 0.00E+00 + 140400 14.5213 53.2088 0.6996 701.3 2821.4 2772.0 0.570 284.8 0.00E+00 + 151200 17.1342 51.7437 0.6986 697.7 2872.0 2770.5 0.526 284.3 0.00E+00 + 162000 19.9663 50.5788 0.7018 690.2 2948.4 2695.7 0.461 283.7 0.00E+00 + 172800 22.7239 49.6177 0.7118 690.3 2952.3 2567.6 0.437 284.3 0.00E+00 + 183600 25.2275 48.8301 0.7114 692.2 2924.2 2576.1 0.404 284.0 0.00E+00 + 194400 27.5083 48.3010 0.7107 701.6 2813.3 2620.6 0.368 284.5 0.00E+00 + 205200 29.6233 47.9107 0.7139 706.4 2759.8 2594.0 0.375 284.5 0.00E+00 + 216000 31.5016 47.7425 0.7164 712.0 2694.5 2573.0 0.384 284.1 0.00E+00 + 226800 33.1676 47.8007 0.7323 728.3 2515.2 2407.0 0.381 283.5 0.00E+00 + 237600 34.7034 48.1166 0.7204 716.0 2635.8 2529.1 0.337 284.0 0.00E+00 + 248400 36.0751 48.5587 0.7329 726.3 2515.3 2390.4 0.396 283.1 0.00E+00 + 259200 37.1320 48.9790 0.7462 737.6 2395.2 2252.7 0.386 282.8 0.00E+00 +DATE: 20120111 TIME: 90000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8676 830.0 1512.0 1088.3 0.279 278.3 0.00E+00 + 10800 -15.9492 63.3522 0.8851 889.3 965.3 967.3 0.267 276.9 0.00E+00 + 21600 -13.6165 63.0576 0.9086 912.0 764.3 764.3 0.296 277.3 0.00E+00 + 32400 -12.1125 62.4730 0.9106 913.7 748.5 748.5 0.125 277.5 0.00E+00 + 43200 -11.0993 61.6460 0.9119 916.5 738.8 738.7 0.115 277.8 0.00E+00 + 54000 -10.0095 60.5460 0.9120 918.9 738.9 739.0 0.219 278.1 0.00E+00 + 64800 -8.4510 59.0397 0.9101 920.8 759.8 760.1 0.239 279.1 0.00E+00 + 75600 -6.6852 57.2784 0.9135 926.5 757.6 731.8 0.384 279.2 0.00E+00 + 86400 -4.9867 55.8091 0.9346 939.8 682.0 546.1 0.263 279.2 0.00E+00 + 97200 -3.1216 54.7705 0.9509 965.5 484.6 408.4 0.169 277.7 0.00E+00 + 108000 -1.4284 53.9327 0.9598 968.3 470.6 333.7 0.044 279.3 0.00E+00 + 118800 -0.3639 53.0573 0.9599 982.9 368.2 333.8 0.202 278.8 0.00E+00 + 129600 0.3385 52.2537 0.9616 984.5 370.0 318.8 0.290 278.4 0.00E+00 + 140400 0.8961 51.6035 0.9699 996.6 275.1 248.7 0.432 277.8 0.00E+00 + 151200 1.3214 51.0131 0.9763 1005.8 204.1 195.2 0.466 277.5 0.00E+00 + 162000 1.6102 50.5172 0.9784 1005.6 206.9 177.7 0.394 277.0 0.00E+00 + 172800 1.7836 50.1498 0.9825 1007.6 199.3 143.1 0.352 276.7 0.00E+00 + 183600 1.9096 49.8968 0.9862 1009.0 187.4 113.5 0.005 276.9 0.00E+00 + 194400 2.0052 49.6700 0.9873 1008.8 181.7 103.9 0.039 277.5 0.00E+00 + 205200 1.8786 49.3833 0.9884 1009.8 173.9 94.9 0.625 277.0 0.00E+00 + 216000 1.3948 49.1185 0.9896 1007.3 193.5 84.6 1.662 275.8 0.00E+00 + 226800 0.7156 49.0434 0.9904 1005.3 200.7 77.5 1.938 274.3 0.00E+00 + 237600 0.1273 49.1465 0.9912 1010.5 151.0 70.8 1.721 273.2 0.00E+00 + 248400 -0.3784 49.3553 0.9927 1012.7 125.4 58.6 1.122 273.8 0.00E+00 + 259200 -0.9831 49.6761 0.9944 1017.1 88.4 45.6 0.137 275.7 0.00E+00 +DATE: 20120111 TIME: 120000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8675 830.2 1512.0 1088.3 0.323 278.3 0.00E+00 + 10800 -16.8656 63.1456 0.8876 886.0 998.9 943.3 0.308 277.5 0.00E+00 + 21600 -15.2580 62.5533 0.9073 912.0 776.3 776.8 0.127 277.2 0.00E+00 + 32400 -13.7102 61.6899 0.9130 919.8 729.0 729.1 0.043 277.3 0.00E+00 + 43200 -12.0013 60.5467 0.9167 926.0 699.8 699.8 0.049 277.8 0.00E+00 + 54000 -10.1384 59.0984 0.9257 939.1 625.6 625.6 0.000 278.4 0.00E+00 + 64800 -8.4237 57.5263 0.9318 950.0 574.9 575.3 0.035 278.8 0.00E+00 + 75600 -7.0189 56.2151 0.9356 957.3 552.6 544.3 0.014 279.2 0.00E+00 + 86400 -5.7603 55.1216 0.9374 947.8 658.2 525.5 0.019 279.9 0.00E+00 + 97200 -4.6412 54.1965 0.9448 968.5 492.9 465.9 0.013 279.6 0.00E+00 + 108000 -3.7484 53.3649 0.9518 962.7 558.4 402.1 0.038 279.6 0.00E+00 + 118800 -3.1181 52.6766 0.9582 969.1 514.7 346.3 0.098 278.4 0.00E+00 + 129600 -2.7828 52.0751 0.9674 977.9 444.8 267.9 0.162 277.9 0.00E+00 + 140400 -2.7007 51.5934 0.9738 989.1 353.9 214.7 0.266 277.5 0.00E+00 + 151200 -2.8360 51.2207 0.9779 997.1 287.4 180.8 0.448 277.0 0.00E+00 + 162000 -3.1979 50.9634 0.9802 1002.8 246.9 161.8 0.750 276.2 0.00E+00 + 172800 -3.6822 50.8552 0.9837 1005.5 223.8 133.1 0.514 275.9 0.00E+00 + 183600 -4.1756 50.8873 0.9864 1007.4 197.8 111.3 0.072 276.7 0.00E+00 + 194400 -4.7254 51.0121 0.9880 1014.7 133.2 98.2 0.200 276.8 0.00E+00 + 205200 -5.3843 51.2965 0.9893 1018.6 94.6 87.7 0.144 277.5 0.00E+00 + 216000 -6.0069 51.7657 0.9889 1017.0 93.3 91.7 0.049 278.4 0.00E+00 + 226800 -6.4844 52.3684 0.9864 1008.8 143.1 112.1 0.256 278.2 0.00E+00 + 237600 -6.9801 52.9821 0.9854 998.3 212.1 119.3 0.776 277.4 0.00E+00 + 248400 -7.6046 53.5045 0.9859 995.7 223.5 114.9 0.772 277.0 0.00E+00 + 259200 -8.3866 53.9819 0.9872 996.2 206.5 105.2 0.041 278.1 0.00E+00 +DATE: 20120111 TIME: 150000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8675 830.2 1512.0 1088.3 0.475 278.0 0.00E+00 + 10800 -16.9880 62.8433 0.8889 894.6 937.3 936.8 0.233 276.9 0.00E+00 + 21600 -15.1449 61.9618 0.9105 918.3 750.1 750.2 -0.007 276.8 0.00E+00 + 32400 -13.1121 60.8607 0.9223 932.8 650.5 650.7 -0.006 277.3 0.00E+00 + 43200 -11.0114 59.5228 0.9291 943.3 594.8 594.9 0.002 277.8 0.00E+00 + 54000 -9.2103 58.0617 0.9376 956.2 524.8 524.1 -0.006 278.3 0.00E+00 + 64800 -7.8162 56.8187 0.9428 966.0 480.7 481.3 -0.009 278.8 0.00E+00 + 75600 -6.7123 55.8559 0.9460 968.1 486.8 454.1 -0.009 279.1 0.00E+00 + 86400 -5.7268 55.0563 0.9461 957.9 583.6 451.0 -0.005 279.6 0.00E+00 + 97200 -4.8492 54.3776 0.9554 980.3 409.0 374.5 0.011 279.3 0.00E+00 + 108000 -4.1010 53.7534 0.9599 983.1 397.7 335.5 0.015 279.1 0.00E+00 + 118800 -3.4864 53.2371 0.9630 975.2 466.8 306.5 0.073 278.7 0.00E+00 + 129600 -2.9283 52.7210 0.9678 981.2 416.7 265.2 0.140 277.7 0.00E+00 + 140400 -2.5788 52.2199 0.9724 984.8 387.3 225.6 0.225 277.3 0.00E+00 + 151200 -2.5065 51.7542 0.9764 992.0 333.8 192.7 0.399 276.6 0.00E+00 + 162000 -2.7027 51.4514 0.9798 997.2 291.8 165.0 0.399 276.1 0.00E+00 + 172800 -2.9608 51.2892 0.9833 1001.1 251.8 136.5 0.098 276.6 0.00E+00 + 183600 -3.4117 51.1959 0.9859 1003.4 229.9 114.8 0.238 276.6 0.00E+00 + 194400 -4.1158 51.3102 0.9882 1003.9 219.1 95.9 0.610 276.3 0.00E+00 + 205200 -4.8727 51.6795 0.9890 1012.9 134.2 90.1 0.337 276.6 0.00E+00 + 216000 -5.5256 52.2750 0.9871 1011.6 127.4 106.2 0.093 277.5 0.00E+00 + 226800 -6.0344 52.9867 0.9856 1004.0 173.3 118.5 0.153 277.9 0.00E+00 + 237600 -6.5413 53.6984 0.9849 999.2 205.0 123.4 0.508 277.3 0.00E+00 + 248400 -7.0528 54.3075 0.9856 992.2 251.8 118.2 0.180 277.8 0.00E+00 + 259200 -7.6675 54.8328 0.9908 992.8 230.8 75.1 0.062 279.1 0.00E+00 + 42 Number of header lines +********************************************************************* +* * +* FLEXTRA MODEL OUTPUT * +* FOR ECMWF WINDFIELDS * +* * +********************************************************************* +* * +* TIME OF COMPUTATION: Fri Jan 27 14:55:44 2012 * +* * +********************************************************************* +* * +* TYPE OF TRAJECTORIES: 3-DIMENSIONAL * +* * +********************************************************************* +* * +* INTEGRATION SCHEME: PETTERSSEN * +* INTERPOLATION METHOD: IDEAL * +* * +* SPATIAL CFL CRITERION: 2.00 * +* TEMPORAL CFL CRITERION: 2.00 * +* * +********************************************************************* +* * +* START POINT COMMENT: Stromboli * +* MODEL RUN COMMENT: FLEXTRA * +* * +********************************************************************* +* * +* INFORMATION ON WIND FIELDS USED FOR COMPUTATIONS: * +* * +* NORMAL INTERVAL BETWEEN WIND FIELDS: 21600 SECONDS * +* MAXIMUM INTERVAL BETWEEN WIND FIELDS: 43200 SECONDS * +* * +* NUMBER OF VERTICAL LEVELS: 91 92 * +* * +* MOTHER DOMAIN: * +* LONGITUDE RANGE: -60.00 TO 50.00 GRID DISTANCE: 1.00 * +* LATITUDE RANGE: 20.00 TO 90.00 GRID DISTANCE: 1.00 * +* * +********************************************************************* + +DATE: 20120111 TIME: 30000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 15.2100 38.7900 0.9095 917.6 926.0 781.0 0.119 285.1 0.00E+00 + 10800 15.1040 38.1031 0.9202 875.2 1316.6 666.0 0.108 287.7 0.00E+00 + 21600 15.0364 37.4283 0.9370 903.5 1063.9 527.3 0.106 286.9 0.00E+00 + 32400 14.8945 36.8997 0.9257 915.6 951.1 633.3 0.014 286.4 0.00E+00 + 43200 14.8744 36.4474 0.9008 908.2 1013.6 859.9 0.059 285.6 0.00E+00 + 54000 15.0084 35.9292 0.8766 899.7 1091.7 1089.8 0.032 284.9 0.00E+00 + 64800 15.2250 35.3096 0.8576 880.7 1268.5 1268.6 0.118 285.2 0.00E+00 + 75600 15.4018 34.6169 0.8485 871.3 1354.2 1354.0 0.141 285.5 0.00E+00 + 86400 15.5826 33.8983 0.8446 867.1 1391.5 1391.6 0.139 285.7 0.00E+00 + 97200 15.7934 33.1428 0.8317 854.6 1518.5 1518.3 0.149 286.4 0.00E+00 + 108000 15.9814 32.3784 0.8104 833.6 1729.3 1729.1 0.184 287.4 0.00E+00 + 118800 16.1914 31.6709 0.7934 813.6 1920.6 1898.3 0.175 288.3 0.00E+00 + 129600 16.4312 30.9783 0.7888 802.7 2027.7 1937.2 0.195 289.0 0.00E+00 + 140400 16.6402 30.2560 0.7993 801.6 2044.1 1811.5 0.200 288.6 0.00E+00 + 151200 16.8288 29.5301 0.8192 818.2 1884.1 1610.3 0.129 287.6 0.00E+00 + 162000 16.9553 28.8588 0.8253 820.7 1854.7 1546.6 0.178 287.7 0.00E+00 + 172800 16.9230 28.1536 0.8487 827.4 1782.6 1306.1 0.201 287.2 0.00E+00 + 183600 16.7039 27.5037 0.8857 852.0 1556.9 964.4 0.137 286.5 0.00E+00 + 194400 16.3860 27.0838 0.8908 856.7 1523.8 921.2 0.152 286.6 0.00E+00 + 205200 16.0921 26.8802 0.8862 856.0 1520.6 970.6 0.034 287.3 0.00E+00 + 216000 15.8828 26.7414 0.8902 861.5 1463.3 940.3 0.015 288.3 0.00E+00 + 226800 15.6049 26.6062 0.9054 878.9 1306.3 806.7 0.012 288.2 0.00E+00 + 237600 15.2376 26.5373 0.9236 899.2 1118.4 647.3 0.020 287.7 0.00E+00 + 248400 14.9090 26.5390 0.9401 916.2 956.2 503.6 0.026 287.2 0.00E+00 + 259200 14.6562 26.5727 0.9437 919.1 918.9 471.1 0.045 286.8 0.00E+00 +DATE: 20120111 TIME: 60000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 15.2100 38.7900 0.9094 917.9 926.0 781.0 0.119 284.8 0.00E+00 + 10800 15.0452 38.1604 0.9140 872.6 1356.2 721.2 0.083 287.4 0.00E+00 + 21600 15.1334 37.5103 0.9195 887.5 1208.4 679.0 0.011 287.2 0.00E+00 + 32400 15.3041 36.9313 0.8948 891.3 1166.8 910.2 0.042 286.5 0.00E+00 + 43200 15.4685 36.2800 0.8685 885.4 1219.4 1160.4 0.061 285.1 0.00E+00 + 54000 15.6485 35.5217 0.8542 877.1 1299.1 1299.1 0.120 285.0 0.00E+00 + 64800 15.7955 34.7003 0.8457 868.2 1381.0 1380.5 0.129 285.4 0.00E+00 + 75600 15.9751 33.8518 0.8369 858.8 1464.5 1464.9 0.116 285.9 0.00E+00 + 86400 16.1747 32.9592 0.8172 839.4 1658.9 1658.9 0.183 287.0 0.00E+00 + 97200 16.3507 32.0846 0.7958 818.3 1876.4 1874.2 0.190 288.0 0.00E+00 + 108000 16.5423 31.2667 0.7796 796.2 2089.7 2032.1 0.190 289.2 0.00E+00 + 118800 16.7411 30.4588 0.7761 781.7 2236.5 2049.4 0.212 289.7 0.00E+00 + 129600 16.8946 29.6554 0.7944 793.7 2120.9 1853.8 0.201 288.5 0.00E+00 + 140400 17.0054 28.9483 0.8054 803.8 2027.2 1745.1 0.215 287.9 0.00E+00 + 151200 17.0447 28.2356 0.8304 812.7 1931.8 1480.8 0.240 287.9 0.00E+00 + 162000 16.9203 27.4857 0.8755 839.5 1667.7 1053.5 0.161 287.0 0.00E+00 + 172800 16.5880 26.8999 0.8856 847.6 1600.0 963.6 0.161 286.9 0.00E+00 + 183600 16.1561 26.5720 0.8841 856.0 1529.7 984.6 0.107 286.5 0.00E+00 + 194400 15.7589 26.4465 0.8886 862.8 1456.7 951.1 0.026 286.9 0.00E+00 + 205200 15.4594 26.3611 0.9002 875.3 1334.1 853.3 -0.003 287.9 0.00E+00 + 216000 15.1228 26.2592 0.9155 893.4 1171.3 719.3 0.008 287.5 0.00E+00 + 226800 14.7035 26.2035 0.9383 916.3 964.1 520.0 0.012 287.0 0.00E+00 + 237600 14.3165 26.2047 0.9564 932.2 814.2 364.4 0.022 286.6 0.00E+00 + 248400 13.9906 26.2739 0.9637 937.7 755.2 301.4 0.060 286.0 0.00E+00 + 259200 13.6824 26.4556 0.9637 936.5 765.7 299.9 0.122 285.5 0.00E+00 +DATE: 20120111 TIME: 90000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 15.2100 38.7900 0.9094 919.5 926.0 781.0 0.084 284.2 0.00E+00 + 10800 15.2716 38.1637 0.9141 882.2 1258.7 724.4 0.032 286.7 0.00E+00 + 21600 15.5804 37.4919 0.9074 897.4 1112.1 793.2 0.026 286.2 0.00E+00 + 32400 15.7326 36.7470 0.8951 910.4 994.2 914.8 0.055 285.0 0.00E+00 + 43200 15.7774 35.9273 0.8887 912.8 976.1 976.6 0.069 284.2 0.00E+00 + 54000 15.8048 35.0913 0.8823 906.1 1036.5 1036.0 0.096 284.7 0.00E+00 + 64800 15.9058 34.2770 0.8695 892.5 1155.2 1155.2 0.114 285.1 0.00E+00 + 75600 16.0911 33.4625 0.8553 878.8 1290.9 1291.0 0.109 285.7 0.00E+00 + 86400 16.2922 32.6223 0.8357 859.8 1480.7 1480.8 0.147 286.4 0.00E+00 + 97200 16.5429 31.8173 0.8192 840.7 1655.7 1641.8 0.165 287.4 0.00E+00 + 108000 16.8587 31.0292 0.8069 821.7 1838.4 1754.7 0.190 288.6 0.00E+00 + 118800 17.1769 30.2059 0.8067 810.7 1950.2 1738.6 0.151 288.3 0.00E+00 + 129600 17.4602 29.3517 0.8237 822.2 1845.7 1568.2 0.080 288.0 0.00E+00 + 140400 17.7076 28.5507 0.8309 821.5 1845.5 1489.6 0.121 288.0 0.00E+00 + 151200 17.8099 27.6920 0.8631 843.8 1622.8 1178.5 0.116 287.1 0.00E+00 + 162000 17.6481 26.9423 0.8839 854.0 1536.7 983.5 0.164 286.8 0.00E+00 + 172800 17.2909 26.4529 0.8860 855.2 1534.3 967.1 0.123 287.0 0.00E+00 + 183600 16.9345 26.2229 0.8783 846.5 1610.8 1042.2 0.016 288.1 0.00E+00 + 194400 16.6333 26.0805 0.8732 844.2 1627.9 1092.8 0.040 289.0 0.00E+00 + 205200 16.2391 25.9368 0.8756 848.9 1585.8 1072.0 0.089 289.0 0.00E+00 + 216000 15.6935 25.8704 0.8805 855.9 1518.2 1027.4 0.080 288.6 0.00E+00 + 226800 15.1248 25.9698 0.8830 862.3 1448.7 1004.8 0.111 288.0 0.00E+00 + 237600 14.6268 26.2314 0.8830 861.5 1446.6 1002.0 0.207 287.8 0.00E+00 + 248400 14.2637 26.6249 0.8828 862.3 1439.0 1002.9 0.281 287.8 0.00E+00 + 259200 14.0924 27.1743 0.8788 857.3 1492.3 1038.4 0.337 288.4 0.00E+00 +DATE: 20120111 TIME: 120000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 15.2100 38.7900 0.9093 918.7 926.0 781.0 0.009 284.1 0.00E+00 + 10800 15.4174 38.1453 0.9120 885.5 1225.5 744.2 0.027 286.4 0.00E+00 + 21600 15.6742 37.3887 0.9114 909.7 1005.6 760.3 0.091 285.6 0.00E+00 + 32400 15.5960 36.6144 0.9141 928.7 840.5 742.5 0.070 284.7 0.00E+00 + 43200 15.3293 35.9529 0.9174 942.9 716.3 716.9 0.012 284.1 0.00E+00 + 54000 15.0223 35.4281 0.9151 940.1 738.0 738.3 0.016 284.4 0.00E+00 + 64800 14.7770 34.9077 0.9066 932.7 815.7 815.6 0.037 284.6 0.00E+00 + 75600 14.5714 34.3608 0.9048 932.4 833.2 833.3 0.034 284.5 0.00E+00 + 86400 14.4314 33.8553 0.9114 938.5 774.0 774.3 0.008 285.0 0.00E+00 + 97200 14.4485 33.3950 0.9147 941.6 744.9 745.2 0.012 285.2 0.00E+00 + 108000 14.5728 32.9454 0.9147 941.4 752.4 744.8 0.004 285.4 0.00E+00 + 118800 14.7230 32.4698 0.9148 936.8 796.7 741.7 0.029 285.4 0.00E+00 + 129600 14.8630 32.0056 0.9180 938.1 778.6 710.5 0.015 285.2 0.00E+00 + 140400 15.0346 31.5857 0.9232 942.2 732.6 662.3 0.038 285.2 0.00E+00 + 151200 15.2947 31.2088 0.9294 947.0 695.3 605.5 0.051 284.9 0.00E+00 + 162000 15.5972 30.9340 0.9405 957.5 612.6 507.3 0.067 284.6 0.00E+00 + 172800 16.0448 30.8145 0.9535 967.8 513.0 397.1 0.002 285.2 0.00E+00 + 183600 16.5921 30.7486 0.9632 974.9 444.6 313.3 -0.003 286.2 0.00E+00 + 194400 17.1880 30.6810 0.9715 983.9 369.6 241.7 0.016 286.1 0.00E+00 + 205200 17.9195 30.6673 0.9789 996.3 260.8 178.5 0.076 285.7 0.00E+00 + 216000 18.8339 30.6932 0.9826 1005.1 176.3 146.8 0.126 285.8 0.00E+00 + 226800 19.8470 30.6737 0.9801 1003.4 180.0 168.2 0.141 285.7 0.00E+00 + 237600 20.8450 30.6500 0.9742 994.3 258.4 218.1 0.457 285.1 0.00E+00 + 248400 21.7814 30.7814 0.9733 987.6 315.2 225.3 0.489 284.9 0.00E+00 + 259200 22.7850 31.0201 0.9747 983.0 337.7 214.4 -0.007 286.7 0.00E+00 +DATE: 20120111 TIME: 150000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 15.2100 38.7900 0.9095 918.8 926.0 781.0 0.007 284.7 0.00E+00 + 10800 15.4044 38.0948 0.9189 889.2 1198.1 682.7 0.156 286.5 0.00E+00 + 21600 15.5761 37.3273 0.9244 921.1 913.9 644.3 0.092 285.5 0.00E+00 + 32400 15.3451 36.6326 0.9295 937.6 767.0 603.9 0.078 285.1 0.00E+00 + 43200 15.0114 36.0861 0.9271 949.0 662.5 629.4 0.020 284.4 0.00E+00 + 54000 14.8336 35.6027 0.9273 954.3 628.4 628.8 0.014 284.1 0.00E+00 + 64800 14.7258 35.1260 0.9255 953.9 646.1 646.2 0.005 284.4 0.00E+00 + 75600 14.7088 34.6561 0.9243 951.8 657.0 657.0 0.013 284.6 0.00E+00 + 86400 14.7866 34.1877 0.9286 955.8 618.6 618.6 0.016 284.8 0.00E+00 + 97200 14.9314 33.7216 0.9397 967.8 521.2 521.1 0.011 284.9 0.00E+00 + 108000 15.1503 33.2879 0.9460 974.8 465.9 465.6 -0.003 285.3 0.00E+00 + 118800 15.4458 32.8513 0.9449 972.4 478.4 475.4 -0.005 285.5 0.00E+00 + 129600 15.8440 32.3892 0.9435 969.7 489.9 486.9 0.012 285.4 0.00E+00 + 140400 16.2688 31.9379 0.9394 965.8 527.2 523.3 0.029 285.6 0.00E+00 + 151200 16.7640 31.5182 0.9271 949.9 671.9 632.4 0.036 286.0 0.00E+00 + 162000 17.3503 31.1396 0.9104 930.6 829.6 782.5 0.062 286.2 0.00E+00 + 172800 17.9634 30.7871 0.8975 916.3 951.5 899.9 0.068 286.5 0.00E+00 + 183600 18.5682 30.4718 0.8923 909.4 1016.4 946.5 0.080 286.9 0.00E+00 + 194400 19.1606 30.2202 0.8935 913.3 978.6 936.8 0.055 287.0 0.00E+00 + 205200 19.7578 30.0409 0.8916 912.0 982.4 953.9 0.029 286.9 0.00E+00 + 216000 20.3882 29.8894 0.8861 907.1 1018.2 1003.5 0.033 286.6 0.00E+00 + 226800 21.0385 29.7577 0.8823 903.8 1050.7 1038.1 0.033 286.5 0.00E+00 + 237600 21.6257 29.7021 0.8794 898.9 1098.7 1062.9 0.030 286.4 0.00E+00 + 248400 22.2358 29.7744 0.8855 901.7 1060.5 1006.3 0.038 286.6 0.00E+00 + 259200 23.0071 29.9270 0.9038 918.3 905.1 839.8 0.061 286.5 0.00E+00 diff -Nru metview-5.17.4/metview/test/data/flextra_res_normal.txt metview-5.19.2/metview/test/data/flextra_res_normal.txt --- metview-5.17.4/metview/test/data/flextra_res_normal.txt 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/data/flextra_res_normal.txt 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,177 @@ + 42 Number of header lines +********************************************************************* +* * +* FLEXTRA MODEL OUTPUT * +* FOR ECMWF WINDFIELDS * +* * +********************************************************************* +* * +* TIME OF COMPUTATION: Mon Jan 23 11:46:27 2012 * +* * +********************************************************************* +* * +* TYPE OF TRAJECTORIES: 3-DIMENSIONAL * +* * +********************************************************************* +* * +* INTEGRATION SCHEME: PETTERSSEN * +* INTERPOLATION METHOD: IDEAL * +* * +* SPATIAL CFL CRITERION: 2.00 * +* TEMPORAL CFL CRITERION: 2.00 * +* * +********************************************************************* +* * +* START POINT COMMENT: Katla * +* MODEL RUN COMMENT: FLEXTRA * +* * +********************************************************************* +* * +* INFORMATION ON WIND FIELDS USED FOR COMPUTATIONS: * +* * +* NORMAL INTERVAL BETWEEN WIND FIELDS: 21600 SECONDS * +* MAXIMUM INTERVAL BETWEEN WIND FIELDS: 43200 SECONDS * +* * +* NUMBER OF VERTICAL LEVELS: 91 92 * +* * +* MOTHER DOMAIN: * +* LONGITUDE RANGE: -60.00 TO 50.00 GRID DISTANCE: 1.00 * +* LATITUDE RANGE: 20.00 TO 90.00 GRID DISTANCE: 1.00 * +* * +********************************************************************* + +DATE: 20120111 TIME: 30000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8677 829.5 1512.0 1088.3 0.292 278.2 0.00E+00 + 10800 -13.3063 63.5992 0.8992 902.6 847.4 848.1 0.138 277.5 0.00E+00 + 21600 -7.6374 63.4449 0.9005 903.5 837.0 837.0 0.161 277.8 0.00E+00 + 32400 -2.0160 63.1638 0.8763 879.4 1049.6 1049.5 0.188 278.3 0.00E+00 + 43200 3.2851 63.0128 0.8558 858.0 1236.6 1236.7 0.247 280.0 0.00E+00 + 54000 8.7149 63.1078 0.7996 767.7 2074.1 1704.9 0.188 282.0 0.00E+00 + 64800 14.2910 62.7328 0.7616 719.9 2555.7 2040.2 0.167 283.8 0.00E+00 + 75600 18.2208 62.3399 0.7433 739.4 2344.5 2306.8 0.179 283.7 0.00E+00 + 86400 21.4933 62.4022 0.7278 722.9 2489.0 2458.0 0.163 283.6 0.00E+00 + 97200 24.8885 62.5768 0.7472 731.2 2381.8 2228.9 0.213 283.3 0.00E+00 + 108000 27.9038 62.7651 0.7291 717.3 2516.6 2412.2 0.265 283.8 0.00E+00 + 118800 30.4272 63.0468 0.7286 712.5 2554.9 2401.5 0.252 283.5 0.00E+00 + 129600 32.4093 63.4755 0.7226 704.9 2624.5 2451.6 0.316 283.5 0.00E+00 + 140400 33.7897 64.0346 0.7063 694.4 2726.5 2626.8 0.324 283.8 0.00E+00 + 151200 34.5431 64.7086 0.6984 690.3 2763.6 2716.2 0.362 283.6 0.00E+00 + 162000 34.5109 65.3356 0.7099 702.5 2629.7 2596.1 0.364 283.1 0.00E+00 + 172800 33.3879 65.8888 0.7090 697.3 2686.0 2592.5 0.333 283.7 0.00E+00 + 183600 31.0452 66.3628 0.7070 690.8 2753.7 2590.6 0.325 283.0 0.00E+00 + 194400 27.9341 66.6295 0.6953 676.0 2933.5 2699.4 0.375 283.0 0.00E+00 + 205200 24.7241 66.3514 0.6642 657.3 3163.1 3064.1 0.364 283.3 0.00E+00 + 216000 21.7482 65.3932 0.6408 639.1 3394.9 3338.2 0.309 283.5 0.00E+00 + 226800 19.2114 63.7349 0.6443 636.3 3456.1 3277.9 0.309 283.6 0.00E+00 + 237600 17.5497 61.4444 0.6283 630.2 3543.4 3506.6 0.354 283.4 0.00E+00 + 248400 16.4128 58.7767 0.6452 647.0 3376.9 3324.3 0.339 283.3 0.00E+00 + 259200 15.8823 56.2876 0.6547 658.7 3268.9 3236.1 0.335 283.1 0.00E+00 +DATE: 20120111 TIME: 60000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8678 830.5 1512.0 1088.3 0.253 278.6 0.00E+00 + 10800 -14.5195 63.4691 0.8885 892.6 940.0 941.1 0.248 277.5 0.00E+00 + 21600 -10.3865 63.3966 0.8983 901.9 855.9 856.3 0.171 277.8 0.00E+00 + 32400 -6.4084 63.1591 0.8809 883.3 1007.8 1007.9 0.212 278.3 0.00E+00 + 43200 -2.6669 62.9103 0.8566 857.3 1224.4 1224.1 0.374 279.4 0.00E+00 + 54000 0.8544 62.6162 0.8700 869.2 1103.4 1103.3 0.380 279.2 0.00E+00 + 64800 3.7569 62.2113 0.8803 877.2 1011.3 1011.7 0.500 279.6 0.00E+00 + 75600 5.6844 61.6558 0.8474 807.7 1653.9 1272.6 0.651 282.4 0.00E+00 + 86400 7.0488 60.8337 0.8795 789.7 1813.1 952.7 0.581 281.7 0.00E+00 + 97200 8.4028 59.7551 0.8995 800.8 1707.7 795.3 0.518 284.3 0.00E+00 + 108000 9.0069 58.2196 0.8397 829.2 1444.2 1387.8 0.419 284.0 0.00E+00 + 118800 9.7219 56.5697 0.7519 750.2 2263.4 2234.5 0.588 284.8 0.00E+00 + 129600 11.9442 54.8476 0.7142 716.4 2644.9 2627.4 0.444 285.1 0.00E+00 + 140400 14.5213 53.2088 0.6996 701.3 2821.4 2772.0 0.570 284.8 0.00E+00 + 151200 17.1342 51.7437 0.6986 697.7 2872.0 2770.5 0.526 284.3 0.00E+00 + 162000 19.9663 50.5788 0.7018 690.2 2948.4 2695.7 0.461 283.7 0.00E+00 + 172800 22.7239 49.6177 0.7118 690.3 2952.3 2567.6 0.437 284.3 0.00E+00 + 183600 25.2275 48.8301 0.7114 692.2 2924.2 2576.1 0.404 284.0 0.00E+00 + 194400 27.5083 48.3010 0.7107 701.6 2813.3 2620.6 0.368 284.5 0.00E+00 + 205200 29.6233 47.9107 0.7139 706.4 2759.8 2594.0 0.375 284.5 0.00E+00 + 216000 31.5016 47.7425 0.7164 712.0 2694.5 2573.0 0.384 284.1 0.00E+00 + 226800 33.1676 47.8007 0.7323 728.3 2515.2 2407.0 0.381 283.5 0.00E+00 + 237600 34.7034 48.1166 0.7204 716.0 2635.8 2529.1 0.337 284.0 0.00E+00 + 248400 36.0751 48.5587 0.7329 726.3 2515.3 2390.4 0.396 283.1 0.00E+00 + 259200 37.1320 48.9790 0.7462 737.6 2395.2 2252.7 0.386 282.8 0.00E+00 +DATE: 20120111 TIME: 90000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8676 830.0 1512.0 1088.3 0.279 278.3 0.00E+00 + 10800 -15.9492 63.3522 0.8851 889.3 965.3 967.3 0.267 276.9 0.00E+00 + 21600 -13.6165 63.0576 0.9086 912.0 764.3 764.3 0.296 277.3 0.00E+00 + 32400 -12.1125 62.4730 0.9106 913.7 748.5 748.5 0.125 277.5 0.00E+00 + 43200 -11.0993 61.6460 0.9119 916.5 738.8 738.7 0.115 277.8 0.00E+00 + 54000 -10.0095 60.5460 0.9120 918.9 738.9 739.0 0.219 278.1 0.00E+00 + 64800 -8.4510 59.0397 0.9101 920.8 759.8 760.1 0.239 279.1 0.00E+00 + 75600 -6.6852 57.2784 0.9135 926.5 757.6 731.8 0.384 279.2 0.00E+00 + 86400 -4.9867 55.8091 0.9346 939.8 682.0 546.1 0.263 279.2 0.00E+00 + 97200 -3.1216 54.7705 0.9509 965.5 484.6 408.4 0.169 277.7 0.00E+00 + 108000 -1.4284 53.9327 0.9598 968.3 470.6 333.7 0.044 279.3 0.00E+00 + 118800 -0.3639 53.0573 0.9599 982.9 368.2 333.8 0.202 278.8 0.00E+00 + 129600 0.3385 52.2537 0.9616 984.5 370.0 318.8 0.290 278.4 0.00E+00 + 140400 0.8961 51.6035 0.9699 996.6 275.1 248.7 0.432 277.8 0.00E+00 + 151200 1.3214 51.0131 0.9763 1005.8 204.1 195.2 0.466 277.5 0.00E+00 + 162000 1.6102 50.5172 0.9784 1005.6 206.9 177.7 0.394 277.0 0.00E+00 + 172800 1.7836 50.1498 0.9825 1007.6 199.3 143.1 0.352 276.7 0.00E+00 + 183600 1.9096 49.8968 0.9862 1009.0 187.4 113.5 0.005 276.9 0.00E+00 + 194400 2.0052 49.6700 0.9873 1008.8 181.7 103.9 0.039 277.5 0.00E+00 + 205200 1.8786 49.3833 0.9884 1009.8 173.9 94.9 0.625 277.0 0.00E+00 + 216000 1.3948 49.1185 0.9896 1007.3 193.5 84.6 1.662 275.8 0.00E+00 + 226800 0.7156 49.0434 0.9904 1005.3 200.7 77.5 1.938 274.3 0.00E+00 + 237600 0.1273 49.1465 0.9912 1010.5 151.0 70.8 1.721 273.2 0.00E+00 + 248400 -0.3784 49.3553 0.9927 1012.7 125.4 58.6 1.122 273.8 0.00E+00 + 259200 -0.9831 49.6761 0.9944 1017.1 88.4 45.6 0.137 275.7 0.00E+00 +DATE: 20120111 TIME: 120000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8675 830.2 1512.0 1088.3 0.323 278.3 0.00E+00 + 10800 -16.8656 63.1456 0.8876 886.0 998.9 943.3 0.308 277.5 0.00E+00 + 21600 -15.2580 62.5533 0.9073 912.0 776.3 776.8 0.127 277.2 0.00E+00 + 32400 -13.7102 61.6899 0.9130 919.8 729.0 729.1 0.043 277.3 0.00E+00 + 43200 -12.0013 60.5467 0.9167 926.0 699.8 699.8 0.049 277.8 0.00E+00 + 54000 -10.1384 59.0984 0.9257 939.1 625.6 625.6 0.000 278.4 0.00E+00 + 64800 -8.4237 57.5263 0.9318 950.0 574.9 575.3 0.035 278.8 0.00E+00 + 75600 -7.0189 56.2151 0.9356 957.3 552.6 544.3 0.014 279.2 0.00E+00 + 86400 -5.7603 55.1216 0.9374 947.8 658.2 525.5 0.019 279.9 0.00E+00 + 97200 -4.6412 54.1965 0.9448 968.5 492.9 465.9 0.013 279.6 0.00E+00 + 108000 -3.7484 53.3649 0.9518 962.7 558.4 402.1 0.038 279.6 0.00E+00 + 118800 -3.1181 52.6766 0.9582 969.1 514.7 346.3 0.098 278.4 0.00E+00 + 129600 -2.7828 52.0751 0.9674 977.9 444.8 267.9 0.162 277.9 0.00E+00 + 140400 -2.7007 51.5934 0.9738 989.1 353.9 214.7 0.266 277.5 0.00E+00 + 151200 -2.8360 51.2207 0.9779 997.1 287.4 180.8 0.448 277.0 0.00E+00 + 162000 -3.1979 50.9634 0.9802 1002.8 246.9 161.8 0.750 276.2 0.00E+00 + 172800 -3.6822 50.8552 0.9837 1005.5 223.8 133.1 0.514 275.9 0.00E+00 + 183600 -4.1756 50.8873 0.9864 1007.4 197.8 111.3 0.072 276.7 0.00E+00 + 194400 -4.7254 51.0121 0.9880 1014.7 133.2 98.2 0.200 276.8 0.00E+00 + 205200 -5.3843 51.2965 0.9893 1018.6 94.6 87.7 0.144 277.5 0.00E+00 + 216000 -6.0069 51.7657 0.9889 1017.0 93.3 91.7 0.049 278.4 0.00E+00 + 226800 -6.4844 52.3684 0.9864 1008.8 143.1 112.1 0.256 278.2 0.00E+00 + 237600 -6.9801 52.9821 0.9854 998.3 212.1 119.3 0.776 277.4 0.00E+00 + 248400 -7.6046 53.5045 0.9859 995.7 223.5 114.9 0.772 277.0 0.00E+00 + 259200 -8.3866 53.9819 0.9872 996.2 206.5 105.2 0.041 278.1 0.00E+00 +DATE: 20120111 TIME: 150000 STOP INDEX: 1 # OF POINTS: 25 + SECS LONGIT LATIT ETA PRESS Z Z-ORO PV THETA Q + 0 -19.0500 63.6300 0.8675 830.2 1512.0 1088.3 0.475 278.0 0.00E+00 + 10800 -16.9880 62.8433 0.8889 894.6 937.3 936.8 0.233 276.9 0.00E+00 + 21600 -15.1449 61.9618 0.9105 918.3 750.1 750.2 -0.007 276.8 0.00E+00 + 32400 -13.1121 60.8607 0.9223 932.8 650.5 650.7 -0.006 277.3 0.00E+00 + 43200 -11.0114 59.5228 0.9291 943.3 594.8 594.9 0.002 277.8 0.00E+00 + 54000 -9.2103 58.0617 0.9376 956.2 524.8 524.1 -0.006 278.3 0.00E+00 + 64800 -7.8162 56.8187 0.9428 966.0 480.7 481.3 -0.009 278.8 0.00E+00 + 75600 -6.7123 55.8559 0.9460 968.1 486.8 454.1 -0.009 279.1 0.00E+00 + 86400 -5.7268 55.0563 0.9461 957.9 583.6 451.0 -0.005 279.6 0.00E+00 + 97200 -4.8492 54.3776 0.9554 980.3 409.0 374.5 0.011 279.3 0.00E+00 + 108000 -4.1010 53.7534 0.9599 983.1 397.7 335.5 0.015 279.1 0.00E+00 + 118800 -3.4864 53.2371 0.9630 975.2 466.8 306.5 0.073 278.7 0.00E+00 + 129600 -2.9283 52.7210 0.9678 981.2 416.7 265.2 0.140 277.7 0.00E+00 + 140400 -2.5788 52.2199 0.9724 984.8 387.3 225.6 0.225 277.3 0.00E+00 + 151200 -2.5065 51.7542 0.9764 992.0 333.8 192.7 0.399 276.6 0.00E+00 + 162000 -2.7027 51.4514 0.9798 997.2 291.8 165.0 0.399 276.1 0.00E+00 + 172800 -2.9608 51.2892 0.9833 1001.1 251.8 136.5 0.098 276.6 0.00E+00 + 183600 -3.4117 51.1959 0.9859 1003.4 229.9 114.8 0.238 276.6 0.00E+00 + 194400 -4.1158 51.3102 0.9882 1003.9 219.1 95.9 0.610 276.3 0.00E+00 + 205200 -4.8727 51.6795 0.9890 1012.9 134.2 90.1 0.337 276.6 0.00E+00 + 216000 -5.5256 52.2750 0.9871 1011.6 127.4 106.2 0.093 277.5 0.00E+00 + 226800 -6.0344 52.9867 0.9856 1004.0 173.3 118.5 0.153 277.9 0.00E+00 + 237600 -6.5413 53.6984 0.9849 999.2 205.0 123.4 0.508 277.3 0.00E+00 + 248400 -7.0528 54.3075 0.9856 992.2 251.8 118.2 0.180 277.8 0.00E+00 + 259200 -7.6675 54.8328 0.9908 992.8 230.8 75.1 0.062 279.1 0.00E+00 Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ew_maximum_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ew_maximum_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ew_mean_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ew_mean_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ew_median_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ew_median_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ew_minimum_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ew_minimum_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ew_stdev_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ew_stdev_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ew_variance_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ew_variance_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ns_maximum_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ns_maximum_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ns_mean_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ns_mean_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ns_median_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ns_median_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ns_minimum_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ns_minimum_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ns_stdev_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ns_stdev_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovarea_ll_ns_variance_ref.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovarea_ll_ns_variance_ref.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovexp_area_ref_1.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovexp_area_ref_1.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovexp_line_ref_1.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovexp_line_ref_1.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovexp_vert_area.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovexp_vert_area.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovexp_vert_nearest_gridpoint.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovexp_vert_nearest_gridpoint.nc differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/hovexp_vert_point.nc and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/hovexp_vert_point.nc differ diff -Nru metview-5.17.4/metview/test/data/invalid_geo_interpolate_gg_ref.gpt metview-5.19.2/metview/test/data/invalid_geo_interpolate_gg_ref.gpt --- metview-5.17.4/metview/test/data/invalid_geo_interpolate_gg_ref.gpt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/data/invalid_geo_interpolate_gg_ref.gpt 2023-07-15 08:28:47.000000000 +0000 @@ -19,5 +19,5 @@ 45 180 1000 20180610 1200 279.3019993 45 190 1000 20180610 1200 279.327854 45 -170 1000 20180610 1200 279.327854 -45 360 1000 20180610 1200 293.3791866 +45 360 1000 20180610 1200 293.44530891735655587 45 361 1000 20180610 1200 3e+38 diff -Nru metview-5.17.4/metview/test/data/invalid_geo_interpolate_ll_ref.gpt metview-5.19.2/metview/test/data/invalid_geo_interpolate_ll_ref.gpt --- metview-5.17.4/metview/test/data/invalid_geo_interpolate_ll_ref.gpt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/data/invalid_geo_interpolate_ll_ref.gpt 2023-07-15 08:28:47.000000000 +0000 @@ -19,5 +19,5 @@ 45 180 1000 20150422 1200 277.7045898 45 190 1000 20150422 1200 275.7045898 45 -170 1000 20150422 1200 275.7045898 -45 360 1000 20150422 1200 249.7045898 +45 360 1000 20150422 1200 294.70458984375 45 361 1000 20150422 1200 3e+38 diff -Nru metview-5.17.4/metview/test/data/invalid_geo_nearest_gg_ref.gpt metview-5.19.2/metview/test/data/invalid_geo_nearest_gg_ref.gpt --- metview-5.17.4/metview/test/data/invalid_geo_nearest_gg_ref.gpt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/data/invalid_geo_nearest_gg_ref.gpt 2023-07-15 08:28:47.000000000 +0000 @@ -19,5 +19,5 @@ 45 180 1000 20180610 1200 279.0086212 45 190 1000 20180610 1200 278.723465 45 -170 1000 20180610 1200 278.723465 -45 360 1000 20180610 1200 292.4558868 +45 360 1000 20180610 1200 294.0379180908203125 45 361 1000 20180610 1200 3e+38 Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/regular_gaussian_subarea_g2.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/regular_gaussian_subarea_g2.grib differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/rgg_western_subarea_g2.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/rgg_western_subarea_g2.grib differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/rgg_zero_lon_subarea_g2.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/rgg_zero_lon_subarea_g2.grib differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/rgg_zero_lon_subarea.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/rgg_zero_lon_subarea.grib differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/t1000_LL_1x1_subarea_g2.grb and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/t1000_LL_1x1_subarea_g2.grb differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/t1000_SH_to_RGG_reference_g2.grb and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/t1000_SH_to_RGG_reference_g2.grb differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/metview/test/data/z500_g2.grb and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/metview/test/data/z500_g2.grb differ diff -Nru metview-5.17.4/metview/test/macros/bufr_obs_filter.mv metview-5.19.2/metview/test/macros/bufr_obs_filter.mv --- metview-5.17.4/metview/test/macros/bufr_obs_filter.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/bufr_obs_filter.mv 2023-07-15 08:28:47.000000000 +0000 @@ -14,6 +14,7 @@ global VECTOR_DIFF_THRESHOLD = 2E-3 global fMissingLocation = read("ssd_missing_location.bufr") + # call each test test_basic_filter() test_level_filter() @@ -30,6 +31,8 @@ test_geo_ncols_stnids_with_spaces() test_missing_ident() test_missing_location() +test_empty_input() +test_empty_output() # this does not work - see METV-2352 # global fWaveUc=read("wave_uncompressed.bufr") #36 subsets, each having a different time! @@ -490,3 +493,187 @@ compare_geopoints_missing(r, gpt_ref, "missing_location",1) end test_missing_location + +function test_empty_input() + + # standard geopoints + f = tmpfile() + data = read(f) + obs = obsfilter( + OUTPUT : 'GEOPOINTS', + PARAMETER : 019001, + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "geopoints", "type test_empty_input", 1) + assert_equal(dtype(obs), "standard", "dtype test_empty_input", 1) + assert_equal(count(obs), 0, "count test_empty_input", 1) + + # bufr + obs = obsfilter( + OUTPUT : 'BUFR', + OBSERVATION_TYPES : 1, + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "observations", "type test_empty_input", 2) + #assert_equal(count(obs), 0, "count test_empty_input", 2) + + # csv + obs = obsfilter( + OUTPUT : 'CSV', + OBSERVATION_TYPES : 1, + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "table", "type test_empty_input",3) + #assert_equal(count(obs), 0, "count test_empty_input", 3) + + # ncols geopoints + obs = obsfilter( + OUTPUT : 'NCOLS', + PARAMETER : [19001, 19002], + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "geopoints", "type test_empty_input", 4) + assert_equal(dtype(obs), "ncols", "dtype test_empty_input", 4) + assert_equal(count(obs), 0, "count test_empty_input", 4) + + # polar vector geopoints + obs = obsfilter( + OUTPUT : 'POLAR_VECTOR', + PARAMETER : [19001, 19002], + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "geopoints", "type test_empty_input", 5) + assert_equal(dtype(obs), "polar_vector", "dtype test_empty_input", 5) + assert_equal(count(obs), 0, "count test_empty_input", 5) + + # xy vector geopoints + obs = obsfilter( + OUTPUT : 'XY_VECTOR', + PARAMETER : [19001, 19002], + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "geopoints", "type test_empty_input", 6) + assert_equal(dtype(obs), "xy_vector", "dtype test_empty_input", 6) + assert_equal(count(obs), 0, "count test_empty_input", 6) + + +end test_empty_input + +function test_empty_output_1() + + data = read('temp_10.bufr') + + gpt = obsfilter( + OUTPUT : 'GEOPOINTS', + PARAMETER : "invalid", + DATA : data, + FAIL_ON_EMPTY_OUTPUT : "no" + ) + + assert_equal(uppercase(type(gpt)), "GEOPOINTS", "type empty_output", 1) + assert_equal(count(gpt), 0, "count empty_output", 1) + +end test_empty_output + +function test_empty_output() + + fn_name = "test_empty_output" + + data = read('temp_10.bufr') + + # standard geopoints + obs = obsfilter( + OUTPUT : 'GEOPOINTS', + PARAMETER : "invalid", + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "geopoints", fn_name & " - type", 1) + assert_equal(dtype(obs), "standard", fn_name & " - dtype", 1) + assert_equal(count(obs), 0, fn_name & " - count", 1) + + # bufr + obs = obsfilter( + OUTPUT : 'BUFR', + OBSERVATION_TYPES : 999, + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "observations", fn_name & " - type", 2) + #assert_equal(count(obs), 0, fn_name & " - count", 2) + + # csv + obs = obsfilter( + OUTPUT : 'CSV', + PARAMETER : "invalid", + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "table", fn_name & " - type",3) + #assert_equal(count(obs), 0, fn_name & " - count", 3) + + # ncols geopoints + obs = obsfilter( + OUTPUT : 'NCOLS', + PARAMETER : ["invalid_1", "invalid_2"], + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "geopoints", fn_name & " - type", 4) + assert_equal(dtype(obs), "ncols", fn_name & " - dtype", 4) + assert_equal(count(obs), 0, fn_name & " - count", 4) + + # polar vector geopoints + obs = obsfilter( + OUTPUT : 'POLAR_VECTOR', + PARAMETER : ["invalid_1", "invalid_2"], + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "geopoints", fn_name & " - type", 5) + assert_equal(dtype(obs), "polar_vector", fn_name & " - dtype", 5) + assert_equal(count(obs), 0, fn_name & " - count", 5) + + # xy vector geopoints + obs = obsfilter( + OUTPUT : 'XY_VECTOR', + PARAMETER : ["invalid_1", "invalid_2"], + DATA : data, + FAIL_ON_ERROR : "NO" + ) + + assert_equal(type(obs), "geopoints", fn_name & " - type", 6) + assert_equal(dtype(obs), "xy_vector", fn_name & " - dtype", 6) + assert_equal(count(obs), 0, fn_name & " - count", 6) + + # test crash on empty output + # ONLY enable it for local/temporary testing + if 1 = 0 then + obs = obsfilter( + OUTPUT : 'GEOPOINTS', + PARAMETER : "invalid", + DATA : data, + FAIL_ON_ERROR : "NO", + FAIL_ON_EMPTY_OUTPUT : "YES" + ) + print(obs) + end if + +end test_empty_input \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/CMakeLists.txt metview-5.19.2/metview/test/macros/CMakeLists.txt --- metview-5.17.4/metview/test/macros/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -17,7 +17,7 @@ COMMAND ${FULL_STARTUP_SCRIPT_PATH} TYPE SCRIPT ARGS -nocreatehome -b ${_PAR_MACRO} ${_PAR_MACRO_ARGS} - RESOURCES ${_PAR_MACRO} ${_PAR_RESOURCES} test_utils.mv) + RESOURCES ${_PAR_MACRO} ${_PAR_RESOURCES} test_utils.mv hov_utils.mv grib_nearest_utils.mv thermo_parcel_utils.mv ) # add to the post-install tests too if(_PAR_POST_INSTALL) @@ -69,6 +69,7 @@ metview_macro_test(MACRO grib_keys.mv RESOURCES ../data/fc_data.grib ../data/lnsp.grib + ../data/xs_rgg_input.grib POST_INSTALL) metview_macro_test(MACRO grib_gradient.mv @@ -104,44 +105,96 @@ ../data/rgg_O1280_subarea.grib ../data/rgg_small_subarea_cellarea_ref.grib) -metview_macro_test(MACRO grib_nearest_gridpoint.mv - RESOURCES ../data/t1000_LL_1x1.grb +metview_macro_test(MACRO grib_nearest_ll.mv + RESOURCES ../data/bufr_picker_reference.gpt + ../data/nearest_gridpoint_gpt_ref_1.gpt + ../data/t1000_LL_1x1.grb ../data/t1000_LL_1x1_subarea.grb + ../data/t1000_LL_1x1_subarea_g2.grb ../data/t1000_LL_2x2.grb ../data/t1000_LL_2x2_with_missing.grb - ../data/t1000_reg_gg_N48.grib - ../data/t1000_red_gg_N48.grib + ../data/nearest_gridpoint_gpt_ref_missing_1.gpt + ../data/nearest_gridpoint_gpt_ref_missing_1.gpt + ../data/nearest_gridpoint_gpt_ref_missing_2.gpt + ../data/nearest_gridpoint_gpt_ref_missing_2.gpt ../data/ll_no_pole.grib + ../data/z500.grb + ../data/z500_g2.grb) + +metview_macro_test(MACRO grib_nearest_reduced_ll.mv + RESOURCES ../data/reduced_ll.grib + ) + +metview_macro_test(MACRO grib_nearest_reduced_gg.mv + RESOURCES + ../data/t1000_SH_to_RGG_reference.grb + ../data/t1000_SH_to_RGG_reference_g2.grb + ../data/t1000_red_gg_N48.grib + ../data/rgg_western_subarea.grib + ../data/rgg_western_subarea_g2.grib ../data/rgg_small_subarea.grib + ../data/rgg_zero_lon_subarea.grib + ../data/rgg_zero_lon_subarea_g2.grib + ) + +metview_macro_test(MACRO grib_nearest_regular_gg.mv + RESOURCES ../data/regular_gaussian_subarea.grib - ../data/rgg_western_subarea.grib - ../data/reduced_ll.grib - ../data/nearest_gridpoint_gpt_ref_missing_1.gpt - ../data/nearest_gridpoint_gpt_ref_missing_2.gpt) + ../data/regular_gaussian_subarea_g2.grib + ../data/t1000_reg_gg_N48.grib +) -metview_macro_test(MACRO grib_vertical.mv +metview_macro_test(MACRO grib_vertical_geopot_on_ml.mv + RESOURCES ../data/tq_ml137.grib + ../data/z_ml137_ref.grib + ) + +metview_macro_test(MACRO grib_vertical_integral.mv RESOURCES ../data/t_lnsp_ml137.grb - ../data/pres_ml137.grib - ../data/thickness_ml137.grib - ../data/vertint_ref.grib ../data/univertint_ml_ref.grib ../data/univertint_pl_ref.grib - ../data/tq_ml137.grib - ../data/z_ml137_ref.grib - ../data/ml2pl_ref.grib - ../data/ml_to_hl_asl_ref.grib - ../data/ml_to_hl_agr_ref.grib - ../data/ml_to_hl_agr_surf_ref.grib - ../data/ml_to_hl_agr_log_surf_ref.grib - ../data/ml_to_hl_log_asl_ref.grib - ../data/ml_to_hl_log_agr_ref.grib ../data/t_80Pa.grib + ../data/vertint_ref.grib + ../data/tuv_pl.grib + ) + + metview_macro_test(MACRO grib_vertical_interpolate_to_pl.mv + RESOURCES ../data/tq_ml137.grib + ../data/ml2pl_ref.grib + ../data/xs_pl_input.grib + ../data/pl_to_pl_ref.grib + ../data/pl_to_pl_log_ref.grib + ../data/pl_pa_hpa.grib + ) + + metview_macro_test(MACRO grib_vertical_interpolate_to_hl_1.mv + RESOURCES ../data/tq_ml137.grib + ../data/z_ml137_ref.grib + ../data/ml_to_hl_asl_ref.grib + ../data/ml_to_hl_agr_ref.grib + ../data/ml_to_hl_log_asl_ref.grib + ../data/ml_to_hl_log_agr_ref.grib + ) + + + metview_macro_test(MACRO grib_vertical_interpolate_to_hl_2.mv + RESOURCES ../data/tq_ml137.grib + ../data/z_ml137_ref.grib + ../data/ml_to_hl_asl_ref.grib + ../data/ml_to_hl_agr_ref.grib + ../data/ml_to_hl_agr_surf_ref.grib + ../data/ml_to_hl_agr_log_surf_ref.grib + ) + +metview_macro_test(MACRO grib_vertical_pressure.mv + RESOURCES ../data/t_lnsp_ml137.grb + ../data/tuv_pl.grib + ../data/thickness_ml137.grib + ../data/pres_ml137.grib + ../data/dt_dp_ref.grib ../data/omega_ml.grib ../data/omega_pl.grib - ../data/dt_dp_ref.grib - ../data/pl_to_pl_ref.grib - ../data/pl_to_pl_log_ref.grib - ../data/pl_pa_hpa.grib) + ) metview_macro_test(MACRO polygon_mask.mv RESOURCES ../data/poly_ref.grib @@ -307,21 +360,75 @@ metview_macro_test(MACRO version.mv POST_INSTALL) -metview_macro_test(MACRO fieldsets.mv - RESOURCES ../data/hindcast.grib - ../data/tuv_pl.grib - ../data/t1000_LL_2x2.grb +metview_macro_test(MACRO fieldset_bitmap.mv + RESOURCES ../data/t1000_LL_2x2.grb ../data/t1000_LL_2x2_with_missing.grb + ../data/monthly_avg.grib + ) + +metview_macro_test(MACRO fieldset_compute.mv + RESOURCES ../data/tuv_pl.grib + ../data/surface_wind.grib + ../data/abs_vort.grib + ) + +metview_macro_test(MACRO fieldset_geo.mv + RESOURCES ../data/t1000_LL_2x2.grb + ../data/t1000_LL_7x7.grb + ../data/fc_data.grib + ../data/t1000_reg_gg_N48.grib + ../data/regular_gaussian_subarea.grib + ../data/t1000_red_gg_N48.grib + ../data/rgg_small_subarea.grib + ../data/rgg_western_subarea.grib + ../data/reduced_ll.grib + ../data/ll_dateline.grib + ../data/solar_zenith_angle.grib ../data/rmask_ref.grib + ) + +metview_macro_test(MACRO fieldset_maths.mv + RESOURCES ../data/t1000_LL_2x2.grb + ../data/t1000_LL_7x7.grb + ) + +metview_macro_test(MACRO fieldset_stats.mv + RESOURCES ../data/t1000_LL_2x2.grb + ../data/t1000_LL_7x7.grb + ../data/monthly_avg.grib + ) + +metview_macro_test(MACRO fieldset_util.mv + RESOURCES ../data/hindcast.grib ../data/sort.grib - ../data/daily_clims.grib + ../data/t1000_LL_2x2.grb + ../data/t1000_LL_2x2_with_missing.grb + ../data/t1000_LL_7x7.grb ../data/surface_wind.grib ../data/xs_rgg_input.grib ../data/xs_ml_input.grib - ../data/abs_vort.grib - ../data/ll_dateline.grib - ../data/solar_zenith_angle.grib - ../data/ll_steps_168.grib) + ../data/tuv_pl.grib + ../data/daily_clims.grib + ../data/ll_steps_168.grib + ) + +metview_macro_test(MACRO fieldset_read_sort.mv + RESOURCES ../data/daily_clims.grib + ../data/ll_steps_168.grib + ../data/ml2pl_ref.grib + ) + +metview_macro_test(MACRO fieldset_sort_default.mv + RESOURCES ../data/sort.grib + ) + +metview_macro_test(MACRO fieldset_sort_custom_1.mv + RESOURCES ../data/sort.grib + ) + +metview_macro_test(MACRO fieldset_sort_custom_2.mv + RESOURCES ../data/sort.grib + ) metview_macro_test(MACRO llmatrix.mv RESOURCES ../data/myllmat.llmat) @@ -389,33 +496,83 @@ # MACRO_ARGS 1 mv_flextra_prepare_test01.txt # RESOURCES ../../scripts/mv_flextra_prep.mv # ../data/mv_flextra_prepare_test01.txt) -metview_macro_test(MACRO thermo.mv +metview_macro_test(MACRO thermo_data.mv RESOURCES ../data/thermo_profile.grib - ../data/theta_input_pl.grib - ../data/theta_pl_ref.grib - ../data/theta_ml_ref.grib + ../data/temp_10.bufr ../data/thermo_bufr_ref.nc ../data/temp_wigos.bufr ../data/thermo_bufr_wigos_ref.nc - ../data/thermo_profile.grib ../data/thermo_grib_ref.nc ../data/thermo_grib_area_ref.nc + ../data/thermo_profile_baltic.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_humidity.mv + RESOURCES ../data/thermo_profile.grib + ../data/theta_input_pl.grib ../data/td_2m.grib + ../data/tq_ml137.grib POST_INSTALL) -metview_macro_test(MACRO thermo_parcel.mv +metview_macro_test(MACRO thermo_parcel_grib_amazon_1.mv RESOURCES ../data/thermo_profile.grib - ../data/thermo_profile_east.grib - ../data/thermo_profile_baltic.grib - ../data/thermo_profile_obs.bufr - ../data/thermo_profile_pl_east.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_grib_amazon_2.mv + RESOURCES ../data/thermo_profile.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_grib_cin.mv + RESOURCES ../data/thermo_profile_east.grib ../data/thermo_profile_capping_cin.grib POST_INSTALL) -metview_macro_test(MACRO xsection_ml.mv + +metview_macro_test(MACRO thermo_parcel_grib_himalayas.mv + RESOURCES ../data/thermo_profile_east.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_grib_inversion_warm_sea.mv + RESOURCES ../data/thermo_profile_east.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_grib_inversion_cold.mv + RESOURCES ../data/thermo_profile_east.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_grib_inversion_unstable.mv + RESOURCES ../data/thermo_profile_baltic.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_grib_sahara.mv + RESOURCES ../data/thermo_profile.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_grib_unstable.mv + RESOURCES ../data/thermo_profile_east.grib + ../data/thermo_profile_pl_east.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_grib_warm_atl.mv + RESOURCES ../data/thermo_profile_east.grib + POST_INSTALL) + +metview_macro_test(MACRO thermo_parcel_bufr.mv + RESOURCES ../data/thermo_profile_obs.bufr + POST_INSTALL) + +metview_macro_test(MACRO xsection_ml_scalar.mv RESOURCES ../data/t_lnsp_ml137.grb ../data/t_lnsp_ml137_xs_ref.nc ../data/xs_ml_input.grib + POST_INSTALL) + +metview_macro_test(MACRO xsection_ml_wind.mv + RESOURCES ../data/xs_ml_input.grib + POST_INSTALL) + +metview_macro_test(MACRO xsection_ml_ghbc.mv + RESOURCES ../data/xs_ml_input.grib ../data/xs_tz_ml.grib ../data/xs_ml_ghbc_wind_2d_intensity.nc ../data/xs_ml_ghbc_wind_3d_intensity_1.nc @@ -430,6 +587,18 @@ ../data/xs_ml_ghbc_from_data_extra_constant_ref.nc POST_INSTALL) + +metview_macro_test(MACRO xsection_ml_orog.mv + RESOURCES ../data/t_lnsp_ml137.grb + ../data/t_lnsp_ml137_xs_ref.nc + POST_INSTALL) + + +metview_macro_test(MACRO xsection_ml_curve.mv + RESOURCES ../data/t_lnsp_ml137.grb + ../data/t_lnsp_ml137_xs_ref.nc + POST_INSTALL) + metview_macro_test(MACRO xsection_pl.mv RESOURCES ../data/xs_pl_input.grib ../data/xs_wind_3d_w_default_pl_ref.nc @@ -463,12 +632,28 @@ ../data/hovline_ll_ref_2.nc) metview_macro_test(MACRO hovarea.mv - RESOURCES ../data/t_1000_timeseries.grb) + RESOURCES ../data/t_1000_timeseries.grb + ../data/hovarea_ll_ew_mean_ref.nc + ../data/hovarea_ll_ew_maximum_ref.nc + ../data/hovarea_ll_ew_median_ref.nc + ../data/hovarea_ll_ew_minimum_ref.nc + ../data/hovarea_ll_ew_stdev_ref.nc + ../data/hovarea_ll_ew_variance_ref.nc + ../data/hovarea_ll_ns_mean_ref.nc + ../data/hovarea_ll_ns_maximum_ref.nc + ../data/hovarea_ll_ns_median_ref.nc + ../data/hovarea_ll_ns_minimum_ref.nc + ../data/hovarea_ll_ns_stdev_ref.nc + ../data/hovarea_ll_ns_variance_ref.nc + ) -metview_macro_test(MACRO hovvert.mv +metview_macro_test(MACRO hovvert_pl.mv RESOURCES ../data/t_timeseries.grb - ../data/hov_ml_input.grib ../data/hovvert_pl_ref.nc + ) + +metview_macro_test(MACRO hovvert_ml_to_pl.mv + RESOURCES ../data/hov_ml_input.grib ../data/hovvert_ml_pl_ref.nc ../data/hovvert_ml_pl_fixed_lnsp_ref.nc ../data/hovvert_ml_pl_extra_ref_1.nc @@ -478,13 +663,24 @@ ../data/hovvert_ml_pl_missing_ref_2.nc ../data/hovvert_ml_pl_range_ref.nc ../data/hovvert_ml_pl_subset_ref.nc + ) + +metview_macro_test(MACRO hovvert_ml_to_hl.mv + RESOURCES ../data/hov_ml_input.grib ../data/hovvert_ml_hl_ref.nc ../data/hovvert_ml_hl_extra_ref_1.nc ../data/hovvert_ml_hl_extra_ref_2.nc ../data/hovvert_ml_hl_extra_ref_3.nc) + metview_macro_test(MACRO hovexp.mv - RESOURCES ../data/t_1000_timeseries.grb) + RESOURCES ../data/t_1000_timeseries.grb + ../data/hovexp_area_ref_1.nc + ../data/hovexp_line_ref_1.nc + ../data/hovexp_vert_area.nc + ../data/hovexp_vert_nearest_gridpoint.nc + ../data/hovexp_vert_point.nc + ) metview_macro_test(MACRO memory.mv RESOURCES ../data/t1000_LL_2x2.grb @@ -562,6 +758,23 @@ metview_macro_test(MACRO stvl.mv) endif() +if(ENABLE_FLEXTRA_TEST) + metview_macro_test(MACRO flextra_run.mv) +endif() + +metview_macro_test(MACRO flextra_output.mv + RESOURCES ../data/flextra_res_normal.txt + ../data/flextra_res_multi.txt) + +if(ENABLE_FLEXPART_TEST) + metview_macro_test(MACRO flexpart_run.mv) +endif() + +metview_macro_test(MACRO flexpart_output.mv + RESOURCES ../data/flexpart_conc_fwd.grib + ../data/flexpart_flux_fwd.grib + ../data/flexpart_bwd.grib) + # finish the post-install test script file(APPEND ${POST_INSTALL_TEST_SCRIPT} "\n") file(APPEND ${POST_INSTALL_TEST_SCRIPT} "# if we got this far, then all tests must have succeeded\n") diff -Nru metview-5.17.4/metview/test/macros/fieldset_bitmap.mv metview-5.19.2/metview/test/macros/fieldset_bitmap.mv --- metview-5.17.4/metview/test/macros/fieldset_bitmap.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_bitmap.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,137 @@ +#Metview Macro +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +global fs_22 = read('t1000_LL_2x2.grb') + +test_bitmap() +test_nobitmap() + +function test_bitmap() + fs = fs_22 + + #-- const field + f = fs*0+1 + + # non missing + r = bitmap(f,0) + v = values(r) + v_ref = values(f) + assert(vec_same(v, v_ref,1E-4), "bitmap const",1) + + # all missing + r = bitmap(f,1) + v = values(r) + v_ref = values(f) * vector_missing_value + assert(vec_same_missing(v, v_ref,1E-4), "bitmap const",2) + + #-- non const field + f = fs + + # bitmap with value + f_mask = f > 300 + r = bitmap(f_mask, 1) + v = values(r) + v_ref = values(f_mask) + v_ref = bitmap(v_ref, 1) + assert(vec_same_missing(v, v_ref,1E-4), "bitmap value",1) + + f_mask = f > 300 + r = bitmap(f_mask*2 , 2) + v = values(r) + v_ref = values(f_mask*2) + v_ref = bitmap(v_ref, 2) + assert(vec_same_missing(v, v_ref,1E-4), "bitmap value",1) + + # bitmap with field + r = bitmap( f > 300, 0) + r = bitmap(f, r) + v = values(r) + v_ref = values(f) + v_ref = v_ref * bitmap(v_ref > 300, 0) + assert(vec_same_missing(v, v_ref,1E-4), "bitmap field",2) + + # multiple fields + f = read('monthly_avg.grib') + f = f[1,2] + + # with value + f_mask = f > 300 + r = bitmap(f_mask, 1) + assert(count(r) = count(f), "bitmap multi count", 1) + for i=1 to count(r) do + v = values(r[i]) + v_ref = values(f_mask[i]) + v_ref = bitmap(v_ref, 1) + assert(vec_same_missing(v, v_ref,1E-3), "bitmap multi value",1) + end for + + # with field + r = bitmap( f > 300, 0) + r = bitmap(f, r) + assert(count(r) = count(f), "bitmap multi count", 2) + for i=1 to count(r) do + v = values(r[i]) + v_ref = values(f[i]) + v_ref = v_ref * bitmap(v_ref > 300, 0) + assert(vec_same_missing(v, v_ref,1E-3), "bitmap multi value",2) + end for + +end test_bitmap + + +function test_nobitmap() + + fs = read('t1000_LL_2x2_with_missing.grb') + + # single field + f = fs + r = nobitmap(f,1) + v = values(r) + vf = values(f) + assert_equal(count(r),count(f), "nobitmap count",1) + assert_equal(count(v),count(vf), "nobitmap value_count",1) + + for i=1 to count(v) do + + if vf[i] = vector_missing_value then + assert_equal(v[i],1,"nobitmap value [" & i & "]",1) + else + assert_equal(v[i],vf[i],"nobitmap value [" & i & "]",1) + end if + end for + + # multiple fields + f = fs & 2*fs + r = nobitmap(f,1) + assert_equal(count(r),count(f), "nobitmap count",2) + + for k=1 to count(r) do + v = values(r[k]) + vf = values(f[k]) + + assert_equal(count(v),count(vf), "nobitmap value_count f" & k,2) + + for i=1 to count(v) do + if vf[i] = vector_missing_value then + assert_equal(v[i],1,"nobitmap value f" & k & " [" & i & "]",2) + else + assert_equal(v[i],vf[i],"nobitmap value f" & k & " [" & i & "]",2) + end if + end for + end for + +end test_nobitmap diff -Nru metview-5.17.4/metview/test/macros/fieldset_compute.mv metview-5.19.2/metview/test/macros/fieldset_compute.mv --- metview-5.17.4/metview/test/macros/fieldset_compute.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_compute.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,218 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_absolute_vorticity() +test_direction() +test_speed() +test_xy_from_polar() + +function test_absolute_vorticity() + f = read("abs_vort.grib") + vo = f[1] + absv_ref = f[2] + absv = absolute_vorticity(vo) + assert_equal(count(absv), 1, "absolute_vorticity count",1) + + id = grib_get_long(absv,"paramId") + assert_equal(id,3041,"absolute_vorticity paramId",1) + gpId = grib_get_long(absv,"generatingProcessIdentifier") + assert_equal(gpId,128,"absolute_vorticity gpId",1) + + assert(vec_same(values(absv), values(absv_ref),1E-8),"absolute_vorticity values") +end test_absolute_vorticity + +function test_direction() + fs = read("tuv_pl.grib") + u = read(data: fs, param: "u") + v = read(data: fs, param: "v") + + u_val = values(u[1]) + v_val = values(v[1]) + u_val_test = |0, 1, 1, 1, 0, -1, -1, -1, 0| + v_val_test = |1, 1, 0, -1, -1, -1, 0, 1, 0| + d_ref_test = |180, 225, 270, 315, 0, 45, 90, 135, 0| + + for i=1 to count(u_val_test) do + u_val[i] = u_val_test[i] + v_val[i] = v_val_test[i] + end for + + u_t = set_values(u[1], u_val) + v_t = set_values(v[1], v_val) + + u_t = u_t & u_t + v_t = v_t & v_t + + d = direction(u_t, v_t) + assert(count(d) = 2, "direction_count", 1) + for i=1 to count(d) do + d_val = values(d[i])[1, count(d_ref_test)] + assert(vec_same(d_val, d_ref_test, 0.000001), "direction " & i) + param_id = grib_get_long(d[i], "paramId") + assert_equal(3031, param_id, "direction - paramId " & i) + end for + + # check value range + min_d = minvalue(d[1]) + assert(min_d >=0 and min_d <= 360,"direction min",1) + max_d = maxvalue(d[1]) + assert(max_d >=0 and max_d <= 360,"direction max",1) + + # test missing values + u_t = bitmap(u_t[1], bitmap(u_t[1] > 0.9, 1)) + v_t = bitmap(v_t[1], bitmap(v_t[1] < -0.9, 1)) + d = direction(u_t, v_t) + assert(count(d) = 1, "direction_count bitmap") + d_val = values(d)[1, count(d_ref_test)] + d_ref_test = |180,vector_missing_value,vector_missing_value,vector_missing_value,vector_missing_value,vector_missing_value,90,135,0| + assert(vec_same_missing(d_val, d_ref_test, 0.000001), "direction bitmap" ) + assert_equal(3031, grib_get_long(d[1], 'paramId'), "direction - bitmap paramId") + +end test_direction + +function test_speed() + fs = read("tuv_pl.grib") + u = read(data: fs, param: "u") + v = read(data: fs, param: "v") + + u_val = values(u[1]) + v_val = values(v[1]) + u_val_test = |0, 1, 1, 1, 3, -1, -1, -1, 0| + v_val_test = |1, 1, 0, -1, 4, -1, 0, 1, 0| + d_ref_test = |1, 1.414, 1, 1.414, 5, 1.414, 1, 1.414, 0| + + for i=1 to count(u_val_test) do + u_val[i] = u_val_test[i] + v_val[i] = v_val_test[i] + end for + + u_t = set_values(u[1], u_val) + v_t = set_values(v[1], v_val) + + u_t = u_t & u_t + v_t = v_t & v_t + + d = speed(u_t, v_t) + assert(count(d) = 2, "speed_count", 1) + for i=1 to count(d) do + d_val = values(d[i])[1, count(d_ref_test)] + assert(vec_same(d_val, d_ref_test, 0.0005), "speed " & i) + assert(grib_get_long(d[i], "paramId")=10, "speed paramId") + end for + + + # test missing values + u_t = bitmap(u_t[1], bitmap(u_t[1] > 0.9, 1)) + v_t = bitmap(v_t[1], bitmap(v_t[1] < -0.9, 1)) + d = speed(u_t, v_t) + assert(count(d) = 1, "speed_count bitmap") + assert(grib_get_long(d, "paramId")=10, "speed paramId bitmap") + d_val = values(d)[1, count(d_ref_test)] + d_ref_test = |1,vector_missing_value,vector_missing_value,vector_missing_value,vector_missing_value,vector_missing_value,1,1.414,0| + assert(vec_same_missing(d_val, d_ref_test, 0.0005), "speed bitmap" ) + + + # the whole field + u_val = values(u[1]) + v_val = values(v[1]) + spd_ref_vals = sqrt((u_val*u_val) + (v_val*v_val)) + spd_test_vals = values(speed(u[1], v[1])) + assert(vec_same_missing(spd_test_vals, spd_ref_vals, 0.00005), "speed field" ) + + + # multi-fields + spd_test_vals = values(speed(u, v)) + for i = 1 to count(u) do + u_val = values(u[i]) + v_val = values(v[i]) + spd_ref_vals = sqrt((u_val*u_val) + (v_val*v_val)) + assert(vec_same_missing(spd_test_vals[i], spd_ref_vals, 0.00005), "speed field i" ) + end for + + # resulting paramids from surface winds + # note about 200U/200V - the test was failing on lxg because it has old MARS config files + # therefore we use the paramIds for those: 228239/228240==200U/200V + uv_s = read("surface_wind.grib") + s100 = speed(read(data:uv_s, param:"100U"), read(data:uv_s, param:"100V")) + assert(grib_get_long(s100, "paramId")=228249, "speed paramId s100") + s200 = speed(read(data:uv_s, param:228239), read(data:uv_s, param:228240)) # 200U/200V + assert(grib_get_long(s200, "paramId")=228241, "speed paramId s200") + s10 = speed(read(data:uv_s, param:"10U"), read(data:uv_s, param:"10V")) + assert(grib_get_long(s10, "paramId")=207, "speed paramId s10") + +end test_speed + +function test_xy_from_polar() + + fn_name = "xy_from_polar" + + sqr2 = sqrt(2)/2 + sqr3 = sqrt(3)/2 + + # values + sp = | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10| + d = |0, 45, 90, 135, 180, 225, 270, 315, 360, 30| + u = |0, -sqr2*2, -3, -sqr2*4, 0, sqr2*6, 7, sqr2*8, 0, -0.5*10| + v = |-1,-sqr2*2, 0, sqr2*4, 5, sqr2*6, 0, -sqr2*8, -9, -sqr3*10| + + for i=1 to count(sp) do + r = xy_from_polar(sp[i], d[i]) + assert_equal(count(r),2, fn_name & " len [" & i & "]", 1) + assert_equal(r[1],u[i], fn_name & " u [" & i & "]", 1) + assert_equal(r[2],v[i], fn_name & " v [" & i & "]", 1) + end for + + # vectors + r = xy_from_polar(sp, d) + assert_equal(count(r),2, fn_name & " len [" & i & "]", 2) + assert(vec_same(r[1],u), fn_name & " u [" & i & "]", 2) + assert(vec_same(r[2],v), fn_name & " v [" & i & "]", 2) + + # fieldset + fs = read("tuv_pl.grib") + f_sp = read(data: fs, param: "u", levelist: 500) + f_d = read(data: fs, param: "v", levelist: 500) + f_sp = grib_set_long(f_sp, ["paramId",10]) + + # write the input sp and d test values into the beginning of the fields + sp_val = values(f_sp) + d_val = values(f_d) + for i=1 to count(sp) do + sp_val[i] = sp[i] + d_val[i] = d[i] + end for + f_sp = set_values(f_sp, sp_val) + f_d = set_values(f_d, d_val) + + f_sp = f_sp & f_sp + f_d = f_d & f_d + + # we will only check the first count(sp) values + r = xy_from_polar(f_sp, f_d) + assert_equal(count(r), 4, fn_name & " field count", 3) + for i=1 to count(r) by 2 do + r_val = values(r[i])[1, count(sp)] + assert(vec_same(r_val, u, 1E-5), fn_name & " u [" & i & "]", 3) + assert_equal(grib_get_long(r[i], "paramId"), 131, fn_name & " u paramid [" & i & "]", 3) + end for + + for i=2 to count(r) by 2 do + r_val = values(r[i])[1, count(sp)] + assert(vec_same(r_val, v, 1E-5), fn_name & " v [" & i & "]", 3) + assert_equal(grib_get_long(r[i], "paramId"), 132, fn_name & " v paramid [" & i & "]", 3) + end for + +end test_xy_from_polar diff -Nru metview-5.17.4/metview/test/macros/fieldset_geo.mv metview-5.19.2/metview/test/macros/fieldset_geo.mv --- metview-5.17.4/metview/test/macros/fieldset_geo.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_geo.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,588 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +global fs_22 = read('t1000_LL_2x2.grb') +global fs_77 = read('t1000_LL_7x7.grb') + +test_bearing() +test_bounding_box() +test_coslat() +test_distance() +test_latitudes() +test_longitudes() +test_mask() +test_mask_missing() +test_rmask() +test_rmask_missing() +test_sinlat() +test_solar_zenith_angle() +test_tanlat() + + +function test_bearing() + fs = fs_22 + lat_ref = 46 + lon_ref = 20 + b = bearing(fs[1],lat_ref,lon_ref) + + eps =1E-4 + assert_equal(nearest_gridpoint(b,[50,20]),0,"bearing_basic",1) + assert_equal(nearest_gridpoint(b,[46,24]),90,"bearing_basic",2) + assert_equal(nearest_gridpoint(b,[40,20]),180,"bearing_basic",3) + assert_equal(nearest_gridpoint(b,[46,16]),270,"bearing_basic",4) + assert_equal(nearest_gridpoint(b,[46,-80]),270,"bearing_basic",5) + assert_equal(nearest_gridpoint(b,[46,100]),90,"bearing_basic",6) + assert_equal(nearest_gridpoint(b,[-40,20]),180,"bearing_basic",7) + assert_equal(nearest_gridpoint(b,[80,20]),0,"bearing_basic",8) + assert(nearest_gridpoint(b,[46,20]) = nil,"bearing_basic_9") + + assert_equal(nearest_gridpoint(b,[50,22]),19.092956543,"bearing",1) + assert_equal(nearest_gridpoint(b,[50,18]),340.907043457,"bearing",2) + assert_equal(nearest_gridpoint(b,[40,18]),193.098327637,"bearing",3) + assert_equal(nearest_gridpoint(b,[40,22]),166.901672363,"bearing",4) + + b = bearing(fs[1],[lat_ref,lon_ref]) # coords as list + assert_equal(nearest_gridpoint(b,[50,20]),0,"bearing_basic_l",1) + assert_equal(nearest_gridpoint(b,[46,24]),90,"bearing_basic_l",2) +end test_bearing + +function test_bounding_box() + fn_name = "test_bounding_box" + + # lam + fs = read("fc_data.grib") + v = bounding_box(fs) + v_ref = [|70,10,80,20|,|70,10,80,20|,|70,10,80,20|,|70,10,80,20|] + assert(count(v) = count(v_ref), fn_name & " count", 1) + for i=1 to count(v_ref) do + assert(vec_same(v[i], v_ref[i],1E-4), fn_name & " vals-" & i,1) + end for + + # global + fs = fs_22 + v = bounding_box(fs) + v_ref = |-90,-180,90,180| + assert(count(v) = count(v_ref), fn_name & " count", 2) + assert(vec_same(v, v_ref,1E-4), fn_name & " vals",2) + + # regular Gaussian global + fs = read("t1000_reg_gg_N48.grib") + v = bounding_box(fs) + v_ref = |-90,-180,90,180| + assert(count(v) = count(v_ref), fn_name & " count", 3) + assert(vec_same(v, v_ref,1E-4), fn_name & " vals",3) + + # regular Gaussian subarea + fs = read("regular_gaussian_subarea.grib") + v = bounding_box(fs) + v_ref = |15.0351,-101.25,56.9086,-38.812| + assert(count(v) = count(v_ref), fn_name & " count", 4) + assert(vec_same(v, v_ref,1E-4), fn_name & " vals",4) + + # reduced Gaussian global + fs = read("t1000_red_gg_N48.grib") + v = bounding_box(fs) + v_ref = |-90,-180,90,180| + assert(count(v) = count(v_ref), fn_name & " count", 5) + assert(vec_same(v, v_ref,1E-4), fn_name & " vals",5) + + # reduced Gaussian subarea + fs = read("rgg_small_subarea.grib") + v = bounding_box(fs) + v_ref = |84.8155,36.233,89.8765,46.185| + assert(count(v) = count(v_ref), fn_name & " count", 6) + assert(vec_same(v, v_ref,1E-4), fn_name & " vals",6) + + fs = read("rgg_western_subarea.grib") + v = bounding_box(fs) + v_ref = |-9.97658,-80,11.9438,-70| + assert(count(v) = count(v_ref), fn_name & " count", 7) + assert(vec_same(v, v_ref,1E-4), fn_name & " vals",7) + + # reduced latlon + fs = read("reduced_ll.grib") + v = bounding_box(fs) + v_ref = |-90,-180,90,180| + assert(count(v) = count(v_ref), fn_name & " count", 8) + assert(vec_same(v, v_ref,1E-4), fn_name & " vals",8) + + # ll dateline + fs = read("ll_dateline.grib") + v = bounding_box(fs) + v_ref = |-90,120,90,240| + assert(count(v) = count(v_ref), fn_name & " count", 9) + assert(vec_same(v, v_ref,1E-4), fn_name & " vals",9) + +end test_bounding_box + +function test_coslat() + fs = fs_22 + v = values(coslat(fs)) + v_ref = cos(pi * latitudes(fs) / 180.) + assert(vec_same(v, v_ref), "coslat", 1) +end test_coslat + +function test_distance() + fs = fs_22 + eps =1E-4 + + lat_ref = 0 + lon_ref = 0 + b = distance(fs[1],lat_ref,lon_ref) + assert_equal(nearest_gridpoint(b,[0,0]),0,"distance_eq",1) + assert_equal(nearest_gridpoint(b,[0,90]),10000800,"distance_eq",2) + assert_equal(nearest_gridpoint(b,[0,-90]),10000800,"distance_eq",3) + assert_equal(nearest_gridpoint(b,[0,180]),2*10000800,"distance_eq",4) + assert_equal(nearest_gridpoint(b,[90,0]),10000800,"distance_eq",5) + assert_equal(nearest_gridpoint(b,[-90,0]),10000800,"distance_eq",6) + assert_equal(nearest_gridpoint(b,[48,20]),5671570,"distance_eq",7) + assert_equal(nearest_gridpoint(b,[48,-20]),5671570,"distance_eq",8) + assert_equal(nearest_gridpoint(b,[-48,-20]),5671570,"distance_eq",9) + assert_equal(nearest_gridpoint(b,[-48,20]),5671570,"distance_eq",10) + + lat_ref = 90 + lon_ref = 0 + b = distance(fs[1],lat_ref,lon_ref) + assert_equal(nearest_gridpoint(b,[0,0]),10000800,"distance_np",1) + assert_equal(nearest_gridpoint(b,[0,90]),10000800,"distance_np",2) + assert_equal(nearest_gridpoint(b,[0,-90]),10000800,"distance_np",3) + assert_equal(nearest_gridpoint(b,[0,180]),10000800,"distance_np",4) + assert_equal(nearest_gridpoint(b,[90,0]),0,"distance_np",5) + assert_equal(nearest_gridpoint(b,[-90,0]),2*10000800,"distance_np",6) + assert_equal(nearest_gridpoint(b,[48,20]),4667040,"distance_np",7) + assert_equal(nearest_gridpoint(b,[48,-20]),4667040,"distance_np",8) + assert_equal(nearest_gridpoint(b,[-48,-20]),15334560,"distance_np",9) + assert_equal(nearest_gridpoint(b,[-48,20]),15334560,"distance_np",10) + + lat_ref = -90 + lon_ref = 0 + b = distance(fs[1],lat_ref,lon_ref) + assert_equal(nearest_gridpoint(b,[0,0]),10000800,"distance_sp",1) + assert_equal(nearest_gridpoint(b,[0,90]),10000800,"distance_sp",2) + assert_equal(nearest_gridpoint(b,[0,-90]),10000800,"distance_sp",3) + assert_equal(nearest_gridpoint(b,[0,180]),10000800,"distance_sp",4) + assert_equal(nearest_gridpoint(b,[90,0]),2*10000800,"distance_sp",5) + assert_equal(nearest_gridpoint(b,[-90,0]),0,"distance_sp",6) + assert_equal(nearest_gridpoint(b,[48,20]),15334560,"distance_sp",7) + assert_equal(nearest_gridpoint(b,[48,-20]),15334560,"distance_sp",8) + assert_equal(nearest_gridpoint(b,[-48,-20]),4667040,"distance_sp",9) + assert_equal(nearest_gridpoint(b,[-48,20]),4667040,"distance_sp",10) + + lat_ref = 48 + lon_ref = 20 + b = distance(fs[1],lat_ref,lon_ref) + assert_equal(nearest_gridpoint(b,[0,0]),5671570,"distance_hu",1) + assert_equal(nearest_gridpoint(b,[0,90]),8530712,"distance_hu",2) + assert_equal(nearest_gridpoint(b,[0,-90]),11470888,"distance_hu",3) + assert_equal(nearest_gridpoint(b,[0,180]),14330030,"distance_hu",4) + assert_equal(nearest_gridpoint(b,[90,0]),4667040,"distance_hu",5) + assert_equal(nearest_gridpoint(b,[-90,0]),15334560,"distance_hu",6) + assert_equal(nearest_gridpoint(b,[48,20]),0,"distance_hu",7) + assert_equal(nearest_gridpoint(b,[48,-20]),2940176,"distance_hu",8) + assert_equal(nearest_gridpoint(b,[-48,-20]),11343140,"distance_hu",9) + assert_equal(nearest_gridpoint(b,[-48,20]),10667520,"distance_hu",10) + + + b = distance(fs[1],[lat_ref,lon_ref]) # target as list + assert_equal(nearest_gridpoint(b,[0,0]),5671570,"distance_hu_l",1) + assert_equal(nearest_gridpoint(b,[0,90]),8530712,"distance_hu_l",2) + assert_equal(nearest_gridpoint(b,[0,-90]),11470888,"distance_hu_l",3) + assert_equal(nearest_gridpoint(b,[0,180]),14330030,"distance_hu_l",4) + assert_equal(nearest_gridpoint(b,[90,0]),4667040,"distance_hu_l",5) + assert_equal(nearest_gridpoint(b,[-90,0]),15334560,"distance_hu_l",6) + assert_equal(nearest_gridpoint(b,[48,20]),0,"distance_hu_l",7) + assert_equal(nearest_gridpoint(b,[48,-20]),2940176,"distance_hu_l",8) + assert_equal(nearest_gridpoint(b,[-48,-20]),11343140,"distance_hu_l",9) + assert_equal(nearest_gridpoint(b,[-48,20]),10667520,"distance_hu_l",10) + +end test_distance + +function test_latitudes() + + fs = fs_22 + + v = latitudes(fs) + assert_equal(count(v),16380,"latitudes_count",1) + assert_equal(v[1],90,"latitudes_1",1) + assert_equal(v[2],90,"latitudes_2",1) + assert_equal(v[8104],0,"latitudes_3",1) + assert_equal(v[11336],-34,"latitudes_4",1) + assert_equal(v[16380],-90,"latitudes_5",1) + + fs = fs_22 & fs_22 + lst = latitudes(fs) + assert_equal(count(lst),2,"latitudes_list_count",2) + for i=1 to count(lst) do + v = lst[i] + assert_equal(count(v),16380,"latitudes_count",1+i) + assert_equal(v[1],90,"latitudes_1",1+i) + assert_equal(v[2],90,"latitudes_2",1+i) + assert_equal(v[8104],0,"latitudes_3",1+i) + assert_equal(v[11336],-34,"latitudes_4",1+i) + assert_equal(v[16380],-90,"latitudes_5",1+i) + end for + +end test_latitudes + +function test_longitudes() + + fs = fs_22 + + v = longitudes(fs) + assert_equal(count(v),16380,"longitudes_count",1) + assert_equal(v[1],0,"longitudes_1",1) + assert_equal(v[2],2,"longitudes_2",1) + assert_equal(v[8104],6,"longitudes_3",1) + assert_equal(v[11336],350,"longitudes_4",1) + assert_equal(v[16380],358,"longitudes_5",1) + + fs = fs_22 & fs_22 + lst = longitudes(fs) + assert_equal(count(lst),2,"longitudes_list_count",2) + for i=1 to count(lst) do + v = lst[i] + assert_equal(count(v),16380,"longitudes_count",1+i) + assert_equal(v[1],0,"longitudes_1",1+i) + assert_equal(v[2],2,"longitudes_2",1+i) + assert_equal(v[8104],6,"longitudes_3",1+i) + assert_equal(v[11336],350,"longitudes_4",1+i) + assert_equal(v[16380],358,"longitudes_5",1+i) + end for + +end test_longitudes + +function test_mask() + + fs = fs_22 + + # global area + area = [90,-180,-90,180] + + r = mask(fs,area) + v = values(r) + v_ref = values(fs)*0+1 + assert(vec_same(v, v_ref,1E-4), "mask global",1) + + # limited area + area = [80,-100,-60, 80] + + r = mask(fs,area) + v = values(r) + + # build ref + lat = latitudes(fs) + lon = longitudes(fs) + v_ref = values(fs)*0 + for i=1 to count(lat) do + + if lon[i] > 180 then + lon[i] = lon [i] - 360 + end if + + if lat[i] <= area[1] and lat[i] >= area[3] and + lon[i] <= area[4] and lon[i] >= area[2] then + v_ref[i] = 1 + end if + end for + + assert(vec_same(v, v_ref,1E-4), "mask lam",1) + + + r = mask(fs,80,-100,-60,80) # same as above, but area as numbers + v = values(r) + assert(vec_same(v, v_ref,1E-4), "mask lam_area_as_nums",1) + + + r = mask(fs,80,-100,-60,80, 'missing', 'off') # same as above, but Pythonesque way missing=False + v = values(r) + assert(vec_same(v, v_ref,1E-4), "mask lam_area_as_nums_py",1) + + + # multiple fields - limited area + f = fs & 2*fs + + r = mask(f, area) + assert(count(r) = count(f), "mask multi count", 1) + # v_ref is the same as before + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref,1E-3), "mask multi value",1) + end for + + # area that straddles the date line + area = [50,150,30,-130] + r = mask(fs,area) + ones = find(r, 1) + assert(list_same(ones[1], [50, 150]), "mask dateline first 1") + assert(list_same(ones[count(ones)], [30, 230]), "mask dateline last 1") + assert_equal(count(ones), 451, "mask dateline count") + +end test_mask + +function test_mask_missing() + + fs = fs_22 + + # global area + area = [90,-180,-90,180] + + r = mask(fs,area,'missing') + v = values(r) + v_ref = values(fs) + assert(vec_same(v, v_ref,1E-4), "mask_missing global",1) + + # limited area + area = [80,-100,-60, 80] + + r = mask(fs,area,'missing') + v = values(r) + + # build ref + lat = latitudes(fs) + lon = longitudes(fs) + src_vals = values(fs) + v_ref = src_vals + vector_missing_value + for i=1 to count(lat) do + + if lon[i] > 180 then + lon[i] = lon [i] - 360 + end if + + if lat[i] <= area[1] and lat[i] >= area[3] and + lon[i] <= area[4] and lon[i] >= area[2] then + v_ref[i] = src_vals[i] + end if + end for + + assert(vec_same(v, v_ref,1E-4), "mask_missing lam",1) + + + r = mask(fs,80,-100,-60,80,'missing') # same as above, but area as numbers + v = values(r) + assert(vec_same(v, v_ref,1E-4), "mask_missing lam_area_as_nums",1) + + r = mask(fs,80,-100,-60,80,'missing', 'on') # same as above, but Pythonesque missing=True + v = values(r) + assert(vec_same(v, v_ref,1E-4), "mask_missing lam_area_as_nums_py",1) + + # multiple fields - limited area + f = fs & 2*fs + + r = mask(f, area, 'missing') + assert(count(r) = count(f), "mask_missing multi count", 1) + # v_ref is the same as before + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref*i,1E-3), "mask_missing multi value",1) + end for + +end test_mask_missing + +function test_rmask() + fs = fs_22 + f_ref = read('rmask_ref.grib') + + lat_c = [48, -40, 90] + lon_c = [19,-60, 0] + rad = [1000000, 7000000, 6000000] + + for i=1 to count(f_ref) do + r = rmask(fs, lat_c[i], lon_c[i], rad[i]) + v = values(r) + v_ref = values(f_ref[i]) + assert(vec_same(v,v_ref),"rmask",i) + end for + + # list as argument + r = rmask(fs, [lat_c[1], lon_c[1], rad[1]]) + v = values(r) + v_ref = values(f_ref[1]) + assert(vec_same(v,v_ref),"rmask",4) + + # same, but Pythonesque way of supplying missing=False + r = rmask(fs, [lat_c[1], lon_c[1], rad[1]], 'missing', 'off') + v = values(r) + v_ref = values(f_ref[1]) + assert(vec_same(v,v_ref),"rmask_py",1) + +end test_rmask + +function test_rmask_missing() + fs = fs_22 + f_ref = read('rmask_ref.grib') + f_ref = bitmap(f_ref, bitmap(f_ref, 0)) + + lat_c = [48, -40, 90] + lon_c = [19,-60, 0] + rad = [1000000, 7000000, 6000000] + + for i=1 to count(f_ref) do + r = rmask(fs, lat_c[i], lon_c[i], rad[i], 'missing') + v = values(r) + v_ref = values(f_ref[i])-1 + values(fs) + assert(vec_same(v,v_ref),"rmask_missing",i) + end for + + # list as argument + r = rmask(fs, [lat_c[1], lon_c[1], rad[1]], 'missing') + v = values(r) + v_ref = values(f_ref[1])-1 + values(fs) + assert(vec_same(v,v_ref),"rmask_missing",4) + + # same, but Pythonesque way of supplying 'missing' + r = rmask(fs, [lat_c[1], lon_c[1], rad[1]], 'missing', 'on') + v = values(r) + v_ref = values(f_ref[1])-1 + values(fs) + assert(vec_same(v,v_ref),"rmask_missing_py",1) + +end test_rmask_missing + +function test_sinlat() + fs = fs_77 + eps = 1E-6 + v = values(sinlat(fs)) + v_ref = sin(pi * latitudes(fs) / 180.) + assert(vec_same(v, v_ref, eps), "sinlat", 1) +end test_sinlat + +function test_tanlat() + fs = fs_77 + eps = 1E-6 + v = values(tanlat(fs)) + lats = latitudes(fs) + lats = lats + bitmap(abs(lats) > 90-1E-7, 1) + v_ref = tan(pi * lats / 180.) + assert(vec_same_missing(v, v_ref, eps), "tanlat", 1) +end test_tanlat + +function test_solar_zenith_angle() + fn_name = "solar_zenith_angle" + + fs = read("solar_zenith_angle.grib") + f_in = fs[1,6] + f_ref = fs[7,12] + + r = solar_zenith_angle(f_in) + + # fs =0 + # write("solar_zenith_angle.grib", f_in, r) + assert_equal(count(r),count(f_ref),fn_name & " count",1) + for i=1 to count(r) do + v = values(r[i]) + v_ref = values(f_ref[i]) + assert(vec_same(v, v_ref, 1E-6), fn_name & " value-" & i, 1) + end for + + # some obvious cases + + # get data on 0.5x0.5 grid + hr = read(data: f_in[1], grid:[0.5, 0.5]) + lat = |0,23.5,-23.5| + lon = |0,0,0| + + # spring equinox + ft = grib_set(hr, ["dataDate", 20180321, "dataTime",0, "step", 12]) + r = solar_zenith_angle(ft) + v_ref = |0.0301904268563, 23.4698113985, 23.5301904269| + v = nearest_gridpoint(r, lat, lon) + assert(vec_same(v, v_ref, 1E-5), fn_name & " spring", 2) + + # summer solstice + ft = grib_set(hr, ["dataDate", 20180621, "dataTime",0, "step", 12]) + r = solar_zenith_angle(ft) + v_ref = |23.4382684194, 0.0617272816598, 46.9382684194| + v = nearest_gridpoint(r, lat, lon) + assert(vec_same(v, v_ref, 1E-5), fn_name & " summer", 2) + + # autumn equinox + ft = grib_set(hr, ["dataDate", 20180923, "dataTime",0, "step", 12]) + r = solar_zenith_angle(ft) + v_ref = |0.133450090885,23.3665433526,23.6334500909| + v = nearest_gridpoint(r, lat, lon) + assert(vec_same(v, v_ref, 1E-5), fn_name & " autumn", 2) + + # winter solstice + ft = grib_set(hr, ["dataDate", 20181221, "dataTime",0, "step", 12]) + r = solar_zenith_angle(ft) + v_ref = |23.4350353479, 46.9350353479, 0.0649639368057| + v = nearest_gridpoint(r, lat, lon) + assert(vec_same(v, v_ref, 1E-5), fn_name & " winter", 2) + + # test cosine option + r = solar_zenith_angle(ft, to_cosine:"on") + v_ref = cos(v_ref * acos(-1)/180) + v = nearest_gridpoint(r, lat, lon) + assert(vec_same(v, v_ref, 1E-5), fn_name & " cosine", 3) + + assert_equal(grib_get_long(r, "paramId"), 214001, + fn_name & " cosine paramId", 3) + +end test_solar_zenith_angle + + +#---------------------------- + +function step_equal(fs:fieldset, refstep:number) + s = grib_get_long(fs, 'step') + return (s = refstep) +end steps_equal + +function steps_equal(fs:fieldset, refsteps:list) + s = grib_get_long(fs, 'step') + return is_equal_any(s, refsteps) +end steps_equal + +function levels_equal(fs:fieldset, reflevs:list) + s = grib_get_long(fs, 'level') + eq = is_equal_any(s, reflevs) + if not eq then + print('levels not equal: ', s, ' vs ref ', reflevs) + end if + return eq +end levels_equal + +function params_equal(fs:fieldset, refparams:list) + s = grib_get_string(fs, 'shortName') + return is_equal_any(s, refparams) +end params_equal + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function generate_test_rmask_reference() + fs = fs_22 + + lat_c = 48 + lon_c = 19 + rad = 1000000 + r1 = rmask(fs, lat_c, lon_c, rad) + + lat_c = -40 + lon_c = -60 + rad = 7000000 + r2 = rmask(fs, lat_c, lon_c, rad) + + lat_c = 90 + lon_c = 0 + rad = 6000000 + r3 = rmask(fs, lat_c, lon_c, rad) + + #write('rmask_ref.grib',r1 & r2 & r3) + +end generate_test_rmask_reference diff -Nru metview-5.17.4/metview/test/macros/fieldset_maths.mv metview-5.19.2/metview/test/macros/fieldset_maths.mv --- metview-5.17.4/metview/test/macros/fieldset_maths.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_maths.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,176 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +global fs_22 = read('t1000_LL_2x2.grb') +global fs_77 = read('t1000_LL_7x7.grb') + +# maths operators +test_abs(fs_22) +test_cos(fs_22) +test_count(fs_22) +test_exp(fs_22) +test_float(fs_22) +test_int(fs_22) +test_log(fs_22) +test_log10(fs_22) +test_neg(fs_22) +test_sgn(fs_22) +test_sin(fs_22) +test_sqrt(fs_22) +test_tan(fs_22) + +test_div() +test_mod() + +function test_abs(fs) + v = values(abs(fs)) + v_ref = abs(values(fs)) + assert(vec_same(v, v_ref), "abs", 1) +end test_abs + +function test_cos(fs) + v = values(cos(fs)) + v_ref = cos(values(fs)) + assert(vec_same(v, v_ref), "cos", 1) +end test_cos + +function test_count(fs) + assert(count(fs) = 1, "count", 1) +end test_count + +function test_exp(fs) + f = fs / maxvalue(fs) # scales between [0,1] + v = values(exp(f)) + v_ref = exp(values(f)) + assert(vec_same(v, v_ref), "exp", 1) +end test_exp + +function test_float(fs) + f = fs * 0 + 2 + v = values(float(f)) + v_ref = vector(count(v)) + 2 + assert(vec_same(v, v_ref), "float", 1) +end test_float + +function test_int(fs) + v = values(int(fs)) + v_ref = int(values(fs)) + assert(vec_same(v, v_ref), "int", 1) +end test_int + +function test_log(fs) + v = values(log(fs)) + v_ref = log(values(fs)) + assert(vec_same(v, v_ref), "log", 1) +end test_log + +function test_log10(fs) + v = values(log10(fs)) + v_ref = log10(values(fs)) + assert(vec_same(v, v_ref), "log10", 1) +end test_log10 + +function test_neg(fs) + v = values(neg(fs)) + v_ref = neg(values(fs)) + assert(vec_same(v, v_ref), "neg", 1) +end test_neg + +function test_sgn(fs) + v = values(sgn(fs)) + v_ref = sgn(values(fs)) + assert(vec_same(v, v_ref), "sgn", 1) +end test_sgn + +function test_sin(fs) + v = values(sin(fs)) + v_ref = sin(values(fs)) + assert(vec_same(v, v_ref), "sin") +end test_sin + + +function test_sqrt(fs) + f = abs(fs) + v = values(sqrt(f)) + v_ref = sqrt(values(f)) + assert(vec_same(v, v_ref, 0.000001), "sqrt") +end test_sqrt + +function test_tan(fs) + v = values(tan(fs)) + v_ref = tan(values(fs)) + assert(vec_same(v, v_ref, 0.00010), "tan") +end test_tan + + +function test_div() + fs = fs_77 + + d = div(fs,fs) + v = values(d) + v_ref = v*0 + 1 + assert(vec_same(v,v_ref),"div",1) + + d = div(fs,2*fs) + v = values(d) + v_ref = v*0 + assert(vec_same(v,v_ref),"div",2) + + f = fs * 0.2 * coslat(fs) + 10 + d = div(fs,f) + v = values(d) + v_ref = div(values(fs),values(f)) + assert(vec_same(v,v_ref),"div",3) + + # here we need to use bitmap to avoid divison by 0 + f = fs * 0.2 * coslat(fs) + f = bitmap(f,bitmap(abs(f) < 1E-14 ,1)) + d = div(fs,f) + v = values(d) + v_ref = div(values(fs),values(f)) + assert(vec_same(v,v_ref),"div",4) + +end test_div + + +function test_mod() + fs = fs_77 + + d = mod(fs,fs) + v = values(d) + v_ref = v*0 + assert(vec_same(v,v_ref),"mod",1) + + d = div(3*fs,2*fs) + v = values(d) + v_ref = v*1 + assert(vec_same(v,v_ref),"mod",2) + + f = fs * 0.2 * coslat(fs) + 10 + d = div(fs,f) + v = values(d) + v_ref = div(values(fs),values(f)) + assert(vec_same(v,v_ref),"mod",3) + + # here we need to use bitmap to avoid divison by 0 + f = fs * 0.2 * coslat(fs) + f = bitmap(f,bitmap(abs(f) < 1E-14 ,1)) + d = div(fs,f) + v = values(d) + v_ref = div(values(fs),values(f)) + assert(vec_same(v,v_ref),"mod",4) + +end test_mod diff -Nru metview-5.17.4/metview/test/macros/fieldset_read_sort.mv metview-5.19.2/metview/test/macros/fieldset_read_sort.mv --- metview-5.17.4/metview/test/macros/fieldset_read_sort.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_read_sort.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,77 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_read_sort() + +function test_read_sort() + + fn_name = "read_sort" + + # 1. date and time + a_dates = [402, 401, 310, 310, 304, 513, 520, 405, 311, 501, 501] + b_dates = [304, 310, 310, 311, 401, 402, 405, 501, 501, 513, 520] + b_times = [600, 600, 1800, 600, 600, 600, 600, 600, 1800, 1800, 1800] + + a = read('daily_clims.grib') + assert_equal(grib_get_long(a, 'date'), a_dates, fn_name & " date ori", 1) + b = read(data:a, order:'sorted') + assert_equal(grib_get_long(b, 'date'), b_dates, fn_name & " date sorted", 1) + assert_equal(grib_get_long(b, 'time'), b_times, fn_name & " time sorted", 1) + + # 2. step - sorted initial state + f = read(source: "ll_steps_168.grib") + ref = [0,12,24,36,48,60,72,84,96,108,120,132,144,156,168] + assert_equal(grib_get_long(f, "step"), ref, fn_name & " step ori", 2) + + f = read(source: "ll_steps_168.grib", order: "sorted") + assert_equal(grib_get_long(f, "step"), ref, fn_name & " step sorted", 2) + + # 3. step - unsorted initial state + f = read(source: "ll_steps_168.grib") + ref_unsorted = [36,108,12,24,0,48,60,72,84,96,120,132,144,156,168] + ref_sorted = [0,12,24,36,48,60,72,84,96,108,120,132,144,156,168] + g = nil + for i=1 to count(f) do + g = g & grib_set_long(f[i], ["step", ref_unsorted[i]]) + end for + g = g + 0 + assert_equal(grib_get_long(g, "step"), ref_unsorted, fn_name & " step ori", 3) + + h = read(data: g) + 0 + assert_equal(grib_get_long(h, "step"), ref_unsorted, fn_name & " step ori", 3) + + h = read(data: g, order: "as_is") + 0 + assert_equal(grib_get_long(h, "step"), ref_unsorted, fn_name & " step order=as_is", 3) + + h = read(data: g, order: 0) + 0 + assert_equal(grib_get_long(h, "step"), ref_unsorted, fn_name & " step order=0", 3) + + h = read(data: g, order: 1) + 0 + assert_equal(grib_get_long(h, "step"), ref_sorted, fn_name & " step order=1", 3) + + h = read(data: g, order: "sorted") + 0 + assert_equal(grib_get_long(h, "step"), ref_sorted, fn_name & " step order=sorted", 3) + + # 4. level + f = read(source: "ml2pl_ref.grib") + ref_unsorted = [100, 925, 500, 1000, 850] + ref_sorted = [100, 500, 850, 925, 1000] + assert_equal(grib_get_long(f, "level"), ref_unsorted, fn_name & " level ori", 4) + + f = read(source: "ml2pl_ref.grib", order: "sorted") + assert_equal(grib_get_long(f, "level"), ref_sorted, fn_name & " level sorted", 4) + +end test_read_sort diff -Nru metview-5.17.4/metview/test/macros/fieldsets.mv metview-5.19.2/metview/test/macros/fieldsets.mv --- metview-5.17.4/metview/test/macros/fieldsets.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldsets.mv 1970-01-01 00:00:00.000000000 +0000 @@ -1,3288 +0,0 @@ -# Metview Macro - -# **************************** LICENSE START *********************************** -# -# Copyright 2019 ECMWF. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ - -include "test_utils.mv" - -global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() -global VECTOR_DIFF_THRESHOLD = 0.0000001 - -global fs_22 = read('t1000_LL_2x2.grb') -global fs_77 = read('t1000_LL_7x7.grb') - -test_basic() - -# maths operators -test_abs(fs_22) -test_cos(fs_22) -test_count(fs_22) -test_exp(fs_22) -test_float(fs_22) -test_int(fs_22) -test_log(fs_22) -test_log10(fs_22) -test_neg(fs_22) -test_sgn(fs_22) -test_sin(fs_22) -test_sqrt(fs_22) -test_tan(fs_22) - -test_absolute_vorticity() -test_accumulate() -test_average() -test_average_ew() -test_average_ns() -test_bearing() -test_bitmap() -test_bounding_box() -test_corr_a() -test_coslat() -test_covar() -test_covar_a() -test_datainfo() -test_direction() -test_distance() -test_div() -test_duplicate() -test_find() -test_frequencies() -test_gfind() -test_grib_indexes() -test_gribsetbits() -test_indexes() -test_indexes_interpolate() -test_integrate() -test_longitudes() -test_latitudes() -test_lookup() -test_mask() -test_mask_missing() -test_max() -test_maxvalue() -test_mean() -test_mean_missing() -test_mean_ew() -test_merge() -test_min() -test_minvalue() -test_mod() -test_nobitmap() -test_percentile() -test_percentile_missing_1() -test_percentile_missing_2() -test_percentile_missing_3() -test_read() -test_read_sort() -test_rmask() -test_rmask_missing() -test_rms_a() -test_set_values() -test_sinlat() -test_solar_zenith_angle() -test_sort() -test_speed() -test_stdev() -test_stdev_a() -test_sum() -test_sum_missing() -test_tanlat() -test_values() -test_var() -test_var_a() -test_xy_from_polar() - -# perform some basic operations on the 'fieldset' Macro data type -function test_basic() - a = read('hindcast.grib') - steps = [0,6,24,36,48,72] - - assert(steps_equal(a, steps), 'all fields') - assert(step_equal(a[1], 0), 'first field') - assert(step_equal(a[count(a)], 72), 'last field') - assert(steps_equal(a[1,3], [0,6,24]), '2 indexes (1)') - assert(steps_equal(a[3,6], [24,36,48,72]), '2 indexes (2)') - assert(steps_equal(a[2,6,2], [6,36,72]), '3 indexes') - - i = |2, 3, 6, 2| - assert(steps_equal(a[i], [6,24,72,6]), 'vector index (1)') - i = |5| - assert(step_equal(a[i], 48), 'vector index (2)') -end test_basic - -function test_abs(fs) - v = values(abs(fs)) - v_ref = abs(values(fs)) - assert(vec_same(v, v_ref), "abs", 1) -end test_abs - -function test_cos(fs) - v = values(cos(fs)) - v_ref = cos(values(fs)) - assert(vec_same(v, v_ref), "cos", 1) -end test_cos - -function test_count(fs) - assert(count(fs) = 1, "count", 1) -end test_count - -function test_exp(fs) - f = fs / maxvalue(fs) # scales between [0,1] - v = values(exp(f)) - v_ref = exp(values(f)) - assert(vec_same(v, v_ref), "exp", 1) -end test_exp - -function test_float(fs) - f = fs * 0 + 2 - v = values(float(f)) - v_ref = vector(count(v)) + 2 - assert(vec_same(v, v_ref), "float", 1) -end test_float - -function test_int(fs) - v = values(int(fs)) - v_ref = int(values(fs)) - assert(vec_same(v, v_ref), "int", 1) -end test_int - -function test_log(fs) - v = values(log(fs)) - v_ref = log(values(fs)) - assert(vec_same(v, v_ref), "log", 1) -end test_log - -function test_log10(fs) - v = values(log10(fs)) - v_ref = log10(values(fs)) - assert(vec_same(v, v_ref), "log10", 1) -end test_log10 - -function test_neg(fs) - v = values(neg(fs)) - v_ref = neg(values(fs)) - assert(vec_same(v, v_ref), "neg", 1) -end test_neg - -function test_sgn(fs) - v = values(sgn(fs)) - v_ref = sgn(values(fs)) - assert(vec_same(v, v_ref), "sgn", 1) -end test_sgn - -function test_sin(fs) - v = values(sin(fs)) - v_ref = sin(values(fs)) - assert(vec_same(v, v_ref), "sin") -end test_sin - -function test_absolute_vorticity() - f = read("abs_vort.grib") - vo = f[1] - absv_ref = f[2] - absv = absolute_vorticity(vo) - assert_equal(count(absv), 1, "absolute_vorticity count",1) - - id = grib_get_long(absv,"paramId") - assert_equal(id,3041,"absolute_vorticity paramId",1) - gpId = grib_get_long(absv,"generatingProcessIdentifier") - assert_equal(gpId,128,"absolute_vorticity gpId",1) - - assert(vec_same(values(absv), values(absv_ref),1E-8),"absolute_vorticity values") -end test_absolute_vorticity - -function test_sqrt(fs) - f = abs(fs) - v = values(sqrt(f)) - v_ref = sqrt(values(f)) - assert(vec_same(v, v_ref, 0.000001), "sqrt") -end test_sqrt - -function test_tan(fs) - v = values(tan(fs)) - v_ref = tan(values(fs)) - assert(vec_same(v, v_ref, 0.00010), "tan") -end test_tan - -function test_accumulate() - fs = fs_77 - v = accumulate(fs) - v_ref = 393334.244141 - assert_equal(v, v_ref, "accumulate_single", 1) - v_ref = sum(values(fs)) - assert_equal(v, v_ref, "accumulate_single", 2) - - f = read('monthly_avg.grib') - v = accumulate(f) - assert(count(v) = count(f), "accmulate_count", 1) - for i=1 to count(v) do - assert_equal(v[i],sum(values(f[i])), "accumulate",i) - end for -end accumulate - - -function test_average() - fs = fs_22 - - # const fields - v = average(fs*0+1) - v_ref = 1 - assert_equal(v, v_ref, "average_const", 0) - - # single field - v = average(fs) - v_ref = 280.991189355 - assert_equal(v, v_ref, "average_single", 1) - v_ref = mean(values(fs)) - assert_equal(v, v_ref, "average_single", 2) - - # multiple fields - f = read('monthly_avg.grib') - v = average(f) - assert(count(v) = count(f), "average_count", 1) - for i=1 to count(v) do - assert_equal(v[i],mean(values(f[i])), "average",i) - end for -end test_average - -function test_average_ew() - fs = fs_22 - - # const field global - area =[90,-180,-90,180] - dy = 30 - v = average_ew(fs*0+1, area, dy) - v_ref = |1,1,1,1,1,1,1| - assert(vec_same(v, v_ref,1E-4), "average_ew const",1) - - # const field area - area =[60,-180,-60,180] - dy = 20 - v = average_ew(fs*0+2, area, dy) - v_ref = |2,2,2,2,2,2,2| - assert(vec_same(v, v_ref,1E-4), "average_ew const",2) - - # single field - area =[60,-180,-60,180] - dy = 20 - v = average_ew(fs, area, dy) - v_ref = |274.751,287.56,298.855,300.051,296.955,287.059,274.002| - assert(vec_same(v, v_ref,1E-3), "average_ew single",1) - - # multiple fields - f = read('monthly_avg.grib') - v = average_ew(f[1,2], area, dy) - v_ref = [|359.156,332.584,249.805,247.509,260.009,279.057,292.451|, - |383.311,343.246,254.138,248.505,257.765,272.993,287.189|] - assert(count(v) = 2, "average_ew multi_count", 1) - for i=1 to count(v) do - assert(vec_same(v[i], v_ref[i],1E-3), "average_ew multi",1) - end for - -end test_average_ew - -function test_average_ns() - fs = fs_22 - - # const field global - area =[90,-180,-90,180] - dy = 60 - v = average_ns(fs*0+1, area, dy) - v_ref = |1,1,1,1,1,1,1| - assert(vec_same(v, v_ref,1E-4), "average_ns const",1) - - # const field area - area =[90,-120,-90,120] - dy = 40 - v = average_ns(fs*0+2, area, dy) - v_ref = |2,2,2,2,2,2,2| - assert(vec_same(v, v_ref,1E-4), "average_ns const",2) - - # single field - area =[90,-120,-90,120] - dy = 40 - v = average_ns(fs, area, dy) - v_ref = |287.82,286.99,287.547,290.989,292.157,292.072,288.593| - assert(vec_same(v, v_ref,1E-3), "average_ns single",1) - - # multiple fields - f = read('monthly_avg.grib') - v = average_ns(f[1,2], area, dy) - v_ref = [|281.504,279.59,274.796,277.391,281.457,275.671,282.888|, - |287.213,290.872,281.548,279.08,276.233,277.212,285.542|] - - assert(count(v) = 2, "average_ns multi_count", 1) - for i=1 to count(v) do - assert(vec_same(v[i], v_ref[i],1E-3), "average_ns multi",1) - end for - -end test_average_ns - -function test_bearing() - fs = fs_22 - lat_ref = 46 - lon_ref = 20 - b = bearing(fs[1],lat_ref,lon_ref) - - eps =1E-4 - assert_equal(nearest_gridpoint(b,[50,20]),0,"bearing_basic",1) - assert_equal(nearest_gridpoint(b,[46,24]),90,"bearing_basic",2) - assert_equal(nearest_gridpoint(b,[40,20]),180,"bearing_basic",3) - assert_equal(nearest_gridpoint(b,[46,16]),270,"bearing_basic",4) - assert_equal(nearest_gridpoint(b,[46,-80]),270,"bearing_basic",5) - assert_equal(nearest_gridpoint(b,[46,100]),90,"bearing_basic",6) - assert_equal(nearest_gridpoint(b,[-40,20]),180,"bearing_basic",7) - assert_equal(nearest_gridpoint(b,[80,20]),0,"bearing_basic",8) - assert(nearest_gridpoint(b,[46,20]) = nil,"bearing_basic_9") - - assert_equal(nearest_gridpoint(b,[50,22]),19.092956543,"bearing",1) - assert_equal(nearest_gridpoint(b,[50,18]),340.907043457,"bearing",2) - assert_equal(nearest_gridpoint(b,[40,18]),193.098327637,"bearing",3) - assert_equal(nearest_gridpoint(b,[40,22]),166.901672363,"bearing",4) - - b = bearing(fs[1],[lat_ref,lon_ref]) # coords as list - assert_equal(nearest_gridpoint(b,[50,20]),0,"bearing_basic_l",1) - assert_equal(nearest_gridpoint(b,[46,24]),90,"bearing_basic_l",2) -end test_bearing - -function test_bitmap() - fs = fs_22 - - #-- const field - f = fs*0+1 - - # non missing - r = bitmap(f,0) - v = values(r) - v_ref = values(f) - assert(vec_same(v, v_ref,1E-4), "bitmap const",1) - - # all missing - r = bitmap(f,1) - v = values(r) - v_ref = values(f) * vector_missing_value - assert(vec_same_missing(v, v_ref,1E-4), "bitmap const",2) - - #-- non const field - f = fs - - # bitmap with value - f_mask = f > 300 - r = bitmap(f_mask, 1) - v = values(r) - v_ref = values(f_mask) - v_ref = bitmap(v_ref, 1) - assert(vec_same_missing(v, v_ref,1E-4), "bitmap value",1) - - f_mask = f > 300 - r = bitmap(f_mask*2 , 2) - v = values(r) - v_ref = values(f_mask*2) - v_ref = bitmap(v_ref, 2) - assert(vec_same_missing(v, v_ref,1E-4), "bitmap value",1) - - # bitmap with field - r = bitmap( f > 300, 0) - r = bitmap(f, r) - v = values(r) - v_ref = values(f) - v_ref = v_ref * bitmap(v_ref > 300, 0) - assert(vec_same_missing(v, v_ref,1E-4), "bitmap field",2) - - # multiple fields - f = read('monthly_avg.grib') - f = f[1,2] - - # with value - f_mask = f > 300 - r = bitmap(f_mask, 1) - assert(count(r) = count(f), "bitmap multi count", 1) - for i=1 to count(r) do - v = values(r[i]) - v_ref = values(f_mask[i]) - v_ref = bitmap(v_ref, 1) - assert(vec_same_missing(v, v_ref,1E-3), "bitmap multi value",1) - end for - - # with field - r = bitmap( f > 300, 0) - r = bitmap(f, r) - assert(count(r) = count(f), "bitmap multi count", 2) - for i=1 to count(r) do - v = values(r[i]) - v_ref = values(f[i]) - v_ref = v_ref * bitmap(v_ref > 300, 0) - assert(vec_same_missing(v, v_ref,1E-3), "bitmap multi value",2) - end for - -end test_bitmap - -function test_bounding_box() - fn_name = "test_bounding_box" - - # lam - fs = read("fc_data.grib") - v = bounding_box(fs) - v_ref = [|70,10,80,20|,|70,10,80,20|,|70,10,80,20|,|70,10,80,20|] - assert(count(v) = count(v_ref), fn_name & " count", 1) - for i=1 to count(v_ref) do - assert(vec_same(v[i], v_ref[i],1E-4), fn_name & " vals-" & i,1) - end for - - # global - fs = fs_22 - v = bounding_box(fs) - v_ref = |-90,-180,90,180| - assert(count(v) = count(v_ref), fn_name & " count", 2) - assert(vec_same(v, v_ref,1E-4), fn_name & " vals",2) - - # regular Gaussian global - fs = read("t1000_reg_gg_N48.grib") - v = bounding_box(fs) - v_ref = |-90,-180,90,180| - assert(count(v) = count(v_ref), fn_name & " count", 3) - assert(vec_same(v, v_ref,1E-4), fn_name & " vals",3) - - # regular Gaussian subarea - fs = read("regular_gaussian_subarea.grib") - v = bounding_box(fs) - v_ref = |15.0351,-101.25,56.9086,-38.812| - assert(count(v) = count(v_ref), fn_name & " count", 4) - assert(vec_same(v, v_ref,1E-4), fn_name & " vals",4) - - # reduced Gaussian global - fs = read("t1000_red_gg_N48.grib") - v = bounding_box(fs) - v_ref = |-90,-180,90,180| - assert(count(v) = count(v_ref), fn_name & " count", 5) - assert(vec_same(v, v_ref,1E-4), fn_name & " vals",5) - - # reduced Gaussian subarea - fs = read("rgg_small_subarea.grib") - v = bounding_box(fs) - v_ref = |84.8155,36.233,89.8765,46.185| - assert(count(v) = count(v_ref), fn_name & " count", 6) - assert(vec_same(v, v_ref,1E-4), fn_name & " vals",6) - - fs = read("rgg_western_subarea.grib") - v = bounding_box(fs) - v_ref = |-9.97658,-80,11.9438,-70| - assert(count(v) = count(v_ref), fn_name & " count", 7) - assert(vec_same(v, v_ref,1E-4), fn_name & " vals",7) - - # reduced latlon - fs = read("reduced_ll.grib") - v = bounding_box(fs) - v_ref = |-90,-180,90,180| - assert(count(v) = count(v_ref), fn_name & " count", 8) - assert(vec_same(v, v_ref,1E-4), fn_name & " vals",8) - - # ll dateline - fs = read("ll_dateline.grib") - v = bounding_box(fs) - v_ref = |-90,120,90,240| - assert(count(v) = count(v_ref), fn_name & " count", 9) - assert(vec_same(v, v_ref,1E-4), fn_name & " vals",9) - - -end test_bounding_box - -function test_corr_a() - - fs = fs_22 - - # global - - # single field - self covariance - v = corr_a(fs, fs) - v_ref = 1 - assert_equal(v, v_ref, "corr_a",1) - - # real life example - f1 = read('monthly_avg.grib') - f2 = nil - for i=count(f1) to 1 by -1 do - f2 = f2 & f1[i] - end for - v = vector(corr_a(f1,f2)) - assert_equal(count(v),count(f1), "corr_a_count", 2) - v_ref = |0.389037,0.603044,0.835476,0.940168,0.940168,0.835476,0.603044,0.389037| - assert(vec_same(v, v_ref,1E-2), "corr_a",2) - - # sub area - area = [60, -20, 30, 28] - - v = corr_a(fs, fs, area) - v_ref = 1 - assert_equal(v, v_ref, "corr_a",3) - - f1 = read('monthly_avg.grib') - f2 = nil - for i=count(f1) to 1 by -1 do - f2 = f2 & f1[i] - end for - v = vector(corr_a(f1,f2, area)) - assert_equal(count(v),count(f1), "corr_a_count", 4) - v_ref = |0.448865,0.75234,0.616183,0.821316,0.821316,0.616183,0.75234,0.448865| - assert(vec_same(v, v_ref,1E-2), "corr_a",4) - -end test_corr_a - -function test_coslat() - fs = fs_22 - v = values(coslat(fs)) - v_ref = cos(pi * latitudes(fs) / 180.) - assert(vec_same(v, v_ref), "coslat", 1) -end test_coslat - -function test_covar() - - fs = fs_77 - - # single field - self covariance - r = covar(fs, fs) - v = values(r) - v_ref = v * 0 - assert_equal(count(r),1,"covar_count",1) - assert(vec_same(v, v_ref), "covar",1) - - # multiple fields - self covariance - r = covar(fs & 2*fs, fs & 2*fs) - v = values(r) - v_ref = values(fs)^2 * 0.25 - assert_equal(count(r),1,"covar_count",2) - assert(vec_same(v, v_ref, 1E-3), "covar",2) - - # real life example - f1 = read('monthly_avg.grib') - f2 = nil - for i=count(f1) to 1 by -1 do - f2 = f2 & f1[i] - end for - r = covar(f1,f2) - assert_equal(count(r),1, "covar_count", 3) - v = values(r) - - # we compute the ref values with vectors - # the mean is the same for f1 and f2! - v_ref_mean = v * 0 - for i=1 to count(f1) do - v_ref_mean = v_ref_mean + values(f1[i]) - end for - v_ref_mean = v_ref_mean / count(f1) - - v_ref = v * 0 - for i=1 to count(f1) do - v_ref = v_ref + (values(f1[i]) - v_ref_mean)*(values(f2[i]) - v_ref_mean) - end for - v_ref = v_ref/count(f1) - assert(vec_same(v, v_ref), "covar",3) -end test_covar - -function test_covar_a() - - fs = fs_22 - - # global - - # single field - self covariance - v = covar_a(fs, fs) - v_ref = 179.19426768 - assert_equal(v, v_ref, "covar_a",1) - - # real life example - f1 = read('monthly_avg.grib') - f2 = nil - for i=count(f1) to 1 by -1 do - f2 = f2 & f1[i] - end for - v = vector(covar_a(f1,f2)) - assert_equal(count(v),count(f1), "covar_a_count", 2) - v_ref = |473.87,870.576,1591.66,2122.84,2122.84,1591.66,870.576,473.87| - assert(vec_same(v, v_ref,1E-2), "covar_a",2) - - # sub area - area = [60, -20, 30, 28] - - v = covar_a(fs, fs, area) - v_ref = 38.7289133484 - assert_equal(v, v_ref, "covar_a",3) - - f1 = read('monthly_avg.grib') - f2 = nil - for i=count(f1) to 1 by -1 do - f2 = f2 & f1[i] - end for - v = vector(covar_a(f1,f2, area)) - assert_equal(count(v),count(f1), "covar_a_count", 4) - v_ref = |119.03,192.666,121.255,321.397,321.397,121.255,192.666,119.03| - assert(vec_same(v, v_ref,1E-2), "covar_a",4) - -end test_covar_a - -function test_datainfo() - a = read('hindcast.grib') - - di = datainfo(a) - di3 = di[3] - assert(di3.index = 3, 'datainfo.index') - assert(di3.number_present = 2664, 'datainfo.number_present') - assert(di3.number_missing = 0, 'datainfo.number_missing') - assert(di3.proportion_present = 1, 'datainfo.proportion_present') - assert(di3.proportion_missing = 0, 'datainfo.proportion_missing') -end test_datainfo - -function test_grib_indexes() - # read a single GRIB file - fs1 = read("hindcast.grib") - gi = grib_indexes(fs1) - assert(type(gi) = "list", "test_grib_indexes1: type gi") - assert(count(gi) = count(fs1), "test_grib_indexes1: count(fs1)") - assert(gi[1][2] = 0, "test_grib_indexes1: gi[1][2]") - assert(gi[1][3] = 1494, "test_grib_indexes1: gi[1][3]") - assert(gi[3][2] = 3054, "test_grib_indexes1: gi[3][2]") - assert(gi[3][3] = 1494, "test_grib_indexes1: gi[3][3]") - path = gi[1][1] - for i = 2 to count(fs1) do - assert(path = gi[i][1], "test_grib_indexes1: path i") # all paths should be the same - end for - path_parts = parse(path, "/") - assert(path_parts[count(path_parts)] = "hindcast.grib", "test_grib_indexes1: path hindcast") # last bit should be original filename - - # take a selection of fields - fs2 = fs1[3] & fs1[1] & fs1[2] - gi = grib_indexes(fs2) - assert(type(gi) = "list", "test_grib_indexes2: type gi") - assert(count(gi) = count(fs2), "test_grib_indexes2: count(fs2)") - assert(gi[1][2] = 3054, "test_grib_indexes2: gi[1][2]") - assert(gi[1][3] = 1494, "test_grib_indexes2: gi[1][3]") - assert(gi[2][2] = 0, "test_grib_indexes2: gi[2][2]") - assert(gi[2][3] = 1494, "test_grib_indexes2: gi[2][3]") - assert(gi[3][2] = 1494, "test_grib_indexes2: gi[3][2]") - assert(gi[3][3] = 1494, "test_grib_indexes2: gi[3][3]") - path = gi[1][1] - for i = 2 to count(fs2) do - assert(path = gi[i][1], "test_grib_indexes2: path i") # all paths should be the same - end for - path_parts = parse(path, "/") - assert(path_parts[count(path_parts)] = "hindcast.grib", "test_grib_indexes2: path hindcast") # last bit should be original filename - - # read another fieldset and make a new fieldset containing fields from both - fs3 = read('surface_wind.grib') - fsmerged = fs1[2] & fs3[4] & fs1[1] - gi = grib_indexes(fsmerged) - assert(type(gi) = "list", "test_grib_indexes3: type gi") - assert(count(gi) = 3, "test_grib_indexes3: count gi") - assert(gi[1][2] = 1494, "test_grib_indexes3: gi[1][2]") - assert(gi[1][3] = 1494, "test_grib_indexes3: gi[1][3]") - path_parts = parse(gi[1][1], "/") - assert(path_parts[count(path_parts)] = "hindcast.grib", "test_grib_indexes3: path1 hindcast") - assert(gi[2][2] = 16476, "test_grib_indexes3: gi[2][2]") - assert(gi[2][3] = 5436, "test_grib_indexes3: gi[2][3]") - path_parts = parse(gi[2][1], "/") - assert(path_parts[count(path_parts)] = "surface_wind.grib", "test_grib_indexes3: path2 surface_wind") - assert(gi[3][2] = 0, "test_grib_indexes3: gi[3][2]") - assert(gi[3][3] = 1494, "test_grib_indexes3: gi[3][3]") - path_parts = parse(gi[3][1], "/") - assert(path_parts[count(path_parts)] = "hindcast.grib", "test_grib_indexes3: path3 hindcast") - - # perform computations, forcing temporary file - # note that it seems that in this case, MARS returns zero for the length - fstemp = fs1*1 - gi = grib_indexes(fstemp) - assert(type(gi) = "list", "test_grib_indexes4: type gi") - assert(count(gi) = count(fstemp), "test_grib_indexes4: count gi") - assert(gi[1][2] = 0, "test_grib_indexes4: gi[1][2]") - assert(gi[1][3] = 8154, "test_grib_indexes4: gi[1][3]") - assert(gi[2][2] = 8160, "test_grib_indexes4: gi[1][2]") - assert(gi[2][3] = 8154, "test_grib_indexes4: gi[1][3]") - assert(gi[3][2] = 16320, "test_grib_indexes4: gi[3][2]") - assert(gi[3][3] = 8154) - path = gi[1][1] - for i = 2 to count(fstemp) do - assert(path = gi[i][1], "test_grib_indexes4: paths same") # all paths should be the same - end for - assert(search(path, "mv.") >= 0, "test_grib_indexes4: path in tmp") # "mv." should appear in name of temporary directory -end test_grib_indexes - - -function test_direction() - fs = read("tuv_pl.grib") - u = read(data: fs, param: "u") - v = read(data: fs, param: "v") - - u_val = values(u[1]) - v_val = values(v[1]) - u_val_test = |0, 1, 1, 1, 0, -1, -1, -1, 0| - v_val_test = |1, 1, 0, -1, -1, -1, 0, 1, 0| - d_ref_test = |180, 225, 270, 315, 0, 45, 90, 135, 0| - - for i=1 to count(u_val_test) do - u_val[i] = u_val_test[i] - v_val[i] = v_val_test[i] - end for - - u_t = set_values(u[1], u_val) - v_t = set_values(v[1], v_val) - - u_t = u_t & u_t - v_t = v_t & v_t - - d = direction(u_t, v_t) - assert(count(d) = 2, "direction_count", 1) - for i=1 to count(d) do - d_val = values(d[i])[1, count(d_ref_test)] - assert(vec_same(d_val, d_ref_test, 0.000001), "direction " & i) - param_id = grib_get_long(d[i], "paramId") - assert_equal(3031, param_id, "direction - paramId " & i) - end for - - # check value range - min_d = minvalue(d[1]) - assert(min_d >=0 and min_d <= 360,"direction min",1) - max_d = maxvalue(d[1]) - assert(max_d >=0 and max_d <= 360,"direction max",1) - - # test missing values - u_t = bitmap(u_t[1], bitmap(u_t[1] > 0.9, 1)) - v_t = bitmap(v_t[1], bitmap(v_t[1] < -0.9, 1)) - d = direction(u_t, v_t) - assert(count(d) = 1, "direction_count bitmap") - d_val = values(d)[1, count(d_ref_test)] - d_ref_test = |180,vector_missing_value,vector_missing_value,vector_missing_value,vector_missing_value,vector_missing_value,90,135,0| - assert(vec_same_missing(d_val, d_ref_test, 0.000001), "direction bitmap" ) - assert_equal(3031, grib_get_long(d[1], 'paramId'), "direction - bitmap paramId") - -end test_direction - - -function test_distance() - fs = fs_22 - eps =1E-4 - - lat_ref = 0 - lon_ref = 0 - b = distance(fs[1],lat_ref,lon_ref) - assert_equal(nearest_gridpoint(b,[0,0]),0,"distance_eq",1) - assert_equal(nearest_gridpoint(b,[0,90]),10000800,"distance_eq",2) - assert_equal(nearest_gridpoint(b,[0,-90]),10000800,"distance_eq",3) - assert_equal(nearest_gridpoint(b,[0,180]),2*10000800,"distance_eq",4) - assert_equal(nearest_gridpoint(b,[90,0]),10000800,"distance_eq",5) - assert_equal(nearest_gridpoint(b,[-90,0]),10000800,"distance_eq",6) - assert_equal(nearest_gridpoint(b,[48,20]),5671570,"distance_eq",7) - assert_equal(nearest_gridpoint(b,[48,-20]),5671570,"distance_eq",8) - assert_equal(nearest_gridpoint(b,[-48,-20]),5671570,"distance_eq",9) - assert_equal(nearest_gridpoint(b,[-48,20]),5671570,"distance_eq",10) - - lat_ref = 90 - lon_ref = 0 - b = distance(fs[1],lat_ref,lon_ref) - assert_equal(nearest_gridpoint(b,[0,0]),10000800,"distance_np",1) - assert_equal(nearest_gridpoint(b,[0,90]),10000800,"distance_np",2) - assert_equal(nearest_gridpoint(b,[0,-90]),10000800,"distance_np",3) - assert_equal(nearest_gridpoint(b,[0,180]),10000800,"distance_np",4) - assert_equal(nearest_gridpoint(b,[90,0]),0,"distance_np",5) - assert_equal(nearest_gridpoint(b,[-90,0]),2*10000800,"distance_np",6) - assert_equal(nearest_gridpoint(b,[48,20]),4667040,"distance_np",7) - assert_equal(nearest_gridpoint(b,[48,-20]),4667040,"distance_np",8) - assert_equal(nearest_gridpoint(b,[-48,-20]),15334560,"distance_np",9) - assert_equal(nearest_gridpoint(b,[-48,20]),15334560,"distance_np",10) - - lat_ref = -90 - lon_ref = 0 - b = distance(fs[1],lat_ref,lon_ref) - assert_equal(nearest_gridpoint(b,[0,0]),10000800,"distance_sp",1) - assert_equal(nearest_gridpoint(b,[0,90]),10000800,"distance_sp",2) - assert_equal(nearest_gridpoint(b,[0,-90]),10000800,"distance_sp",3) - assert_equal(nearest_gridpoint(b,[0,180]),10000800,"distance_sp",4) - assert_equal(nearest_gridpoint(b,[90,0]),2*10000800,"distance_sp",5) - assert_equal(nearest_gridpoint(b,[-90,0]),0,"distance_sp",6) - assert_equal(nearest_gridpoint(b,[48,20]),15334560,"distance_sp",7) - assert_equal(nearest_gridpoint(b,[48,-20]),15334560,"distance_sp",8) - assert_equal(nearest_gridpoint(b,[-48,-20]),4667040,"distance_sp",9) - assert_equal(nearest_gridpoint(b,[-48,20]),4667040,"distance_sp",10) - - lat_ref = 48 - lon_ref = 20 - b = distance(fs[1],lat_ref,lon_ref) - assert_equal(nearest_gridpoint(b,[0,0]),5671570,"distance_hu",1) - assert_equal(nearest_gridpoint(b,[0,90]),8530712,"distance_hu",2) - assert_equal(nearest_gridpoint(b,[0,-90]),11470888,"distance_hu",3) - assert_equal(nearest_gridpoint(b,[0,180]),14330030,"distance_hu",4) - assert_equal(nearest_gridpoint(b,[90,0]),4667040,"distance_hu",5) - assert_equal(nearest_gridpoint(b,[-90,0]),15334560,"distance_hu",6) - assert_equal(nearest_gridpoint(b,[48,20]),0,"distance_hu",7) - assert_equal(nearest_gridpoint(b,[48,-20]),2940176,"distance_hu",8) - assert_equal(nearest_gridpoint(b,[-48,-20]),11343140,"distance_hu",9) - assert_equal(nearest_gridpoint(b,[-48,20]),10667520,"distance_hu",10) - - - b = distance(fs[1],[lat_ref,lon_ref]) # target as list - assert_equal(nearest_gridpoint(b,[0,0]),5671570,"distance_hu_l",1) - assert_equal(nearest_gridpoint(b,[0,90]),8530712,"distance_hu_l",2) - assert_equal(nearest_gridpoint(b,[0,-90]),11470888,"distance_hu_l",3) - assert_equal(nearest_gridpoint(b,[0,180]),14330030,"distance_hu_l",4) - assert_equal(nearest_gridpoint(b,[90,0]),4667040,"distance_hu_l",5) - assert_equal(nearest_gridpoint(b,[-90,0]),15334560,"distance_hu_l",6) - assert_equal(nearest_gridpoint(b,[48,20]),0,"distance_hu_l",7) - assert_equal(nearest_gridpoint(b,[48,-20]),2940176,"distance_hu_l",8) - assert_equal(nearest_gridpoint(b,[-48,-20]),11343140,"distance_hu_l",9) - assert_equal(nearest_gridpoint(b,[-48,20]),10667520,"distance_hu_l",10) - - - -end test_distance - -function test_div() - fs = fs_77 - - d = div(fs,fs) - v = values(d) - v_ref = v*0 + 1 - assert(vec_same(v,v_ref),"div",1) - - d = div(fs,2*fs) - v = values(d) - v_ref = v*0 - assert(vec_same(v,v_ref),"div",2) - - f = fs * 0.2 * coslat(fs) + 10 - d = div(fs,f) - v = values(d) - v_ref = div(values(fs),values(f)) - assert(vec_same(v,v_ref),"div",3) - - # here we need to use bitmap to avoid divison by 0 - f = fs * 0.2 * coslat(fs) - f = bitmap(f,bitmap(abs(f) < 1E-14 ,1)) - d = div(fs,f) - v = values(d) - v_ref = div(values(fs),values(f)) - assert(vec_same(v,v_ref),"div",4) - -end test_div - -function test_duplicate() - fs = fs_77 - - d = duplicate(fs, 1) - assert_equal(count(d),1,"duplicate",1) - - d = duplicate(fs, 2) - assert_equal(count(d),2,"duplicate",2) - -end test_duplicate - -function test_find() - fs = read('t1000_LL_2x2_with_missing.grb') - - # find() cannot use a tolerance so it is almost impossible to - # find a floating value, so we cast it into int!!! - - f = int(fs*100) - - dref = 2015-04-22 12:00 - - # with value only - v = find(f, 28845) - v_ref = [[54,242],[52,100],[50,64],[50,104],[50,248],[48,20],[48,54],[48,104],[48,250],[46,22],[46,356],[44,130], - [44,242],[44,354],[42,128],[42,240],[40,4],[38,2],[38,128],[38,130],[38,164],[38,286],[36,122],[36,124], - [36,138],[36,144],[36,198],[36,202],[36,354],[34,18],[34,20],[34,24],[34,28],[34,32],[34,122],[34,130], - [34,132],[34,206],[34,266],[34,274],[34,330],[34,352],[32,124],[32,128],[32,164],[32,244],[32,276],[32,320], - [32,322],[32,340],[32,342],[30,166],[30,216],[30,232],[30,314],[30,340],[28,170],[28,178],[28,180],[28,182], - [28,186],[28,188],[28,340],[28,346],[24,342],[-24,288],[-28,128],[-28,280],[-28,282],[-28,286],[-30,298], - [-30,304],[-32,16],[-32,130],[-32,136],[-32,138],[-32,142],[-32,216],[-32,218],[-32,220],[-32,226],[-32,228], - [-32,230],[-32,276],[-34,12],[-34,16],[-34,48],[-34,50],[-34,52],[-34,54],[-34,90],[-34,112],[-34,130],[-34,180], - [-34,194],[-34,198],[-34,296],[-34,306],[-36,18],[-36,20],[-36,86],[-36,120],[-36,126],[-36,172],[-36,174],[-36,178], - [-36,200],[-36,204],[-36,246],[-36,294],[-36,302],[-36,324],[-36,326],[-36,328],[-36,330],[-38,76],[-38,170],[-38,288], - [-38,308],[-38,316],[-38,334],[-38,338],[-40,0],[-40,32],[-40,152],[-40,274],[-40,302],[-40,310],[-40,312],[-40,350], - [-40,352],[-40,358],[-42,272],[-42,312],[-42,346],[-44,264],[-44,266],[-44,268],[-44,270]] - - assert_equal(count(v),count(v_ref),"find count",1) - - for i=1 to count(v) do - assert_equal(v[i],v_ref[i],"find latlon 1") - assert_equal(nearest_gridpoint(f,v[i],'valid'),28845,"find value 1") - end for - - # with value + area - area = [52.1,99.9,49.9,105.1] - v = find(int(f), 28845, area) - v_ref = [[52,100],[50,104]] - assert_equal(count(v),count(v_ref),"find count",2) - - for i=1 to count(v) do - assert_equal(v[i],v_ref[i],"find latlon 2") - assert_equal(nearest_gridpoint(f,v[i],'valid'),28845,"find value 2") - end for - - # with value + mask - area = [52.1,99.9,49.9,105.1] - area_mask = mask(f, area) - v = find(int(f), 28845, area_mask) - v_ref = [[52,100],[50,104]] - assert_equal(count(v),count(v_ref),"find count",3) - - for i=1 to count(v) do - assert_equal(v[i],v_ref[i],"find latlon 3") - assert_equal(nearest_gridpoint(f,v[i],'valid'),28845,"find value 3") - end for - - # intervals - we use the original field!!! - - # with interval only - f = fs - v = find(f, [234.9,236.0]) - v_ref = [[-78,176],[-80,176],[-80,178],[-80,180]] - assert_equal(count(v),count(v_ref),"find count",4) - - for i=1 to count(v) do - assert_equal(v[i],v_ref[i],"find latlon 4") - vv = nearest_gridpoint(f,v[i],'valid') - assert(vv >= 234.9 and vv <= 236.0,"find value", 4) - end for - - # with interval + area - area = [-77.9, 175.9, -80.1, 176.1] - v = find(f, [234.9,236.0], area) - v_ref = [[-78,176],[-80,176]] - assert_equal(count(v),count(v_ref),"find count",5) - - for i=1 to count(v) do - assert_equal(v[i],v_ref[i],"find latlon 5") - vv = nearest_gridpoint(f,v[i],'valid') - assert(vv >= 234.9 and vv <= 236.0,"find value", 5) - end for - - # with interval + mask - area = [-77.9, 175.9, -80.1, 176.1] - area_mask = mask(f, area) - v = find(f, [234.9,236.0], area_mask) - v_ref = [[-78,176],[-80,176]] - assert_equal(count(v),count(v_ref),"find count",6) - - for i=1 to count(v) do - assert_equal(v[i],v_ref[i],"find latlon 6") - vv = nearest_gridpoint(f,v[i],'valid') - assert(vv >= 234.9 and vv <= 236.0,"find value", 6) - end for - -end test_find - -function test_frequencies() - - fs = fs_22 - - # const - single field - f = fs*0 + 1 - v = frequencies(f,[0,1,2]) - v_ref = [0,0,16380,0] - assert_equal(v, v_ref, "frequencies",1) - - # const - multiple fields (results are accumulated!!!) - f = (fs*0 + 1) & (fs*0 + 0.5) - v = frequencies(f,[0,1,2]) - v_ref = [[0,0,16380,0],[0,16380,16380,0]] - assert_equal(count(v),count(v_ref),"frequencies count",2) - - for i=1 to count(v) do - assert_equal(v[i], v_ref[i], "frequencies", 2) - end for - - # real field - f = fs - bins = [230,250,270,290,310,330] - v = frequencies(f,bins) - v_ref = [0,424,4152,5600,5983,221,0] - - # compute with vectors - vv = values(f) - v_ref_comp = [sum(vv < bins[1])] - for i=1 to count(bins) do - if i = count(bins) then - v_ref_comp = v_ref_comp & [sum(vv > bins[i])] - else - v_ref_comp = v_ref_comp & [sum(vv >= bins[i] and vv < bins[i+1])] - end if - end for - - assert_equal(v, v_ref, "frequencies preset",3) - assert_equal(v, v_ref_comp, "frequencies comp",3) - - # real field with area - f = fs - bins = [230,250,270,290,310,330] - area = [-77,-50,-84,178] # south polar region - v = frequencies(f,bins,area) - v_ref = [0,136,324,0,0,0,0] # only visually checked!! - assert_equal(v, v_ref, "frequencies",4) - - -end test_frequencies - - -function test_gfind() - fs = read('t1000_LL_2x2_with_missing.grb') - dref = 2015-04-22 12:00 - gf1 = gfind(fs, 280, 0.5) # fieldset, value, tolerance - assert(count(gf1) = 287, 'gfind1 count is ' & count(gf1)) - assert(values(gf1)[1] = 279.955, 'gf1 values[1]') - assert(values(gf1)[2] = 280.455, 'gf1 values[2]') - assert(latitudes(gf1)[1] = 64, 'gf1 latitudes[1]') - assert(latitudes(gf1)[287] = -58, 'gf1 latitudes[287]') - assert(longitudes(gf1)[1] = 2, 'gf1 longitudes[1]') - assert(longitudes(gf1)[287] = 178, 'gf1 longitudes[287]') - assert(levels(gf1)[1] = 1000, 'gf1 levels[1]') - assert(levels(gf1)[287] = 1000, 'gf1 levels[287]') - assert(dates(gf1)[1]-dref = 0, 'gf1 dates[1]') - assert(dates(gf1)[287]-dref = 0, 'gf1 dates[287]') -end test_gfind - - -function test_gribsetbits() - - f = fs_22 - - ori = gribsetbits(16) - g = f*1 - v = grib_get_long(g, 'bitsPerValue') - assert_equal(v,16,"gribsetbits",1) - - prev = gribsetbits(24) - g = f*1 - v = grib_get_long(g, 'bitsPerValue') - assert_equal(v,24,"gribsetbits",2) - assert_equal(prev,16,"gribsetbits prev",2) - - gribsetbits(ori) - -end test_gribsetbits - -function test_indexes() - - f = fs_22-10 - - vals = |230, 240, 250| - r = indexes(f, vals) - v = values(r) - v_ref = values(f) - for i=1 to count(v_ref) do - if v_ref[i] < 235 then - v_ref[i]=0 - else if v_ref[i] < 245 then - v_ref[i]=1 - else - v_ref[i]=2 - end if - end for - - assert(vec_same(v, v_ref), "indexes",1) - -end test_indexes - -function test_indexes_interpolate() - - f = fs_22-10 - sv = values(f) - - vals = |230, 240, 250| - r = indexes(f, vals, 'interpolate') - rv = values(r) - - # value below the min, should be 230, which equals index 0 (0-based, capped to 0) - i = 14814 - assert_equal(sv[i], 229.454589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 0, 'test_indexes_interpolate ' & i & ' result val') - - i = 15577 - assert_equal(sv[i], 228.454589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 0, 'test_indexes_interpolate ' & i & ' result val') - - - # value between 230 and 240, which equals index 0.x - i = 15175 - assert_equal(sv[i], 236.954589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 0.6954589844, 'test_indexes_interpolate ' & i & ' result val') - - i = 15350 - assert_equal(sv[i], 239.954589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 0.9954589844, 'test_indexes_interpolate ' & i & ' result val') - - i = 14817 - assert_equal(sv[i], 230.954589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 0.0954589844, 'test_indexes_interpolate ' & i & ' result val') - - - # value between 240 and 250, which equals index 1.x - i = 16301 - assert_equal(sv[i], 248.454589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 1.8454589844, 'test_indexes_interpolate ' & i & ' result val') - - i = 381 - assert_equal(sv[i], 243.954589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 1.3954589844, 'test_indexes_interpolate ' & i & ' result val') - - - # value above the max, should be 250, which equals index 2 (0-based, capped to 0) - i = 10491 - assert_equal(sv[i], 283.954589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 2, 'test_indexes_interpolate ' & i & ' result val') - - # value above the max, should be 250, which equals index 2 (0-based, capped to 0) - i = 15968 - assert_equal(sv[i], 250.454589844, 'test_indexes_interpolate ' & i & ' source val') - assert_equal(rv[i], 2, 'test_indexes_interpolate ' & i & ' result val') - - #found = (sv > 240) * (sv < 245) - #print(find(found, 1, 'all')) - #print(sv[381]) - -end test_indexes_interpolate - - -function test_integrate() - - fs = fs_22 - - # const fields - v = integrate(fs*0+1) - v_ref = 1 - assert_equal(v, v_ref, "integrate_const", 0) - - # single field - v = integrate(fs) - v_ref = 288.931134546 - assert_equal(v, v_ref, "integrate_single", 1) - - # multiple fields - f = read('monthly_avg.grib') - v = vector(integrate(f)) - v_ref = |281.131,284.188,286.904,289.891,290.385,289.162,287.446,287.64| - assert(vec_same(v, v_ref,1E-2), "integrate",2) - - # sub area - area = [60, -20, 30, 28] - - v = integrate(fs, area) - v_ref = 288.266360826 - assert_equal(v, v_ref, "integrate",3) - - v = integrate(fs, 60, -20, 30, 28) # area as nums - v_ref = 288.266360826 - assert_equal(v, v_ref, "integrate_area_as_nums",3) - - - f1 = read('monthly_avg.grib') - v = vector(integrate(f1, area)) - assert_equal(count(v),count(f1), "integrate_count", 4) - v_ref = |321.581,324.78,346.414,355.78,354.426,328.62,313.588,303.825| - assert(vec_same(v, v_ref,1E-2), "integrate",4) - -end test_integrate - -function test_latitudes() - - fs = fs_22 - - v = latitudes(fs) - assert_equal(count(v),16380,"latitudes_count",1) - assert_equal(v[1],90,"latitudes_1",1) - assert_equal(v[2],90,"latitudes_2",1) - assert_equal(v[8104],0,"latitudes_3",1) - assert_equal(v[11336],-34,"latitudes_4",1) - assert_equal(v[16380],-90,"latitudes_5",1) - - fs = fs_22 & fs_22 - lst = latitudes(fs) - assert_equal(count(lst),2,"latitudes_list_count",2) - for i=1 to count(lst) do - v = lst[i] - assert_equal(count(v),16380,"latitudes_count",1+i) - assert_equal(v[1],90,"latitudes_1",1+i) - assert_equal(v[2],90,"latitudes_2",1+i) - assert_equal(v[8104],0,"latitudes_3",1+i) - assert_equal(v[11336],-34,"latitudes_4",1+i) - assert_equal(v[16380],-90,"latitudes_5",1+i) - end for - -end test_latitudes - -function test_longitudes() - - fs = fs_22 - - v = longitudes(fs) - assert_equal(count(v),16380,"longitudes_count",1) - assert_equal(v[1],0,"longitudes_1",1) - assert_equal(v[2],2,"longitudes_2",1) - assert_equal(v[8104],6,"longitudes_3",1) - assert_equal(v[11336],350,"longitudes_4",1) - assert_equal(v[16380],358,"longitudes_5",1) - - fs = fs_22 & fs_22 - lst = longitudes(fs) - assert_equal(count(lst),2,"longitudes_list_count",2) - for i=1 to count(lst) do - v = lst[i] - assert_equal(count(v),16380,"longitudes_count",1+i) - assert_equal(v[1],0,"longitudes_1",1+i) - assert_equal(v[2],2,"longitudes_2",1+i) - assert_equal(v[8104],6,"longitudes_3",1+i) - assert_equal(v[11336],350,"longitudes_4",1+i) - assert_equal(v[16380],358,"longitudes_5",1+i) - end for - -end test_longitudes - -function test_lookup() - - fs = fs_22 - - # one field - f = fs - r = lookup(f*0, f) - v = values(r) - v_ref = values(f) - assert(vec_same(v, v_ref), 'lookup',1) - - # multiple fields - f = fs & 2*fs - r = lookup(f[1] > 273.16, f) - v = values(r) - v_ref = values(f[1]) - v_ref = v_ref * (v_ref <= 273.16) + 2*v_ref * (v_ref > 273.16) - assert(vec_same(v, v_ref), 'lookup',2) - -end test_lookup - -function test_mask() - - fs = fs_22 - - # global area - area = [90,-180,-90,180] - - r = mask(fs,area) - v = values(r) - v_ref = values(fs)*0+1 - assert(vec_same(v, v_ref,1E-4), "mask global",1) - - # limited area - area = [80,-100,-60, 80] - - r = mask(fs,area) - v = values(r) - - # build ref - lat = latitudes(fs) - lon = longitudes(fs) - v_ref = values(fs)*0 - for i=1 to count(lat) do - - if lon[i] > 180 then - lon[i] = lon [i] - 360 - end if - - if lat[i] <= area[1] and lat[i] >= area[3] and - lon[i] <= area[4] and lon[i] >= area[2] then - v_ref[i] = 1 - end if - end for - - assert(vec_same(v, v_ref,1E-4), "mask lam",1) - - - r = mask(fs,80,-100,-60,80) # same as above, but area as numbers - v = values(r) - assert(vec_same(v, v_ref,1E-4), "mask lam_area_as_nums",1) - - - r = mask(fs,80,-100,-60,80, 'missing', 'off') # same as above, but Pythonesque way missing=False - v = values(r) - assert(vec_same(v, v_ref,1E-4), "mask lam_area_as_nums_py",1) - - - # multiple fields - limited area - f = fs & 2*fs - - r = mask(f, area) - assert(count(r) = count(f), "mask multi count", 1) - # v_ref is the same as before - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref,1E-3), "mask multi value",1) - end for - - # area that straddles the date line - area = [50,150,30,-130] - r = mask(fs,area) - ones = find(r, 1) - assert(list_same(ones[1], [50, 150]), "mask dateline first 1") - assert(list_same(ones[count(ones)], [30, 230]), "mask dateline last 1") - assert_equal(count(ones), 451, "mask dateline count") - -end test_mask - -function test_mask_missing() - - fs = fs_22 - - # global area - area = [90,-180,-90,180] - - r = mask(fs,area,'missing') - v = values(r) - v_ref = values(fs) - assert(vec_same(v, v_ref,1E-4), "mask_missing global",1) - - # limited area - area = [80,-100,-60, 80] - - r = mask(fs,area,'missing') - v = values(r) - - # build ref - lat = latitudes(fs) - lon = longitudes(fs) - src_vals = values(fs) - v_ref = src_vals + vector_missing_value - for i=1 to count(lat) do - - if lon[i] > 180 then - lon[i] = lon [i] - 360 - end if - - if lat[i] <= area[1] and lat[i] >= area[3] and - lon[i] <= area[4] and lon[i] >= area[2] then - v_ref[i] = src_vals[i] - end if - end for - - assert(vec_same(v, v_ref,1E-4), "mask_missing lam",1) - - - r = mask(fs,80,-100,-60,80,'missing') # same as above, but area as numbers - v = values(r) - assert(vec_same(v, v_ref,1E-4), "mask_missing lam_area_as_nums",1) - - r = mask(fs,80,-100,-60,80,'missing', 'on') # same as above, but Pythonesque missing=True - v = values(r) - assert(vec_same(v, v_ref,1E-4), "mask_missing lam_area_as_nums_py",1) - - # multiple fields - limited area - f = fs & 2*fs - - r = mask(f, area, 'missing') - assert(count(r) = count(f), "mask_missing multi count", 1) - # v_ref is the same as before - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref*i,1E-3), "mask_missing multi value",1) - end for - -end test_mask_missing - -function test_max() - - fs = fs_22 - - f = fs & 3*fs & 2*fs - r=max(f) - v = values(r) - v_ref = 3*values(fs) - assert(vec_same(v,v_ref),"max",1) - - f = fs - g = 2*fs - r=max(f, g) - v = values(r) - v_ref = 2*values(fs) - assert(vec_same(v,v_ref),"max",2) - - r=max(g, f) - v = values(r) - v_ref = 2*values(fs) - assert(vec_same(v,v_ref),"max",3) - -end test_max - -function test_maxvalue() - - fs = fs_22 - - f = fs & 3*fs & 2*fs - v = maxvalue(f) - v_ref = 3*maxvalue(values(fs)) - assert_equal(v,v_ref,"maxvalue",1) - - # area - area = [80, -120, -10, 120] - v = maxvalue(f,area) - v_ref = 950.863769531 - assert_equal(v,v_ref,"maxvalue",2) - -end test_maxvalue - -function test_mean() - fs_name = "mean" - - fs = fs_22 - fs_m = bitmap(fs, bitmap(fs > 280, 1)) - - # single fields - f = fs - r = mean(f) - v = values(r) - v_ref = values(fs) - assert_equal(count(r),1, fs_name & " - count", 1) - assert(vec_same(v, v_ref), fs_name & " - values", 1) - - # known mean - f = fs & 2*fs & 3*fs - r = mean(f) - v = values(r) - v_ref = values(fs) * 2 - assert_equal(count(r),1, fs_name & " - count", 2) - assert(vec_same(v, v_ref), fs_name & " - values", 2) - - # real life example - f = read('monthly_avg.grib') - r = mean(f) - assert_equal(count(r),1, fs_name & " - count", 3) - v = values(r) - v_ref = v * 0 - for i=1 to count(f) do - v_ref = v_ref + values(f[i]) - end for - v_ref = v_ref / count(f) - assert(vec_same(v, v_ref), fs_name & " - values",3) - - # missing values - single field - f = fs_m - r = mean(f) - v = values(r) - v_ref = values(fs_m) - assert_equal(count(r),1, fs_name & " - count", 4) - assert(vec_same_missing(v, v_ref), fs_name & " - values", 4) - - # known mean - f = fs & 2*fs_m & 3*fs_m - r = mean(f) - v = values(r) - v_ref = values(fs_m) * 2 - assert_equal(count(r),1, fs_name & " - count", 5) - assert(vec_same_missing(v, v_ref), fs_name & " - values", 5) - - -end test_mean - -function test_mean_missing() - fs_name = "mean_missing" - - fs = fs_22 - fs_m = bitmap(fs, bitmap(fs > 280, 1)) - - # single fields - f = fs - r = mean(f, "missing") - v = values(r) - v_ref = values(fs) - assert_equal(count(r),1, fs_name & " - count", 1) - assert(vec_same(v, v_ref), fs_name & " - values", 1) - - # known mean - f = fs & 2*fs & 3*fs - r = mean(f, "missing") - v = values(r) - v_ref = values(fs) * 2 - assert_equal(count(r),1, fs_name & " - count", 2) - assert(vec_same(v, v_ref), fs_name & " - values", 2) - - # real life example - f = read('monthly_avg.grib') - r = mean(f, "missing") - assert_equal(count(r),1, fs_name & " - count", 3) - v = values(r) - v_ref = v * 0 - for i=1 to count(f) do - v_ref = v_ref + values(f[i]) - end for - v_ref = v_ref / count(f) - assert(vec_same(v, v_ref), fs_name & " - values",3) - - # missing values - single field - f = fs_m - r = mean(f, "missing") - v = values(r) - v_ref = values(fs_m) - assert_equal(count(r),1, fs_name & " - count", 4) - assert(vec_same_missing(v, v_ref), fs_name & " - values", 4) - - # multiple fields, in the second one there are some missing values - f = fs & fs_m & 2*fs - - # in the first point we only have missing values! - for i=1 to count(f) do - fv = values(f[i]) - fv[1] = vector_missing_value - f[i] = set_values(f[i], fv) - end for - - r = mean(f, "missing") - v = values(r) - - b1 = values(fs_m)*0 - b1 = nobitmap(b1,1) - b2 = values(fs_m)*0+1 - b2 = nobitmap(b2,0) - v_ref = values(fs)*(b1*(3./2.) + b2*(4./3.)) - v_ref[1] = vector_missing_value - - assert_equal(count(r),1, fs_name & " - count", 5) - assert(vec_same_missing(v, v_ref,1E-5), fs_name & " - values", 5) - -end test_mean_missing - -function test_mean_ew() - fs = fs_22 - - # const field global - r = mean_ew(fs*0+1) - v = values(r) - v_ref = v*0 + 1 - assert(vec_same(v, v_ref,1E-4), "mean_ew",1) - - # real field - r = mean_ew(fs) - v = values(r) - - nx = grib_get_long(fs,'Ni') - ny = grib_get_long(fs,'Nj') - assert(nx > 0,'mean_ew nx',2) - assert(ny > 0,'mean_ew ny',2) - v_ref = values(fs) - for j=0 to ny-1 do - s=0 - for i=1 to nx do - idx= j*nx+i - s = s + v_ref[idx] - end for - for i=1 to nx do - idx= j*nx+i - v_ref[idx] = s/nx - end for - end for - assert(vec_same(v, v_ref,1E-4), "mean_ew",2) - -end test_mean_ew - -function test_merge() - - fs = fs_22 - - r = fs & nil - assert_equal(count(fs), count(r),"merge count",1) - v = values(r) - v_ref = values(fs) - assert(vec_same(v,v_ref),"merge value",1) - - r = fs & 2*fs & -1*fs - assert_equal(3*count(fs), count(r),"merge count",2) - - v = values(r[1]) - v_ref = values(fs) - assert(vec_same(v,v_ref),"merge value [1]",2) - - v = values(r[2]) - v_ref = values(2*fs) - assert(vec_same(v,v_ref),"merge value [2]",2) - - v = values(r[3]) - v_ref = values(-1*fs) - assert(vec_same(v,v_ref),"merge value [3]",2) - - function levs(g) - return grib_get_double(g, 'level') - end levs - - # test calling the merge() function directly - fs_pl = read('xs_rgg_input.grib') - fs_ml = read('xs_ml_input.grib') - pl_levs = levs(fs_pl) - ml_levs = levs(fs_ml) - - m1 = merge(fs_pl) # single fieldset - assert(list_same(levs(m1), pl_levs),"merge levs",1) - - m1 = merge(fs_pl[1]) - assert_equal(levs(m1), pl_levs[1],"merge levs",2) - - m1 = merge(fs_pl[2]) - assert_equal(levs(m1), pl_levs[2],"merge levs",3) - - m1 = merge(fs_pl, fs_ml) - assert(list_same(levs(m1), pl_levs&ml_levs),"merge levs",4) - - m1 = merge(fs_pl[1], fs_ml[2]) - assert(list_same(levs(m1), [pl_levs[1]]&[ml_levs[2]]),"merge levs",5) - - m1 = merge(fs_pl[4,6], fs_ml[22,31]) - assert(list_same(levs(m1), pl_levs[4,6]&ml_levs[22,31]),"merge levs",6) - - m1 = merge(fs_pl, fs_ml[2], fs_ml[9], fs_pl[2,3], fs_pl) - assert(list_same(levs(m1), [1000,850,700,500,400,300,1,2,850,700,1000,850,700,500,400,300]),"merge levs",7) - -end test_merge - -function test_min() - - fs = fs_22 - - f = 3*fs & fs & 2*fs - r=min(f) - v = values(r) - v_ref = values(fs) - assert(vec_same(v,v_ref),"min",1) - - f = fs - g = 2*fs - r=min(f, g) - v = values(r) - v_ref = values(fs) - assert(vec_same(v,v_ref),"min",2) - - r=min(g, f) - v = values(r) - v_ref = values(fs) - assert(vec_same(v,v_ref),"min",3) - -end test_min - -function test_minvalue() - - fs = fs_22 - - f = 3*fs & fs & 2*fs - v = minvalue(f) - v_ref = minvalue(values(fs)) - assert_equal(v,v_ref,"minvalue",1) - - # area - area = [80, -120, -10, 120] - v = minvalue(f,area) - v_ref = 252.454589844 - assert_equal(v,v_ref,"minvalue",2) - -end test_minvalue - -function test_mod() - fs = fs_77 - - d = mod(fs,fs) - v = values(d) - v_ref = v*0 - assert(vec_same(v,v_ref),"mod",1) - - d = div(3*fs,2*fs) - v = values(d) - v_ref = v*1 - assert(vec_same(v,v_ref),"mod",2) - - f = fs * 0.2 * coslat(fs) + 10 - d = div(fs,f) - v = values(d) - v_ref = div(values(fs),values(f)) - assert(vec_same(v,v_ref),"mod",3) - - # here we need to use bitmap to avoid divison by 0 - f = fs * 0.2 * coslat(fs) - f = bitmap(f,bitmap(abs(f) < 1E-14 ,1)) - d = div(fs,f) - v = values(d) - v_ref = div(values(fs),values(f)) - assert(vec_same(v,v_ref),"mod",4) - -end test_mod - -function test_nobitmap() - - fs = read('t1000_LL_2x2_with_missing.grb') - - # single field - f = fs - r = nobitmap(f,1) - v = values(r) - vf = values(f) - assert_equal(count(r),count(f), "nobitmap count",1) - assert_equal(count(v),count(vf), "nobitmap value_count",1) - - for i=1 to count(v) do - - if vf[i] = vector_missing_value then - assert_equal(v[i],1,"nobitmap value [" & i & "]",1) - else - assert_equal(v[i],vf[i],"nobitmap value [" & i & "]",1) - end if - end for - - # multiple fields - f = fs & 2*fs - r = nobitmap(f,1) - assert_equal(count(r),count(f), "nobitmap count",2) - - for k=1 to count(r) do - v = values(r[k]) - vf = values(f[k]) - - assert_equal(count(v),count(vf), "nobitmap value_count f" & k,2) - - for i=1 to count(v) do - if vf[i] = vector_missing_value then - assert_equal(v[i],1,"nobitmap value f" & k & " [" & i & "]",2) - else - assert_equal(v[i],vf[i],"nobitmap value f" & k & " [" & i & "]",2) - end if - end for - end for - -end test_nobitmap - -function test_percentile() - - # populate a list of vectors with numbers that are easy to check their percentiles - num_vecs = 10 - num_vals = 4 # num vals per vector - - list_of_vectors = nil - for i = 1 to num_vecs do - vec = vector(num_vals) - for j = 1 to num_vals do - vec[j] = i * 10^j - end for - list_of_vectors = list_of_vectors & [vec] - end for - - # create a fieldset with 4 values only set the list of vectors as values - fs = read(data: fs_22, area: [20,40,30,50], grid: [10,10]) - f = nil - for i=1 to num_vecs do - f = f & (set_values(fs, list_of_vectors[i])) - end for - - # 50% - r = percentile(data: f, percentiles: [50]) - assert_equal(count(r), 1, "percentile nn count",1) - v = values(r) - assert(vec_same(v, |60,600,6000,60000|), "percentile nn value", 1) - - r = percentile(data: f, percentiles: 50) - assert_equal(count(r), 1, "percentile nn-num count",1) - v = values(r) - assert(vec_same(v, |60,600,6000,60000|), "percentile nn-num value", 1) - - r = percentile(data: f, percentiles: [50], interpolation: "nearest_neighbour") - assert_equal(count(r), 1, "percentile nn-a count",1) - v = values(r) - assert(vec_same(v, |60,600,6000,60000|), "percentile nn-a value", 1) - - r = percentile(data: f, percentiles: [50], interpolation: 'linear') - assert_equal(count(r), 1, "percentile lin count",1) - v = values(r) - assert(vec_same(v, |55,550,5500,55000|), "percentile lin value", 1) - - # 5% - r = percentile(data: f, percentiles: [5]) - assert_equal(count(r),1, "percentile nn count",2) - v = values(r) - assert(vec_same(v, |10,100,1000,10000|), "percentile nn value",2) - - r = percentile(data: f, percentiles: [5], interpolation: 'linear') - assert_equal(count(r),1, "percentile lin count",2) - v = values(r) - assert(vec_same(v, |10,100,1000,10000|), "percentile lin value",2) - - # 99% - r = percentile(data: f, percentiles: [99]) - assert_equal(count(r),1, "percentile nn count",3) - v = values(r) - assert(vec_same(v, |100,1000,10000,100000|), "percentile nn value",3) - - r = percentile(data: f, percentiles: [99], interpolation: 'linear') - assert_equal(count(r),1, "percentile lin count",3) - v = values(r) - assert(vec_same(v, |100,1000,10000,100000|), "percentile lin value",3) - - # list: 50%, 60% - r = percentile(data: f, percentiles: [50,60]) - assert_equal(count(r),2, "percentile nn count",4) - v_ref = [|60,600,6000,60000|,|70,700,7000,70000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same(v, v_ref[i]), "percentile nn value [" & i & "]",4) - end for - - r = percentile(data: f, percentiles: [50,60], interpolation: 'linear') - assert_equal(count(r),2, "percentile lin count",4) - v_ref = [|55,550,5500,55000|,|66,660,6600,66000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same(v, v_ref[i]), "percentile lin value [" & i & "]",4) - end for - - # list of more percentiles than we have fields in the input fieldset - r = percentile(data: f, percentiles: [1,2,3,4,5,6,7,8,9,50,60,80,99], interpolation: "nearest_neighbour") - assert_equal(count(r),13, "percentile lin [13] count",5) - v_ref = [|10, 100, 1000, 10000|, - |10, 100, 1000, 10000|, - |10, 100, 1000, 10000|, - |10, 100, 1000, 10000|, - |10, 100, 1000, 10000|, - |10, 100, 1000, 10000|, - |10, 100, 1000, 10000|, - |10, 100, 1000, 10000|, - |10, 100, 1000, 10000|, - |60, 600, 6000, 60000|, - |70, 700, 7000, 70000|, - |90, 900, 9000, 90000|, - |100, 1000, 10000, 100000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same(v, v_ref[i]), "percentile lin value [" & i & "]",5) - end for - -end test_percentile - - -function test_percentile_missing_1() - - # test Percentile with compute_if_missing: 'off' - # - any grid point with at least one missing value will - # have a missing value as its result - - - # populate a list of vectors with numbers that are easy to check their percentiles - num_vecs = 10 - num_vals = 4 # num vals per vector - vm = vector_missing_value - - list_of_vectors = [ - |10,100,1000,10000|, - |20,vm, 2000,20000|, - |30,300,3000,30000|, - |40,400,4000,40000|, - |50,vm, 5000,50000|, - |60,vm, 6000,60000|, - |70,vm, 7000,70000|, - |80,800,8000,80000|, - |90,900,9000,90000|, - |100,vm,10000,100000| - ] - - # create a fieldset with 4 values only set the list of vectors as values - fs = read(data: fs_22, area: [20,40,30,50], grid: [10,10]) - f = nil - for i=1 to num_vecs do - f = f & (set_values(fs, list_of_vectors[i])) - end for - - - # 50% - r = percentile(data: f, percentiles: [50], compute_if_missing: 'off') - assert_equal(count(r), 1, "percentile_missing nn count",1) - v = values(r) - print('values: ', v) - assert(vec_same_missing(v, |60,vm,6000,60000|), "percentile_missing nn value", 1) - - r = percentile(data: f, percentiles: 50, compute_if_missing: 'off') - assert_equal(count(r), 1, "percentile_missing nn-num count",1) - v = values(r) - assert(vec_same_missing(v, |60,vm,6000,60000|), "percentile_missing nn-num value", 1) - - r = percentile(data: f, percentiles: [50], interpolation: "nearest_neighbour", compute_if_missing: 'off') - assert_equal(count(r), 1, "percentile_missing nn-a count",1) - v = values(r) - assert(vec_same_missing(v, |60,vm,6000,60000|), "percentile nn-a value", 1) - - r = percentile(data: f, percentiles: [50], interpolation: 'linear', compute_if_missing: 'off') - assert_equal(count(r), 1, "percentile_missing lin count",1) - v = values(r) - assert(vec_same_missing(v, |55,vm,5500,55000|), "percentile_missing lin value", 1) - - # 5% - r = percentile(data: f, percentiles: [5], compute_if_missing: 'off') - assert_equal(count(r),1, "percentile_missing nn count",2) - v = values(r) - assert(vec_same_missing(v, |10,vm,1000,10000|), "percentile_missing nn value",2) - - r = percentile(data: f, percentiles: [5], interpolation: 'linear', compute_if_missing: 'off') - assert_equal(count(r),1, "percentile_missing lin count",2) - v = values(r) - assert(vec_same_missing(v, |10,vm,1000,10000|), "percentile_missing lin value",2) - - # 99% - r = percentile(data: f, percentiles: [99], compute_if_missing: 'off') - assert_equal(count(r),1, "percentile_missing nn count",3) - v = values(r) - assert(vec_same_missing(v, |100,vm,10000,100000|), "percentile_missing nn value",3) - - r = percentile(data: f, percentiles: [99], interpolation: 'linear', compute_if_missing: 'off') - assert_equal(count(r),1, "percentile_missing lin count",3) - v = values(r) - assert(vec_same_missing(v, |100,vm,10000,100000|), "percentile_missing lin value",3) - - # list: 50%, 60% - r = percentile(data: f, percentiles: [50,60], compute_if_missing: 'off') - assert_equal(count(r),2, "percentile_missing nn count",4) - v_ref = [|60,vm,6000,60000|,|70,vm,7000,70000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing nn value [" & i & "]",4) - end for - - r = percentile(data: f, percentiles: [50,60], interpolation: 'linear', compute_if_missing: 'off') - assert_equal(count(r),2, "percentile_missing lin count",4) - v_ref = [|55,vm,5500,55000|,|66,vm,6600,66000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing lin value [" & i & "]",4) - end for - - # list of more percentiles than we have fields in the input fieldset - r = percentile(data: f, percentiles: [1,2,3,4,5,6,7,8,9,50,60,80,99], - interpolation: "nearest_neighbour", compute_if_missing: 'off') - assert_equal(count(r),13, "percentile_missing lin [13] count",5) - v_ref = [|10, vm, 1000, 10000|, - |10, vm, 1000, 10000|, - |10, vm, 1000, 10000|, - |10, vm, 1000, 10000|, - |10, vm, 1000, 10000|, - |10, vm, 1000, 10000|, - |10, vm, 1000, 10000|, - |10, vm, 1000, 10000|, - |10, vm, 1000, 10000|, - |60, vm, 6000, 60000|, - |70, vm, 7000, 70000|, - |90, vm, 9000, 90000|, - |100, vm, 10000, 100000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing lin value [" & i & "]",5) - end for - -end test_percentile_missing_1 - - -function test_percentile_missing_2() - ## test Percentile module with a gridpoint that has missing - ## values in every field - - # populate a list of vectors with numbers that are easy to check their percentiles - num_vecs = 10 - num_vals = 4 # num vals per vector - vm = vector_missing_value - - list_of_vectors = [ - |10,100, vm,10000|, - |20,200, vm,20000|, - |30,300, vm,30000|, - |40,400, vm,40000|, - |50,500, vm,50000|, - |60,600, vm,60000|, - |70,700, vm,70000|, - |80,800, vm,80000|, - |90,900, vm,90000|, - |100,1000,vm,100000| - ] - - # create a fieldset with 4 values only set the list of vectors as values - fs = read(data: fs_22, area: [20,40,30,50], grid: [10,10]) - f = nil - for i=1 to num_vecs do - f = f & (set_values(fs, list_of_vectors[i])) - end for - - - # 50% - r = percentile(data: f, percentiles: [50]) - assert_equal(count(r), 1, "percentile_missing_2 nn count",1) - v = values(r) - print('values: ', v) - assert(vec_same_missing(v, |60,600,vm,60000|), "percentile_missing_2 nn value", 1) - - r = percentile(data: f, percentiles: 50) - assert_equal(count(r), 1, "percentile_missing_2 nn-num count",1) - v = values(r) - assert(vec_same_missing(v, |60,600,vm,60000|), "percentile_missing_2 nn-num value", 1) - - r = percentile(data: f, percentiles: 50, compute_if_missing: 'off') - assert_equal(count(r), 1, "percentile_missing_2 nn-num count",1) - v = values(r) - assert(vec_same_missing(v, |60,600,vm,60000|), "percentile_missing_2 nn-num value", 1) - - r = percentile(data: f, percentiles: [50], interpolation: "nearest_neighbour") - assert_equal(count(r), 1, "percentile_missing_2 nn-a count",1) - v = values(r) - assert(vec_same_missing(v, |60,600,vm,60000|), "percentile nn-a value", 1) - - r = percentile(data: f, percentiles: [50], interpolation: 'linear') - assert_equal(count(r), 1, "percentile_missing_2 lin count",1) - v = values(r) - assert(vec_same_missing(v, |55,550,vm,55000|), "percentile_missing_2 lin value", 1) - - # 5% - r = percentile(data: f, percentiles: [5]) - assert_equal(count(r),1, "percentile_missing_2 nn count",2) - v = values(r) - assert(vec_same_missing(v, |10,100,vm,10000|), "percentile_missing_2 nn value",2) - - r = percentile(data: f, percentiles: [5], interpolation: 'linear') - assert_equal(count(r),1, "percentile_missing_2 lin count",2) - v = values(r) - assert(vec_same_missing(v, |10,100,vm,10000|), "percentile_missing_2 lin value",2) - - # 99% - r = percentile(data: f, percentiles: [99]) - assert_equal(count(r),1, "percentile_missing_2 nn count",3) - v = values(r) - assert(vec_same_missing(v, |100,1000,vm,100000|), "percentile_missing_2 nn value",3) - - r = percentile(data: f, percentiles: [99], interpolation: 'linear') - assert_equal(count(r),1, "percentile_missing_2 lin count",3) - v = values(r) - assert(vec_same_missing(v, |100,1000,vm,100000|), "percentile_missing_2 lin value",3) - - # list: 50%, 60% - r = percentile(data: f, percentiles: [50,60]) - assert_equal(count(r),2, "percentile_missing_2 nn count",4) - v_ref = [|60,600,vm,60000|,|70,700,vm,70000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing_2 nn value [" & i & "]",4) - end for - - r = percentile(data: f, percentiles: [50,60], interpolation: 'linear') - assert_equal(count(r),2, "percentile_missing_2 lin count",4) - v_ref = [|55,550,vm,55000|,|66,660,vm,66000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing_2 lin value [" & i & "]",4) - end for - - # list of more percentiles than we have fields in the input fieldset - r = percentile(data: f, percentiles: [1,2,3,4,5,6,7,8,9,50,60,80,99], interpolation: "nearest_neighbour") - assert_equal(count(r),13, "percentile_missing_2 lin [13] count",5) - v_ref = [|10, 100, vm, 10000|, - |10, 100, vm, 10000|, - |10, 100, vm, 10000|, - |10, 100, vm, 10000|, - |10, 100, vm, 10000|, - |10, 100, vm, 10000|, - |10, 100, vm, 10000|, - |10, 100, vm, 10000|, - |10, 100, vm, 10000|, - |60, 600, vm, 60000|, - |70, 700, vm, 70000|, - |90, 900, vm, 90000|, - |100,1000,vm, 100000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing_2 lin value [" & i & "]",5) - end for - -end test_percentile_missing_2 - - -function test_percentile_missing_3() - - ## test the Percentile module with COMPUTE_IF_MISSING_PRESENT=ON - ## compute_if_missing: 'on' is by default - - # populate a list of vectors with numbers that are easy to check their percentiles - num_vecs = 10 - num_vals = 4 # num vals per vector - vm = vector_missing_value - - list_of_vectors = [ - |10,100,1000,10000|, - |20,vm, 2000,20000|, - |30,300,3000,30000|, - |40,400,4000,40000|, - |50,vm, 5000,50000|, - |60,vm, 6000,60000|, - |70,vm, 7000,70000|, - |80,800,8000,80000|, - |90,900,9000,90000|, - |100,vm,10000,100000| - ] - - # create a fieldset with 4 values only set the list of vectors as values - fs = read(data: fs_22, area: [20,40,30,50], grid: [10,10]) - f = nil - for i=1 to num_vecs do - f = f & (set_values(fs, list_of_vectors[i])) - end for - - - # 50% - r = percentile(data: f, percentiles: [50]) - assert_equal(count(r), 1, "percentile_missing_3 nn count",1) - v = values(r) - print('values: ', v) - assert(vec_same_missing(v, |60,400,6000,60000|), "percentile_missing_3 nn value", 1) - - r = percentile(data: f, percentiles: 50) - assert_equal(count(r), 1, "percentile_missing_3 nn-num count",1) - v = values(r) - assert(vec_same_missing(v, |60,400,6000,60000|), "percentile_missing_3 nn-num value", 1) - - r = percentile(data: f, percentiles: [50], interpolation: "nearest_neighbour") - assert_equal(count(r), 1, "percentile_missing_3 nn-a count",1) - v = values(r) - assert(vec_same_missing(v, |60,400,6000,60000|), "percentile_missing_3 nn-a value", 1) - - r = percentile(data: f, percentiles: [50], interpolation: 'linear') - assert_equal(count(r), 1, "percentile_missing_3 lin count",1) - v = values(r) - assert(vec_same_missing(v, |55,400,5500,55000|), "percentile_missing_3 lin value", 1) - - # 5% - r = percentile(data: f, percentiles: [5]) - assert_equal(count(r),1, "percentile_missing_3 nn count",2) - v = values(r) - assert(vec_same_missing(v, |10,100,1000,10000|), "percentile_missing_3 nn value",2) - - r = percentile(data: f, percentiles: [5], interpolation: 'linear') - assert_equal(count(r),1, "percentile_missing_3 lin count",2) - v = values(r) - assert(vec_same_missing(v, |10,100,1000,10000|), "percentile_missing_3 lin value",2) - - # 99% - r = percentile(data: f, percentiles: [99]) - assert_equal(count(r),1, "percentile_missing_3 nn count",3) - v = values(r) - assert(vec_same_missing(v, |100,900,10000,100000|), "percentile_missing_3 nn value",3) - - r = percentile(data: f, percentiles: [99], interpolation: 'linear') - assert_equal(count(r),1, "percentile_missing_3 lin count",3) - v = values(r) - assert(vec_same_missing(v, |100,900,10000,100000|), "percentile_missing_3 lin value",3) - - # list: 50%, 60% - r = percentile(data: f, percentiles: [50,60]) - assert_equal(count(r),2, "percentile_missing_3 nn count",4) - v_ref = [|60,400,6000,60000|,|70,800,7000,70000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing_3 nn value [" & i & "]",4) - end for - - r = percentile(data: f, percentiles: [50,60], - interpolation: 'linear') - assert_equal(count(r),2, "percentile_missing_3 lin count",4) - v_ref = [|55,400,5500,55000|,|66,640,6600,66000|] - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing_3 lin value [" & i & "]",4) - end for - - # list of more percentiles than we have fields in the input fieldset - r = percentile(data: f, percentiles: [1,2,3,4,5,6,7,8,9,50,60,80,99], - interpolation: "nearest_neighbour") - assert_equal(count(r),13, "percentile_missing_3 lin [13] count",5) - v_ref = [|10, 100, 1000, 10000|, # 1 - |10, 100, 1000, 10000|, # 2 - |10, 100, 1000, 10000|, # 3 - |10, 100, 1000, 10000|, # 4 - |10, 100, 1000, 10000|, # 5 - |10, 100, 1000, 10000|, # 6 - |10, 100, 1000, 10000|, # 7 - |10, 100, 1000, 10000|, # 8 - |10, 100, 1000, 10000|, # 9 - |60, 400, 6000, 60000|, # 50 - |70, 800, 7000, 70000|, # 60 - |90, 900, 9000, 90000|, # 80 - |100,900,10000, 100000|] # 99 - for i=1 to count(r) do - v = values(r[i]) - assert(vec_same_missing(v, v_ref[i]), "percentile_missing_3 lin value [" & i & "]",5) - end for - -end test_percentile_missing_3 - - -# --------------------------------------------------- -# mars filter and double filter, index filter and double filter -function test_read() - a = read('hindcast.grib') - - lstep = [0,24,36,48,72] - b = read(data:a, step:lstep) - assert(steps_equal(b,lstep), 'mars single filter') - - c = read(data:b) - assert(steps_equal(c,lstep), 'mars double filter') - - c = read(data:b, step:[24, 72]) - assert(steps_equal(c,[24,72]), 'mars double filter (2)') - - c = b[2,4] - assert(steps_equal(c,[24,36,48]), 'index filter') - - d = read(data:c) - assert(steps_equal(d,[24,36,48]), 'index double filter') - - e = read('tuv_pl.grib') - f = read(data: e, param: 'u') - assert(levels_equal(f, [1000,850,700,500,400,300]), 'mars filter 1 level') - assert(params_equal(f, ['u','u','u','u','u','u']), 'mars filter 1 param') - - g = read(data: f, levelist: [700,400]) - assert(levels_equal(g, [700,400]), 'mars filter 2 level') - assert(params_equal(g, ['u','u']), 'mars filter 2 param') - - h = merge(f[3,5], f[1,2]) - assert(levels_equal(g, [700,400]), 'mars filter on subset level a') - g = read(data: h, levelist: [500,1000]) - assert(levels_equal(g, [500,1000]), 'mars filter on subset level b') - -end test_read - -function test_read_sort() - - fn_name = "read_sort" - - # 1. date and time - a_dates = [402, 401, 310, 310, 304, 513, 520, 405, 311, 501, 501] - b_dates = [304, 310, 310, 311, 401, 402, 405, 501, 501, 513, 520] - b_times = [600, 600, 1800, 600, 600, 600, 600, 600, 1800, 1800, 1800] - - a = read('daily_clims.grib') - assert_equal(grib_get_long(a, 'date'), a_dates, fn_name & " date ori", 1) - b = read(data:a, order:'sorted') - assert_equal(grib_get_long(b, 'date'), b_dates, fn_name & " date sorted", 1) - assert_equal(grib_get_long(b, 'time'), b_times, fn_name & " time sorted", 1) - - # 2. step - sorted initial state - f = read(source: "ll_steps_168.grib") - ref = [0,12,24,36,48,60,72,84,96,108,120,132,144,156,168] - assert_equal(grib_get_long(f, "step"), ref, fn_name & " step ori", 2) - - f = read(source: "ll_steps_168.grib", order: "sorted") - assert_equal(grib_get_long(f, "step"), ref, fn_name & " step sorted", 2) - - # 3. step - unsorted initial state - f = read(source: "ll_steps_168.grib") - ref_unsorted = [36,108,12,24,0,48,60,72,84,96,120,132,144,156,168] - ref_sorted = [0,12,24,36,48,60,72,84,96,108,120,132,144,156,168] - g = nil - for i=1 to count(f) do - g = g & grib_set_long(f[i], ["step", ref_unsorted[i]]) - end for - g = g + 0 - assert_equal(grib_get_long(g, "step"), ref_unsorted, fn_name & " step ori", 3) - - h = read(data: g) + 0 - assert_equal(grib_get_long(h, "step"), ref_unsorted, fn_name & " step ori", 3) - - h = read(data: g, order: "as_is") + 0 - assert_equal(grib_get_long(h, "step"), ref_unsorted, fn_name & " step order=as_is", 3) - - h = read(data: g, order: 0) + 0 - assert_equal(grib_get_long(h, "step"), ref_unsorted, fn_name & " step order=0", 3) - - h = read(data: g, order: 1) + 0 - assert_equal(grib_get_long(h, "step"), ref_sorted, fn_name & " step order=1", 3) - - h = read(data: g, order: "sorted") + 0 - assert_equal(grib_get_long(h, "step"), ref_sorted, fn_name & " step order=sorted", 3) - - # 4. level - f = read(source: "ml2pl_ref.grib") - ref_unsorted = [100, 925, 500, 1000, 850] - ref_sorted = [100, 500, 850, 925, 1000] - assert_equal(grib_get_long(f, "level"), ref_unsorted, fn_name & " level ori", 4) - - f = read(source: "ml2pl_ref.grib", order: "sorted") - assert_equal(grib_get_long(f, "level"), ref_sorted, fn_name & " level sorted", 4) - -end test_read_sort - -function test_rmask() - fs = fs_22 - f_ref = read('rmask_ref.grib') - - lat_c = [48, -40, 90] - lon_c = [19,-60, 0] - rad = [1000000, 7000000, 6000000] - - for i=1 to count(f_ref) do - r = rmask(fs, lat_c[i], lon_c[i], rad[i]) - v = values(r) - v_ref = values(f_ref[i]) - assert(vec_same(v,v_ref),"rmask",i) - end for - - # list as argument - r = rmask(fs, [lat_c[1], lon_c[1], rad[1]]) - v = values(r) - v_ref = values(f_ref[1]) - assert(vec_same(v,v_ref),"rmask",4) - - # same, but Pythonesque way of supplying missing=False - r = rmask(fs, [lat_c[1], lon_c[1], rad[1]], 'missing', 'off') - v = values(r) - v_ref = values(f_ref[1]) - assert(vec_same(v,v_ref),"rmask_py",1) - -end test_rmask - -function test_rmask_missing() - fs = fs_22 - f_ref = read('rmask_ref.grib') - f_ref = bitmap(f_ref, bitmap(f_ref, 0)) - - lat_c = [48, -40, 90] - lon_c = [19,-60, 0] - rad = [1000000, 7000000, 6000000] - - for i=1 to count(f_ref) do - r = rmask(fs, lat_c[i], lon_c[i], rad[i], 'missing') - v = values(r) - v_ref = values(f_ref[i])-1 + values(fs) - assert(vec_same(v,v_ref),"rmask_missing",i) - end for - - # list as argument - r = rmask(fs, [lat_c[1], lon_c[1], rad[1]], 'missing') - v = values(r) - v_ref = values(f_ref[1])-1 + values(fs) - assert(vec_same(v,v_ref),"rmask_missing",4) - - # same, but Pythonesque way of supplying 'missing' - r = rmask(fs, [lat_c[1], lon_c[1], rad[1]], 'missing', 'on') - v = values(r) - v_ref = values(f_ref[1])-1 + values(fs) - assert(vec_same(v,v_ref),"rmask_missing_py",1) - - -end test_rmask_missing - -function test_rms_a() - - fs = fs_22 - - # global - - # single field - v = rms_a(fs) - v_ref = 289.241066893 - assert_equal(v, v_ref, "rms_a",1) - - # real life example - f1 = read('monthly_avg.grib') - v = vector(rms_a(f1)) - assert_equal(count(v),count(f1), "rms_a_count", 2) - v_ref = |284.463,288.644,292.036,294.422,293.681,291.267,288.863,289.005| - assert(vec_same(v, v_ref,1E-2), "rms_a",2) - - # sub area - area = [60, -20, 30, 28] - - v = rms_a(fs, area) - v_ref = 288.33352857 - assert_equal(v, v_ref, "rms_a",3) - - f1 = read('monthly_avg.grib') - v = vector(rms_a(f1, area)) - assert_equal(count(v),count(f1), "rsm_a_count", 4) - v_ref = |322.811,325.302,346.721,356.758,354.736,328.896,313.896,303.971| - assert(vec_same(v, v_ref,1E-2), "rms_a",4) - -end test_rms_a - - -function test_set_values() - fs = fs_22 - - # single field - v = values(fs) - v = v*0+2 - r = set_values(fs, v) - mnv = minvalue(r) - mxv = maxvalue(r) - assert_equal(mnv,2,"set_values min",1) - assert_equal(mxv,2,"set_values max",1) - - # multiple fields - single vectors - f = fs_22 & fs_22 - v = values(f) - v1 = v[1]*0+2 - r = set_values(f,v1) - assert_equal(count(r),2,"set_values multi count",1) - mnv = minvalue(r[1]) - mxv = maxvalue(r[1]) - assert_equal(mnv,2,"set_values multi max a",1) - assert_equal(mxv,2,"set_values multi min a",1) - mnv = minvalue(r[2]) - mxv = maxvalue(r[2]) - assert_equal(mnv,2,"set_values multi max b",1) - assert_equal(mxv,2,"set_values multi min b",1) - - # multiple fields - multiple vectors - f = fs_22 & fs_22 - v = values(f) - v1 = v[1]*0+2 - v2 = v[1]*0-1 - r = set_values(f,[v1,v2]) - assert_equal(count(r),2,"set_values multi count",2) - mnv = minvalue(r[1]) - mxv = maxvalue(r[1]) - assert_equal(mnv,2,"set_values multi max a",2) - assert_equal(mxv,2,"set_values multi min a",2) - mnv = minvalue(r[2]) - mxv = maxvalue(r[2]) - assert_equal(mnv,-1,"set_values multi max b",2) - assert_equal(mxv,-1,"set_values multi min b",2) - - # multiple fields - single vector - resize - f = fs_22 & fs_22 - v = values(f) - v1 = v[1]*0+2 - v1 = v1[1,count(v1) - 100] - r = set_values(f,v1,"resize") - assert_equal(count(r),2,"set_values multi count",3) - mnv = minvalue(r[1]) - mxv = maxvalue(r[1]) - assert_equal(mnv,2,"set_values multi max a",3) - assert_equal(mxv,2,"set_values multi min a",3) - mnv = minvalue(r[2]) - mxv = maxvalue(r[2]) - assert_equal(mnv,2,"set_values multi max b",3) - assert_equal(mxv,2,"set_values multi min b",3) - - - f = fs_22 & fs_22 - v = values(f) - v1 = v[1]*0+2 - v1 = v1 & |2,2,2,2| - r = set_values(f,v1,"resize") - assert_equal(count(r),2,"set_values multi count",4) - mnv = minvalue(r[1]) - mxv = maxvalue(r[1]) - assert_equal(mnv,2,"set_values multi max a",4) - assert_equal(mxv,2,"set_values multi min a",4) - mnv = minvalue(r[2]) - mxv = maxvalue(r[2]) - assert_equal(mnv,2,"set_values multi max b",4) - assert_equal(mxv,2,"set_values multi min b",4) - - # multiple fields - multiple vectors - resize - f = fs_22 & fs_22 - v = values(f) - v1 = v[1]*0+2 - v2 = v[1]*0-1 - v1 = v1[1,count(v1) - 100] - v2 = v2[1,count(v2) - 1000] - r = set_values(f,[v1,v2],"resize") - assert_equal(count(r),2,"set_values multi count",5) - mnv = minvalue(r[1]) - mxv = maxvalue(r[1]) - assert_equal(mnv,2,"set_values multi max a",5) - assert_equal(mxv,2,"set_values multi min a",5) - mnv = minvalue(r[2]) - mxv = maxvalue(r[2]) - assert_equal(mnv,-1,"set_values multi max b",5) - assert_equal(mxv,-1,"set_values multi min b",5) - -end test_set_values - -function test_sinlat() - fs = fs_77 - eps = 1E-6 - v = values(sinlat(fs)) - v_ref = sin(pi * latitudes(fs) / 180.) - assert(vec_same(v, v_ref, eps), "sinlat", 1) -end test_sinlat - -function test_tanlat() - fs = fs_77 - eps = 1E-6 - v = values(tanlat(fs)) - lats = latitudes(fs) - lats = lats + bitmap(abs(lats) > 90-1E-7, 1) - v_ref = tan(pi * lats / 180.) - assert(vec_same_missing(v, v_ref, eps), "tanlat", 1) -end test_tanlat - -function test_solar_zenith_angle() - fn_name = "solar_zenith_angle" - - fs = read("solar_zenith_angle.grib") - f_in = fs[1,6] - f_ref = fs[7,12] - - r = solar_zenith_angle(f_in) - - # fs =0 - # write("solar_zenith_angle.grib", f_in, r) - assert_equal(count(r),count(f_ref),fn_name & " count",1) - for i=1 to count(r) do - v = values(r[i]) - v_ref = values(f_ref[i]) - assert(vec_same(v, v_ref, 1E-6), fn_name & " value-" & i, 1) - end for - - # some obvious cases - - # get data on 0.5x0.5 grid - hr = read(data: f_in[1], grid:[0.5, 0.5]) - lat = |0,23.5,-23.5| - lon = |0,0,0| - - # spring equinox - ft = grib_set(hr, ["dataDate", 20180321, "dataTime",0, "step", 12]) - r = solar_zenith_angle(ft) - v_ref = |0.0301904268563, 23.4698113985, 23.5301904269| - v = nearest_gridpoint(r, lat, lon) - assert(vec_same(v, v_ref, 1E-5), fn_name & " spring", 2) - - # summer solstice - ft = grib_set(hr, ["dataDate", 20180621, "dataTime",0, "step", 12]) - r = solar_zenith_angle(ft) - v_ref = |23.4382684194, 0.0617272816598, 46.9382684194| - v = nearest_gridpoint(r, lat, lon) - assert(vec_same(v, v_ref, 1E-5), fn_name & " summer", 2) - - # autumn equinox - ft = grib_set(hr, ["dataDate", 20180923, "dataTime",0, "step", 12]) - r = solar_zenith_angle(ft) - v_ref = |0.133450090885,23.3665433526,23.6334500909| - v = nearest_gridpoint(r, lat, lon) - assert(vec_same(v, v_ref, 1E-5), fn_name & " autumn", 2) - - # winter solstice - ft = grib_set(hr, ["dataDate", 20181221, "dataTime",0, "step", 12]) - r = solar_zenith_angle(ft) - v_ref = |23.4350353479, 46.9350353479, 0.0649639368057| - v = nearest_gridpoint(r, lat, lon) - assert(vec_same(v, v_ref, 1E-5), fn_name & " winter", 2) - - # test cosine option - r = solar_zenith_angle(ft, to_cosine:"on") - v_ref = cos(v_ref * acos(-1)/180) - v = nearest_gridpoint(r, lat, lon) - assert(vec_same(v, v_ref, 1E-5), fn_name & " cosine", 3) - - assert_equal(grib_get_long(r, "paramId"), 214001, - fn_name & " cosine paramId", 3) - -end test_solar_zenith_angle - - -function test_sort() - fs = read("sort.grib") - - # default - dateLst =["20190603","20190604","20190605"] - timeLst = ["0000","1200"] - stepLst = ["0","6","12","18"] - numberLst = ["1","2","3"] - levelLst = ["300","500","700"] - paramLst = ["130", "131", "133"] # (t,u,q) - v_ref = make_sort_reference(dateLst,timeLst,stepLst,numberLst,levelLst,paramLst) - - r = sort(fs) - v = grib_get(r, ['date','time','step','number','level','paramId']) - assert_equal(count(v),count(v_ref),"sort count",1) - for i=1 to count(v) do - assert_equal(v[i],v_ref[i],"sort +" & i,1) - end for - - # custom order - step - r = sort(fs,"step") - v = grib_get(r, ['step:l','date','time','number','level','paramId']) - v_ref = grib_get(fs, ['step:l','date','time','number','level','paramId']) - v_ref = sort(v_ref,'compare_for_sort_test_1_asc') - - assert_equal(count(v),count(v_ref),"sort count",2) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,2) - end for - - # custom order - param - r = sort(fs,"param") - v = grib_get(r, ['paramId:l','date','time','step','number','level']) - v_ref = grib_get(fs, ['paramId:l','date','time','step','number','level']) - v_ref = sort(v_ref,'compare_for_sort_test_1_asc') - - assert_equal(count(v),count(v_ref),"sort count",3) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,3) - end for - - # custom order - levelist - r = sort(fs,"levelist") - v = grib_get(r, ['level:l','date','time','step','number','paramId']) - v_ref = grib_get(fs, ['level:l','date','time','step','number','paramId']) - v_ref = sort(v_ref,'compare_for_sort_test_1_asc') - - assert_equal(count(v),count(v_ref),"sort count",4) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,4) - end for - - # custom order - date - r = sort(fs,"date") - v = grib_get(r, ['date','time','step','number','level','paramId']) - v_ref = grib_get(fs, ['date','time','step','number','level','paramId']) - v_ref = sort(v_ref,'compare_for_sort_test_1_asc') - - assert_equal(count(v),count(v_ref),"sort count",5) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,5) - end for - - # custom order - time - r = sort(fs,"time") - v = grib_get(r, ['time:l','date','step','number','level','paramId']) - v_ref = grib_get(fs, ['time:l','date','step','number','level','paramId']) - v_ref = sort(v_ref,'compare_for_sort_test_1_asc') - - assert_equal(count(v),count(v_ref),"sort count",6) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,6) - end for - - # custom order - number - r = sort(fs,"number") - v = grib_get(r, ['number:l','date','time','step','level','paramId']) - v_ref = grib_get(fs, ['number:l','date','time','step','level','paramId']) - v_ref = sort(v_ref,'compare_for_sort_test_1_asc') - - assert_equal(count(v),count(v_ref),"sort count",7) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,7) - end for - - # custom order - param + "<" (ascending) - r = sort(fs,"param", "<") - v = grib_get(r, ['paramId:l','date','time','step','number','level']) - v_ref = grib_get(fs, ['paramId:l','date','time','step','number','level']) - v_ref = sort(v_ref,'compare_for_sort_test_1_asc') - - assert_equal(count(v),count(v_ref),"sort count",8) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,8) - end for - - # custom order - param + ">" (descending) - r = sort(fs,"param", ">") - v = grib_get(r, ['paramId:l','date','time','step','number','level']) - v_ref = grib_get(fs, ['paramId:l','date','time','step','number','level']) - v_ref = sort(v_ref,'compare_for_sort_test_1_desc') - assert_equal(count(v),count(v_ref),"sort count",9) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,9) - end for - - # custom order - [param,level] - r = sort(fs,["param","levelist"]) - v = grib_get(r, ['paramId:l','level:l','date','time','step','number']) - v_ref = grib_get(fs, ['paramId:l','level:l','date','time','step','number']) - v_ref = sort(v_ref,'compare_for_sort_test_2_asc') - - assert_equal(count(v),count(v_ref),"sort count",10) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,10.1) - assert_equal(v[i][2],v_ref[i][2],"sort +" & i,10.2) - end for - - # custom order - [param,level] + "<" (ascending) - r = sort(fs,["param","levelist"],"<") - v = grib_get(r, ['paramId:l','level:l','date','time','step','number']) - v_ref = grib_get(fs, ['paramId:l','level:l','date','time','step','number']) - v_ref = sort(v_ref,'compare_for_sort_test_2_asc') - - assert_equal(count(v),count(v_ref),"sort count",11) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,11.1) - assert_equal(v[i][2],v_ref[i][2],"sort +" & i,11.2) - end for - - # custom order - [param,level] + ">" (descending) - r = sort(fs,["param","levelist"],">") - v = grib_get(r, ['paramId:l','level:l','date','time','step','number']) - v_ref = grib_get(fs, ['paramId:l','level:l','date','time','step','number']) - v_ref = sort(v_ref,'compare_for_sort_test_2_desc') - - assert_equal(count(v),count(v_ref),"sort count",12) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,12.1) - assert_equal(v[i][2],v_ref[i][2],"sort +" & i,12.2) - end for - - # custom order - [param,level] + ">","<" (descending, ascending) - r = sort(fs,["param","levelist"],[">","<"]) - v = grib_get(r, ['paramId:l','level:l','date','time','step','number']) - v_ref = grib_get(fs, ['paramId:l','level:l','date','time','step','number']) - v_ref = sort(v_ref,'compare_for_sort_test_2_desc_asc') - - assert_equal(count(v),count(v_ref),"sort count",13) - for i=1 to count(v) do - assert_equal(v[i][1],v_ref[i][1],"sort +" & i,13.1) - assert_equal(v[i][2],v_ref[i][2],"sort +" & i,13.2) - end for - -end test_sort - - - -function test_speed() - fs = read("tuv_pl.grib") - u = read(data: fs, param: "u") - v = read(data: fs, param: "v") - - u_val = values(u[1]) - v_val = values(v[1]) - u_val_test = |0, 1, 1, 1, 3, -1, -1, -1, 0| - v_val_test = |1, 1, 0, -1, 4, -1, 0, 1, 0| - d_ref_test = |1, 1.414, 1, 1.414, 5, 1.414, 1, 1.414, 0| - - for i=1 to count(u_val_test) do - u_val[i] = u_val_test[i] - v_val[i] = v_val_test[i] - end for - - u_t = set_values(u[1], u_val) - v_t = set_values(v[1], v_val) - - u_t = u_t & u_t - v_t = v_t & v_t - - d = speed(u_t, v_t) - assert(count(d) = 2, "speed_count", 1) - for i=1 to count(d) do - d_val = values(d[i])[1, count(d_ref_test)] - assert(vec_same(d_val, d_ref_test, 0.0005), "speed " & i) - assert(grib_get_long(d[i], "paramId")=10, "speed paramId") - end for - - - # test missing values - u_t = bitmap(u_t[1], bitmap(u_t[1] > 0.9, 1)) - v_t = bitmap(v_t[1], bitmap(v_t[1] < -0.9, 1)) - d = speed(u_t, v_t) - assert(count(d) = 1, "speed_count bitmap") - assert(grib_get_long(d, "paramId")=10, "speed paramId bitmap") - d_val = values(d)[1, count(d_ref_test)] - d_ref_test = |1,vector_missing_value,vector_missing_value,vector_missing_value,vector_missing_value,vector_missing_value,1,1.414,0| - assert(vec_same_missing(d_val, d_ref_test, 0.0005), "speed bitmap" ) - - - # the whole field - u_val = values(u[1]) - v_val = values(v[1]) - spd_ref_vals = sqrt((u_val*u_val) + (v_val*v_val)) - spd_test_vals = values(speed(u[1], v[1])) - assert(vec_same_missing(spd_test_vals, spd_ref_vals, 0.00005), "speed field" ) - - - # multi-fields - spd_test_vals = values(speed(u, v)) - for i = 1 to count(u) do - u_val = values(u[i]) - v_val = values(v[i]) - spd_ref_vals = sqrt((u_val*u_val) + (v_val*v_val)) - assert(vec_same_missing(spd_test_vals[i], spd_ref_vals, 0.00005), "speed field i" ) - end for - - # resulting paramids from surface winds - # note about 200U/200V - the test was failing on lxg because it has old MARS config files - # therefore we use the paramIds for those: 228239/228240==200U/200V - uv_s = read("surface_wind.grib") - s100 = speed(read(data:uv_s, param:"100U"), read(data:uv_s, param:"100V")) - assert(grib_get_long(s100, "paramId")=228249, "speed paramId s100") - s200 = speed(read(data:uv_s, param:228239), read(data:uv_s, param:228240)) # 200U/200V - assert(grib_get_long(s200, "paramId")=228241, "speed paramId s200") - s10 = speed(read(data:uv_s, param:"10U"), read(data:uv_s, param:"10V")) - assert(grib_get_long(s10, "paramId")=207, "speed paramId s10") - -end test_speed - - -function test_stdev() - fs = fs_77 - - # single field - r = stdev(fs) - v = values(r) - v_ref = v * 0 - assert_equal(count(r), 1, "stdev_count", 1) - assert(vec_same(v, v_ref), "stdev", 1) - - # known stdev - f = fs & (4*fs) & (10*fs) - r = stdev(f) - v = values(r) - v_ref = values(fs) * sqrt(42/3) - assert_equal(count(r), 1, "stdev_count", 2) - assert(vec_same(v, v_ref, 1E-4), "stdev", 2) - - # real example - f = read('monthly_avg.grib') - r = stdev(f) - assert_equal(count(r),1, "stdev_count", 3) - v = values(r) - - v_ref_mean = v * 0 - for i=1 to count(f) do - v_ref_mean = v_ref_mean + values(f[i]) - end for - v_ref_mean = v_ref_mean / count(f) - v_ref = v * 0 - for i=1 to count(f) do - v_ref = v_ref + (values(f[i]) - v_ref_mean)^2 - end for - v_ref = sqrt(v_ref/count(f)) - assert(vec_same(v, v_ref), "stdev",3) - -end test_stdev - -function test_stdev_a() - fs = fs_22 - - # const field - v = stdev_a(fs*0) - v_ref = 0 - assert_equal(v, v_ref, "stdev_a",0) - - # single field - v = stdev_a(fs) - v_ref = 13.3863463156 - assert_equal(v, v_ref, "stdev_a",1) - - # real life example - f1 = read('monthly_avg.grib') - v = vector(stdev_a(f1)) - assert_equal(count(v),count(f1), "stdev_a_count", 2) - v_ref = |43.4115,50.5214,54.5082,51.4585,43.8788,34.9506,28.5748,28.0585| - assert(vec_same(v, v_ref,1E-2), "stdev_a",2) - - # sub area - area = [60, -20, 30, 28] - - v = stdev_a(fs, area) - v_ref = 6.2232558479 - assert_equal(v, v_ref, "stdev_a",3) - - f1 = read('monthly_avg.grib') - v = vector(stdev_a(f1, area)) - assert_equal(count(v),count(f1), "stdev_a_count", 4) - v_ref = |28.1503,18.4203,14.5876,26.4032,14.821,13.4898,13.9025,9.42017| - assert(vec_same(v, v_ref,1E-2), "stdev_a",4) - -end test_stdev_a - -function test_sum() - fs_name = "sum" - - fs = fs_77 - fs_m = bitmap(fs, bitmap(fs > 280, 1)) - - # single fields - f = fs - r = sum(f) - v = values(r) - v_ref = values(fs) - assert_equal(count(r),1, fs_name & " - count", 1) - assert(vec_same(v, v_ref), fs_name & "- values", 1) - - # known sum - f = fs & fs & fs - r = sum(f) - v = values(r) - v_ref = values(fs) * 3 - assert_equal(count(r),1, fs_name & " - count", 2) - assert(vec_same(v, v_ref), fs_name & "- values", 2) - - # real life example - f = read('monthly_avg.grib') - r = sum(f) - assert_equal(count(r),1, fs_name & " - count", 3) - v = values(r) - v_ref = v * 0 - for i=1 to count(f) do - v_ref = v_ref + values(f[i]) - end for - assert(vec_same(v, v_ref), fs_name & "- values",3) - - # missing values - single field - f = fs_m - r = sum(f) - v = values(r) - v_ref = values(fs_m) - assert_equal(count(r),1, fs_name & " - count", 4) - assert(vec_same_missing(v, v_ref), fs_name & " - values", 4) - - # known sum - f = fs & 2*fs_m & 3*fs_m - r = sum(f) - v = values(r) - v_ref = values(fs_m) * 6 - assert_equal(count(r),1, fs_name & " - count", 5) - assert(vec_same(v, v_ref), fs_name & " - values", 5) - -end test_sum - -function test_sum_missing() - fs_name = "sum_missing" - - fs = fs_77 - fs_m = bitmap(fs, bitmap(fs > 280, 1)) - - # single fields - f = fs - r = sum(f, "missing") - v = values(r) - v_ref = values(fs) - assert_equal(count(r),1, fs_name & " - count", 1) - assert(vec_same(v, v_ref), fs_name & " - values", 1) - - # known mean - f = fs & fs & fs - r = sum(f, "missing") - v = values(r) - v_ref = values(fs) * 3 - assert_equal(count(r),1, fs_name & " - count", 2) - assert(vec_same(v, v_ref), fs_name & " - values", 2) - - # real life example - f = read('monthly_avg.grib') - r = sum(f, "missing") - assert_equal(count(r),1, fs_name & " - count", 3) - v = values(r) - v_ref = v * 0 - for i=1 to count(f) do - v_ref = v_ref + values(f[i]) - end for - assert(vec_same(v, v_ref), fs_name & " - values",3) - - # missing values - single field - f = fs_m - r = sum(f,"missing") - v = values(r) - v_ref = values(fs_m) - assert_equal(count(r),1, fs_name & " - count", 4) - assert(vec_same_missing(v, v_ref), fs_name & " - values", 4) - - # multiple fields, in the second one there are some missing values - f = fs & fs_m & 2*fs - - # in the first point we only have missing values! - for i=1 to count(f) do - fv = values(f[i]) - fv[1] = vector_missing_value - f[i] = set_values(f[i], fv) - end for - - r = sum(f,"missing") - v = values(r) - - b1 = values(fs_m)*0 - b1 = nobitmap(b1,1) - b2 = values(fs_m)*0+1 - b2 = nobitmap(b2,0) - v_ref = values(fs)*(b1*3. + b2*4.) - v_ref[1] = vector_missing_value - - assert_equal(count(r),1, fs_name & " - count", 5) - assert(vec_same_missing(v, v_ref,1E-5), fs_name & " - values", 5) - -end test_sum_missing - -function test_values() - - # single field - f = fs_22*0+2 - v = values(f) - v_ref = vector(count(v)) - for i=1 to count(v_ref) do - v_ref[i] = 2 - end for - assert(vec_same(v,v_ref),"values",1) - - # multiple fields - f = (fs_22*0+2) & (fs_22*0-1) - v = values(f) - assert_equal(count(v),2,"values multi count",1) - v_ref = v_ref*0+2 - assert(vec_same(v[1],v_ref),"values multi a",1) - v_ref = v_ref*0-1 - assert(vec_same(v[2],v_ref),"values multi b",1) - -end test_values - -function test_var() - fs = fs_77 - - # single field - r = var(fs) - v = values(r) - v_ref = v * 0 - assert_equal(count(r), 1, "var_count", 1) - assert(vec_same(v, v_ref), "var", 1) - - # increase grib precision for next test - prev_b = gribsetbits(32) - - # known variance - f = fs & (4*fs) & (10*fs) - r = var(f) - v = values(r) - v_ref = values(fs) - v_ref = v_ref * v_ref * 42/3 - assert_equal(count(r), 1, "var_count", 2) - # TODO: figure out why the diff is so large between result and reference - assert(vec_same(v, v_ref, 1E-3), "var", 2) - - # reset precision - gribsetbits(prev_b) - - # real life example - f = read('monthly_avg.grib') - r = var(f) - assert_equal(count(r),1, "var_count", 3) - v = values(r) - - v_ref_mean = v * 0 - for i=1 to count(f) do - v_ref_mean = v_ref_mean + values(f[i]) - end for - v_ref_mean = v_ref_mean / count(f) - v_ref = v * 0 - for i=1 to count(f) do - v_ref = v_ref + (values(f[i]) - v_ref_mean)^2 - end for - v_ref = v_ref/count(f) - assert(vec_same(v, v_ref), "var",3) - -end test_var - -function test_var_a() - - fs = fs_22 - - # global - - # single field - v = var_a(fs) - v_ref = 179.19426768 - assert_equal(v, v_ref, "var_a",1) - - # real life example - f1 = read('monthly_avg.grib') - v = vector(var_a(f1)) - assert_equal(count(v),count(f1), "var_a_count", 2) - v_ref = |1884.56,2552.41,2971.15,2647.97,1925.35,1221.54,816.517,787.277| - assert(vec_same(v, v_ref,1E-2), "var_a",2) - - # sub area - area = [60, -20, 30, 28] - - v = var_a(fs, area) - v_ref = 38.7289133484 - assert_equal(v, v_ref, "var_a",3) - - f1 = read('monthly_avg.grib') - v = vector(var_a(f1, area)) - assert_equal(count(v),count(f1), "var_a_count", 4) - v_ref = |792.438,339.306,212.798,697.127,219.661,181.974,193.281,88.7397| - assert(vec_same(v, v_ref,1E-2), "var_a",4) - -end test_var_a - -function test_xy_from_polar() - - fn_name = "xy_from_polar" - - sqr2 = sqrt(2)/2 - sqr3 = sqrt(3)/2 - - # values - sp = | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10| - d = |0, 45, 90, 135, 180, 225, 270, 315, 360, 30| - u = |0, -sqr2*2, -3, -sqr2*4, 0, sqr2*6, 7, sqr2*8, 0, -0.5*10| - v = |-1,-sqr2*2, 0, sqr2*4, 5, sqr2*6, 0, -sqr2*8, -9, -sqr3*10| - - for i=1 to count(sp) do - r = xy_from_polar(sp[i], d[i]) - assert_equal(count(r),2, fn_name & " len [" & i & "]", 1) - assert_equal(r[1],u[i], fn_name & " u [" & i & "]", 1) - assert_equal(r[2],v[i], fn_name & " v [" & i & "]", 1) - end for - - # vectors - r = xy_from_polar(sp, d) - assert_equal(count(r),2, fn_name & " len [" & i & "]", 2) - assert(vec_same(r[1],u), fn_name & " u [" & i & "]", 2) - assert(vec_same(r[2],v), fn_name & " v [" & i & "]", 2) - - # fieldset - fs = read("tuv_pl.grib") - f_sp = read(data: fs, param: "u", levelist: 500) - f_d = read(data: fs, param: "v", levelist: 500) - f_sp = grib_set_long(f_sp, ["paramId",10]) - - # write the input sp and d test values into the beginning of the fields - sp_val = values(f_sp) - d_val = values(f_d) - for i=1 to count(sp) do - sp_val[i] = sp[i] - d_val[i] = d[i] - end for - f_sp = set_values(f_sp, sp_val) - f_d = set_values(f_d, d_val) - - f_sp = f_sp & f_sp - f_d = f_d & f_d - - # we will only check the first count(sp) values - r = xy_from_polar(f_sp, f_d) - assert_equal(count(r), 4, fn_name & " field count", 3) - for i=1 to count(r) by 2 do - r_val = values(r[i])[1, count(sp)] - assert(vec_same(r_val, u, 1E-5), fn_name & " u [" & i & "]", 3) - assert_equal(grib_get_long(r[i], "paramId"), 131, fn_name & " u paramid [" & i & "]", 3) - end for - - for i=2 to count(r) by 2 do - r_val = values(r[i])[1, count(sp)] - assert(vec_same(r_val, v, 1E-5), fn_name & " v [" & i & "]", 3) - assert_equal(grib_get_long(r[i], "paramId"), 132, fn_name & " v paramid [" & i & "]", 3) - end for - -end test_xy_from_polar - -# --------------------------------------------------- - -function step_equal(fs:fieldset, refstep:number) - s = grib_get_long(fs, 'step') - return (s = refstep) -end steps_equal - -function steps_equal(fs:fieldset, refsteps:list) - s = grib_get_long(fs, 'step') - return is_equal_any(s, refsteps) -end steps_equal - -function levels_equal(fs:fieldset, reflevs:list) - s = grib_get_long(fs, 'level') - eq = is_equal_any(s, reflevs) - if not eq then - print('levels not equal: ', s, ' vs ref ', reflevs) - end if - return eq -end levels_equal - -function params_equal(fs:fieldset, refparams:list) - s = grib_get_string(fs, 'shortName') - return is_equal_any(s, refparams) -end params_equal - -#==================================================== -# -# Functions to generate test reference data -# -#==================================================== - -function generate_test_rmask_reference() - fs = fs_22 - - lat_c = 48 - lon_c = 19 - rad = 1000000 - r1 = rmask(fs, lat_c, lon_c, rad) - - lat_c = -40 - lon_c = -60 - rad = 7000000 - r2 = rmask(fs, lat_c, lon_c, rad) - - lat_c = 90 - lon_c = 0 - rad = 6000000 - r3 = rmask(fs, lat_c, lon_c, rad) - - #write('rmask_ref.grib',r1 & r2 & r3) - -end generate_test_rmask_reference - -function make_sort_reference(lst1,lst2,lst3,lst4,lst5,lst6) - - v_ref = nil - loop dd in lst1 - loop tt in lst2 - loop ss in lst3 - loop nn in lst4 - loop ll in lst5 - loop pp in lst6 - v_ref = v_ref & [[dd,tt,ss,nn,ll,pp]] - end loop - end loop - end loop - end loop - end loop - end loop - - return v_ref - -end make_sort_reference - -function compare_for_sort_test_1_asc(a, b) - return a[1] < b[1] -end compare_for_sort_test_1_asc - -function compare_for_sort_test_1_desc(a, b) - return a[1] > b[1] -end compare_for_sort_test_1_desc - -function compare_for_sort_test_2_asc(a, b) - - for i=1 to 2 do - if a[i] <> b[i] then - return a[i] < b[i] - end if - end for - - return 0 - -end compare_for_sort_test_2_asc - -function compare_for_sort_test_2_desc(a, b) - - for i=1 to 2 do - if a[i] <> b[i] then - return a[i] > b[i] - end if - end for - - return 0 - -end compare_for_sort_test_2_desc - - -function compare_for_sort_test_2_desc_asc(a, b) - - if a[1] <> b[1] then - return a[1] > b[1] - end if - return a[2] < b[2] - -end compare_for_sort_test_2_desc_asc - diff -Nru metview-5.17.4/metview/test/macros/fieldset_sort_custom_1.mv metview-5.19.2/metview/test/macros/fieldset_sort_custom_1.mv --- metview-5.17.4/metview/test/macros/fieldset_sort_custom_1.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_sort_custom_1.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,166 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_sort_custom_1() + +function test_sort_custom_1() + fs = read("sort.grib") + + # default + dateLst =["20190603","20190604","20190605"] + timeLst = ["0000","1200"] + stepLst = ["0","6","12","18"] + numberLst = ["1","2","3"] + levelLst = ["300","500","700"] + paramLst = ["130", "131", "133"] # (t,u,q) + + # custom order - step + r = sort(fs,"step") + v = grib_get(r, ['step:l','date','time','number','level','paramId']) + v_ref = grib_get(fs, ['step:l','date','time','number','level','paramId']) + v_ref = sort(v_ref,'compare_for_sort_test_1_asc') + + assert_equal(count(v),count(v_ref),"sort count",2) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,2) + end for + + # custom order - param + r = sort(fs,"param") + v = grib_get(r, ['paramId:l','date','time','step','number','level']) + v_ref = grib_get(fs, ['paramId:l','date','time','step','number','level']) + v_ref = sort(v_ref,'compare_for_sort_test_1_asc') + + assert_equal(count(v),count(v_ref),"sort count",3) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,3) + end for + + # custom order - levelist + r = sort(fs,"levelist") + v = grib_get(r, ['level:l','date','time','step','number','paramId']) + v_ref = grib_get(fs, ['level:l','date','time','step','number','paramId']) + v_ref = sort(v_ref,'compare_for_sort_test_1_asc') + + assert_equal(count(v),count(v_ref),"sort count",4) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,4) + end for + + # custom order - date + r = sort(fs,"date") + v = grib_get(r, ['date','time','step','number','level','paramId']) + v_ref = grib_get(fs, ['date','time','step','number','level','paramId']) + v_ref = sort(v_ref,'compare_for_sort_test_1_asc') + + assert_equal(count(v),count(v_ref),"sort count",5) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,5) + end for + + # custom order - time + r = sort(fs,"time") + v = grib_get(r, ['time:l','date','step','number','level','paramId']) + v_ref = grib_get(fs, ['time:l','date','step','number','level','paramId']) + v_ref = sort(v_ref,'compare_for_sort_test_1_asc') + + assert_equal(count(v),count(v_ref),"sort count",6) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,6) + end for + + # custom order - number + r = sort(fs,"number") + v = grib_get(r, ['number:l','date','time','step','level','paramId']) + v_ref = grib_get(fs, ['number:l','date','time','step','level','paramId']) + v_ref = sort(v_ref,'compare_for_sort_test_1_asc') + + assert_equal(count(v),count(v_ref),"sort count",7) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,7) + end for + +end test_sort_custom_1 + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function make_sort_reference(lst1,lst2,lst3,lst4,lst5,lst6) + + v_ref = nil + loop dd in lst1 + loop tt in lst2 + loop ss in lst3 + loop nn in lst4 + loop ll in lst5 + loop pp in lst6 + v_ref = v_ref & [[dd,tt,ss,nn,ll,pp]] + end loop + end loop + end loop + end loop + end loop + end loop + + return v_ref + +end make_sort_reference + +function compare_for_sort_test_1_asc(a, b) + return a[1] < b[1] +end compare_for_sort_test_1_asc + +function compare_for_sort_test_1_desc(a, b) + return a[1] > b[1] +end compare_for_sort_test_1_desc + +function compare_for_sort_test_2_asc(a, b) + + for i=1 to 2 do + if a[i] <> b[i] then + return a[i] < b[i] + end if + end for + + return 0 + +end compare_for_sort_test_2_asc + +function compare_for_sort_test_2_desc(a, b) + + for i=1 to 2 do + if a[i] <> b[i] then + return a[i] > b[i] + end if + end for + + return 0 + +end compare_for_sort_test_2_desc + + +function compare_for_sort_test_2_desc_asc(a, b) + + if a[1] <> b[1] then + return a[1] > b[1] + end if + return a[2] < b[2] + +end compare_for_sort_test_2_desc_asc + diff -Nru metview-5.17.4/metview/test/macros/fieldset_sort_custom_2.mv metview-5.19.2/metview/test/macros/fieldset_sort_custom_2.mv --- metview-5.17.4/metview/test/macros/fieldset_sort_custom_2.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_sort_custom_2.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,169 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_sort_custom_2() + +function test_sort_custom_2() + fs = read("sort.grib") + + # default + dateLst =["20190603","20190604","20190605"] + timeLst = ["0000","1200"] + stepLst = ["0","6","12","18"] + numberLst = ["1","2","3"] + levelLst = ["300","500","700"] + paramLst = ["130", "131", "133"] # (t,u,q) + + # custom order - param + "<" (ascending) + r = sort(fs,"param", "<") + v = grib_get(r, ['paramId:l','date','time','step','number','level']) + v_ref = grib_get(fs, ['paramId:l','date','time','step','number','level']) + v_ref = sort(v_ref,'compare_for_sort_test_1_asc') + + assert_equal(count(v),count(v_ref),"sort count",8) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,8) + end for + + # custom order - param + ">" (descending) + r = sort(fs,"param", ">") + v = grib_get(r, ['paramId:l','date','time','step','number','level']) + v_ref = grib_get(fs, ['paramId:l','date','time','step','number','level']) + v_ref = sort(v_ref,'compare_for_sort_test_1_desc') + assert_equal(count(v),count(v_ref),"sort count",9) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,9) + end for + + # custom order - [param,level] + r = sort(fs,["param","levelist"]) + v = grib_get(r, ['paramId:l','level:l','date','time','step','number']) + v_ref = grib_get(fs, ['paramId:l','level:l','date','time','step','number']) + v_ref = sort(v_ref,'compare_for_sort_test_2_asc') + + assert_equal(count(v),count(v_ref),"sort count",10) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,10.1) + assert_equal(v[i][2],v_ref[i][2],"sort +" & i,10.2) + end for + + # custom order - [param,level] + "<" (ascending) + r = sort(fs,["param","levelist"],"<") + v = grib_get(r, ['paramId:l','level:l','date','time','step','number']) + v_ref = grib_get(fs, ['paramId:l','level:l','date','time','step','number']) + v_ref = sort(v_ref,'compare_for_sort_test_2_asc') + + assert_equal(count(v),count(v_ref),"sort count",11) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,11.1) + assert_equal(v[i][2],v_ref[i][2],"sort +" & i,11.2) + end for + + # custom order - [param,level] + ">" (descending) + r = sort(fs,["param","levelist"],">") + v = grib_get(r, ['paramId:l','level:l','date','time','step','number']) + v_ref = grib_get(fs, ['paramId:l','level:l','date','time','step','number']) + v_ref = sort(v_ref,'compare_for_sort_test_2_desc') + + assert_equal(count(v),count(v_ref),"sort count",12) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,12.1) + assert_equal(v[i][2],v_ref[i][2],"sort +" & i,12.2) + end for + + # custom order - [param,level] + ">","<" (descending, ascending) + r = sort(fs,["param","levelist"],[">","<"]) + v = grib_get(r, ['paramId:l','level:l','date','time','step','number']) + v_ref = grib_get(fs, ['paramId:l','level:l','date','time','step','number']) + v_ref = sort(v_ref,'compare_for_sort_test_2_desc_asc') + + assert_equal(count(v),count(v_ref),"sort count",13) + for i=1 to count(v) do + assert_equal(v[i][1],v_ref[i][1],"sort +" & i,13.1) + assert_equal(v[i][2],v_ref[i][2],"sort +" & i,13.2) + end for + +end test_sort_custom_2 + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function make_sort_reference(lst1,lst2,lst3,lst4,lst5,lst6) + + v_ref = nil + loop dd in lst1 + loop tt in lst2 + loop ss in lst3 + loop nn in lst4 + loop ll in lst5 + loop pp in lst6 + v_ref = v_ref & [[dd,tt,ss,nn,ll,pp]] + end loop + end loop + end loop + end loop + end loop + end loop + + return v_ref + +end make_sort_reference + +function compare_for_sort_test_1_asc(a, b) + return a[1] < b[1] +end compare_for_sort_test_1_asc + +function compare_for_sort_test_1_desc(a, b) + return a[1] > b[1] +end compare_for_sort_test_1_desc + +function compare_for_sort_test_2_asc(a, b) + + for i=1 to 2 do + if a[i] <> b[i] then + return a[i] < b[i] + end if + end for + + return 0 + +end compare_for_sort_test_2_asc + +function compare_for_sort_test_2_desc(a, b) + + for i=1 to 2 do + if a[i] <> b[i] then + return a[i] > b[i] + end if + end for + + return 0 + +end compare_for_sort_test_2_desc + + +function compare_for_sort_test_2_desc_asc(a, b) + + if a[1] <> b[1] then + return a[1] > b[1] + end if + return a[2] < b[2] + +end compare_for_sort_test_2_desc_asc + diff -Nru metview-5.17.4/metview/test/macros/fieldset_sort_default.mv metview-5.19.2/metview/test/macros/fieldset_sort_default.mv --- metview-5.17.4/metview/test/macros/fieldset_sort_default.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_sort_default.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,113 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +global fs_22 = read('t1000_LL_2x2.grb') +global fs_77 = read('t1000_LL_7x7.grb') + +test_sort_default() + + +function test_sort_default() + fs = read("sort.grib") + + # default + dateLst =["20190603","20190604","20190605"] + timeLst = ["0000","1200"] + stepLst = ["0","6","12","18"] + numberLst = ["1","2","3"] + levelLst = ["300","500","700"] + paramLst = ["130", "131", "133"] # (t,u,q) + v_ref = make_sort_reference(dateLst,timeLst,stepLst,numberLst,levelLst,paramLst) + + r = sort(fs) + v = grib_get(r, ['date','time','step','number','level','paramId']) + assert_equal(count(v),count(v_ref),"sort count",1) + for i=1 to count(v) do + assert_equal(v[i],v_ref[i],"sort +" & i,1) + end for + +end test_sort_default + + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function make_sort_reference(lst1,lst2,lst3,lst4,lst5,lst6) + + v_ref = nil + loop dd in lst1 + loop tt in lst2 + loop ss in lst3 + loop nn in lst4 + loop ll in lst5 + loop pp in lst6 + v_ref = v_ref & [[dd,tt,ss,nn,ll,pp]] + end loop + end loop + end loop + end loop + end loop + end loop + + return v_ref + +end make_sort_reference + +function compare_for_sort_test_1_asc(a, b) + return a[1] < b[1] +end compare_for_sort_test_1_asc + +function compare_for_sort_test_1_desc(a, b) + return a[1] > b[1] +end compare_for_sort_test_1_desc + +function compare_for_sort_test_2_asc(a, b) + + for i=1 to 2 do + if a[i] <> b[i] then + return a[i] < b[i] + end if + end for + + return 0 + +end compare_for_sort_test_2_asc + +function compare_for_sort_test_2_desc(a, b) + + for i=1 to 2 do + if a[i] <> b[i] then + return a[i] > b[i] + end if + end for + + return 0 + +end compare_for_sort_test_2_desc + + +function compare_for_sort_test_2_desc_asc(a, b) + + if a[1] <> b[1] then + return a[1] > b[1] + end if + return a[2] < b[2] + +end compare_for_sort_test_2_desc_asc + diff -Nru metview-5.17.4/metview/test/macros/fieldset_stats.mv metview-5.19.2/metview/test/macros/fieldset_stats.mv --- metview-5.17.4/metview/test/macros/fieldset_stats.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_stats.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,1403 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +global fs_22 = read('t1000_LL_2x2.grb') +global fs_77 = read('t1000_LL_7x7.grb') + +test_accumulate() +test_average() +test_average_ew() +test_average_ns() +test_corr_a() +test_covar() +test_covar_a() +test_frequencies() +test_integrate() +test_max() +test_maxvalue() +test_mean() +test_mean_missing() +test_mean_ew() +test_min() +test_minvalue() +test_percentile() +test_percentile_missing_1() +test_percentile_missing_2() +test_percentile_missing_3() +test_rms_a() +test_stdev() +test_stdev_a() +test_sum() +test_sum_missing() +test_var() +test_var_a() + +function test_accumulate() + fs = fs_77 + v = accumulate(fs) + v_ref = 393334.244141 + assert_equal(v, v_ref, "accumulate_single", 1) + v_ref = sum(values(fs)) + assert_equal(v, v_ref, "accumulate_single", 2) + + f = read('monthly_avg.grib') + v = accumulate(f) + assert(count(v) = count(f), "accmulate_count", 1) + for i=1 to count(v) do + assert_equal(v[i],sum(values(f[i])), "accumulate",i) + end for +end accumulate + + +function test_average() + fs = fs_22 + + # const fields + v = average(fs*0+1) + v_ref = 1 + assert_equal(v, v_ref, "average_const", 0) + + # single field + v = average(fs) + v_ref = 280.991189355 + assert_equal(v, v_ref, "average_single", 1) + v_ref = mean(values(fs)) + assert_equal(v, v_ref, "average_single", 2) + + # multiple fields + f = read('monthly_avg.grib') + v = average(f) + assert(count(v) = count(f), "average_count", 1) + for i=1 to count(v) do + assert_equal(v[i],mean(values(f[i])), "average",i) + end for +end test_average + +function test_average_ew() + fs = fs_22 + + # const field global + area =[90,-180,-90,180] + dy = 30 + v = average_ew(fs*0+1, area, dy) + v_ref = |1,1,1,1,1,1,1| + assert(vec_same(v, v_ref,1E-4), "average_ew const",1) + + # const field area + area =[60,-180,-60,180] + dy = 20 + v = average_ew(fs*0+2, area, dy) + v_ref = |2,2,2,2,2,2,2| + assert(vec_same(v, v_ref,1E-4), "average_ew const",2) + + # single field + area =[60,-180,-60,180] + dy = 20 + v = average_ew(fs, area, dy) + v_ref = |274.751,287.56,298.855,300.051,296.955,287.059,274.002| + assert(vec_same(v, v_ref,1E-3), "average_ew single",1) + + # multiple fields + f = read('monthly_avg.grib') + v = average_ew(f[1,2], area, dy) + v_ref = [|359.156,332.584,249.805,247.509,260.009,279.057,292.451|, + |383.311,343.246,254.138,248.505,257.765,272.993,287.189|] + assert(count(v) = 2, "average_ew multi_count", 1) + for i=1 to count(v) do + assert(vec_same(v[i], v_ref[i],1E-3), "average_ew multi",1) + end for + +end test_average_ew + +function test_average_ns() + fs = fs_22 + + # const field global + area =[90,-180,-90,180] + dy = 60 + v = average_ns(fs*0+1, area, dy) + v_ref = |1,1,1,1,1,1,1| + assert(vec_same(v, v_ref,1E-4), "average_ns const",1) + + # const field area + area =[90,-120,-90,120] + dy = 40 + v = average_ns(fs*0+2, area, dy) + v_ref = |2,2,2,2,2,2,2| + assert(vec_same(v, v_ref,1E-4), "average_ns const",2) + + # single field + area =[90,-120,-90,120] + dy = 40 + v = average_ns(fs, area, dy) + v_ref = |287.82,286.99,287.547,290.989,292.157,292.072,288.593| + assert(vec_same(v, v_ref,1E-3), "average_ns single",1) + + # multiple fields + f = read('monthly_avg.grib') + v = average_ns(f[1,2], area, dy) + v_ref = [|281.504,279.59,274.796,277.391,281.457,275.671,282.888|, + |287.213,290.872,281.548,279.08,276.233,277.212,285.542|] + + assert(count(v) = 2, "average_ns multi_count", 1) + for i=1 to count(v) do + assert(vec_same(v[i], v_ref[i],1E-3), "average_ns multi",1) + end for + +end test_average_ns + +function test_corr_a() + + fs = fs_22 + + # global + + # single field - self covariance + v = corr_a(fs, fs) + v_ref = 1 + assert_equal(v, v_ref, "corr_a",1) + + # real life example + f1 = read('monthly_avg.grib') + f2 = nil + for i=count(f1) to 1 by -1 do + f2 = f2 & f1[i] + end for + v = vector(corr_a(f1,f2)) + assert_equal(count(v),count(f1), "corr_a_count", 2) + v_ref = |0.389037,0.603044,0.835476,0.940168,0.940168,0.835476,0.603044,0.389037| + assert(vec_same(v, v_ref,1E-2), "corr_a",2) + + # sub area + area = [60, -20, 30, 28] + + v = corr_a(fs, fs, area) + v_ref = 1 + assert_equal(v, v_ref, "corr_a",3) + + f1 = read('monthly_avg.grib') + f2 = nil + for i=count(f1) to 1 by -1 do + f2 = f2 & f1[i] + end for + v = vector(corr_a(f1,f2, area)) + assert_equal(count(v),count(f1), "corr_a_count", 4) + v_ref = |0.448865,0.75234,0.616183,0.821316,0.821316,0.616183,0.75234,0.448865| + assert(vec_same(v, v_ref,1E-2), "corr_a",4) + +end test_corr_a + +function test_covar() + + fs = fs_77 + + # single field - self covariance + r = covar(fs, fs) + v = values(r) + v_ref = v * 0 + assert_equal(count(r),1,"covar_count",1) + assert(vec_same(v, v_ref), "covar",1) + + # multiple fields - self covariance + r = covar(fs & 2*fs, fs & 2*fs) + v = values(r) + v_ref = values(fs)^2 * 0.25 + assert_equal(count(r),1,"covar_count",2) + assert(vec_same(v, v_ref, 1E-3), "covar",2) + + # real life example + f1 = read('monthly_avg.grib') + f2 = nil + for i=count(f1) to 1 by -1 do + f2 = f2 & f1[i] + end for + r = covar(f1,f2) + assert_equal(count(r),1, "covar_count", 3) + v = values(r) + + # we compute the ref values with vectors + # the mean is the same for f1 and f2! + v_ref_mean = v * 0 + for i=1 to count(f1) do + v_ref_mean = v_ref_mean + values(f1[i]) + end for + v_ref_mean = v_ref_mean / count(f1) + + v_ref = v * 0 + for i=1 to count(f1) do + v_ref = v_ref + (values(f1[i]) - v_ref_mean)*(values(f2[i]) - v_ref_mean) + end for + v_ref = v_ref/count(f1) + assert(vec_same(v, v_ref), "covar",3) +end test_covar + +function test_covar_a() + + fs = fs_22 + + # global + + # single field - self covariance + v = covar_a(fs, fs) + v_ref = 179.19426768 + assert_equal(v, v_ref, "covar_a",1) + + # real life example + f1 = read('monthly_avg.grib') + f2 = nil + for i=count(f1) to 1 by -1 do + f2 = f2 & f1[i] + end for + v = vector(covar_a(f1,f2)) + assert_equal(count(v),count(f1), "covar_a_count", 2) + v_ref = |473.87,870.576,1591.66,2122.84,2122.84,1591.66,870.576,473.87| + assert(vec_same(v, v_ref,1E-2), "covar_a",2) + + # sub area + area = [60, -20, 30, 28] + + v = covar_a(fs, fs, area) + v_ref = 38.7289133484 + assert_equal(v, v_ref, "covar_a",3) + + f1 = read('monthly_avg.grib') + f2 = nil + for i=count(f1) to 1 by -1 do + f2 = f2 & f1[i] + end for + v = vector(covar_a(f1,f2, area)) + assert_equal(count(v),count(f1), "covar_a_count", 4) + v_ref = |119.03,192.666,121.255,321.397,321.397,121.255,192.666,119.03| + assert(vec_same(v, v_ref,1E-2), "covar_a",4) + +end test_covar_a + +function test_frequencies() + + fs = fs_22 + + # const - single field + f = fs*0 + 1 + v = frequencies(f,[0,1,2]) + v_ref = [0,0,16380,0] + assert_equal(v, v_ref, "frequencies",1) + + # const - multiple fields (results are accumulated!!!) + f = (fs*0 + 1) & (fs*0 + 0.5) + v = frequencies(f,[0,1,2]) + v_ref = [[0,0,16380,0],[0,16380,16380,0]] + assert_equal(count(v),count(v_ref),"frequencies count",2) + + for i=1 to count(v) do + assert_equal(v[i], v_ref[i], "frequencies", 2) + end for + + # real field + f = fs + bins = [230,250,270,290,310,330] + v = frequencies(f,bins) + v_ref = [0,424,4152,5600,5983,221,0] + + # compute with vectors + vv = values(f) + v_ref_comp = [sum(vv < bins[1])] + for i=1 to count(bins) do + if i = count(bins) then + v_ref_comp = v_ref_comp & [sum(vv > bins[i])] + else + v_ref_comp = v_ref_comp & [sum(vv >= bins[i] and vv < bins[i+1])] + end if + end for + + assert_equal(v, v_ref, "frequencies preset",3) + assert_equal(v, v_ref_comp, "frequencies comp",3) + + # real field with area + f = fs + bins = [230,250,270,290,310,330] + area = [-77,-50,-84,178] # south polar region + v = frequencies(f,bins,area) + v_ref = [0,136,324,0,0,0,0] # only visually checked!! + assert_equal(v, v_ref, "frequencies",4) + + +end test_frequencies + +function test_integrate() + + fs = fs_22 + + # const fields + v = integrate(fs*0+1) + v_ref = 1 + assert_equal(v, v_ref, "integrate_const", 0) + + # single field + v = integrate(fs) + v_ref = 288.931134546 + assert_equal(v, v_ref, "integrate_single", 1) + + # multiple fields + f = read('monthly_avg.grib') + v = vector(integrate(f)) + v_ref = |281.131,284.188,286.904,289.891,290.385,289.162,287.446,287.64| + assert(vec_same(v, v_ref,1E-2), "integrate",2) + + # sub area + area = [60, -20, 30, 28] + + v = integrate(fs, area) + v_ref = 288.266360826 + assert_equal(v, v_ref, "integrate",3) + + v = integrate(fs, 60, -20, 30, 28) # area as nums + v_ref = 288.266360826 + assert_equal(v, v_ref, "integrate_area_as_nums",3) + + + f1 = read('monthly_avg.grib') + v = vector(integrate(f1, area)) + assert_equal(count(v),count(f1), "integrate_count", 4) + v_ref = |321.581,324.78,346.414,355.78,354.426,328.62,313.588,303.825| + assert(vec_same(v, v_ref,1E-2), "integrate",4) + +end test_integrate + +function test_max() + + fs = fs_22 + + f = fs & 3*fs & 2*fs + r=max(f) + v = values(r) + v_ref = 3*values(fs) + assert(vec_same(v,v_ref),"max",1) + + f = fs + g = 2*fs + r=max(f, g) + v = values(r) + v_ref = 2*values(fs) + assert(vec_same(v,v_ref),"max",2) + + r=max(g, f) + v = values(r) + v_ref = 2*values(fs) + assert(vec_same(v,v_ref),"max",3) + +end test_max + +function test_maxvalue() + + fs = fs_22 + + f = fs & 3*fs & 2*fs + v = maxvalue(f) + v_ref = 3*maxvalue(values(fs)) + assert_equal(v,v_ref,"maxvalue",1) + + # area + area = [80, -120, -10, 120] + v = maxvalue(f,area) + v_ref = 950.863769531 + assert_equal(v,v_ref,"maxvalue",2) + +end test_maxvalue + +function test_mean() + fs_name = "mean" + + fs = fs_22 + fs_m = bitmap(fs, bitmap(fs > 280, 1)) + + # single fields + f = fs + r = mean(f) + v = values(r) + v_ref = values(fs) + assert_equal(count(r),1, fs_name & " - count", 1) + assert(vec_same(v, v_ref), fs_name & " - values", 1) + + # known mean + f = fs & 2*fs & 3*fs + r = mean(f) + v = values(r) + v_ref = values(fs) * 2 + assert_equal(count(r),1, fs_name & " - count", 2) + assert(vec_same(v, v_ref), fs_name & " - values", 2) + + # real life example + f = read('monthly_avg.grib') + r = mean(f) + assert_equal(count(r),1, fs_name & " - count", 3) + v = values(r) + v_ref = v * 0 + for i=1 to count(f) do + v_ref = v_ref + values(f[i]) + end for + v_ref = v_ref / count(f) + assert(vec_same(v, v_ref), fs_name & " - values",3) + + # missing values - single field + f = fs_m + r = mean(f) + v = values(r) + v_ref = values(fs_m) + assert_equal(count(r),1, fs_name & " - count", 4) + assert(vec_same_missing(v, v_ref), fs_name & " - values", 4) + + # known mean + f = fs & 2*fs_m & 3*fs_m + r = mean(f) + v = values(r) + v_ref = values(fs_m) * 2 + assert_equal(count(r),1, fs_name & " - count", 5) + assert(vec_same_missing(v, v_ref), fs_name & " - values", 5) + + +end test_mean + +function test_mean_missing() + fs_name = "mean_missing" + + fs = fs_22 + fs_m = bitmap(fs, bitmap(fs > 280, 1)) + + # single fields + f = fs + r = mean(f, "missing") + v = values(r) + v_ref = values(fs) + assert_equal(count(r),1, fs_name & " - count", 1) + assert(vec_same(v, v_ref), fs_name & " - values", 1) + + # known mean + f = fs & 2*fs & 3*fs + r = mean(f, "missing") + v = values(r) + v_ref = values(fs) * 2 + assert_equal(count(r),1, fs_name & " - count", 2) + assert(vec_same(v, v_ref), fs_name & " - values", 2) + + # real life example + f = read('monthly_avg.grib') + r = mean(f, "missing") + assert_equal(count(r),1, fs_name & " - count", 3) + v = values(r) + v_ref = v * 0 + for i=1 to count(f) do + v_ref = v_ref + values(f[i]) + end for + v_ref = v_ref / count(f) + assert(vec_same(v, v_ref), fs_name & " - values",3) + + # missing values - single field + f = fs_m + r = mean(f, "missing") + v = values(r) + v_ref = values(fs_m) + assert_equal(count(r),1, fs_name & " - count", 4) + assert(vec_same_missing(v, v_ref), fs_name & " - values", 4) + + # multiple fields, in the second one there are some missing values + f = fs & fs_m & 2*fs + + # in the first point we only have missing values! + for i=1 to count(f) do + fv = values(f[i]) + fv[1] = vector_missing_value + f[i] = set_values(f[i], fv) + end for + + r = mean(f, "missing") + v = values(r) + + b1 = values(fs_m)*0 + b1 = nobitmap(b1,1) + b2 = values(fs_m)*0+1 + b2 = nobitmap(b2,0) + v_ref = values(fs)*(b1*(3./2.) + b2*(4./3.)) + v_ref[1] = vector_missing_value + + assert_equal(count(r),1, fs_name & " - count", 5) + assert(vec_same_missing(v, v_ref,1E-5), fs_name & " - values", 5) + +end test_mean_missing + +function test_mean_ew() + fs = fs_22 + + # const field global + r = mean_ew(fs*0+1) + v = values(r) + v_ref = v*0 + 1 + assert(vec_same(v, v_ref,1E-4), "mean_ew",1) + + # real field + r = mean_ew(fs) + v = values(r) + + nx = grib_get_long(fs,'Ni') + ny = grib_get_long(fs,'Nj') + assert(nx > 0,'mean_ew nx',2) + assert(ny > 0,'mean_ew ny',2) + v_ref = values(fs) + for j=0 to ny-1 do + s=0 + for i=1 to nx do + idx= j*nx+i + s = s + v_ref[idx] + end for + for i=1 to nx do + idx= j*nx+i + v_ref[idx] = s/nx + end for + end for + assert(vec_same(v, v_ref,1E-4), "mean_ew",2) + +end test_mean_ew + +function test_min() + + fs = fs_22 + + f = 3*fs & fs & 2*fs + r=min(f) + v = values(r) + v_ref = values(fs) + assert(vec_same(v,v_ref),"min",1) + + f = fs + g = 2*fs + r=min(f, g) + v = values(r) + v_ref = values(fs) + assert(vec_same(v,v_ref),"min",2) + + r=min(g, f) + v = values(r) + v_ref = values(fs) + assert(vec_same(v,v_ref),"min",3) + +end test_min + +function test_minvalue() + + fs = fs_22 + + f = 3*fs & fs & 2*fs + v = minvalue(f) + v_ref = minvalue(values(fs)) + assert_equal(v,v_ref,"minvalue",1) + + # area + area = [80, -120, -10, 120] + v = minvalue(f,area) + v_ref = 252.454589844 + assert_equal(v,v_ref,"minvalue",2) + +end test_minvalue + +function test_percentile() + + # populate a list of vectors with numbers that are easy to check their percentiles + num_vecs = 10 + num_vals = 4 # num vals per vector + + list_of_vectors = nil + for i = 1 to num_vecs do + vec = vector(num_vals) + for j = 1 to num_vals do + vec[j] = i * 10^j + end for + list_of_vectors = list_of_vectors & [vec] + end for + + # create a fieldset with 4 values only set the list of vectors as values + fs = read(data: fs_22, area: [20,40,30,50], grid: [10,10]) + f = nil + for i=1 to num_vecs do + f = f & (set_values(fs, list_of_vectors[i])) + end for + + # 50% + r = percentile(data: f, percentiles: [50]) + assert_equal(count(r), 1, "percentile nn count",1) + v = values(r) + assert(vec_same(v, |60,600,6000,60000|), "percentile nn value", 1) + + r = percentile(data: f, percentiles: 50) + assert_equal(count(r), 1, "percentile nn-num count",1) + v = values(r) + assert(vec_same(v, |60,600,6000,60000|), "percentile nn-num value", 1) + + r = percentile(data: f, percentiles: [50], interpolation: "nearest_neighbour") + assert_equal(count(r), 1, "percentile nn-a count",1) + v = values(r) + assert(vec_same(v, |60,600,6000,60000|), "percentile nn-a value", 1) + + r = percentile(data: f, percentiles: [50], interpolation: 'linear') + assert_equal(count(r), 1, "percentile lin count",1) + v = values(r) + assert(vec_same(v, |55,550,5500,55000|), "percentile lin value", 1) + + # 5% + r = percentile(data: f, percentiles: [5]) + assert_equal(count(r),1, "percentile nn count",2) + v = values(r) + assert(vec_same(v, |10,100,1000,10000|), "percentile nn value",2) + + r = percentile(data: f, percentiles: [5], interpolation: 'linear') + assert_equal(count(r),1, "percentile lin count",2) + v = values(r) + assert(vec_same(v, |10,100,1000,10000|), "percentile lin value",2) + + # 99% + r = percentile(data: f, percentiles: [99]) + assert_equal(count(r),1, "percentile nn count",3) + v = values(r) + assert(vec_same(v, |100,1000,10000,100000|), "percentile nn value",3) + + r = percentile(data: f, percentiles: [99], interpolation: 'linear') + assert_equal(count(r),1, "percentile lin count",3) + v = values(r) + assert(vec_same(v, |100,1000,10000,100000|), "percentile lin value",3) + + # list: 50%, 60% + r = percentile(data: f, percentiles: [50,60]) + assert_equal(count(r),2, "percentile nn count",4) + v_ref = [|60,600,6000,60000|,|70,700,7000,70000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same(v, v_ref[i]), "percentile nn value [" & i & "]",4) + end for + + r = percentile(data: f, percentiles: [50,60], interpolation: 'linear') + assert_equal(count(r),2, "percentile lin count",4) + v_ref = [|55,550,5500,55000|,|66,660,6600,66000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same(v, v_ref[i]), "percentile lin value [" & i & "]",4) + end for + + # list of more percentiles than we have fields in the input fieldset + r = percentile(data: f, percentiles: [1,2,3,4,5,6,7,8,9,50,60,80,99], interpolation: "nearest_neighbour") + assert_equal(count(r),13, "percentile lin [13] count",5) + v_ref = [|10, 100, 1000, 10000|, + |10, 100, 1000, 10000|, + |10, 100, 1000, 10000|, + |10, 100, 1000, 10000|, + |10, 100, 1000, 10000|, + |10, 100, 1000, 10000|, + |10, 100, 1000, 10000|, + |10, 100, 1000, 10000|, + |10, 100, 1000, 10000|, + |60, 600, 6000, 60000|, + |70, 700, 7000, 70000|, + |90, 900, 9000, 90000|, + |100, 1000, 10000, 100000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same(v, v_ref[i]), "percentile lin value [" & i & "]",5) + end for + +end test_percentile + + +function test_percentile_missing_1() + + # test Percentile with compute_if_missing: 'off' + # - any grid point with at least one missing value will + # have a missing value as its result + + + # populate a list of vectors with numbers that are easy to check their percentiles + num_vecs = 10 + num_vals = 4 # num vals per vector + vm = vector_missing_value + + list_of_vectors = [ + |10,100,1000,10000|, + |20,vm, 2000,20000|, + |30,300,3000,30000|, + |40,400,4000,40000|, + |50,vm, 5000,50000|, + |60,vm, 6000,60000|, + |70,vm, 7000,70000|, + |80,800,8000,80000|, + |90,900,9000,90000|, + |100,vm,10000,100000| + ] + + # create a fieldset with 4 values only set the list of vectors as values + fs = read(data: fs_22, area: [20,40,30,50], grid: [10,10]) + f = nil + for i=1 to num_vecs do + f = f & (set_values(fs, list_of_vectors[i])) + end for + + + # 50% + r = percentile(data: f, percentiles: [50], compute_if_missing: 'off') + assert_equal(count(r), 1, "percentile_missing nn count",1) + v = values(r) + print('values: ', v) + assert(vec_same_missing(v, |60,vm,6000,60000|), "percentile_missing nn value", 1) + + r = percentile(data: f, percentiles: 50, compute_if_missing: 'off') + assert_equal(count(r), 1, "percentile_missing nn-num count",1) + v = values(r) + assert(vec_same_missing(v, |60,vm,6000,60000|), "percentile_missing nn-num value", 1) + + r = percentile(data: f, percentiles: [50], interpolation: "nearest_neighbour", compute_if_missing: 'off') + assert_equal(count(r), 1, "percentile_missing nn-a count",1) + v = values(r) + assert(vec_same_missing(v, |60,vm,6000,60000|), "percentile nn-a value", 1) + + r = percentile(data: f, percentiles: [50], interpolation: 'linear', compute_if_missing: 'off') + assert_equal(count(r), 1, "percentile_missing lin count",1) + v = values(r) + assert(vec_same_missing(v, |55,vm,5500,55000|), "percentile_missing lin value", 1) + + # 5% + r = percentile(data: f, percentiles: [5], compute_if_missing: 'off') + assert_equal(count(r),1, "percentile_missing nn count",2) + v = values(r) + assert(vec_same_missing(v, |10,vm,1000,10000|), "percentile_missing nn value",2) + + r = percentile(data: f, percentiles: [5], interpolation: 'linear', compute_if_missing: 'off') + assert_equal(count(r),1, "percentile_missing lin count",2) + v = values(r) + assert(vec_same_missing(v, |10,vm,1000,10000|), "percentile_missing lin value",2) + + # 99% + r = percentile(data: f, percentiles: [99], compute_if_missing: 'off') + assert_equal(count(r),1, "percentile_missing nn count",3) + v = values(r) + assert(vec_same_missing(v, |100,vm,10000,100000|), "percentile_missing nn value",3) + + r = percentile(data: f, percentiles: [99], interpolation: 'linear', compute_if_missing: 'off') + assert_equal(count(r),1, "percentile_missing lin count",3) + v = values(r) + assert(vec_same_missing(v, |100,vm,10000,100000|), "percentile_missing lin value",3) + + # list: 50%, 60% + r = percentile(data: f, percentiles: [50,60], compute_if_missing: 'off') + assert_equal(count(r),2, "percentile_missing nn count",4) + v_ref = [|60,vm,6000,60000|,|70,vm,7000,70000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing nn value [" & i & "]",4) + end for + + r = percentile(data: f, percentiles: [50,60], interpolation: 'linear', compute_if_missing: 'off') + assert_equal(count(r),2, "percentile_missing lin count",4) + v_ref = [|55,vm,5500,55000|,|66,vm,6600,66000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing lin value [" & i & "]",4) + end for + + # list of more percentiles than we have fields in the input fieldset + r = percentile(data: f, percentiles: [1,2,3,4,5,6,7,8,9,50,60,80,99], + interpolation: "nearest_neighbour", compute_if_missing: 'off') + assert_equal(count(r),13, "percentile_missing lin [13] count",5) + v_ref = [|10, vm, 1000, 10000|, + |10, vm, 1000, 10000|, + |10, vm, 1000, 10000|, + |10, vm, 1000, 10000|, + |10, vm, 1000, 10000|, + |10, vm, 1000, 10000|, + |10, vm, 1000, 10000|, + |10, vm, 1000, 10000|, + |10, vm, 1000, 10000|, + |60, vm, 6000, 60000|, + |70, vm, 7000, 70000|, + |90, vm, 9000, 90000|, + |100, vm, 10000, 100000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing lin value [" & i & "]",5) + end for + +end test_percentile_missing_1 + + +function test_percentile_missing_2() + ## test Percentile module with a gridpoint that has missing + ## values in every field + + # populate a list of vectors with numbers that are easy to check their percentiles + num_vecs = 10 + num_vals = 4 # num vals per vector + vm = vector_missing_value + + list_of_vectors = [ + |10,100, vm,10000|, + |20,200, vm,20000|, + |30,300, vm,30000|, + |40,400, vm,40000|, + |50,500, vm,50000|, + |60,600, vm,60000|, + |70,700, vm,70000|, + |80,800, vm,80000|, + |90,900, vm,90000|, + |100,1000,vm,100000| + ] + + # create a fieldset with 4 values only set the list of vectors as values + fs = read(data: fs_22, area: [20,40,30,50], grid: [10,10]) + f = nil + for i=1 to num_vecs do + f = f & (set_values(fs, list_of_vectors[i])) + end for + + + # 50% + r = percentile(data: f, percentiles: [50]) + assert_equal(count(r), 1, "percentile_missing_2 nn count",1) + v = values(r) + print('values: ', v) + assert(vec_same_missing(v, |60,600,vm,60000|), "percentile_missing_2 nn value", 1) + + r = percentile(data: f, percentiles: 50) + assert_equal(count(r), 1, "percentile_missing_2 nn-num count",1) + v = values(r) + assert(vec_same_missing(v, |60,600,vm,60000|), "percentile_missing_2 nn-num value", 1) + + r = percentile(data: f, percentiles: 50, compute_if_missing: 'off') + assert_equal(count(r), 1, "percentile_missing_2 nn-num count",1) + v = values(r) + assert(vec_same_missing(v, |60,600,vm,60000|), "percentile_missing_2 nn-num value", 1) + + r = percentile(data: f, percentiles: [50], interpolation: "nearest_neighbour") + assert_equal(count(r), 1, "percentile_missing_2 nn-a count",1) + v = values(r) + assert(vec_same_missing(v, |60,600,vm,60000|), "percentile nn-a value", 1) + + r = percentile(data: f, percentiles: [50], interpolation: 'linear') + assert_equal(count(r), 1, "percentile_missing_2 lin count",1) + v = values(r) + assert(vec_same_missing(v, |55,550,vm,55000|), "percentile_missing_2 lin value", 1) + + # 5% + r = percentile(data: f, percentiles: [5]) + assert_equal(count(r),1, "percentile_missing_2 nn count",2) + v = values(r) + assert(vec_same_missing(v, |10,100,vm,10000|), "percentile_missing_2 nn value",2) + + r = percentile(data: f, percentiles: [5], interpolation: 'linear') + assert_equal(count(r),1, "percentile_missing_2 lin count",2) + v = values(r) + assert(vec_same_missing(v, |10,100,vm,10000|), "percentile_missing_2 lin value",2) + + # 99% + r = percentile(data: f, percentiles: [99]) + assert_equal(count(r),1, "percentile_missing_2 nn count",3) + v = values(r) + assert(vec_same_missing(v, |100,1000,vm,100000|), "percentile_missing_2 nn value",3) + + r = percentile(data: f, percentiles: [99], interpolation: 'linear') + assert_equal(count(r),1, "percentile_missing_2 lin count",3) + v = values(r) + assert(vec_same_missing(v, |100,1000,vm,100000|), "percentile_missing_2 lin value",3) + + # list: 50%, 60% + r = percentile(data: f, percentiles: [50,60]) + assert_equal(count(r),2, "percentile_missing_2 nn count",4) + v_ref = [|60,600,vm,60000|,|70,700,vm,70000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing_2 nn value [" & i & "]",4) + end for + + r = percentile(data: f, percentiles: [50,60], interpolation: 'linear') + assert_equal(count(r),2, "percentile_missing_2 lin count",4) + v_ref = [|55,550,vm,55000|,|66,660,vm,66000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing_2 lin value [" & i & "]",4) + end for + + # list of more percentiles than we have fields in the input fieldset + r = percentile(data: f, percentiles: [1,2,3,4,5,6,7,8,9,50,60,80,99], interpolation: "nearest_neighbour") + assert_equal(count(r),13, "percentile_missing_2 lin [13] count",5) + v_ref = [|10, 100, vm, 10000|, + |10, 100, vm, 10000|, + |10, 100, vm, 10000|, + |10, 100, vm, 10000|, + |10, 100, vm, 10000|, + |10, 100, vm, 10000|, + |10, 100, vm, 10000|, + |10, 100, vm, 10000|, + |10, 100, vm, 10000|, + |60, 600, vm, 60000|, + |70, 700, vm, 70000|, + |90, 900, vm, 90000|, + |100,1000,vm, 100000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing_2 lin value [" & i & "]",5) + end for + +end test_percentile_missing_2 + + +function test_percentile_missing_3() + + ## test the Percentile module with COMPUTE_IF_MISSING_PRESENT=ON + ## compute_if_missing: 'on' is by default + + # populate a list of vectors with numbers that are easy to check their percentiles + num_vecs = 10 + num_vals = 4 # num vals per vector + vm = vector_missing_value + + list_of_vectors = [ + |10,100,1000,10000|, + |20,vm, 2000,20000|, + |30,300,3000,30000|, + |40,400,4000,40000|, + |50,vm, 5000,50000|, + |60,vm, 6000,60000|, + |70,vm, 7000,70000|, + |80,800,8000,80000|, + |90,900,9000,90000|, + |100,vm,10000,100000| + ] + + # create a fieldset with 4 values only set the list of vectors as values + fs = read(data: fs_22, area: [20,40,30,50], grid: [10,10]) + f = nil + for i=1 to num_vecs do + f = f & (set_values(fs, list_of_vectors[i])) + end for + + + # 50% + r = percentile(data: f, percentiles: [50]) + assert_equal(count(r), 1, "percentile_missing_3 nn count",1) + v = values(r) + print('values: ', v) + assert(vec_same_missing(v, |60,400,6000,60000|), "percentile_missing_3 nn value", 1) + + r = percentile(data: f, percentiles: 50) + assert_equal(count(r), 1, "percentile_missing_3 nn-num count",1) + v = values(r) + assert(vec_same_missing(v, |60,400,6000,60000|), "percentile_missing_3 nn-num value", 1) + + r = percentile(data: f, percentiles: [50], interpolation: "nearest_neighbour") + assert_equal(count(r), 1, "percentile_missing_3 nn-a count",1) + v = values(r) + assert(vec_same_missing(v, |60,400,6000,60000|), "percentile_missing_3 nn-a value", 1) + + r = percentile(data: f, percentiles: [50], interpolation: 'linear') + assert_equal(count(r), 1, "percentile_missing_3 lin count",1) + v = values(r) + assert(vec_same_missing(v, |55,400,5500,55000|), "percentile_missing_3 lin value", 1) + + # 5% + r = percentile(data: f, percentiles: [5]) + assert_equal(count(r),1, "percentile_missing_3 nn count",2) + v = values(r) + assert(vec_same_missing(v, |10,100,1000,10000|), "percentile_missing_3 nn value",2) + + r = percentile(data: f, percentiles: [5], interpolation: 'linear') + assert_equal(count(r),1, "percentile_missing_3 lin count",2) + v = values(r) + assert(vec_same_missing(v, |10,100,1000,10000|), "percentile_missing_3 lin value",2) + + # 99% + r = percentile(data: f, percentiles: [99]) + assert_equal(count(r),1, "percentile_missing_3 nn count",3) + v = values(r) + assert(vec_same_missing(v, |100,900,10000,100000|), "percentile_missing_3 nn value",3) + + r = percentile(data: f, percentiles: [99], interpolation: 'linear') + assert_equal(count(r),1, "percentile_missing_3 lin count",3) + v = values(r) + assert(vec_same_missing(v, |100,900,10000,100000|), "percentile_missing_3 lin value",3) + + # list: 50%, 60% + r = percentile(data: f, percentiles: [50,60]) + assert_equal(count(r),2, "percentile_missing_3 nn count",4) + v_ref = [|60,400,6000,60000|,|70,800,7000,70000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing_3 nn value [" & i & "]",4) + end for + + r = percentile(data: f, percentiles: [50,60], + interpolation: 'linear') + assert_equal(count(r),2, "percentile_missing_3 lin count",4) + v_ref = [|55,400,5500,55000|,|66,640,6600,66000|] + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing_3 lin value [" & i & "]",4) + end for + + # list of more percentiles than we have fields in the input fieldset + r = percentile(data: f, percentiles: [1,2,3,4,5,6,7,8,9,50,60,80,99], + interpolation: "nearest_neighbour") + assert_equal(count(r),13, "percentile_missing_3 lin [13] count",5) + v_ref = [|10, 100, 1000, 10000|, # 1 + |10, 100, 1000, 10000|, # 2 + |10, 100, 1000, 10000|, # 3 + |10, 100, 1000, 10000|, # 4 + |10, 100, 1000, 10000|, # 5 + |10, 100, 1000, 10000|, # 6 + |10, 100, 1000, 10000|, # 7 + |10, 100, 1000, 10000|, # 8 + |10, 100, 1000, 10000|, # 9 + |60, 400, 6000, 60000|, # 50 + |70, 800, 7000, 70000|, # 60 + |90, 900, 9000, 90000|, # 80 + |100,900,10000, 100000|] # 99 + for i=1 to count(r) do + v = values(r[i]) + assert(vec_same_missing(v, v_ref[i]), "percentile_missing_3 lin value [" & i & "]",5) + end for + +end test_percentile_missing_3 + +function test_rms_a() + + fs = fs_22 + + # global + + # single field + v = rms_a(fs) + v_ref = 289.241066893 + assert_equal(v, v_ref, "rms_a",1) + + # real life example + f1 = read('monthly_avg.grib') + v = vector(rms_a(f1)) + assert_equal(count(v),count(f1), "rms_a_count", 2) + v_ref = |284.463,288.644,292.036,294.422,293.681,291.267,288.863,289.005| + assert(vec_same(v, v_ref,1E-2), "rms_a",2) + + # sub area + area = [60, -20, 30, 28] + + v = rms_a(fs, area) + v_ref = 288.33352857 + assert_equal(v, v_ref, "rms_a",3) + + f1 = read('monthly_avg.grib') + v = vector(rms_a(f1, area)) + assert_equal(count(v),count(f1), "rsm_a_count", 4) + v_ref = |322.811,325.302,346.721,356.758,354.736,328.896,313.896,303.971| + assert(vec_same(v, v_ref,1E-2), "rms_a",4) + +end test_rms_a + +function test_stdev() + fs = fs_77 + + # single field + r = stdev(fs) + v = values(r) + v_ref = v * 0 + assert_equal(count(r), 1, "stdev_count", 1) + assert(vec_same(v, v_ref), "stdev", 1) + + # known stdev + f = fs & (4*fs) & (10*fs) + r = stdev(f) + v = values(r) + v_ref = values(fs) * sqrt(42/3) + assert_equal(count(r), 1, "stdev_count", 2) + assert(vec_same(v, v_ref, 1E-4), "stdev", 2) + + # real example + f = read('monthly_avg.grib') + r = stdev(f) + assert_equal(count(r),1, "stdev_count", 3) + v = values(r) + + v_ref_mean = v * 0 + for i=1 to count(f) do + v_ref_mean = v_ref_mean + values(f[i]) + end for + v_ref_mean = v_ref_mean / count(f) + v_ref = v * 0 + for i=1 to count(f) do + v_ref = v_ref + (values(f[i]) - v_ref_mean)^2 + end for + v_ref = sqrt(v_ref/count(f)) + assert(vec_same(v, v_ref), "stdev",3) + +end test_stdev + +function test_stdev_a() + fs = fs_22 + + # const field + v = stdev_a(fs*0) + v_ref = 0 + assert_equal(v, v_ref, "stdev_a",0) + + # single field + v = stdev_a(fs) + v_ref = 13.3863463156 + assert_equal(v, v_ref, "stdev_a",1) + + # real life example + f1 = read('monthly_avg.grib') + v = vector(stdev_a(f1)) + assert_equal(count(v),count(f1), "stdev_a_count", 2) + v_ref = |43.4115,50.5214,54.5082,51.4585,43.8788,34.9506,28.5748,28.0585| + assert(vec_same(v, v_ref,1E-2), "stdev_a",2) + + # sub area + area = [60, -20, 30, 28] + + v = stdev_a(fs, area) + v_ref = 6.2232558479 + assert_equal(v, v_ref, "stdev_a",3) + + f1 = read('monthly_avg.grib') + v = vector(stdev_a(f1, area)) + assert_equal(count(v),count(f1), "stdev_a_count", 4) + v_ref = |28.1503,18.4203,14.5876,26.4032,14.821,13.4898,13.9025,9.42017| + assert(vec_same(v, v_ref,1E-2), "stdev_a",4) + +end test_stdev_a + +function test_sum() + fs_name = "sum" + + fs = fs_77 + fs_m = bitmap(fs, bitmap(fs > 280, 1)) + + # single fields + f = fs + r = sum(f) + v = values(r) + v_ref = values(fs) + assert_equal(count(r),1, fs_name & " - count", 1) + assert(vec_same(v, v_ref), fs_name & "- values", 1) + + # known sum + f = fs & fs & fs + r = sum(f) + v = values(r) + v_ref = values(fs) * 3 + assert_equal(count(r),1, fs_name & " - count", 2) + assert(vec_same(v, v_ref), fs_name & "- values", 2) + + # real life example + f = read('monthly_avg.grib') + r = sum(f) + assert_equal(count(r),1, fs_name & " - count", 3) + v = values(r) + v_ref = v * 0 + for i=1 to count(f) do + v_ref = v_ref + values(f[i]) + end for + assert(vec_same(v, v_ref), fs_name & "- values",3) + + # missing values - single field + f = fs_m + r = sum(f) + v = values(r) + v_ref = values(fs_m) + assert_equal(count(r),1, fs_name & " - count", 4) + assert(vec_same_missing(v, v_ref), fs_name & " - values", 4) + + # known sum + f = fs & 2*fs_m & 3*fs_m + r = sum(f) + v = values(r) + v_ref = values(fs_m) * 6 + assert_equal(count(r),1, fs_name & " - count", 5) + assert(vec_same(v, v_ref), fs_name & " - values", 5) + +end test_sum + +function test_sum_missing() + fs_name = "sum_missing" + + fs = fs_77 + fs_m = bitmap(fs, bitmap(fs > 280, 1)) + + # single fields + f = fs + r = sum(f, "missing") + v = values(r) + v_ref = values(fs) + assert_equal(count(r),1, fs_name & " - count", 1) + assert(vec_same(v, v_ref), fs_name & " - values", 1) + + # known mean + f = fs & fs & fs + r = sum(f, "missing") + v = values(r) + v_ref = values(fs) * 3 + assert_equal(count(r),1, fs_name & " - count", 2) + assert(vec_same(v, v_ref), fs_name & " - values", 2) + + # real life example + f = read('monthly_avg.grib') + r = sum(f, "missing") + assert_equal(count(r),1, fs_name & " - count", 3) + v = values(r) + v_ref = v * 0 + for i=1 to count(f) do + v_ref = v_ref + values(f[i]) + end for + assert(vec_same(v, v_ref), fs_name & " - values",3) + + # missing values - single field + f = fs_m + r = sum(f,"missing") + v = values(r) + v_ref = values(fs_m) + assert_equal(count(r),1, fs_name & " - count", 4) + assert(vec_same_missing(v, v_ref), fs_name & " - values", 4) + + # multiple fields, in the second one there are some missing values + f = fs & fs_m & 2*fs + + # in the first point we only have missing values! + for i=1 to count(f) do + fv = values(f[i]) + fv[1] = vector_missing_value + f[i] = set_values(f[i], fv) + end for + + r = sum(f,"missing") + v = values(r) + + b1 = values(fs_m)*0 + b1 = nobitmap(b1,1) + b2 = values(fs_m)*0+1 + b2 = nobitmap(b2,0) + v_ref = values(fs)*(b1*3. + b2*4.) + v_ref[1] = vector_missing_value + + assert_equal(count(r),1, fs_name & " - count", 5) + assert(vec_same_missing(v, v_ref,1E-5), fs_name & " - values", 5) + +end test_sum_missing + +function test_var() + fs = fs_77 + + # single field + r = var(fs) + v = values(r) + v_ref = v * 0 + assert_equal(count(r), 1, "var_count", 1) + assert(vec_same(v, v_ref), "var", 1) + + # increase grib precision for next test + prev_b = gribsetbits(32) + + # known variance + f = fs & (4*fs) & (10*fs) + r = var(f) + v = values(r) + v_ref = values(fs) + v_ref = v_ref * v_ref * 42/3 + assert_equal(count(r), 1, "var_count", 2) + # TODO: figure out why the diff is so large between result and reference + assert(vec_same(v, v_ref, 1E-3), "var", 2) + + # reset precision + gribsetbits(prev_b) + + # real life example + f = read('monthly_avg.grib') + r = var(f) + assert_equal(count(r),1, "var_count", 3) + v = values(r) + + v_ref_mean = v * 0 + for i=1 to count(f) do + v_ref_mean = v_ref_mean + values(f[i]) + end for + v_ref_mean = v_ref_mean / count(f) + v_ref = v * 0 + for i=1 to count(f) do + v_ref = v_ref + (values(f[i]) - v_ref_mean)^2 + end for + v_ref = v_ref/count(f) + assert(vec_same(v, v_ref), "var",3) + +end test_var + +function test_var_a() + + fs = fs_22 + + # global + + # single field + v = var_a(fs) + v_ref = 179.19426768 + assert_equal(v, v_ref, "var_a",1) + + # real life example + f1 = read('monthly_avg.grib') + v = vector(var_a(f1)) + assert_equal(count(v),count(f1), "var_a_count", 2) + v_ref = |1884.56,2552.41,2971.15,2647.97,1925.35,1221.54,816.517,787.277| + assert(vec_same(v, v_ref,1E-2), "var_a",2) + + # sub area + area = [60, -20, 30, 28] + + v = var_a(fs, area) + v_ref = 38.7289133484 + assert_equal(v, v_ref, "var_a",3) + + f1 = read('monthly_avg.grib') + v = vector(var_a(f1, area)) + assert_equal(count(v),count(f1), "var_a_count", 4) + v_ref = |792.438,339.306,212.798,697.127,219.661,181.974,193.281,88.7397| + assert(vec_same(v, v_ref,1E-2), "var_a",4) + +end test_var_a + + +# --------------------------------------------------- + +function step_equal(fs:fieldset, refstep:number) + s = grib_get_long(fs, 'step') + return (s = refstep) +end steps_equal + +function steps_equal(fs:fieldset, refsteps:list) + s = grib_get_long(fs, 'step') + return is_equal_any(s, refsteps) +end steps_equal + +function levels_equal(fs:fieldset, reflevs:list) + s = grib_get_long(fs, 'level') + eq = is_equal_any(s, reflevs) + if not eq then + print('levels not equal: ', s, ' vs ref ', reflevs) + end if + return eq +end levels_equal + +function params_equal(fs:fieldset, refparams:list) + s = grib_get_string(fs, 'shortName') + return is_equal_any(s, refparams) +end params_equal diff -Nru metview-5.17.4/metview/test/macros/fieldset_util.mv metview-5.19.2/metview/test/macros/fieldset_util.mv --- metview-5.17.4/metview/test/macros/fieldset_util.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/fieldset_util.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,623 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +global fs_22 = read('t1000_LL_2x2.grb') +global fs_77 = read('t1000_LL_7x7.grb') + +test_basic() + +test_datainfo() +test_duplicate() +test_find() +test_gfind() +test_grib_indexes() +test_gribsetbits() +test_indexes() +test_indexes_interpolate() +test_lookup() +test_merge() +test_read() +test_set_values() +test_values() + + +# perform some basic operations on the 'fieldset' Macro data type +function test_basic() + a = read('hindcast.grib') + steps = [0,6,24,36,48,72] + + assert(steps_equal(a, steps), 'all fields') + assert(step_equal(a[1], 0), 'first field') + assert(step_equal(a[count(a)], 72), 'last field') + assert(steps_equal(a[1,3], [0,6,24]), '2 indexes (1)') + assert(steps_equal(a[3,6], [24,36,48,72]), '2 indexes (2)') + assert(steps_equal(a[2,6,2], [6,36,72]), '3 indexes') + + i = |2, 3, 6, 2| + assert(steps_equal(a[i], [6,24,72,6]), 'vector index (1)') + i = |5| + assert(step_equal(a[i], 48), 'vector index (2)') +end test_basic + + +function test_datainfo() + a = read('hindcast.grib') + + di = datainfo(a) + di3 = di[3] + assert(di3.index = 3, 'datainfo.index') + assert(di3.number_present = 2664, 'datainfo.number_present') + assert(di3.number_missing = 0, 'datainfo.number_missing') + assert(di3.proportion_present = 1, 'datainfo.proportion_present') + assert(di3.proportion_missing = 0, 'datainfo.proportion_missing') +end test_datainfo + +function test_duplicate() + fs = fs_77 + + d = duplicate(fs, 1) + assert_equal(count(d),1,"duplicate",1) + + d = duplicate(fs, 2) + assert_equal(count(d),2,"duplicate",2) + +end test_duplicate + +function test_find() + fs = read('t1000_LL_2x2_with_missing.grb') + + # find() cannot use a tolerance so it is almost impossible to + # find a floating value, so we cast it into int!!! + + f = int(fs*100) + + dref = 2015-04-22 12:00 + + # with value only + v = find(f, 28845) + v_ref = [[54,242],[52,100],[50,64],[50,104],[50,248],[48,20],[48,54],[48,104],[48,250],[46,22],[46,356],[44,130], + [44,242],[44,354],[42,128],[42,240],[40,4],[38,2],[38,128],[38,130],[38,164],[38,286],[36,122],[36,124], + [36,138],[36,144],[36,198],[36,202],[36,354],[34,18],[34,20],[34,24],[34,28],[34,32],[34,122],[34,130], + [34,132],[34,206],[34,266],[34,274],[34,330],[34,352],[32,124],[32,128],[32,164],[32,244],[32,276],[32,320], + [32,322],[32,340],[32,342],[30,166],[30,216],[30,232],[30,314],[30,340],[28,170],[28,178],[28,180],[28,182], + [28,186],[28,188],[28,340],[28,346],[24,342],[-24,288],[-28,128],[-28,280],[-28,282],[-28,286],[-30,298], + [-30,304],[-32,16],[-32,130],[-32,136],[-32,138],[-32,142],[-32,216],[-32,218],[-32,220],[-32,226],[-32,228], + [-32,230],[-32,276],[-34,12],[-34,16],[-34,48],[-34,50],[-34,52],[-34,54],[-34,90],[-34,112],[-34,130],[-34,180], + [-34,194],[-34,198],[-34,296],[-34,306],[-36,18],[-36,20],[-36,86],[-36,120],[-36,126],[-36,172],[-36,174],[-36,178], + [-36,200],[-36,204],[-36,246],[-36,294],[-36,302],[-36,324],[-36,326],[-36,328],[-36,330],[-38,76],[-38,170],[-38,288], + [-38,308],[-38,316],[-38,334],[-38,338],[-40,0],[-40,32],[-40,152],[-40,274],[-40,302],[-40,310],[-40,312],[-40,350], + [-40,352],[-40,358],[-42,272],[-42,312],[-42,346],[-44,264],[-44,266],[-44,268],[-44,270]] + + assert_equal(count(v),count(v_ref),"find count",1) + + for i=1 to count(v) do + assert_equal(v[i],v_ref[i],"find latlon 1") + assert_equal(nearest_gridpoint(f,v[i],'valid'),28845,"find value 1") + end for + + # with value + area + area = [52.1,99.9,49.9,105.1] + v = find(int(f), 28845, area) + v_ref = [[52,100],[50,104]] + assert_equal(count(v),count(v_ref),"find count",2) + + for i=1 to count(v) do + assert_equal(v[i],v_ref[i],"find latlon 2") + assert_equal(nearest_gridpoint(f,v[i],'valid'),28845,"find value 2") + end for + + # with value + mask + area = [52.1,99.9,49.9,105.1] + area_mask = mask(f, area) + v = find(int(f), 28845, area_mask) + v_ref = [[52,100],[50,104]] + assert_equal(count(v),count(v_ref),"find count",3) + + for i=1 to count(v) do + assert_equal(v[i],v_ref[i],"find latlon 3") + assert_equal(nearest_gridpoint(f,v[i],'valid'),28845,"find value 3") + end for + + # intervals - we use the original field!!! + + # with interval only + f = fs + v = find(f, [234.9,236.0]) + v_ref = [[-78,176],[-80,176],[-80,178],[-80,180]] + assert_equal(count(v),count(v_ref),"find count",4) + + for i=1 to count(v) do + assert_equal(v[i],v_ref[i],"find latlon 4") + vv = nearest_gridpoint(f,v[i],'valid') + assert(vv >= 234.9 and vv <= 236.0,"find value", 4) + end for + + # with interval + area + area = [-77.9, 175.9, -80.1, 176.1] + v = find(f, [234.9,236.0], area) + v_ref = [[-78,176],[-80,176]] + assert_equal(count(v),count(v_ref),"find count",5) + + for i=1 to count(v) do + assert_equal(v[i],v_ref[i],"find latlon 5") + vv = nearest_gridpoint(f,v[i],'valid') + assert(vv >= 234.9 and vv <= 236.0,"find value", 5) + end for + + # with interval + mask + area = [-77.9, 175.9, -80.1, 176.1] + area_mask = mask(f, area) + v = find(f, [234.9,236.0], area_mask) + v_ref = [[-78,176],[-80,176]] + assert_equal(count(v),count(v_ref),"find count",6) + + for i=1 to count(v) do + assert_equal(v[i],v_ref[i],"find latlon 6") + vv = nearest_gridpoint(f,v[i],'valid') + assert(vv >= 234.9 and vv <= 236.0,"find value", 6) + end for + +end test_find + +function test_gfind() + fs = read('t1000_LL_2x2_with_missing.grb') + dref = 2015-04-22 12:00 + gf1 = gfind(fs, 280, 0.5) # fieldset, value, tolerance + assert(count(gf1) = 287, 'gfind1 count is ' & count(gf1)) + assert(values(gf1)[1] = 279.955, 'gf1 values[1]') + assert(values(gf1)[2] = 280.455, 'gf1 values[2]') + assert(latitudes(gf1)[1] = 64, 'gf1 latitudes[1]') + assert(latitudes(gf1)[287] = -58, 'gf1 latitudes[287]') + assert(longitudes(gf1)[1] = 2, 'gf1 longitudes[1]') + assert(longitudes(gf1)[287] = 178, 'gf1 longitudes[287]') + assert(levels(gf1)[1] = 1000, 'gf1 levels[1]') + assert(levels(gf1)[287] = 1000, 'gf1 levels[287]') + assert(dates(gf1)[1]-dref = 0, 'gf1 dates[1]') + assert(dates(gf1)[287]-dref = 0, 'gf1 dates[287]') +end test_gfind + + +function test_grib_indexes() + # read a single GRIB file + fs1 = read("hindcast.grib") + gi = grib_indexes(fs1) + assert(type(gi) = "list", "test_grib_indexes1: type gi") + assert(count(gi) = count(fs1), "test_grib_indexes1: count(fs1)") + assert(gi[1][2] = 0, "test_grib_indexes1: gi[1][2]") + assert(gi[1][3] = 1494, "test_grib_indexes1: gi[1][3]") + assert(gi[3][2] = 3054, "test_grib_indexes1: gi[3][2]") + assert(gi[3][3] = 1494, "test_grib_indexes1: gi[3][3]") + path = gi[1][1] + for i = 2 to count(fs1) do + assert(path = gi[i][1], "test_grib_indexes1: path i") # all paths should be the same + end for + path_parts = parse(path, "/") + assert(path_parts[count(path_parts)] = "hindcast.grib", "test_grib_indexes1: path hindcast") # last bit should be original filename + + # take a selection of fields + fs2 = fs1[3] & fs1[1] & fs1[2] + gi = grib_indexes(fs2) + assert(type(gi) = "list", "test_grib_indexes2: type gi") + assert(count(gi) = count(fs2), "test_grib_indexes2: count(fs2)") + assert(gi[1][2] = 3054, "test_grib_indexes2: gi[1][2]") + assert(gi[1][3] = 1494, "test_grib_indexes2: gi[1][3]") + assert(gi[2][2] = 0, "test_grib_indexes2: gi[2][2]") + assert(gi[2][3] = 1494, "test_grib_indexes2: gi[2][3]") + assert(gi[3][2] = 1494, "test_grib_indexes2: gi[3][2]") + assert(gi[3][3] = 1494, "test_grib_indexes2: gi[3][3]") + path = gi[1][1] + for i = 2 to count(fs2) do + assert(path = gi[i][1], "test_grib_indexes2: path i") # all paths should be the same + end for + path_parts = parse(path, "/") + assert(path_parts[count(path_parts)] = "hindcast.grib", "test_grib_indexes2: path hindcast") # last bit should be original filename + + # read another fieldset and make a new fieldset containing fields from both + fs3 = read('surface_wind.grib') + fsmerged = fs1[2] & fs3[4] & fs1[1] + gi = grib_indexes(fsmerged) + assert(type(gi) = "list", "test_grib_indexes3: type gi") + assert(count(gi) = 3, "test_grib_indexes3: count gi") + assert(gi[1][2] = 1494, "test_grib_indexes3: gi[1][2]") + assert(gi[1][3] = 1494, "test_grib_indexes3: gi[1][3]") + path_parts = parse(gi[1][1], "/") + assert(path_parts[count(path_parts)] = "hindcast.grib", "test_grib_indexes3: path1 hindcast") + assert(gi[2][2] = 16476, "test_grib_indexes3: gi[2][2]") + assert(gi[2][3] = 5436, "test_grib_indexes3: gi[2][3]") + path_parts = parse(gi[2][1], "/") + assert(path_parts[count(path_parts)] = "surface_wind.grib", "test_grib_indexes3: path2 surface_wind") + assert(gi[3][2] = 0, "test_grib_indexes3: gi[3][2]") + assert(gi[3][3] = 1494, "test_grib_indexes3: gi[3][3]") + path_parts = parse(gi[3][1], "/") + assert(path_parts[count(path_parts)] = "hindcast.grib", "test_grib_indexes3: path3 hindcast") + + # perform computations, forcing temporary file + # note that it seems that in this case, MARS returns zero for the length + fstemp = fs1*1 + gi = grib_indexes(fstemp) + assert(type(gi) = "list", "test_grib_indexes4: type gi") + assert(count(gi) = count(fstemp), "test_grib_indexes4: count gi") + assert(gi[1][2] = 0, "test_grib_indexes4: gi[1][2]") + assert(gi[1][3] = 8154, "test_grib_indexes4: gi[1][3]") + assert(gi[2][2] = 8160, "test_grib_indexes4: gi[1][2]") + assert(gi[2][3] = 8154, "test_grib_indexes4: gi[1][3]") + assert(gi[3][2] = 16320, "test_grib_indexes4: gi[3][2]") + assert(gi[3][3] = 8154) + path = gi[1][1] + for i = 2 to count(fstemp) do + assert(path = gi[i][1], "test_grib_indexes4: paths same") # all paths should be the same + end for + assert(search(path, "mv.") >= 0, "test_grib_indexes4: path in tmp") # "mv." should appear in name of temporary directory +end test_grib_indexes + +function test_gribsetbits() + + f = fs_22 + + ori = gribsetbits(16) + g = f*1 + v = grib_get_long(g, 'bitsPerValue') + assert_equal(v,16,"gribsetbits",1) + + prev = gribsetbits(24) + g = f*1 + v = grib_get_long(g, 'bitsPerValue') + assert_equal(v,24,"gribsetbits",2) + assert_equal(prev,16,"gribsetbits prev",2) + + gribsetbits(ori) + +end test_gribsetbits + +function test_indexes() + + f = fs_22-10 + + vals = |230, 240, 250| + r = indexes(f, vals) + v = values(r) + v_ref = values(f) + for i=1 to count(v_ref) do + if v_ref[i] < 235 then + v_ref[i]=0 + else if v_ref[i] < 245 then + v_ref[i]=1 + else + v_ref[i]=2 + end if + end for + + assert(vec_same(v, v_ref), "indexes",1) + +end test_indexes + +function test_indexes_interpolate() + + f = fs_22-10 + sv = values(f) + + vals = |230, 240, 250| + r = indexes(f, vals, 'interpolate') + rv = values(r) + + # value below the min, should be 230, which equals index 0 (0-based, capped to 0) + i = 14814 + assert_equal(sv[i], 229.454589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 0, 'test_indexes_interpolate ' & i & ' result val') + + i = 15577 + assert_equal(sv[i], 228.454589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 0, 'test_indexes_interpolate ' & i & ' result val') + + + # value between 230 and 240, which equals index 0.x + i = 15175 + assert_equal(sv[i], 236.954589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 0.6954589844, 'test_indexes_interpolate ' & i & ' result val') + + i = 15350 + assert_equal(sv[i], 239.954589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 0.9954589844, 'test_indexes_interpolate ' & i & ' result val') + + i = 14817 + assert_equal(sv[i], 230.954589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 0.0954589844, 'test_indexes_interpolate ' & i & ' result val') + + + # value between 240 and 250, which equals index 1.x + i = 16301 + assert_equal(sv[i], 248.454589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 1.8454589844, 'test_indexes_interpolate ' & i & ' result val') + + i = 381 + assert_equal(sv[i], 243.954589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 1.3954589844, 'test_indexes_interpolate ' & i & ' result val') + + + # value above the max, should be 250, which equals index 2 (0-based, capped to 0) + i = 10491 + assert_equal(sv[i], 283.954589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 2, 'test_indexes_interpolate ' & i & ' result val') + + # value above the max, should be 250, which equals index 2 (0-based, capped to 0) + i = 15968 + assert_equal(sv[i], 250.454589844, 'test_indexes_interpolate ' & i & ' source val') + assert_equal(rv[i], 2, 'test_indexes_interpolate ' & i & ' result val') + + #found = (sv > 240) * (sv < 245) + #print(find(found, 1, 'all')) + #print(sv[381]) + +end test_indexes_interpolate + +function test_lookup() + + fs = fs_22 + + # one field + f = fs + r = lookup(f*0, f) + v = values(r) + v_ref = values(f) + assert(vec_same(v, v_ref), 'lookup',1) + + # multiple fields + f = fs & 2*fs + r = lookup(f[1] > 273.16, f) + v = values(r) + v_ref = values(f[1]) + v_ref = v_ref * (v_ref <= 273.16) + 2*v_ref * (v_ref > 273.16) + assert(vec_same(v, v_ref), 'lookup',2) + +end test_lookup + +function test_merge() + + fs = fs_22 + + r = fs & nil + assert_equal(count(fs), count(r),"merge count",1) + v = values(r) + v_ref = values(fs) + assert(vec_same(v,v_ref),"merge value",1) + + r = fs & 2*fs & -1*fs + assert_equal(3*count(fs), count(r),"merge count",2) + + v = values(r[1]) + v_ref = values(fs) + assert(vec_same(v,v_ref),"merge value [1]",2) + + v = values(r[2]) + v_ref = values(2*fs) + assert(vec_same(v,v_ref),"merge value [2]",2) + + v = values(r[3]) + v_ref = values(-1*fs) + assert(vec_same(v,v_ref),"merge value [3]",2) + + function levs(g) + return grib_get_double(g, 'level') + end levs + + # test calling the merge() function directly + fs_pl = read('xs_rgg_input.grib') + fs_ml = read('xs_ml_input.grib') + pl_levs = levs(fs_pl) + ml_levs = levs(fs_ml) + + m1 = merge(fs_pl) # single fieldset + assert(list_same(levs(m1), pl_levs),"merge levs",1) + + m1 = merge(fs_pl[1]) + assert_equal(levs(m1), pl_levs[1],"merge levs",2) + + m1 = merge(fs_pl[2]) + assert_equal(levs(m1), pl_levs[2],"merge levs",3) + + m1 = merge(fs_pl, fs_ml) + assert(list_same(levs(m1), pl_levs&ml_levs),"merge levs",4) + + m1 = merge(fs_pl[1], fs_ml[2]) + assert(list_same(levs(m1), [pl_levs[1]]&[ml_levs[2]]),"merge levs",5) + + m1 = merge(fs_pl[4,6], fs_ml[22,31]) + assert(list_same(levs(m1), pl_levs[4,6]&ml_levs[22,31]),"merge levs",6) + + m1 = merge(fs_pl, fs_ml[2], fs_ml[9], fs_pl[2,3], fs_pl) + assert(list_same(levs(m1), [1000,850,700,500,400,300,1,2,850,700,1000,850,700,500,400,300]),"merge levs",7) + +end test_merge + +# --------------------------------------------------- +# mars filter and double filter, index filter and double filter +function test_read() + a = read('hindcast.grib') + + lstep = [0,24,36,48,72] + b = read(data:a, step:lstep) + assert(steps_equal(b,lstep), 'mars single filter') + + c = read(data:b) + assert(steps_equal(c,lstep), 'mars double filter') + + c = read(data:b, step:[24, 72]) + assert(steps_equal(c,[24,72]), 'mars double filter (2)') + + c = b[2,4] + assert(steps_equal(c,[24,36,48]), 'index filter') + + d = read(data:c) + assert(steps_equal(d,[24,36,48]), 'index double filter') + + e = read('tuv_pl.grib') + f = read(data: e, param: 'u') + assert(levels_equal(f, [1000,850,700,500,400,300]), 'mars filter 1 level') + assert(params_equal(f, ['u','u','u','u','u','u']), 'mars filter 1 param') + + g = read(data: f, levelist: [700,400]) + assert(levels_equal(g, [700,400]), 'mars filter 2 level') + assert(params_equal(g, ['u','u']), 'mars filter 2 param') + + h = merge(f[3,5], f[1,2]) + assert(levels_equal(g, [700,400]), 'mars filter on subset level a') + g = read(data: h, levelist: [500,1000]) + assert(levels_equal(g, [500,1000]), 'mars filter on subset level b') + +end test_read + +function test_set_values() + fs = fs_22 + + # single field + v = values(fs) + v = v*0+2 + r = set_values(fs, v) + mnv = minvalue(r) + mxv = maxvalue(r) + assert_equal(mnv,2,"set_values min",1) + assert_equal(mxv,2,"set_values max",1) + + # multiple fields - single vectors + f = fs_22 & fs_22 + v = values(f) + v1 = v[1]*0+2 + r = set_values(f,v1) + assert_equal(count(r),2,"set_values multi count",1) + mnv = minvalue(r[1]) + mxv = maxvalue(r[1]) + assert_equal(mnv,2,"set_values multi max a",1) + assert_equal(mxv,2,"set_values multi min a",1) + mnv = minvalue(r[2]) + mxv = maxvalue(r[2]) + assert_equal(mnv,2,"set_values multi max b",1) + assert_equal(mxv,2,"set_values multi min b",1) + + # multiple fields - multiple vectors + f = fs_22 & fs_22 + v = values(f) + v1 = v[1]*0+2 + v2 = v[1]*0-1 + r = set_values(f,[v1,v2]) + assert_equal(count(r),2,"set_values multi count",2) + mnv = minvalue(r[1]) + mxv = maxvalue(r[1]) + assert_equal(mnv,2,"set_values multi max a",2) + assert_equal(mxv,2,"set_values multi min a",2) + mnv = minvalue(r[2]) + mxv = maxvalue(r[2]) + assert_equal(mnv,-1,"set_values multi max b",2) + assert_equal(mxv,-1,"set_values multi min b",2) + + # multiple fields - single vector - resize + f = fs_22 & fs_22 + v = values(f) + v1 = v[1]*0+2 + v1 = v1[1,count(v1) - 100] + r = set_values(f,v1,"resize") + assert_equal(count(r),2,"set_values multi count",3) + mnv = minvalue(r[1]) + mxv = maxvalue(r[1]) + assert_equal(mnv,2,"set_values multi max a",3) + assert_equal(mxv,2,"set_values multi min a",3) + mnv = minvalue(r[2]) + mxv = maxvalue(r[2]) + assert_equal(mnv,2,"set_values multi max b",3) + assert_equal(mxv,2,"set_values multi min b",3) + + + f = fs_22 & fs_22 + v = values(f) + v1 = v[1]*0+2 + v1 = v1 & |2,2,2,2| + r = set_values(f,v1,"resize") + assert_equal(count(r),2,"set_values multi count",4) + mnv = minvalue(r[1]) + mxv = maxvalue(r[1]) + assert_equal(mnv,2,"set_values multi max a",4) + assert_equal(mxv,2,"set_values multi min a",4) + mnv = minvalue(r[2]) + mxv = maxvalue(r[2]) + assert_equal(mnv,2,"set_values multi max b",4) + assert_equal(mxv,2,"set_values multi min b",4) + + # multiple fields - multiple vectors - resize + f = fs_22 & fs_22 + v = values(f) + v1 = v[1]*0+2 + v2 = v[1]*0-1 + v1 = v1[1,count(v1) - 100] + v2 = v2[1,count(v2) - 1000] + r = set_values(f,[v1,v2],"resize") + assert_equal(count(r),2,"set_values multi count",5) + mnv = minvalue(r[1]) + mxv = maxvalue(r[1]) + assert_equal(mnv,2,"set_values multi max a",5) + assert_equal(mxv,2,"set_values multi min a",5) + mnv = minvalue(r[2]) + mxv = maxvalue(r[2]) + assert_equal(mnv,-1,"set_values multi max b",5) + assert_equal(mxv,-1,"set_values multi min b",5) + +end test_set_values + +function test_values() + + # single field + f = fs_22*0+2 + v = values(f) + v_ref = vector(count(v)) + for i=1 to count(v_ref) do + v_ref[i] = 2 + end for + assert(vec_same(v,v_ref),"values",1) + + # multiple fields + f = (fs_22*0+2) & (fs_22*0-1) + v = values(f) + assert_equal(count(v),2,"values multi count",1) + v_ref = v_ref*0+2 + assert(vec_same(v[1],v_ref),"values multi a",1) + v_ref = v_ref*0-1 + assert(vec_same(v[2],v_ref),"values multi b",1) + +end test_values + +# --------------------------------------------------- + +function step_equal(fs:fieldset, refstep:number) + s = grib_get_long(fs, 'step') + return (s = refstep) +end steps_equal + +function steps_equal(fs:fieldset, refsteps:list) + s = grib_get_long(fs, 'step') + return is_equal_any(s, refsteps) +end steps_equal + +function levels_equal(fs:fieldset, reflevs:list) + s = grib_get_long(fs, 'level') + eq = is_equal_any(s, reflevs) + if not eq then + print('levels not equal: ', s, ' vs ref ', reflevs) + end if + return eq +end levels_equal + +function params_equal(fs:fieldset, refparams:list) + s = grib_get_string(fs, 'shortName') + return is_equal_any(s, refparams) +end params_equal diff -Nru metview-5.17.4/metview/test/macros/flexpart_output.mv metview-5.19.2/metview/test/macros/flexpart_output.mv --- metview-5.17.4/metview/test/macros/flexpart_output.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/flexpart_output.mv 2023-07-15 08:28:47.000000000 +0000 @@ -11,6 +11,7 @@ test_flexpart_conc_file() test_flexpart_flux_file() +test_flexpart_bwd_file() # check if we can still read and filter the FLEXPART output file function test_flexpart_conc_file() @@ -127,4 +128,52 @@ fn_name & " title", 1) -end test_flexpart_flux_file \ No newline at end of file +end test_flexpart_flux_file + +function test_flexpart_bwd_file() + + fn_name = "flexpart_bwd_file" + + f = read("flexpart_bwd.grib") + + assert_equal(count(f), 2, fn_name & " count", 1) + + #values + v = values(f[1]) + assert_equal(v[1], 0, 1E-10, fn_name & " values 0", 1) + assert_equal(v[12973],4.8665E-12, 1E-14, fn_name & " values 1", 1) + assert_equal(v[14560], 0, 1E-10, fn_name & " values 2", 1) + + # shortNames + m = grib_get_string(f, "shortName") + m_ref = ["fprt","fprt"] + assert_equal(m, m_ref, fn_name & " shortName", 1) + + # filter + lev=1500 + par="fprt" + step=-45 + + g = flexpart_filter(data: f, param: par, levType: "hl", + level: lev, step: step) + + assert_equal(count(g), 1, fn_name & " filter count", 1) + + m = grib_get(g, FX_KEYS) + assert_equal(count(m), 1, fn_name & " filter meta count", 1) + m_ref = ["fprt","heightAboveGround",1500,-45,"s",1,"SO2 ",1,1, + "INVERNESS ",1,1,0,999999999] + + assert_equal(m[1], m_ref, fn_name & " filter meta", 1) + + # title + title=flexpart_build_title(data: g, + fontsize: 0.3, + units: "ng m**-3") + + assert_equal(title.TEXT_LINE_1, + "FLEXPART Par: . [ng m**-3] . Species: Level: m . Step: Valid: ", + fn_name & " title", 1) + + +end test_flexpart_bwd_file \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/flexpart_run.mv metview-5.19.2/metview/test/macros/flexpart_run.mv --- metview-5.17.4/metview/test/macros/flexpart_run.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/flexpart_run.mv 2023-07-15 08:28:47.000000000 +0000 @@ -8,12 +8,15 @@ "speciesId:l", "speciesName", "numberOfReleases:l","releaseNumber:l", "releaseName", "numberOfAgeClasses:l", "ageClass:l","ageClassBegin:l","ageClassEnd:l"] - -test_flexpart_run() + +test_flexpart_fwd_run() +test_flexpart_bwd_run() +test_flexpart_tr_run() -function test_flexpart_run() +# forward simulation +function test_flexpart_fwd_run() - fn_name = "flexpart_run" + fn_name = "flexpart_fwd_run" exe = getenv("MV_FLEXPART_EXE") if exe = "" or exe = nil then @@ -21,10 +24,10 @@ end if # create dirs - data_dir = getenv("TMPDIR") & "/flexpart_data_tmp" + data_dir = getenv("TMPDIR") & "/flexpart_data_fwd_tmp" res_dir = getenv("TMPDIR") & "/flexpart_res_fwd_tmp" - print("data_dir=", data_dir) - print("res_dir=", res_dir) + #print("data_dir=", data_dir) + #print("res_dir=", res_dir) if shell("mkdir -p " & data_dir) <> 0 then fail(fn_name & ": failed to create data_dir=", data_dir) end if @@ -50,7 +53,7 @@ end if #home = getenv("HOME") - #shell("cd " & res_dir & "; cp " & home "/metview/ctest/conc_s001.grib .; cp " & home & "/metview/ctest/flux_s001.grib .") + #shell("cd " & res_dir & "; cp " & home "/metview/ctest/flexpart_data/conc_s001.grib .; cp " & home & "/metview/ctest/flexpart_data/flux_s001.grib .") #Define release rel_volcano = flexpart_release( @@ -65,11 +68,11 @@ particle_count : 10000, masses : 1000000 ) - + #the tgz is extracted into a subfolder data_dir = data_dir & "/flexpart_test_input_data" print("data_dir=" & data_dir) - + #Run flexpart (asynchronous call!) r= flexpart_run( output_path : res_dir, @@ -99,6 +102,8 @@ fail(fn_name & "failed to run flexpart") end if + print(r) + # ---------------------- # check conc result # ---------------------- @@ -179,4 +184,276 @@ assert_equal(m[1], m_ref, fn_name & " flux filter meta", 1) -end test_flexpart_run() \ No newline at end of file +end test_flexpart_fwd_run() + +# backward simulation +function test_flexpart_bwd_run() + + fn_name = "flexpart_bwd_run" + + exe = getenv("MV_FLEXPART_EXE") + if exe = "" or exe = nil then + fail(fn_name & ": no MV_FLEXPART_EXE env variable is defined") + end if + + # create dirs + data_dir = getenv("TMPDIR") & "/flexpart_data_bwd_tmp" + res_dir = getenv("TMPDIR") & "/flexpart_res_bwd_tmp" + #print("data_dir=", data_dir) + #print("res_dir=", res_dir) + + if shell("mkdir -p " & data_dir) <> 0 then + fail(fn_name & ": failed to create data_dir=", data_dir) + end if + if shell("mkdir -p " & res_dir) <> 0 then + fail(fn_name & ": failed to create res_dir=", res_dir) + end if + + # get data from nexus + data_tgz = "flexpart_test_input_data.tar.gz" + url = "https://get.ecmwf.int/repository/test-data/metview/tests/" & data_tgz + r = download(url: url, target: data_dir & "/" & data_tgz) + + #Because Macro runs asynchronously we need to use a reference to + #the download result (e.g. by printing it). Otherwise the macro would + #exit and download would continue running in the background. + #print(r) + if r = nil then + fail(fn_name & ": failed to download input data from url=" & url ) + end if + + if shell("cd " & data_dir & ";tar -xzf " & data_tgz) <> 0 then + fail(fn_name & ": failed to unpack input data") + end if + + #home = getenv("HOME") + #shell("cd " & res_dir & "; cp " & home & "/metview/ctest/flexpart_data/time_s001.grib .") + + #Define release + rel_inv = flexpart_release( + name : "INVERNESS", + starting_date : 1, + starting_time : 12, + ending_date : 2, + ending_time : 12, + level_units : "agl", + top_level : 500, + bottom_level : 0, + particle_count : 10000, + masses : 1, + area : [57.44,-4.23,57.46,-4.21] + ) + + #the tgz is extracted into a subfolder + data_dir = data_dir & "/flexpart_test_input_data" + print("data_dir=" & data_dir) + + #Run flexpart (asynchronous call!) + r = flexpart_run( + output_path : res_dir, + input_path : data_dir, + simulation_direction : "backward", + starting_date : 20120517, + starting_time : 12, + ending_date : 20120519, + ending_time : 12, + output_field_type : "rtime", + output_area : [40,-25,66,10], + output_grid : [0.25,0.25], + output_levels : [100,200,300,400,500,600,700,800,900,1000,1100,1200,1500,2000,3000,4000,5000], + release_species : 8, + release_units : "mass", + receptor_units : "mass", + output_for_each_release : "on", + releases : rel_inv + ) + + #Because macro runs asynchronously we need to use a reference to + #the flexpart_run result (e.g. by printing it). Otherwise the macro would + #exit and flexpart_run would continue running in the background. + #print(r) + + if r = nil then + fail(fn_name & "failed to run flexpart") + end if + + print(r) + + # ---------------------- + # check fprt result + # ---------------------- + + f = read(res_dir & "/time_s001.grib") + assert_equal(count(f), 272, fn_name & " fprt count",1) + + #values + v = values(f[1]) + assert_equal(count(v), 14560,fn_name & " fprt values count", 1) + assert_equal(v[1], 0, 1E-14, fn_name & " fprt values 0", 1) + assert_equal(v[12973],4.8665E-12, 1E-14, fn_name & " fprt values 1", 1) + assert_equal(v[14560], 0, 1E-14, fn_name & " fprt values 2", 1) + + # shortNames + m = grib_get_string(f[1,3], "shortName") + m_ref = ["fprt","fprt","fprt"] + assert_equal(m, m_ref, fn_name & " fprt shortName", 1) + + # filter + lev=1500 + par="fprt" + step=-45 + + g = flexpart_filter(data: f, param: par, levType: "hl", + level: lev, step: step) + + assert_equal(count(g), 1, fn_name & " filter count", 1) + + m = grib_get(g, FX_KEYS) + assert_equal(count(m), 1, fn_name & " filter meta count", 1) + m_ref = ["fprt","heightAboveGround",1500,-45,"s",1,"SO2 ",1,1, + "INVERNESS ",1,1,0,999999999] + + assert_equal(m[1], m_ref, fn_name & " filter meta", 1) + + +end test_flexpart_bwd_run + +# trajectory simulation +function test_flexpart_tr_run() + + fn_name = "flexpart_tr_run" + + exe = getenv("MV_FLEXPART_EXE") + if exe = "" or exe = nil then + fail(fn_name & ": no MV_FLEXPART_EXE env variable is defined") + end if + + # create dirs + data_dir = getenv("TMPDIR") & "/flexpart_data_tr_tmp" + res_dir = getenv("TMPDIR") & "/flexpart_res_tr_tmp" + #print("data_dir=", data_dir) + #print("res_dir=", res_dir) + + if shell("mkdir -p " & data_dir) <> 0 then + fail(fn_name & ": failed to create data_dir=", data_dir) + end if + if shell("mkdir -p " & res_dir) <> 0 then + fail(fn_name & ": failed to create res_dir=", res_dir) + end if + + # get data from nexus + data_tgz = "flexpart_test_input_data.tar.gz" + url = "https://get.ecmwf.int/repository/test-data/metview/tests/" & data_tgz + r = download(url: url, target: data_dir & "/" & data_tgz) + + #Because Macro runs asynchronously we need to use a reference to + #the download result (e.g. by printing it). Otherwise the macro would + #exit and download would continue running in the background. + #print(r) + if r = nil then + fail(fn_name & ": failed to download input data from url=" & url ) + end if + + if shell("cd " & data_dir & ";tar -xzf " & data_tgz) <> 0 then + fail(fn_name & ": failed to unpack input data") + end if + + #home = getenv("HOME") + #shell("cd " & res_dir & "; cp " & home & "/metview/ctest/flexpart_data/tr_r001.csv .") + + #Define release + rel_ncastle = flexpart_release( + name : "NEWCASTLE", + starting_date : 0, + starting_time : 15, + ending_date : 0, + ending_time : 18, + level_units : "agl", + top_level : 500, + bottom_level : 0, + particle_count : 10000, + masses : 1000, + area : [54.96,-1.6,54.96,-1.6] + ) + + #the tgz is extracted into a subfolder + data_dir = data_dir & "/flexpart_test_input_data" + print("data_dir=" & data_dir) + + #Run forward simulation (asynchronous call) + r = flexpart_run( + output_path : res_dir, + input_path : data_dir, + starting_date : 20120517, + starting_time : 12, + ending_date : 20120519, + ending_time : 12, + output_field_type : "none", + output_trajectory : "on", + output_area : [40,-25,66,10], + output_grid : [0.25,0.25], + output_levels : 500, + release_species : 1, + release_units: "mass", + receptor_units: "mass", + releases : rel_ncastle + ) + + #Because macro runs asynchronously we need to use a reference to + #the flexpart_run result (e.g. by printing it). Otherwise the macro would + #exit and flexpart_run would continue running in the background. + #print(r) + + if r = nil then + fail(fn_name & "failed to run flexpart") + end if + + print(r) + + # ---------------------- + # check trajectory result + # ---------------------- + + # Read table (CSV) data + tbl=read_table(table_filename: res_dir & "/tr_r001.csv", + table_header_row: "2", + table_meta_data_rows: "1") + + # header + keys = metadata_keys(tbl) + keys_ref = ["clNum","end","lat1","lat2","lon1","lon2","particlesNum", + "runDate","runTime","start","z1","z2","zUnits"] + assert_equal(keys, keys_ref, fn_name & " keys",1) + + runDate=date(metadata_value(tbl,"runDate")) + assert_equal(runDate, 2012-05-17 00:00:00, fn_name & " rundate",1) + + runTime=number(metadata_value(tbl,"runTime")) + assert_equal(runTime, 120000, fn_name & " runtime",1) + + startSec=number(metadata_value(tbl,"start")) + assert_equal(startSec, 10800, fn_name & " start",1) + + endSec=number(metadata_value(tbl,"end")) + assert_equal(endSec, 21600, fn_name & " end",1) + + clNum=number(metadata_value(tbl,"clNum")) + assert_equal(clNum, 5, fn_name & " clnum",1) + + for i=1 to 1 do + + clLatName="clLat_" & i + clLonName="clLon_" & i + + clLat=values(tbl,clLatName) + lat_ref=|54.96,55.21,55.347,55.462,55.572,55.486,55.369,55.189,55.468,55.326,54.958,54.629,54.248,53.82,53.384,52.941| + assert(vec_same(clLat, lat_ref),fn_name & " " & clLatName,1) + + clLon=values(tbl,clLonName) + lon_ref=|-1.6,-1.344,-1.322,-1.399,-1.526,-2.755,-3.809,-5.095,-5.371,-6.426,-7.694,-9.077,-10.151,-11.044,-11.861,-12.497| + assert(vec_same(clLat, lat_ref),fn_name & " " & clLatName,1) + + end for + +end test_flexpart_tr_run + diff -Nru metview-5.17.4/metview/test/macros/flextra_output.mv metview-5.19.2/metview/test/macros/flextra_output.mv --- metview-5.17.4/metview/test/macros/flextra_output.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/flextra_output.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,74 @@ +#Metview Macro + +include "test_utils.mv" + +test_flextra_output() +test_flextra_multi_output() + +function test_flextra_output() + + fn_name = "flextra_output" + + # read flextra output + flx=read("flextra_res_normal.txt") + + # number of trajectories + trNum=number(flextra_group_get(flx,"trNum")) + + assert_equal(trNum, 5 , fn_name & ": trNum", 1) + + # meta-data for each trajectory + start_times = ["03:00:00","06:00:00","09:00:00","12:00:00","15:00:00"] + for i=1 to trNum do + vals=flextra_tr_get(flx,i,["startTime","stopIndex"]) + assert_equal(vals, [start_times[i],"1"], fn_name & ": meta " & "tr=" & i, 1) + end for + + # data for the first trajectory + vals=flextra_tr_get(flx,1,["lat","lon","date"]) + + assert_equal(count(vals), 3, fn_name & ": meta first tr",1) + + lat=vals[1] + lon=vals[2] + dt=vals[3] + + lat_ref = |63.63,63.5992,63.4449,63.1638,63.0128,63.1078,62.7328,62.3399,62.4022,62.5768,62.7651,63.0468,63.4755,64.0346,64.7086,65.3356,65.8888,66.3628,66.6295,66.3514,65.3932,63.7349,61.4444,58.7767,56.2876| + lon_ref = |-19.05,-13.3063,-7.6374,-2.016,3.2851,8.7149,14.291,18.2208,21.4933,24.8885,27.9038,30.4272,32.4093,33.7897,34.5431,34.5109,33.3879,31.0452,27.9341,24.7241,21.7482,19.2114,17.5497,16.4128,15.8823| + dt_ref = [2012-01-11 03:00:00,2012-01-11 06:00:00,2012-01-11 09:00:00,2012-01-11 12:00:00,2012-01-11 15:00:00,2012-01-11 18:00:00,2012-01-11 21:00:00,2012-01-12 00:00:00,2012-01-12 03:00:00,2012-01-12 06:00:00,2012-01-12 09:00:00,2012-01-12 12:00:00,2012-01-12 15:00:00,2012-01-12 18:00:00,2012-01-12 21:00:00,2012-01-13 00:00:00,2012-01-13 03:00:00,2012-01-13 06:00:00,2012-01-13 09:00:00,2012-01-13 12:00:00,2012-01-13 15:00:00,2012-01-13 18:00:00,2012-01-13 21:00:00,2012-01-14 00:00:00,2012-01-14 03:00:00] + + assert(vec_same(lat, lat_ref,1E-3), fn_name & ": lat",1) + assert(vec_same(lon, lon_ref,1E-3), fn_name & ": lon",1) + assert_equal(dt, dt_ref, fn_name & ": dt",1) + +end test_flextra_output + + +function test_flextra_multi_output() + + fn_name = "flextra_multi_output" + + # read flextra output + flx=read("flextra_res_multi.txt") + + grNum=count(flx) + assert_equal(grNum, 2 , fn_name & " count", 1) + + # groups + vals=flextra_group_get(flx[1],["name","type"]) + assert_equal(vals, ["Katla","3D"], fn_name & ": meta " & "gr=1", 1) + + vals=flextra_group_get(flx[2],["name","type"]) + assert_equal(vals, ["Stromboli","3D"], fn_name & ": meta " & "gr=2", 1) + + # first trajectory in the second group (Stromboli). + vals=flextra_tr_get(flx[2],1,["lat","lon"]) + assert_equal(count(vals), 2, fn_name & ": vals count",1) + + lat_ref = |38.79,38.1031,37.4283,36.8997,36.4474,35.9292,35.3096,34.6169,33.8983,33.1428,32.3784,31.6709,30.9783,30.256,29.5301,28.8588,28.1536,27.5037,27.0838,26.8802,26.7414,26.6062,26.5373,26.539,26.5727| + lon_ref = |15.21,15.104,15.0364,14.8945,14.8744,15.0084,15.225,15.4018,15.5826,15.7934,15.9814,16.1914,16.4312,16.6402,16.8288,16.9553,16.923,16.7039,16.386,16.0921,15.8828,15.6049,15.2376,14.909,14.6562| + + assert(vec_same(vals[1], lat_ref,1E-3), fn_name & ": lat",1) + assert(vec_same(vals[2], lon_ref,1E-3), fn_name & ": lon",1) + +end test_flextra_multi_output diff -Nru metview-5.17.4/metview/test/macros/flextra_run.mv metview-5.19.2/metview/test/macros/flextra_run.mv --- metview-5.17.4/metview/test/macros/flextra_run.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/flextra_run.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,108 @@ +#Metview Macro + +include "test_utils.mv" + +test_flextra_run() + +function test_flextra_run() + + fn_name = "flextra_run" + + exe = getenv("MV_FLEXTRA_EXE") + if exe = "" or exe = nil then + fail(fn_name & ": no MV_FLEXTRA_EXE env variable is defined") + end if + + # create dirs + data_dir = getenv("TMPDIR") & "/flextra_data_tmp" + print("data_dir=", data_dir) + if shell("mkdir -p " & data_dir) <> 0 then + fail(fn_name & ": failed to create data_dir=", data_dir) + end if + + # get data from nexus + data_tgz = "flextra_data.tar" + url = "https://get.ecmwf.int/repository/test-data/metview/tutorial/" & data_tgz + r = download(url: url, target: data_dir & "/" & data_tgz) + + #Because Macro runs asynchronously we need to use a reference to + #the download result (e.g. by printing it). Otherwise the macro would + #exit and download would continue running in the background. + + if r = nil then + fail(fn_name & ": failed to download input data from url=" & url ) + end if + + if shell("cd " & data_dir & ";tar -xvf " & data_tgz) <> 0 then + fail(fn_name & ": failed to unpack input data") + end if + + #Run flextra + run_normal = flextra_run( + flextra_input_mode : "path", + flextra_input_path : data_dir, + flextra_trajectory_length : 72, + flextra_first_starting_date : 20120111, + flextra_first_starting_time : 3, + flextra_last_starting_date : 20120111, + flextra_last_starting_time : 15, + flextra_starting_time_interval : 3, + flextra_normal_types : 1, + flextra_normal_names : "Katla", + flextra_normal_latitudes : 63.63, + flextra_normal_longitudes : -19.05, + flextra_normal_levels : 1512, + flextra_normal_level_units : 1 + ) + + #Write the result into a file + resFile = tmpfile() + write(resFile,run_normal) + + #resFile = getenv("HOME") & "/metview/ctest/flextra_res_normal.txt" + #print("resFile=", resFile) + + #Because macro runs asynchronously we need to use a reference to + #the flextra_run result (e.g. by printing it). Otherwise the macro would + #exit and flextra_run would continue running in the background. + + if r = nil then + fail(fn_name & "failed to run flextra") + end if + + # ---------------------- + # check result + # ---------------------- + + flx = read(resFile) + + # number of trajectories + trNum=number(flextra_group_get(flx,"trNum")) + + assert_equal(trNum, 5 , fn_name & ": trNum", 1) + + # meta-data for each trajectory + start_times = ["03:00:00","06:00:00","09:00:00","12:00:00","15:00:00"] + for i=1 to trNum do + vals=flextra_tr_get(flx,i,["startTime","stopIndex"]) + assert_equal(vals, [start_times[i],"1"], fn_name & ": meta " & "tr=" & i, 1) + end for + + # data for the first trajectory + vals=flextra_tr_get(flx,1,["lat","lon","date"]) + + assert_equal(count(vals), 3, fn_name & ": meta first tr",1) + + lat=vals[1] + lon=vals[2] + dt=vals[3] + + lat_ref = |63.63,63.5992,63.4449,63.1638,63.0128,63.1078,62.7328,62.3399,62.4022,62.5768,62.7651,63.0468,63.4755,64.0346,64.7086,65.3356,65.8888,66.3628,66.6295,66.3514,65.3932,63.7349,61.4444,58.7767,56.2876| + lon_ref = |-19.05,-13.3063,-7.6374,-2.016,3.2851,8.7149,14.291,18.2208,21.4933,24.8885,27.9038,30.4272,32.4093,33.7897,34.5431,34.5109,33.3879,31.0452,27.9341,24.7241,21.7482,19.2114,17.5497,16.4128,15.8823| + dt_ref = [2012-01-11 03:00:00,2012-01-11 06:00:00,2012-01-11 09:00:00,2012-01-11 12:00:00,2012-01-11 15:00:00,2012-01-11 18:00:00,2012-01-11 21:00:00,2012-01-12 00:00:00,2012-01-12 03:00:00,2012-01-12 06:00:00,2012-01-12 09:00:00,2012-01-12 12:00:00,2012-01-12 15:00:00,2012-01-12 18:00:00,2012-01-12 21:00:00,2012-01-13 00:00:00,2012-01-13 03:00:00,2012-01-13 06:00:00,2012-01-13 09:00:00,2012-01-13 12:00:00,2012-01-13 15:00:00,2012-01-13 18:00:00,2012-01-13 21:00:00,2012-01-14 00:00:00,2012-01-14 03:00:00] + + assert(vec_same(lat, lat_ref,1E-3), fn_name & ": lat",1) + assert(vec_same(lon, lon_ref,1E-3), fn_name & ": lon",1) + assert_equal(dt, dt_ref, fn_name & ": dt",1) + +end test_flextra_run() diff -Nru metview-5.17.4/metview/test/macros/grib_keys.mv metview-5.19.2/metview/test/macros/grib_keys.mv --- metview-5.17.4/metview/test/macros/grib_keys.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_keys.mv 2023-07-15 08:28:47.000000000 +0000 @@ -13,6 +13,7 @@ test_grib_get() test_grib_set() +test_grib_set_step() test_repack() function test_grib_get() @@ -21,6 +22,9 @@ data = read('fc_data.grib') d1 = data[1] + data_rgg = read('xs_rgg_input.grib') + d_rgg1 = data_rgg[1] + # read some keys whose values we know ip = grib_get_long(d1, 'indicatorOfParameter') assert_equal(ip, 129, 'indicatorOfParameter') @@ -37,6 +41,17 @@ steps = grib_get_long(data, 'step') assert_equal(steps, [0,6,12,120], 'all steps') + pl = grib_get_long_array(d_rgg1, 'pl') + expected_pl = |20,25,36,40,45,50,60,60,72,75,80,90,96,100,108, + 120,120,120,128,135,144,144,160,160,160,160,160, + 180,180,180,180,180,192,192,192,192,192,192,192, + 192,192,192,192,192,192,192,192,192,192,192,192, + 192,192,192,192,192,192,192,192,192,192,192,192, + 192,180,180,180,180,180,160,160,160,160,160,144, + 144,135,128,120,120,120,108,100,96,90,80,75,72, + 60,60,50,45,40,36,25,20| + assert(vec_same(pl, expected_pl)) + # read keys that do not exist nolong = grib_get_long(d1, 'doesnotexist') assert_equal(nolong, nil, 'doesnotexist long') @@ -97,7 +112,10 @@ data = read('fc_data.grib') d1 = data[1] - + + data_rgg = read('xs_rgg_input.grib') + d_rgg1 = data_rgg[1] + #grib set r = grib_set_double(d1, ['latitudeOfFirstGridPointInDegrees',82.5]) lat = grib_get_double(r, 'latitudeOfFirstGridPointInDegrees') @@ -117,8 +135,45 @@ assert_equal(lat, 82.5, 'grib_set lat',1) assert_equal(step, 24, 'grib_set step',1) + new_pl = |18,35,84,40,45,50,60,60,72,75,80,90,96,100,108, + 120,120,120,128,135,144,144,160,160,160,160,160, + 180,180,180,180,180,192,192,192,192,192,192,192, + 192,192,192,192,192,192,192,192,192,192,192,192, + 192,192,192,192,192,192,192,192,192,192,192,192, + 192,180,180,180,180,180,160,160,160,160,160,144, + 144,135,128,120,120,120,108,100,96,90,80,75,72, + 60,60,50,45,40,36,27,19| + r = grib_set_long_array(d_rgg1, ['pl', new_pl]) + pl = grib_get_long_array(r, 'pl') + assert(vec_same(pl, new_pl)) + end test_grib_set +function test_grib_set_step() + + data = read('fc_data.grib') + f = data[1] + + r = grib_get(f,[ "date", "time", "stepType","startStep", "endStep", "unitOfTimeRange"]) + r_ref = ["20160415","1200","instant","0","0","h"] + assert_equal(r[1], r_ref, "grib_set_date before",1) + + f = grib_set(f, + ["date", 20150601, + "time", 0600, + "stepType", "avg", + #"unitOfTimeRange", "D", + "startStep", 0 , + "endStep", 31 + ]) + + r = grib_get(f,[ "date", "time", "stepType","startStep", "endStep", "unitOfTimeRange"]) + r_ref = ["20150601","0600","avg","0","31","h"] + assert_equal(r[1], r_ref, "grib_set_date after",1) + +end test_grib_set_step + + function test_repack() fs = read("lnsp.grib") diff -Nru metview-5.17.4/metview/test/macros/grib_nearest_gridpoint.mv metview-5.19.2/metview/test/macros/grib_nearest_gridpoint.mv --- metview-5.17.4/metview/test/macros/grib_nearest_gridpoint.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_nearest_gridpoint.mv 1970-01-01 00:00:00.000000000 +0000 @@ -1,1003 +0,0 @@ -# Metview Macro - -# **************************** LICENSE START *********************************** -# -# Copyright 2019 ECMWF. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ - -include "test_utils.mv" - -global USE_NEAREST_NON_MISSING = 0 - -test_1x1() -test_1x1_surrounding() -test_2x2_surrounding() -test_rgg_surrounding() -test_2x2_missing_surrounding() -test_ll_no_pole_surrounding() -test_reduced_ll_surrounding() -test_reg_gg_subarea() -test_reduced_gg_subarea() - -loop ctl in [0, 1] - - USE_NEAREST_NON_MISSING = ctl - - test_1x1_sub() - test_2x2() - test_2x2_missing() - test_rgg() - test_reg_gg_small() - test_red_gg_small() - test_red_gg_tiny() - -end loop - -#--------------------------------------- -# Testing global lat-lon 1x1 -#--------------------------------------- -function test_1x1() - -# read the data file (global field) -data = read('t1000_LL_1x1.grb') -print('Testing global 1x1 lat/lon grid') -numcols = 360 -numrows = 181 -lastrowindex = numcols*(numrows-1)+1 -lastpointindex = lastrowindex + numcols - 1 - -test_interpolate_on_original_gridpoints('t1000_LL_1x1.grb', 0.000000001, 'gpt') -test_interpolate_on_original_gridpoints('t1000_LL_1x1.grb', 0.000000001, 'vector') - -# test a whole bunch of points, checking their locations and indexes in particular -# lat lon reflat reflon refindex -test_nearest_gridpoint_info(data, 90, 0, 90, 0, 1) # top row, first point -test_nearest_gridpoint_info(data, 90, 359, 90, 359, numcols) # top row, last point -test_nearest_gridpoint_info(data, 89, 0, 89, 0, 361) -test_nearest_gridpoint_info(data, 89.2, 0, 89, 0, 361) # should be the same as above -test_nearest_gridpoint_info(data, 88.7, 0, 89, 0, 361) # should be the same as above -test_nearest_gridpoint_info(data, 0, 0, 0, 0, 32401) -test_nearest_gridpoint_info(data, 0, 360, 0, 0, 32401) # should be the same as above -test_nearest_gridpoint_info(data, 0, 359.9, 0, 0, 32401) # should be the same as above -test_nearest_gridpoint_info(data, 0, 359.6, 0, 0, 32401) # should be the same as above -test_nearest_gridpoint_info(data, 0, -0.1, 0, 0, 32401) # should be the same as above -test_nearest_gridpoint_info(data, 0, 0.1, 0, 0, 32401) # should be the same as above -test_nearest_gridpoint_info(data, 0, 1, 0, 1, 32402) -test_nearest_gridpoint_info(data, 0, -1, 0, 359, 32760) -test_nearest_gridpoint_info(data, 0, 359, 0, 359, 32760) # should be the same as above -test_nearest_gridpoint_info(data, 0, 359.1, 0, 359, 32760) # should be the same as above -test_nearest_gridpoint_info(data, 0, 359.4, 0, 359, 32760) # should be the same as above -test_nearest_gridpoint_info(data, -1, 0, -1, 0, 32761) -test_nearest_gridpoint_info(data, -90, 0, -90, 0, lastrowindex) # bottom row, first point -test_nearest_gridpoint_info(data, -90, 359, -90, 359, lastpointindex) # bottom row, last point - -test_nearest_geopoints(data, read('bufr_picker_reference.gpt'), read('nearest_gridpoint_gpt_ref_1.gpt')) - -test_interpolate(data, 0, 0, 300.4779) -test_interpolate(data, 0, 360, 300.4779) -test_interpolate(data, 0, 359.6, 300.4779) -test_interpolate(data, 0, 359.3, 300.4779) - -test_interpolate_vector(data, |0, 0, 0, 0|, - |0, 360, 359.6, 359.3|, - |300.4779, 300.4779, 300.4779, 300.4779|) - -end test_1x1 - -#----------------------------------------------------- -# Testing global lat-lon 1x1 for surrounding points -#-----------------------------------------------------test_2x2_surrounding -function test_1x1_surrounding() - -# read the data file (global field) -data = read('t1000_LL_1x1.grb') -print('Testing global 1x1 lat/lon grid for surrounding') - -loop optionAll in [0,1] - test_surrounding_points(data, -57.7, -111.7, |53529,53530,53169,53170|, optionAll) - test_surrounding_points(data, -57.1, -111.2, |53170,53169,53530,53529|, optionAll) - test_surrounding_points(data, -56.9, -111.2, |53170,53169,52810,52809|, optionAll) - test_surrounding_points(data, 24.8, 3.1, |23404,23764,23405,23765|, optionAll) - test_surrounding_points(data, -0.3, -0.4, |32401,32760,32761,33120|, optionAll) - test_surrounding_points(data, 0.3, 0.1, |32401,32041,32402,32042|, optionAll) - test_surrounding_points(data, 0, 0, |32401,32402,32761,32762|, optionAll) - test_surrounding_points(data, 0, 360, |32401,32402,32761,32762|, optionAll) - test_surrounding_points(data, 0, 359.6, |32401,32760,32761,33120|, optionAll) - test_surrounding_points(data, 0, 359.3, |32760,32401,33120,32761|, optionAll) - - test_surrounding_points_vector(data, - |-57.7, -57.1, -56.9, 24.8, -0.3, 0.3, 0, 0, 0, 0|, - |-111.7, -111.2, -111.2, 3.1, -0.4, 0.1, 0, 360, 359.6, 359.3|, - [ - |53529,53530,53169,53170|, - |53170,53169,53530,53529|, - |53170,53169,52810,52809|, - |23404,23764,23405,23765|, - |32401,32760,32761,33120|, - |32401,32041,32402,32042|, - |32401,32402,32761,32762|, - |32401,32402,32761,32762|, - |32401,32760,32761,33120|, - |32760,32401,33120,32761| - ], - optionAll) -end loop - -end test_1x1_surrounding - -#---------------------------------------test_2x2_surrounding -# Testing subarea lat-lon 1x1 -#--------------------------------------- -function test_1x1_sub() - -# read the data file (sub-area field) -data = read('t1000_LL_1x1_subarea.grb') # lat: -30 to +30, lon: -60 to +60 -print(' ') -print('Testing subarea of 1x1 lat/lon grid') -numcols = 121 -numrows = 61 -lastrowindex = numcols*(numrows-1)+1 -lastpointindex = lastrowindex + numcols - 1 - -test_interpolate_on_original_gridpoints('t1000_LL_1x1_subarea.grb', 0.000000001, 'gpt') - -# test a whole bunch of points, checking their locations and indexes in particular -# lat lon reflat reflon refindex -test_nearest_gridpoint_info(data, 0, 75, nil, nil, nil) # out of area -test_nearest_gridpoint_info(data, 0, -61, nil, nil, nil ) # out of area -test_nearest_gridpoint_info(data, -31, 0, nil, nil, nil ) # out of area -test_nearest_gridpoint_info(data, 31, 0, nil, nil, nil ) # out of area -test_nearest_gridpoint_info(data, 30, -60, 30, -60, 1) # top row, first point -test_nearest_gridpoint_info(data, 30, 60, 30, 60, numcols) # top row, last point -test_nearest_gridpoint_info(data, -30, -60, -30, -60, lastrowindex) # bottom row, first point -test_nearest_gridpoint_info(data, -30, 60, -30, 60, lastpointindex) # bottom row, last point -test_nearest_gridpoint_info(data, -30, 59.6, -30, 60, lastpointindex) # should be the same as above -test_nearest_gridpoint_info(data, 0, -60, 0, -60, numcols*30+1) -test_nearest_gridpoint_info(data, 0, 0, 0, 0, numcols*30+61) -test_nearest_gridpoint_info(data, 0.1, 0.1, 0, 0, numcols*30+61) # should be the same as above -test_nearest_gridpoint_info(data, -0.1, -0.1, 0, 0, numcols*30+61) # should be the same as above - -end test_1x1_sub - - -#--------------------------------------- -# Testing global lat-lon 2x2 -#--------------------------------------- -function test_2x2() - -# read the 2x2 data file (global field) -data = read('t1000_LL_2x2.grb') -print(' ') -print('Testing global 2x2 lat/lon grid') -numcols = 180 -numrows = 91 -lastrowindex = numcols*(numrows-1)+1 -lastpointindex = lastrowindex + numcols - 1 - -test_interpolate_on_original_gridpoints('t1000_LL_2x2.grb', 0.000000001, 'number') -test_interpolate_on_original_gridpoints('t1000_LL_2x2.grb', 0.000000001, 'vector') - - -# test a whole bunch of points, checking their locations and indexes in particular -# lat lon reflat reflon refindex -test_nearest_gridpoint_info(data, 90, 0, 90, 0, 1) # top row, first point -test_nearest_gridpoint_info(data, 90, 358, 90, 358, numcols) # top row, last point -test_nearest_gridpoint_info(data, 0, 0, 0, 0, 8101) -test_nearest_gridpoint_info(data, 0, 360, 0, 0, 8101) # should be the same as above -test_nearest_gridpoint_info(data, 0, 359.9, 0, 0, 8101) # should be the same as above -test_nearest_gridpoint_info(data, 0, -0.1, 0, 0, 8101) # should be the same as above -test_nearest_gridpoint_info(data, 0, 0.1, 0, 0, 8101) # should be the same as above - -test_interpolate(data, 25.4, 9.8, 309.975) -test_interpolate(data, 0.1, 0.2, 300.475) -test_interpolate(data, 74.8, -79.9, 255.505) - -test_interpolate_vector(data, |25.4, 0.1, 74.8|, |9.8, 0.2, -79.9|, |309.975, 300.475, 255.505|) - -data2 = data & (data+1) -test_interpolate_vector(data2, |25.4, 0.1, 74.8|, |9.8, 0.2, -79.9|, - [|309.975, 300.475, 255.505|, - |310.975, 301.475, 256.505|]) - - -end test_2x2 - -#------------------------------------------------------ -# Testing global lat-lon 2x2 for surrounding points -#------------------------------------------------------ -function test_2x2_surrounding() - -# read the 2x2 data file (global field) -data = read('t1000_LL_2x2.grb') -print(' ') -print('Testing global 2x2 lat/lon grid for surrounding') - -loop optionAll in [0,1] - test_surrounding_points(data, 74.8, -79.9, |1581,1582,1401,1402|, optionAll) - test_surrounding_points(data, 14.4, 15.0, |6848,6849,6668,6669|, optionAll) - test_surrounding_points(data, 14.4, 16.0, |6849,6669,6850,6670|, optionAll) - test_surrounding_points(data, 16.0, 16.0, |6669,6670,6849,6850|, optionAll) - - test_surrounding_points_vector(data, |74.8, 14.4, 14.4, 16.0|, |-79.9, 15.0, 16.0, 16.0|, - [ - |1581,1582,1401,1402|, - |6848,6849,6668,6669|, - |6849,6669,6850,6670|, - |6669,6670,6849,6850| - ], optionAll) - -end loop - -end test_2x2_surrounding - -#------------------------------------------------- -# Testing global lat-lon 2x2 with missing values -#------------------------------------------------- -function test_2x2_missing() - -# read the 2x2 data file containing missing values -data = read('t1000_LL_2x2_with_missing.grb') -print(' ') -print('Testing global 2x2 lat/lon grid with missing values') - -#test_interpolate_on_original_gridpoints('t1000_LL_2x2_with_missing.grb', 0.000000001, 'vector') - -test_nearest_gridpoint_value(data, 36.163, -12.39, 287.455) -test_nearest_gridpoint_value(data, 30.273, -11.55, 286.455) - -if USE_NEAREST_NON_MISSING <> 1 then - test_nearest_gridpoint_value(data, 30.507, -9.49, nil) - test_nearest_gridpoint_value_vector(data, |30.273, 30.507, 36.163|, |-11.55, -9.49, -12.39|, |286.455, vector_missing_value, 287.455|) - test_nearest_geopoints(data, read('nearest_gridpoint_gpt_ref_missing_1.gpt'), read('nearest_gridpoint_gpt_ref_missing_1.gpt')) -else - test_nearest_gridpoint_value(data, 30.507, -7.49, nil) - test_nearest_gridpoint_value(data, 30.507, -9.49, 289.455) - test_nearest_gridpoint_value(data, 31.01, -10.49, 289.455) - test_nearest_gridpoint_value(data, 31.01, -11.49, 287.455) - test_nearest_gridpoint_value(data, 30.88, -11.49, 286.455) - test_nearest_gridpoint_value(data, 30.18, -10.19, 286.455) - test_nearest_gridpoint_value_vector(data, |30.273, 30.507, 36.163|, |-11.55, -9.49, -12.39|, |286.455, 289.455, 287.455|) - test_nearest_geopoints(data, read('nearest_gridpoint_gpt_ref_missing_2.gpt'), read('nearest_gridpoint_gpt_ref_missing_2.gpt')) -end if - -end test_2x2_missing - -#---------------------------------------------------------------------- -# Testing global lat-lon 2x2 with missing values for surrounding points -#---------------------------------------------------------------------- -function test_2x2_missing_surrounding() - -# read the 2x2 data file containing missing values -data = read('t1000_LL_2x2_with_missing.grb') -print(' ') -print('Testing global 2x2 lat/lon grid with missing values for surrounding') - -optionAll = 0 -test_surrounding_points(data, 30.507, -7.49, nil, optionAll) -test_surrounding_points(data, 30.507, -9.49, nil, optionAll) -test_surrounding_points(data, 30.507, -10.80, nil, optionAll) - -test_surrounding_points_vector(data, |30.507, 30.507, 30.507|, |-7.49, -9.49, -10.80|, - [nil, nil, nil], optionAll) - -optionAll = 1 -test_surrounding_points(data, 30.507, -7.49, |5577,5578,5397,5398|, optionAll) -test_surrounding_points(data, 30.507, -9.49, |5576,5577,5396,5397|, optionAll) -test_surrounding_points(data, 30.507, -10.80, |5576,5575,5396,5395|, optionAll) - -data_multi = data&data -test_surrounding_points(data_multi, 30.507, -7.49, - [|5577,5578,5397,5398|, |5577,5578,5397,5398|], optionAll) - -test_surrounding_points_vector(data, |30.507, 30.507, 30.507|, |-7.49, -9.49, -10.80|, - [ - |5577,5578,5397,5398|, - |5576,5577,5396,5397|, - |5576,5575,5396,5395| - ], optionAll) - -test_surrounding_points_vector(data_multi, |30.507, 30.507, 30.507|, |-7.49, -9.49, -10.80|, - [ - [ - |5577,5578,5397,5398|, - |5576,5577,5396,5397|, - |5576,5575,5396,5395| - ], - [ - |5577,5578,5397,5398|, - |5576,5577,5396,5397|, - |5576,5575,5396,5395| - ] - ] - , optionAll) - -end test_2x2_missing_surrounding - - -#------------------------------------------------------------------------- -# Testing global lat-lon with no point at the poles for surrounding points -#------------------------------------------------------------------------- -function test_ll_no_pole_surrounding() - - # read the data file - data = read('ll_no_pole.grib') - print(' ') - print('Testing global lat/lon grid with no pole points for surrounding') - - optionAll = 0 - - #plot_surrounding_points (data, ) - test_surrounding_points(data, 53.376, -4.396, |250865,250864,249585,249584|, optionAll) - test_surrounding_points(data, 52.119, 0.034, |258561,257281,259840,258560|, optionAll) - test_surrounding_points(data, 89.886, 112.975, |402,403,1682,1683|, optionAll) - - # North pole - s = surrounding_points_indexes(data, 89.962, 79.158) - assert_equal(count(s), 1280, 'test_ll_no_pole_surrounding: n pole 1 count') - assert_equal(s[1], 282, 'test_ll_no_pole_surrounding: n pole 1 [1]') - assert_equal(s[2], 281, 'test_ll_no_pole_surrounding: n pole 1 [2]') - assert_equal(s[3], 283, 'test_ll_no_pole_surrounding: n pole 1 [3]') - assert_equal(s[500], 32, 'test_ll_no_pole_surrounding: n pole 1 [500]') - assert_equal(s[501], 532, 'test_ll_no_pole_surrounding: n pole 1 [501]') - assert_equal(s[502], 31, 'test_ll_no_pole_surrounding: n pole 1 [502]') - assert_equal(s[1279], 921, 'test_ll_no_pole_surrounding: n pole 1 [1279]') - assert_equal(s[1280], 922, 'test_ll_no_pole_surrounding: n pole 1 [1280]') - - # North pole - s = surrounding_points_indexes(data, 89.965, -164.534) - assert_equal(count(s), 1280, 'test_ll_no_pole_surrounding: n pole 2 count') - assert_equal(s[1], 695, 'test_ll_no_pole_surrounding: n pole 2 [1]') - assert_equal(s[2], 696, 'test_ll_no_pole_surrounding: n pole 2 [2]') - assert_equal(s[3], 694, 'test_ll_no_pole_surrounding: n pole 2 [3]') - assert_equal(s[500], 945, 'test_ll_no_pole_surrounding: n pole 2 [500]') - assert_equal(s[501], 445, 'test_ll_no_pole_surrounding: n pole 2 [501]') - assert_equal(s[502], 946, 'test_ll_no_pole_surrounding: n pole 2 [502]') - assert_equal(s[1279], 56, 'test_ll_no_pole_surrounding: n pole 2 [1279]') - assert_equal(s[1280], 55, 'test_ll_no_pole_surrounding: n pole 2 [1280]') - - # South pole - s = surrounding_points_indexes(data, -89.960, 48.662) - assert_equal(count(s), 1280, 'test_ll_no_pole_surrounding: s pole 1 count') - assert_equal(s[1], 1227694, 'test_ll_no_pole_surrounding: s pole 1 [1]') - assert_equal(s[2], 1227693, 'test_ll_no_pole_surrounding: s pole 1 [2]') - assert_equal(s[3], 1227695, 'test_ll_no_pole_surrounding: s pole 1 [3]') - assert_equal(s[500], 1228724, 'test_ll_no_pole_surrounding: s pole 1 [500]') - assert_equal(s[501], 1227944, 'test_ll_no_pole_surrounding: s pole 1 [501]') - assert_equal(s[502], 1228723, 'test_ll_no_pole_surrounding: s pole 1 [502]') - assert_equal(s[1279], 1228333, 'test_ll_no_pole_surrounding: s pole 1 [1279]') - assert_equal(s[1280], 1228334, 'test_ll_no_pole_surrounding: s pole 1 [1280]') - - #plot_surrounding_points (data, 90, 48.662) - - -end test_ll_no_pole_surrounding - - -#------------------------------------------------------------------------- -# Testing global lat-lon with no point at the poles for surrounding points -#------------------------------------------------------------------------- -function test_reduced_ll_surrounding() - - # this data file has first/last latitudes set to 90 and -90, and so is - # considered global, but its 'pl' array has zeros in all rows south - # of 78S, meaning there is no data there. - - # read the data file - data = read('reduced_ll.grib') - print(' ') - print('Testing global reduced lat/lon grid for surrounding') - - loop optionAll in [0, 1] - test_surrounding_points(data, 40, -60, |472483,472484,470278,470279|, optionAll) - test_surrounding_points(data, -50, 60, |2331274,2331273,2329418,2329419|, optionAll) - test_surrounding_points(data, -90, 0, nil, optionAll) - test_surrounding_points(data, -84.73, 10, nil, optionAll) - test_surrounding_points(data, -78.29, -165.68, nil, optionAll) - test_surrounding_points(data, -78.1, 20, nil, optionAll) # just over the edge - end loop - - optionAll = 0 - test_surrounding_points(data, 50, 20, nil, optionAll) - test_surrounding_points(data, -5.053, -35.7, nil, optionAll) - test_surrounding_points(data, 90, 0, nil, optionAll) - optionAll = 1 - test_surrounding_points(data, -5.053, -35.7, |1436670,1439539,1436671,1439538|, optionAll) - -end test_reduced_ll_surrounding - - - -#------------------------------------------------- -# Testing reduced Gaussian grid -#------------------------------------------------- -function test_rgg() - -# read the data file (reduced Gaussian field) -data = read('t1000_SH_to_RGG_reference.grb') -print(' ') -print('Testing reduced Gaussian grid') - -# this test returns some higher values due to imprecision in co-ordinates -#test_interpolate_on_original_gridpoints('t1000_SH_to_RGG_reference.grb', 0.01, 'gpt') - -# test a whole bunch of points, checking their locations and indexes in particular -# lat lon reflat reflon refindex -test_nearest_gridpoint_info(data, 89.82, 0, 89.828, 0, 1) # top row, first point -test_nearest_gridpoint_info(data, 89.82, 350, 89.828, 340, 18) # top row, last point -test_nearest_gridpoint_info(data, 89.90, 350, 89.828, 340, 18) # top row, last point (outside grid) -test_nearest_gridpoint_info(data, 89.82, 351, 89.828, 0, 1) # top row, first point -test_nearest_gridpoint_info(data, 89.82, 358, 89.828, 0, 1) # top row, first point -test_nearest_gridpoint_info(data, 89.90, 0, 89.828, 0, 1) # top row, first point (outside grid) -test_nearest_gridpoint_info(data, -89.82, 340, -89.828, 340, 843490) # bottom row, last point -test_nearest_gridpoint_info(data, -89.90, 340, -89.828, 340, 843490) # bottom row, last point (outside grid) -test_nearest_gridpoint_info(data, -89.82, 0, -89.828, 0, 843490-17) # bottom row, first point -test_nearest_gridpoint_info(data, -89.90, 0, -89.828, 0, 843490-17) # bottom row, first point (outside grid) -test_nearest_gridpoint_info(data, -89.82, 355, -89.828, 0, 843490-17) # should be the same as above - -end test_rgg() - -#-------------------------------------------------------- -# Testing reduced Gaussian grid for surrounding points -#-------------------------------------------------------- -function test_rgg_surrounding() - -# read the data file (reduced Gaussian field) -data = read('t1000_SH_to_RGG_reference.grb') -print(' ') -print('Testing reduced Gaussian grid for surrounding') - -loop optionAll in [0,1] - test_surrounding_points(data, 16.0, 16.0, |306617,308217,306618,308218|, optionAll) - test_surrounding_points(data, -27.1, -4.0, |611896,611895,613354,613353|, optionAll) - test_surrounding_points(data, 73.8, 129.5, |17201,17200,17681,17680|, optionAll) - test_surrounding_points(data, 40.0, 0.0, |152670,151390,152671,151391|, optionAll) - test_surrounding_points(data, 88.9, 5.0, |117,116,162,161|, optionAll) - test_surrounding_points(data, 89.9, 5.0, |1,2,18,3,17,4,16,5,15,6,14,7,13,8,12,9,11,10|, optionAll) - test_surrounding_points(data, -6., 0.0, |463346,464946,463347,464947|, optionAll) - test_surrounding_points(data, -6., 360.0, |463346,464946,463347,464947|, optionAll) - test_surrounding_points(data, -89.9, 5.0, - |843473,843474,843490,843475,843489,843476,843488,843477,843487,843478,843486,843479,843485,843480,843484,843481,843483,843482|, optionAll) - - test_surrounding_points_vector(data, - |16.0, -27.1, 73.8, 40.0, 88.9, 89.9, -89.9|, - |16.0, -4.0, 129.5, 0.0, 5.0, 5.0, 5.0|, - [ - |306617,308217,306618,308218|, - |611896,611895,613354,613353|, - |17201,17200,17681,17680|, - |152670,151390,152671,151391|, - |117,116,162,161|, - |1,2,18,3,17,4,16,5,15,6,14,7,13,8,12,9,11,10|, - |843473,843474,843490,843475,843489,843476,843488,843477,843487,843478,843486,843479,843485,843480,843484,843481,843483,843482| - ], - optionAll - ) - -end loop - -end test_rgg_surrounding - -#------------------------------------------------- -# Testing small regular Gaussian grid -#------------------------------------------------- -function test_reg_gg_small() - print(' ') - print('Testing small regular Gaussian grid') - test_interpolate_on_original_gridpoints('t1000_reg_gg_N48.grib', 0.000000001, 'vector') -end test_reg_gg_small - -#------------------------------------------------- -# Testing small reduced Gaussian grid -#------------------------------------------------- -function test_red_gg_small() - print(' ') - print('Testing small reduced Gaussian grid') - test_interpolate_on_original_gridpoints('t1000_red_gg_N48.grib', 0.000000001, 'vector') -end test_red_gg_small - - -#------------------------------------------------- -# Testing subarea of regular Gaussian grid -#------------------------------------------------- -function test_reg_gg_subarea() - print(' ') - print('Testing subarea regular Gaussian grid') - data = read('regular_gaussian_subarea.grib') - - # test all points with longitude values in both 0-360 range and -180-+180 range - loop lon_offset in [0, 360] - # point in the middle with lon in 0-360 range - test_nearest_gridpoint_value(data, 37.0, -75 + lon_offset, -1.9101) # in the middle of the area - test_nearest_gridpoint_value(data, 15.09, -100.9 + lon_offset, -3.69) # towards South-West corner - test_nearest_gridpoint_value(data, 15.40, -101.2 + lon_offset, -3.04) # towards South-West corner - test_nearest_gridpoint_value(data, 56.87, -38.87 + lon_offset, 4.28) # towards North-East corner - end loop - - #test_interpolate_on_original_gridpoints('regular_gaussian_subarea.grib', 0.000000001, 'vector') -end test_reg_gg_subarea - -#------------------------------------------------- -# Testing subarea of reduced Gaussian grid -#------------------------------------------------- -function test_reduced_gg_subarea() - print(' ') - print('Testing subarea reduced Gaussian grid') - data = read('rgg_western_subarea.grib') - # test all points with longitude values in both 0-360 range and -180-+180 range - loop lon_offset in [0] - test_nearest_gridpoint_value(data, 11.9, -70.24 + lon_offset, 300.07) # North-East corner of area - test_nearest_gridpoint_value(data, -9.73, -79.63 + lon_offset, 290.68) # South-West corner of area - test_nearest_gridpoint_value(data, 11.91, -79.76 + lon_offset, 300.87) # North-West corner of area - test_nearest_gridpoint_value(data, -9.92, -70.12 + lon_offset, 294.04) # South-East corner of area - test_nearest_gridpoint_value(data, 0.70, -75.43 + lon_offset, 295.25) # middle, N hemisphere - test_nearest_gridpoint_value(data, -0.44, -75.84 + lon_offset, 295.37) # middle, S hemisphere - end loop - - - print('Testing latitudes of subarea reduced Gaussian grid - rgg_western_subarea.grib') - lats = latitudes(data[1]) - assert(count(lats) = 2683, 'count lats of rgg_western_subarea') - assert(vec_same(lats[|1, 100, 1000,2683|], |11.9438,11.1007,3.51288,-9.97658|, 0.0001), 'lats of rgg_western_subarea') - print('Testing longitudes of subarea reduced Gaussian grid - rgg_western_subarea.grib') - lons = longitudes(data[1]) - assert(count(lons) = 2683, 'count lons of rgg_western_subarea') - assert(vec_same(lons[|1, 100, 1000,2683|], |-80,-78.3158,-77.5962,-70.0692|, 0.0001), 'lons of rgg_western_subarea') - - data = read('rgg_O1280_subarea.grib') - print('Testing latitudes of subarea reduced Gaussian grid - rgg_O1280_subarea.grib') - lats = latitudes(data[1]) - assert(count(lats) = 2124, 'count lats of rgg_O1280_subarea') - assert(vec_same(lats[|1, 100, 1000,2124|], |44.2531,44.1125,42.7768,41.2302|, 0.0001), 'lats of rgg_O1280_subarea') - print('Testing longitudes of subarea reduced Gaussian grid - rgg_O1280_subarea.grib') - lons = longitudes(data[1]) - assert(count(lons) = 2124, 'count lons of rgg_O1280_subarea') - assert(vec_same(lons[|1, 100, 1000,2124|], |22.269,23.1507,22.8994,28.6246|, 0.0001), 'lons of rgg_O1280_subarea') - - -end test_reduced_gg_subarea - - - - -#------------------------------------------------- -# Testing tiny reduced Gaussian grid -#------------------------------------------------- - -function test_red_gg_tiny() - data = read('rgg_small_subarea.grib') - print(' ') - print('Testing tiny reduced Gaussian grid subarea for surrounding') - - # the interesting thing about this grid is that some of the rows have - # only 1 point - - # test a whole bunch of points, checking their locations and indexes in particular - # lat lon reflat reflon refindex - test_nearest_gridpoint_info(data, 89.80, 41.20, 89.806, 38.572, 2) - test_nearest_gridpoint_info(data, 89.86, 47.00, 89.877, 45.000, 1) - test_nearest_gridpoint_info(data, 89.59, 42.37, 89.60, 45.000, 5) - test_nearest_gridpoint_info(data, 89.18, 43.88, 89.17, 45.000, 14) - test_nearest_gridpoint_info(data, 85.30, 39.84, 85.31, 39.30, 276) - - # lat lon refvalue - test_nearest_gridpoint_value(data, 89.80, 41.20, 242.883) - test_nearest_gridpoint_value(data, 89.86, 47.00, 242.793) - test_nearest_gridpoint_value(data, 89.59, 42.37, 243.154) - test_nearest_gridpoint_value(data, 89.18, 43.88, 243.776) - test_nearest_gridpoint_value(data, 85.30, 39.84, 250.764) -end test_red_gg_tiny - - -# ---------------------------------------------------------------------------- -# Function : test_nearest_gridpoint_info -# -# Description : checks whether the nearest_gridpoint function is giving -# the expected result (supplied as arguments). It currently -# only checks the lat, lon and index of the returned point, -# not its value. -# ---------------------------------------------------------------------------- - -function test_nearest_gridpoint_info(f:fieldset, inlat, inlon, correctlat, correctlon, correctindex) - - if USE_NEAREST_NON_MISSING <> 1 then - ng = nearest_gridpoint_info(f, inlat, inlon) - else - ng = nearest_gridpoint_info(f, inlat, inlon, 'valid') - end if - ng = ng[1] - print('in: ', inlat, ',', inlon, tab, ' out:', ng) - if (correctlat = nil and ng = nil) then - return - end if - if (different(ng.latitude, correctlat) or - different(ng.longitude, correctlon) or - different(ng.index, correctindex)) then - print("Nearest gridpoint gave incorrect result:") - print(ng) - print("Should have been : lat=", correctlat, " lon=", correctlon, " index=", correctindex) - fail('Stopped') - end if - -end test_nearest_gridpoint - - -function test_nearest_gridpoint_value(f:fieldset, inlat, inlon, correctval) - - if USE_NEAREST_NON_MISSING <> 1 then - ng = nearest_gridpoint_info(f, inlat, inlon) - else - ng = nearest_gridpoint_info(f, inlat, inlon, 'valid') - if ng = [nil] then - if correctval = nil then - return - else - print('in: ', inlat, ',', inlon, tab, ' out:', ng) - print("Nearest gridpoint gave incorrect result:") - print("Should have been : val=", correctval, " but it was ", ng) - fail('Stopped') - end if - end if - end if - ng = ng[1] - - print('in: ', inlat, ',', inlon, tab, ' out:', ng) - if (correctval = nil and ng.value = nil) then - return - end if - if (different(ng.value, correctval)) then - print("Nearest gridpoint gave incorrect result:") - print(ng) - print("Should have been : val=", correctval, " but it was ", ng.value) - fail('Stopped') - end if - -end test_nearest_gridpoint_value - -function test_nearest_gridpoint_value_vector(f:fieldset, inlat, inlon, correctval) - if USE_NEAREST_NON_MISSING <> 1 then - ng = nearest_gridpoint(f, inlat, inlon) - else - ng = nearest_gridpoint(f, inlat, inlon, 'valid') - end if - print('in: ', inlat, ',', inlon, tab, ' out:', ng) - if (count(ng) <> count(correctval)) then - print('Wrong number of elements: ', count(ng), ', got: ', count(correctval)) - fail('Stopped') - end if - if maxvalue(abs(ng - correctval)) > 0.01 then - print("Nearest gridpoint gave incorrect vector result:") - print("Should have been : val=", correctval, " but it was ", ng) - fail('Stopped') - end if -end test_nearest_gridpoint_value_vector - -function test_interpolate(f:fieldset, inlat, inlon, correctval) - ip = interpolate(f, inlat, inlon) - print('in: ', inlat, ',', inlon, tab, ' out:', ip) - if (correctval = nil and ip = nil) then - return - end if - if (different(ip, correctval)) then - print("Interpolate gave incorrect result:") - print("Should have been : val=", correctval, " but it was ", ip) - fail('Stopped') - end if -end test_interpolate - -function test_interpolate_vector(f:fieldset, inlat, inlon, correctval) - ng = interpolate(f, inlat, inlon) - print('in: ', inlat, ',', inlon, tab, ' out:', ng) - - islist = (count(f) > 1) - - for i = 1 to count(f) do - - if islist then - ngi = ng[i] - correctvali = correctval[i] - else - ngi = ng - correctvali = correctval - end if - - if (count(ngi) <> count(correctvali)) then - print('Wrong number of elements: ', count(ngi), ', got: ', count(correctvali)) - fail('Stopped') - end if - if maxvalue(abs(ngi - correctvali)) > 0.01 then - print("Interpolate gave incorrect vector result:") - print("Should have been : val=", correctvali, " but it was ", ngi) - fail('Stopped') - end if - end for -end test_interpolate_vector - - - -# test_interpolate_on_original_gridpoints -# calls the interpolate() function on every original gridpoint of the -# given fieldset - the results should be the s|5577,5578,5397,5398|ame as the original -# gridpoint values; differences can be expected when interpolating with -# geopoints giving the target points, as this format could crop -# the lat/lon co-ordinates slightly -function test_interpolate_on_original_gridpoints(grib_file:string, tolerance:number, method:string) - - m_all = read(grib_file) - - for f = 1 to count(m_all) do - m = m_all[f] - lats = latitudes(m) - lons = longitudes(m) - v = values(m) - - if method = 'gpt' then - g = create_geo(count(values(m))) - g = set_latitudes(g, lats) - g = set_longitudes(g, lons) - vgeo = values(interpolate(m, g)) - diff = vgeo - v - else if method = 'vector' then - vvec = interpolate(m, lats, lons) - diff = vvec - v - else - #alternative - more precise, but takes a lot longer - c = count(v) - vx = vector(c) - for i = 1 to c do - vx[i] = interpolate(m, lats[i], lons[i]) - end for - diff = vx-v - end if - maxdiff = maxvalue(abs(diff)) - print('test_interpolate_on_original_gridpoints maxdiff: ', maxdiff) - if maxdiff > tolerance then - print('test_interpolate_on_original_gridpoints: ', grib_file, ' field ', f) - print('gave high difference: ', maxdiff) - fail('Stopped') - end if - end for - -end test_interpolate_on_original_gridpoints - - -function test_surrounding_points(f:fieldset, inlat:number, inlon:number, correctval_all, all) - print('surround in: ', inlat, ',', inlon, "mode=", all) - - if all <> 1 then - sp_all = surrounding_points_indexes(f, inlat, inlon) - else - sp_all = surrounding_points_indexes(f, inlat, inlon, 'all') - end if - - print(' out:', sp_all) - if correctval_all = nil and sp_all = nil then - return - end if - - num_fields = count(f) - for fi = 1 to num_fields do - - if num_fields > 1 then - sp = sp_all[fi] - correctval = correctval_all[fi] - else - sp = sp_all - correctval = correctval_all - end if - - if (count(sp) <> count(correctval)) then - print('Wrong number of elements: ', count(sp), ', instead of: ', count(correctval)) - fail('Stopped') - end if - if maxvalue(abs(sp - correctval)) > 0.01 then - print("Surrounding gridpoints gave incorrect vector result:") - print("Should have been : val=", correctval, " but it was ", sp) - if runmode() = "prepare" then - plot_surrounding_points(f, inlat, inlon) - end if - fail('Stopped') - end if - end for # num_fields -end test_surrounding_points - - -function test_surrounding_points_vector(f:fieldset, inlat:vector, inlon:vector, correctval_all, all) - print('surround vec in: ', inlat, ',', inlon, "mode=", all) - - if all <> 1 then - sp_all = surrounding_points_indexes(f, inlat, inlon) - else - sp_all = surrounding_points_indexes(f, inlat, inlon, 'all') - end if - - print(' out:', sp_all) - if correctval_all = nil and sp_all = nil then - return - end if - - num_fields = count(f) - for fi = 1 to num_fields do - - if num_fields > 1 then - sp = sp_all[fi] - correctval = correctval_all[fi] - else - sp = sp_all - correctval = correctval_all - end if - - - if (count(sp) <> count(correctval)) then - print('Wrong number of elements: ', count(sp), ', instead of: ', count(correctval)) - fail('Stopped') - end if - - for i = 1 to count(sp) do - if (count(sp[i]) <> count(correctval[i])) then - print(i, ': Wrong number of elements: ', count(sp[i]), ', instead of: ', count(correctval[i])) - fail('Stopped') - end if - if sp[i] <> nil and correctval[i] <> nil then - if maxvalue(abs(sp[i] - correctval[i])) > 0.01 then - print("Surrounding gridpoints gave incorrect vector result:") - print(i, ": Should have been : val=", correctval[i], " but it was ", sp[i]) - if runmode() = "prepare" then - plot_surrounding_points(f, inlat, inlon) - end if - fail('Stopped') - end if - end if - end for - end for # num_fields -end test_surrounding_points - - -function test_nearest_geopoints(f: fieldset, gpt: geopoints, correct: geopoints) - print('test_nearest_geopoints, ', count(gpt), ', ', count(correct)) - if USE_NEAREST_NON_MISSING <> 1 then - near = nearest_gridpoint(f, gpt) - else - near = nearest_gridpoint(f, gpt, 'valid') - end if - res = geopoints_same(near, correct) - if res = 0 then - if runmode() = "prepare" then - plot_fieldset_and_geopoints_vals(f, near) - end if - fail('test_nearest_geopoints failed') - end if -end test_nearest_geopoints - - -# ----------------------------------------------------------- -# geopoints_same -# will 0 if any element of the geopoints variables differs; otherwise 1 -# ----------------------------------------------------------- - -function geopoints_same(g1: geopoints, g2: geopoints) - - if count(g1) <> count(g2) then - print('Different number of points: ', count(g1), ' vs ', count(g2)) - return 0 - end if - - diff = g1 - g2 - - if maxvalue(abs(diff)) > 0.1 then - print('Difference in values. Please inspect the results vs the reference') - return 0 - end if - - if maxvalue(abs(latitudes(g1)-latitudes(g2))) > 0.05 then - print('Difference in latitudes. Please inspect the results vs the reference') - return 0 - end if - - if maxvalue(abs(longitudes(g1)-longitudes(g2))) > 0.05 then - print('Difference in longitudes. Please inspect the results vs the reference') - return 0 - end if - - if maxvalue(abs(levels(g1)-levels(g2))) > 0.05 then - print('Difference in levels. Please inspect the results vs the reference') - fail() - end if - - if maxvalue(abs(vector(dates(g1)-dates(g2)))) > 0.05 then - print('Difference in dates. Please inspect the results vs the reference') - return 0 - end if - -end compare_geopoints - - -function different(v1, v2) - return (abs(v1-v2) > 0.01) # threshold may have to change if we use higher-res data -end different - -# plot_surrounding_points -# convenience function to plot the specified point (red), plus the computed -# four surrounding points. The surrounding points are in shades a green, with -# the closest point in the darkest colour, up to the farthest point in the -# lightest colour -function plot_surrounding_points (data:fieldset, tlat: number, tlon: number, all) - print('plot_surrounding_points: ', nearest_gridpoint_info(data, tlat, tlon)) - print('plot_surrounding_points: ', interpolate(data, tlat, tlon)) - b = surrounding_points_indexes(data, tlat, tlon, all) - print(b[1], ' ', b[2], ' ', b[3], ' ', b[4], ' ') - extracted_vals = values(data)[b] - print('plot_surrounding_points: ', b) - print('plot_surrounding_points: ', extracted_vals) - spts_lats = latitudes(data)[b] - spts_lons = longitudes(data)[b] - print('plot_surrounding_points: ', spts_lats, spts_lons) - val_lst = nil - for i=1 to count(b) do - val_lst = val_lst & [i] - end for - spts = input_visualiser( - input_plot_type : "geo_points", - input_longitude_values : tolist(spts_lons), - input_latitude_values : tolist(spts_lats), - input_values : val_lst) - symb_common = (symbol_type: 'marker', symbol_marker_index: 15, symbol_height: 0.4) - spts_symb = msymb( - symbol_type : "marker", - symbol_table_mode : "advanced", - symbol_outline : "on", - symbol_advanced_table_selection_type : "list", - symbol_advanced_table_level_list : val_lst & [count(val_lst)+1], - symbol_advanced_table_colour_method : "list", - symbol_advanced_table_colour_list : ["RGB(0.0000,0.4000,0.1333)","RGB(0.0000,0.6039,0.2013)","RGB(0,0.8706,0.2902)","RGB(0.7804,0.9451,0.8353)"], - symbol_advanced_table_height_list : 0.6 - ) - - symb_multi = msymb( - legend : "on", - symbol_type : "marker", - symbol_table_mode : "advanced", - symbol_advanced_table_level_count : 50, - symbol_advanced_table_max_level_colour : "red", - symbol_advanced_table_min_level_colour : "blue", - symbol_advanced_table_colour_direction : "clockwise" - ) - - if count(spts_lats) > 4 then - symb_for_spts = symb_multi - else - symb_for_spts = spts_symb - end if - - tpt = input_visualiser(input_plot_type: "geo_points", - input_longitude_values: [tlon], - input_latitude_values: [tlat]) - tpt_symb = msymb(symb_common, symbol_colour : "red") - plot(data, spts, symb_for_spts, tpt, tpt_symb) -end plot_surrounding_points - - - -function plot_fieldset_and_geopoints_vals(data: fieldset, gpt: geopoints) - - grid_1x1 = mcont( - contour : "off", - contour_grid_value_plot : "on", - contour_grid_value_plot_type : "both", - grib_scaling_of_retrieved_fields : "off" - ) - symb = msymb(symbol_type: 'marker', symbol_marker_index: 15, symbol_height: 0.3, symbol_colour: 'cyan') - text = msymb(symbol_type: 'number', symbol_colour: 'olive') - plot(gpt, symb, data, grid_1x1, gpt, text) - -end plot_fieldset_and_geopoints_vals - -function assert_equal(v1: number, v2: number, msg:string) - if v1 <> v2 then - fail(tab,"test failed: ", v1, " <> ",v2," [",msg,"]") - end if -end assert - diff -Nru metview-5.17.4/metview/test/macros/grib_nearest_ll.mv metview-5.19.2/metview/test/macros/grib_nearest_ll.mv --- metview-5.17.4/metview/test/macros/grib_nearest_ll.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_nearest_ll.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,716 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "grib_nearest_utils.mv" + +global USE_NEAREST_NON_MISSING = 0 + +# latlon +test_1x1() +test_1x1_surrounding() +test_2x2_surrounding() +test_2x2_missing_surrounding() +test_ll_no_pole_surrounding() + +test_interpolate_global_ll_eastern_border() +test_nearest_global_ll_eastern_border() +test_interpolate_sub_ll_eastern_border() +test_nearest_sub_ll_eastern_border() + +loop ctl in [0, 1] + + USE_NEAREST_NON_MISSING = ctl + + test_1x1_sub() + test_2x2() + test_2x2_missing() + +end loop + +#--------------------------------------- +# Testing global lat-lon 1x1 +#--------------------------------------- +function test_1x1() + +# read the data file (global field) +data = read('t1000_LL_1x1.grb') +print('Test: test_1x1') +numcols = 360 +numrows = 181 +lastrowindex = numcols*(numrows-1)+1 +lastpointindex = lastrowindex + numcols - 1 + +test_interpolate_on_original_gridpoints('t1000_LL_1x1.grb', 0.000000001, 'gpt') +test_interpolate_on_original_gridpoints('t1000_LL_1x1.grb', 0.000000001, 'vector') + +# test a whole bunch of points, checking their locations and indexes in particular +# lat lon reflat reflon refindex +test_nearest_gridpoint_info(data, 90, 0, 90, 0, 1) # top row, first point +test_nearest_gridpoint_info(data, 90, 359, 90, 359, numcols) # top row, last point +test_nearest_gridpoint_info(data, 89, 0, 89, 0, 361) +test_nearest_gridpoint_info(data, 89.2, 0, 89, 0, 361) # should be the same as above +test_nearest_gridpoint_info(data, 88.7, 0, 89, 0, 361) # should be the same as above +test_nearest_gridpoint_info(data, 0, 0, 0, 0, 32401) +test_nearest_gridpoint_info(data, 0, 360, 0, 0, 32401) # should be the same as above +test_nearest_gridpoint_info(data, 0, 359.9, 0, 0, 32401) # should be the same as above +test_nearest_gridpoint_info(data, 0, 359.6, 0, 0, 32401) # should be the same as above +test_nearest_gridpoint_info(data, 0, -0.1, 0, 0, 32401) # should be the same as above +test_nearest_gridpoint_info(data, 0, 0.1, 0, 0, 32401) # should be the same as above +test_nearest_gridpoint_info(data, 0, 1, 0, 1, 32402) +test_nearest_gridpoint_info(data, 0, -1, 0, 359, 32760) +test_nearest_gridpoint_info(data, 0, 359, 0, 359, 32760) # should be the same as above +test_nearest_gridpoint_info(data, 0, 359.1, 0, 359, 32760) # should be the same as above +test_nearest_gridpoint_info(data, 0, 359.4, 0, 359, 32760) # should be the same as above +test_nearest_gridpoint_info(data, -1, 0, -1, 0, 32761) +test_nearest_gridpoint_info(data, -90, 0, -90, 0, lastrowindex) # bottom row, first point +test_nearest_gridpoint_info(data, -90, 359, -90, 359, lastpointindex) # bottom row, last point + +test_nearest_geopoints(data, read('bufr_picker_reference.gpt'), read('nearest_gridpoint_gpt_ref_1.gpt')) + +test_interpolate(data, 0, 0, 300.4779) +test_interpolate(data, 0, 360, 300.4779) +test_interpolate(data, 0, 359.6, 300.4779) +test_interpolate(data, 0, 359.3, 300.4779) + +test_interpolate_vector(data, |0, 0, 0, 0|, + |0, 360, 359.6, 359.3|, + |300.4779, 300.4779, 300.4779, 300.4779|) + +end test_1x1 + +#----------------------------------------------------- +# Testing global lat-lon 1x1 for surrounding points +#-----------------------------------------------------test_2x2_surrounding +function test_1x1_surrounding() + +# read the data file (global field) +data = read('t1000_LL_1x1.grb') +print('Test: test_1x1_surrounding') + +loop optionAll in [0,1] + test_surrounding_points(data, -57.7, -111.7, |53529,53530,53169,53170|, optionAll) + test_surrounding_points(data, -57.1, -111.2, |53170,53169,53530,53529|, optionAll) + test_surrounding_points(data, -56.9, -111.2, |53170,53169,52810,52809|, optionAll) + test_surrounding_points(data, 24.8, 3.1, |23404,23764,23405,23765|, optionAll) + test_surrounding_points(data, -0.3, -0.4, |32401,32760,32761,33120|, optionAll) + test_surrounding_points(data, 0.3, 0.1, |32401,32041,32402,32042|, optionAll) + test_surrounding_points(data, 0, 0, |32401,32761,32402,32762|, optionAll) + test_surrounding_points(data, 0, 360, |32401,32402,32761,32762|, optionAll) + test_surrounding_points(data, 0, 359.6, |32401,32760,32761,33120|, optionAll) + test_surrounding_points(data, 0, 359.3, |32760,32401,33120,32761|, optionAll) + + test_surrounding_points_vector(data, + |-57.7, -57.1, -56.9, 24.8, -0.3, 0.3, 0, 0, 0, 0|, + |-111.7, -111.2, -111.2, 3.1, -0.4, 0.1, 0, 360, 359.6, 359.3|, + [ + |53529,53530,53169,53170|, + |53170,53169,53530,53529|, + |53170,53169,52810,52809|, + |23404,23764,23405,23765|, + |32401,32760,32761,33120|, + |32401,32041,32402,32042|, + |32401,32761,32402,32762|, + |32401,32402,32761,32762|, + |32401,32760,32761,33120|, + |32760,32401,33120,32761| + ], + optionAll) +end loop + +end test_1x1_surrounding + +#---------------------------------------test_2x2_surrounding +# Testing subarea lat-lon 1x1 +#--------------------------------------- +function test_1x1_sub() + +# read the data file (sub-area field) +data = read('t1000_LL_1x1_subarea.grb') # lat: -30 to +30, lon: -60 to +60 +print(' ') +print('Test: test_1x1_sub USE_NEAREST_NON_MISSING=' & USE_NEAREST_NON_MISSING) +numcols = 121 +numrows = 61 +lastrowindex = numcols*(numrows-1)+1 +lastpointindex = lastrowindex + numcols - 1 + +test_interpolate_on_original_gridpoints('t1000_LL_1x1_subarea.grb', 0.000000001, 'gpt') + +# test a whole bunch of points, checking their locations and indexes in particular +# lat lon reflat reflon refindex +test_nearest_gridpoint_info(data, 0, 75, nil, nil, nil) # out of area +test_nearest_gridpoint_info(data, 0, -61, nil, nil, nil ) # out of area +test_nearest_gridpoint_info(data, -31, 0, nil, nil, nil ) # out of area +test_nearest_gridpoint_info(data, 31, 0, nil, nil, nil ) # out of area +test_nearest_gridpoint_info(data, 30, -60, 30, -60, 1) # top row, first point +test_nearest_gridpoint_info(data, 30, 60, 30, 60, numcols) # top row, last point +test_nearest_gridpoint_info(data, -30, -60, -30, -60, lastrowindex) # bottom row, first point +test_nearest_gridpoint_info(data, -30, 60, -30, 60, lastpointindex) # bottom row, last point +test_nearest_gridpoint_info(data, -30, 59.6, -30, 60, lastpointindex) # should be the same as above +test_nearest_gridpoint_info(data, 0, -60, 0, -60, numcols*30+1) +test_nearest_gridpoint_info(data, 0, 0, 0, 0, numcols*30+61) +test_nearest_gridpoint_info(data, 0.1, 0.1, 0, 0, numcols*30+61) # should be the same as above +test_nearest_gridpoint_info(data, -0.1, -0.1, 0, 0, numcols*30+61) # should be the same as above + +end test_1x1_sub + + +#--------------------------------------- +# Testing global lat-lon 2x2 +#--------------------------------------- +function test_2x2() + +# read the 2x2 data file (global field) +data = read('t1000_LL_2x2.grb') +print(' ') +print('Test: test_2x2 USE_NEAREST_NON_MISSING=' & USE_NEAREST_NON_MISSING) +numcols = 180 +numrows = 91 +lastrowindex = numcols*(numrows-1)+1 +lastpointindex = lastrowindex + numcols - 1 + +test_interpolate_on_original_gridpoints('t1000_LL_2x2.grb', 0.000000001, 'number') +test_interpolate_on_original_gridpoints('t1000_LL_2x2.grb', 0.000000001, 'vector') + + +# test a whole bunch of points, checking their locations and indexes in particular +# lat lon reflat reflon refindex +test_nearest_gridpoint_info(data, 90, 0, 90, 0, 1) # top row, first point +test_nearest_gridpoint_info(data, 90, 358, 90, 358, 180) # top row, last point +test_nearest_gridpoint_info(data, 0, 0, 0, 0, 8101) +test_nearest_gridpoint_info(data, 0, 360, 0, 0, 8101) # should be the same as above +test_nearest_gridpoint_info(data, 0, 359.9, 0, 0, 8101) # should be the same as above +test_nearest_gridpoint_info(data, 0, -0.1, 0, 0, 8101) # should be the same as above +test_nearest_gridpoint_info(data, 0, 0.1, 0, 0, 8101) # should be the same as above + +test_interpolate(data, 25.4, 9.8, 309.975) +test_interpolate(data, 0.1, 0.2, 300.475) +test_interpolate(data, 74.8, -79.9, 255.505) + +test_interpolate_vector(data, |25.4, 0.1, 74.8|, |9.8, 0.2, -79.9|, |309.975, 300.475, 255.505|) + +data2 = data & (data+1) +test_interpolate_vector(data2, |25.4, 0.1, 74.8|, |9.8, 0.2, -79.9|, + [|309.975, 300.475, 255.505|, + |310.975, 301.475, 256.505|]) + + +end test_2x2 + +#------------------------------------------------------ +# Testing global lat-lon 2x2 for surrounding points +#------------------------------------------------------ +function test_2x2_surrounding() + +# read the 2x2 data file (global field) +data = read('t1000_LL_2x2.grb') +print(' ') +print('Testing global 2x2 lat/lon grid for surrounding') + +loop optionAll in [0,1] + test_surrounding_points(data, 74.8, -79.9, |1581,1582,1401,1402|, optionAll) + test_surrounding_points(data, 14.4, 15.0, |6848,6849,6668,6669|, optionAll) + test_surrounding_points(data, 14.4, 16.0, |6849,6669,6850,6670|, optionAll) + test_surrounding_points(data, 16.0, 16.0, |6669,6670,6849,6850|, optionAll) + + test_surrounding_points_vector(data, |74.8, 14.4, 14.4, 16.0|, |-79.9, 15.0, 16.0, 16.0|, + [ + |1581,1582,1401,1402|, + |6848,6849,6668,6669|, + |6849,6669,6850,6670|, + |6669,6670,6849,6850| + ], optionAll) + +end loop + +end test_2x2_surrounding + +#------------------------------------------------- +# Testing global lat-lon 2x2 with missing values +#------------------------------------------------- +function test_2x2_missing() + +# read the 2x2 data file containing missing values +data = read('t1000_LL_2x2_with_missing.grb') +print(' ') +print('Test: test_2x2_missing USE_NEAREST_NON_MISSING=' & USE_NEAREST_NON_MISSING) + +#test_interpolate_on_original_gridpoints('t1000_LL_2x2_with_missing.grb', 0.000000001, 'vector') + +test_nearest_gridpoint_value(data, 36.163, -12.39, 287.455) +test_nearest_gridpoint_value(data, 30.273, -11.55, 286.455) + +if USE_NEAREST_NON_MISSING <> 1 then + test_nearest_gridpoint_value(data, 30.507, -9.49, nil) + test_nearest_gridpoint_value_vector(data, |30.273, 30.507, 36.163|, |-11.55, -9.49, -12.39|, |286.455, vector_missing_value, 287.455|) + test_nearest_geopoints(data, read('nearest_gridpoint_gpt_ref_missing_1.gpt'), read('nearest_gridpoint_gpt_ref_missing_1.gpt')) +else + test_nearest_gridpoint_value(data, 30.507, -7.49, nil) + test_nearest_gridpoint_value(data, 30.507, -9.49, 289.455) + test_nearest_gridpoint_value(data, 31.01, -10.49, 289.455) + test_nearest_gridpoint_value(data, 31.01, -11.49, 287.455) + test_nearest_gridpoint_value(data, 30.88, -11.49, 286.455) + test_nearest_gridpoint_value(data, 30.18, -10.19, 286.455) + test_nearest_gridpoint_value_vector(data, |30.273, 30.507, 36.163|, |-11.55, -9.49, -12.39|, |286.455, 289.455, 287.455|) + test_nearest_geopoints(data, read('nearest_gridpoint_gpt_ref_missing_2.gpt'), read('nearest_gridpoint_gpt_ref_missing_2.gpt')) +end if + +end test_2x2_missing + +#---------------------------------------------------------------------- +# Testing global lat-lon 2x2 with missing values for surrounding points +#---------------------------------------------------------------------- +function test_2x2_missing_surrounding() + +# read the 2x2 data file containing missing values +data = read('t1000_LL_2x2_with_missing.grb') +print(' ') +print('Testing global 2x2 lat/lon grid with missing values for surrounding') + +optionAll = 0 +test_surrounding_points(data, 30.507, -7.49, nil, optionAll) +test_surrounding_points(data, 30.507, -9.49, nil, optionAll) +test_surrounding_points(data, 30.507, -10.80, nil, optionAll) + +test_surrounding_points_vector(data, |30.507, 30.507, 30.507|, |-7.49, -9.49, -10.80|, + [nil, nil, nil], optionAll) + +optionAll = 1 +test_surrounding_points(data, 30.507, -7.49, |5577,5578,5397,5398|, optionAll) +test_surrounding_points(data, 30.507, -9.49, |5576,5577,5396,5397|, optionAll) +test_surrounding_points(data, 30.507, -10.80, |5576,5575,5396,5395|, optionAll) + +data_multi = data&data +test_surrounding_points(data_multi, 30.507, -7.49, + [|5577,5578,5397,5398|, |5577,5578,5397,5398|], optionAll) + +test_surrounding_points_vector(data, |30.507, 30.507, 30.507|, |-7.49, -9.49, -10.80|, + [ + |5577,5578,5397,5398|, + |5576,5577,5396,5397|, + |5576,5575,5396,5395| + ], optionAll) + +test_surrounding_points_vector(data_multi, |30.507, 30.507, 30.507|, |-7.49, -9.49, -10.80|, + [ + [ + |5577,5578,5397,5398|, + |5576,5577,5396,5397|, + |5576,5575,5396,5395| + ], + [ + |5577,5578,5397,5398|, + |5576,5577,5396,5397|, + |5576,5575,5396,5395| + ] + ] + , optionAll) + +end test_2x2_missing_surrounding + + +#------------------------------------------------------------------------- +# Testing global lat-lon with no point at the poles for surrounding points +#------------------------------------------------------------------------- +function test_ll_no_pole_surrounding() + + # read the data file + data = read('ll_no_pole.grib') + print(' ') + print('Testing global lat/lon grid with no pole points for surrounding') + + optionAll = 0 + + #plot_surrounding_points (data, ) + test_surrounding_points(data, 53.376, -4.396, |250865,250864,249585,249584|, optionAll) + test_surrounding_points(data, 52.119, 0.034, |258561,257281,259840,258560|, optionAll) + test_surrounding_points(data, 89.886, 112.975, |402,403,1682,1683|, optionAll) + + # North pole + s = surrounding_points_indexes(data, 89.962, 79.158) + assert_equal(count(s), 1280, 'test_ll_no_pole_surrounding: n pole 1 count') + assert_equal(s[1], 282, 'test_ll_no_pole_surrounding: n pole 1 [1]') + assert_equal(s[2], 281, 'test_ll_no_pole_surrounding: n pole 1 [2]') + assert_equal(s[3], 283, 'test_ll_no_pole_surrounding: n pole 1 [3]') + assert_equal(s[500], 32, 'test_ll_no_pole_surrounding: n pole 1 [500]') + assert_equal(s[501], 532, 'test_ll_no_pole_surrounding: n pole 1 [501]') + assert_equal(s[502], 31, 'test_ll_no_pole_surrounding: n pole 1 [502]') + assert_equal(s[1279], 921, 'test_ll_no_pole_surrounding: n pole 1 [1279]') + assert_equal(s[1280], 922, 'test_ll_no_pole_surrounding: n pole 1 [1280]') + + # North pole + s = surrounding_points_indexes(data, 89.965, -164.534) + assert_equal(count(s), 1280, 'test_ll_no_pole_surrounding: n pole 2 count') + assert_equal(s[1], 695, 'test_ll_no_pole_surrounding: n pole 2 [1]') + assert_equal(s[2], 696, 'test_ll_no_pole_surrounding: n pole 2 [2]') + assert_equal(s[3], 694, 'test_ll_no_pole_surrounding: n pole 2 [3]') + assert_equal(s[500], 945, 'test_ll_no_pole_surrounding: n pole 2 [500]') + assert_equal(s[501], 445, 'test_ll_no_pole_surrounding: n pole 2 [501]') + assert_equal(s[502], 946, 'test_ll_no_pole_surrounding: n pole 2 [502]') + assert_equal(s[1279], 56, 'test_ll_no_pole_surrounding: n pole 2 [1279]') + assert_equal(s[1280], 55, 'test_ll_no_pole_surrounding: n pole 2 [1280]') + + # South pole + s = surrounding_points_indexes(data, -89.960, 48.662) + assert_equal(count(s), 1280, 'test_ll_no_pole_surrounding: s pole 1 count') + assert_equal(s[1], 1227694, 'test_ll_no_pole_surrounding: s pole 1 [1]') + assert_equal(s[2], 1227693, 'test_ll_no_pole_surrounding: s pole 1 [2]') + assert_equal(s[3], 1227695, 'test_ll_no_pole_surrounding: s pole 1 [3]') + assert_equal(s[500], 1228724, 'test_ll_no_pole_surrounding: s pole 1 [500]') + assert_equal(s[501], 1227944, 'test_ll_no_pole_surrounding: s pole 1 [501]') + assert_equal(s[502], 1228723, 'test_ll_no_pole_surrounding: s pole 1 [502]') + assert_equal(s[1279], 1228333, 'test_ll_no_pole_surrounding: s pole 1 [1279]') + assert_equal(s[1280], 1228334, 'test_ll_no_pole_surrounding: s pole 1 [1280]') + + #plot_surrounding_points (data, 90, 48.662) + + +end test_ll_no_pole_surrounding + +#------------------------------------------------- +# Testing global latlon grid +#------------------------------------------------- +# lon close to eastern border, see METV-3362 + +function test_interpolate_global_ll_eastern_border() + + print('Test: test_interpolate_global_ll_eastern_border') + + # north pole: 52878.9766 + # south pole: 50801.9766 + + # grid: + # latitudeOfFirstGridPointInDegrees = 90; + # longitudeOfFirstGridPointInDegrees = 0; + # latitudeOfLastGridPointInDegrees = -90; + # longitudeOfLastGridPointInDegrees = 358.5; + # iScansNegatively = 0; + # jScansPositively = 0; + + files = ["z500.grb", "z500_g2.grb"] + loop fname in files + data = read(fname) + print("fname=", fname) + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + print('interpolate lon_offset=', lon_offset) + + # -- north pole + + # first gridpoint + test_interpolate(data, 90, 0 + lon_offset, 52878.9765625) + if lon_offset = 0 then + test_interpolate(data, 90, 360 + lon_offset, 52878.9765625) + end if + + # west of the first gridpoint + test_interpolate(data, 90, -1e-15 + lon_offset, 52878.9765625) + test_interpolate(data, 90, -1.4 + lon_offset, 52878.9765625) + + # east of the first gridpoint + test_interpolate(data, 90, 1e-15 + lon_offset, 52878.9765625) + test_interpolate(data, 90, 1.4 + lon_offset, 52878.9765625) + + # -- row below the north pole + + # points on the last/first cell border + test_interpolate(data, 88.505, 0 + lon_offset, 53102.9773958) + if lon_offset = 0 then + test_interpolate(data, 88.505, 360 + lon_offset, 53102.9773958) + end if + + # points in the last cell + test_interpolate(data, 88.505, -1e-15 + lon_offset, 53102.9773958) + test_interpolate(data, 88.505, -1.4 + lon_offset, 53100.8843958) + test_interpolate(data, 89.8, -1e-15 + lon_offset, 52908.9432292) + test_interpolate(data, 89.8, -1.4 + lon_offset, 52908.6632292) + + # points in the first cell + if lon_offset = 0 then + test_interpolate(data, 88.505, 1e-15 + lon_offset, 53102.9773958) + test_interpolate(data, 88.505, 1.4 + lon_offset, 53104.8378403) + test_interpolate(data, 89.8, 1e-15 + lon_offset, 52908.9432292) + test_interpolate(data, 89.8, 1.4 + lon_offset, 52909.1921181) + end if + + # -- south pole + + # first gridpoint + test_interpolate(data, -90, 0 + lon_offset, 50081.9765625) + if lon_offset = 0 then + test_interpolate(data, -90, 360 + lon_offset, 50081.9765625) + end if + + # west of the first gridpoint + test_interpolate(data, -90, -1e-15 + lon_offset, 50081.9765625) + test_interpolate(data, -90, -1.4 + lon_offset, 50081.9765625) + + # east of the first gridpoint + test_interpolate(data, -90, 1e-15 + lon_offset, 50081.9765625) + test_interpolate(data, -90, 1.4 + lon_offset, 50081.9765625) + + # -- row above the south pole + + # points on the last/first cell border + test_interpolate(data, -88.505, 0 + lon_offset, 50100.9132292) + if lon_offset = 0 then + test_interpolate(data, -88.505, 360 + lon_offset, 50100.9132292) + end if + + # points in the last cell + test_interpolate(data, -88.505, -1e-15 + lon_offset, 50100.9132292) + test_interpolate(data, -88.505, -1.4 + lon_offset, 50104.1690069) + test_interpolate(data, -89.8, -1e-15 + lon_offset, 50084.5098958) + test_interpolate(data, -89.8, -1.4 + lon_offset, 50084.9454514) + + # points in the first cell + if lon_offset = 0 then + test_interpolate(data, -88.505, 1e-15 + lon_offset, 50100.9132292) + test_interpolate(data, -88.505, 1.4 + lon_offset, 50097.8900069) + test_interpolate(data, -89.8, 1e-15 + lon_offset, 50084.5098958) + test_interpolate(data, -89.8, 1.4 + lon_offset, 50084.1054514) + end if + + end loop + end loop + +end test_interpolate_global_ll_eastern_border + +function test_nearest_global_ll_eastern_border() + + print('Test: test_nearest_global_ll_eastern_border') + + # north pole: 52878.9766 + # south pole: 50801.9766 + + # grid: + # latitudeOfFirstGridPointInDegrees = 90; + # longitudeOfFirstGridPointInDegrees = 0; + # latitudeOfLastGridPointInDegrees = -90; + # longitudeOfLastGridPointInDegrees = 358.5; + # iScansNegatively = 0; + # jScansPositively = 0; + + files = ["z500.grb", "z500_g2.grb"] + loop fname in files + data = read(fname) + print("fname=", fname) + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0] + print('nearest_gridpoint_info lon_offset=', lon_offset) + + # lat lon reflat reflon refindex + + # -- north pole + + # first gridpoint + test_nearest_gridpoint_info(data, 90, 0 + lon_offset, 90, 0, 1) + if lon_offset = 0 then + test_nearest_gridpoint_info(data, 90, 360 + lon_offset, 90, 0, 1) + end if + + # west of the first gridpoint + test_nearest_gridpoint_info(data, 90, -1e-15 + lon_offset, 90, 0, 1) + test_nearest_gridpoint_info(data, 90, -1.4 + lon_offset, 90, 358.5, 240) + + # east of the first gridpoint + test_nearest_gridpoint_info(data, 90, 1e-15 + lon_offset, 90, 0, 1) + test_nearest_gridpoint_info(data, 90, 1.4 + lon_offset, 90, 1.5, 2) + + # -- row below the north pole + + # points on the last/first cell border + test_nearest_gridpoint_info(data, 88.505, 0 + lon_offset, 88.5, 0, 241) + if lon_offset = 0 then + test_nearest_gridpoint_info(data, 88.505, 360 + lon_offset, 88.5, 0, 241) + end if + + # points in the last cell + test_nearest_gridpoint_info(data, 88.505, -1e-15 + lon_offset, 88.5, 0, 241) + test_nearest_gridpoint_info(data, 88.505, -1.4 + lon_offset, 88.5, 358.5, 480) + test_nearest_gridpoint_info(data, 89.8, -1e-15 + lon_offset, 90, 0, 1) + test_nearest_gridpoint_info(data, 89.8, -1.4 + lon_offset, 90, 358.5, 240) + + # points in the first cell + if lon_offset = 0 then + test_nearest_gridpoint_info(data, 88.505, 1e-15 + lon_offset, 88.5, 0, 241) + test_nearest_gridpoint_info(data, 88.505, 1.4 + lon_offset, 88.5, 1.5, 242) + test_nearest_gridpoint_info(data, 89.8, 1e-15 + lon_offset, 90, 0, 1) + test_nearest_gridpoint_info(data, 89.8, 1.4 + lon_offset, 90, 1.5, 2) + end if + + # -- south pole + + # first gridpoint + test_nearest_gridpoint_info(data, -90, 0 + lon_offset, -90, 0, 28801) + if lon_offset = 0 then + test_nearest_gridpoint_info(data, -90, 360 + lon_offset, -90, 0, 28801) + end if + + # west of the first gridpoint + test_nearest_gridpoint_info(data, -90, -1e-15 + lon_offset, -90, 0, 28801) + test_nearest_gridpoint_info(data, -90, -1.4 + lon_offset, -90, 358.5, 29040) + + # east of the first gridpoint + test_nearest_gridpoint_info(data, -90, 1e-15 + lon_offset, -90, 0, 28801) + test_nearest_gridpoint_info(data, -90, 1.4 + lon_offset, -90, 1.5, 28802) + + # -- row above the south pole + + # points on the last/first cell border + test_nearest_gridpoint_info(data, -88.505, 0 + lon_offset, -88.5, 0, 28561) + if lon_offset = 0 then + test_nearest_gridpoint_info(data, -88.505, 360 + lon_offset, -88.5, 0, 28561) + end if + + # points in the last cell + test_nearest_gridpoint_info(data, -88.505, -1e-15 + lon_offset, -88.5, 0, 28561) + test_nearest_gridpoint_info(data, -88.505, -1.4 + lon_offset, -88.5, 358.5, 28800) + test_nearest_gridpoint_info(data, -89.8, -1e-15 + lon_offset, -90, 0, 28801) + test_nearest_gridpoint_info(data, -89.8, -1.4 + lon_offset, -90, 358.5, 29040) + + # points in the first cell + if lon_offset = 0 then + test_nearest_gridpoint_info(data, -88.505, 1e-15 + lon_offset, -88.5, 0, 28561) + test_nearest_gridpoint_info(data, -88.505, 1.4 + lon_offset, -88.5, 1.5, 28562) + test_nearest_gridpoint_info(data, -89.8, 1e-15 + lon_offset, -90, 0, 28801) + test_nearest_gridpoint_info(data, -89.8, 1.4 + lon_offset, -90, 1.5, 28802) + end if + + end loop + end loop + +end test_nearest_global_ll_eastern_border + +function test_interpolate_sub_ll_eastern_border() + + print('Test: test_interpolate_sub_ll_eastern_border') + + # grid: + # Ni = 121; + # Nj = 61; + # latitudeOfFirstGridPointInDegrees = 30; + # longitudeOfFirstGridPointInDegrees = -60; + # earthIsOblate = 0; + # uvRelativeToGrid = 0; + # latitudeOfLastGridPointInDegrees = -30; + # longitudeOfLastGridPointInDegrees = 60; + # iScansNegatively = 0; + # jScansPositively = 0; + + files = ["t1000_LL_1x1_subarea.grb", "t1000_LL_1x1_subarea_g2.grb"] + loop fname in files + data = read(fname) + print("fname=", fname) + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + print('interpolate lon_offset=', lon_offset) + + # -- NE corner + if lon_offset = 0 then + test_interpolate(data, 29.95, 59.9 + lon_offset, 311.874824219) + test_interpolate(data, 29.95, 59.999999999999999 + lon_offset, 311.579833984) + test_interpolate(data, 29.95, 60 + lon_offset, 311.579833984) + test_interpolate(data, 29.95, 60.000000000000001 + lon_offset, 311.579833984) + test_interpolate(data, 29.95, 60.1 + lon_offset, nil) + end if + + # -- NW corner + test_interpolate(data, 29.95, -59.9 + lon_offset, 294.02519043) + test_interpolate(data, 29.95, -59.999999999999999 + lon_offset, 294.040673828) + test_interpolate(data, 29.95, -60 + lon_offset, 294.040673828) + test_interpolate(data, 29.95, -60.000000000000001 + lon_offset, 294.040673828) + test_interpolate(data, 29.95, -60.1 + lon_offset, nil) + + # -- SW corner + test_interpolate(data, -29.95, -59.9 + lon_offset, 288.743479004) + test_interpolate(data, -29.95, -59.999999999999999 + lon_offset, 288.843457031) + test_interpolate(data, -29.95, -60 + lon_offset, 288.843457031) + test_interpolate(data, -29.95, -60.000000000000001 + lon_offset, 288.843457031) + test_interpolate(data, -29.95, -60.1 + lon_offset, nil) + + # -- SE corner + if lon_offset = 0 then + test_interpolate(data, -29.95, 59.9 + lon_offset, 294.438464355) + test_interpolate(data, -29.95, 59.999999999999999 + lon_offset, 294.588500977) + test_interpolate(data, -29.95, 60 + lon_offset, 294.588500977) + test_interpolate(data, -29.95, 60.000000000000001 + lon_offset, 294.588500977) + test_interpolate(data, -29.95, 60.1 + lon_offset, nil) + end if + end loop + end loop + +end test_interpolate_sub_ll_eastern_border + +function test_nearest_sub_ll_eastern_border() + + print('Test: test_nearest_sub_ll_eastern_border') + + # grid: + # Ni = 121; + # Nj = 61; + # latitudeOfFirstGridPointInDegrees = 30; + # longitudeOfFirstGridPointInDegrees = -60; + # earthIsOblate = 0; + # uvRelativeToGrid = 0; + # latitudeOfLastGridPointInDegrees = -30; + # longitudeOfLastGridPointInDegrees = 60; + # iScansNegatively = 0; + # jScansPositively = 0; + + files = ["t1000_LL_1x1_subarea.grb", "t1000_LL_1x1_subarea_g2.grb"] + loop fname in files + data = read(fname) + print("fname=", fname) + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + print('interpolate lon_offset=', lon_offset) + + # -- NE corner + if lon_offset = 0 then + test_nearest_gridpoint_info(data, 29.95, 59.9 + lon_offset, 30, 60, 121) + test_nearest_gridpoint_info(data, 29.95, 59.999999999999999 + lon_offset, 30, 60, 121) + test_nearest_gridpoint_info(data, 29.95, 60 + lon_offset, 30, 60, 121) + test_nearest_gridpoint_info(data, 29.95, 60.000000000000001 + lon_offset, 30, 60, 121) + test_nearest_gridpoint_info(data, 29.95, 60.1 + lon_offset, nil, nil, nil) + end if + + # -- NW corner + test_nearest_gridpoint_info(data, 29.95, -59.9 + lon_offset, 30, -60, 1) + test_nearest_gridpoint_info(data, 29.95, -59.999999999999999 + lon_offset, 30, -60, 1) + test_nearest_gridpoint_info(data, 29.95, -60 + lon_offset, 30, -60, 1) + test_nearest_gridpoint_info(data, 29.95, -60.000000000000001 + lon_offset, 30, -60, 1) + test_nearest_gridpoint_info(data, 29.95, -60.1 + lon_offset, nil, nil, nil) + + # -- SW corner + test_nearest_gridpoint_info(data, -29.95, -59.9 + lon_offset, -30, -60, 7261) + test_nearest_gridpoint_info(data, -29.95, -59.999999999999999 + lon_offset, -30, -60, 7261) + test_nearest_gridpoint_info(data, -29.95, -60 + lon_offset, -30, -60, 7261) + test_nearest_gridpoint_info(data, -29.95, -60.000000000000001 + lon_offset, -30, -60, 7261) + test_nearest_gridpoint_info(data, -29.95, -60.1 + lon_offset, nil, nil, nil) + + # -- SE corner + if lon_offset = 0 then + test_nearest_gridpoint_info(data, -29.95, 59.9 + lon_offset, -30, 60, 7381) + test_nearest_gridpoint_info(data, -29.95, 59.999999999999999 + lon_offset, -30, 60, 7381) + test_nearest_gridpoint_info(data, -29.95, 60 + lon_offset, -30, 60, 7381) + test_nearest_gridpoint_info(data, -29.95, 60.000000000000001 + lon_offset, -30, 60, 7381) + test_nearest_gridpoint_info(data, -29.95, 60.1 + lon_offset, nil, nil, nil) + end if + + end loop + end loop + +end test_nearest_sub_ll_eastern_border + diff -Nru metview-5.17.4/metview/test/macros/grib_nearest_reduced_gg.mv metview-5.19.2/metview/test/macros/grib_nearest_reduced_gg.mv --- metview-5.17.4/metview/test/macros/grib_nearest_reduced_gg.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_nearest_reduced_gg.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,831 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" +include "grib_nearest_utils.mv" + +global USE_NEAREST_NON_MISSING = 0 + +# reduced Gaussian +test_reduced_gg_surrounding() +test_reduced_gg_border_interpolate() +test_reduced_gg_border_nearest() +test_reduced_gg_border_surrounding() +test_reduced_gg_subarea_interpolate() +test_reduced_gg_subarea_nearest() +test_reduced_gg_subarea_surrounding() +test_reduced_gg_subarea_latlons() +test_reduced_gg_subarea_interpolate_across_zero_lon() +test_reduced_gg_subarea_nearest_across_zero_lon() +test_reduced_gg_subarea_surrounding_across_zero_lon() +test_reduced_gg_subarea_latlons_across_zero_lon() + +loop ctl in [0, 1] + + USE_NEAREST_NON_MISSING = ctl + + test_reduced_gg_interpolate() + test_reduced_gg_nearest() + test_reduced_gg_small() + test_reduced_gg_tiny() + +end loop + + +#------------------------------------------------- +# Testing reduced Gaussian grid +#------------------------------------------------- +function test_reduced_gg_interpolate() + + print('Test: test_reduced_gg_interpolate') + + files = ["t1000_SH_to_RGG_reference.grb", "t1000_SH_to_RGG_reference_g2.grb"] + loop fname in files + data = read(fname) + print("fname=", fname) + + # this test returns some higher values due to imprecision in co-ordinates + #test_interpolate_on_original_gridpoints('t1000_SH_to_RGG_reference.grb', 0.01, 'gpt') + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + print('interpolate lon_offset=', lon_offset) + test_interpolate(data, 89.82, 0 + lon_offset, 273.680419922) # top row, first point + test_interpolate(data, 89.82, -10 + lon_offset, 273.680419922) # top row, last point + test_interpolate(data, 89.90, -10 + lon_offset, 273.680419922) # top row, last point (outside grid) + test_interpolate(data, 89.82, -9 + lon_offset, 273.680419922) # top row, first point + test_interpolate(data, 89.82, -2 + lon_offset, 273.680419922) # top row, first point + test_interpolate(data, 89.90, 0 + lon_offset, 273.680419922) # top row, first point (outside grid) + test_interpolate(data, 15.1, -70.1 + lon_offset, 299.506954405) + test_interpolate(data, -89.82, -20 + lon_offset, 237.198078125) # bottom row, last point + test_interpolate(data, -89.90, -20 + lon_offset, 236.994185226) # bottom row, last point (outside grid) + + # these are giving wrong results when lon_offset = 360 + #test_interpolate(data, -89.82, 0 + lon_offset, 237.198078125) # bottom row, first point + #test_interpolate(data, -89.90, 0 + lon_offset, 236.994185226) # bottom row, first point (outside grid) + + test_interpolate(data, -89.82, -5 + lon_offset, 237.198078125) # should be the same as above + + if lon_offset = 0 then + test_interpolate(data, -89.82, 0 , 237.198078125) # bottom row, first point + test_interpolate(data, -89.90, 0 , 236.994185226) # bottom row, first point (outside grid) + test_interpolate(data, 15, 0 , 307.680419922) + test_interpolate(data, 15.1, 0.1 , 307.603324137) + test_interpolate(data, 15.1, 46, 317.506954405) + + # lon close to eastern border, see METV-3362 + test_interpolate(data, -89.733, -1E-14, 237.393167999) + + end if + end loop + end loop + +end test_reduced_gg_interpolate + +function test_reduced_gg_nearest() + + print('Test: test_reduced_gg_nearest') + + files = ["t1000_SH_to_RGG_reference.grb", "t1000_SH_to_RGG_reference_g2.grb"] + loop fname in files + data = read(fname) + print("fname=", fname) + + # this test returns some higher values due to imprecision in co-ordinates + #test_interpolate_on_original_gridpoints('t1000_SH_to_RGG_reference.grb', 0.01, 'gpt') + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + print('interpolate lon_offset=', lon_offset) + test_interpolate(data, 89.82, 0 + lon_offset, 273.680419922) # top row, first point + test_interpolate(data, 89.82, -10 + lon_offset, 273.680419922) # top row, last point + test_interpolate(data, 89.90, -10 + lon_offset, 273.680419922) # top row, last point (outside grid) + test_interpolate(data, 89.82, -9 + lon_offset, 273.680419922) # top row, first point + test_interpolate(data, 89.82, -2 + lon_offset, 273.680419922) # top row, first point + test_interpolate(data, 89.90, 0 + lon_offset, 273.680419922) # top row, first point (outside grid) + test_interpolate(data, 15.1, -70.1 + lon_offset, 299.506954405) + test_interpolate(data, -89.82, -20 + lon_offset, 237.198078125) # bottom row, last point + test_interpolate(data, -89.90, -20 + lon_offset, 236.994185226) # bottom row, last point (outside grid) + + # these are giving wrong results when lon_offset = 360 + #test_interpolate(data, -89.82, 0 + lon_offset, 237.198078125) # bottom row, first point + #test_interpolate(data, -89.90, 0 + lon_offset, 236.994185226) # bottom row, first point (outside grid) + + test_interpolate(data, -89.82, -5 + lon_offset, 237.198078125) # should be the same as above + + if lon_offset = 0 then + test_interpolate(data, -89.82, 0 , 237.198078125) # bottom row, first point + test_interpolate(data, -89.90, 0 , 236.994185226) # bottom row, first point (outside grid) + test_interpolate(data, 15, 0 , 307.680419922) + test_interpolate(data, 15.1, 0.1 , 307.603324137) + test_interpolate(data, 15.1, 46, 317.506954405) + + # lon close to eastern border, see METV-3362 + test_interpolate(data, -89.733, -1E-14, 237.393167999) + + end if + end loop + end loop + +end test_reduced_gg_nearest + + +function test_reduced_gg_surrounding() + + print(' ') + print('Test: test_reduced_gg_surrounding') + + files = ["t1000_SH_to_RGG_reference.grb", "t1000_SH_to_RGG_reference_g2.grb"] + loop fname in files + data = read(fname) + print("fname=", fname) + + loop optionAll in [0,1] + test_surrounding_points(data, 16.0, 16.0, |306617,308217,306618,308218|, optionAll) + test_surrounding_points(data, -27.1, -4.0, |611896,611895,613354,613353|, optionAll) + test_surrounding_points(data, 73.8, 129.5, |17201,17200,17681,17680|, optionAll) + test_surrounding_points(data, 40.0, 0.0, |152670,151390,152671,151391|, optionAll) + test_surrounding_points(data, 88.9, 5.0, |117,116,162,161|, optionAll) + test_surrounding_points(data, 89.9, 5.0, |1,2,18,3,17,4,16,5,15,6,14,7,13,8,12,9,11,10|, optionAll) + test_surrounding_points(data, -6., 0.0, |463346,464946,463347,464947|, optionAll) + test_surrounding_points(data, -6., 360.0, |463346,464946,463347,464947|, optionAll) + test_surrounding_points(data, -89.9, 5.0, + |843473,843474,843490,843475,843489,843476,843488,843477,843487,843478,843486,843479,843485,843480,843484,843481,843483,843482|, optionAll) + + + # lon close to eastern border, see METV-3362 + test_surrounding_points(data, -89.733, -1E-14, |843473,843490,843448,843472|, optionAll) + + test_surrounding_points_vector(data, + |16.0, -27.1, 73.8, 40.0, 88.9, 89.9, -89.9|, + |16.0, -4.0, 129.5, 0.0, 5.0, 5.0, 5.0|, + [ + |306617,308217,306618,308218|, + |611896,611895,613354,613353|, + |17201,17200,17681,17680|, + |152670,151390,152671,151391|, + |117,116,162,161|, + |1,2,18,3,17,4,16,5,15,6,14,7,13,8,12,9,11,10|, + |843473,843474,843490,843475,843489,843476,843488,843477,843487,843478,843486,843479,843485,843480,843484,843481,843483,843482| + ], + optionAll + ) + + end loop + end loop + +end test_reduced_gg_surrounding + +#------------------------------------------------- +# Testing reduced Gaussian grid +#------------------------------------------------- +# lon close to eastern border, see METV-3362 + +function test_reduced_gg_border_interpolate() + + print('Test: test_reduced_gg_border_interpolate') + + # global reduced Gaussian grid + # northernmost lat=88.5722 + # southernmost lat=-88.5722 + + files = ["t1000_red_gg_N48.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + print('interpolate lon_offset=', lon_offset) + + # points in the last cell below the northernmost lat + test_interpolate(data, 88.348, -1e-15 + lon_offset, 270.448016991) + test_interpolate(data, 88, -1e-15 + lon_offset, 270.426703694) + test_interpolate(data, 87.115, -1e-15 + lon_offset, 270.372501774) + + test_interpolate(data, 88.348, -11 + lon_offset, 270.296399658) + test_interpolate(data, 88, -11 + lon_offset, 270.239829594) + test_interpolate(data, 87.115, -11 + lon_offset, 270.09596607) + test_interpolate(data, 86.9, -13.5 + lon_offset, 269.993216651) + + # north of the northernmost lat (extrapolate) + test_interpolate(data, 88.7, -1e-15 + lon_offset, 270.473155843) + test_interpolate(data, 88.7, -1 + lon_offset, 270.462486254) + + if lon_offset = 0 then + test_interpolate(data, 88.7, 1e-15 + lon_offset, 270.473155843) + test_interpolate(data, 88.7, 1 + lon_offset, 270.477502712) + test_interpolate(data, 88.7, 10 + lon_offset, 270.516624538) + test_interpolate(data, 88.7, 50 + lon_offset, 270.629643147) + test_interpolate(data, 88.7, 90 + lon_offset, 270.972848257) + end if + + # north pole (mean) + test_interpolate(data, 90, -1e-15 + lon_offset, 270.589187622) + test_interpolate(data, 90, -1 + lon_offset, 270.589187622) + if lon_offset = 0 then + test_interpolate(data, 90, 1e-15 + lon_offset, 270.589187622) + test_interpolate(data, 90, 1 + lon_offset, 270.589187622) + test_interpolate(data, 90, 50 + lon_offset, 270.589187622) + end if + + # point in the last cell below the southernmost lat + test_interpolate(data, -88.348, -1e-15 + lon_offset, 242.239271416) + test_interpolate(data, -88, -1e-15 + lon_offset, 242.194072527) + test_interpolate(data, -87.115, -1e-15 + lon_offset, 242.079127077) + + test_interpolate(data, -88.348, -11 + lon_offset, 243.280999379) + test_interpolate(data, -88, -11 + lon_offset, 243.783852329) + test_interpolate(data, -87.115, -11 + lon_offset, 245.0626594) + test_interpolate(data, -86.9, -13.5 + lon_offset, 246.128359037) + + # south of the southernmost lat (extrapolate) + test_interpolate(data, -88.7, -1e-15 + lon_offset, 242.558663483) + test_interpolate(data, -88.7, -1 + lon_offset, 242.61566675) + test_interpolate(data, -88.7, -10 + lon_offset, 243.12869615) + if lon_offset = 0 then + test_interpolate(data, -88.7, 1e-15 + lon_offset, 242.558663483) + test_interpolate(data, -88.7, 1 + lon_offset, 242.558465898) + test_interpolate(data, -88.7, 10 + lon_offset, 242.556687633) + end if + test_interpolate(data, -89.5, -1 + lon_offset, 244.39720844) + + # south pole (mean) + test_interpolate(data, -90, -1e-15 + lon_offset, 245.510671997) + test_interpolate(data, -90, -1 + lon_offset, 245.510671997) + if lon_offset = 0 then + test_interpolate(data, -90, 1e-15 + lon_offset, 245.510671997) + test_interpolate(data, -90, 1 + lon_offset, 245.510671997) + test_interpolate(data, -90, 50 + lon_offset, 245.510671997) + end if + end loop + end loop + +end test_reduced_gg_border_interpolate() + +#------------------------------------------------- +# Testing reduced Gaussian grid +#------------------------------------------------- +# lon close to eastern border, see METV-3362 + +function test_reduced_gg_border_nearest() + + print('Test: test_reduced_gg_border_nearest') + + # global reduced Gaussian grid + # northernmost lat=88.5722 + # southernmost lat=-88.5722 + + files = ["t1000_red_gg_N48.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + print('nearest_gridpoint_info lon_offset=', lon_offset) + # lat lon reflat reflon refindex + # points in the last cell below the northernmost lat + test_nearest_gridpoint_info(data, 88.34, -1e-15, 88.5722, 0, 1) + test_nearest_gridpoint_info(data, 88.00, -1e-15, 88.5722, 0, 1) + test_nearest_gridpoint_info(data, 87.115,-1e-15, 86.7225, 2.30926e-14, 21) + + test_nearest_gridpoint_info(data, 88.34, -11, 88.5722, -18, 20) + test_nearest_gridpoint_info(data, 88.00, -11, 88.5722, -18, 20) + test_nearest_gridpoint_info(data, 87.115,-11, 86.7225, -14.4, 45) + + # north of the northernmost lat + test_nearest_gridpoint_info(data, 88.7, -1E-15, 88.5722, 0, 1) + test_nearest_gridpoint_info(data, 88.7, -1, 88.5722, 0, 1) + test_nearest_gridpoint_info(data, 88.7, 1E-15, 88.5722, 0, 1) + test_nearest_gridpoint_info(data, 88.7, 1, 88.5722, 0, 1) + test_nearest_gridpoint_info(data, 88.7, 10, 88.5722, 18, 2) + + # near the north pole + test_nearest_gridpoint_info(data, 89.5, -1E-15, 88.5722, 0, 1) + test_nearest_gridpoint_info(data, 89.5, 90, 88.5722, 90, 6) + + # lat lon reflat reflon refindex + # points in the last cell below southernmost lat + test_nearest_gridpoint_info(data, -88.34, -1e-15, -88.5722, 0, 13261) + test_nearest_gridpoint_info(data, -88.00, -1e-15, -88.5722, 0, 13261) + test_nearest_gridpoint_info(data, -87.115,-1e-15, -86.7225, 2.30926e-14, 13236) + + test_nearest_gridpoint_info(data, -88.34, -11, -88.5722, -18, 13280) + test_nearest_gridpoint_info(data, -88.00, -11, -88.5722, -18, 13280) + test_nearest_gridpoint_info(data, -87.115,-11, -86.7225, -14.4, 13260) + + # south of the southernmost lat + test_nearest_gridpoint_info(data, -88.7, -1E-15, -88.5722, 0, 13261) + test_nearest_gridpoint_info(data, -88.7, -1, -88.5722, 0, 13261) + test_nearest_gridpoint_info(data, -88.7, 1E-15, -88.5722, 0, 13261) + test_nearest_gridpoint_info(data, -88.7, 1, -88.5722, 0, 13261) + test_nearest_gridpoint_info(data, -88.7, 10, -88.5722, 18, 13262) + + # near the south pole + test_nearest_gridpoint_info(data, -89.5, -1E-15, -88.5722, 0, 13261) + test_nearest_gridpoint_info(data, -89.5, 90, -88.5722, 90, 13266) + end loop + end loop + +end test_reduced_gg_border_nearest() + +#-------------------------------------------------------- +# Testing reduced Gaussian grid for surrounding points +#-------------------------------------------------------- + +# lon close to eastern border, see METV-3362 +function test_reduced_gg_border_surrounding() + + print('Test: test_reduced_gg_border_surrounding') + + # global reduced Gaussian grid + # northernmost lat=88.5722 + # southernmost lat=-88.5722 + + files = ["t1000_red_gg_N48.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + loop optionAll in [0,1] + # points in the last cell below the northernmost lat + test_surrounding_points(data, 88.348, -1e-15, |1,20,21,45|, optionAll) + test_surrounding_points(data, 88, -1e-15, |1,20,21,45|, optionAll) + test_surrounding_points(data, 87.115, -1e-15, |21,45,1,20|, optionAll) + test_surrounding_points(data, 88.348, -11, |20,1,45,21|, optionAll) + test_surrounding_points(data, 88, -11, |20,1,45,21|, optionAll) + test_surrounding_points(data, 87.115, -11, |45,21,20,1|, optionAll) + test_surrounding_points(data, 86.9, -13.5, |45,21,20,1|, optionAll) + + # north of the northernmost lat + test_surrounding_points(data, 88.7, -1e-15, |1,20,2,19,3,18,4,17,5,16,6,15,7,14,8,13,9,12,10,11|, optionAll) + test_surrounding_points(data, 88.7, -1, |1,20,2,19,3,18,4,17,5,16,6,15,7,14,8,13,9,12,10,11|, optionAll) + test_surrounding_points(data, 88.7, 1e-15, |1,2,20,3,19,4,18,5,17,6,16,7,15,8,14,9,13,10,12,11|, optionAll) + test_surrounding_points(data, 88.7, 1, |1,2,20,3,19,4,18,5,17,6,16,7,15,8,14,9,13,10,12,11|, optionAll) + test_surrounding_points(data, 88.7, 10, |2,1,3,20,4,19,5,18,6,17,7,16,8,15,9,14,10,13,11,12|, optionAll) + + # north pole + test_surrounding_points(data, 90, -1e-15, |20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1|, optionAll) + test_surrounding_points(data, 90, -1, |20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1|, optionAll) + + # point in the last cell above the southernmost lat + test_surrounding_points(data, -88.348, -1e-15, |13261,13280,13236,13260|, optionAll) + test_surrounding_points(data, -88, -1e-15, |13261,13280,13236,13260|, optionAll) + test_surrounding_points(data, -87.115, -1e-15, |13236,13260,13261,13280|, optionAll) + + test_surrounding_points(data, -88.348, -11, |13280,13261,13260,13236|, optionAll) + test_surrounding_points(data, -88, -11, |13280,13261,13260,13236|, optionAll) + test_surrounding_points(data, -87.115, -11, |13260,13236,13280,13261|, optionAll) + test_surrounding_points(data, -86.9, -13.5, |13260,13236,13280,13261|, optionAll) + + # south of the southernmost lat + test_surrounding_points(data, -88.7, -1e-15, |13261,13280,13262,13279,13263,13278,13264,13277,13265,13276,13266,13275,13267,13274,13268,13273,13269,13272,13270,13271|, optionAll) + test_surrounding_points(data, -88.7, -1, |13261,13280,13262,13279,13263,13278,13264,13277,13265,13276,13266,13275,13267,13274,13268,13273,13269,13272,13270,13271|, optionAll) + test_surrounding_points(data, -88.7, 1e-15, |13261,13262,13280,13263,13279,13264,13278,13265,13277,13266,13276,13267,13275,13268,13274,13269,13273,13270,13272,13271| , optionAll) + test_surrounding_points(data, -88.7, 1, |13261,13262,13280,13263,13279,13264,13278,13265,13277,13266,13276,13267,13275,13268,13274,13269,13273,13270,13272,13271|, optionAll) + test_surrounding_points(data, -88.7, 10, |13262,13261,13263,13280,13264,13279,13265,13278,13266,13277,13267,13276,13268,13275,13269,13274,13270,13273,13271,13272|, optionAll) + + test_surrounding_points(data, -89.5, -1, |13261,13280,13262,13279,13263,13278,13264,13277,13265,13276,13266,13275,13267,13274,13268,13273,13269,13272,13270,13271|, optionAll) + + # south pole (mean) + test_surrounding_points(data, -90, -1e-15, |13280,13279,13278,13277,13276,13275,13274,13273,13272,13271,13270,13269,13268,13267,13266,13265,13264,13263,13262,13261|, optionAll) + test_surrounding_points(data, -90, -1, |13280,13279,13278,13277,13276,13275,13274,13273,13272,13271,13270,13269,13268,13267,13266,13265,13264,13263,13262,13261|, optionAll) + end loop + end loop + +end test_reduced_gg_border_surrounding + + +#------------------------------------------------- +# Testing small reduced Gaussian grid +#------------------------------------------------- +function test_reduced_gg_small() + print(' ') + print('Test: test_reduced_gg_small USE_NEAREST_NON_MISSING=' & USE_NEAREST_NON_MISSING) + + test_interpolate_on_original_gridpoints('t1000_red_gg_N48.grib', 0.000000001, 'vector') +end test_redduced_gg_small + + +#------------------------------------------------- +# Testing subarea of reduced Gaussian grid +#------------------------------------------------- +function test_reduced_gg_subarea_interpolate() + print(' ') + print('Test: test_reduced_gg_subarea_interpolate') + + files = ["rgg_western_subarea.grib", "rgg_western_subarea_g2.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + grib2 = (fname = "rgg_western_subarea_g2.grib") + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + + if lon_offset = 0 or grib2 then + print('interpolate lon_offset=', lon_offset) + + # North-East corner of area + test_interpolate(data, 11.9, -70.24 + lon_offset, nil) + test_interpolate(data, 11.93, -70.213 + lon_offset, nil ) + test_interpolate(data, 11.93, -70.283 + lon_offset, 299.813419235) + test_interpolate(data, 11.93, -70.28299999999999999 + lon_offset, 299.813419235) + test_interpolate(data, 11.93, -70.29 + lon_offset, 299.790672062) + test_interpolate(data, 11.68, -70.213 + lon_offset, nil) + test_interpolate(data, 11.68, -70.283 + lon_offset, 299.408780047) + test_interpolate(data, 11.68, -70.28299999999999999 + lon_offset, 299.408780047) + test_interpolate(data, 11.68, -70.29 + lon_offset, 299.397489569) + + # South-West corner of area + test_interpolate(data, -9.73, -79.63 + lon_offset, 290.625301207) + + # North-West corner of area + test_interpolate(data, 11.91, -79.76 + lon_offset, 300.866517527) + + # South-East corner of area + test_interpolate(data, -9.92, -70.12 + lon_offset, nil) # South-East corner of area + test_interpolate(data, -9.97, -70.069 + lon_offset, nil) + test_interpolate(data, -9.97, -70.138 + lon_offset, 293.967903658) + test_interpolate(data, -9.97, -70.13799999999999999 + lon_offset, 293.967903658) + test_interpolate(data, -9.97, -70.14 + lon_offset, 293.966003801) + test_interpolate(data, -9.705, -70.069 + lon_offset, nil) + test_interpolate(data, -9.705, -70.138 + lon_offset, 293.948441927) + test_interpolate(data, -9.705, -70.13799999999999999 + lon_offset, 293.948441927) + test_interpolate(data, -9.705, -70.14 + lon_offset, 293.948203308) + + # middle, N hemisphere + test_interpolate(data, 0.70, -75.43 + lon_offset, 295.234408007) + + # middle, S hemisphere + test_interpolate(data, -0.44, -75.84 + lon_offset, 295.402649703) + end if + end loop + end loop + +end test_reduced_gg_subarea_interpolate + +function test_reduced_gg_subarea_nearest() + print(' ') + print('Test: test_reduced_gg_subarea_nearest') + + files = ["rgg_western_subarea.grib", "rgg_western_subarea_g2.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + grib2 = (fname = "rgg_western_subarea_g2.grib") + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + + if lon_offset = 0 or grib2 then + print('nearest_gridpoint lon_offset=', lon_offset) + # North-East corner of area + test_nearest_gridpoint_value(data, 11.9, -70.17 + lon_offset, nil) + test_nearest_gridpoint_value(data, 11.9, -70.24 + lon_offset, 300.07) + test_nearest_gridpoint_value(data, 11.73, -70.23 + lon_offset, 299.381347656) + test_nearest_gridpoint_value(data, 11.63, -70.23 + lon_offset, 299.381347656) + test_nearest_gridpoint_value(data, 11.42, -70.12 + lon_offset, 300.751464844) + test_nearest_gridpoint_value(data, 11.32, -70.12 + lon_offset, 300.751464844) + test_nearest_gridpoint_value(data, 11.88, -70.468 + lon_offset, 299.004394531) + + # South-West corner of area + test_nearest_gridpoint_value(data, -9.73, -79.63 + lon_offset, 290.677246094) + test_nearest_gridpoint_value(data, -9.73, -79.744 + lon_offset, 290.677246094) + test_nearest_gridpoint_value(data, -9.91, -79.744 + lon_offset, 290.674316406) + + + # North-West corner of area + test_nearest_gridpoint_value(data, 11.91, -79.76 + lon_offset, 300.871582031) + test_nearest_gridpoint_value(data, 11.91, -79.81 + lon_offset, 300.871582031) # out of domain + test_nearest_gridpoint_value(data, 11.91, -79.95 + lon_offset, 300.871582031) # out of domain + test_nearest_gridpoint_value(data, 11.91, -81 + lon_offset, nil) # out of domain + test_nearest_gridpoint_value(data, 11.75, -79.712 + lon_offset, 300.708984375) + + # South-East corner of area + test_nearest_gridpoint_value(data, -9.88, -70.05 + lon_offset, nil) + test_nearest_gridpoint_value(data, -9.92, -70 + lon_offset, nil) + test_nearest_gridpoint_value(data, -9.92, -70.12 + lon_offset, 294.04) + test_nearest_gridpoint_value(data, -9.92, -70.088 + lon_offset, 294.03515625) + test_nearest_gridpoint_value(data, -9.72, -70.088 + lon_offset, 293.947753906) + test_nearest_gridpoint_value(data, -9.72, -70.18 + lon_offset, 293.947753906) + test_nearest_gridpoint_value(data, -9.45, -70.195 + lon_offset, 293.565429688) + test_nearest_gridpoint_value(data, -9.72, -70.38 + lon_offset, 293.919921875) + + # middle, N hemisphere + test_nearest_gridpoint_value(data, 0.70, -75.43 + lon_offset, 295.25) + + # middle, S hemisphere + test_nearest_gridpoint_value(data, -0.44, -75.84 + lon_offset, 295.37) + end if + + end loop + end loop + +end test_reduced_gg_subarea_nearest + +#------------------------------------------------- +# Testing subarea of reduced Gaussian grid +#------------------------------------------------- +function test_reduced_gg_subarea_surrounding() + print(' ') + print('Test: test_reduced_gg_subarea_sourrounding') + + optionAll = 0 + + files = ["rgg_western_subarea.grib", "rgg_western_subarea_g2.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + grib2 = (fname = "rgg_western_subarea_g2.grib") + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + + #if lon_offset = 0 or grib2 then + print('nearest_gridpoint lon_offset=', lon_offset) + # North-East corner of area + test_surrounding_points(data, 11.9, -70.17, nil, optionAll) + test_surrounding_points(data, 11.9, -70.24, nil, optionAll) + test_surrounding_points(data, 11.73, -70.23, nil, optionAll) + test_surrounding_points(data, 11.63, -70.23, nil, optionAll) + test_surrounding_points(data, 11.42, -70.12, nil, optionAll) + test_surrounding_points(data, 11.32, -70.12, |94,126,93,125|, optionAll) + test_surrounding_points(data, 11.88, -70.468, |30,61,31,62|, optionAll) + + # South-West corner of area + test_surrounding_points(data, -9.73, -79.63, |2620,2621,2652,2653|, optionAll) + test_surrounding_points(data, -9.73, -79.744, |2620,2652,2621,2653|, optionAll) + test_surrounding_points(data, -9.91, -79.744, |2652,2620,2653,2621|, optionAll) + + # North-West corner of area + test_surrounding_points(data, 11.91, -79.76, |1,32,2,33|, optionAll) + test_surrounding_points(data, 11.91, -79.81, |1,32,2,33|, optionAll) + test_surrounding_points(data, 11.91, -79.95, |1,32,2,33|, optionAll) + test_surrounding_points(data, 11.91, -81, nil, optionAll) + test_surrounding_points(data, 11.75, -79.81, |32,1,33,2|, optionAll) + test_surrounding_points(data, 11.75, -79.712, |32,1,33,2|, optionAll) + + # South-East corner of area + test_surrounding_points(data, -9.88, -70.05, nil, optionAll) + test_surrounding_points(data, -9.92, -70, nil, optionAll) + test_surrounding_points(data, -9.92, -70.12, nil, optionAll) + test_surrounding_points(data, -9.92, -70.088, nil, optionAll) + test_surrounding_points(data, -9.72, -70.088, nil, optionAll) + test_surrounding_points(data, -9.72, -70.18, |2651,2650,2683,2682|, optionAll) + test_surrounding_points(data, -9.45, -70.195, nil, optionAll) + test_surrounding_points(data, -9.72, -70.38, |2650,2651,2682,2683|, optionAll) + + # middle, N hemisphere + test_surrounding_points(data, 0.7, -75.43, |1361,1362,1397,1398|, optionAll) + + # middle, S hemisphere + test_surrounding_points(data, -0.44, -75.84, |1506,1505,1542,1541|, optionAll) + #end if + end loop + end loop + +end test_reduced_gg_subarea_surrounding + +function test_reduced_gg_subarea_latlons() + print(' ') + print('Test: test_reduced_gg_subarea_latlons') + fnName = "test_reduced_gg_subarea_latlons" + + files = ["rgg_western_subarea.grib", "rgg_western_subarea_g2.grib"] + loop fname in files + grib2 = (fname = "rgg_western_subarea_g2.grib") + data = read(fname) + print("fname=", fname) + lon = longitudes(data) + lat = latitudes(data) + + lat_index = |1,2,3,32,63| + lat_ref = |11.9438, 11.9438, 11.9438, 11.6628, 11.3817| + assert(vec_same(lat[lat_index], lat_ref, 1E-4), fnName & " lat", 1) + + lon_index = |1,2,3,32,63| + if grib2 then + lon_ref = |280.212765957, 280.531914894, 280.85106383, 280.176678445, 280.14084507| + + else + lon_ref = |-79.7872340426, -79.4680851064, -79.1489361702, -79.8233215548, -79.8591549296| + end if + #loop idx in lon_index + # print(lon[idx]) + #end loop + assert(vec_same(lon[lon_index], lon_ref, 1E-4), fnName & " lon", 1) + + end loop +end test_reduced_gg_subarea_latlons + + +function test_reduced_gg_subarea_nearest_across_zero_lon() + print(' ') + print('Test: test_reduced_gg_subarea_nearest_across_zero_lon') + + files = ["rgg_zero_lon_subarea.grib", "rgg_zero_lon_subarea_g2.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + grib2 = (fname = "rgg_zero_lon_subarea_g2.grib") + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + + if lon_offset = 0 or grib2 then + print('nearest_gridpoint lon_offset=', lon_offset) + + # middle, West + test_nearest_gridpoint_value(data, 47, -5 + lon_offset, 8.1875) + + # middle, East + test_nearest_gridpoint_value(data, 47, 5 + lon_offset, 40.62) + + # North-East corner of area + test_nearest_gridpoint_value(data, 70.074, 37.946 + lon_offset, nil) + test_nearest_gridpoint_value(data, 69.985, 38.609 + lon_offset, nil) + test_nearest_gridpoint_value(data, 69.985, 37.946 + lon_offset, 0.1875) + test_nearest_gridpoint_value(data, 69.985, 37.7399999999999 + lon_offset, 0.1875) + + # North-West corner of area + test_nearest_gridpoint_value(data, 70.074, -16.59 + lon_offset, nil) + test_nearest_gridpoint_value(data, 69.985, -16.59 + lon_offset, 4) + test_nearest_gridpoint_value(data, 69.985, -16.221 + lon_offset, 4) + # this should give 4 + #test_nearest_gridpoint_value(data, 69.985, -16.398 + lon_offset, nil) + + # South-West corner of area + test_nearest_gridpoint_value(data, 33.381, -16.579 + lon_offset, nil) + test_nearest_gridpoint_value(data, 33.414, -16.488 + lon_offset, 0.3125) + test_nearest_gridpoint_value(data, 33.414, -16.5199999999 + lon_offset, 0.3125) + test_nearest_gridpoint_value(data, 33.541, -16.633 + lon_offset, 0.25) + + # South-East corner of area + test_nearest_gridpoint_value(data, 33.381, 38.4 + lon_offset, nil) + test_nearest_gridpoint_value(data, 33.414, 38.292 + lon_offset, 0) + test_nearest_gridpoint_value(data, 33.597, 38.292 + lon_offset, 0) + + end if + + end loop + end loop + +end test_reduced_gg_subarea_nearest_across_zero_lon + +function test_reduced_gg_subarea_interpolate_across_zero_lon() + print(' ') + print('Test: test_reduced_gg_subarea_interpolate_across_zero_lon') + + files = ["rgg_zero_lon_subarea.grib", "rgg_zero_lon_subarea_g2.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + grib2 = (fname = "rgg_zero_lon_subarea_g2.grib") + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + + if lon_offset = 0 or grib2 then + print('interpolate lon_offset=', lon_offset) + + # North-East corner of area + test_interpolate(data, 70.074, 37.946 + lon_offset, nil) + test_interpolate(data, 69.985, 38.609 + lon_offset, nil ) + test_interpolate(data, 69.985, 37.946 + lon_offset, nil) + test_interpolate(data, 69.985, 37.7399999999999 + lon_offset, 0.154780586604) + + # South-West corner of area + test_interpolate(data, 33.414, -16.488 + lon_offset, 0.325065798637) + + # North-West corner of area + test_interpolate(data, 69.985, -16.335 + lon_offset, 4.00150208746) + + # South-East corner of area + test_interpolate(data, 33.381, 38.4 + lon_offset, nil) + test_interpolate(data, 33.414, 38.292 + lon_offset, nil) + test_interpolate(data, 33.597, 38.088 + lon_offset, 0) + + # middle, West + test_interpolate(data, 47, -5 + lon_offset, 8.87034140986) + + # middle, East + test_interpolate(data, 47, 5 + lon_offset, 40.6516807519) + + end if + end loop + end loop + +end test_reduced_gg_subarea_interpolate_across_zero_lon + +function test_reduced_gg_subarea_surrounding_across_zero_lon() + print(' ') + print('Test: test_reduced_gg_subarea_sourrounding_across_zero_lon') + + optionAll = 0 + + files = ["rgg_zero_lon_subarea.grib", "rgg_zero_lon_subarea_g2.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + + grib2 = (fname = "rgg_zero_lon_subarea_g2.grib") + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + + #if lon_offset = 0 or grib2 then + print('nearest_gridpoint lon_offset=', lon_offset) + + # middle, West + test_surrounding_points(data, 47, -5 + lon_offset, |8998,9118,8999,9119|, optionAll) + + # middle, East + test_surrounding_points(data, 47, 5 + lon_offset, |9020,9140,9019,9139|, optionAll) + + # North-East corner of area + test_surrounding_points(data, 70.074, 37.946 + lon_offset, nil, optionAll) + test_surrounding_points(data, 69.985, 38.609 + lon_offset, nil, optionAll) + test_surrounding_points(data, 69.985, 37.946 + lon_offset, nil, optionAll) + test_surrounding_points(data, 69.985, 37.7399999999999 + lon_offset,|57,114,115,56|, optionAll) + + #end if + end loop + end loop + +end test_reduced_gg_subarea_surrounding_across_zero_lon + +function test_reduced_gg_subarea_latlons_across_zero_lon() + print(' ') + print('Test: test_reduced_gg_subarea_latlons_across_zero_lon') + fnName = "test_reduced_gg_subarea_latlons_across_zero_lon" + + precision(12) + + files = ["rgg_zero_lon_subarea.grib", "rgg_zero_lon_subarea_g2.grib"] + loop fname in files + grib2 = (fname = "rgg_zero_lon_subarea_g2.grib") + data = read(fname) + print("fname=", fname) + lon = longitudes(data) + lat = latitudes(data) + + lat_index = |1,2,3,58,116| + lat_ref = |70.0436918931, 70.0436918931, 70.0436918931, 69.8188328027, 69.5939737045| + assert(vec_same(lat[lat_index], lat_ref, 1E-4), fnName & " lat", 1) + + lon_index = |1,2,3,58,116| + lon_ref = |-16.4516129032, -15.4838709677, -14.5161290323, -16.2765957447, -16.1052631579| + + #loop idx in lon_index + # print(lon[idx]) + # end loop + assert(vec_same(lon[lon_index], lon_ref, 1E-4), fnName & " lon", 1) + + end loop +end test_reduced_gg_subarea_latlons_across_zero_lon + + +#------------------------------------------------- +# Testing tiny reduced Gaussian grid +#------------------------------------------------- + +function test_reduced_gg_tiny() + data = read('rgg_small_subarea.grib') + print(' ') + print('Test: test_reduced_gg_tiny USE_NEAREST_NON_MISSING=' & USE_NEAREST_NON_MISSING) + + # the interesting thing about this grid is that some of the rows have + # only 1 point + + # test a whole bunch of points, checking their locations and indexes in particular + # lat lon reflat reflon refindex + test_nearest_gridpoint_info(data, 89.80, 41.20, 89.806, 38.572, 2) + test_nearest_gridpoint_info(data, 89.86, 47.00, 89.877, 45.000, 1) + test_nearest_gridpoint_info(data, 89.59, 42.37, 89.60, 45.000, 5) + test_nearest_gridpoint_info(data, 89.18, 43.88, 89.17, 45.000, 14) + test_nearest_gridpoint_info(data, 85.30, 39.84, 85.31, 39.30, 276) + + # lat lon refvalue + test_nearest_gridpoint_value(data, 89.80, 41.20, 242.883) + test_nearest_gridpoint_value(data, 89.86, 47.00, 242.793) + test_nearest_gridpoint_value(data, 89.59, 42.37, 243.154) + test_nearest_gridpoint_value(data, 89.18, 43.88, 243.776) + test_nearest_gridpoint_value(data, 85.30, 39.84, 250.764) +end test_reduced_gg_tiny + diff -Nru metview-5.17.4/metview/test/macros/grib_nearest_reduced_ll.mv metview-5.19.2/metview/test/macros/grib_nearest_reduced_ll.mv --- metview-5.17.4/metview/test/macros/grib_nearest_reduced_ll.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_nearest_reduced_ll.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,86 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" +include "grib_nearest_utils.mv" + +global USE_NEAREST_NON_MISSING = 0 + +# reduced latlon +test_reduced_ll_surrounding() +test_reduced_ll_latlons() + +#------------------------------------------------------------------------- +# Testing global lat-lon with no point at the poles for surrounding points +#------------------------------------------------------------------------- +function test_reduced_ll_surrounding() + + # this data file has first/last latitudes set to 90 and -90, and so is + # considered global, but its 'pl' array has zeros in all rows south + # of 78S, meaning there is no data there. + + # read the data file + data = read('reduced_ll.grib') + print(' ') + print('Testing global reduced lat/lon grid for surrounding') + + loop optionAll in [0, 1] + test_surrounding_points(data, 40, -60, |472483,472484,470278,470279|, optionAll) + test_surrounding_points(data, -50, 60, |2331274,2331273,2329418,2329419|, optionAll) + test_surrounding_points(data, -90, 0, nil, optionAll) + test_surrounding_points(data, -84.73, 10, nil, optionAll) + test_surrounding_points(data, -78.29, -165.68, nil, optionAll) + test_surrounding_points(data, -78.1, 20, nil, optionAll) # just over the edge + end loop + + optionAll = 0 + test_surrounding_points(data, 50, 20, nil, optionAll) + test_surrounding_points(data, -5.053, -35.7, nil, optionAll) + test_surrounding_points(data, 90, 0, nil, optionAll) + optionAll = 1 + test_surrounding_points(data, -5.053, -35.7, |1436670,1439539,1436671,1439538|, optionAll) + +end test_reduced_ll_surrounding + +function test_reduced_ll_latlons() + print(' ') + print('Test: test_reduced_ll_latlons') + fnName = "test_reduced_ll_latlons" + + #precision(12) + + files = ["reduced_ll.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + lon = longitudes(data) + lat = latitudes(data) + + lat_index = |1,2,3,9,23,24| + lat_ref = |90, 90, 89.875, 89.75, 89.625, 89.625| + #loop idx in lat_index + # print(lat[idx]) + #end loop + assert(vec_same(lat[lat_index], lat_ref, 1E-4), fnName & " lat", 1) + + lon_index = |1,2,3,9,23,24| + lon_ref = |0,180,0,0,0,18| + + #loop idx in lon_index + # print(lon[idx]) + #end loop + assert(vec_same(lon[lon_index], lon_ref, 1E-4), fnName & " lon", 1) + + end loop +end test_reduced_ll_latlons + + + diff -Nru metview-5.17.4/metview/test/macros/grib_nearest_regular_gg.mv metview-5.19.2/metview/test/macros/grib_nearest_regular_gg.mv --- metview-5.17.4/metview/test/macros/grib_nearest_regular_gg.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_nearest_regular_gg.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,155 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" +include "grib_nearest_utils.mv" + +global USE_NEAREST_NON_MISSING = 0 + +# regular Gaussian +test_reg_gg_latlons() +test_reg_gg_subarea() +test_reg_gg_subarea_latlons() + +loop ctl in [0, 1] + + USE_NEAREST_NON_MISSING = ctl + + test_reg_gg_small() + +end loop + + +#------------------------------------------------- +# Testing small regular Gaussian grid +#------------------------------------------------- +function test_reg_gg_small() + print(' ') + print('Test: test_reg_gg_small USE_NEAREST_NON_MISSING=' & USE_NEAREST_NON_MISSING) + test_interpolate_on_original_gridpoints('t1000_reg_gg_N48.grib', 0.000000001, 'vector') +end test_reg_gg_small + +function test_reg_gg_latlons() + print(' ') + print('Test: test_reg_gg_latlons') + fnName = "test_reg_gg_latlons" + + #precision(12) + + files = ["t1000_reg_gg_N48.grib"] + loop fname in files + data = read(fname) + print("fname=", fname) + lon = longitudes(data) + lat = latitudes(data) + + lat_index = |1,2,3,193,385| + lat_ref = |88.572168514, 88.572168514, 88.572168514, 86.7225309547, 84.861970292| + #loop idx in lat_index + # print(lat[idx]) + #end loop + assert(vec_same(lat[lat_index], lat_ref, 1E-4), fnName & " lat", 1) + + lon_index = |1,2,3,193,385| + lon_ref = |0,1.875,3.75,0,0| + + #loop idx in lon_index + # print(lon[idx]) + #end loop + assert(vec_same(lon[lon_index], lon_ref, 1E-4), fnName & " lon", 1) + + end loop +end test_reg_gg_latlons + +#------------------------------------------------- +# Testing subarea of regular Gaussian grid +#------------------------------------------------- +function test_reg_gg_subarea() + print(' ') + print('Testing subarea regular Gaussian grid') + data = read('regular_gaussian_subarea.grib') + + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + # point in the middle with lon in 0-360 range + print('nearest_gridpoint lon_offset=', lon_offset) + test_nearest_gridpoint_value(data, 37.0, -75 + lon_offset, -1.9101) # in the middle of the area + test_nearest_gridpoint_value(data, 15.09, -100.9 + lon_offset, -3.69) # towards South-West corner + test_nearest_gridpoint_value(data, 15.40, -101.2 + lon_offset, -3.04) # towards South-West corner + test_nearest_gridpoint_value(data, 56.87, -38.87 + lon_offset, 4.28) # towards North-East corner + + print('interpolate lon_offset=', lon_offset) + test_interpolate(data, 37.0, -75 + lon_offset, -2.75669094004) # in the middle of the area + test_interpolate(data, 15.09, -100.9 + lon_offset, -3.61352386547) # towards South-West corner + test_interpolate(data, 15.40, -101.2 + lon_offset, -2.93612764983) # towards South-West corner + test_interpolate(data, 56.87, -38.87 + lon_offset, 4.49194312115) # towards North-East corner + if lon_offset = 0 then + test_interpolate(data, 56.87, 28 + lon_offset, nil) # point outside domain + end if + end loop + + print(' ') + print('Testing subarea regular Gaussian grid GRIB2') + data = read('regular_gaussian_subarea_g2.grib') + # test all points with longitude values in both 0-360 range and -180-+180 range + loop lon_offset in [0, 360] + print('nearest_gridpoint lon_offset=', lon_offset) + test_nearest_gridpoint_value(data, 37.0, -75 + lon_offset, -1.9101) # in the middle of the area + test_nearest_gridpoint_value(data, 15.09, -100.9 + lon_offset, -3.69) # towards South-West corner + test_nearest_gridpoint_value(data, 15.40, -101.2 + lon_offset, -3.04) # towards South-West corner + test_nearest_gridpoint_value(data, 56.87, -38.87 + lon_offset, 4.28) # towards North-East corner + + print('interpolate lon_offset=', lon_offset) + test_interpolate(data, 37.0, -75 + lon_offset, -2.75669094004) # in the middle of the area + test_interpolate(data, 15.09, -100.9 + lon_offset, -3.61352386547) # towards South-West corner + test_interpolate(data, 15.40, -101.2 + lon_offset, -2.93612764983) # towards South-West corner + test_interpolate(data, 56.87, -38.87 + lon_offset, 4.49194312115) # towards North-East corner + if lon_offset = 0 then + test_interpolate(data, 56.87, 28 + lon_offset, nil) # point outside domain + end if + end loop + + #test_interpolate_on_original_gridpoints('regular_gaussian_subarea.grib', 0.000000001, 'vector') +end test_reg_gg_subarea + +function test_reg_gg_subarea_latlons() + print(' ') + print('Test: test_reg_gg_subarea_latlons') + fnName = "test_reg_gg_subarea_latlons" + + #precision(12) + + files = ["regular_gaussian_subarea.grib", "regular_gaussian_subarea_g2.grib"] + loop fname in files + grib2 = (fname = "regular_gaussian_subarea_g2.grib") + data = read(fname) + print("fname=", fname) + lon = longitudes(data) + lat = latitudes(data) + + lat_index = |1,2,3,224,447| + lat_ref = |56.9086383162, 56.9086383162, 56.9086383162, 56.6276081563, 56.3465779923| + #loop idx in lat_index + # print(lat[idx]) + #end loop + assert(vec_same(lat[lat_index], lat_ref, 1E-4), fnName & " lat", 1) + + lon_index = |1,2,3,224,447| + lon_ref = |258.75, 259.031, 259.312, 258.75, 258.75| + + #loop idx in lon_index + # print(lon[idx]) + #end loop + assert(vec_same(lon[lon_index], lon_ref, 1E-4), fnName & " lon", 1) + + end loop +end test_reg_gg_subarea_latlons + diff -Nru metview-5.17.4/metview/test/macros/grib_nearest_utils.mv metview-5.19.2/metview/test/macros/grib_nearest_utils.mv --- metview-5.17.4/metview/test/macros/grib_nearest_utils.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_nearest_utils.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,430 @@ +#Metview Macro + +# ---------------------------------------------------------------------------- +# Function : test_nearest_gridpoint_info +# +# Description : checks whether the nearest_gridpoint function is giving +# the expected result (supplied as arguments). It currently +# only checks the lat, lon and index of the returned point, +# not its value. +# ---------------------------------------------------------------------------- + +function test_nearest_gridpoint_info(f:fieldset, inlat, inlon, correctlat, correctlon, correctindex) + + if USE_NEAREST_NON_MISSING <> 1 then + ng = nearest_gridpoint_info(f, inlat, inlon) + else + ng = nearest_gridpoint_info(f, inlat, inlon, 'valid') + end if + ng = ng[1] + print('in: ', inlat, ',', inlon, tab, ' out:', ng) + if (correctlat = nil and ng = nil) then + return + end if + if (different(ng.latitude, correctlat) or + different(ng.longitude, correctlon) or + different(ng.index, correctindex)) then + print("Nearest gridpoint gave incorrect result:") + print(ng) + print("Should have been : lat=", correctlat, " lon=", correctlon, " index=", correctindex) + fail('Stopped') + end if + +end test_nearest_gridpoint + + +function test_nearest_gridpoint_value(f:fieldset, inlat, inlon, correctval) + + if USE_NEAREST_NON_MISSING <> 1 then + ng = nearest_gridpoint_info(f, inlat, inlon) + else + ng = nearest_gridpoint_info(f, inlat, inlon, 'valid') + if ng = [nil] then + print("correctval=", correctval) + if correctval = nil then + return + else + print('in: ', inlat, ',', inlon, tab, ' out:', ng) + print("Nearest gridpoint gave incorrect result:") + print("Should have been : val=", correctval, " but it was ", ng) + fail('Stopped') + end if + end if + end if + + ng = ng[1] + print('in: ', inlat, ',', inlon, tab, ' out: ', ng) + if correctval = nil then + if ng = nil then + return + else if ng.value = nil then + return + end if + end if + + if ng = nil then + print("Nearest gridpoint gave incorrect result:") + print(ng) + print("Should have been: val=", correctval, " but it was nil") + fail('Stopped') + + fail('') + end if + + if (different(ng.value, correctval)) then + print("Nearest gridpoint gave incorrect result:") + print(ng) + print("Should have been: val=", correctval, " but it was ", ng.value) + fail('Stopped') + end if + +end test_nearest_gridpoint_value + +function test_nearest_gridpoint_value_vector(f:fieldset, inlat, inlon, correctval) + if USE_NEAREST_NON_MISSING <> 1 then + ng = nearest_gridpoint(f, inlat, inlon) + else + ng = nearest_gridpoint(f, inlat, inlon, 'valid') + end if + print('in: ', inlat, ',', inlon, tab, ' out:', ng) + if (count(ng) <> count(correctval)) then + print('Wrong number of elements: ', count(ng), ', got: ', count(correctval)) + fail('Stopped') + end if + if maxvalue(abs(ng - correctval)) > 0.01 then + print("Nearest gridpoint gave incorrect vector result:") + print("Should have been : val=", correctval, " but it was ", ng) + fail('Stopped') + end if +end test_nearest_gridpoint_value_vector + +function test_interpolate(f:fieldset, inlat, inlon, correctval) + ip = interpolate(f, inlat, inlon) + print('in: ', inlat, ',', inlon, tab, ' out:', ip) + if (correctval = nil and ip = nil) then + return + end if + + if (different(ip, correctval)) then + print("Interpolate gave incorrect result:") + print("Should have been : val=", correctval, " but it was ", ip) + fail('Stopped') + end if +end test_interpolate + +function test_interpolate_vector(f:fieldset, inlat, inlon, correctval) + ng = interpolate(f, inlat, inlon) + print('in: ', inlat, ',', inlon, tab, ' out:', ng) + + islist = (count(f) > 1) + + for i = 1 to count(f) do + + if islist then + ngi = ng[i] + correctvali = correctval[i] + else + ngi = ng + correctvali = correctval + end if + + if (count(ngi) <> count(correctvali)) then + print('Wrong number of elements: ', count(ngi), ', got: ', count(correctvali)) + fail('Stopped') + end if + if maxvalue(abs(ngi - correctvali)) > 0.01 then + print("Interpolate gave incorrect vector result:") + print("Should have been : val=", correctvali, " but it was ", ngi) + fail('Stopped') + end if + end for +end test_interpolate_vector + + + +# test_interpolate_on_original_gridpoints +# calls the interpolate() function on every original gridpoint of the +# given fieldset - the results should be the s|5577,5578,5397,5398|ame as the original +# gridpoint values; differences can be expected when interpolating with +# geopoints giving the target points, as this format could crop +# the lat/lon co-ordinates slightly +function test_interpolate_on_original_gridpoints(grib_file:string, tolerance:number, method:string) + + m_all = read(grib_file) + + for f = 1 to count(m_all) do + m = m_all[f] + lats = latitudes(m) + lons = longitudes(m) + v = values(m) + + if method = 'gpt' then + g = create_geo(count(values(m))) + g = set_latitudes(g, lats) + g = set_longitudes(g, lons) + vgeo = values(interpolate(m, g)) + diff = vgeo - v + else if method = 'vector' then + vvec = interpolate(m, lats, lons) + diff = vvec - v + else + #alternative - more precise, but takes a lot longer + c = count(v) + vx = vector(c) + for i = 1 to c do + vx[i] = interpolate(m, lats[i], lons[i]) + end for + diff = vx-v + end if + maxdiff = maxvalue(abs(diff)) + print('test_interpolate_on_original_gridpoints maxdiff: ', maxdiff) + if maxdiff > tolerance then + print('test_interpolate_on_original_gridpoints: ', grib_file, ' field ', f) + print('gave high difference: ', maxdiff) + fail('Stopped') + end if + end for + +end test_interpolate_on_original_gridpoints + + +function test_surrounding_points(f:fieldset, inlat:number, inlon:number, correctval_all, all) + print('surround in: ', inlat, ',', inlon, "mode=", all) + + if all <> 1 then + sp_all = surrounding_points_indexes(f, inlat, inlon) + else + sp_all = surrounding_points_indexes(f, inlat, inlon, 'all') + end if + + print(' out:', sp_all) + if correctval_all = nil and sp_all = nil then + return + end if + + num_fields = count(f) + for fi = 1 to num_fields do + + if num_fields > 1 then + sp = sp_all[fi] + correctval = correctval_all[fi] + else + sp = sp_all + correctval = correctval_all + end if + + if (count(sp) <> count(correctval)) then + print('Wrong number of elements: ', count(sp), ', instead of: ', count(correctval)) + fail('Stopped') + end if + if maxvalue(abs(sp - correctval)) > 0.01 then + print("Surrounding gridpoints gave incorrect vector result:") + print("Should have been : val=", correctval, " but it was ", sp) + if runmode() = "prepare" then + plot_surrounding_points(f, inlat, inlon) + end if + fail('Stopped') + end if + end for # num_fields +end test_surrounding_points + + +function test_surrounding_points_vector(f:fieldset, inlat:vector, inlon:vector, correctval_all, all) + print('surround vec in: ', inlat, ',', inlon, "mode=", all) + + if all <> 1 then + sp_all = surrounding_points_indexes(f, inlat, inlon) + else + sp_all = surrounding_points_indexes(f, inlat, inlon, 'all') + end if + + print(' out:', sp_all) + if correctval_all = nil and sp_all = nil then + return + end if + + num_fields = count(f) + for fi = 1 to num_fields do + + if num_fields > 1 then + sp = sp_all[fi] + correctval = correctval_all[fi] + else + sp = sp_all + correctval = correctval_all + end if + + + if (count(sp) <> count(correctval)) then + print('Wrong number of elements: ', count(sp), ', instead of: ', count(correctval)) + fail('Stopped') + end if + + for i = 1 to count(sp) do + if (count(sp[i]) <> count(correctval[i])) then + print(i, ': Wrong number of elements: ', count(sp[i]), ', instead of: ', count(correctval[i])) + fail('Stopped') + end if + if sp[i] <> nil and correctval[i] <> nil then + if maxvalue(abs(sp[i] - correctval[i])) > 0.01 then + print("Surrounding gridpoints gave incorrect vector result:") + print(i, ": Should have been : val=", correctval[i], " but it was ", sp[i]) + if runmode() = "prepare" then + plot_surrounding_points(f, inlat, inlon) + end if + fail('Stopped') + end if + end if + end for + end for # num_fields +end test_surrounding_points + + +function test_nearest_geopoints(f: fieldset, gpt: geopoints, correct: geopoints) + print('test_nearest_geopoints, ', count(gpt), ', ', count(correct)) + if USE_NEAREST_NON_MISSING <> 1 then + near = nearest_gridpoint(f, gpt) + else + near = nearest_gridpoint(f, gpt, 'valid') + end if + res = geopoints_same(near, correct) + if res = 0 then + if runmode() = "prepare" then + plot_fieldset_and_geopoints_vals(f, near) + end if + fail('test_nearest_geopoints failed') + end if +end test_nearest_geopoints + + +# ----------------------------------------------------------- +# geopoints_same +# will 0 if any element of the geopoints variables differs; otherwise 1 +# ----------------------------------------------------------- + +function geopoints_same(g1: geopoints, g2: geopoints) + + if count(g1) <> count(g2) then + print('Different number of points: ', count(g1), ' vs ', count(g2)) + return 0 + end if + + diff = g1 - g2 + + if maxvalue(abs(diff)) > 0.1 then + print('Difference in values. Please inspect the results vs the reference') + return 0 + end if + + if maxvalue(abs(latitudes(g1)-latitudes(g2))) > 0.05 then + print('Difference in latitudes. Please inspect the results vs the reference') + return 0 + end if + + if maxvalue(abs(longitudes(g1)-longitudes(g2))) > 0.05 then + print('Difference in longitudes. Please inspect the results vs the reference') + return 0 + end if + + if maxvalue(abs(levels(g1)-levels(g2))) > 0.05 then + print('Difference in levels. Please inspect the results vs the reference') + fail() + end if + + if maxvalue(abs(vector(dates(g1)-dates(g2)))) > 0.05 then + print('Difference in dates. Please inspect the results vs the reference') + return 0 + end if + +end compare_geopoints + + +function different(v1, v2) + if v1 = nil or v2 = nil then + return 1 + end if + return (abs(v1-v2) > 0.01) # threshold may have to change if we use higher-res data +end different + +# plot_surrounding_points +# convenience function to plot the specified point (red), plus the computed +# four surrounding points. The surrounding points are in shades a green, with +# the closest point in the darkest colour, up to the farthest point in the +# lightest colour +function plot_surrounding_points (data:fieldset, tlat: number, tlon: number, all) + print('plot_surrounding_points: ', nearest_gridpoint_info(data, tlat, tlon)) + print('plot_surrounding_points: ', interpolate(data, tlat, tlon)) + b = surrounding_points_indexes(data, tlat, tlon, all) + print(b[1], ' ', b[2], ' ', b[3], ' ', b[4], ' ') + extracted_vals = values(data)[b] + print('plot_surrounding_points: ', b) + print('plot_surrounding_points: ', extracted_vals) + spts_lats = latitudes(data)[b] + spts_lons = longitudes(data)[b] + print('plot_surrounding_points: ', spts_lats, spts_lons) + val_lst = nil + for i=1 to count(b) do + val_lst = val_lst & [i] + end for + spts = input_visualiser( + input_plot_type : "geo_points", + input_longitude_values : tolist(spts_lons), + input_latitude_values : tolist(spts_lats), + input_values : val_lst) + symb_common = (symbol_type: 'marker', symbol_marker_index: 15, symbol_height: 0.4) + spts_symb = msymb( + symbol_type : "marker", + symbol_table_mode : "advanced", + symbol_outline : "on", + symbol_advanced_table_selection_type : "list", + symbol_advanced_table_level_list : val_lst & [count(val_lst)+1], + symbol_advanced_table_colour_method : "list", + symbol_advanced_table_colour_list : ["RGB(0.0000,0.4000,0.1333)","RGB(0.0000,0.6039,0.2013)","RGB(0,0.8706,0.2902)","RGB(0.7804,0.9451,0.8353)"], + symbol_advanced_table_height_list : 0.6 + ) + + symb_multi = msymb( + legend : "on", + symbol_type : "marker", + symbol_table_mode : "advanced", + symbol_advanced_table_level_count : 50, + symbol_advanced_table_max_level_colour : "red", + symbol_advanced_table_min_level_colour : "blue", + symbol_advanced_table_colour_direction : "clockwise" + ) + + if count(spts_lats) > 4 then + symb_for_spts = symb_multi + else + symb_for_spts = spts_symb + end if + + tpt = input_visualiser(input_plot_type: "geo_points", + input_longitude_values: [tlon], + input_latitude_values: [tlat]) + tpt_symb = msymb(symb_common, symbol_colour : "red") + plot(data, spts, symb_for_spts, tpt, tpt_symb) +end plot_surrounding_points + + + +function plot_fieldset_and_geopoints_vals(data: fieldset, gpt: geopoints) + + grid_1x1 = mcont( + contour : "off", + contour_grid_value_plot : "on", + contour_grid_value_plot_type : "both", + grib_scaling_of_retrieved_fields : "off" + ) + symb = msymb(symbol_type: 'marker', symbol_marker_index: 15, symbol_height: 0.3, symbol_colour: 'cyan') + text = msymb(symbol_type: 'number', symbol_colour: 'olive') + plot(gpt, symb, data, grid_1x1, gpt, text) + +end plot_fieldset_and_geopoints_vals + +function assert_equal(v1: number, v2: number, msg:string) + if v1 <> v2 then + fail(tab,"test failed: ", v1, " <> ",v2," [",msg,"]") + end if +end assert + diff -Nru metview-5.17.4/metview/test/macros/grib_vertical_geopot_on_ml.mv metview-5.19.2/metview/test/macros/grib_vertical_geopot_on_ml.mv --- metview-5.17.4/metview/test/macros/grib_vertical_geopot_on_ml.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_vertical_geopot_on_ml.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,153 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_mvl_geopotential_on_ml() + +function test_mvl_geopotential_on_ml() + + fn_name = "mvl_geopotential_on_ml" + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + q = read(data: fs, param: 'q') + zs = read(data: fs, param: 'z') + lnsp = read(data: fs, param: 'lnsp') + + # the ref contains the levels in ascending order! + z_ref = read("z_ml137_ref.grib") + nLev = 137 + + # 1. all levels - ascending order + r = mvl_geopotential_on_ml(t,q,lnsp,zs) + assert_equal(count(r),nLev, fn_name & ": count",1) + + for i=1 to nLev do + assert_equal(grib_get_long(r[i],'level'), i, fn_name & ": level lev" & i,1) + v = values(r[i]) + v_ref = values(z_ref[i]) + assert(vec_same(v,v_ref,1E-2),fn_name & ": value lev" & i,1) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z",fn_name & ": shortName lev" & i,1) + end for + + # 2. all levels - descending order + t_desc = sort(t, "levelist", ">") + q_desc = sort(q, "levelist", ">") + + r = mvl_geopotential_on_ml(t_desc, q_desc,lnsp,zs) + assert_equal(count(r),nLev, fn_name & ": count",2) + + for i=1 to nLev do + assert_equal(grib_get_long(r[i],'level'), i, fn_name & ": level lev" & i,2) + v = values(r[i]) + v_ref = values(z_ref[i]) + assert(vec_same(v,v_ref,1E-2),fn_name & ": value lev" & i,2) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z",fn_name & ": shortName lev" & i,2) + end for + + # 3. levels 137->38 - ascending order + levs = nil + startLev = 38 + endLev = 137 + nLev = endLev - startLev + 1 + for i=startLev to endLev do + levs = levs & [i] + end for + t_sub = read(data: t, levelist: levs) + q_sub = read(data: q, levelist: levs) + + r = mvl_geopotential_on_ml(t_sub, q_sub,lnsp,zs) + assert_equal(count(r),nLev, fn_name & ": count",3) + + for i=1 to nLev do + lev = startLev + i - 1 + assert_equal(grib_get_long(r[i],'level'), lev, fn_name & ": level lev" & i,3) + + v = values(r[i]) + v_ref = values(z_ref[lev]) + assert(vec_same(v,v_ref,1E-2),fn_name & ": value lev" & i,3) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z",fn_name & ": shortName lev" & i,3) + end for + + # 4. levels 137->87 - descending order + levs = nil + startLev = 137 + endLev = 87 + nLev = startLev - endLev + 1 + for i=startLev to endLev by -1 do + levs = levs & [i] + end for + t_sub = read(data: t, levelist: levs) + q_sub = read(data: q, levelist: levs) + t_sub = sort(t_sub, "levelist", ">") + q_sub = sort(q_sub, "levelist", ">") + + r = mvl_geopotential_on_ml(t_sub, q_sub,lnsp,zs) + assert_equal(count(r),nLev, fn_name & ": count",4) + + for i=1 to nLev do + lev = endLev + i - 1 + assert_equal(grib_get_long(r[i],'level'), lev, fn_name & ": level lev" & i,4) + + v = values(r[i]) + v_ref = values(z_ref[lev]) + assert(vec_same(v,v_ref,1E-2),fn_name & ": value lev" & i,4) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z",fn_name & ": shortName lev" & i,4) + end for + + +end test_mvl_geopotential_on_ml + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function generate_geo_on_ml_input() + + # get analysis data + r = (date: 20190602, time: 12, levtype: "ml", grid: [5,5]) + t = retrieve(r,levelist: [1,"to",137],param: "t") + q = retrieve(r,levelist: [1,"to",137],param: "q") + zs = retrieve(r,levelist: 1,param: "z") + lnsp = retrieve(r,levelist: 1,param: "lnsp") + + #write("tq_ml137.grib",lnsp,zs,t,q) + +end generate_geo_on_ml_input + +function generate_geo_on_ml_reference() + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + q = read(data: fs, param: 'q') + zs = read(data: fs, param: 'z') + lnsp = read(data: fs, param: 'lnsp') + + r = mvl_geopotential_on_ml(t,q,lnsp,zs) + + #plot(r[137]-zs) + #write("z_ml137_ref.grib",r) + +end generate_geo_on_ml_reference \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/grib_vertical_integral.mv metview-5.19.2/metview/test/macros/grib_vertical_integral.mv --- metview-5.17.4/metview/test/macros/grib_vertical_integral.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_vertical_integral.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,203 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_univertint() +test_univertint_pl() +test_vertint() + +function test_univertint() + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + t = read(data: fs, param: 't') + f_ref = read("univertint_ml_ref.grib") + + # one fieldset - constant fields + r=univertint(lnsp & (t*0+1)) + assert_equal(count(r),1, "univertint count", 1) + + v = values(r) + v_ref = values(f_ref[1]) + assert(vec_same(v, v_ref,1E-4), "univertint values",1) + assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",1) + + # one fieldset + r=univertint(fs) + assert_equal(count(r),1, "univertint count", 2) + v = values(r) + v_ref = values(f_ref[2]) + assert(vec_same(v, v_ref,1E-4), "univertint values",2) + assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",2) + + # two args: lnsp, fieldset + r=univertint(lnsp,t) + assert_equal(count(r),1, "unvertint count", 3) + v = values(r) + v_ref = values(f_ref[3]) + assert(vec_same(v, v_ref,1E-4), "univertint values",3) + assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",3) + + # use custom lnsp paramId + lnspId = 152 + lnsp_152 = grib_set_long(lnsp, ['paramId',lnspId]) + + # one fieldset + custom lnsp paramId + r = univertint(lnsp_152 & t, lnspId) + assert_equal(count(r),1, "univertint count", 4) + v = values(r) + v_ref = values(f_ref[4]) + assert(vec_same(v, v_ref,1E-4), "univertint values",4) + assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",4) + + # two args: lnsp, fieldset + custom lnsp paramId + r = univertint(lnsp_152, t, lnspId) + assert_equal(count(r),1, "univertint count", 5) + v = values(r) + v_ref = values(f_ref[5]) + assert(vec_same(v, v_ref,1E-4), "univertint values",5) + assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",5) + + # two args: lnsp, fieldset + level range + r = univertint(lnsp, t*0+1, [96,137]) + assert_equal(count(r),1, "univertint count", 6) + v = values(r) + v_ref = values(f_ref[6]) + assert(vec_same(v, v_ref,1E-4), "univertint values",6) + assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",6) + +end test_univertint + +function test_univertint_pl() + fs = read('tuv_pl.grib') + t = read(data: fs, param: 't') + + fs_ref = read("univertint_pl_ref.grib") + + g = 9.80665 + dp = |75, 150, 175, 150, 100, 50| + dp = 100.*dp/g + + r_out = nil + + # unsorted input fieldset + us_idx = [2, 3, 1, 6, 5, 4] + t_us = nil + loop i in us_idx + t_us = t_us & t[i] + end loop + + # one fieldset - constant fields + r=univertint(t*0+1) + assert_equal(count(r),1, "univertint_pl count", 1) + v = values(r) + v_ref = values(fs_ref[1]) + assert(vec_same(v, v_ref,1E-2), "univertint_pl",1) + + # one fieldset - constant fields , unsorted pl levels + r=univertint(t_us*0+1) + assert_equal(count(r),1, "univertint_pl count", 2) + v = values(r) + v_ref = values(fs_ref[2]) + assert(vec_same(v, v_ref,1E-2), "univertint_pl",2) + + # one fieldset + r=univertint(t) + assert_equal(count(r),1, "univertint_pl count", 3) + v = values(r) + v_ref = values(fs_ref[3]) + + #v_ref = v*0 + #for i=1 to count(t) do + # v_ref = v_ref + values(t[i]) * dp[i] + #end for + assert(vec_same(v, v_ref,1E-4), "univertint_pl",3) + + # one fieldset unsorted level + r=univertint(t_us) + assert_equal(count(r),1, "univertint_pl count", 4) + v = values(r) + v_ref = values(fs_ref[4]) + assert(vec_same(v, v_ref, 1E-4), "univertint_pl",4) + + # one fieldset - extra 100Pa level + t_80 = read("t_80Pa.grib") + dp = |75, 150, 175, 150, 100, 199.6, 149.6| + dp = 100.*dp/g + t1 = read(data:t, area: [-20, -30, 20, 30]) & t_80 + r=univertint(t1) + assert_equal(count(r),1, "univertint_pl count", 5) + v = values(r) + #v_ref = v*0 + #for i=1 to count(t1) do + # v_ref = v_ref + values(t1[i]) * dp[i] + # end for + v_ref = values(fs_ref[5]) + assert(vec_same(v, v_ref,1E-4), "univertint_pl",5) + + +end test_univertint_pl + +function test_vertint() + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + t = read(data: fs, param: 't') + f_ref = read("vertint_ref.grib") + + r=vertint(lnsp & (t*0+1)) + assert_equal(count(r),1, "vertint count", 1) + v = values(r) + v_ref = values(f_ref[1]) + assert(vec_same(v, v_ref,1E-2), "vertint",1) + + r=vertint(fs) + assert_equal(count(r),1, "vertint count", 2) + v = values(r) + v_ref = values(f_ref[2]) + assert(vec_same(v, v_ref,1E-2), "vertint",2) + + r=vertint(lnsp,t) + assert_equal(count(r),1, "vertint count", 3) + v = values(r) + v_ref = values(f_ref[2]) + assert(vec_same(v, v_ref,1E-2), "vertint",3) + +end test_vertint + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function generate_test_vertint_reference() + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + t = read(data: fs, param: 't') + g = 9.80665 + + f = lnsp & (t*0+1) + r1=vertint(f) + # r1*g is a good approximation of surface pressure + #plot(r1-exp(lnsp)/g) + + f = fs + r2=vertint(f) + + r3=univertint(lnsp,t*0+1,[96,137]) + # r2*g is a good approximation of 500hpa pressure + #plot(r3*g) + #write("vertint_ref.grib",r1 & r2 & r3) + +end generate_test_vertint_reference \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/grib_vertical_interpolate_to_hl_1.mv metview-5.19.2/metview/test/macros/grib_vertical_interpolate_to_hl_1.mv --- metview-5.17.4/metview/test/macros/grib_vertical_interpolate_to_hl_1.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_vertical_interpolate_to_hl_1.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,413 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_ml_to_hl_linear() +test_ml_to_hl_log() + +function test_ml_to_hl_linear() + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + zs = read(data: fs, param: 'zs') + lnsp = read(data: fs, param: 'lnsp') + z = read("z_ml137_ref.grib") + + method = "linear" + hLst = [1000, 500, 2500, 10000] + gEarth = 9.80665 + + # 1. interpolate height field above sea to height levels above sea + r = ml_to_hl(z/gEarth, z, nil, hLst, "sea", method) + assert_equal(count(r),count(hLst),"ml_to_hl count",1) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the height field + v_ref = v*0 + hLst[i] + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_linear value lev" & i,1) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,1) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,1) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,1) + end for + + # 2. interpolate height field above ground to heigh tevels above ground + h_agr = nil + for i=1 to count(z) do + h_agr = h_agr & (z[i] - zs[1])/gEarth + end for + + r = ml_to_hl(h_agr, z, zs, hLst, "ground", method) + assert_equal(count(r),count(hLst),"ml_to_hl_linear count",2) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = v*0 + hLst[i] + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_linear value lev" & i,2) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,2) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveGround","ml_to_hl_linear typeOfLevel lev" & i,2) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,2) + + end for + + # 3. interpolate pressure to height levels above sea + f_ref =read("ml_to_hl_asl_ref.grib") + + pres = unipressure(lnsp) + r = ml_to_hl(pres, z, nil, hLst, "sea", method) + assert_equal(count(r),count(hLst),"ml_to_hl_linear count",3) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = values(f_ref[i]) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_linear value lev" & i,3) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,3) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,3) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"pres","ml_to_hl_linear shortName lev" & i,3) + + end for + + + # 4. interpolate pressure to height levels above ground + f_ref =read("ml_to_hl_agr_ref.grib") + + pres = unipressure(lnsp) + r = ml_to_hl(pres, z, zs, hLst, "ground", method) + assert_equal(count(r),count(hLst),"ml_to_hl_linear count",4) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = values(f_ref[i]) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_linear value lev" & i,4) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,4) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveGround","ml_to_hl_linear typeOfLevel lev" & i,4) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"pres","ml_to_hl_linear shortName lev" & i,4) + + end for + + # 5. interpolate height field above sea to height levels above sea + # - the input field and the input z field contain the fields in a different + # order + h_fs = sort(z,"levelist", ">") + z_fs = sort(z,"levelist", "<") + #print(grib_get(h_fs,["level"])) + #print(grib_get(z_fs,["level"])) + r = ml_to_hl(h_fs/gEarth, z_fs, nil, hLst, "sea", method) + assert_equal(count(r),count(hLst),"ml_to_hl_linear count",5) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the height field + v_ref = v*0 + hLst[i] + assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,5) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,5) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,5) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,5) + end for + + # 6. interpolate height field above sea to height levels above sea + # - the input field and the input z field contain the fields in a different + # order + h_fs = sort(z,"levelist", "<") + z_fs = sort(z,"levelist", ">") + #print(grib_get(h_fs,["level"])) + #print(grib_get(z_fs,["level"])) + r = ml_to_hl(h_fs/gEarth, z_fs, nil, hLst, "sea", method) + assert_equal(count(r),count(hLst),"ml_to_hl_linear count",6) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the height field + v_ref = v*0 + hLst[i] + assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,6) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,6) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,6) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,6) + end for + + # 7. interpolate ws to height levels above ground + # here we test the shortName in the result because if typeOfLevel is "heightAboveGround" + # and we set certain levels for certain parameters ecCodes silently changes the shortName!!!! + # E.g. if we set the level as 10m for param "ws" it becomes "10si"!!! + # ml_to_hl() should take care of it!!!! + + hLst = [10, 100, 200, 1000] + + h_agr = nil + for i=1 to count(z) do + h_agr = h_agr & (z[i] - zs[1])/gEarth + end for + + ws = grib_set_long(h_agr, ["paramId", 10]) + + #print(grib_get_long(ws[1], "paramId")) + #print(grib_get_string(ws[1], "mars.param")) + + r = ml_to_hl(ws, z, zs, hLst, "ground", method) + assert_equal(count(r),count(hLst),"ml_to_hl_linear count",7) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = v*0 + hLst[i] + assert(vec_same(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,7) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,7) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveGround","ml_to_hl_linear typeOfLevel lev" & i,7) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"ws","ml_to_hl_linear shortName lev" & i,7) + end for + + # 8. interpolate height field above sea to height levels above sea. Some target + # levels are out of range + hLst = [150000, 10000] + r = ml_to_hl(z/gEarth, z, nil, hLst, "sea", method) + assert_equal(count(r),count(hLst),"ml_to_hl count",8) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the height field + v_ref = v*0 + hLst[i] + assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,8) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,8) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,8) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,8) + end for + + # 9. interpolate height field above sea to height levels above sea. + # The input data only contains model levels from 137 to 70. + hLst = [11585, 15000] # 15000 is out of range! + + lev = nil + for i=137 to 70 by -1 do + lev = lev & [i] + end for + z = read(data:z, levelist: lev) + + r = ml_to_hl(z/gEarth, z, nil, hLst, "sea", method) + assert_equal(count(r),count(hLst),"ml_to_hl count",9) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the height field + v_ref = v*0 + hLst[i] + assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,9) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,9) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,9) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,9) + end for + +end test_ml_to_hl_linear + + +function test_ml_to_hl_log() + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + zs = read(data: fs, param: 'zs') + lnsp = read(data: fs, param: 'lnsp') + z = read("z_ml137_ref.grib") + + method = "log" + hLst = [1000, 500, 2500, 10000] + gEarth = 9.80665 + + # 1. interpolate log height field above sea to height levels above sea + f_ref = read("ml_to_hl_log_asl_ref.grib") + + r = ml_to_hl(1000*log(z/gEarth+1000), z, nil, hLst, "sea", method) + assert_equal(count(r),count(hLst),"ml_to_hl_log count",1) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the log height field + v_ref = values(f_ref[i]) + + #print(maxvalue(abs(v - v_ref))) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_log value lev" & i,1) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_log level lev" & i,1) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveSea","ml_to_hl_log typeOfLevel lev" & i,1) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z","ml_to_hl_log shortName lev" & i,1) + end for + + # 2. interpolate log height field above ground to height levels above ground + f_ref = read("ml_to_hl_log_agr_ref.grib") + + h_agr = nil + for i=1 to count(z) do + h_agr = h_agr & 1000*log((z[i] - zs[1])/gEarth+ 1000) + end for + + r = ml_to_hl(h_agr, z, zs, hLst, "ground", method) + assert_equal(count(r),count(hLst),"ml_to_hl_log count",2) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = values(f_ref[i]) + #print(maxvalue(abs(v - v_ref))) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_log value lev" & i,2) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],"ml_to_hl_log level lev" & i,2) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveGround","ml_to_hl_log typeOfLevel lev" & i,2) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z","ml_to_hl_log shortName lev" & i,2) + end for + +end test_ml_to_hl_log + +function diag_ml_to_hl_compare_log_to_linear() + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + zs = read(data: fs, param: 'zs') + lnsp = read(data: fs, param: 'lnsp') + z = read("z_ml137_ref.grib") + + hLst = [1000, 500, 2500, 10000] + + print('ml_to_hl_compare_log_to_linear -->') + + # field changing by log height + r = ml_to_hl(1000*log(z/9.81+1000), z, nil, hLst, "sea", "log") + r1 = ml_to_hl(1000*log(z/9.81+1000), z, nil, hLst, "sea", "linear") + v = interpolate(r, [50,20]) + v1 = interpolate(r1, [50,20]) + print('field changing by log height') + print('log',v) + print('lin',v1) + ref = 1000*log(vector(hLst) + 1000) + print('ref',ref) + print('err_log', abs(vector(v)-ref)) + print('err_lin', abs(vector(v1)-ref)) + + # field changing by height + r = ml_to_hl(z/9.81, z, nil, hLst, "sea", "log") + r1 = ml_to_hl(z/9.81, z, nil, hLst, "sea", "linear") + v = interpolate(r, [50,20]) + v1 = interpolate(r1, [50,20]) + print(' ') + print('field changing by height') + print('log',v) + print('lin',v1) + ref = vector(hLst) + print('ref',ref) + print('err_log', abs(vector(v)-ref)) + print('err_lin', abs(vector(v1)-ref)) + +end diag_ml_to_hl_compare_log_to_linear + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function generate_ml_to_h_reference() + + hLst = [1000, 500, 2500, 10000] + fs = read('tq_ml137.grib') + lnsp = read(data: fs, param: 'lnsp') + zs = read(data: fs, param: 'z') + z = read("z_ml137_ref.grib") + + # asl + pres = unipressure(lnsp) + r1 = ml_to_hl(pres, z, nil, hLst, "sea", "linear") + + # visually checked!!! + #plot(r1) + #write("ml_to_hl_asl_ref.grib", r1) + + # agr + pres = unipressure(lnsp) + r2 = ml_to_hl(pres, z, zs, hLst, "ground", "linear") + + # visually checked!!! + #plot(r1-r2) + #write("ml_to_hl_agr_ref.grib", r2) + +end generate_ml_to_h_reference() \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/grib_vertical_interpolate_to_hl_2.mv metview-5.19.2/metview/test/macros/grib_vertical_interpolate_to_hl_2.mv --- metview-5.17.4/metview/test/macros/grib_vertical_interpolate_to_hl_2.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_vertical_interpolate_to_hl_2.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,339 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_ml_to_hl_field() +test_ml_to_hl_surface() + +function test_ml_to_hl_field() + + # The target height now is defined by a field! + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + zs = read(data: fs, param: 'zs') + lnsp = read(data: fs, param: 'lnsp') + z = read("z_ml137_ref.grib") + + z_bottom = read(data: z, levelist: 137) + + method = "linear" + hLst = [1000, 500, 2500, 10000] + gEarth = 9.80665 + + # Construct a height field with contant values + h_fs = nil + for i=1 to count(hLst) do + h_fs = h_fs & (z[1]*0 + hLst[i]) + end for + + # 1. interpolate height field above sea to height levels above sea + #f_ref = read("ml_to_hl_field_asl_ref.grib") + + r = ml_to_hl(z/gEarth, z, nil, h_fs, "sea", method) + assert_equal(count(r),count(h_fs),"ml_to_hl_field count",1) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the height field + v_ref = values(bitmap(h_fs[i], bitmap(z_bottom > h_fs[i]*gEarth, 1))) + + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,1) + end for + + + # 2. interpolate height field above ground to height levels above ground + h_agr = nil + for i=1 to count(z) do + h_agr = h_agr & (z[i] - zs[1])/gEarth + end for + + r = ml_to_hl(h_agr, z, zs, h_fs, "ground", method) + assert_equal(count(r),count(h_fs),"ml_to_hl_field count",2) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = values(h_fs[i]) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,2) + + end for + + # 3. interpolate pressure to height levels above sea + f_ref =read("ml_to_hl_asl_ref.grib") + + pres = unipressure(lnsp) + r = ml_to_hl(pres, z, nil, h_fs, "sea", method) + assert_equal(count(r),count(h_fs),"ml_to_hl_field count",3) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = values(f_ref[i]) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,3) + end for + + + # 4. interpolate pressure to height levels above ground + f_ref =read("ml_to_hl_agr_ref.grib") + + pres = unipressure(lnsp) + r = ml_to_hl(pres, z, zs, h_fs, "ground", method) + assert_equal(count(r),count(h_fs),"ml_to_hl_field count",4) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = values(f_ref[i]) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,4) + end for + + # 5. interpolate height above sea to non constant height + # fields above sea + h_fs_noconst = nil + # the target height field = surface orography + a constant value + delta_h_lst = [1200, 5000, 10000] + for i=1 to count(delta_h_lst) do + h_fs_noconst = h_fs_noconst & (zs/gEarth + delta_h_lst[i]) + end for + + # the results should be very close to the target heights themselves + r = ml_to_hl(z/gEarth, z, nil, h_fs_noconst, "sea", method) + assert_equal(count(r),count(h_fs_noconst),"ml_to_hl_field count",5) + + for i=1 to count(r) do + v = values(r[i]) + v_ref = values(h_fs_noconst[i]) +# plot(r[i]-h_fs_noconst[i]) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,5) + end for + + # 6. interpolate height above sea to non constant height + # fields above ground + + # the results should be very close to the target heights + zs/9.81 + r = ml_to_hl(z/gEarth, z, zs, h_fs_noconst, "ground", method) + assert_equal(count(r),count(h_fs_noconst),"ml_to_hl_field count",6) + + for i=1 to count(r) do + v = values(r[i]) + # we should get back the target height field + surf orography + v_ref = values(h_fs_noconst[i] + zs/gEarth) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,6) + end for + + # 7. interpolate height above sea to non constant height + # fields above sea + # - the input field and the input z field contain the fields in a different + # order + z_fs_input = sort(z,"levelist", ">") + z_fs = sort(z,"levelist", "<") + #print(grib_get(h_fs,["level"])) + #print(grib_get(z_fs,["level"])) + r = ml_to_hl(z_fs_input/gEarth, z_fs, nil, h_fs_noconst, "sea", method) + assert_equal(count(r),count(h_fs_noconst),"ml_to_hl_field count",7) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the target height field + v_ref = values(h_fs_noconst[i]) + assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,7) + end for + + # 8. interpolate height above sea to non constant height + # fields above ground + # - the input field and the input z field contain the fields in a different + # order + r = ml_to_hl(z_fs_input/gEarth, z_fs, zs, h_fs_noconst, "ground", method) + assert_equal(count(r),count(h_fs_noconst),"ml_to_hl_field count",8) + + for i=1 to count(r) do + v = values(r[i]) + + # we should get back the target height field + surf orography + v_ref = values(h_fs_noconst[i] + zs/gEarth) + assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_field value lev" & i,8) + end for + +end test_ml_to_hl_field + +function test_ml_to_hl_surface() + + fn_name = "ml_to_hl_surface" + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + zs = read(data: fs, param: 'zs') + lnsp = read(data: fs, param: 'lnsp') + z = read("z_ml137_ref.grib") + + hLst = [1, 5, 120, 10] + gEarth = 9.80665 + + # 1. interpolate height field above ground to height levels above ground + h_agr = nil + for i=1 to count(z) do + h_agr = h_agr & (z[i] - zs[1])/gEarth + end for + + r = ml_to_hl(h_agr, z, zs, hLst, "ground", "linear", 0) + assert_equal(count(r),count(hLst),fn_name & " count",1) + + for i=1 to count(r) do + v = values(r[i]) + + v_ref = v*0 + hLst[i] + assert(vec_same_missing(v,v_ref,1E-2),fn_name & " value lev" & i,1) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],fn_name & " level lev" & i,1) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveGround",fn_name & " typeOfLevel lev" & i,1) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z",fn_name & " shortName lev" & i,1) + end for + + # 2. interpolate height field above ground to height levels above ground + f_ref =read("ml_to_hl_agr_log_surf_ref.grib") + + hLst = [1, 5, 120, 212, 10] + r = ml_to_hl(h_agr, z, zs, hLst, "ground", "log", 0) + assert_equal(count(r),count(hLst),fn_name & " count",2) + + for i=1 to count(r) do + v = values(r[i]) + v_ref = values(f_ref[i]) + + #print(maxvalue(v)) + #print(maxvalue(abs(v - v_ref))) + #print(v[1,10]) + #print(v_ref[1,10]) + assert(vec_same_missing(v,v_ref,1E-3),fn_name & " value lev" & i,2) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],fn_name & " level lev" & i,2) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveGround",fn_name & " typeOfLevel lev" & i,2) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"z",fn_name & " shortName lev" & i,2) + end for + + # 3. interpolate pressure to height levels above ground + f_ref =read("ml_to_hl_agr_surf_ref.grib") + + hLst = [1, 5, 120, 10] + pres = unipressure(lnsp) + r = ml_to_hl(pres, z, zs, hLst, "ground", "linear", exp(lnsp)) + assert_equal(count(r),count(hLst), fn_name & " count",3) + + for i=1 to count(r) do + v = values(r[i]) + v_ref = values(f_ref[i]) + + assert(vec_same_missing(v,v_ref,1E-3),fn_name & " value lev" & i,3) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,hLst[i],fn_name & " level lev" & i,3) + + r_level=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level,"heightAboveGround",fn_name & " typeOfLevel lev" & i,3) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"pres",fn_name & " shortName lev" & i,3) + + end for + + +end test_ml_to_hl_surface + + +function diag_ml_to_hl_compare_log_to_linear() + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + zs = read(data: fs, param: 'zs') + lnsp = read(data: fs, param: 'lnsp') + z = read("z_ml137_ref.grib") + + hLst = [1000, 500, 2500, 10000] + + print('ml_to_hl_compare_log_to_linear -->') + + # field changing by log height + r = ml_to_hl(1000*log(z/9.81+1000), z, nil, hLst, "sea", "log") + r1 = ml_to_hl(1000*log(z/9.81+1000), z, nil, hLst, "sea", "linear") + v = interpolate(r, [50,20]) + v1 = interpolate(r1, [50,20]) + print('field changing by log height') + print('log',v) + print('lin',v1) + ref = 1000*log(vector(hLst) + 1000) + print('ref',ref) + print('err_log', abs(vector(v)-ref)) + print('err_lin', abs(vector(v1)-ref)) + + # field changing by height + r = ml_to_hl(z/9.81, z, nil, hLst, "sea", "log") + r1 = ml_to_hl(z/9.81, z, nil, hLst, "sea", "linear") + v = interpolate(r, [50,20]) + v1 = interpolate(r1, [50,20]) + print(' ') + print('field changing by height') + print('log',v) + print('lin',v1) + ref = vector(hLst) + print('ref',ref) + print('err_log', abs(vector(v)-ref)) + print('err_lin', abs(vector(v1)-ref)) + +end diag_ml_to_hl_compare_log_to_linear + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function generate_ml_to_h_reference() + + hLst = [1000, 500, 2500, 10000] + fs = read('tq_ml137.grib') + lnsp = read(data: fs, param: 'lnsp') + zs = read(data: fs, param: 'z') + z = read("z_ml137_ref.grib") + + # asl + pres = unipressure(lnsp) + r1 = ml_to_hl(pres, z, nil, hLst, "sea", "linear") + + # visually checked!!! + #plot(r1) + #write("ml_to_hl_asl_ref.grib", r1) + + # agr + pres = unipressure(lnsp) + r2 = ml_to_hl(pres, z, zs, hLst, "ground", "linear") + + # visually checked!!! + #plot(r1-r2) + #write("ml_to_hl_agr_ref.grib", r2) + +end generate_ml_to_h_reference() \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/grib_vertical_interpolate_to_pl.mv metview-5.19.2/metview/test/macros/grib_vertical_interpolate_to_pl.mv --- metview-5.17.4/metview/test/macros/grib_vertical_interpolate_to_pl.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_vertical_interpolate_to_pl.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,306 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_mvl_ml2hPa() +test_pl_to_pl() + +function test_mvl_ml2hPa() + + fn_name ="mvl_ml2hPa" + + fs = read('tq_ml137.grib') + t = read(data: fs, param: 't') + lnsp = read(data: fs, param: 'lnsp') + + # ---------------------------------------------- + # 1. no missing values in input, vector target + # ---------------------------------------------- + + # this is not the same order as in t_ref! + pLst = |100,500,925,850,1000| + t_ref = read("ml2pl_ref.grib") + + r = mvl_ml2hPa(lnsp,t,pLst) + assert_equal(count(r),count(pLst),fn_name & ": count",1) + + for i=1 to count(r) do + v = values(r[i]) + t_ref_i = read(data: t_ref, level: pLst[i]) + v_ref = values(t_ref_i) + + assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], 1) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,1) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"t",fn_name & ": shortName lev" & i,1) + end for + + # ----------------------------------------- + # 2. missing values in input, list target + # ----------------------------------------- + + v = values(lnsp) + v[243] = vector_missing_value + lnsp_m = set_values(lnsp, v) + + # this is not the same order as in t_ref! + pLst = [100,500,925,850,1000] + t_ref = read("ml2pl_ref.grib") + + r = mvl_ml2hPa(lnsp_m,t,pLst) + assert_equal(count(r),count(pLst),fn_name & ": count",2) + + for i=1 to count(r) do + v = values(r[i]) + t_ref_i = read(data: t_ref, level: pLst[i]) + v_ref = values(t_ref_i) + v_ref[243] = vector_missing_value + + assert(vec_same_missing(v,v_ref,1E-3), + fn_name & ": value lev=" & pLst[i], 2) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,2) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"t",fn_name & ": shortName lev" & i,2) + end for + + # ---------------------------------------------- + # 3. target levels out of pressure value range + # ---------------------------------------------- + + pLst = [0.00001, 2000] + t_ref = read("ml2pl_ref.grib") + + r = mvl_ml2hPa(lnsp,t,pLst) + assert_equal(count(r),count(pLst),fn_name & ": count",3) + + for i=1 to count(r) do + v = values(r[i]) + v_ref = v * 0 + vector_missing_value + + assert(vec_same_missing(v,v_ref,1E-3), + fn_name & ": value lev=" & pLst[i], 3) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,3) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"t",fn_name & ": shortName lev" & i,3) + end for + + # ---------------------------------------------- + # 4. target levels below 1 hpa + # ---------------------------------------------- + + pLst = [0.01, 0.5, 10] + + r = mvl_ml2hPa(lnsp,t,pLst) + assert_equal(count(r),count(pLst),fn_name & ": count",4) + + pRef = [1, 50, 10] + pTypeRef = ["isobaricInPa","isobaricInPa","isobaricInhPa"] + for i=1 to count(r) do + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,pRef[i],fn_name & ": level lev" & i,4) + + r_level_type=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_level_type,pTypeRef[i],fn_name & ": level type" & i,4) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"t",fn_name & ": shortName lev" & i,4) + end for +end test_mvl_ml2hPa + + +function test_pl_to_pl() + + fn_name ="pl_to_pl" + + fs = read('xs_pl_input.grib') + t = read(data: fs, param: 't', step: 12) + # input levels: 1000, 850, 700, 500, 400, 300 + + pLst = |500,925,1000,300,200| + + # ------------ + # 1-3. linear + # ------------ + + t_ref = read("pl_to_pl_ref.grib") + + # original order (desending) + r1 = pl_to_pl(t, pLst) + + # ascending order + t_asc = sort(t, "levelist", "<") + r2 = pl_to_pl(t_asc, pLst) + + # explicit method + r3 = pl_to_pl(t, pLst, "linear") + + rLst = [r1, r2, r3] + for k=1 to count(rLst) do + r = rLst[k] + + assert_equal(count(r),count(pLst),fn_name & ": count",k) + + for i=1 to count(r) do + v = values(r[i]) + t_ref_i = read(data: t_ref, level: pLst[i]) + v_ref = values(t_ref_i) + + assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], k) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,k) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"t",fn_name & ": shortName lev" & i,k) + end for + end for + + # ------------ + # 4. log + # ------------ + + t_ref = read("pl_to_pl_log_ref.grib") + + r = pl_to_pl(t, pLst, "log") + + assert_equal(count(r),count(pLst),fn_name & ": count",4) + + for i=1 to count(r) do + v = values(r[i]) + t_ref_i = read(data: t_ref, level: pLst[i]) + v_ref = values(t_ref_i) + + assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], 4) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,4) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"t",fn_name & ": shortName lev" & i,4) + end for + + #------------------------------------------------------ + # 5. Using Pa levels in input + # - same target levels as in input + #------------------------------------------------------ + + fs = read("pl_pa_hpa.grib") + + # constant fields containing the pressure in Pa on each level + # =[500, 100, 50, 10, 5, 1] + + refVals = [500, 100, 50, 10, 5, 1] + refLev = [5, 1, 50, 10, 5, 1] + refLevType = ["isobaricInhPa", "isobaricInhPa", "isobaricInPa", + "isobaricInPa","isobaricInPa","isobaricInPa"] + + # target pressure in hPa + pLst = |5, 1, 0.5, 0.1, 0.05, 0.01| + + r = pl_to_pl(fs, pLst) + assert_equal(count(r),count(pLst),fn_name & ": count",5) + + for i=1 to count(r) do + v = values(r[i]) + v_ref = v*0 + refVals[i] + + assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], 5) + + r_levType=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_levType,refLevType[i],fn_name & ": levType lev" & i,5) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,refLev[i],fn_name & ": level lev" & i,5) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"t",fn_name & ": shortName lev" & i,5) + end for + + #------------------------------------------------------ + # 6. Using Pa levels in input + # - different target levels as in input + #------------------------------------------------------ + + fs = read("pl_pa_hpa.grib") + + # constant fields containing the pressure in Pa on each level + # =[500, 100, 50, 10, 5, 1] + + refVals = [400, 200, 75, 33, 9, 3] + refLev = [4, 2, 75, 33, 9, 3] + refLevType = ["isobaricInhPa", "isobaricInhPa", "isobaricInPa", + "isobaricInPa","isobaricInPa","isobaricInPa"] + + # target pressure in hPa + pLst = |4, 2, 0.75, 0.33, 0.09, 0.03| + + r = pl_to_pl(fs, pLst) + assert_equal(count(r),count(pLst),fn_name & ": count",6) + + for i=1 to count(r) do + v = values(r[i]) + v_ref = v*0 + refVals[i] + + assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], 6) + + r_levType=grib_get_string(r[i],"typeOfLevel") + assert_equal(r_levType,refLevType[i],fn_name & ": levType lev" & i,6) + + r_level=grib_get_long(r[i],"level") + assert_equal(r_level,refLev[i],fn_name & ": level lev" & i,6) + + r_name=grib_get_string(r[i],"shortName") + assert_equal(r_name,"t",fn_name & ": shortName lev" & i,6) + end for + +end test_pl_to_pl + + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function generate_ml2pl_reference() + + # get analysis data + # the same date has to be used as in generate_geo_on_ml_input() + + r = (date: 20190602, time: 12, levtype: "pl", grid: [5,5]) + t_ref = retrieve(r,levelist: [100,925,500,1000,850], param: "t") + + fs = read('tq_ml137.grib') + t_in = read(data: fs, param: 't') + lnsp_in = read(data: fs, param: 'lnsp') + + pLst = [100,925,500,1000,850] + r = mvl_ml2hPa(lnsp_in,t_in,pLst) + + # visually checked!!! + #plot(abs(r-t_ref)) + + #write("ml2pl_ref.grib",r) + +end generate_ml2pl_reference diff -Nru metview-5.17.4/metview/test/macros/grib_vertical.mv metview-5.19.2/metview/test/macros/grib_vertical.mv --- metview-5.17.4/metview/test/macros/grib_vertical.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_vertical.mv 1970-01-01 00:00:00.000000000 +0000 @@ -1,1735 +0,0 @@ -#Metview Macro - -# **************************** LICENSE START *********************************** -# -# Copyright 2019 ECMWF. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ - -include "test_utils.mv" - -global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() -global VECTOR_DIFF_THRESHOLD = 0.0000001 - -test_mvl_geopotential_on_ml() -test_mvl_ml2hPa() -test_pl_to_pl() -test_ml_to_hl_linear() -test_ml_to_hl_log() -test_ml_to_hl_field() -test_ml_to_hl_surface() -test_pressure() -test_pressure_derivative() -test_thickness() -test_unipressure() -test_unithickness() -test_univertint() -test_univertint_pl() -test_vertint() -test_w_from_omega() - -# diagnostics -#diag_ml_to_hl_compare_log_to_linear() - -function test_mvl_geopotential_on_ml() - - fn_name = "mvl_geopotential_on_ml" - - fs = read('tq_ml137.grib') - t = read(data: fs, param: 't') - q = read(data: fs, param: 'q') - zs = read(data: fs, param: 'z') - lnsp = read(data: fs, param: 'lnsp') - - # the ref contains the levels in ascending order! - z_ref = read("z_ml137_ref.grib") - nLev = 137 - - # 1. all levels - ascending order - r = mvl_geopotential_on_ml(t,q,lnsp,zs) - assert_equal(count(r),nLev, fn_name & ": count",1) - - for i=1 to nLev do - assert_equal(grib_get_long(r[i],'level'), i, fn_name & ": level lev" & i,1) - v = values(r[i]) - v_ref = values(z_ref[i]) - assert(vec_same(v,v_ref,1E-2),fn_name & ": value lev" & i,1) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z",fn_name & ": shortName lev" & i,1) - end for - - # 2. all levels - descending order - t_desc = sort(t, "levelist", ">") - q_desc = sort(q, "levelist", ">") - - r = mvl_geopotential_on_ml(t_desc, q_desc,lnsp,zs) - assert_equal(count(r),nLev, fn_name & ": count",2) - - for i=1 to nLev do - assert_equal(grib_get_long(r[i],'level'), i, fn_name & ": level lev" & i,2) - v = values(r[i]) - v_ref = values(z_ref[i]) - assert(vec_same(v,v_ref,1E-2),fn_name & ": value lev" & i,2) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z",fn_name & ": shortName lev" & i,2) - end for - - # 3. levels 137->38 - ascending order - levs = nil - startLev = 38 - endLev = 137 - nLev = endLev - startLev + 1 - for i=startLev to endLev do - levs = levs & [i] - end for - t_sub = read(data: t, levelist: levs) - q_sub = read(data: q, levelist: levs) - - r = mvl_geopotential_on_ml(t_sub, q_sub,lnsp,zs) - assert_equal(count(r),nLev, fn_name & ": count",3) - - for i=1 to nLev do - lev = startLev + i - 1 - assert_equal(grib_get_long(r[i],'level'), lev, fn_name & ": level lev" & i,3) - - v = values(r[i]) - v_ref = values(z_ref[lev]) - assert(vec_same(v,v_ref,1E-2),fn_name & ": value lev" & i,3) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z",fn_name & ": shortName lev" & i,3) - end for - - # 4. levels 137->87 - descending order - levs = nil - startLev = 137 - endLev = 87 - nLev = startLev - endLev + 1 - for i=startLev to endLev by -1 do - levs = levs & [i] - end for - t_sub = read(data: t, levelist: levs) - q_sub = read(data: q, levelist: levs) - t_sub = sort(t_sub, "levelist", ">") - q_sub = sort(q_sub, "levelist", ">") - - r = mvl_geopotential_on_ml(t_sub, q_sub,lnsp,zs) - assert_equal(count(r),nLev, fn_name & ": count",4) - - for i=1 to nLev do - lev = endLev + i - 1 - assert_equal(grib_get_long(r[i],'level'), lev, fn_name & ": level lev" & i,4) - - v = values(r[i]) - v_ref = values(z_ref[lev]) - assert(vec_same(v,v_ref,1E-2),fn_name & ": value lev" & i,4) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z",fn_name & ": shortName lev" & i,4) - end for - - -end test_mvl_geopotential_on_ml - -function test_mvl_ml2hPa() - - fn_name ="mvl_ml2hPa" - - fs = read('tq_ml137.grib') - t = read(data: fs, param: 't') - lnsp = read(data: fs, param: 'lnsp') - - # ---------------------------------------------- - # 1. no missing values in input, vector target - # ---------------------------------------------- - - # this is not the same order as in t_ref! - pLst = |100,500,925,850,1000| - t_ref = read("ml2pl_ref.grib") - - r = mvl_ml2hPa(lnsp,t,pLst) - assert_equal(count(r),count(pLst),fn_name & ": count",1) - - for i=1 to count(r) do - v = values(r[i]) - t_ref_i = read(data: t_ref, level: pLst[i]) - v_ref = values(t_ref_i) - - assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], 1) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,1) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"t",fn_name & ": shortName lev" & i,1) - end for - - # ----------------------------------------- - # 2. missing values in input, list target - # ----------------------------------------- - - v = values(lnsp) - v[243] = vector_missing_value - lnsp_m = set_values(lnsp, v) - - # this is not the same order as in t_ref! - pLst = [100,500,925,850,1000] - t_ref = read("ml2pl_ref.grib") - - r = mvl_ml2hPa(lnsp_m,t,pLst) - assert_equal(count(r),count(pLst),fn_name & ": count",2) - - for i=1 to count(r) do - v = values(r[i]) - t_ref_i = read(data: t_ref, level: pLst[i]) - v_ref = values(t_ref_i) - v_ref[243] = vector_missing_value - - assert(vec_same_missing(v,v_ref,1E-3), - fn_name & ": value lev=" & pLst[i], 2) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,2) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"t",fn_name & ": shortName lev" & i,2) - end for - - # ---------------------------------------------- - # 3. target levels out of pressure value range - # ---------------------------------------------- - - pLst = [0.00001, 2000] - t_ref = read("ml2pl_ref.grib") - - r = mvl_ml2hPa(lnsp,t,pLst) - assert_equal(count(r),count(pLst),fn_name & ": count",3) - - for i=1 to count(r) do - v = values(r[i]) - v_ref = v * 0 + vector_missing_value - - assert(vec_same_missing(v,v_ref,1E-3), - fn_name & ": value lev=" & pLst[i], 3) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,3) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"t",fn_name & ": shortName lev" & i,3) - end for - - # ---------------------------------------------- - # 4. target levels below 1 hpa - # ---------------------------------------------- - - pLst = [0.01, 0.5, 10] - - r = mvl_ml2hPa(lnsp,t,pLst) - assert_equal(count(r),count(pLst),fn_name & ": count",4) - - pRef = [1, 50, 10] - pTypeRef = ["isobaricInPa","isobaricInPa","isobaricInhPa"] - for i=1 to count(r) do - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,pRef[i],fn_name & ": level lev" & i,4) - - r_level_type=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level_type,pTypeRef[i],fn_name & ": level type" & i,4) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"t",fn_name & ": shortName lev" & i,4) - end for -end test_mvl_ml2hPa - - -function test_pl_to_pl() - - fn_name ="pl_to_pl" - - fs = read('xs_pl_input.grib') - t = read(data: fs, param: 't', step: 12) - # input levels: 1000, 850, 700, 500, 400, 300 - - pLst = |500,925,1000,300,200| - - # ------------ - # 1-3. linear - # ------------ - - t_ref = read("pl_to_pl_ref.grib") - - # original order (desending) - r1 = pl_to_pl(t, pLst) - - # ascending order - t_asc = sort(t, "levelist", "<") - r2 = pl_to_pl(t_asc, pLst) - - # explicit method - r3 = pl_to_pl(t, pLst, "linear") - - rLst = [r1, r2, r3] - for k=1 to count(rLst) do - r = rLst[k] - - assert_equal(count(r),count(pLst),fn_name & ": count",k) - - for i=1 to count(r) do - v = values(r[i]) - t_ref_i = read(data: t_ref, level: pLst[i]) - v_ref = values(t_ref_i) - - assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], k) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,k) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"t",fn_name & ": shortName lev" & i,k) - end for - end for - - # ------------ - # 4. log - # ------------ - - t_ref = read("pl_to_pl_log_ref.grib") - - r = pl_to_pl(t, pLst, "log") - - assert_equal(count(r),count(pLst),fn_name & ": count",4) - - for i=1 to count(r) do - v = values(r[i]) - t_ref_i = read(data: t_ref, level: pLst[i]) - v_ref = values(t_ref_i) - - assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], 4) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,pLst[i],fn_name & ": level lev" & i,4) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"t",fn_name & ": shortName lev" & i,4) - end for - - #------------------------------------------------------ - # 5. Using Pa levels in input - # - same target levels as in input - #------------------------------------------------------ - - fs = read("pl_pa_hpa.grib") - - # constant fields containing the pressure in Pa on each level - # =[500, 100, 50, 10, 5, 1] - - refVals = [500, 100, 50, 10, 5, 1] - refLev = [5, 1, 50, 10, 5, 1] - refLevType = ["isobaricInhPa", "isobaricInhPa", "isobaricInPa", - "isobaricInPa","isobaricInPa","isobaricInPa"] - - # target pressure in hPa - pLst = |5, 1, 0.5, 0.1, 0.05, 0.01| - - r = pl_to_pl(fs, pLst) - assert_equal(count(r),count(pLst),fn_name & ": count",5) - - for i=1 to count(r) do - v = values(r[i]) - v_ref = v*0 + refVals[i] - - assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], 5) - - r_levType=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_levType,refLevType[i],fn_name & ": levType lev" & i,5) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,refLev[i],fn_name & ": level lev" & i,5) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"t",fn_name & ": shortName lev" & i,5) - end for - - #------------------------------------------------------ - # 6. Using Pa levels in input - # - different target levels as in input - #------------------------------------------------------ - - fs = read("pl_pa_hpa.grib") - - # constant fields containing the pressure in Pa on each level - # =[500, 100, 50, 10, 5, 1] - - refVals = [400, 200, 75, 33, 9, 3] - refLev = [4, 2, 75, 33, 9, 3] - refLevType = ["isobaricInhPa", "isobaricInhPa", "isobaricInPa", - "isobaricInPa","isobaricInPa","isobaricInPa"] - - # target pressure in hPa - pLst = |4, 2, 0.75, 0.33, 0.09, 0.03| - - r = pl_to_pl(fs, pLst) - assert_equal(count(r),count(pLst),fn_name & ": count",6) - - for i=1 to count(r) do - v = values(r[i]) - v_ref = v*0 + refVals[i] - - assert(vec_same_missing(v,v_ref,1E-3),fn_name & ": value lev=" & pLst[i], 6) - - r_levType=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_levType,refLevType[i],fn_name & ": levType lev" & i,6) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,refLev[i],fn_name & ": level lev" & i,6) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"t",fn_name & ": shortName lev" & i,6) - end for - -end test_pl_to_pl - -function test_ml_to_hl_linear() - - fs = read('tq_ml137.grib') - t = read(data: fs, param: 't') - zs = read(data: fs, param: 'zs') - lnsp = read(data: fs, param: 'lnsp') - z = read("z_ml137_ref.grib") - - method = "linear" - hLst = [1000, 500, 2500, 10000] - gEarth = 9.80665 - - # 1. interpolate height field above sea to height levels above sea - r = ml_to_hl(z/gEarth, z, nil, hLst, "sea", method) - assert_equal(count(r),count(hLst),"ml_to_hl count",1) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the height field - v_ref = v*0 + hLst[i] - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_linear value lev" & i,1) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,1) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,1) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,1) - end for - - # 2. interpolate height field above ground to heigh tevels above ground - h_agr = nil - for i=1 to count(z) do - h_agr = h_agr & (z[i] - zs[1])/gEarth - end for - - r = ml_to_hl(h_agr, z, zs, hLst, "ground", method) - assert_equal(count(r),count(hLst),"ml_to_hl_linear count",2) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = v*0 + hLst[i] - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_linear value lev" & i,2) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,2) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveGround","ml_to_hl_linear typeOfLevel lev" & i,2) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,2) - - end for - - # 3. interpolate pressure to height levels above sea - f_ref =read("ml_to_hl_asl_ref.grib") - - pres = unipressure(lnsp) - r = ml_to_hl(pres, z, nil, hLst, "sea", method) - assert_equal(count(r),count(hLst),"ml_to_hl_linear count",3) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = values(f_ref[i]) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_linear value lev" & i,3) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,3) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,3) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"pres","ml_to_hl_linear shortName lev" & i,3) - - end for - - - # 4. interpolate pressure to height levels above ground - f_ref =read("ml_to_hl_agr_ref.grib") - - pres = unipressure(lnsp) - r = ml_to_hl(pres, z, zs, hLst, "ground", method) - assert_equal(count(r),count(hLst),"ml_to_hl_linear count",4) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = values(f_ref[i]) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_linear value lev" & i,4) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,4) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveGround","ml_to_hl_linear typeOfLevel lev" & i,4) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"pres","ml_to_hl_linear shortName lev" & i,4) - - end for - - # 5. interpolate height field above sea to height levels above sea - # - the input field and the input z field contain the fields in a different - # order - h_fs = sort(z,"levelist", ">") - z_fs = sort(z,"levelist", "<") - #print(grib_get(h_fs,["level"])) - #print(grib_get(z_fs,["level"])) - r = ml_to_hl(h_fs/gEarth, z_fs, nil, hLst, "sea", method) - assert_equal(count(r),count(hLst),"ml_to_hl_linear count",5) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the height field - v_ref = v*0 + hLst[i] - assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,5) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,5) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,5) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,5) - end for - - # 6. interpolate height field above sea to height levels above sea - # - the input field and the input z field contain the fields in a different - # order - h_fs = sort(z,"levelist", "<") - z_fs = sort(z,"levelist", ">") - #print(grib_get(h_fs,["level"])) - #print(grib_get(z_fs,["level"])) - r = ml_to_hl(h_fs/gEarth, z_fs, nil, hLst, "sea", method) - assert_equal(count(r),count(hLst),"ml_to_hl_linear count",6) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the height field - v_ref = v*0 + hLst[i] - assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,6) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,6) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,6) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,6) - end for - - # 7. interpolate ws to height levels above ground - # here we test the shortName in the result because if typeOfLevel is "heightAboveGround" - # and we set certain levels for certain parameters ecCodes silently changes the shortName!!!! - # E.g. if we set the level as 10m for param "ws" it becomes "10si"!!! - # ml_to_hl() should take care of it!!!! - - hLst = [10, 100, 200, 1000] - - h_agr = nil - for i=1 to count(z) do - h_agr = h_agr & (z[i] - zs[1])/gEarth - end for - - ws = grib_set_long(h_agr, ["paramId", 10]) - - #print(grib_get_long(ws[1], "paramId")) - #print(grib_get_string(ws[1], "mars.param")) - - r = ml_to_hl(ws, z, zs, hLst, "ground", method) - assert_equal(count(r),count(hLst),"ml_to_hl_linear count",7) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = v*0 + hLst[i] - assert(vec_same(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,7) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,7) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveGround","ml_to_hl_linear typeOfLevel lev" & i,7) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"ws","ml_to_hl_linear shortName lev" & i,7) - end for - - # 8. interpolate height field above sea to height levels above sea. Some target - # levels are out of range - hLst = [150000, 10000] - r = ml_to_hl(z/gEarth, z, nil, hLst, "sea", method) - assert_equal(count(r),count(hLst),"ml_to_hl count",8) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the height field - v_ref = v*0 + hLst[i] - assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,8) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,8) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,8) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,8) - end for - - # 9. interpolate height field above sea to height levels above sea. - # The input data only contains model levels from 137 to 70. - hLst = [11585, 15000] # 15000 is out of range! - - lev = nil - for i=137 to 70 by -1 do - lev = lev & [i] - end for - z = read(data:z, levelist: lev) - - r = ml_to_hl(z/gEarth, z, nil, hLst, "sea", method) - assert_equal(count(r),count(hLst),"ml_to_hl count",9) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the height field - v_ref = v*0 + hLst[i] - assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_linear value lev" & i,9) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_linear level lev" & i,9) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveSea","ml_to_hl_linear typeOfLevel lev" & i,9) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z","ml_to_hl_linear shortName lev" & i,9) - end for - -end test_ml_to_hl_linear - - -function test_ml_to_hl_log() - - fs = read('tq_ml137.grib') - t = read(data: fs, param: 't') - zs = read(data: fs, param: 'zs') - lnsp = read(data: fs, param: 'lnsp') - z = read("z_ml137_ref.grib") - - method = "log" - hLst = [1000, 500, 2500, 10000] - gEarth = 9.80665 - - # 1. interpolate log height field above sea to height levels above sea - f_ref = read("ml_to_hl_log_asl_ref.grib") - - r = ml_to_hl(1000*log(z/gEarth+1000), z, nil, hLst, "sea", method) - assert_equal(count(r),count(hLst),"ml_to_hl_log count",1) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the log height field - v_ref = values(f_ref[i]) - - #print(maxvalue(abs(v - v_ref))) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_log value lev" & i,1) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_log level lev" & i,1) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveSea","ml_to_hl_log typeOfLevel lev" & i,1) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z","ml_to_hl_log shortName lev" & i,1) - end for - - # 2. interpolate log height field above ground to height levels above ground - f_ref = read("ml_to_hl_log_agr_ref.grib") - - h_agr = nil - for i=1 to count(z) do - h_agr = h_agr & 1000*log((z[i] - zs[1])/gEarth+ 1000) - end for - - r = ml_to_hl(h_agr, z, zs, hLst, "ground", method) - assert_equal(count(r),count(hLst),"ml_to_hl_log count",2) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = values(f_ref[i]) - #print(maxvalue(abs(v - v_ref))) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_log value lev" & i,2) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],"ml_to_hl_log level lev" & i,2) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveGround","ml_to_hl_log typeOfLevel lev" & i,2) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z","ml_to_hl_log shortName lev" & i,2) - end for - -end test_ml_to_hl_log - -function test_ml_to_hl_field() - - # The target height now is defined by a field! - - fs = read('tq_ml137.grib') - t = read(data: fs, param: 't') - zs = read(data: fs, param: 'zs') - lnsp = read(data: fs, param: 'lnsp') - z = read("z_ml137_ref.grib") - - z_bottom = read(data: z, levelist: 137) - - method = "linear" - hLst = [1000, 500, 2500, 10000] - gEarth = 9.80665 - - # Construct a height field with contant values - h_fs = nil - for i=1 to count(hLst) do - h_fs = h_fs & (z[1]*0 + hLst[i]) - end for - - # 1. interpolate height field above sea to height levels above sea - #f_ref = read("ml_to_hl_field_asl_ref.grib") - - r = ml_to_hl(z/gEarth, z, nil, h_fs, "sea", method) - assert_equal(count(r),count(h_fs),"ml_to_hl_field count",1) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the height field - v_ref = values(bitmap(h_fs[i], bitmap(z_bottom > h_fs[i]*gEarth, 1))) - - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,1) - end for - - - # 2. interpolate height field above ground to height levels above ground - h_agr = nil - for i=1 to count(z) do - h_agr = h_agr & (z[i] - zs[1])/gEarth - end for - - r = ml_to_hl(h_agr, z, zs, h_fs, "ground", method) - assert_equal(count(r),count(h_fs),"ml_to_hl_field count",2) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = values(h_fs[i]) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,2) - - end for - - # 3. interpolate pressure to height levels above sea - f_ref =read("ml_to_hl_asl_ref.grib") - - pres = unipressure(lnsp) - r = ml_to_hl(pres, z, nil, h_fs, "sea", method) - assert_equal(count(r),count(h_fs),"ml_to_hl_field count",3) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = values(f_ref[i]) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,3) - end for - - - # 4. interpolate pressure to height levels above ground - f_ref =read("ml_to_hl_agr_ref.grib") - - pres = unipressure(lnsp) - r = ml_to_hl(pres, z, zs, h_fs, "ground", method) - assert_equal(count(r),count(h_fs),"ml_to_hl_field count",4) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = values(f_ref[i]) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,4) - end for - - # 5. interpolate height above sea to non constant height - # fields above sea - h_fs_noconst = nil - # the target height field = surface orography + a constant value - delta_h_lst = [1200, 5000, 10000] - for i=1 to count(delta_h_lst) do - h_fs_noconst = h_fs_noconst & (zs/gEarth + delta_h_lst[i]) - end for - - # the results should be very close to the target heights themselves - r = ml_to_hl(z/gEarth, z, nil, h_fs_noconst, "sea", method) - assert_equal(count(r),count(h_fs_noconst),"ml_to_hl_field count",5) - - for i=1 to count(r) do - v = values(r[i]) - v_ref = values(h_fs_noconst[i]) -# plot(r[i]-h_fs_noconst[i]) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,5) - end for - - # 6. interpolate height above sea to non constant height - # fields above ground - - # the results should be very close to the target heights + zs/9.81 - r = ml_to_hl(z/gEarth, z, zs, h_fs_noconst, "ground", method) - assert_equal(count(r),count(h_fs_noconst),"ml_to_hl_field count",6) - - for i=1 to count(r) do - v = values(r[i]) - # we should get back the target height field + surf orography - v_ref = values(h_fs_noconst[i] + zs/gEarth) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,6) - end for - - # 7. interpolate height above sea to non constant height - # fields above sea - # - the input field and the input z field contain the fields in a different - # order - z_fs_input = sort(z,"levelist", ">") - z_fs = sort(z,"levelist", "<") - #print(grib_get(h_fs,["level"])) - #print(grib_get(z_fs,["level"])) - r = ml_to_hl(z_fs_input/gEarth, z_fs, nil, h_fs_noconst, "sea", method) - assert_equal(count(r),count(h_fs_noconst),"ml_to_hl_field count",7) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the target height field - v_ref = values(h_fs_noconst[i]) - assert(vec_same_missing(v,v_ref,1E-3),"ml_to_hl_field value lev" & i,7) - end for - - # 8. interpolate height above sea to non constant height - # fields above ground - # - the input field and the input z field contain the fields in a different - # order - r = ml_to_hl(z_fs_input/gEarth, z_fs, zs, h_fs_noconst, "ground", method) - assert_equal(count(r),count(h_fs_noconst),"ml_to_hl_field count",8) - - for i=1 to count(r) do - v = values(r[i]) - - # we should get back the target height field + surf orography - v_ref = values(h_fs_noconst[i] + zs/gEarth) - assert(vec_same_missing(v,v_ref,1E-2),"ml_to_hl_field value lev" & i,8) - end for - -end test_ml_to_hl_field - -function test_ml_to_hl_surface() - - fn_name = "ml_to_hl_surface" - - fs = read('tq_ml137.grib') - t = read(data: fs, param: 't') - zs = read(data: fs, param: 'zs') - lnsp = read(data: fs, param: 'lnsp') - z = read("z_ml137_ref.grib") - - hLst = [1, 5, 120, 10] - gEarth = 9.80665 - - # 1. interpolate height field above ground to height levels above ground - h_agr = nil - for i=1 to count(z) do - h_agr = h_agr & (z[i] - zs[1])/gEarth - end for - - r = ml_to_hl(h_agr, z, zs, hLst, "ground", "linear", 0) - assert_equal(count(r),count(hLst),fn_name & " count",1) - - for i=1 to count(r) do - v = values(r[i]) - - v_ref = v*0 + hLst[i] - assert(vec_same_missing(v,v_ref,1E-2),fn_name & " value lev" & i,1) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],fn_name & " level lev" & i,1) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveGround",fn_name & " typeOfLevel lev" & i,1) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z",fn_name & " shortName lev" & i,1) - end for - - # 2. interpolate height field above ground to height levels above ground - f_ref =read("ml_to_hl_agr_log_surf_ref.grib") - - hLst = [1, 5, 120, 212, 10] - r = ml_to_hl(h_agr, z, zs, hLst, "ground", "log", 0) - assert_equal(count(r),count(hLst),fn_name & " count",2) - - for i=1 to count(r) do - v = values(r[i]) - v_ref = values(f_ref[i]) - - #print(maxvalue(v)) - #print(maxvalue(abs(v - v_ref))) - #print(v[1,10]) - #print(v_ref[1,10]) - assert(vec_same_missing(v,v_ref,1E-3),fn_name & " value lev" & i,2) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],fn_name & " level lev" & i,2) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveGround",fn_name & " typeOfLevel lev" & i,2) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"z",fn_name & " shortName lev" & i,2) - end for - - # 3. interpolate pressure to height levels above ground - f_ref =read("ml_to_hl_agr_surf_ref.grib") - - hLst = [1, 5, 120, 10] - pres = unipressure(lnsp) - r = ml_to_hl(pres, z, zs, hLst, "ground", "linear", exp(lnsp)) - assert_equal(count(r),count(hLst), fn_name & " count",3) - - for i=1 to count(r) do - v = values(r[i]) - v_ref = values(f_ref[i]) - - assert(vec_same_missing(v,v_ref,1E-3),fn_name & " value lev" & i,3) - - r_level=grib_get_long(r[i],"level") - assert_equal(r_level,hLst[i],fn_name & " level lev" & i,3) - - r_level=grib_get_string(r[i],"typeOfLevel") - assert_equal(r_level,"heightAboveGround",fn_name & " typeOfLevel lev" & i,3) - - r_name=grib_get_string(r[i],"shortName") - assert_equal(r_name,"pres",fn_name & " shortName lev" & i,3) - - end for - - -end test_ml_to_hl_surface - - -function diag_ml_to_hl_compare_log_to_linear() - - fs = read('tq_ml137.grib') - t = read(data: fs, param: 't') - zs = read(data: fs, param: 'zs') - lnsp = read(data: fs, param: 'lnsp') - z = read("z_ml137_ref.grib") - - hLst = [1000, 500, 2500, 10000] - - print('ml_to_hl_compare_log_to_linear -->') - - # field changing by log height - r = ml_to_hl(1000*log(z/9.81+1000), z, nil, hLst, "sea", "log") - r1 = ml_to_hl(1000*log(z/9.81+1000), z, nil, hLst, "sea", "linear") - v = interpolate(r, [50,20]) - v1 = interpolate(r1, [50,20]) - print('field changing by log height') - print('log',v) - print('lin',v1) - ref = 1000*log(vector(hLst) + 1000) - print('ref',ref) - print('err_log', abs(vector(v)-ref)) - print('err_lin', abs(vector(v1)-ref)) - - # field changing by height - r = ml_to_hl(z/9.81, z, nil, hLst, "sea", "log") - r1 = ml_to_hl(z/9.81, z, nil, hLst, "sea", "linear") - v = interpolate(r, [50,20]) - v1 = interpolate(r1, [50,20]) - print(' ') - print('field changing by height') - print('log',v) - print('lin',v1) - ref = vector(hLst) - print('ref',ref) - print('err_log', abs(vector(v)-ref)) - print('err_lin', abs(vector(v1)-ref)) - -end diag_ml_to_hl_compare_log_to_linear - -function test_pressure() - - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - nLev = 137 - p_ref = read('pres_ml137.grib') - - # all levels - r = pressure(lnsp) - assert_equal(count(r),137,"pressure count",1) - - for i=1 to nLev do - assert_equal(grib_get_long(r[i],'level'), i, "pressure level lev" & i,1) - v = values(r[i]) - v_ref = values(p_ref[i]) - assert(vec_same(v,v_ref,1E-2),"pressure value lev" & i,1) - assert_equal(grib_get_long(r[i], "paramId"), 54, "pressure paramId["&i&"]", 1) - end for - - # given levels - lev = 100 - r = pressure(lnsp, lev) - assert_equal(count(r),1,"pressure count",2) - assert_equal(grib_get_long(r,'level'), lev, "pressure level",2) - - v = values(r) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-2),"pressure value lev" & lev,2) - - # list of levels - levLst = [100, 110] - r = pressure(lnsp, levLst) - assert_equal(count(r),count(levLst),"pressure count",3) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "pressure level lev" & lev,3) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-2),"pressure value lev" & lev,3) - assert_equal(grib_get_long(r[i], "paramId"), 54, "pressure paramId["&i&"]", 3) - end for - - # levels from field - levLst = [10,20] - t = read(data: fs, param: 't', levelist: levLst) - r = pressure(lnsp, t) - assert_equal(count(r),count(t),"pressure count",4) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "pressure level lev" & lev,4) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-2),"pressure value lev" & lev,4) - assert_equal(grib_get_long(r[i], "paramId"), 54, "pressure paramId["&i&"]", 4) - end for - -end test_pressure - -function test_pressure_derivative() - test_name = "pressure_derivative" - - p = |1000, 850, 700, 500, 400, 300| - p = p*100 - - # test on vectors - sorted - t = |270, 240, 235, 230, 200, 225| - r = pressure_derivative(t, p) - v_ref = |0.002,0.00116666666667,0.000285714285714,0.00116666666667,0.00025,-0.0025| - assert(vec_same(r, v_ref, 1E-6), test_name & " vector sorted",1) - - # test on vectors - unsorted - us_idx = [2, 3, 1, 6, 5, 4] - p_us = p - t_us = t - v_ref_us = v_ref - for i=1 to count(us_idx) do - p_us[i] = p[us_idx[i]] - t_us[i] = t[us_idx[i]] - v_ref_us[i] = v_ref[us_idx[i]] - end for - r = pressure_derivative(t_us, p_us) - assert(vec_same(r, v_ref_us, 1E-6), test_name & " vector unsorted",1) - - # pl fieldset - sorted - fs = read('tuv_pl.grib') - t = read(data: fs, param: 't') - ref = read("dt_dp_ref.grib") - - r = pressure_derivative(t) - for i=1 to count(r) do - lev = p[i]/100 - assert_equal(grib_get_long(r[i],'level'), lev, test_name & "pl sorted - level i=" & i,1) - v = values(r[i]) - v_ref = values(ref[i]) - assert(vec_same(v,v_ref,1E-7), test_name & "pl sorted - values i=" & i,1) - end for - - # pl fieldset - unsorted - us_idx = [2, 3, 1, 6, 5, 4] - p_us = p - t_us = nil - ref_us = nil - for i=1 to count(us_idx) do - p_us[i] = p[us_idx[i]] - t_us = t_us & t[us_idx[i]] - ref_us = ref_us & ref[us_idx[i]] - end for - - r = pressure_derivative(t_us) - for i=1 to count(r) do - lev = p_us[i]/100 - assert_equal(grib_get_long(r[i],'level'), lev, test_name & "pl unsorted - level i=" & i,1) - v = values(r[i]) - v_ref = values(ref_us[i]) - assert(vec_same(v,v_ref,1E-7), test_name & "pl unsorted - values i=" & i,1) - end for - -end test_pressure_derivative - -function test_thickness() - - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - nLev = 137 - p_ref = read('thickness_ml137.grib') - - # all levels - r = thickness(lnsp) - assert_equal(count(r),137,"thickness count",1) - - for i=1 to nLev do - assert_equal(grib_get_long(r[i],'level'), i, "thickness level lev" & i,1) - v = values(r[i]) - v_ref = values(p_ref[i]) - assert(vec_same(v,v_ref,1E-2),"thickness value lev" & i,1) - assert_equal(grib_get_long(r[i], "paramId"), 54, "thickness paramId["&i&"]", 1) - end for - - # given levels - lev = 100 - r = thickness(lnsp, lev) - assert_equal(count(r),1,"thickness count",2) - assert_equal(grib_get_long(r,'level'), lev, "thickness level",2) - - v = values(r) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-2),"thickness value lev" & lev,2) - assert_equal(grib_get_long(r, "paramId"), 54, "thickness paramId", 2) - - # list of levels - levLst = [100, 110] - r = thickness(lnsp, levLst) - assert_equal(count(r),count(levLst),"thickness count",3) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "thickness level lev" & lev,3) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-2),"thickness value lev" & lev,3) - assert_equal(grib_get_long(r[i], "paramId"), 54, "thickness paramId["&i&"]", 3) - end for - - # levels from field - levLst = [10,20] - t = read(data: fs, param: 't', levelist: levLst) - r = thickness(lnsp, t) - assert_equal(count(r),count(t),"thickness count",4) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "thickness level lev" & lev,4) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-2),"thickness value lev" & lev,4) - assert_equal(grib_get_long(r[i], "paramId"), 54, "thickness paramId["&i&"]", 4) - end for - -end test_thickness - -function test_unipressure() - - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - nLev = 137 - p_ref = read('pres_ml137.grib') - - # all levels - r = unipressure(lnsp) - assert_equal(count(r),137,"unipressure count",1) - - for i=1 to nLev do - assert_equal(grib_get_long(r[i],'level'), i, "unipressure level lev" & i,1) - v = values(r[i]) - v_ref = values(p_ref[i]) - assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & i,1) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 1) - end for - - # list of levels - levLst = [100, 110] - r = unipressure(lnsp, levLst) - assert_equal(count(r),count(levLst),"unipressure count",2) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "unipressure level lev" & lev,2) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & lev,2) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 2) - end for - - # levels from field - levLst = [10,20] - t = read(data: fs, param: 't', levelist: levLst) - r = unipressure(lnsp, t) - assert_equal(count(r),count(t),"unipressure count",3) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "unipressure level lev" & lev, 3) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & lev,3) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 3) - end for - - # use custom lnsp paramId - lnspId = 152 - lnsp = grib_set_long(lnsp, ['paramId',lnspId]) - - # list of levels + custom lnsp paramId - levLst = [100, 110] - r = unipressure(lnsp, levLst, lnspId) - assert_equal(count(r),count(levLst),"unipressure count",4) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "unipressure level lev" & lev,4) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & lev,4) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 4) - end for - - # levels from field + custom lnsp paramId - levLst = [10,20] - t = read(data: fs, param: 't', levelist: levLst) - r = unipressure(lnsp, t, lnspId) - assert_equal(count(r),count(t),"unipressure count",5) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "unipressure level lev" & lev, 5) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & lev,5) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 5) - end for - - -end test_unipressure - -function test_unithickness() - - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - nLev = 137 - p_ref = read('thickness_ml137.grib') - - # all levels - r = unithickness(lnsp) - assert_equal(count(r),137,"unithickness count",1) - - for i=1 to nLev do - assert_equal(grib_get_long(r[i],'level'), i, "unithickness level lev" & i,1) - v = values(r[i]) - v_ref = values(p_ref[i]) - assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & i,1) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 1) - end for - - # list of levels - levLst = [100, 110] - r = unithickness(lnsp, levLst) - assert_equal(count(r),count(levLst),"unithickness count",2) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "unithickness level lev" & lev,2) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & lev,2) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 2) - end for - - # levels from field - levLst = [10,20] - t = read(data: fs, param: 't', levelist: levLst) - r = unithickness(lnsp, t) - assert_equal(count(r),count(t),"unithickness count",3) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "unithickness level lev" & lev, 3) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & lev,3) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 3) - end for - - # use custom lnsp paramId - lnspId = 152 - lnsp = grib_set_long(lnsp, ['paramId',lnspId]) - - # list of levels + custom lnsp paramId - levLst = [100, 110] - r = unithickness(lnsp, levLst, lnspId) - assert_equal(count(r),count(levLst),"unithickness count",4) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "unithickness level lev" & lev,4) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & lev,4) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 4) - end for - - # levels from field + custom lnsp paramId - levLst = [10,20] - t = read(data: fs, param: 't', levelist: levLst) - r = unithickness(lnsp, t, lnspId) - assert_equal(count(r),count(t),"unithickness count",5) - - for i=1 to count(levLst) do - lev = levLst[i] - assert_equal(grib_get_long(r[i],'level'), lev, "unithickness level lev" & lev, 5) - v = values(r[i]) - v_ref = values(p_ref[lev]) - assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & lev,5) - assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 5) - end for - - -end test_unithickness - -function test_univertint() - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - t = read(data: fs, param: 't') - f_ref = read("univertint_ml_ref.grib") - - # one fieldset - constant fields - r=univertint(lnsp & (t*0+1)) - assert_equal(count(r),1, "univertint count", 1) - - v = values(r) - v_ref = values(f_ref[1]) - assert(vec_same(v, v_ref,1E-4), "univertint values",1) - assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",1) - - # one fieldset - r=univertint(fs) - assert_equal(count(r),1, "univertint count", 2) - v = values(r) - v_ref = values(f_ref[2]) - assert(vec_same(v, v_ref,1E-4), "univertint values",2) - assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",2) - - # two args: lnsp, fieldset - r=univertint(lnsp,t) - assert_equal(count(r),1, "unvertint count", 3) - v = values(r) - v_ref = values(f_ref[3]) - assert(vec_same(v, v_ref,1E-4), "univertint values",3) - assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",3) - - # use custom lnsp paramId - lnspId = 152 - lnsp_152 = grib_set_long(lnsp, ['paramId',lnspId]) - - # one fieldset + custom lnsp paramId - r = univertint(lnsp_152 & t, lnspId) - assert_equal(count(r),1, "univertint count", 4) - v = values(r) - v_ref = values(f_ref[4]) - assert(vec_same(v, v_ref,1E-4), "univertint values",4) - assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",4) - - # two args: lnsp, fieldset + custom lnsp paramId - r = univertint(lnsp_152, t, lnspId) - assert_equal(count(r),1, "univertint count", 5) - v = values(r) - v_ref = values(f_ref[5]) - assert(vec_same(v, v_ref,1E-4), "univertint values",5) - assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",5) - - # two args: lnsp, fieldset + level range - r = univertint(lnsp, t*0+1, [96,137]) - assert_equal(count(r),1, "univertint count", 6) - v = values(r) - v_ref = values(f_ref[6]) - assert(vec_same(v, v_ref,1E-4), "univertint values",6) - assert_equal(grib_get_long(r, "paramId"), 130, "univertint paramId",6) - -end test_univertint - -function test_univertint_pl() - fs = read('tuv_pl.grib') - t = read(data: fs, param: 't') - - fs_ref = read("univertint_pl_ref.grib") - - g = 9.80665 - dp = |75, 150, 175, 150, 100, 50| - dp = 100.*dp/g - - r_out = nil - - # unsorted input fieldset - us_idx = [2, 3, 1, 6, 5, 4] - t_us = nil - loop i in us_idx - t_us = t_us & t[i] - end loop - - # one fieldset - constant fields - r=univertint(t*0+1) - assert_equal(count(r),1, "univertint_pl count", 1) - v = values(r) - v_ref = values(fs_ref[1]) - assert(vec_same(v, v_ref,1E-2), "univertint_pl",1) - - # one fieldset - constant fields , unsorted pl levels - r=univertint(t_us*0+1) - assert_equal(count(r),1, "univertint_pl count", 2) - v = values(r) - v_ref = values(fs_ref[2]) - assert(vec_same(v, v_ref,1E-2), "univertint_pl",2) - - # one fieldset - r=univertint(t) - assert_equal(count(r),1, "univertint_pl count", 3) - v = values(r) - v_ref = values(fs_ref[3]) - - #v_ref = v*0 - #for i=1 to count(t) do - # v_ref = v_ref + values(t[i]) * dp[i] - #end for - assert(vec_same(v, v_ref,1E-4), "univertint_pl",3) - - # one fieldset unsorted level - r=univertint(t_us) - assert_equal(count(r),1, "univertint_pl count", 4) - v = values(r) - v_ref = values(fs_ref[4]) - assert(vec_same(v, v_ref, 1E-4), "univertint_pl",4) - - # one fieldset - extra 100Pa level - t_80 = read("t_80Pa.grib") - dp = |75, 150, 175, 150, 100, 199.6, 149.6| - dp = 100.*dp/g - t1 = read(data:t, area: [-20, -30, 20, 30]) & t_80 - r=univertint(t1) - assert_equal(count(r),1, "univertint_pl count", 5) - v = values(r) - #v_ref = v*0 - #for i=1 to count(t1) do - # v_ref = v_ref + values(t1[i]) * dp[i] - # end for - v_ref = values(fs_ref[5]) - assert(vec_same(v, v_ref,1E-4), "univertint_pl",5) - - -end test_univertint_pl - -function test_vertint() - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - t = read(data: fs, param: 't') - f_ref = read("vertint_ref.grib") - - r=vertint(lnsp & (t*0+1)) - assert_equal(count(r),1, "vertint count", 1) - v = values(r) - v_ref = values(f_ref[1]) - assert(vec_same(v, v_ref,1E-2), "vertint",1) - - r=vertint(fs) - assert_equal(count(r),1, "vertint count", 2) - v = values(r) - v_ref = values(f_ref[2]) - assert(vec_same(v, v_ref,1E-2), "vertint",2) - - r=vertint(lnsp,t) - assert_equal(count(r),1, "vertint count", 3) - v = values(r) - v_ref = values(f_ref[2]) - assert(vec_same(v, v_ref,1E-2), "vertint",3) - -end test_vertint - -function test_w_from_omega() - - g = 9.81 - RD = 287.058 - - # numbers - omega = 1.2 - t = 285.6 - p = 1000*100 - ref = -0.100285950826 - w = w_from_omega(omega, t, p) - assert_equal(w,ref,"w_from_omega",1) - - # fields - ml - data_grb =read("omega_ml.grib") - omega = read(data: data_grb, param: 'w') - t = read(data: data_grb, param: 't') - lnsp = read(data: data_grb, param: "lnsp") - p = unipressure(lnsp, omega) - - # ml: use lnsp - w = w_from_omega(omega, t, lnsp) - for i=1 to count(omega) do - v = values(w[i]) - omega_v = values(omega[i]) - t_v = values(t[i]) - p_v = values(p[i]) - v_ref = w_from_omega(omega_v, t_v, p_v) - assert(vec_same(v, v_ref,0.00001), "w_from_omega lnsp field-ml",i) - end for - - # ml: use pressure - w = w_from_omega(omega, t, p) - for i=1 to count(omega) do - v = values(w[i]) - omega_v = values(omega[i]) - t_v = values(t[i]) - p_v = values(p[i]) - v_ref = w_from_omega(omega_v, t_v, p_v) - assert(vec_same(v, v_ref,0.00001), "w_from_omega p field-ml",i) - end for - - # fields - pl - data_grb =read(source: "omega_pl.grib") - omega = read(data: data_grb, param: 'w') - t = read(data: data_grb, param: 't') - p = [100000, 50000] - w = w_from_omega(omega, t) - - for i=1 to count(omega) do - v = values(w[i]) - omega_v = values(omega[i]) - t_v = values(t[i]) - p_v = p[i] - v_ref = w_from_omega(omega_v, t_v, p_v) - assert(vec_same(v, v_ref,0.00001), "w_from_omega field-pl",i) - end for - -end test_w_from_omega - - -#==================================================== -# -# Functions to generate test reference data -# -#==================================================== - -function generate_test_pressure_reference() - - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - sp = exp(values(lnsp)) - - pv=grib_get_double_array(lnsp,"pv") - nLev=count(pv)/2-1 - ac=vector(nLev+1) - bc=vector(nLev+1) - for i=1 to nLev+1 do - ac[i]=pv[i] - bc[i]=pv[nLev+1+i] - end for - - r = nil - for i=1 to nLev do - pval = sp*(bc[i+1]+bc[i])/2 + (ac[i]+ac[i+1])/2 - p = grib_set_long(lnsp, ['level',i]) - p = set_values(p, pval) - r = r & p - end for - - write('pres_ml137.grib',r) - -end generate_test_pressure_reference - -function generate_test_thickness_reference() - - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - sp = exp(values(lnsp)) - - pv=grib_get_double_array(lnsp,"pv") - nLev=count(pv)/2-1 - ac=vector(nLev+1) - bc=vector(nLev+1) - for i=1 to nLev+1 do - ac[i]=pv[i] - bc[i]=pv[nLev+1+i] - end for - - r = nil - for i=1 to nLev do - p1 = sp*bc[i]+ac[i] - p2 = sp*bc[i+1]+ac[i+1] - pval = p2 - p1 - p = grib_set_long(lnsp, ['level',i]) - p = set_values(p, pval) - r = r & p - end for - - write('thickness_ml137.grib',r) - -end generate_test_thickness_reference - - -function generate_test_vertint_reference() - fs = read('t_lnsp_ml137.grb') - lnsp = read(data: fs, param: 'lnsp') - t = read(data: fs, param: 't') - g = 9.80665 - - f = lnsp & (t*0+1) - r1=vertint(f) - # r1*g is a good approximation of surface pressure - #plot(r1-exp(lnsp)/g) - - f = fs - r2=vertint(f) - - r3=univertint(lnsp,t*0+1,[96,137]) - # r2*g is a good approximation of 500hpa pressure - #plot(r3*g) - #write("vertint_ref.grib",r1 & r2 & r3) - -end generate_test_vertint_reference - -function generate_geo_on_ml_input() - - # get analysis data - r = (date: 20190602, time: 12, levtype: "ml", grid: [5,5]) - t = retrieve(r,levelist: [1,"to",137],param: "t") - q = retrieve(r,levelist: [1,"to",137],param: "q") - zs = retrieve(r,levelist: 1,param: "z") - lnsp = retrieve(r,levelist: 1,param: "lnsp") - - #write("tq_ml137.grib",lnsp,zs,t,q) - -end generate_geo_on_ml_input - -function generate_geo_on_ml_reference() - - fs = read('tq_ml137.grib') - t = read(data: fs, param: 't') - q = read(data: fs, param: 'q') - zs = read(data: fs, param: 'z') - lnsp = read(data: fs, param: 'lnsp') - - r = mvl_geopotential_on_ml(t,q,lnsp,zs) - - #plot(r[137]-zs) - #write("z_ml137_ref.grib",r) - -end generate_geo_on_ml_reference - -function generate_ml2pl_reference() - - # get analysis data - # the same date has to be used as in generate_geo_on_ml_input() - - r = (date: 20190602, time: 12, levtype: "pl", grid: [5,5]) - t_ref = retrieve(r,levelist: [100,925,500,1000,850], param: "t") - - fs = read('tq_ml137.grib') - t_in = read(data: fs, param: 't') - lnsp_in = read(data: fs, param: 'lnsp') - - pLst = [100,925,500,1000,850] - r = mvl_ml2hPa(lnsp_in,t_in,pLst) - - # visually checked!!! - #plot(abs(r-t_ref)) - - #write("ml2pl_ref.grib",r) - -end generate_ml2pl_reference - -function generate_ml_to_h_reference() - - hLst = [1000, 500, 2500, 10000] - fs = read('tq_ml137.grib') - lnsp = read(data: fs, param: 'lnsp') - zs = read(data: fs, param: 'z') - z = read("z_ml137_ref.grib") - - # asl - pres = unipressure(lnsp) - r1 = ml_to_hl(pres, z, nil, hLst, "sea", "linear") - - # visually checked!!! - #plot(r1) - #write("ml_to_hl_asl_ref.grib", r1) - - # agr - pres = unipressure(lnsp) - r2 = ml_to_hl(pres, z, zs, hLst, "ground", "linear") - - # visually checked!!! - #plot(r1-r2) - #write("ml_to_hl_agr_ref.grib", r2) - -end generate_ml_to_h_reference() \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/grib_vertical_pressure.mv metview-5.19.2/metview/test/macros/grib_vertical_pressure.mv --- metview-5.17.4/metview/test/macros/grib_vertical_pressure.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/grib_vertical_pressure.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,497 @@ +#Metview Macro + +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" + +global ASSERT_EQUAL_EPS = 1E-4 # used by assert_equal() +global VECTOR_DIFF_THRESHOLD = 0.0000001 + +test_pressure() +test_pressure_derivative() +test_thickness() +test_unipressure() +test_unithickness() +test_w_from_omega() + +function test_pressure() + + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + nLev = 137 + p_ref = read('pres_ml137.grib') + + # all levels + r = pressure(lnsp) + assert_equal(count(r),137,"pressure count",1) + + for i=1 to nLev do + assert_equal(grib_get_long(r[i],'level'), i, "pressure level lev" & i,1) + v = values(r[i]) + v_ref = values(p_ref[i]) + assert(vec_same(v,v_ref,1E-2),"pressure value lev" & i,1) + assert_equal(grib_get_long(r[i], "paramId"), 54, "pressure paramId["&i&"]", 1) + end for + + # given levels + lev = 100 + r = pressure(lnsp, lev) + assert_equal(count(r),1,"pressure count",2) + assert_equal(grib_get_long(r,'level'), lev, "pressure level",2) + + v = values(r) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-2),"pressure value lev" & lev,2) + + # list of levels + levLst = [100, 110] + r = pressure(lnsp, levLst) + assert_equal(count(r),count(levLst),"pressure count",3) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "pressure level lev" & lev,3) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-2),"pressure value lev" & lev,3) + assert_equal(grib_get_long(r[i], "paramId"), 54, "pressure paramId["&i&"]", 3) + end for + + # levels from field + levLst = [10,20] + t = read(data: fs, param: 't', levelist: levLst) + r = pressure(lnsp, t) + assert_equal(count(r),count(t),"pressure count",4) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "pressure level lev" & lev,4) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-2),"pressure value lev" & lev,4) + assert_equal(grib_get_long(r[i], "paramId"), 54, "pressure paramId["&i&"]", 4) + end for + +end test_pressure + +function test_pressure_derivative() + test_name = "pressure_derivative" + + p = |1000, 850, 700, 500, 400, 300| + p = p*100 + + # test on vectors - sorted + t = |270, 240, 235, 230, 200, 225| + r = pressure_derivative(t, p) + v_ref = |0.002,0.00116666666667,0.000285714285714,0.00116666666667,0.00025,-0.0025| + assert(vec_same(r, v_ref, 1E-6), test_name & " vector sorted",1) + + # test on vectors - unsorted + us_idx = [2, 3, 1, 6, 5, 4] + p_us = p + t_us = t + v_ref_us = v_ref + for i=1 to count(us_idx) do + p_us[i] = p[us_idx[i]] + t_us[i] = t[us_idx[i]] + v_ref_us[i] = v_ref[us_idx[i]] + end for + r = pressure_derivative(t_us, p_us) + assert(vec_same(r, v_ref_us, 1E-6), test_name & " vector unsorted",1) + + # pl fieldset - sorted + fs = read('tuv_pl.grib') + t = read(data: fs, param: 't') + ref = read("dt_dp_ref.grib") + + r = pressure_derivative(t) + for i=1 to count(r) do + lev = p[i]/100 + assert_equal(grib_get_long(r[i],'level'), lev, test_name & "pl sorted - level i=" & i,1) + v = values(r[i]) + v_ref = values(ref[i]) + assert(vec_same(v,v_ref,1E-7), test_name & "pl sorted - values i=" & i,1) + end for + + # pl fieldset - unsorted + us_idx = [2, 3, 1, 6, 5, 4] + p_us = p + t_us = nil + ref_us = nil + for i=1 to count(us_idx) do + p_us[i] = p[us_idx[i]] + t_us = t_us & t[us_idx[i]] + ref_us = ref_us & ref[us_idx[i]] + end for + + r = pressure_derivative(t_us) + for i=1 to count(r) do + lev = p_us[i]/100 + assert_equal(grib_get_long(r[i],'level'), lev, test_name & "pl unsorted - level i=" & i,1) + v = values(r[i]) + v_ref = values(ref_us[i]) + assert(vec_same(v,v_ref,1E-7), test_name & "pl unsorted - values i=" & i,1) + end for + +end test_pressure_derivative + +function test_thickness() + + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + nLev = 137 + p_ref = read('thickness_ml137.grib') + + # all levels + r = thickness(lnsp) + assert_equal(count(r),137,"thickness count",1) + + for i=1 to nLev do + assert_equal(grib_get_long(r[i],'level'), i, "thickness level lev" & i,1) + v = values(r[i]) + v_ref = values(p_ref[i]) + assert(vec_same(v,v_ref,1E-2),"thickness value lev" & i,1) + assert_equal(grib_get_long(r[i], "paramId"), 54, "thickness paramId["&i&"]", 1) + end for + + # given levels + lev = 100 + r = thickness(lnsp, lev) + assert_equal(count(r),1,"thickness count",2) + assert_equal(grib_get_long(r,'level'), lev, "thickness level",2) + + v = values(r) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-2),"thickness value lev" & lev,2) + assert_equal(grib_get_long(r, "paramId"), 54, "thickness paramId", 2) + + # list of levels + levLst = [100, 110] + r = thickness(lnsp, levLst) + assert_equal(count(r),count(levLst),"thickness count",3) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "thickness level lev" & lev,3) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-2),"thickness value lev" & lev,3) + assert_equal(grib_get_long(r[i], "paramId"), 54, "thickness paramId["&i&"]", 3) + end for + + # levels from field + levLst = [10,20] + t = read(data: fs, param: 't', levelist: levLst) + r = thickness(lnsp, t) + assert_equal(count(r),count(t),"thickness count",4) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "thickness level lev" & lev,4) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-2),"thickness value lev" & lev,4) + assert_equal(grib_get_long(r[i], "paramId"), 54, "thickness paramId["&i&"]", 4) + end for + +end test_thickness + +function test_unipressure() + + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + nLev = 137 + p_ref = read('pres_ml137.grib') + + # all levels + r = unipressure(lnsp) + assert_equal(count(r),137,"unipressure count",1) + + for i=1 to nLev do + assert_equal(grib_get_long(r[i],'level'), i, "unipressure level lev" & i,1) + v = values(r[i]) + v_ref = values(p_ref[i]) + assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & i,1) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 1) + end for + + # list of levels + levLst = [100, 110] + r = unipressure(lnsp, levLst) + assert_equal(count(r),count(levLst),"unipressure count",2) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "unipressure level lev" & lev,2) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & lev,2) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 2) + end for + + # levels from field + levLst = [10,20] + t = read(data: fs, param: 't', levelist: levLst) + r = unipressure(lnsp, t) + assert_equal(count(r),count(t),"unipressure count",3) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "unipressure level lev" & lev, 3) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & lev,3) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 3) + end for + + # use custom lnsp paramId + lnspId = 152 + lnsp = grib_set_long(lnsp, ['paramId',lnspId]) + + # list of levels + custom lnsp paramId + levLst = [100, 110] + r = unipressure(lnsp, levLst, lnspId) + assert_equal(count(r),count(levLst),"unipressure count",4) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "unipressure level lev" & lev,4) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & lev,4) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 4) + end for + + # levels from field + custom lnsp paramId + levLst = [10,20] + t = read(data: fs, param: 't', levelist: levLst) + r = unipressure(lnsp, t, lnspId) + assert_equal(count(r),count(t),"unipressure count",5) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "unipressure level lev" & lev, 5) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-3),"unipressure value lev" & lev,5) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unipreassure paramId["&i&"]", 5) + end for + + +end test_unipressure + +function test_unithickness() + + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + nLev = 137 + p_ref = read('thickness_ml137.grib') + + # all levels + r = unithickness(lnsp) + assert_equal(count(r),137,"unithickness count",1) + + for i=1 to nLev do + assert_equal(grib_get_long(r[i],'level'), i, "unithickness level lev" & i,1) + v = values(r[i]) + v_ref = values(p_ref[i]) + assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & i,1) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 1) + end for + + # list of levels + levLst = [100, 110] + r = unithickness(lnsp, levLst) + assert_equal(count(r),count(levLst),"unithickness count",2) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "unithickness level lev" & lev,2) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & lev,2) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 2) + end for + + # levels from field + levLst = [10,20] + t = read(data: fs, param: 't', levelist: levLst) + r = unithickness(lnsp, t) + assert_equal(count(r),count(t),"unithickness count",3) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "unithickness level lev" & lev, 3) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & lev,3) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 3) + end for + + # use custom lnsp paramId + lnspId = 152 + lnsp = grib_set_long(lnsp, ['paramId',lnspId]) + + # list of levels + custom lnsp paramId + levLst = [100, 110] + r = unithickness(lnsp, levLst, lnspId) + assert_equal(count(r),count(levLst),"unithickness count",4) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "unithickness level lev" & lev,4) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & lev,4) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 4) + end for + + # levels from field + custom lnsp paramId + levLst = [10,20] + t = read(data: fs, param: 't', levelist: levLst) + r = unithickness(lnsp, t, lnspId) + assert_equal(count(r),count(t),"unithickness count",5) + + for i=1 to count(levLst) do + lev = levLst[i] + assert_equal(grib_get_long(r[i],'level'), lev, "unithickness level lev" & lev, 5) + v = values(r[i]) + v_ref = values(p_ref[lev]) + assert(vec_same(v,v_ref,1E-4),"unithickness value lev" & lev,5) + assert_equal(grib_get_long(r[i], "paramId"), 54, "unithickness paramId["&i&"]", 5) + end for + + +end test_unithickness + +function test_w_from_omega() + + g = 9.81 + RD = 287.058 + + # numbers + omega = 1.2 + t = 285.6 + p = 1000*100 + ref = -0.100285950826 + w = w_from_omega(omega, t, p) + assert_equal(w,ref,"w_from_omega",1) + + # fields - ml + data_grb =read("omega_ml.grib") + omega = read(data: data_grb, param: 'w') + t = read(data: data_grb, param: 't') + lnsp = read(data: data_grb, param: "lnsp") + p = unipressure(lnsp, omega) + + # ml: use lnsp + w = w_from_omega(omega, t, lnsp) + for i=1 to count(omega) do + v = values(w[i]) + omega_v = values(omega[i]) + t_v = values(t[i]) + p_v = values(p[i]) + v_ref = w_from_omega(omega_v, t_v, p_v) + assert(vec_same(v, v_ref,0.00001), "w_from_omega lnsp field-ml",i) + end for + + # ml: use pressure + w = w_from_omega(omega, t, p) + for i=1 to count(omega) do + v = values(w[i]) + omega_v = values(omega[i]) + t_v = values(t[i]) + p_v = values(p[i]) + v_ref = w_from_omega(omega_v, t_v, p_v) + assert(vec_same(v, v_ref,0.00001), "w_from_omega p field-ml",i) + end for + + # fields - pl + data_grb =read(source: "omega_pl.grib") + omega = read(data: data_grb, param: 'w') + t = read(data: data_grb, param: 't') + p = [100000, 50000] + w = w_from_omega(omega, t) + + for i=1 to count(omega) do + v = values(w[i]) + omega_v = values(omega[i]) + t_v = values(t[i]) + p_v = p[i] + v_ref = w_from_omega(omega_v, t_v, p_v) + assert(vec_same(v, v_ref,0.00001), "w_from_omega field-pl",i) + end for + +end test_w_from_omega + + +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function generate_test_pressure_reference() + + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + sp = exp(values(lnsp)) + + pv=grib_get_double_array(lnsp,"pv") + nLev=count(pv)/2-1 + ac=vector(nLev+1) + bc=vector(nLev+1) + for i=1 to nLev+1 do + ac[i]=pv[i] + bc[i]=pv[nLev+1+i] + end for + + r = nil + for i=1 to nLev do + pval = sp*(bc[i+1]+bc[i])/2 + (ac[i]+ac[i+1])/2 + p = grib_set_long(lnsp, ['level',i]) + p = set_values(p, pval) + r = r & p + end for + + write('pres_ml137.grib',r) + +end generate_test_pressure_reference + +function generate_test_thickness_reference() + + fs = read('t_lnsp_ml137.grb') + lnsp = read(data: fs, param: 'lnsp') + sp = exp(values(lnsp)) + + pv=grib_get_double_array(lnsp,"pv") + nLev=count(pv)/2-1 + ac=vector(nLev+1) + bc=vector(nLev+1) + for i=1 to nLev+1 do + ac[i]=pv[i] + bc[i]=pv[nLev+1+i] + end for + + r = nil + for i=1 to nLev do + p1 = sp*bc[i]+ac[i] + p2 = sp*bc[i+1]+ac[i+1] + pval = p2 - p1 + p = grib_set_long(lnsp, ['level',i]) + p = set_values(p, pval) + r = r & p + end for + + write('thickness_ml137.grib',r) + +end generate_test_thickness_reference diff -Nru metview-5.17.4/metview/test/macros/hovarea.mv metview-5.19.2/metview/test/macros/hovarea.mv --- metview-5.17.4/metview/test/macros/hovarea.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/hovarea.mv 2023-07-15 08:28:47.000000000 +0000 @@ -10,40 +10,121 @@ # ***************************** LICENSE END ************************************ include "test_utils.mv" +include "hov_utils.mv" -# read input grib data -data = read("t_1000_timeseries.grb") - -# compute hovmoeller and save it in a netcdf file -nc = mhovmoeller_area( - area : [33,-27,75,45], - data : data +test_ll_default() +test_ll_ew() +test_ll_ns() + +function test_ll_default() + + statsLst = ["mean", "minimum", "maximum", "stdev", "variance", "median"] + + fn_name = "ll_ew_default" + + # read input grib data + data = read("t_1000_timeseries.grb") + + # read reference data + nc_ref = read("hovarea_ll_ew_mean_ref.nc") + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_area( + area : [33,-27,75,45], + data : data ) - -# define variable to be checked -setcurrent(nc,"t") - -# variables -lvar = variables(nc) -assert_equal(count(lvar),3,'hovarea: count variables') -assert_equal(lvar[3],"t",'hovarea: third variable name') - -# global attributes -gattr = global_attributes(nc) -assert_equal(count(keywords(gattr)),8,'hovarea: count global attributes') -assert_equal(gattr.type,"AREA_HOVM",'hovarea: global attribute type') - -# attributes of a variable -attr = attributes(nc) -assert_equal(count(keywords(attr)),6,'hovarea: count t attributes') -assert_equal(attr.long_name,"Temperature",'hovarea: attribute t long_name') - -# dimensions of a variable -dims = dimensions(nc) -assert_equal(dims,[43,5],'hovarea: variable t dimension') -dimnames = dimension_names(nc) -assert_equal(dimnames,["lat","time"],'hovarea: variable t dimension names') - -# values of t variable -vals = values(nc) -check_same_vector(vals,215,270.611150872,288.343823577,'hovarea: variable t values') + + # variables + vars_ref = ["time", "lat", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",1) + + # global attributes + _check_hov_global_attr_area(fn_name, 1, nc, + "EAST_WEST", " 75.00/ -27.00/ 33.00/ 45.00", 1, "MEAN") + + _check_hov_data(nc, nc_ref, "lat", 43, 5, 0, fn_name, 1) + +end test_ll_default + + +function test_ll_ew() + + statsLst = ["mean", "minimum", "maximum", "stdev", "variance", "median"] + + fn_name = "ll_ew" + + # read input grib data + data = read("t_1000_timeseries.grb") + + for i=1 to count(statsLst) do + + # read reference data + nc_ref = read("hovarea_ll_ew_" & statsLst[i] & "_ref.nc") + #_plot_hov_nc(nc_ref) + #plot(mhovmoellerview(type: "area_hovm", area: [75,-27,33,45]), nc_ref) + #stop + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_area( + area : [33,-27,75,45], + data : data, + area_statistics: statsLst[i] + ) + #write("hovarea_ll_ew_" & statsLst[i] & "_ref.nc", nc) + + # variables + vars_ref = ["time", "lat", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",i) + + # global attributes + _check_hov_global_attr_area(fn_name, i, nc, + "EAST_WEST", " 75.00/ -27.00/ 33.00/ 45.00", 1, uppercase(statsLst[i])) + + _check_hov_data(nc, nc_ref, "lat", 43, 5, 0, fn_name, i) + + end for + +end test_ll_ew + +function test_ll_ns() + + statsLst = ["mean", "minimum", "maximum", "stdev", "variance", "median"] + + fn_name = "ll_ns" + + # read input grib data + data = read("t_1000_timeseries.grb") + + for i=1 to count(statsLst) do + + # read reference data + nc_ref = read("hovarea_ll_ns_" & statsLst[i] & "_ref.nc") + #_plot_hov_nc("lon", -27, 45, [nc_ref]) + #plot(mhovmoellerview(type: "area_hovm", area: [75,-27,33,45]), nc_ref) + #stop + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_area( + area : [33,-27,75,45], + data : data, + area_statistics: statsLst[i], + average_direction: "north_south" + ) + #write("hovarea_ll_ns_" & statsLst[i] & "_ref.nc", nc) + + # variables + vars_ref = ["time", "lon", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",i) + + # global attributes + _check_hov_global_attr_area(fn_name, i, nc, + "NORTH_SOUTH", " 75.00/ -27.00/ 33.00/ 45.00", 0, uppercase(statsLst[i])) + + _check_hov_data(nc, nc_ref, "lon", 73, 5, 1, fn_name, i) + + end for + +end test_ll_ns diff -Nru metview-5.17.4/metview/test/macros/hovexp.mv metview-5.19.2/metview/test/macros/hovexp.mv --- metview-5.17.4/metview/test/macros/hovexp.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/hovexp.mv 2023-07-15 08:28:47.000000000 +0000 @@ -9,55 +9,165 @@ # # ***************************** LICENSE END ************************************ # + include "test_utils.mv" +include "hov_utils.mv -# read input grib data and split it into two datasets -data = read("t_1000_timeseries.grb") -data1 = read( - step : [12,18,24], - data : data - ) -data2 = read( - step : [30,36], - data : data - ) - -# compute hovmoeller using the first dataset and save it in a netcdf file -nc_area = mhovmoeller_area( - area : [33,-27,75,45], - data : data1 - ) - -# expand hovmoeller using the second dataset and save it in a netcdf file -nc = mhovmoeller_expand( - netcdf_data : nc_area, - data : data2 - ) - -# define variable to be checked -setcurrent(nc,"t") - -# variables -lvar = variables(nc) -assert_equal(count(lvar),3,'hovarea: count variables') -assert_equal(lvar[3],"t",'hovarea: third variable name') - -# global attributes -gattr = global_attributes(nc) -assert_equal(count(keywords(gattr)),8,'hovarea: count global attributes') -assert_equal(gattr.type,"AREA_HOVM",'hovarea: global attribute type') - -# attributes of a variable -attr = attributes(nc) -assert_equal(count(keywords(attr)),6,'hovarea: count t attributes') -assert_equal(attr.long_name,"Temperature",'hovarea: attribute t long_name') - -# dimensions of a variable -dims = dimensions(nc) -assert_equal(dims,[43,5],'hovarea: variable t dimension') -dimnames = dimension_names(nc) -assert_equal(dimnames,["lat","time"],'hovarea: variable t dimension names') - -# values of t variable -vals = values(nc) -check_same_vector(vals,215,270.611150872,288.343823577,'hovarea: variable t values') +test_area() +test_vertical() +test_line() + +function test_area() + + fn_name ="area" + + # read input grib data and split it into two datasets + data = read("t_1000_timeseries.grb") + data1 = read( + step : [12,18,24], + data : data + ) + data2 = read( + step : [30,36], + data : data + ) + + nc_ref = read("hovexp_area_ref_1.nc") + + nc_1 = mhovmoeller_area( + area : [33,-27,75,45], + data : data1 + ) + + nc = mhovmoeller_expand( + netcdf_data : nc_1, + data : data2 + ) + + #write("hovexp_area_ref_1.nc", nc) + #stop + + _check_hov_global_attr_area(fn_name, 1, nc, + "EAST_WEST", " 75.00/ -27.00/ 33.00/ 45.00", 1, "MEAN") + + _check_hov_data(nc, nc_ref, "lat", 43, 5, 0, fn_name, 1) + + +end test_area + + +function test_vertical() + + fn_name ="vertical" + + # read input grib data and split it into two datasets + data = read("t_timeseries.grb") + data1 = read( + step : [12,18], + data : data + ) + data2 = read( + step : [24,30], + data : data + ) + data3 = read( + step : [36], + data : data + ) + + + methods = ["area", "nearest_gridpoint", "point"] + + for i=1 to count(methods) do + + nc_ref = read("hovexp_vert_" & methods[i] & ".nc") + + if methods[i] = "area" then + nc_1 = mhovmoeller_vertical( + area : [33,-27,75,45], + data : data1, + input_mode: methods[i], + area_statistics: "maximum" + ) + else + nc_1 = mhovmoeller_vertical( + point : [40, 20], + data : data1, + input_mode: methods[i] + ) + end if + + nc_2 = mhovmoeller_expand( + netcdf_data : nc_1, + data : data2 + ) + + nc_3 = mhovmoeller_expand( + netcdf_data : nc_2, + data : data3 + ) + +# nc_all = mhovmoeller_vertical( +# area : [33,-27,75,45], +# data : data1 & data2 & data3, +# input_mode: "area", +# area_statistics: "maximum" +# ) +# +# _plot_hov_vert_nc([nc_3, nc_all]) +# stop +# + #write("hovexp_vert_" & methods[i] & ".nc", nc_3) + #stop + + if methods[i] = "area" then + _check_hov_global_attr_vert(fn_name, i, nc_3, uppercase(methods[i]), + " 75.00/ -27.00/ 33.00/ 45.00", "AS_IN_DATA", "MAXIMUM") + else + _check_hov_global_attr_vert(fn_name, i, nc_3, uppercase(methods[i]), + " 40.00/ 20.00/ 0.00/ 0.00", "AS_IN_DATA", "") + end if + _check_hov_data(nc_3, nc_ref, "vertical", 6, 5, 0, fn_name, i) + + end for + +end test_vertical + +function test_line() + + fn_name ="line" + + # read input grib data and split it into two datasets + data = read("t_1000_timeseries.grb") + data1 = read( + step : [12,18,24], + data : data + ) + data2 = read( + step : [30,36], + data : data + ) + + nc_ref = read("hovexp_line_ref_1.nc") + + nc_1 = mhovmoeller_line( + line : [33,-27,75,45], + data : data1 + ) + + nc = mhovmoeller_expand( + netcdf_data : nc_1, + data : data2 + ) + + #_plot_hov_line_nc([nc, nc_1], "lon", -27, 45) + + #write("hovexp_line_ref_1.nc", nc) + #stop + + _check_hov_global_attr_line(fn_name, 1, nc, + " 33.00/ -27.00/ 75.00/ 45.00") + + _check_hov_data(nc, nc_ref, "lon", 83, 5, 1, fn_name, 1) + +end test_line diff -Nru metview-5.17.4/metview/test/macros/hovline.mv metview-5.19.2/metview/test/macros/hovline.mv --- metview-5.17.4/metview/test/macros/hovline.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/hovline.mv 2023-07-15 08:28:47.000000000 +0000 @@ -10,6 +10,7 @@ # ***************************** LICENSE END ************************************ include "test_utils.mv" +include "hov_utils.mv" test_ll_1() test_ll_2() @@ -36,38 +37,9 @@ assert_equal(vars, vars_ref, fn_name & ": vars",1) # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),7,fn_name & ": count global attributes") - assert_equal(gattr.type,"LINE_HOVM",fn_name & ": global attribute type") - assert_equal(gattr.vertical_axis, 0 ,fn_name & ": global attribute vertical_axis") - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") - - # t - setcurrent(nc_ref,"t") - vals_ref = values(nc_ref) - - ref = (var_name: "t", - dim_names: ["time", "lon"], - dim_values: [5, 64], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=t",1) - - # time - setcurrent(nc_ref,"time") - vals_ref = values(nc_ref) - - ref = (var_name: "time", - dim_names: ["time"], - dim_values: [5], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=time",1) + _check_hov_global_attr_line(fn_name, 1, nc, " 49.00/ 0.00/ 42.00/ 25.00") + + _check_hov_data(nc, nc_ref, "lon", 64, 5, 1, fn_name, 1) end test_ll_1 @@ -91,40 +63,11 @@ vars_ref = ["time", "lon", "lat", "t"] vars = variables(nc) assert_equal(vars, vars_ref, fn_name & ": vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),7,fn_name & ": count global attributes") - assert_equal(gattr.type,"LINE_HOVM",fn_name & ": global attribute type") - assert_equal(gattr.vertical_axis, 0 ,fn_name & ": global attribute vertical_axis") - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") - - # t - setcurrent(nc_ref,"t") - vals_ref = values(nc_ref) - - ref = (var_name: "t", - dim_names: ["time", "lon"], - dim_values: [5, 64], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=t",1) - # time - setcurrent(nc_ref,"time") - vals_ref = values(nc_ref) - - ref = (var_name: "time", - dim_names: ["time"], - dim_values: [5], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=time",1) + # global attributes + _check_hov_global_attr_line(fn_name, 1, nc, " 42.00/ 0.00/ 49.00/ 25.00") + + _check_hov_data(nc, nc_ref, "lon", 64, 5, 1, fn_name, 1) end test_ll_2 \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/hov_utils.mv metview-5.19.2/metview/test/macros/hov_utils.mv --- metview-5.17.4/metview/test/macros/hov_utils.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/hov_utils.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,224 @@ +#Metview Macro + +function _check_hov_data_core(nc, nc_ref, coord_name, coord_num, time_num, time_first, missing, fn_name, id) + + # attributes of a variable + setcurrent(nc,"t") + attr = attributes(nc) + assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") + assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") + + # t + setcurrent(nc_ref,"t") + vals_ref = values(nc_ref) + + if time_first then + dim_names = ["time", coord_name] + dim_values = [time_num, coord_num] + else + dim_names = [coord_name, "time"] + dim_values = [coord_num, time_num] + end if + + ref = (var_name: "t", + dim_names: dim_names, + dim_values: dim_values, + values: vals_ref) + if missing = 1 then + check_xs_var_missing(nc, ref, 1e-3, fn_name & ": var=t",id) + else + check_xs_var(nc, ref, fn_name & ": var=t",id) + end if + + # lat/lon + setcurrent(nc_ref,coord_name) + vals_ref = values(nc_ref) + + ref = (var_name: coord_name, + dim_names: [coord_name], + dim_values: [coord_num], + values: vals_ref) + check_xs_var(nc, ref, fn_name & ": var=" & coord_name,id) + + # time + setcurrent(nc_ref,"time") + vals_ref = values(nc_ref) + + ref = (var_name: "time", + dim_names: ["time"], + dim_values: [time_num], + values: vals_ref) + check_xs_var(nc, ref, fn_name & ": var=time",id) + +end _check_hov_data + + +function _check_hov_data(nc, nc_ref, coord_name, coord_num, time_num, time_first, fn_name, id) + + _check_hov_data_core(nc, nc_ref, coord_name, coord_num, time_num, time_first, 0, fn_name, id) + +end _check_hov_data + +function _check_hov_data_missing(nc, nc_ref, coord_name, coord_num, time_num, time_first, fn_name, id) + + _check_hov_data_core(nc, nc_ref, coord_name, coord_num, time_num, time_first, 1, fn_name, id) + +end _check_hov_data_missing + + +function _check_hov_global_attr_area(fn_name, id, nc, average_direction, coordinates, vertical_axis, area_statistics) + + gattr = global_attributes(nc) + assert_equal(count(keywords(gattr)),9,fn_name & ": count global attributes",id) + assert_equal(gattr.type,"AREA_HOVM",fn_name & ": global attribute type",id) + assert_equal(gattr.average_direction,average_direction,fn_name & ": global attribute avergage_direction",id) + assert_equal(gattr.coordinates,coordinates,fn_name & ": global attribute coordinates",id) + assert_equal(gattr.grid," 1.00/ 1.00",fn_name & ": global attribute grid",id) + assert_equal(gattr.vertical_axis,vertical_axis,fn_name & ": global attribute vertical_axis",id) + assert_equal(gattr.area_statistics,area_statistics,fn_name & ": global attribute area_statistics",id) + +end _check_hov_global_attr_area + + +function _check_hov_global_attr_vert(fn_name, id, nc, input_mode,coordinates, vertical_type, area_statistics) + + if input_mode = "AREA" then + num = 10 + else + num = 9 + end if + + gattr = global_attributes(nc) + assert_equal(count(keywords(gattr)),num,fn_name & ": count global attributes",id) + assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type",id) + assert_equal(gattr.vertical_type,vertical_type,fn_name & ": global attribute vertical_type",id) + assert_equal(gattr.coordinates,coordinates,fn_name & ": global attribute coordinates",id) + assert_equal(gattr.grid," 1.00/ 1.00",fn_name & ": global attribute grid",id) + assert_equal(gattr.vertical_axis,1,fn_name & ": global attribute vertical_axis",id) + assert_equal(gattr.input_mode,input_mode,fn_name & ": global attribute input_mode",id) + + if input_mode = "AREA" then + assert_equal(gattr.area_statistics,area_statistics,fn_name & ": global attribute area_statistics",id) + end if + +end _check_hov_global_attr_vert + + +function _check_hov_global_attr_line(fn_name, id, nc, coordinates) + + gattr = global_attributes(nc) + assert_equal(count(keywords(gattr)),7,fn_name & ": count global attributes",id) + assert_equal(gattr.type,"LINE_HOVM",fn_name & ": global attribute type",id) + assert_equal(gattr.coordinates,coordinates,fn_name & ": global attribute coordinates",id) + assert_equal(gattr.grid," 1.00/ 1.00",fn_name & ": global attribute grid",id) + assert_equal(gattr.vertical_axis,0,fn_name & ": global attribute vertical_axis",id) + +end _check_hov_global_attr_line + + +function _plot_hov_area_nc(nc_lst, coord_name) + + + view = cartesianview( + x_automatic: "on", + x_axis_type: "date" + #y_min: 1000, + #y_max: 100 + ) + + cols = ["blue", "red"] + plt_lst = [] + for i=1 to count(nc_lst) do + + vis = netcdf_visualiser( + netcdf_plot_type: "xy_matrix", + netcdf_x_variable: "time", + netcdf_y_variable: coord_name, + netcdf_value_variable: "t", + netcdf_data: nc_lst[i] + ) + + cont = mcont( + contour_line_colour: cols[i], + contour_highlight: "off", + contour_level_selection_type: "interval", + contour_interval: 5) + + + plt_lst = plt_lst & [vis, cont] + end for + + plot(view, plt_lst) + +end _plot_hov_area_nc + +function _plot_hov_vert_nc(nc_lst) + + view = cartesianview( + x_automatic: "on", + x_axis_type: "date", + y_min: 1000, + y_max: 100 + ) + + cols = ["blue", "red"] + plt_lst = [] + for i=1 to count(nc_lst) do + + vis = netcdf_visualiser( + netcdf_plot_type: "xy_matrix", + netcdf_x_variable: "time", + netcdf_y_variable: "vertical", + netcdf_value_variable: "t", + netcdf_data: nc_lst[i] + ) + + cont = mcont( + contour_line_colour: cols[i], + contour_highlight: "off", + contour_level_selection_type: "interval", + contour_interval: 5) + + + plt_lst = plt_lst & [vis, cont] + end for + + plot(view, plt_lst) + +end _plot_hov_vert_nc + +function _plot_hov_line_nc(nc_lst, coord_name, x_min, x_max) + + + view = cartesianview( + y_automatic: "on", + y_axis_type: "date", + x_min: x_min, + x_max: x_max + ) + + cols = ["blue", "red"] + plt_lst = [] + for i=1 to count(nc_lst) do + + vis = netcdf_visualiser( + netcdf_plot_type: "xy_matrix", + netcdf_y_variable: "time", + netcdf_x_variable: coord_name, + netcdf_value_variable: "t", + netcdf_data: nc_lst[i] + ) + + cont = mcont( + contour_line_colour: cols[i], + contour_highlight: "off", + contour_level_selection_type: "interval", + contour_interval: 2) + + + plt_lst = plt_lst & [vis, cont] + end for + + plot(view, plt_lst) + +end _plot_hov_line_nc \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/hovvert_ml_to_hl.mv metview-5.19.2/metview/test/macros/hovvert_ml_to_hl.mv --- metview-5.17.4/metview/test/macros/hovvert_ml_to_hl.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/hovvert_ml_to_hl.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,206 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2022 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" +include "hov_utils.mv" + +# model level to height (param) +test_scalar_ml_to_hl() +test_scalar_ml_to_hl_extrapolate() + + +function test_scalar_ml_to_hl() + + fn_name = "scalar_ml_to_hl" + + # read input grib data + data = read("hov_ml_input.grib") + t = read(data: data, param: "t") + z = read(data: data, param: "z")/9.81 + lnsp = read(data: data, param: "lnsp") + + # read reference data + nc_ref = read("hovvert_ml_hl_ref.nc") + + lat = 30 + lon = -60 + delta = 1 + + # ----------------------------- + # 1. original field ordering + # ----------------------------- + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "user", + vertical_coordinate_param: 129, + data : t & z, + top_level: 50000, + bottom_level: 0 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",1) + + # global attributes + _check_hov_global_attr_vert(fn_name, 1, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "USER", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 126, 3, 0, fn_name, 1) + + # ----------------------------------- + # 2. Change order of fields in input + # ----------------------------------- + + data1 = sort(data, ["levelist", "step"], [">", ">"]) + 0 + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "user", + vertical_coordinate_param: 129, + data : t & z, + top_level: 50000, + bottom_level: 0 + ) + + # global attributes + _check_hov_global_attr_vert(fn_name, 2, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "USER", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 126, 3, 0, fn_name, 2) + +end test_scalar_ml_to_hl + +function test_scalar_ml_to_hl_extrapolate() + + fn_name = "scalar_ml_to_hl_extrapolate" + + # read input grib data + data = read("hov_ml_input.grib") + t = read(data: data, param: "t") + z = read(data: data, param: "z")/9.81 + lnsp = read(data: data, param: "lnsp") + + # read reference data + nc_ref = read("hovvert_ml_hl_extra_ref_1.nc") + + lat = 30 + lon = 60 + delta = 1 + + # ----------------------------- + # 1. No extrapolation + # ----------------------------- + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "user", + vertical_coordinate_param: 129, + data : t & z, + vertical_coordinate_extrapolate: "off", + top_level: 20000, + bottom_level: 0 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",1) + + # global attributes + _check_hov_global_attr_vert(fn_name, 1, nc, + "AREA", " 31.00/ 59.00/ 29.00/ 61.00", "USER", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 89, 3, 0, fn_name, 1) + + # +# +# # global attributes +# _check_global_attr_area(fn_name, 1, nc, +# " 31.00/ 59.00/ 29.00/ 61.00", "USER", "MEAN") +# +# # define variable to be checked +# setcurrent(nc,"t") +# +# # attributes of a variable +# attr = attributes(nc) +# assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes",1) +# assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",1) +# +# _check_hovvert(nc, nc_ref, 89, fn_name, 1) + + # ------------------------------------ + # 2. Extrapolate: linear, top+bottom + # ------------------------------------ + + # read reference data + nc_ref = read("hovvert_ml_hl_extra_ref_2.nc") + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "user", + vertical_coordinate_param: 129, + data : t & z, + vertical_coordinate_extrapolate: "on", + vertical_coordinate_extrapolate_mode: "linear", + vertical_coordinate_extrapolate_fixed_sign: "on", + top_level: 100000, + bottom_level: 0 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",2) + + # global attributes + _check_hov_global_attr_vert(fn_name, 2, nc, + "AREA", " 31.00/ 59.00/ 29.00/ 61.00", "USER", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 139, 3, 0, fn_name, 2) + + # ------------------------------------ + # 3. Extrapolate: constant, top+bottom + # ------------------------------------ + + # read reference data + nc_ref = read("hovvert_ml_hl_extra_ref_3.nc") + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "user", + vertical_coordinate_param: 129, + data : t & z, + vertical_coordinate_extrapolate: "on", + vertical_coordinate_extrapolate_mode: "constant", + top_level: 100000, + bottom_level: 0 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",3) + + # global attributes + _check_hov_global_attr_vert(fn_name, 3, nc, + "AREA", " 31.00/ 59.00/ 29.00/ 61.00", "USER", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 139, 3, 0, fn_name, 3) + +end test_scalar_ml_to_hl_extrapolate diff -Nru metview-5.17.4/metview/test/macros/hovvert_ml_to_pl.mv metview-5.19.2/metview/test/macros/hovvert_ml_to_pl.mv --- metview-5.17.4/metview/test/macros/hovvert_ml_to_pl.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/hovvert_ml_to_pl.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,524 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2022 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" +include "hov_utils.mv" + +# model level to pressure +test_scalar_ml_to_pl() +test_scalar_ml_to_pl_missing() +test_scalar_ml_to_pl_subset() +test_scalar_ml_to_pl_range() +test_scalar_ml_to_pl_extrapolate() +test_scalar_ml_input_methods() + +function test_scalar_ml_to_pl() + + fn_name = "scalar_ml_to_pl" + + # read input grib data + data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) + + # read reference data + nc_ref = read("hovvert_ml_pl_ref.nc") + + lat = 30 + lon = -60 + delta = 1 + + # ----------------------------- + # 1. original field ordering + # ----------------------------- + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + bottom_level : 1100 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",1) + + # global attributes + _check_hov_global_attr_vert(fn_name, 1, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 137, 3, 0, fn_name, 1) + + # ----------------------------------- + # 2. Change order of fields in input + # ----------------------------------- + + data1 = sort(data, ["levelist", "step"], [">", ">"]) + 0 + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data1, + bottom_level : 1100 + ) + + + # global attributes + _check_hov_global_attr_vert(fn_name, 2, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 137, 3, 0, fn_name, 2) + + # ------------------ + # 3. fixed lnsp + #------------------- + + nc_ref = read("hovvert_ml_pl_fixed_lnsp_ref.nc") + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + bottom_level : 1100, + use_fixed_surface_pressure: "on", + fixed_surface_pressure: 1013.25 + ) + + # global attributes + _check_hov_global_attr_vert(fn_name, 3, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 137, 3, 0, fn_name, 3) + + # ---------------------------------- + # 4. fixed lnsp, default value + #----------------------------------- + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + bottom_level : 1100, + use_fixed_surface_pressure: "on" + ) + + # global attributes + _check_hov_global_attr_vert(fn_name, 4, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 137, 3, 0, fn_name, 4) + +end test_scalar_ml_to_pl + +function test_scalar_ml_to_pl_missing() + fn_name = "scalar_ml_to_pl_missing" + + # read input grib data + data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) + + # read reference data + nc_ref = read("hovvert_ml_pl_missing_ref_1.nc") + + lat = 30 + lon = -60 + delta = 1 + + # --------------------------------- + # 1. no missing value in output + # --------------------------------- + + # Add missing values + f = data[134] + f = bitmap(f>0,1) + data_m = data + 0 + data_m[134] = f + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data_m, + bottom_level: 1100 + ) + + _check_hov_global_attr_vert(fn_name, 1, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + _check_hov_data_missing(nc, nc_ref, "vertical", 137, 3, 0, fn_name, 1) + + # --------------------------------- + # 2. missing value in output + # --------------------------------- + + # read reference data + nc_ref = read("hovvert_ml_pl_missing_ref_2.nc") + + # Add missing values + data_m = data + 0 + f = bitmap(data_m[118, 124] > 0, 1) + for i=1 to count(f) do + data_m[118+i-1] = f[i] + end for + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data_m, + bottom_level: 1100 + ) + + _check_hov_global_attr_vert(fn_name, 2, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + _check_hov_data_missing(nc, nc_ref, "vertical", 137, 3, 0, fn_name, 2) + +end test_scalar_ml_to_pl_missing + +function test_scalar_ml_to_pl_subset() + fn_name = "scalar_ml_to_pl_subset" + + # read input grib data + data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) + + # read reference data + nc_ref = read("hovvert_ml_pl_subset_ref.nc") + + lat = 30 + lon = -60 + delta = 1 + + lnsp = read(data:data, param: "lnsp") + t = read(data:data, param: "t", levelist: ["90","TO","137"]) + data_s = lnsp & t + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data_s, + bottom_level: 1100 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",1) + + # global attributes + _check_hov_global_attr_vert(fn_name, 1, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 48, 3, 0, fn_name, 1) + +end test_scalar_ml_to_pl_subset + +function test_scalar_ml_to_pl_range() + + fn_name = "scalar_ml_to_pl_range" + + # read input grib data + data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) + + # read reference data + nc_ref = read("hovvert_ml_pl_range_ref.nc") + + lat = 30 + lon = -60 + delta = 1 + + # ---------------- + # 1. mid range + # ---------------- + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + top_level: 500, + bottom_level: 900 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",1) + + # global attributes + _check_hov_global_attr_vert(fn_name, 1, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 24, 3, 0, fn_name, 1) + + # ------------------------ + # 2. near bottom range + # ------------------------ + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + top_level: 1022, + bottom_level: 1100 + ) + #examine(nc) + #sleep(1000) + + # global attributes + _check_hov_global_attr_vert(fn_name, 2, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + # define variable to be checked + setcurrent(nc,"t") + + # global attributes + _check_hov_global_attr_vert(fn_name, 2, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + # attributes of a variable + attr = attributes(nc) + assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes", 2) + assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name", 2) + + # t + vals_ref = |294.541168212891, 294.05841784515, 295.274291992188, + 294.329271274914, 293.82236835103, 295.128666097709| + + ref = (var_name: "t", + dim_names: ["vertical", "time"], + dim_values: [2, 3], + values: vals_ref) + check_xs_var(nc, ref, fn_name & ": var=t",2) + + # vertical + vals_ref = |1024.20184845339, 1021.65838120911| + + ref = (var_name: "vertical", + dim_names: ["vertical"], + dim_values: [2], + values: vals_ref) + check_xs_var(nc, ref, fn_name & ": var=vertical",2) + + # ------------------------ + # 3. near top range + # ------------------------ + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + top_level: 0.0010, + bottom_level: 0.0100033 + ) + + # global attributes + _check_hov_global_attr_vert(fn_name, 3, nc, + "AREA", " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + + # define variable to be checked + setcurrent(nc,"t") + + # attributes of a variable + attr = attributes(nc) + assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes", 2) + assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",3) + + # t + vals_ref = |215.954650878906, 214.80744934082, 214.67268371582, + 208.421432495117, 205.548202514648, 206.270797729492| + + ref = (var_name: "t", + dim_names: ["vertical", "time"], + dim_values: [2, 3], + values: vals_ref) + check_xs_var(nc, ref, fn_name & ": var=t",3) + + # vertical + vals_ref = |0.0255130302906036, 0.010001825094223| + + ref = (var_name: "vertical", + dim_names: ["vertical"], + dim_values: [2], + values: vals_ref) + check_xs_var(nc, ref, fn_name & ": var=vertical",3) + + +end test_scalar_ml_to_pl_range + +function test_scalar_ml_to_pl_extrapolate() + + fn_name = "scalar_ml_to_pl_extrapolate" + + # read input grib data + data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) + + # read reference data + nc_ref = read("hovvert_ml_pl_extra_ref_1.nc") + + lat = 30 + lon = 60 + delta = 1 + + # ----------------------------- + # 1. No extrapolation + # ----------------------------- + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + vertical_coordinate_extrapolate: "off", + top_level: 0.01, + bottom_level: 1015 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",1) + + # global attributes + _check_hov_global_attr_vert(fn_name, 1, nc, + "AREA", " 31.00/ 59.00/ 29.00/ 61.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 137, 3, 0, fn_name, 1) + + # ------------------------------------- + # 2. Extrapolate: linear, top+bottom + # -------------------------------------- + + # read reference data + nc_ref = read("hovvert_ml_pl_extra_ref_2.nc") + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + vertical_coordinate_extrapolate: "on", + vertical_coordinate_extrapolate_mode: "linear", + vertical_coordinate_extrapolate_fixed_sign: "on", + top_level: 0.005, + bottom_level: 1000 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",2) + + # global attributes + _check_hov_global_attr_vert(fn_name, 2, nc, + "AREA", " 31.00/ 59.00/ 29.00/ 61.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 139, 3, 0, fn_name, 2) + + # ------------------------------------- + # 3. Extrapolate: constant, top+bottom + # -------------------------------------- + + # read reference data + nc_ref = read("hovvert_ml_pl_extra_ref_3.nc") + + # compute hovmoeller and save it in a netcdf file + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + vertical_coordinate_extrapolate: "on", + vertical_coordinate_extrapolate_mode: "constant", + top_level: 0.005, + bottom_level: 1000 + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",3) + + # global attributes + _check_hov_global_attr_vert(fn_name, 3, nc, + "AREA", " 31.00/ 59.00/ 29.00/ 61.00", "PRESSURE", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 139, 3, 0, fn_name, 3) + +end test_scalar_ml_to_pl_extrapolate + + +function test_scalar_ml_input_methods() + fn_name = "scalar_ml_input_methods" + + # read input grib data + data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) + + # read reference data + nc_ref = read("hovvert_ml_pl_ref.nc") + + lat = 30 + lon = -60 + delta = 1 + + methods = ["area", "nearest_gridpoint", "point"] + + for i=1 to 3 do + + if methods[i] = "area" then + nc = mhovmoeller_vertical( + area : [lat-delta,lon-delta,lat+delta,lon+delta], + vertical_level_type : "pressure", + data : data, + bottom_level: 1100 + ) + else if methods[i] = "nearest_gridpoint" then + nc = mhovmoeller_vertical( + input_method: "nearest_gridpoint", + point: [lat, lon], + vertical_level_type : "pressure", + data : data, + bottom_level: 1100 + ) + else if methods[i] = "point" then + nc = mhovmoeller_vertical( + input_method: "point", + point: [lat, lon], + vertical_level_type : "pressure", + data : data, + bottom_level: 1100 + ) + end if + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",i) + + + # global attributes + if methods[i] = "area" then + _check_hov_global_attr_vert(fn_name, i, nc, + uppercase(methods[i]), " 31.00/ -61.00/ 29.00/ -59.00", "PRESSURE", "MEAN") + else + _check_hov_global_attr_vert(fn_name, i, nc, + uppercase(methods[i]), " 30.00/ -60.00/ 0.00/ 0.00", "PRESSURE", "MEAN") + end if + + _check_hov_data(nc, nc_ref, "vertical", 137, 3, 0, fn_name, i) + + end for + +end test_scalar_ml_input_methods diff -Nru metview-5.17.4/metview/test/macros/hovvert.mv metview-5.19.2/metview/test/macros/hovvert.mv --- metview-5.17.4/metview/test/macros/hovvert.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/hovvert.mv 1970-01-01 00:00:00.000000000 +0000 @@ -1,921 +0,0 @@ -# Metview Macro - -# **************************** LICENSE START *********************************** -# -# Copyright 2022 ECMWF. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ - -include "test_utils.mv" - -# pressure leveles -test_scalar_pl() - -# model level to pressure -test_scalar_ml_to_pl() -test_scalar_ml_to_pl_missing() -test_scalar_ml_to_pl_subset() -test_scalar_ml_to_pl_range() -test_scalar_ml_to_pl_extrapolate() -test_scalar_ml_input_methods() - -# model level to height (param) -test_scalar_ml_to_hl() -test_scalar_ml_to_hl_extrapolate() - - -function test_scalar_pl() - - fn_name = "scalar_pl" - - # read input grib data - data = read("t_timeseries.grb") - - # read reference data - nc_ref = read("hovvert_pl_ref.nc") - - # compute hovmoeller - nc = mhovmoeller_vertical( - area : [33,-27,75,45], - data : data - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes") - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type") - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") - - # t - setcurrent(nc_ref,"t") - vals_ref = values(nc_ref) - - ref = (var_name: "t", - dim_names: ["vertical", "time"], - dim_values: [6, 5], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=t",1) - - # vertical - setcurrent(nc_ref,"vertical") - vals_ref = values(nc_ref) - - ref = (var_name: "vertical", - dim_names: ["vertical"], - dim_values: [6], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=vertical",1) - - # time - setcurrent(nc_ref,"time") - vals_ref = values(nc_ref) - - ref = (var_name: "time", - dim_names: ["time"], - dim_values: [5], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=time",1) - -end test_scalar_pl - -function test_scalar_ml_to_pl() - - fn_name = "scalar_ml_to_pl" - - # read input grib data - data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) - - # read reference data - nc_ref = read("hovvert_ml_pl_ref.nc") - - lat = 30 - lon = -60 - delta = 1 - - # ----------------------------- - # 1. original field ordering - # ----------------------------- - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - bottom_level : 1100 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes") - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type") - assert_equal(gattr.vertical_type,"PRESSURE",fn_name & ": global attribute vertical_type") - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") - - _check_hovvert(nc, nc_ref, 137, fn_name, 1) - - # ----------------------------------- - # 2. Change order of fields in input - # ----------------------------------- - - data1 = sort(data, ["levelist", "step"], [">", ">"]) + 0 - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data1, - bottom_level : 1100 - ) - - _check_hovvert(nc, nc_ref, 137, fn_name, 2) - - # ------------------ - # 3. fixed lnsp - #------------------- - - nc_ref = read("hovvert_ml_pl_fixed_lnsp_ref.nc") - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - bottom_level : 1100, - use_fixed_surface_pressure: "on", - fixed_surface_pressure: 1013.25 - ) - - _check_hovvert(nc, nc_ref, 137, fn_name, 3) - - # ---------------------------------- - # 4. fixed lnsp, default value - #----------------------------------- - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - bottom_level : 1100, - use_fixed_surface_pressure: "on" - ) - _check_hovvert(nc, nc_ref, 137, fn_name, 4) - -end test_scalar_ml_to_pl - -function test_scalar_ml_to_pl_missing() - fn_name = "scalar_ml_to_pl_missing" - - # read input grib data - data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) - - # read reference data - nc_ref = read("hovvert_ml_pl_missing_ref_1.nc") - - lat = 30 - lon = -60 - delta = 1 - - # --------------------------------- - # 1. no missing value in output - # --------------------------------- - - # Add missing values - f = data[134] - f = bitmap(f>0,1) - data_m = data + 0 - data_m[134] = f - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data_m, - bottom_level: 1100 - ) - - # t - setcurrent(nc_ref,"t") - vals_ref = values(nc_ref) - num = count(vals_ref) - - ref = (var_name: "t", - dim_names: ["vertical", "time"], - dim_values: [137, 3], - values: vals_ref) - check_xs_var_missing(nc, ref, 1e-3, fn_name & ": var=t",1) - - # --------------------------------- - # 2. missing value in output - # --------------------------------- - - # read reference data - nc_ref = read("hovvert_ml_pl_missing_ref_2.nc") - - # Add missing values - data_m = data + 0 - f = bitmap(data_m[118, 124] > 0, 1) - for i=1 to count(f) do - data_m[118+i-1] = f[i] - end for - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data_m, - bottom_level: 1100 - ) - - # t - setcurrent(nc_ref,"t") - vals_ref = values(nc_ref) - num = count(vals_ref) - - ref = (var_name: "t", - dim_names: ["vertical", "time"], - dim_values: [137, 3], - values: vals_ref) - check_xs_var_missing(nc, ref, 1e-3, fn_name & ": var=t",2) - -end test_scalar_ml_to_pl_missing - -function test_scalar_ml_to_pl_subset() - fn_name = "scalar_ml_to_pl_subset" - - # read input grib data - data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) - - # read reference data - nc_ref = read("hovvert_ml_pl_subset_ref.nc") - - lat = 30 - lon = -60 - delta = 1 - - lnsp = read(data:data, param: "lnsp") - t = read(data:data, param: "t", levelist: ["90","TO","137"]) - data_s = lnsp & t - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data_s, - bottom_level: 1100 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes") - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type") - assert_equal(gattr.vertical_type,"PRESSURE",fn_name & ": global attribute vertical_type") - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") - - _check_hovvert(nc, nc_ref, 48, fn_name, 1) - -end test_scalar_ml_to_pl_subset - -function test_scalar_ml_to_pl_range() - - fn_name = "scalar_ml_to_pl_range" - - # read input grib data - data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) - - # read reference data - nc_ref = read("hovvert_ml_pl_range_ref.nc") - - lat = 30 - lon = -60 - delta = 1 - - # ---------------- - # 1. mid range - # ---------------- - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - top_level: 500, - bottom_level: 900 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes") - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type") - assert_equal(gattr.vertical_type,"PRESSURE",fn_name & ": global attribute vertical_type") - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") - - _check_hovvert(nc, nc_ref, 24, fn_name, 1) - - # ------------------------ - # 2. near bottom range - # ------------------------ - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - top_level: 1022, - bottom_level: 1100 - ) - #examine(nc) - #sleep(1000) - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes", 2) - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name", 2) - - # t - vals_ref = |294.541168212891, 294.05841784515, 295.274291992188, - 294.329271274914, 293.82236835103, 295.128666097709| - - ref = (var_name: "t", - dim_names: ["vertical", "time"], - dim_values: [2, 3], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=t",2) - - # vertical - vals_ref = |1024.20184845339, 1021.65838120911| - - ref = (var_name: "vertical", - dim_names: ["vertical"], - dim_values: [2], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=vertical",2) - - # ------------------------ - # 3. near top range - # ------------------------ - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - top_level: 0.0010, - bottom_level: 0.0100033 - ) - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes", 2) - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",3) - - # t - vals_ref = |215.954650878906, 214.80744934082, 214.67268371582, - 208.421432495117, 205.548202514648, 206.270797729492| - - ref = (var_name: "t", - dim_names: ["vertical", "time"], - dim_values: [2, 3], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=t",3) - - # vertical - vals_ref = |0.0255130302906036, 0.010001825094223| - - ref = (var_name: "vertical", - dim_names: ["vertical"], - dim_values: [2], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=vertical",3) - - -end test_scalar_ml_to_pl_range - -function test_scalar_ml_to_pl_extrapolate() - - fn_name = "scalar_ml_to_pl_extrapolate" - - # read input grib data - data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) - - # read reference data - nc_ref = read("hovvert_ml_pl_extra_ref_1.nc") - - lat = 30 - lon = 60 - delta = 1 - - # ----------------------------- - # 1. No extrapolation - # ----------------------------- - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - vertical_coordinate_extrapolate: "off", - top_level: 0.01, - bottom_level: 1015 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes") - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type") - assert_equal(gattr.vertical_type,"PRESSURE",fn_name & ": global attribute vertical_type") - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") - - _check_hovvert(nc, nc_ref, 137, fn_name, 1) - - # ------------------------------------- - # 2. Extrapolate: linear, top+bottom - # -------------------------------------- - - # read reference data - nc_ref = read("hovvert_ml_pl_extra_ref_2.nc") - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - vertical_coordinate_extrapolate: "on", - vertical_coordinate_extrapolate_mode: "linear", - vertical_coordinate_extrapolate_fixed_sign: "on", - top_level: 0.005, - bottom_level: 1000 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",2) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes",2) - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type",2) - assert_equal(gattr.vertical_type,"PRESSURE",fn_name & ": global attribute vertical_type",2) - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes",2) - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",2) - - _check_hovvert(nc, nc_ref, 139, fn_name, 2) - - # ------------------------------------- - # 3. Extrapolate: constant, top+bottom - # -------------------------------------- - - # read reference data - nc_ref = read("hovvert_ml_pl_extra_ref_3.nc") - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - vertical_coordinate_extrapolate: "on", - vertical_coordinate_extrapolate_mode: "constant", - top_level: 0.005, - bottom_level: 1000 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",3) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes",3) - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type",3) - assert_equal(gattr.vertical_type,"PRESSURE",fn_name & ": global attribute vertical_type",3) - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes",3) - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",3) - - _check_hovvert(nc, nc_ref, 139, fn_name, 3) - -end test_scalar_ml_to_pl_extrapolate - - -function test_scalar_ml_input_methods() - fn_name = "scalar_ml_input_methods" - - # read input grib data - data = read(source: "hov_ml_input.grib", param: ["t","lnsp"]) - - # read reference data - nc_ref = read("hovvert_ml_pl_ref.nc") - - lat = 30 - lon = -60 - delta = 1 - - for i=1 to 3 do - - if i = 1 then - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "pressure", - data : data, - bottom_level: 1100 - ) - else if i = 2 then - nc = mhovmoeller_vertical( - input_method: "nearest_gridpoint", - point: [lat, lon], - vertical_level_type : "pressure", - data : data, - bottom_level: 1100 - ) - else if i = 3 then - nc = mhovmoeller_vertical( - input_method: "point", - point: [lat, lon], - vertical_level_type : "pressure", - data : data, - bottom_level: 1100 - ) - end if - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",i) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes",i) - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type",i) - assert_equal(gattr.vertical_type,"PRESSURE",fn_name & ": global attribute vertical_type",i) - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes",i) - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",i) - - _check_hovvert(nc, nc_ref, 137, fn_name, i) - - end for - -end test_scalar_ml_input_methods - -function test_scalar_ml_to_hl() - - fn_name = "scalar_ml_to_hl" - - # read input grib data - data = read("hov_ml_input.grib") - t = read(data: data, param: "t") - z = read(data: data, param: "z")/9.81 - lnsp = read(data: data, param: "lnsp") - - # read reference data - nc_ref = read("hovvert_ml_hl_ref.nc") - - lat = 30 - lon = -60 - delta = 1 - - # ----------------------------- - # 1. original field ordering - # ----------------------------- - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "user", - vertical_coordinate_param: 129, - data : t & z, - top_level: 50000, - bottom_level: 0 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes") - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type") - assert_equal(gattr.vertical_type,"USER",fn_name & ": global attribute vertical_type") - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes") - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name") - - _check_hovvert(nc, nc_ref, 126, fn_name, 1) - - # ----------------------------------- - # 2. Change order of fields in input - # ----------------------------------- - - data1 = sort(data, ["levelist", "step"], [">", ">"]) + 0 - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "user", - vertical_coordinate_param: 129, - data : t & z, - top_level: 50000, - bottom_level: 0 - ) - - _check_hovvert(nc, nc_ref, 126, fn_name, 2) - -end test_scalar_ml_to_hl - -function test_scalar_ml_to_hl_extrapolate() - - fn_name = "scalar_ml_to_hl_extrapolate" - - # read input grib data - data = read("hov_ml_input.grib") - t = read(data: data, param: "t") - z = read(data: data, param: "z")/9.81 - lnsp = read(data: data, param: "lnsp") - - # read reference data - nc_ref = read("hovvert_ml_hl_extra_ref_1.nc") - - lat = 30 - lon = 60 - delta = 1 - - # ----------------------------- - # 1. No extrapolation - # ----------------------------- - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "user", - vertical_coordinate_param: 129, - data : t & z, - vertical_coordinate_extrapolate: "off", - top_level: 20000, - bottom_level: 0 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes",1) - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type",1) - assert_equal(gattr.vertical_type,"USER",fn_name & ": global attribute vertical_type",1) - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes",1) - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",1) - - _check_hovvert(nc, nc_ref, 89, fn_name, 1) - - # ------------------------------------ - # 2. Extrapolate: linear, top+bottom - # ------------------------------------ - - # read reference data - nc_ref = read("hovvert_ml_hl_extra_ref_2.nc") - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "user", - vertical_coordinate_param: 129, - data : t & z, - vertical_coordinate_extrapolate: "on", - vertical_coordinate_extrapolate_mode: "linear", - vertical_coordinate_extrapolate_fixed_sign: "on", - top_level: 100000, - bottom_level: 0 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",2) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes",2) - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type",2) - assert_equal(gattr.vertical_type,"USER",fn_name & ": global attribute vertical_type",2) - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes",2) - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",2) - - _check_hovvert(nc, nc_ref, 139, fn_name, 2) - - # ------------------------------------ - # 3. Extrapolate: constant, top+bottom - # ------------------------------------ - - # read reference data - nc_ref = read("hovvert_ml_hl_extra_ref_3.nc") - - # compute hovmoeller and save it in a netcdf file - nc = mhovmoeller_vertical( - area : [lat-delta,lon-delta,lat+delta,lon+delta], - vertical_level_type : "user", - vertical_coordinate_param: 129, - data : t & z, - vertical_coordinate_extrapolate: "on", - vertical_coordinate_extrapolate_mode: "constant", - top_level: 100000, - bottom_level: 0 - ) - - # variables - vars_ref = ["time", "vertical", "t"] - vars = variables(nc) - assert_equal(vars, vars_ref,fn_name & ": vars",3) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),8,fn_name & ": count global attributes",3) - assert_equal(gattr.type,"VERTICAL_HOVM",fn_name & ": global attribute type",3) - assert_equal(gattr.vertical_type,"USER",fn_name & ": global attribute vertical_type",3) - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - assert_equal(count(keywords(attr)),6,fn_name & ": count t attributes",3) - assert_equal(attr.long_name,"Temperature",fn_name & ": attribute t long_name",3) - - _check_hovvert(nc, nc_ref, 139, fn_name, 3) - -end test_scalar_ml_to_hl_extrapolate - -function _check_hovvert(nc, nc_ref, lev_num, fn_name, id) - - # t - setcurrent(nc_ref,"t") - vals_ref = values(nc_ref) - - ref = (var_name: "t", - dim_names: ["vertical", "time"], - dim_values: [lev_num, 3], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=t",id) - - # vertical - setcurrent(nc_ref,"vertical") - vals_ref = values(nc_ref) - - ref = (var_name: "vertical", - dim_names: ["vertical"], - dim_values: [lev_num], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=vertical",id) - - # time - setcurrent(nc_ref,"time") - vals_ref = values(nc_ref) - - ref = (var_name: "time", - dim_names: ["time"], - dim_values: [3], - values: vals_ref) - check_xs_var(nc, ref, fn_name & ": var=time",id) - -end _check_hovvert_res - -function _plot_hov_nc(nc_lst) - - view = cartesianview( - x_automatic: "on", - x_axis_type: "date", - y_min: 1000, - y_max: 100 - ) - - cols = ["blue", "red"] - plt_lst = [] - for i=1 to count(nc_lst) do - - vis = netcdf_visualiser( - netcdf_plot_type: "xy_matrix", - netcdf_x_variable: "time", - netcdf_y_variable: "vertical", - netcdf_value_variable: "t", - netcdf_data: nc_lst[i] - ) - - cont = mcont( - contour_line_colour: cols[i], - contour_highlight: "off", - contour_level_selection_type: "interval", - contour_interval: 5) - - - plt_lst = plt_lst & [vis, cont] - end for - - plot(view, plt_lst) - -end _plot_hov_nc \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/hovvert_pl.mv metview-5.19.2/metview/test/macros/hovvert_pl.mv --- metview-5.17.4/metview/test/macros/hovvert_pl.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/hovvert_pl.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,46 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2022 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include "test_utils.mv" +include "hov_utils.mv" + +# pressure leveles +test_scalar_pl() + + +function test_scalar_pl() + + fn_name = "scalar_pl" + + # read input grib data + data = read("t_timeseries.grb") + + # read reference data + nc_ref = read("hovvert_pl_ref.nc") + + # compute hovmoeller + nc = mhovmoeller_vertical( + area : [33,-27,75,45], + data : data + ) + + # variables + vars_ref = ["time", "vertical", "t"] + vars = variables(nc) + assert_equal(vars, vars_ref,fn_name & ": vars",1) + + # global attributes + _check_hov_global_attr_vert(fn_name, 1, nc, + "AREA", " 75.00/ -27.00/ 33.00/ 45.00", "AS_IN_DATA", "MEAN") + + _check_hov_data(nc, nc_ref, "vertical", 6, 5, 0, fn_name, 1) + +end test_scalar_pl diff -Nru metview-5.17.4/metview/test/macros/inline_fortran.mv metview-5.19.2/metview/test/macros/inline_fortran.mv --- metview-5.17.4/metview/test/macros/inline_fortran.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/inline_fortran.mv 2023-07-15 08:28:47.000000000 +0000 @@ -55,7 +55,7 @@ parameter(isize=50) integer i - real r(isize) + real*8 r(isize) i = isize diff -Nru metview-5.17.4/metview/test/macros/pottf.mv metview-5.19.2/metview/test/macros/pottf.mv --- metview-5.17.4/metview/test/macros/pottf.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/pottf.mv 2023-07-15 08:28:47.000000000 +0000 @@ -181,3 +181,39 @@ end test_theta_field +#==================================================== +# +# Functions to generate test reference data +# +#==================================================== + +function generate_test_theta_pl_field_reference() + + f = read("theta_input_pl.grib") + t = read(data:f, param: "t") + q = read(data:f, param: "q") + + r1=eqpott_p(temperature: t, humidity: q) + r2=seqpott_p(temperature: t) + + write("theta_pl_ref.grib",r1 & r2) + + +end generate_test_theta_pl_field_reference + +function generate_test_theta_ml_field_reference() + + lev = [135, 110] + f = read("thermo_profile.grib") + t = read(data:f, param: "t", levelist: lev) + q = read(data:f, param: "q", levelist: lev) + lnsp = read(data:f, param: "lnsp") + + # visually checked + r1=pott_m(temperature: t, lnsp: lnsp) + r2=eqpott_m(temperature: t, humidity: q, lnsp: lnsp) + r3=seqpott_m(temperature: t, lnsp: lnsp) + + write("theta_ml_ref.grib",r1 & r2 & r3) + +end generate_test_theta_ml_field_reference diff -Nru metview-5.17.4/metview/test/macros/regrid.mv metview-5.19.2/metview/test/macros/regrid.mv --- metview-5.17.4/metview/test/macros/regrid.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/regrid.mv 2023-07-15 08:28:47.000000000 +0000 @@ -315,3 +315,16 @@ assert_equal(grib_get_double(r1, 'longitudeOfLastGridPointInDegrees'), 356, 'pre-globalise - longitudeOfLastGridPointInDegrees') +# basic_angle +input_for_basic_angle = read('z_ml137_ref.grib') +r1 = regrid(data: input_for_basic_angle[1], grid:[0.75,0.75], basic_angle: 'decimal') +assert_equal(grib_get_double(r1, 'latitudeOfFirstGridPoint'), 90000000, 'input_for_basic_angle - decimal - latitudeOfFirstGridPoint') +assert_equal(grib_get_double(r1, 'iDirectionIncrement'), 750000, 'input_for_basic_angle - decimal - iDirectionIncrement') +assert_equal(grib_get_double(r1, 'basicAngleOfTheInitialProductionDomain'), 0, 'input_for_basic_angle - decimal - basicAngleOfTheInitialProductionDomain') +assert_equal(grib_get_double(r1, 'subdivisionsOfBasicAngle'), 2147483647, 'input_for_basic_angle - decimal - subdivisionsOfBasicAngle') # MISSING + +r1 = regrid(data: input_for_basic_angle[1], grid:[0.75,0.75], basic_angle: 'fraction') +assert_equal(grib_get_double(r1, 'latitudeOfFirstGridPoint'), 120, 'input_for_basic_angle - fraction - latitudeOfFirstGridPoint') +assert_equal(grib_get_double(r1, 'iDirectionIncrement'), 1, 'input_for_basic_angle - fraction - iDirectionIncrement') +assert_equal(grib_get_double(r1, 'basicAngleOfTheInitialProductionDomain'), 3, 'input_for_basic_angle - fraction - basicAngleOfTheInitialProductionDomain') +assert_equal(grib_get_double(r1, 'subdivisionsOfBasicAngle'), 4, 'input_for_basic_angle - fraction - subdivisionsOfBasicAngle') # MISSING diff -Nru metview-5.17.4/metview/test/macros/test_utils.mv metview-5.19.2/metview/test/macros/test_utils.mv --- metview-5.17.4/metview/test/macros/test_utils.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/test_utils.mv 2023-07-15 08:28:47.000000000 +0000 @@ -629,4 +629,4 @@ assert_equal(gattr.Coordinates, glob_attr[2], fn_name & ' - global_attribute Coordinates',idNum) end if assert(gattr._FILL_VALUE > 1.6e+38,fn_name & ' - global_attribute _FILL_VALUE',idNum) -end check_thermo_profile \ No newline at end of file +end check_thermo_profile diff -Nru metview-5.17.4/metview/test/macros/thermo_data.mv metview-5.19.2/metview/test/macros/thermo_data.mv --- metview-5.17.4/metview/test/macros/thermo_data.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_data.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,243 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" + +test_thermo_bufr() +test_thermo_bufr_wigos() +test_thermo_grib() +test_thermo_data_info() + +global ASSERT_EQUAL_EPS = 1E-4 # wil be used by assert_equal() + +function test_thermo_bufr() + + fn_name = "thermo_bufr" + data_bufr=read("temp_10.bufr") + prof_ref=read("thermo_bufr_ref.nc") + + # 1 - use station db + + # extract thermo profile + prof_1 = thermo_bufr( + data : data_bufr, + station : stations( + search_key : "ident", + ident : 1400 + ) + ) + + # 2 - do not use db + # real coords: [56.9,3.35] + prof_2 = thermo_bufr( + data : data_bufr, + station : stations( + search_stations_database : "no", + name : "", + position : [56.86,3.32], + threshold: 0.05 + ) + ) + + # 3 - coords + # real coords: [56.9,3.35] + prof_3 = thermo_bufr( + data : data_bufr, + point_selection: "coordinates", + coordinates: [56.86,3.32], + threshold: 0.05 + ) + + # 4 - coords, default threshold + # real coords: [56.9,3.35] + prof_4 = thermo_bufr( + data : data_bufr, + point_selection: "coordinates", + coordinates: [56.81,3.26] + ) + + # 5 - ident + prof_5 = thermo_bufr( + data : data_bufr, + point_selection: "wmo_ident", + wmo_ident: 1400 + ) + + # 6 - name + # it does not have a name + + profs = [prof_1, prof_2, prof_3, prof_4, prof_5] + + for i=1 to count(profs) do + prof = profs[i] + check_thermo_profile(prof, prof_ref, ['t','td','pres','z','u','v','xwind'], + 72, 13, [1400, "56.9/3.35"], fn_name, i) + end for + +end test_thermo_bufr + +function test_thermo_bufr_wigos() + + fn_name = "thermo_bufr_wigos" + + data_bufr=read("temp_wigos.bufr") + prof_ref=read("thermo_bufr_wigos_ref.nc") + + # + # this station: + # - is not in the stations DB + # - does not have a wmo name or id + + # 1 - do not use db + # real coords: [-2.18165, -59.0218] + prof_1 = thermo_bufr( + data : data_bufr, + station : stations( + search_stations_database : "no", + name : "", + position : [-2.15, -59.04], + threshold: 0.05 + ) + ) + + # 2 - coords + # real coords: [-2.18165, -59.0218] + prof_2 = thermo_bufr( + data : data_bufr, + point_selection: "coordinates", + coordinates: [-2.15, -59.04], + threshold: 0.05 + ) + + # 3 - coords, default threshold + # real coords: [-2.18165, -59.0218] + prof_3 = thermo_bufr( + data : data_bufr, + point_selection: "coordinates", + coordinates: [-2.15, -59.04] + ) + + # 4 - wigos + prof_4 = thermo_bufr( + data : data_bufr, + point_selection: "wigos", + wigos_local_name: "ATTO" + ) + + # 5 - wigos + prof_5 = thermo_bufr( + data : data_bufr, + point_selection: "wigos", + wigos_issuer: 76, + wigos_issue_number: 0, + wigos_local_name: "ATTO" + ) + + profs = [prof_1, prof_2, prof_3, prof_4, prof_5] + + for i=1 to count(profs) do + + prof = profs[i] + check_thermo_profile(prof, prof_ref, ['t','td','pres','z','u','v','xwind'], + 693, 13, [0, "-2.18165/-59.0218"], fn_name, i) + end for + +end test_thermo_bufr_wigos + +function test_thermo_grib() + + fn_name = "thermo_grib" + data_grb=read("thermo_profile.grib") + prof_ref=read("thermo_grib_ref.nc") + + # 1 - nearest gridpoint + prof_1 = thermo_grib( + data : data_grb, + coordinates : [0,-60] + ) + + # 2 - stations + prof_2 = thermo_grib( + data : data_grb, + point_selection: "station", + point_extraction: "nearest_gridpoint", + station : stations( + search_stations_database : "no", + name : "", + position : [0.02,-59.98] + ) + ) + + + profs = [prof_1, prof_2] + for i=1 to count(profs) do + prof = profs[i] + check_thermo_profile(prof, prof_ref, ['t','td','pres'], 108, 17, + [nil, "0/-60"], fn_name, i) + end for + + # 3 - AREA AVERAGE + + prof_ref = read("thermo_grib_area_ref.nc") + prof = thermo_grib( + data : data_grb, + point_selection: "area_average", + area_avreage: [0, -50, -20, -30] + ) + + check_thermo_profile(prof, prof_ref, ['t','td','pres'], 108, 17, + [nil, "0/-50/-20/-30"], fn_name, 3) + + +end test_thermo_grib + +function test_thermo_data_info() + + fn_name = "thermo_data_info" + + # BUFR + prof=read("thermo_bufr_ref.nc") + + info1 = thermo_data_info(prof) + info2= thermo_data_info(prof, 1) + info3= thermo_data_info(prof, "time_dim_index", 1) + info_lst = [info1, info2, info3] + + for i=1 to count(info_lst) do + info = info_lst[i] + assert_equal(info.lat, 56.9, fn_name & " lat", i) + assert_equal(info.lon, 3.35, fn_name & " lon", i) + assert_equal(info.station,1400, fn_name & " station", i) + assert_equal(info.date,20081208, fn_name & " date", i) + assert_equal(info.time, 1200, fn_name & " time", i) + assert_equal(info.base_date,2008-12-08 12:00:00,fn_name & " base_date", i) + end for + + # GRIB forecast + data_grb=read("thermo_profile_baltic.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [56.5, 24.7], + data : data_grb + ) + info = thermo_data_info(prof) + assert_equal(info.lat, 56.5, fn_name & " lat", 4) + assert_equal(info.lon, 24.7, fn_name & " lon", 4) + assert_equal(info.date,20170810, fn_name & " date", 4) + assert_equal(info.time, 1200, fn_name & " time", 4) + assert_equal(info.step, 52, fn_name & " step", 4) + assert_equal(info.base_date,2017-08-10 12:00:00, fn_name & " base_date", 4) + assert_equal(info.valid_date,2017-08-12 16:00:00,fn_name & " valid_date", 4) + + +end test_thermo_data_info diff -Nru metview-5.17.4/metview/test/macros/thermo_humidity.mv metview-5.19.2/metview/test/macros/thermo_humidity.mv --- metview-5.17.4/metview/test/macros/thermo_humidity.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_humidity.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,806 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" + +test_values() +test_relative_humidity_from_dewpoint() +test_dewpoint_from_relative_humidity() +test_dewpoint_from_specific_humidity() +test_saturation_vapour_pressure() +test_saturation_mixing_ratio() +test_specific_humidity_from_dewpoint() +test_specific_humidity_from_relative_humidity() +test_virtual_temperature() +test_vapour_pressure() +test_relative_humidity_from_specific_humidity() +test_rhu_field() + + +global ASSERT_EQUAL_EPS = 1E-4 # wil be used by assert_equal() + +function test_values() + + #-------------------------------- + # potential temperature + #-------------------------------- + t = 25 + 273.16 + p = 100500 + ref = 24.57557 + 273.16 + th = potential_temperature(t,p) + assert_equal(th,ref,"potential_temperature",1) + + ref = t + t = temperature_from_potential_temperature(th,p) + assert_equal(t,ref,"temperature_from_potential_temperature",1) + + #-------------------------------- + # equivalent potential temperature + #-------------------------------- + t = 30 + 273.16 + td = 26 + 273.16 + p = 100500 + ref = 367.178567159 + th = __equivalent_potential_temperature(t,td,p) + assert_equal(th,ref,"equivalent_potential_temperature",1) + + t = 30 + 273.16 + td = 36 + 273.16 + p = 100500 + th = __equivalent_potential_temperature(t,td,p) + assert_equal(th, 423.865175401,"equivalent_potential_temperature",2) + + th = 93.420887 + 273.16 + p = 100500 + ref = 26.8310546875 + 273.16 + t = __temperature_from_equivalent_potential_temperature(th,p, "old") + assert_equal(t,ref,"t_from_equivalent_potential_temperature",3) + + th = 93.420887 + 273.16 + p = 85000 + ref = 21.2353515625 + 273.16 + t = __temperature_from_equivalent_potential_temperature(th,p, "old") + assert_equal(t,ref,"t_from_equivalent_potential_temperature",4) + + #-------------------------------- + # mixing_ratio + #-------------------------------- + + q = 0.018 + ref = 0.0183299389002 + mr = mixing_ratio(q) + assert_equal(mr,ref,"mixing_ratio",1) + + #-------------------------------- + # lifted condensation level + #-------------------------------- + t = 30 + 273.16 + td = 26 + 273.16 + p = 100500 + v = lifted_condensation_level(t, td, p) + assert(v <> nil, "lcl",1) + assert_equal(v.t,298.182282019,"lcl t",1) + assert_equal(v.p,94840.0417043,"lcl p",1) + + t = 30 + 273.16 + td = 36 + 273.16 + p = 100500 + v = lifted_condensation_level(t, td, p) + assert_equal(v.t, 310.73986038, "lcl t",2) + assert_equal(v.p, 109576.487299, "lcl p",2) + + t = 50 + td = 36 + 273.16 + p = 100500 + v = lifted_condensation_level(t, td, p) + assert(v = nil, "lifted_condensation_level",5) + +end test_values + +function test_relative_humidity_from_dewpoint() + # numbers + t = |20, 20, 0, 35, 5, -15, 25| + td = |20, 10, -10, 32, -15, -24, -3| + # reference was tested with an online relhum calculator at: + # https://bmcnoldy.rsmas.miami.edu/Humidity.html + v_ref = |100, 52.5224, 46.8714, 84.5391, 21.9244, 46.1081, 15.4779| + for i=1 to count(t) do + v = relative_humidity_from_dewpoint(t[i] + 273.16, td[i] + 273.16) + assert_equal(v, v_ref[i], "relative_humidity_from_dewpoint number",i) + end for + + # fields + data_grb=read(source: "td_2m.grib") + t = read(data: data_grb, param: "2t") + td = read(data: data_grb, param: "2d") + + r = relative_humidity_from_dewpoint(t, td) + assert_equal(count(r), count(t), "relative_humidity_from_dewpoint field", 0) + + for i=1 to count(t) do + v = values(r[i]) + v_ref = v + t_v = values(t[i]) + td_v = values(td[i]) + for j=1 to count(v_ref) do + v_ref[j] = relative_humidity_from_dewpoint(t_v[j], td_v[j]) + end for + assert(vec_same(v, v_ref,1E-3), "relative_humidity_from_dewpoint field",i) + + # test edition and paramid + keys = grib_get(r[i], ["edition:l", "paramId:l"]) + assert_equal(keys[1][1], 2, "relative_humidity_from_dewpoint edition",1) + assert_equal(keys[1][2], 260242, "relative_humidity_from_dewpoint paramId",1) + + end for + +end test_relative_humidity_from_dewpoint + +function test_dewpoint_from_relative_humidity() + # numbers + t = |20, 20, 0, 35, 5, -15, 25| + r = |100, 52.5224, 46.8714, 84.5391, 21.9244, 46.1081, 15.4779| + v_ref = |20, 10, -10, 32, -15, -24, -3| + v_ref = v_ref + 273.16 + # reference was tested with an online relhum calculator at: + # https://bmcnoldy.rsmas.miami.edu/Humidity.html + #v_ref = |1, 0.525224, 0.468714, 0.845391, 0.219244, 0.461081, 0.154779| + + for i=1 to count(t) do + v = dewpoint_from_relative_humidity(t[i] + 273.16, r[i]) + assert_equal(v, v_ref[i], "dewpoint_from_relative_humidity number",i) + end for + + # fields + data_grb=read(source: "td_2m.grib") + t = read(data: data_grb, param: "2t") + td_ref = read(data: data_grb, param: "2d") + r = relative_humidity_from_dewpoint(t, td_ref) + + td = dewpoint_from_relative_humidity(t, r) + assert_equal(count(td), count(t), "dewpoint_from_relative_humidity field", 0) + + for i=1 to count(t) do + v = values(td[i]) + v_ref = values(td_ref[i]) + t_v = values(t[i]) + r_v = values(r[i]) + assert(vec_same(v, v_ref,1E-3), "dewpoint_from_relative_humidity field",i) + + # test edition and paramid + keys = grib_get(td[i], ["paramId:l"]) + assert_equal(keys[1][1], 168, "dewpoint_from_relative_humidity paramId",i) + end for + +end test_dewpoint_from_relative_humidity + +function test_dewpoint_from_specific_humidity() + # numbers + # reference was taken from a thermo proile (td, p) and a vertical profile (q) created + # from the same input grib for the same location. + q = |0.0169461143668741, 0.015583973727189, 0.0134912085486576, + 0.00834095469326712,0.00571847961691674, 0.00251296901842579| + p = |967.5085, 936.3775, 872.248, 756.1647, 649.157,422.4207| + v_ref = |21.78907,19.90885,16.50236,7.104064,-0.3548709, -16.37916| + p = p*100 + v_ref = v_ref + 273.16 + + # the departures are larger in the negative range! + for i=1 to count(q) do + v = dewpoint_from_specific_humidity(q[i], p[i]) + assert_equal(v, v_ref[i], 0.04, "dewpoint_from_specific_humidity number",i) + end for + + # fields - ml + data_grb =read(source: "tq_ml137.grib") + levLst = [100, 137] + q = read(data: data_grb, param: 'q', levelist: levLst) + lnsp = read(data: data_grb, param: "lnsp") + p = unipressure(lnsp, levLst) + + # ml: use lnsp + td = dewpoint_from_specific_humidity(q, lnsp) + for i=1 to count(q) do + v = values(td[i]) + q_v = values(q[i]) + p_v = values(p[i]) + v_ref = dewpoint_from_specific_humidity(q_v, p_v) + assert(vec_same(v, v_ref,0.04), "dewpoint_from_specific_humidity lnsp field-ml",i) + + # test edition and paramid + keys = grib_get(td[i], ["paramId:l"]) + assert_equal(keys[1][1], 3017, "dewpoint_from_specifc_humidity lnsp paramId-ml",i) + end for + + # ml: use pressure + td = dewpoint_from_specific_humidity(q, p) + for i=1 to count(q) do + v = values(td[i]) + q_v = values(q[i]) + p_v = values(p[i]) + v_ref = dewpoint_from_specific_humidity(q_v, p_v) + assert(vec_same(v, v_ref,0.04), "dewpoint_from_specific_humidity p field-ml",i) + + # test edition and paramid + keys = grib_get(td[i], ["paramId:l"]) + assert_equal(keys[1][1], 3017, "dewpoint_from_specifc_humidity p paramId-ml",i) + end for + + # fields - pl + data_grb =read(source: "theta_input_pl.grib") + q = read(data: data_grb, param: 'q') + p = [85000, 70000] + td = dewpoint_from_specific_humidity(q) + + for i=1 to count(q) do + v = values(td[i]) + q_v = values(q[i]) + p_v = p[i] + v_ref = dewpoint_from_specific_humidity(q_v, p_v) + assert(vec_same(v, v_ref,0.04), "dewpoint_from_specific_humidity field-pl",i) + + # test edition and paramid + keys = grib_get(td[i], ["paramId:l"]) + assert_equal(keys[1][1], 3017, "dewpoint_from_specifc_humidity paramId-pl",i) + end for + +end test_dewpoint_from_specific_humidity + +function test_saturation_vapour_pressure() + #---------------------------------------------------------------------- + # Many other computations rely on this, so has to be properly tested! + #---------------------------------------------------------------------- + + # Mixed phase + t_ref_vec = |-40,-38,-36,-34,-32,-30,-28,-26,-24,-22,-20,-18,-16,-14,-12,-10,-8,-6,-4,-2,0, + 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40| + v_ref_vec = |12.8340726457,16.0609684843,20.0235421629,24.8721311298,30.7841825909,37.9684711167, + 46.669862593,57.1746797573,69.8167282976,85.0224894683,103.505016654,125.899330626,152.861618015, + 185.091435114,223.311442013,268.237242016,320.534777756,380.76229142,449.293361074, + 526.216975169,611.21,705.924130446,813.399624196,935.089307197, + 1072.57932282,1227.59811487,1402.02574841,1597.90356355,1817.4441569,2063.04168364, + 2337.28247285,2642.95594738,2983.06583857,3360.84168562,3779.75060788,4243.50933823, + 4756.09650416,5321.76514313,5945.05543737,6630.80765319,7384.17526886| + + # single values + for i=1 to count(t_ref_vec) do + vp = saturation_vapour_pressure(t_ref_vec[i] + 273.16, "mixed") + assert_equal(vp,v_ref_vec[i],"saturation_vapour_pressure mixed number",i) + end for + + # vectors + vp = saturation_vapour_pressure(t_ref_vec + 273.16, "mixed") + assert(vec_same(vp, v_ref_vec,1E-3), "saturation_vapour_pressure mixed vector",1) + + # fields + data_grb=read(source: "thermo_profile.grib", param: 't') + t = data_grb[1,2] + svp = saturation_vapour_pressure(t, "mixed") + assert_equal(count(svp), count(t), "saturation_vapour_pressure mixed field", 0) + + for i=1 to count(t) do + t_v = values(t[i]) + v_ref = t_v + for j=1 to count(t_v) do + v_ref[j] = saturation_vapour_pressure(t_v[j], "mixed") + end for + v = values(svp[i]) + assert(vec_same(v, v_ref,1E-3), "saturation_vapour_pressure mixed field",i) + end for + + # water phase + v_ref_vec = |18.7639147696,23.0743105511,28.260605363,34.4772357923,41.9015926021,50.7367613421, + 61.2145013826,73.5984745301,88.1877340711,105.320484719,125.378123494,148.789571053,176.035902426, + 207.655285468,244.248234663,286.483187147,335.102407053,390.928223421,454.869606034, + 527.929082632,611.21,705.924130446,813.399624196,935.089307197, + 1072.57932282,1227.59811487,1402.02574841,1597.90356355,1817.4441569,2063.04168364, + 2337.28247285,2642.95594738,2983.06583857,3360.84168562,3779.75060788,4243.50933823, + 4756.09650416,5321.76514313,5945.05543737,6630.80765319,7384.17526886| + + # single values + for i=1 to count(t_ref_vec) do + vp = saturation_vapour_pressure(t_ref_vec[i] + 273.16, "water") + assert_equal(vp,v_ref_vec[i],"saturation_vapour_pressure water number",i) + end for + + # ice phase + v_ref_vec = |12.8340726457,16.0609684843,20.0235421629,24.8721311298,30.7841825909,37.9684711167, + 46.669862593,57.1746797573,69.8167282976,84.9840462955,103.126443651,124.763902033,150.495909814, + 181.011810384,217.102246154,259.671784441,309.752815283,368.52081497,437.311072795, + 517.636982085,611.21,719.961383938,846.065815462,991.967025656, + 1160.40553853,1354.44865167,1577.52277554,1833.44825493,2126.47679789,2461.33163868, + 2843.25056292,3278.03192354,3772.08377695,4332.47626905,4966.99740063,5684.21230099, + 6493.52613833,7405.25079379,8430.67542488,9582.14104197,10873.1192195| + + # single values + for i=1 to count(t_ref_vec) do + vp = saturation_vapour_pressure(t_ref_vec[i] + 273.16, "ice") + assert_equal(vp,v_ref_vec[i],"saturation_vapour_pressure ice number",i) + end for + +end test_saturation_vapour_pressure + +function test_saturation_mixing_ratio() + + fn_name = "saturation_mixing_ratio" + + # Mixed phase + p = 100500 + t_ref_vec = |-25, -10, 30| + v_ref_vec = |0.000391417464004, 0.00166452692675, 0.027420| + + # single values + for i=1 to count(t_ref_vec) do + vp = saturation_mixing_ratio(t_ref_vec[i] + 273.16, p, "mixed") + assert_equal(vp,v_ref_vec[i], fn_name & " mixed number",i) + end for + + # vectors + vp = saturation_mixing_ratio(t_ref_vec + 273.16, p, "mixed") + assert(vec_same(vp, v_ref_vec,1E-3), fn_name & " mixed vector",1) + + # fields + data_grb=read(source: "theta_input_pl.grib", param: 't') + t = data_grb[1,2] + ws = saturation_mixing_ratio(t, "mixed") + assert_equal(count(ws), count(t), fn_name & " mixed field", 0) + + for i=1 to count(t) do + t_v = values(t[i]) + p = grib_get_long(t[i], "level") * 100 + v_ref = saturation_mixing_ratio(t_v, p, "mixed") + v = values(ws[i]) + assert(vec_same(v, v_ref,1E-3), fn_name & " mixed field",i) + end for + + # water phase + p = 100500 + t_ref_vec = |-25, -10, 30| + v_ref_vec = |0.00049920601775,0.00177807450423, 0.027420| + + # single values + for i=1 to count(t_ref_vec) do + vp = saturation_mixing_ratio(t_ref_vec[i] + 273.16, p, "water") + assert_equal(vp,v_ref_vec[i], fn_name & " water number",i) + end for + + # ice phase + p = 100500 + t_ref_vec = |-25, -10, 30| + v_ref_vec = |0.000391417464004, 0.00161123690469, 0.037287799183| + + # single values + for i=1 to count(t_ref_vec) do + vp = saturation_mixing_ratio(t_ref_vec[i] + 273.16, p, "ice") + assert_equal(vp,v_ref_vec[i], fn_name & " ice number",i) + end for + +end test_saturation_mixing_ratio + +function test_specific_humidity_from_dewpoint() + # numbers + # reference was taken from a thermo profile (td, p) and a vertical profile (q) created + # from the same input grib for the same location. + td = |21.78907,19.90885,16.50236,7.104064,-0.3548709, -16.37916| + p = |967.5085, 936.3775, 872.248, 756.1647, 649.157,422.4207| + v_ref = |0.0169461143668741, 0.015583973727189, 0.0134912085486576, + 0.00834095469326712,0.00571847961691674, 0.00251296901842579| + p = p*100 + td = td + 273.16 + + # the departures are larger in the negative range! + for i=1 to count(td) do + v = specific_humidity_from_dewpoint(td[i], p[i]) + assert_equal(v, v_ref[i], 1E-5, "specific_humidity_from_dewpoint number",i) + end for + + # vectors - we now base the test on the inverse function (dewpoint_from_specific_humidity) + q = v_ref + td = dewpoint_from_specific_humidity(q, p) + q_res = specific_humidity_from_dewpoint(td, p) + assert(vec_same(q_res, q, 1E-7), "specific_humidity_from_dewpoint vector",1) + + # fields - ml + data_grb =read(source: "tq_ml137.grib") + levLst = [100, 137] + q = read(data: data_grb, param: 'q', levelist: levLst) + lnsp = read(data: data_grb, param: "lnsp") + p = unipressure(lnsp, levLst) + + # ml: use lnsp + td = dewpoint_from_specific_humidity(q, lnsp) + q_res = specific_humidity_from_dewpoint(td, lnsp) + + for i=1 to count(q) do + v = values(q_res[i]) + v_ref = values(q[i]) + assert(vec_same(v, v_ref, 1E-7), "specific_humidity_from_dewpoint lnsp field-ml",i) + + # test paramid + keys = grib_get(q_res[i], ["paramId:l"]) + assert_equal(keys[1][1], 133, "specific_humidity_from_dewpoint lnsp paramId-ml",i) + end for + + # ml: use pressure + td = dewpoint_from_specific_humidity(q, p) + q_res = specific_humidity_from_dewpoint(td, p) + + for i=1 to count(q) do + v = values(q_res[i]) + v_ref = values(q[i]) + assert(vec_same(v, v_ref, 1E-7), "specific_humidity_from_dewpoint p field-ml",i) + + # test paramid + keys = grib_get(q_res[i], ["paramId:l"]) + assert_equal(keys[1][1], 133, "specific_humidity_from_dewpoint p paramId-ml",i) + end for + + # fields - pl + data_grb =read(source: "theta_input_pl.grib") + q = read(data: data_grb, param: 'q') + p = [85000, 70000] + td = dewpoint_from_specific_humidity(q) + q_res = specific_humidity_from_dewpoint(td) + + for i=1 to count(q) do + v = values(q_res[i]) + v_ref = values(q[i]) + assert(vec_same(v, v_ref,1E-7), "dewpoint_from_specific_humidity field-pl",i) + + # test paramid + keys = grib_get(q_res[i], ["paramId:l"]) + assert_equal(keys[1][1], 133, "specific_humidity_from_dewpoint paramId-pl",i) + end for + +end test_specific_humidity_from_dewpoint + +function test_specific_humidity_from_relative_humidity() + fn_name = "specific_humidity_from_relative_humidity" + + # numbers + # input + reference was constructed taken from an analysis using vertical profile. + # The r values were slightly adjusted. + t = |-29.2884,-14.4118,-5.9235,9.72339,18.4514| + p = |300, 400, 500, 700, 850| + r = |99.7052279329, 100.259008101, 97.1595946332, 71.3793685181, 73.4141886742| + q = |0.000845416891024797, 0.00277950354211498, 0.00464489207661245, + 0.0076785187585422, 0.0114808182580539| + v_ref = q + p = p*100 + t = t + 273.16 + for i=1 to count(t) do + v = specific_humidity_from_relative_humidity(t[i], r[i] ,p[i]) + # rr = 100* vapour_pressure(q[i], p[i])/saturation_vapour_pressure(t[i], "mixed") + assert_equal(v, v_ref[i], 1E-7, fn_name & " number",i) + end for + + # vectors - we now base the test on the inverse function (from_specific_humidity) + q_res = specific_humidity_from_relative_humidity(t, r, p) + assert(vec_same(q_res, v_ref, 1E-7), fn_name & " vector",1) + + # fields - ml + data_grb = read(source: "tq_ml137.grib") + levLst = [100, 137] + t = read(data: data_grb, param: 't', levelist: levLst) + q = read(data: data_grb, param: 'q', levelist: levLst) + lnsp = read(data: data_grb, param: "lnsp") + p = unipressure(lnsp, levLst) + r = 100*vapour_pressure(q, p)/saturation_vapour_pressure(t, "mixed") + + # ml: use lnsp + q_res = specific_humidity_from_relative_humidity(t, r, lnsp) + + for i=1 to count(q) do + v = values(q_res[i]) + v_ref = values(q[i]) + assert(vec_same(v, v_ref, 1E-7), fn_name & " lnsp field-ml",i) + + # test paramid + keys = grib_get(q_res[i], ["paramId:l"]) + assert_equal(keys[1][1], 133, fn_name & " lnsp paramId-ml",i) + end for + + # ml: use pressure + q_res = specific_humidity_from_relative_humidity(t, r, p) + + for i=1 to count(q) do + v = values(q_res[i]) + v_ref = values(q[i]) + assert(vec_same(v, v_ref, 1E-7), fn_name & " p field-ml",i) + + # test paramid + keys = grib_get(q_res[i], ["paramId:l"]) + assert_equal(keys[1][1], 133, fn_name & " p paramId-ml",i) + end for + + # fields - pl + data_grb =read(source: "theta_input_pl.grib") + t = read(data: data_grb, param: 't') + q = read(data: data_grb, param: 'q') + p = [85000, 70000] + r = 100*vapour_pressure(q)/saturation_vapour_pressure(t, "mixed") + q_res = specific_humidity_from_relative_humidity(t, r) + + for i=1 to count(q) do + v = values(q_res[i]) + v_ref = values(q[i]) + assert(vec_same(v, v_ref,1E-7), fn_name & " field-pl",i) + + # test paramid + keys = grib_get(q_res[i], ["paramId:l"]) + assert_equal(keys[1][1], 133, fn_name & " paramId-pl",i) + end for + +end test_specific_humidity_from_relative_humidity + +function test_vapour_pressure() + # numbers + q = 0.018 + p = 1000*100 + ref = 2862.6621522 + vp = vapour_pressure(q, p) + assert_equal(vp,ref,"vapour_pressure",1) + + # fields - ml + data_grb =read(source: "tq_ml137.grib") + levLst = [100, 137] + q = read(data: data_grb, param: 'q', levelist: levLst) + lnsp = read(data: data_grb, param: "lnsp") + p = unipressure(lnsp, levLst) + + # ml: use lnsp + vp = vapour_pressure(q, lnsp) + for i=1 to count(q) do + v = values(vp[i]) + q_v = values(q[i]) + p_v = values(p[i]) + v_ref = vapour_pressure(q_v, p_v) + assert(vec_same(v, v_ref,0.04), "vapour_pressure lnsp field-ml",i) + + # test edition and paramid + # keys = grib_get(vp[i], ["paramId:l"]) + # assert_equal(keys[1][1], 3055, "vapour_pressure lnsp paramId-ml",i) + end for + + # ml: use pressure + vp = vapour_pressure(q, p) + for i=1 to count(q) do + v = values(vp[i]) + q_v = values(q[i]) + p_v = values(p[i]) + v_ref = vapour_pressure(q_v, p_v) + assert(vec_same(v, v_ref,0.04), "vapour_pressure p field-ml",i) + + # test edition and paramid + # keys = grib_get(vp[i], ["paramId:l"]) + # assert_equal(keys[1][1], 3055, "vapour_pressure p paramId-ml",i) + end for + + # fields - pl + data_grb =read(source: "theta_input_pl.grib") + q = read(data: data_grb, param: 'q') + p = [85000, 70000] + vp = vapour_pressure(q) + + for i=1 to count(q) do + v = values(vp[i]) + q_v = values(q[i]) + p_v = p[i] + v_ref = vapour_pressure(q_v, p_v) + assert(vec_same(v, v_ref,0.04), "vapour_pressure field-pl",i) + + # test edition and paramid + # keys = grib_get(vp[i], ["paramId:l"]) + # assert_equal(keys[1][1], 3055, "vapour_pressure paramId-pl",i) + end for + +end test_vapour_pressure + +function test_virtual_temperature() + # numbers + t = 286.4 + w = 0.02 + q = w / (1+w) + v_ref = 289.813024047 + tv = virtual_temperature(t, q) + assert_equal(tv,v_ref,"virtual_temperature number", 1) + + # vectors + t = |286.4, 293.4| + w = |0.02, 0.03| + q = w / (1+w) + v_ref = |289.813,298.594| + tv = virtual_temperature(t, q) + assert(vec_same(tv, v_ref,1E-3), "virtual_temperature vector",1) + + # fields - pl + data_grb =read(source: "theta_input_pl.grib") + t = read(data: data_grb, param: 't') + q = read(data: data_grb, param: 'q') + #w = mixing_ratio(q) + tv = virtual_temperature(t, q) + + for i=1 to count(t) do + v = values(tv[i]) + t_v = values(t[i]) + q_v = values(q[i]) + v_ref = virtual_temperature(t_v, q_v) + assert(vec_same(v, v_ref,0.04), "virtual_temperature field-pl",i) + + # test edition and paramid + keys = grib_get(tv[i], ["paramId:l"]) + assert_equal(keys[1][1], 300012, "virtual_temperature paramId-pl",i) + end for + +end test_virtual_temperature + +function test_relative_humidity_from_specific_humidity() + fn_name = "relative_humidity_from_specific_humidity" + + # numbers + # input + reference was constructed taken from an analysis using vertical profile. + # The r values were slightly adjusted. + t = |-29.2884,-14.4118,-5.9235,9.72339,18.4514| + p = |300, 400, 500, 700, 850| + r = |99.70488530734642, 100.25885732613531, 97.15956159465799, 71.37937968160273, 73.41420898756694| + q = |0.000845416891024797, 0.00277950354211498, 0.00464489207661245, + 0.0076785187585422, 0.0114808182580539| + v_ref = r + p = p*100 + t = t + 273.16 + + for i=1 to count(t) do + v = relative_humidity_from_specific_humidity(t[i], q[i], p[i]) + assert_equal(v, v_ref[i], 1E-5, fn_name & " number",i) + end for + + # vectors + v = relative_humidity_from_specific_humidity(t, q, p) + assert(vec_same(v, v_ref, 1E-5), fn_name & " vector", 0) + + # fields + + # ------------------ + # Pressure level + # ------------------ + + f = read("theta_input_pl.grib") + t = read(data:f, param: "t") + q = read(data:f, param: "q") + + r=relative_humidity_from_specific_humidity(t, q) + assert_equal(count(r), 2, fn_name & " count",1) + + pl =[850, 700] + for i=1 to count(pl) do + + lev = grib_get_long(r[i],"level") + assert_equal(lev,pl[i],fn_name & " level [" & i & "]",1) + id = grib_get_long(r[i],"paramId") + assert_equal(id,157,fn_name & " paramId [" & i & "]",1) + + v = values(r[i]) + pv = pl[i]*100 + tv = values(t[i]) + qv = values(q[i]) + + v_ref = v + for k=1 to count(v) do + v_ref[k] = 100*vapour_pressure(qv[k],pv)/saturation_vapour_pressure(tv[k],"mixed") + end for + assert(vec_same(v, v_ref,1E-2), fn_name & " values [" & i & "]",1) + + end for + + # ------------------ + # Model levels + # ------------------ + + ml = [135, 110] + f = read("thermo_profile.grib") + t = read(data:f, param: "t", levelist: ml) + q = read(data:f, param: "q", levelist: ml) + lnsp = read(data:f, param: "lnsp") + + r=relative_humidity_from_specific_humidity(t, q, lnsp) + assert_equal(count(r), 2, fn_name & " count",2) + + for i=1 to count(r) do + + lev = grib_get_long(r[i],"level") + assert_equal(lev,ml[i],fn_name & "level [" & i & "]",2) + id = grib_get_long(r[i],"paramId") + assert_equal(id,157,fn_name & " paramId [" & i & "]",2) + + v = values(r[i]) + pv = values(pressure(lnsp,ml[i])) + tv = values(t[i]) + qv = values(q[i]) + + v_ref = v + for k=1 to count(v) do + v_ref[k] = 100*vapour_pressure(qv[k],pv[k])/saturation_vapour_pressure(tv[k], "mixed") + end for + assert(vec_same(v, v_ref,1E-3),fn_name & " values [" & i & "]",2) + end for + +end test_relative_humidity_from_specific_humidity + +function test_rhu_field() + + # ------------------ + # Pressure levels + # ------------------ + + f = read("theta_input_pl.grib") + t = read(data:f, param: "t") + q = read(data:f, param: "q") + + r=relhum(data: f) + assert_equal(count(r), 2, "rhu count",1) + + pl =[850, 700] + for i=1 to count(pl) do + + lev = grib_get_long(r[i],"level") + assert_equal(lev,pl[i],"rhu level [" & i & "]",1) + id = grib_get_long(r[i],"paramId") + assert_equal(id,157,"rhu paramId [" & i & "]",1) + + v = values(r[i]) + pv = pl[i]*100 + tv = values(t[i]) + qv = values(q[i]) + + v_ref = v + for k=1 to count(v) do + v_ref[k] = 100 * vapour_pressure(qv[k],pv)/saturation_vapour_pressure(tv[k],"mixed") + #assert_equal(v[k], rhu,"rhu values [" & i & "]",1) + #assert(vec_same(v, values(th),1E-3),"theta values [" & i & "]",1) + end for + assert(vec_same(v, v_ref,1E-3),"rhu values [" & i & "]",1) + + end for + + # ------------------ + # Model levels + # ------------------ + + ml = [135, 110] + f = read("thermo_profile.grib") + t = read(data:f, param: "t", levelist: ml) + q = read(data:f, param: "q", levelist: ml) + lnsp = read(data:f, param: "lnsp") + + r=relhum(data: t & q & lnsp) + assert_equal(count(r), 2, "rhu count",2) + + for i=1 to count(r) do + + lev = grib_get_long(r[i],"level") + assert_equal(lev,ml[i],"rhu level [" & i & "]",2) + id = grib_get_long(r[i],"paramId") + assert_equal(id,157,"rhu paramId [" & i & "]",2) + + v = values(r[i]) + pv = values(pressure(lnsp,ml[i])) + tv = values(t[i]) + qv = values(q[i]) + + v_ref = v + for k=1 to count(v) do + v_ref[k] = 100 * vapour_pressure(qv[k],pv[k])/saturation_vapour_pressure(tv[k], "mixed") + end for + assert(vec_same(v, v_ref,1E-3),"rhu values [" & i & "]",2) + end for + +end test_rhu_field() diff -Nru metview-5.17.4/metview/test/macros/thermo.mv metview-5.19.2/metview/test/macros/thermo.mv --- metview-5.17.4/metview/test/macros/thermo.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo.mv 1970-01-01 00:00:00.000000000 +0000 @@ -1,1069 +0,0 @@ -#Metview Macro - -# **************************** LICENSE START *********************************** -# -# Copyright 2019 ECMWF. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ -# - -include "test_utils.mv" - -test_values() -test_relative_humidity_from_dewpoint() -test_dewpoint_from_relative_humidity() -test_dewpoint_from_specific_humidity() -test_saturation_vapour_pressure() -test_saturation_mixing_ratio() -test_specific_humidity_from_dewpoint() -test_specific_humidity_from_relative_humidity() -test_virtual_temperature() -test_vapour_pressure() -test_relative_humidity_from_specific_humidity() -test_rhu_field() -test_thermo_bufr() -test_thermo_bufr_wigos() -test_thermo_grib() -test_thermo_data_info() - -global ASSERT_EQUAL_EPS = 1E-4 # wil be used by assert_equal() - -function test_values() - - #-------------------------------- - # potential temperature - #-------------------------------- - t = 25 + 273.16 - p = 100500 - ref = 24.57557 + 273.16 - th = potential_temperature(t,p) - assert_equal(th,ref,"potential_temperature",1) - - ref = t - t = temperature_from_potential_temperature(th,p) - assert_equal(t,ref,"temperature_from_potential_temperature",1) - - #-------------------------------- - # equivalent potential temperature - #-------------------------------- - t = 30 + 273.16 - td = 26 + 273.16 - p = 100500 - ref = 367.178567159 - th = __equivalent_potential_temperature(t,td,p) - assert_equal(th,ref,"equivalent_potential_temperature",1) - - t = 30 + 273.16 - td = 36 + 273.16 - p = 100500 - th = __equivalent_potential_temperature(t,td,p) - assert_equal(th, 423.865175401,"equivalent_potential_temperature",2) - - th = 93.420887 + 273.16 - p = 100500 - ref = 26.8310546875 + 273.16 - t = __temperature_from_equivalent_potential_temperature(th,p, "old") - assert_equal(t,ref,"t_from_equivalent_potential_temperature",3) - - th = 93.420887 + 273.16 - p = 85000 - ref = 21.2353515625 + 273.16 - t = __temperature_from_equivalent_potential_temperature(th,p, "old") - assert_equal(t,ref,"t_from_equivalent_potential_temperature",4) - - #-------------------------------- - # mixing_ratio - #-------------------------------- - - q = 0.018 - ref = 0.0183299389002 - mr = mixing_ratio(q) - assert_equal(mr,ref,"mixing_ratio",1) - - #-------------------------------- - # lifted condensation level - #-------------------------------- - t = 30 + 273.16 - td = 26 + 273.16 - p = 100500 - v = lifted_condensation_level(t, td, p) - assert(v <> nil, "lcl",1) - assert_equal(v.t,298.182282019,"lcl t",1) - assert_equal(v.p,94840.0417043,"lcl p",1) - - t = 30 + 273.16 - td = 36 + 273.16 - p = 100500 - v = lifted_condensation_level(t, td, p) - assert_equal(v.t, 310.73986038, "lcl t",2) - assert_equal(v.p, 109576.487299, "lcl p",2) - - t = 50 - td = 36 + 273.16 - p = 100500 - v = lifted_condensation_level(t, td, p) - assert(v = nil, "lifted_condensation_level",5) - -end test_values - -function test_relative_humidity_from_dewpoint() - # numbers - t = |20, 20, 0, 35, 5, -15, 25| - td = |20, 10, -10, 32, -15, -24, -3| - # reference was tested with an online relhum calculator at: - # https://bmcnoldy.rsmas.miami.edu/Humidity.html - v_ref = |100, 52.5224, 46.8714, 84.5391, 21.9244, 46.1081, 15.4779| - for i=1 to count(t) do - v = relative_humidity_from_dewpoint(t[i] + 273.16, td[i] + 273.16) - assert_equal(v, v_ref[i], "relative_humidity_from_dewpoint number",i) - end for - - # fields - data_grb=read(source: "td_2m.grib") - t = read(data: data_grb, param: "2t") - td = read(data: data_grb, param: "2d") - - r = relative_humidity_from_dewpoint(t, td) - assert_equal(count(r), count(t), "relative_humidity_from_dewpoint field", 0) - - for i=1 to count(t) do - v = values(r[i]) - v_ref = v - t_v = values(t[i]) - td_v = values(td[i]) - for j=1 to count(v_ref) do - v_ref[j] = relative_humidity_from_dewpoint(t_v[j], td_v[j]) - end for - assert(vec_same(v, v_ref,1E-3), "relative_humidity_from_dewpoint field",i) - - # test edition and paramid - keys = grib_get(r[i], ["edition:l", "paramId:l"]) - assert_equal(keys[1][1], 2, "relative_humidity_from_dewpoint edition",1) - assert_equal(keys[1][2], 260242, "relative_humidity_from_dewpoint paramId",1) - - end for - -end test_relative_humidity_from_dewpoint - -function test_dewpoint_from_relative_humidity() - # numbers - t = |20, 20, 0, 35, 5, -15, 25| - r = |100, 52.5224, 46.8714, 84.5391, 21.9244, 46.1081, 15.4779| - v_ref = |20, 10, -10, 32, -15, -24, -3| - v_ref = v_ref + 273.16 - # reference was tested with an online relhum calculator at: - # https://bmcnoldy.rsmas.miami.edu/Humidity.html - #v_ref = |1, 0.525224, 0.468714, 0.845391, 0.219244, 0.461081, 0.154779| - - for i=1 to count(t) do - v = dewpoint_from_relative_humidity(t[i] + 273.16, r[i]) - assert_equal(v, v_ref[i], "dewpoint_from_relative_humidity number",i) - end for - - # fields - data_grb=read(source: "td_2m.grib") - t = read(data: data_grb, param: "2t") - td_ref = read(data: data_grb, param: "2d") - r = relative_humidity_from_dewpoint(t, td_ref) - - td = dewpoint_from_relative_humidity(t, r) - assert_equal(count(td), count(t), "dewpoint_from_relative_humidity field", 0) - - for i=1 to count(t) do - v = values(td[i]) - v_ref = values(td_ref[i]) - t_v = values(t[i]) - r_v = values(r[i]) - assert(vec_same(v, v_ref,1E-3), "dewpoint_from_relative_humidity field",i) - - # test edition and paramid - keys = grib_get(td[i], ["paramId:l"]) - assert_equal(keys[1][1], 168, "dewpoint_from_relative_humidity paramId",i) - end for - -end test_dewpoint_from_relative_humidity - -function test_dewpoint_from_specific_humidity() - # numbers - # reference was taken from a thermo proile (td, p) and a vertical profile (q) created - # from the same input grib for the same location. - q = |0.0169461143668741, 0.015583973727189, 0.0134912085486576, - 0.00834095469326712,0.00571847961691674, 0.00251296901842579| - p = |967.5085, 936.3775, 872.248, 756.1647, 649.157,422.4207| - v_ref = |21.78907,19.90885,16.50236,7.104064,-0.3548709, -16.37916| - p = p*100 - v_ref = v_ref + 273.16 - - # the departures are larger in the negative range! - for i=1 to count(q) do - v = dewpoint_from_specific_humidity(q[i], p[i]) - assert_equal(v, v_ref[i], 0.04, "dewpoint_from_specific_humidity number",i) - end for - - # fields - ml - data_grb =read(source: "tq_ml137.grib") - levLst = [100, 137] - q = read(data: data_grb, param: 'q', levelist: levLst) - lnsp = read(data: data_grb, param: "lnsp") - p = unipressure(lnsp, levLst) - - # ml: use lnsp - td = dewpoint_from_specific_humidity(q, lnsp) - for i=1 to count(q) do - v = values(td[i]) - q_v = values(q[i]) - p_v = values(p[i]) - v_ref = dewpoint_from_specific_humidity(q_v, p_v) - assert(vec_same(v, v_ref,0.04), "dewpoint_from_specific_humidity lnsp field-ml",i) - - # test edition and paramid - keys = grib_get(td[i], ["paramId:l"]) - assert_equal(keys[1][1], 3017, "dewpoint_from_specifc_humidity lnsp paramId-ml",i) - end for - - # ml: use pressure - td = dewpoint_from_specific_humidity(q, p) - for i=1 to count(q) do - v = values(td[i]) - q_v = values(q[i]) - p_v = values(p[i]) - v_ref = dewpoint_from_specific_humidity(q_v, p_v) - assert(vec_same(v, v_ref,0.04), "dewpoint_from_specific_humidity p field-ml",i) - - # test edition and paramid - keys = grib_get(td[i], ["paramId:l"]) - assert_equal(keys[1][1], 3017, "dewpoint_from_specifc_humidity p paramId-ml",i) - end for - - # fields - pl - data_grb =read(source: "theta_input_pl.grib") - q = read(data: data_grb, param: 'q') - p = [85000, 70000] - td = dewpoint_from_specific_humidity(q) - - for i=1 to count(q) do - v = values(td[i]) - q_v = values(q[i]) - p_v = p[i] - v_ref = dewpoint_from_specific_humidity(q_v, p_v) - assert(vec_same(v, v_ref,0.04), "dewpoint_from_specific_humidity field-pl",i) - - # test edition and paramid - keys = grib_get(td[i], ["paramId:l"]) - assert_equal(keys[1][1], 3017, "dewpoint_from_specifc_humidity paramId-pl",i) - end for - -end test_dewpoint_from_specific_humidity - -function test_saturation_vapour_pressure() - #---------------------------------------------------------------------- - # Many other computations rely on this, so has to be properly tested! - #---------------------------------------------------------------------- - - # Mixed phase - t_ref_vec = |-40,-38,-36,-34,-32,-30,-28,-26,-24,-22,-20,-18,-16,-14,-12,-10,-8,-6,-4,-2,0, - 2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40| - v_ref_vec = |12.8340726457,16.0609684843,20.0235421629,24.8721311298,30.7841825909,37.9684711167, - 46.669862593,57.1746797573,69.8167282976,85.0224894683,103.505016654,125.899330626,152.861618015, - 185.091435114,223.311442013,268.237242016,320.534777756,380.76229142,449.293361074, - 526.216975169,611.21,705.924130446,813.399624196,935.089307197, - 1072.57932282,1227.59811487,1402.02574841,1597.90356355,1817.4441569,2063.04168364, - 2337.28247285,2642.95594738,2983.06583857,3360.84168562,3779.75060788,4243.50933823, - 4756.09650416,5321.76514313,5945.05543737,6630.80765319,7384.17526886| - - # single values - for i=1 to count(t_ref_vec) do - vp = saturation_vapour_pressure(t_ref_vec[i] + 273.16, "mixed") - assert_equal(vp,v_ref_vec[i],"saturation_vapour_pressure mixed number",i) - end for - - # vectors - vp = saturation_vapour_pressure(t_ref_vec + 273.16, "mixed") - assert(vec_same(vp, v_ref_vec,1E-3), "saturation_vapour_pressure mixed vector",1) - - # fields - data_grb=read(source: "thermo_profile.grib", param: 't') - t = data_grb[1,2] - svp = saturation_vapour_pressure(t, "mixed") - assert_equal(count(svp), count(t), "saturation_vapour_pressure mixed field", 0) - - for i=1 to count(t) do - t_v = values(t[i]) - v_ref = t_v - for j=1 to count(t_v) do - v_ref[j] = saturation_vapour_pressure(t_v[j], "mixed") - end for - v = values(svp[i]) - assert(vec_same(v, v_ref,1E-3), "saturation_vapour_pressure mixed field",i) - end for - - # water phase - v_ref_vec = |18.7639147696,23.0743105511,28.260605363,34.4772357923,41.9015926021,50.7367613421, - 61.2145013826,73.5984745301,88.1877340711,105.320484719,125.378123494,148.789571053,176.035902426, - 207.655285468,244.248234663,286.483187147,335.102407053,390.928223421,454.869606034, - 527.929082632,611.21,705.924130446,813.399624196,935.089307197, - 1072.57932282,1227.59811487,1402.02574841,1597.90356355,1817.4441569,2063.04168364, - 2337.28247285,2642.95594738,2983.06583857,3360.84168562,3779.75060788,4243.50933823, - 4756.09650416,5321.76514313,5945.05543737,6630.80765319,7384.17526886| - - # single values - for i=1 to count(t_ref_vec) do - vp = saturation_vapour_pressure(t_ref_vec[i] + 273.16, "water") - assert_equal(vp,v_ref_vec[i],"saturation_vapour_pressure water number",i) - end for - - # ice phase - v_ref_vec = |12.8340726457,16.0609684843,20.0235421629,24.8721311298,30.7841825909,37.9684711167, - 46.669862593,57.1746797573,69.8167282976,84.9840462955,103.126443651,124.763902033,150.495909814, - 181.011810384,217.102246154,259.671784441,309.752815283,368.52081497,437.311072795, - 517.636982085,611.21,719.961383938,846.065815462,991.967025656, - 1160.40553853,1354.44865167,1577.52277554,1833.44825493,2126.47679789,2461.33163868, - 2843.25056292,3278.03192354,3772.08377695,4332.47626905,4966.99740063,5684.21230099, - 6493.52613833,7405.25079379,8430.67542488,9582.14104197,10873.1192195| - - # single values - for i=1 to count(t_ref_vec) do - vp = saturation_vapour_pressure(t_ref_vec[i] + 273.16, "ice") - assert_equal(vp,v_ref_vec[i],"saturation_vapour_pressure ice number",i) - end for - -end test_saturation_vapour_pressure - -function test_saturation_mixing_ratio() - - fn_name = "saturation_mixing_ratio" - - # Mixed phase - p = 100500 - t_ref_vec = |-25, -10, 30| - v_ref_vec = |0.000391417464004, 0.00166452692675, 0.027420| - - # single values - for i=1 to count(t_ref_vec) do - vp = saturation_mixing_ratio(t_ref_vec[i] + 273.16, p, "mixed") - assert_equal(vp,v_ref_vec[i], fn_name & " mixed number",i) - end for - - # vectors - vp = saturation_mixing_ratio(t_ref_vec + 273.16, p, "mixed") - assert(vec_same(vp, v_ref_vec,1E-3), fn_name & " mixed vector",1) - - # fields - data_grb=read(source: "theta_input_pl.grib", param: 't') - t = data_grb[1,2] - ws = saturation_mixing_ratio(t, "mixed") - assert_equal(count(ws), count(t), fn_name & " mixed field", 0) - - for i=1 to count(t) do - t_v = values(t[i]) - p = grib_get_long(t[i], "level") * 100 - v_ref = saturation_mixing_ratio(t_v, p, "mixed") - v = values(ws[i]) - assert(vec_same(v, v_ref,1E-3), fn_name & " mixed field",i) - end for - - # water phase - p = 100500 - t_ref_vec = |-25, -10, 30| - v_ref_vec = |0.00049920601775,0.00177807450423, 0.027420| - - # single values - for i=1 to count(t_ref_vec) do - vp = saturation_mixing_ratio(t_ref_vec[i] + 273.16, p, "water") - assert_equal(vp,v_ref_vec[i], fn_name & " water number",i) - end for - - # ice phase - p = 100500 - t_ref_vec = |-25, -10, 30| - v_ref_vec = |0.000391417464004, 0.00161123690469, 0.037287799183| - - # single values - for i=1 to count(t_ref_vec) do - vp = saturation_mixing_ratio(t_ref_vec[i] + 273.16, p, "ice") - assert_equal(vp,v_ref_vec[i], fn_name & " ice number",i) - end for - -end test_saturation_mixing_ratio - -function test_specific_humidity_from_dewpoint() - # numbers - # reference was taken from a thermo profile (td, p) and a vertical profile (q) created - # from the same input grib for the same location. - td = |21.78907,19.90885,16.50236,7.104064,-0.3548709, -16.37916| - p = |967.5085, 936.3775, 872.248, 756.1647, 649.157,422.4207| - v_ref = |0.0169461143668741, 0.015583973727189, 0.0134912085486576, - 0.00834095469326712,0.00571847961691674, 0.00251296901842579| - p = p*100 - td = td + 273.16 - - # the departures are larger in the negative range! - for i=1 to count(td) do - v = specific_humidity_from_dewpoint(td[i], p[i]) - assert_equal(v, v_ref[i], 1E-5, "specific_humidity_from_dewpoint number",i) - end for - - # vectors - we now base the test on the inverse function (dewpoint_from_specific_humidity) - q = v_ref - td = dewpoint_from_specific_humidity(q, p) - q_res = specific_humidity_from_dewpoint(td, p) - assert(vec_same(q_res, q, 1E-7), "specific_humidity_from_dewpoint vector",1) - - # fields - ml - data_grb =read(source: "tq_ml137.grib") - levLst = [100, 137] - q = read(data: data_grb, param: 'q', levelist: levLst) - lnsp = read(data: data_grb, param: "lnsp") - p = unipressure(lnsp, levLst) - - # ml: use lnsp - td = dewpoint_from_specific_humidity(q, lnsp) - q_res = specific_humidity_from_dewpoint(td, lnsp) - - for i=1 to count(q) do - v = values(q_res[i]) - v_ref = values(q[i]) - assert(vec_same(v, v_ref, 1E-7), "specific_humidity_from_dewpoint lnsp field-ml",i) - - # test paramid - keys = grib_get(q_res[i], ["paramId:l"]) - assert_equal(keys[1][1], 133, "specific_humidity_from_dewpoint lnsp paramId-ml",i) - end for - - # ml: use pressure - td = dewpoint_from_specific_humidity(q, p) - q_res = specific_humidity_from_dewpoint(td, p) - - for i=1 to count(q) do - v = values(q_res[i]) - v_ref = values(q[i]) - assert(vec_same(v, v_ref, 1E-7), "specific_humidity_from_dewpoint p field-ml",i) - - # test paramid - keys = grib_get(q_res[i], ["paramId:l"]) - assert_equal(keys[1][1], 133, "specific_humidity_from_dewpoint p paramId-ml",i) - end for - - # fields - pl - data_grb =read(source: "theta_input_pl.grib") - q = read(data: data_grb, param: 'q') - p = [85000, 70000] - td = dewpoint_from_specific_humidity(q) - q_res = specific_humidity_from_dewpoint(td) - - for i=1 to count(q) do - v = values(q_res[i]) - v_ref = values(q[i]) - assert(vec_same(v, v_ref,1E-7), "dewpoint_from_specific_humidity field-pl",i) - - # test paramid - keys = grib_get(q_res[i], ["paramId:l"]) - assert_equal(keys[1][1], 133, "specific_humidity_from_dewpoint paramId-pl",i) - end for - -end test_specific_humidity_from_dewpoint - -function test_specific_humidity_from_relative_humidity() - fn_name = "specific_humidity_from_relative_humidity" - - # numbers - # input + reference was constructed taken from an analysis using vertical profile. - # The r values were slightly adjusted. - t = |-29.2884,-14.4118,-5.9235,9.72339,18.4514| - p = |300, 400, 500, 700, 850| - r = |99.7052279329, 100.259008101, 97.1595946332, 71.3793685181, 73.4141886742| - q = |0.000845416891024797, 0.00277950354211498, 0.00464489207661245, - 0.0076785187585422, 0.0114808182580539| - v_ref = q - p = p*100 - t = t + 273.16 - for i=1 to count(t) do - v = specific_humidity_from_relative_humidity(t[i], r[i] ,p[i]) - # rr = 100* vapour_pressure(q[i], p[i])/saturation_vapour_pressure(t[i], "mixed") - assert_equal(v, v_ref[i], 1E-7, fn_name & " number",i) - end for - - # vectors - we now base the test on the inverse function (from_specific_humidity) - q_res = specific_humidity_from_relative_humidity(t, r, p) - assert(vec_same(q_res, v_ref, 1E-7), fn_name & " vector",1) - - # fields - ml - data_grb = read(source: "tq_ml137.grib") - levLst = [100, 137] - t = read(data: data_grb, param: 't', levelist: levLst) - q = read(data: data_grb, param: 'q', levelist: levLst) - lnsp = read(data: data_grb, param: "lnsp") - p = unipressure(lnsp, levLst) - r = 100*vapour_pressure(q, p)/saturation_vapour_pressure(t, "mixed") - - # ml: use lnsp - q_res = specific_humidity_from_relative_humidity(t, r, lnsp) - - for i=1 to count(q) do - v = values(q_res[i]) - v_ref = values(q[i]) - assert(vec_same(v, v_ref, 1E-7), fn_name & " lnsp field-ml",i) - - # test paramid - keys = grib_get(q_res[i], ["paramId:l"]) - assert_equal(keys[1][1], 133, fn_name & " lnsp paramId-ml",i) - end for - - # ml: use pressure - q_res = specific_humidity_from_relative_humidity(t, r, p) - - for i=1 to count(q) do - v = values(q_res[i]) - v_ref = values(q[i]) - assert(vec_same(v, v_ref, 1E-7), fn_name & " p field-ml",i) - - # test paramid - keys = grib_get(q_res[i], ["paramId:l"]) - assert_equal(keys[1][1], 133, fn_name & " p paramId-ml",i) - end for - - # fields - pl - data_grb =read(source: "theta_input_pl.grib") - t = read(data: data_grb, param: 't') - q = read(data: data_grb, param: 'q') - p = [85000, 70000] - r = 100*vapour_pressure(q)/saturation_vapour_pressure(t, "mixed") - q_res = specific_humidity_from_relative_humidity(t, r) - - for i=1 to count(q) do - v = values(q_res[i]) - v_ref = values(q[i]) - assert(vec_same(v, v_ref,1E-7), fn_name & " field-pl",i) - - # test paramid - keys = grib_get(q_res[i], ["paramId:l"]) - assert_equal(keys[1][1], 133, fn_name & " paramId-pl",i) - end for - -end test_specific_humidity_from_relative_humidity - -function test_vapour_pressure() - # numbers - q = 0.018 - p = 1000*100 - ref = 2862.6621522 - vp = vapour_pressure(q, p) - assert_equal(vp,ref,"vapour_pressure",1) - - # fields - ml - data_grb =read(source: "tq_ml137.grib") - levLst = [100, 137] - q = read(data: data_grb, param: 'q', levelist: levLst) - lnsp = read(data: data_grb, param: "lnsp") - p = unipressure(lnsp, levLst) - - # ml: use lnsp - vp = vapour_pressure(q, lnsp) - for i=1 to count(q) do - v = values(vp[i]) - q_v = values(q[i]) - p_v = values(p[i]) - v_ref = vapour_pressure(q_v, p_v) - assert(vec_same(v, v_ref,0.04), "vapour_pressure lnsp field-ml",i) - - # test edition and paramid - # keys = grib_get(vp[i], ["paramId:l"]) - # assert_equal(keys[1][1], 3055, "vapour_pressure lnsp paramId-ml",i) - end for - - # ml: use pressure - vp = vapour_pressure(q, p) - for i=1 to count(q) do - v = values(vp[i]) - q_v = values(q[i]) - p_v = values(p[i]) - v_ref = vapour_pressure(q_v, p_v) - assert(vec_same(v, v_ref,0.04), "vapour_pressure p field-ml",i) - - # test edition and paramid - # keys = grib_get(vp[i], ["paramId:l"]) - # assert_equal(keys[1][1], 3055, "vapour_pressure p paramId-ml",i) - end for - - # fields - pl - data_grb =read(source: "theta_input_pl.grib") - q = read(data: data_grb, param: 'q') - p = [85000, 70000] - vp = vapour_pressure(q) - - for i=1 to count(q) do - v = values(vp[i]) - q_v = values(q[i]) - p_v = p[i] - v_ref = vapour_pressure(q_v, p_v) - assert(vec_same(v, v_ref,0.04), "vapour_pressure field-pl",i) - - # test edition and paramid - # keys = grib_get(vp[i], ["paramId:l"]) - # assert_equal(keys[1][1], 3055, "vapour_pressure paramId-pl",i) - end for - -end test_vapour_pressure - -function test_virtual_temperature() - # numbers - t = 286.4 - w = 0.02 - q = w / (1+w) - v_ref = 289.813024047 - tv = virtual_temperature(t, q) - assert_equal(tv,v_ref,"virtual_temperature number", 1) - - # vectors - t = |286.4, 293.4| - w = |0.02, 0.03| - q = w / (1+w) - v_ref = |289.813,298.594| - tv = virtual_temperature(t, q) - assert(vec_same(tv, v_ref,1E-3), "virtual_temperature vector",1) - - # fields - pl - data_grb =read(source: "theta_input_pl.grib") - t = read(data: data_grb, param: 't') - q = read(data: data_grb, param: 'q') - #w = mixing_ratio(q) - tv = virtual_temperature(t, q) - - for i=1 to count(t) do - v = values(tv[i]) - t_v = values(t[i]) - q_v = values(q[i]) - v_ref = virtual_temperature(t_v, q_v) - assert(vec_same(v, v_ref,0.04), "virtual_temperature field-pl",i) - - # test edition and paramid - keys = grib_get(tv[i], ["paramId:l"]) - assert_equal(keys[1][1], 300012, "virtual_temperature paramId-pl",i) - end for - -end test_virtual_temperature - -function test_relative_humidity_from_specific_humidity() - fn_name = "relative_humidity_from_specific_humidity" - - # numbers - # input + reference was constructed taken from an analysis using vertical profile. - # The r values were slightly adjusted. - t = |-29.2884,-14.4118,-5.9235,9.72339,18.4514| - p = |300, 400, 500, 700, 850| - r = |99.70488530734642, 100.25885732613531, 97.15956159465799, 71.37937968160273, 73.41420898756694| - q = |0.000845416891024797, 0.00277950354211498, 0.00464489207661245, - 0.0076785187585422, 0.0114808182580539| - v_ref = r - p = p*100 - t = t + 273.16 - - for i=1 to count(t) do - v = relative_humidity_from_specific_humidity(t[i], q[i], p[i]) - assert_equal(v, v_ref[i], 1E-5, fn_name & " number",i) - end for - - # vectors - v = relative_humidity_from_specific_humidity(t, q, p) - assert(vec_same(v, v_ref, 1E-5), fn_name & " vector", 0) - - # fields - - # ------------------ - # Pressure level - # ------------------ - - f = read("theta_input_pl.grib") - t = read(data:f, param: "t") - q = read(data:f, param: "q") - - r=relative_humidity_from_specific_humidity(t, q) - assert_equal(count(r), 2, fn_name & " count",1) - - pl =[850, 700] - for i=1 to count(pl) do - - lev = grib_get_long(r[i],"level") - assert_equal(lev,pl[i],fn_name & " level [" & i & "]",1) - id = grib_get_long(r[i],"paramId") - assert_equal(id,157,fn_name & " paramId [" & i & "]",1) - - v = values(r[i]) - pv = pl[i]*100 - tv = values(t[i]) - qv = values(q[i]) - - v_ref = v - for k=1 to count(v) do - v_ref[k] = 100*vapour_pressure(qv[k],pv)/saturation_vapour_pressure(tv[k],"mixed") - end for - assert(vec_same(v, v_ref,1E-2), fn_name & " values [" & i & "]",1) - - end for - - # ------------------ - # Model levels - # ------------------ - - ml = [135, 110] - f = read("thermo_profile.grib") - t = read(data:f, param: "t", levelist: ml) - q = read(data:f, param: "q", levelist: ml) - lnsp = read(data:f, param: "lnsp") - - r=relative_humidity_from_specific_humidity(t, q, lnsp) - assert_equal(count(r), 2, fn_name & " count",2) - - for i=1 to count(r) do - - lev = grib_get_long(r[i],"level") - assert_equal(lev,ml[i],fn_name & "level [" & i & "]",2) - id = grib_get_long(r[i],"paramId") - assert_equal(id,157,fn_name & " paramId [" & i & "]",2) - - v = values(r[i]) - pv = values(pressure(lnsp,ml[i])) - tv = values(t[i]) - qv = values(q[i]) - - v_ref = v - for k=1 to count(v) do - v_ref[k] = 100*vapour_pressure(qv[k],pv[k])/saturation_vapour_pressure(tv[k], "mixed") - end for - assert(vec_same(v, v_ref,1E-3),fn_name & " values [" & i & "]",2) - end for - -end test_relative_humidity_from_specific_humidity - -function test_rhu_field() - - # ------------------ - # Pressure levels - # ------------------ - - f = read("theta_input_pl.grib") - t = read(data:f, param: "t") - q = read(data:f, param: "q") - - r=relhum(data: f) - assert_equal(count(r), 2, "rhu count",1) - - pl =[850, 700] - for i=1 to count(pl) do - - lev = grib_get_long(r[i],"level") - assert_equal(lev,pl[i],"rhu level [" & i & "]",1) - id = grib_get_long(r[i],"paramId") - assert_equal(id,157,"rhu paramId [" & i & "]",1) - - v = values(r[i]) - pv = pl[i]*100 - tv = values(t[i]) - qv = values(q[i]) - - v_ref = v - for k=1 to count(v) do - v_ref[k] = 100 * vapour_pressure(qv[k],pv)/saturation_vapour_pressure(tv[k],"mixed") - #assert_equal(v[k], rhu,"rhu values [" & i & "]",1) - #assert(vec_same(v, values(th),1E-3),"theta values [" & i & "]",1) - end for - assert(vec_same(v, v_ref,1E-3),"rhu values [" & i & "]",1) - - end for - - # ------------------ - # Model levels - # ------------------ - - ml = [135, 110] - f = read("thermo_profile.grib") - t = read(data:f, param: "t", levelist: ml) - q = read(data:f, param: "q", levelist: ml) - lnsp = read(data:f, param: "lnsp") - - r=relhum(data: t & q & lnsp) - assert_equal(count(r), 2, "rhu count",2) - - for i=1 to count(r) do - - lev = grib_get_long(r[i],"level") - assert_equal(lev,ml[i],"rhu level [" & i & "]",2) - id = grib_get_long(r[i],"paramId") - assert_equal(id,157,"rhu paramId [" & i & "]",2) - - v = values(r[i]) - pv = values(pressure(lnsp,ml[i])) - tv = values(t[i]) - qv = values(q[i]) - - v_ref = v - for k=1 to count(v) do - v_ref[k] = 100 * vapour_pressure(qv[k],pv[k])/saturation_vapour_pressure(tv[k], "mixed") - end for - assert(vec_same(v, v_ref,1E-3),"rhu values [" & i & "]",2) - end for - -end test_rhu_field() - -function test_thermo_bufr() - - fn_name = "thermo_bufr" - data_bufr=read("temp_10.bufr") - prof_ref=read("thermo_bufr_ref.nc") - - # 1 - use station db - - # extract thermo profile - prof_1 = thermo_bufr( - data : data_bufr, - station : stations( - search_key : "ident", - ident : 1400 - ) - ) - - # 2 - do not use db - # real coords: [56.9,3.35] - prof_2 = thermo_bufr( - data : data_bufr, - station : stations( - search_stations_database : "no", - name : "", - position : [56.86,3.32], - threshold: 0.05 - ) - ) - - # 3 - coords - # real coords: [56.9,3.35] - prof_3 = thermo_bufr( - data : data_bufr, - point_selection: "coordinates", - coordinates: [56.86,3.32], - threshold: 0.05 - ) - - # 4 - coords, default threshold - # real coords: [56.9,3.35] - prof_4 = thermo_bufr( - data : data_bufr, - point_selection: "coordinates", - coordinates: [56.81,3.26] - ) - - # 5 - ident - prof_5 = thermo_bufr( - data : data_bufr, - point_selection: "wmo_ident", - wmo_ident: 1400 - ) - - # 6 - name - # it does not have a name - - profs = [prof_1, prof_2, prof_3, prof_4, prof_5] - - for i=1 to count(profs) do - prof = profs[i] - check_thermo_profile(prof, prof_ref, ['t','td','pres','z','u','v','xwind'], - 72, 13, [1400, "56.9/3.35"], fn_name, i) - end for - -end test_thermo_bufr - -function test_thermo_bufr_wigos() - - fn_name = "thermo_bufr_wigos" - - data_bufr=read("temp_wigos.bufr") - prof_ref=read("thermo_bufr_wigos_ref.nc") - - # - # this station: - # - is not in the stations DB - # - does not have a wmo name or id - - # 1 - do not use db - # real coords: [-2.18165, -59.0218] - prof_1 = thermo_bufr( - data : data_bufr, - station : stations( - search_stations_database : "no", - name : "", - position : [-2.15, -59.04], - threshold: 0.05 - ) - ) - - # 2 - coords - # real coords: [-2.18165, -59.0218] - prof_2 = thermo_bufr( - data : data_bufr, - point_selection: "coordinates", - coordinates: [-2.15, -59.04], - threshold: 0.05 - ) - - # 3 - coords, default threshold - # real coords: [-2.18165, -59.0218] - prof_3 = thermo_bufr( - data : data_bufr, - point_selection: "coordinates", - coordinates: [-2.15, -59.04] - ) - - # 4 - wigos - prof_4 = thermo_bufr( - data : data_bufr, - point_selection: "wigos", - wigos_local_name: "ATTO" - ) - - # 5 - wigos - prof_5 = thermo_bufr( - data : data_bufr, - point_selection: "wigos", - wigos_issuer: 76, - wigos_issue_number: 0, - wigos_local_name: "ATTO" - ) - - profs = [prof_1, prof_2, prof_3, prof_4, prof_5] - - for i=1 to count(profs) do - - prof = profs[i] - check_thermo_profile(prof, prof_ref, ['t','td','pres','z','u','v','xwind'], - 693, 13, [0, "-2.18165/-59.0218"], fn_name, i) - end for - -end test_thermo_bufr_wigos - -function test_thermo_grib() - - fn_name = "thermo_grib" - data_grb=read("thermo_profile.grib") - prof_ref=read("thermo_grib_ref.nc") - - # 1 - nearest gridpoint - prof_1 = thermo_grib( - data : data_grb, - coordinates : [0,-60] - ) - - # 2 - stations - prof_2 = thermo_grib( - data : data_grb, - point_selection: "station", - point_extraction: "nearest_gridpoint", - station : stations( - search_stations_database : "no", - name : "", - position : [0.02,-59.98] - ) - ) - - - profs = [prof_1, prof_2] - for i=1 to count(profs) do - prof = profs[i] - check_thermo_profile(prof, prof_ref, ['t','td','pres'], 108, 17, - [nil, "0/-60"], fn_name, i) - end for - - # 3 - AREA AVERAGE - - prof_ref = read("thermo_grib_area_ref.nc") - prof = thermo_grib( - data : data_grb, - point_selection: "area_average", - area_avreage: [0, -50, -20, -30] - ) - - check_thermo_profile(prof, prof_ref, ['t','td','pres'], 108, 17, - [nil, "0/-50/-20/-30"], fn_name, 3) - - -end test_thermo_grib - -function test_thermo_data_info() - - fn_name = "thermo_data_info" - - # BUFR - prof=read("thermo_bufr_ref.nc") - - info1 = thermo_data_info(prof) - info2= thermo_data_info(prof, 1) - info3= thermo_data_info(prof, "time_dim_index", 1) - info_lst = [info1, info2, info3] - - for i=1 to count(info_lst) do - info = info_lst[i] - assert_equal(info.lat, 56.9, fn_name & " lat", i) - assert_equal(info.lon, 3.35, fn_name & " lon", i) - assert_equal(info.station,1400, fn_name & " station", i) - assert_equal(info.date,20081208, fn_name & " date", i) - assert_equal(info.time, 1200, fn_name & " time", i) - assert_equal(info.base_date,2008-12-08 12:00:00,fn_name & " base_date", i) - end for - - # GRIB forecast - data_grb=read("thermo_profile_baltic.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [56.5, 24.7], - data : data_grb - ) - info = thermo_data_info(prof) - assert_equal(info.lat, 56.5, fn_name & " lat", 4) - assert_equal(info.lon, 24.7, fn_name & " lon", 4) - assert_equal(info.date,20170810, fn_name & " date", 4) - assert_equal(info.time, 1200, fn_name & " time", 4) - assert_equal(info.step, 52, fn_name & " step", 4) - assert_equal(info.base_date,2017-08-10 12:00:00, fn_name & " base_date", 4) - assert_equal(info.valid_date,2017-08-12 16:00:00,fn_name & " valid_date", 4) - - -end test_thermo_data_info - -#==================================================== -# -# Functions to generate test reference data -# -#==================================================== - -function generate_test_theta_pl_field_reference() - - f = read("theta_input_pl.grib") - t = read(data:f, param: "t") - q = read(data:f, param: "q") - - r1=eqpott_p(temperature: t, humidity: q) - r2=seqpott_p(temperature: t) - - write("theta_pl_ref.grib",r1 & r2) - - -end generate_test_theta_pl_field_reference - -function generate_test_theta_ml_field_reference() - - lev = [135, 110] - f = read("thermo_profile.grib") - t = read(data:f, param: "t", levelist: lev) - q = read(data:f, param: "q", levelist: lev) - lnsp = read(data:f, param: "lnsp") - - # visually checked - r1=pott_m(temperature: t, lnsp: lnsp) - r2=eqpott_m(temperature: t, humidity: q, lnsp: lnsp) - r3=seqpott_m(temperature: t, lnsp: lnsp) - - write("theta_ml_ref.grib",r1 & r2 & r3) - -end generate_test_theta_ml_field_reference diff -Nru metview-5.17.4/metview/test/macros/thermo_pacel_grib_inversion_warm_sea.mv metview-5.19.2/metview/test/macros/thermo_pacel_grib_inversion_warm_sea.mv --- metview-5.17.4/metview/test/macros/thermo_pacel_grib_inversion_warm_sea.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_pacel_grib_inversion_warm_sea.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,95 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +# GRIB - model levels +test_parcel_grib_inversion_warm_sea() + +#------------------------------------------------- +# use case : strong inversion in the tropics +# over sea +#------------------------------------------------- +function test_parcel_grib_inversion_warm_sea() + + fn_name = "test_parcel_grib_inversion_warm_sea" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [-20,-10], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 4.64192296131, + cin: 0, + li: 8.3812020345, + lcl: (t:13.861418388,p:924.80649016), + lfc: (t:21.299697876,p:1011.4755249), + el: (t:13.837027864,p:922.819124892), + top: nil, + area_count: 1, + area_type: "a1", + t_count: 92, + p_count: 92, + t_first: 21.299697876, + t_last: -130.463867187, + t_mean: -32.8533671847, + p_first: 1011.4755249, + p_last: 56.2566757202, + p_mean: 519.939701753 + ) + + #stopwatch_start("1") + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #stopwatch_stop() + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 7.47356572127, + cin: 0, + li: 8.4430773625, + lcl: (t:15.732086262,p:924.80649016), + lfc: (t:23.218844887,p:1011.4755249), + el: (t:14.770261296,p:904.320584596), + top: nil, + area_count: 1, + area_type: "a1", + t_count: 92, + p_count: 92, + t_first: 23.218844887, + t_last: -130.463867181, + t_mean: -32.0986103672, + p_first: 1011.4755249, + p_last: 56.2566757202, + p_mean: 519.738630663 + ) + parcel = thermo_parcel_path(prof, (top_p: 600)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_inversion_warm_sea + \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_bufr.mv metview-5.19.2/metview/test/macros/thermo_parcel_bufr.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_bufr.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_bufr.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,118 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +# BUFR +test_parcel_bufr_unstable() + +#--------------------------------- +# use case : unstable, USA +#--------------------------------- +function test_parcel_bufr_unstable() + + fn_name = "test_parcel_bufr_unstable" + + data_grb=read("thermo_profile_obs.bufr") + + # extract thermo profile + prof = thermo_bufr(data: data_grb, + station: stations(search_key: "ident", + ident: 72249)) + + # 1. surface, non-virtual + ref = ( + cape: 3923.56965701, + cin: 2.73849177608, + li: -7.7001953125, + lcl: (t:16.697974597,p:835.964161938), + lfc: (t:15.918665343,p:818.560036013), + el: (t:-59.809778136,p:179.882712634), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 80, + p_count: 80, + t_first: 30.25, + t_last: -125.014648437, + t_mean: -33.0192663505, + p_first: 981, + p_last: 50, + p_mean: 438.273783745 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 4221.55914588, + cin: 0, + li: -7.6398622225, + lcl: (t:19.21137753,p:835.964161938), + lfc: (t:32.880914623,p:981), + el: (t:-59.805292022,p:179.870783592), + top: nil, + area_count: 1, + area_type: "a1", + t_count: 78, + p_count: 78, + t_first: 32.880914623, + t_last: -125.014648394, + t_mean: -33.3475884794, + p_first: 981, + p_last: 50, + p_mean: 428.132499302 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_bufr_unstable + + +function plot_parcel(prof, parcel) + + parcel_area = thermo_parcel_area(parcel) + + if parcel_area <> nil and parcel["t"] <> nil then + parcel_vis = xy_curve(parcel["t"], parcel["p"], "charcoal", "dash", 6) + end if + + prof_vis = mthermo( + thermo_temperature_line_thickness:5, thermo_dewpoint_line_thickness:5 + ) + + view = thermoview( + type:"skewt", + minimum_temperature:-140, + maximum_temperature:40, + top_pressure:100, + subpage_clipping:"on" + ) + if parcel_area <> nil then + plot(view, parcel_area, prof, prof_vis, parcel_vis) + else + plot(view, prof, prof_vis) + end if + +end plot_parcel diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_amazon_1.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_amazon_1.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_amazon_1.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_amazon_1.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,273 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +# GRIB - model levels +test_parcel_grib_amazon_1() + +#--------------------------------- +# use case : Amazon rainforest +#--------------------------------- +function test_parcel_grib_amazon_1() + + fn_name = "test_parcel_grib_amazon" + + data_grb=read("thermo_profile.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [0,-60], + data : data_grb + ) + + # 0. surface, top, non-virtual + ref = ( + cape: 1672.86107626, + cin: 2.96158852846, + li: -4.4753504185, + lcl: (t:23.212939019,p:979.738781199), + lfc: (t:21.466259477,p:932.203981587), + el: (t:-66.587576048,p:154.403688225), + top: (t:-104.884062131,p:75.2039485425), + area_count: 4, + area_type: "a1010", + t_count: 87, + p_count: 87, + t_first: 24.683532715, + t_last: -102.221679688, + t_mean: -14.6652398094, + p_first: 996.865844727, + p_last: 79.4493560791, + p_mean: 552.416078479 + ) + + #stopwatch_start("1") + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off", comp_top: "on")) + #plot_parcel(prof, parcel) + #stopwatch_stop() + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,0) + + # 1. surface, top, non-virtual, using keywords (to simulate the call from Python) + parcel = thermo_parcel_path(prof, "mode", "surface", "virtual", "off", "comp_top", "on") + test_parcel_core(parcel,ref,fn_name,1) + + # 2. surface, top, non-virtual + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 0, comp_top: 1)) + test_parcel_core(parcel,ref,fn_name,2) + +# # 3. surface, el_area, non-virtual +# ref = ( +# cape: 1672.86107626, +# cin: 2.96158852846, +# li: -4.4753504185, +# lcl: (t:23.212939019,p:979.738781199), +# lfc: (t:21.466259477,p:932.203981587), +# el: (t:-66.587576048,p:154.403688225), +# top: nil, +# area_count: 4, +# area_type: "a1010", +# t_count: 95, +# p_count: 95, +# t_first: 24.683532715, +# t_last: -121.000976562, +# t_mean: -23.0240222465, +# p_first: 996.865844727, +# p_last: 52.8644294739, +# p_mean: 511.146149103 +# ) +# +# parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 0, el_area: 1)) +# #__print_parcel_result_for_test(parcel) +# test_parcel_core(parcel,ref,fn_name,3) + + # 4. surface, stop_at_el, non-virtual + ref = ( + cape: 1672.86107626, + cin: 2.96158852846, + li: -4.4753504185, + lcl: (t:23.212939019,p:979.738781199), + lfc: (t:21.466259477,p:932.203981587), + el: (t:-66.587576048,p:154.403688225), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 74, + p_count: 74, + t_first: 24.683532715, + t_last: -66.587576048, + t_mean: -2.16073537975, + p_first: 996.865844727, + p_last: 154.403688225, + p_mean: 629.972289291 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 0, stop_at_el: 1)) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name, 4) + + # 5. surface, non-virtual + ref = ( + cape: 1672.86107626, + cin: 2.96158852846, + li: -4.4753504185, + lcl: (t:23.212939019,p:979.738781199), + lfc: (t:21.466259477,p:932.203981587), + el: (t:-66.587576048,p:154.403688225), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 95, + p_count: 95, + t_first: 24.683532715, + t_last: -121.000976562, + t_mean: -23.0240222465, + p_first: 996.865844727, + p_last: 52.8644294739, + p_mean: 511.146149103 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 0)) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name, 5) + + # 6. custom, non-virtual + ref = ( + cape: 2844.99479448, + cin: 0, + li: -6.1159754185, + lcl: (t:22.253283037,p:924.471194437), + lfc: (t:28.683532715,p:996.865844727), + el: (t:-68.624110809,p:141.987453431), + top: nil, + area_count: 1, + area_type: "a1", + t_count: 93, + p_count: 93, + t_first: 28.683532715, + t_last: -118.862304687, + t_mean: -21.8091460709, + p_first: 996.865844727, + p_last: 52.8644294739, + p_mean: 500.83492028 + ) + info = thermo_data_info(prof) + opt = (mode: "custom", + start_p: info.bottom_p, + start_t: info.bottom_t + 4, + start_td: info.bottom_td, + virtual: 0) + + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,6) + + # 7. mean layer, non-virtual + ref = ( + cape: 143.6538341, + cin: 58.6754635717, + li: -1.3698816685, + lcl: (t:16.986701813,p:869.840324866), + lfc: (t:2.790296854,p:603.122620868), + el: (t:-32.713065145,p:295.173075496), + top: nil, + area_count: 5, + area_type: "a10101", + t_count: 78, + p_count: 78, + t_first: 19.396555901, + t_last: -124.663085937, + t_mean: -36.8208262852, + p_first: 895.399343491, + p_last: 52.8644294739, + p_mean: 399.001046631 + ) + + info = thermo_data_info(prof) + opt = (mode: "mean_layer", + bottom_p: info.bottom_p, + top_p: 700, + mean_start_from_theta: 0, + virtual: 0) + + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name, 7) + + # 8. mucape, non-virtual + ref = ( + cape: 1672.86107626, + cin: 2.96158852846, + li: -4.4753504185, + lcl: (t:23.212939019,p:979.738781199), + lfc: (t:21.466259477,p:932.203981587), + el: (t:-66.587576048,p:154.403688225), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 95, + p_count: 95, + t_first: 24.683532715, + t_last: -121.000976562, + t_mean: -23.0240222465, + p_first: 996.865844727, + p_last: 52.8644294739, + p_mean: 511.146149103 + ) + + info = thermo_data_info(prof) + opt = (mode: "mucape", + top_p: 700, + virtual: 0) + + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name, 8) + + # 9. surface, explicit virtual (string) + ref = ( + cape: 1842.38184522, + cin: 0, + li: -3.8547100225, + lcl: (t:26.502372912,p:979.738781199), + lfc: (t:25.63666154,p:958.466798426), + el: (t:-66.58861251,p:154.390847059), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 95, + p_count: 95, + t_first: 27.989288681, + t_last: -121.000976419, + t_mean: -21.6594902733, + p_first: 996.865844727, + p_last: 52.8644294739, + p_mean: 511.229215802 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "on")) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,9) + + # 10. surface , explicit virtual (number) + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 1)) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,10) + + # 11. surface , implicit virtual + parcel = thermo_parcel_path(prof, (mode: "surface")) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,11) + +end test_parcel_grib_amazon_1 diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_amazon_2.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_amazon_2.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_amazon_2.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_amazon_2.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,193 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +# GRIB - model levels +test_parcel_grib_amazon_2() + +#--------------------------------- +# use case : Amazon rainforest +#--------------------------------- +function test_parcel_grib_amazon_2() + + fn_name = "test_parcel_grib_amazon" + + data_grb=read("thermo_profile.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [0,-60], + data : data_grb + ) + + # 12. mucape explicit , implicit virtual + ref = ( + cape: 1842.38184522, + cin: 0, + li: -3.8547100225, + lcl: (t:26.502372912,p:979.738781199), + lfc: (t:25.63666154,p:958.466798426), + el: (t:-66.58861251,p:154.390847059), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 95, + p_count: 95, + t_first: 27.989288681, + t_last: -121.000976419, + t_mean: -21.6594902733, + p_first: 996.865844727, + p_last: 52.8644294739, + p_mean: 511.229215802 + ) + + parcel = thermo_parcel_path(prof, (mode: "mucape", top_p: 700)) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,12) + + # 13. mucape implicit , implicit virtual + parcel = thermo_parcel_path(prof, (top_p: 700)) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,13) + + # 14. mucape implicit , implicit virtual, layer + parcel = thermo_parcel_path(prof, (layer_depth: 300)) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,14) + + # 15. mean_layer, implicit virtual + ref = ( + cape: 204.840069774, + cin: 36.8992628233, + li: -0.7492412725, + lcl: (t:19.447800848,p:869.840324866), + lfc: (t:9.69979889,p:686.928740465), + el: (t:-33.069884476,p:292.844083873), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 75, + p_count: 75, + t_first: 21.878095939, + t_last: -124.663085891, + t_mean: -37.8973075448, + p_first: 895.399343491, + p_last: 52.8644294739, + p_mean: 387.376783238 + ) + info = thermo_data_info(prof) + opt = (mode: "mean_layer", + bottom_p: info.bottom_p, + top_p: 700, + mean_start_from_theta: 0) + + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,15) + + # 16. mean_layer, theta mean, implicit virtual + ref = ( + cape: 0, + cin: 0, + li: 0.7741962275, + lcl: (t:17.000521874,p:842.974355672), + lfc: nil, + el: nil, + top: nil, + area_count: 2, + area_type: "a10", + t_count: 93, + p_count: 93, + t_first: 31.234771756, + t_last: -126.30371091, + t_mean: -25.6626788631, + p_first: 996.865844727, + p_last: 52.8644294739, + p_mean: 508.028439142 + ) + opt = (mode: "ml", + top_p: 700) + + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,16) + + # 17. mean_layer, depth=50hpa, theta mean, implicit virtual + ref = ( + cape: 766.01129084, + cin: 18.7511630774, + li: -2.1261943975, + lcl: (t:23.903070817,p:947.911666671), + lfc: (t:20.610921306,p:872.584255166), + el: (t:-55.552685332,p:195.087842543), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 95, + p_count: 95, + t_first: 28.206274658, + t_last: -123.110351487, + t_mean: -23.3786116226, + p_first: 996.865844727, + p_last: 52.8644294739, + p_mean: 510.517363109 + ) + info = thermo_data_info(prof) + opt = (mode: "ml", + layer_depth: 50) + + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,17) + + # 18. ml50, theta mean, implicit virtual + opt = (mode: "ml50") + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,18) + + # 19. mean_layer, depth=100hpa, theta mean, implicit virtual + ref = ( + cape: 514.589755616, + cin: 23.4780659507, + li: -1.5988506475, + lcl: (t:22.658128624,p:927.504967924), + lfc: (t:18.445959733,p:834.968816789), + el: (t:-47.120520308,p:227.143697673), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 95, + p_count: 95, + t_first: 28.814490086, + t_last: -123.696289, + t_mean: -23.725023991, + p_first: 996.865844727, + p_last: 52.8644294739, + p_mean: 510.141148607 + ) + opt = (mode: "ml", + layer_depth: 100) + + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,19) + + # 20. ml100, theta mean, implicit virtual + opt = (mode: "ml100") + parcel = thermo_parcel_path(prof, opt) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,20) + +end test_parcel_grib_amazon_2 diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_cin.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_cin.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_cin.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_cin.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,160 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +test_parcel_grib_large_cin() +test_parcel_grib_capping_cin() + +#-------------------------------------- +# use case : large cin near Italy +#-------------------------------------- +function test_parcel_grib_large_cin() + + fn_name = "test_parcel_grib_large_cin" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [40,10], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 1322.74635153, + cin: 786.921305892, + li: -3.4988896805, + lcl: (t:19.26419474,p:953.782420839), + lfc: (t:3.539373348,p:636.165943283), + el: (t:-60.769950399,p:193.938640909), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 93, + p_count: 93, + t_first: 23.299697876, + t_last: -123.901367187, + t_mean: -27.3418373984, + p_first: 1000.66821289, + p_last: 56.2566757202, + p_mean: 509.486782363 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 1391.38631069, + cin: 632.083879166, + li: -3.1723186605, + lcl: (t:21.875563159,p:953.782420839), + lfc: (t:5.859350843,p:651.073646741), + el: (t:-60.769705583,p:193.916764654), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 93, + p_count: 93, + t_first: 25.947103619, + t_last: -123.901367132, + t_mean: -26.2791649056, + p_first: 1000.66821289, + p_last: 56.2566757202, + p_mean: 509.646845021 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_large_cin + +#-------------------------------------- +# use case : capping cin +#-------------------------------------- +function test_parcel_grib_capping_cin() + + fn_name = "test_parcel_grib_capping_cin" + + data_grb=read("thermo_profile_capping_cin.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [24.4,-90.8], + data : data_grb + ) + + # 1. surface, virtual + ref = ( + cape: 1581.58708203, + cin: 26.0327675077, + li: -4.5345222805, + lcl: (t:25.914044511,p:983.291525421), + lfc: (t:17.041808375,p:785.84564365), + el: (t:-63.141607447,p:168.297424297), + top: nil, + area_count: 6, + area_type: "a010101", + t_count: 77, + p_count: 77, + t_first: 28.302976144, + t_last: -64.980749772, + t_mean: -0.181745758428, + p_first: 1011.06732178, + p_last: 163.082321167, + p_mean: 643.689105621 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "on")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. ml50, virtual + ref = ( + cape: 1103.85580005, + cin: 70.4889565715, + li: -3.6556160305, + lcl: (t:24.658549068,p:968.056298047), + lfc: (t:12.554736345,p:716.46978987), + el: (t:-54.984084744,p:197.430559437), + top: nil, + area_count: 3, + area_type: "a101", + t_count: 74, + p_count: 74, + t_first: 28.379301656, + t_last: -66.387833265, + t_mean: -1.72765083996, + p_first: 1011.06732178, + p_last: 163.082321167, + p_mean: 634.673725143 + ) + parcel = thermo_parcel_path(prof, (mode: "ml50")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + +end test_parcel_grib_capping_cin + \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_himalayas.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_himalayas.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_himalayas.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_himalayas.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,94 @@ +#Metview Macro + + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +test_parcel_grib_himalayas() + +#-------------------------------------- +# use case : Himalayas +#-------------------------------------- +function test_parcel_grib_himalayas() + + fn_name = "test_parcel_grib_himalayas" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [30,80], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 0, + cin: 0, + li: 6.4110684865, + lcl: (t:-0.375000251,p:635.596916122), + lfc: nil, + el: nil, + top: nil, + area_count: 1, + area_type: "a0", + t_count: 91, + p_count: 91, + t_first: 11.299697876, + t_last: -128.559570312, + t_mean: -38.4291593194, + p_first: 736.047302246, + p_last: 56.2566757202, + p_mean: 403.547307737 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 0, + cin: 0, + li: 6.6983161235, + lcl: (t:0.594173086,p:635.596916122), + lfc: nil, + el: nil, + top: nil, + area_count: 1, + area_type: "a0", + t_count: 91, + p_count: 91, + t_first: 12.310350056, + t_last: -128.5595703, + t_mean: -38.0115108289, + p_first: 736.047302246, + p_last: 56.2566757202, + p_mean: 403.547307737 + ) + + parcel = thermo_parcel_path(prof, (top_p: 600)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_himalayas + + diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_inversion_cold.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_inversion_cold.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_inversion_cold.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_inversion_cold.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,91 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +# GRIB - model levels +test_parcel_grib_inversion_cold() + +#-------------------------------------- +# use case : inversion in Antarctica +#-------------------------------------- +function test_parcel_grib_inversion_cold() + + fn_name = "test_parcel_grib_inversion_cold" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [-80,20], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 0, + cin: 0, + li: 25.7207087535, + lcl: (t:-54.856552124,p:662.370849609), + lfc: nil, + el: nil, + top: nil, + area_count: 1, + area_type: "a0", + t_count: 91, + p_count: 91, + t_first: -54.856552124, + t_last: -139.985351562, + t_mean: -93.3388707088, + p_first: 662.370849609, + p_last: 56.2566757202, + p_mean: 374.741248204 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 0, + cin: 0, + li: 25.7303377345, + lcl: (t:-54.851819779,p:662.370849609), + lfc: nil, + el: nil, + top: nil, + area_count: 1, + area_type: "a0", + t_count: 91, + p_count: 91, + t_first: -54.851819779, + t_last: -139.985351562, + t_mean: -93.3377993121, + p_first: 662.370849609, + p_last: 56.2566757202, + p_mean: 374.741248204 + ) + parcel = thermo_parcel_path(prof, (top_p: 600)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_inversion_cold diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_inversion.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_inversion.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_inversion.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_inversion.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,306 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" + +# GRIB - model levels +test_parcel_grib_inversion_warm_sea() +test_parcel_grib_inversion_cold() +test_parcel_grib_inversion_unstable() + +#------------------------------------------------- +# use case : strong inversion in the tropics +# over sea +#------------------------------------------------- +function test_parcel_grib_inversion_warm_sea() + + fn_name = "test_parcel_grib_inversion_warm_sea" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [-20,-10], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 4.64192296131, + cin: 0, + li: 8.3812020345, + lcl: (t:13.861418388,p:924.80649016), + lfc: (t:21.299697876,p:1011.4755249), + el: (t:13.837027864,p:922.819124892), + top: nil, + area_count: 1, + area_type: "a1", + t_count: 92, + p_count: 92, + t_first: 21.299697876, + t_last: -130.463867187, + t_mean: -32.8533671847, + p_first: 1011.4755249, + p_last: 56.2566757202, + p_mean: 519.939701753 + ) + + #stopwatch_start("1") + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #stopwatch_stop() + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 7.47356572127, + cin: 0, + li: 8.4430773625, + lcl: (t:15.732086262,p:924.80649016), + lfc: (t:23.218844887,p:1011.4755249), + el: (t:14.770261296,p:904.320584596), + top: nil, + area_count: 1, + area_type: "a1", + t_count: 92, + p_count: 92, + t_first: 23.218844887, + t_last: -130.463867181, + t_mean: -32.0986103672, + p_first: 1011.4755249, + p_last: 56.2566757202, + p_mean: 519.738630663 + ) + parcel = thermo_parcel_path(prof, (top_p: 600)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_inversion_warm_sea + + +#-------------------------------------- +# use case : inversion in Antarctica +#-------------------------------------- +function test_parcel_grib_inversion_cold() + + fn_name = "test_parcel_grib_inversion_cold" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [-80,20], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 0, + cin: 0, + li: 25.7207087535, + lcl: (t:-54.856552124,p:662.370849609), + lfc: nil, + el: nil, + top: nil, + area_count: 1, + area_type: "a0", + t_count: 91, + p_count: 91, + t_first: -54.856552124, + t_last: -139.985351562, + t_mean: -93.3388707088, + p_first: 662.370849609, + p_last: 56.2566757202, + p_mean: 374.741248204 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 0, + cin: 0, + li: 25.7303377345, + lcl: (t:-54.851819779,p:662.370849609), + lfc: nil, + el: nil, + top: nil, + area_count: 1, + area_type: "a0", + t_count: 91, + p_count: 91, + t_first: -54.851819779, + t_last: -139.985351562, + t_mean: -93.3377993121, + p_first: 662.370849609, + p_last: 56.2566757202, + p_mean: 374.741248204 + ) + parcel = thermo_parcel_path(prof, (top_p: 600)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_inversion_cold + +#-------------------------------------- +# use case : inversion with unstable conditions +# in the Baltic +#-------------------------------------- +function test_parcel_grib_inversion_unstable() + + fn_name = "test_parcel_grib_inversion_unstable" + + data_grb=read("thermo_profile_baltic.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [56.5, 24.7], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 981.244463986, + cin: 79.6396786209, + li: -3.8461594375, + lcl: (t:20.102841941,p:974.7625569), + lfc: (t:12.406078349,p:793.511724936), + el: (t:-48.18916193,p:238.263931328), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 83, + p_count: 83, + t_first: 22.511077881, + t_last: -97.973632812, + t_mean: -16.5319233796, + p_first: 1003.07788086, + p_last: 98.4139328003, + p_mean: 566.211329419 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual, layer=1hPa, + # it should be the same as the surface since the + # layer is very thin + parcel = thermo_parcel_path(prof, (layer_depth: 1, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, non-virtual + ref = ( + cape: 1603.91200489, + cin: 9.06396065273, + li: -5.2817063125, + lcl: (t:15.923494858,p:848.691578958), + lfc: (t:14.514096849,p:816.961565668), + el: (t:-56.603712961,p:200.091734298), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 62, + p_count: 62, + t_first: 17.896392822, + t_last: -96.127929687, + t_mean: -27.4667325322, + p_first: 869.144714355, + p_last: 98.4139328003, + p_mean: 429.496244341 + ) + + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + + # 4. mucape, virtual + ref = ( + cape: 1742.98080645, + cin: 6.52959457711, + li: -4.9898964415, + lcl: (t:18.271378717,p:848.691578958), + lfc: (t:17.031158469,p:823.146292527), + el: (t:-56.617700223,p:200.005985309), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 62, + p_count: 62, + t_first: 20.260300202, + t_last: -96.127892182, + t_mean: -26.6880648133, + p_first: 869.144714355, + p_last: 98.4139328003, + p_mean: 429.594614952 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,4) + + # 5. mucape implicite, virtual, default layer + parcel = thermo_parcel_path(prof) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,5) + +end test_parcel_grib_inversion_unstable + +function plot_parcel(prof, parcel) + + parcel_area = thermo_parcel_area(parcel) + + if parcel_area <> nil and parcel["t"] <> nil then + parcel_vis = xy_curve(parcel["t"], parcel["p"], "charcoal", "dash", 6) + end if + + prof_vis = mthermo( + thermo_temperature_line_thickness:5, thermo_dewpoint_line_thickness:5 + ) + + view = thermoview( + type:"skewt", + minimum_temperature:-140, + maximum_temperature:40, + top_pressure:100, + subpage_clipping:"on" + ) + if parcel_area <> nil then + plot(view, parcel_area, prof, prof_vis, parcel_vis) + else + plot(view, prof, prof_vis) + end if + +end plot_parcel \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_inversion_unstable.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_inversion_unstable.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_inversion_unstable.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_inversion_unstable.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,126 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +# GRIB - model levels +test_parcel_grib_inversion_unstable() + +#-------------------------------------- +# use case : inversion with unstable conditions +# in the Baltic +#-------------------------------------- +function test_parcel_grib_inversion_unstable() + + fn_name = "test_parcel_grib_inversion_unstable" + + data_grb=read("thermo_profile_baltic.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [56.5, 24.7], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 981.244463986, + cin: 79.6396786209, + li: -3.8461594375, + lcl: (t:20.102841941,p:974.7625569), + lfc: (t:12.406078349,p:793.511724936), + el: (t:-48.18916193,p:238.263931328), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 83, + p_count: 83, + t_first: 22.511077881, + t_last: -97.973632812, + t_mean: -16.5319233796, + p_first: 1003.07788086, + p_last: 98.4139328003, + p_mean: 566.211329419 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual, layer=1hPa, + # it should be the same as the surface since the + # layer is very thin + parcel = thermo_parcel_path(prof, (layer_depth: 1, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, non-virtual + ref = ( + cape: 1603.91200489, + cin: 9.06396065273, + li: -5.2817063125, + lcl: (t:15.923494858,p:848.691578958), + lfc: (t:14.514096849,p:816.961565668), + el: (t:-56.603712961,p:200.091734298), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 62, + p_count: 62, + t_first: 17.896392822, + t_last: -96.127929687, + t_mean: -27.4667325322, + p_first: 869.144714355, + p_last: 98.4139328003, + p_mean: 429.496244341 + ) + + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + + # 4. mucape, virtual + ref = ( + cape: 1742.98080645, + cin: 6.52959457711, + li: -4.9898964415, + lcl: (t:18.271378717,p:848.691578958), + lfc: (t:17.031158469,p:823.146292527), + el: (t:-56.617700223,p:200.005985309), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 62, + p_count: 62, + t_first: 20.260300202, + t_last: -96.127892182, + t_mean: -26.6880648133, + p_first: 869.144714355, + p_last: 98.4139328003, + p_mean: 429.594614952 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,4) + + # 5. mucape implicite, virtual, default layer + parcel = thermo_parcel_path(prof) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,5) + +end test_parcel_grib_inversion_unstable diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_inversion_warm_sea.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_inversion_warm_sea.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_inversion_warm_sea.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_inversion_warm_sea.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,95 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +# GRIB - model levels +test_parcel_grib_inversion_warm_sea() + +#------------------------------------------------- +# use case : strong inversion in the tropics +# over sea +#------------------------------------------------- +function test_parcel_grib_inversion_warm_sea() + + fn_name = "test_parcel_grib_inversion_warm_sea" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [-20,-10], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 4.64192296131, + cin: 0, + li: 8.3812020345, + lcl: (t:13.861418388,p:924.80649016), + lfc: (t:21.299697876,p:1011.4755249), + el: (t:13.837027864,p:922.819124892), + top: nil, + area_count: 1, + area_type: "a1", + t_count: 92, + p_count: 92, + t_first: 21.299697876, + t_last: -130.463867187, + t_mean: -32.8533671847, + p_first: 1011.4755249, + p_last: 56.2566757202, + p_mean: 519.939701753 + ) + + #stopwatch_start("1") + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #stopwatch_stop() + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 7.47356572127, + cin: 0, + li: 8.4430773625, + lcl: (t:15.732086262,p:924.80649016), + lfc: (t:23.218844887,p:1011.4755249), + el: (t:14.770261296,p:904.320584596), + top: nil, + area_count: 1, + area_type: "a1", + t_count: 92, + p_count: 92, + t_first: 23.218844887, + t_last: -130.463867181, + t_mean: -32.0986103672, + p_first: 1011.4755249, + p_last: 56.2566757202, + p_mean: 519.738630663 + ) + parcel = thermo_parcel_path(prof, (top_p: 600)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_inversion_warm_sea + \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_sahara.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_sahara.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_sahara.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_sahara.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,91 @@ +#Metview Macro + + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +test_parcel_grib_sahara() + +#--------------------------------- +# use case : Sahara +#--------------------------------- +function test_parcel_grib_sahara + + fn_name = "test_parcel_grib_sahara" + + data_grb=read("thermo_profile.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [15,0], + data : data_grb + ) + + # 1. surface, top, non-virtual + ref = ( + cape: 0, + cin: 0, + li: 15.3632783055, + lcl: (t:-19.579410263,p:524.034000658), + lfc: nil, + el: nil, + top: nil, + area_count: 2, + area_type: "a10", + t_count: 93, + p_count: 93, + t_first: 29.996032715, + t_last: -139.252929687, + t_mean: -37.1011922795, + p_first: 979.226928711, + p_last: 52.8644294739, + p_mean: 497.927884898 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off", comp_top: "on")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 0, + cin: 0, + li: 15.4237942535, + lcl: (t:-19.340482548,p:524.034000658), + lfc: nil, + el: nil, + top: nil, + area_count: 2, + area_type: "a10", + t_count: 93, + p_count: 93, + t_first: 30.281671211, + t_last: -139.252929687, + t_mean: -36.9633570008, + p_first: 979.226928711, + p_last: 52.8644294739, + p_mean: 497.919274643 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_sahara \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_unstable.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_unstable.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_unstable.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_unstable.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,304 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +# GRIB - model levels +test_parcel_grib_unstable_india() +test_parcel_grib_unstable_red_sea() + +# GRIB - pressure levels +test_parcel_grib_pl_unstable_india() + +#------------------------------------- +# use case : India +#-------------------------------------- +function test_parcel_grib_unstable_india() + + fn_name = "test_parcel_grib_unstable_india" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [20,85], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 3944.81105942, + cin: 195.781841881, + li: -8.5398427825, + lcl: (t:25.818828091,p:957.645019851), + lfc: (t:17.497766668,p:747.815475607), + el: (t:-77.232369652,p:108.559184976), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 93, + p_count: 93, + t_first: 29.299697876, + t_last: -110.747070312, + t_mean: -16.4547600578, + p_first: 997.25378418, + p_last: 56.2566757202, + p_mean: 508.491185511 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + ref = ( + cape: 4035.69945142, + cin: 183.109400081, + li: -8.6570302825, + lcl: (t:25.541316037,p:947.580057765), + lfc: (t:17.673029471,p:749.713012081), + el: (t:-77.353022257,p:107.925208407), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 89, + p_count: 89, + t_first: 28.942886353, + t_last: -110.571289062, + t_mean: -18.3227683131, + p_first: 985.903076172, + p_last: 56.2566757202, + p_mean: 486.47529522 + ) + + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 4308.06924351, + cin: 71.7771979858, + li: -7.9496169905, + lcl: (t:29.490505797,p:947.580057765), + lfc: (t:22.597289355,p:788.798470432), + el: (t:-77.353106417,p:107.922961121), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 89, + p_count: 89, + t_first: 32.937048953, + t_last: -110.571286667, + t_mean: -16.6451556846, + p_first: 985.903076172, + p_last: 56.2566757202, + p_mean: 486.914432423 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_unstable_india + + +#-------------------------------------- +# use case : Red Sea +#-------------------------------------- +function test_parcel_grib_unstable_red_sea() + + fn_name = "test_parcel_grib_red_sea" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [15,40], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 5317.06938253, + cin: 105.890041808, + li: -9.4428576735, + lcl: (t:23.705214755,p:889.734498437), + lfc: (t:18.896936164,p:770.60466348), + el: (t:-79.009818892,p:103.360646362), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 93, + p_count: 93, + t_first: 26.393447876, + t_last: -109.956054687, + t_mean: -17.4654646938, + p_first: 918.264770508, + p_last: 56.2566757202, + p_mean: 477.422428974 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + ref = ( + cape: 5478.93387281, + cin: 91.1731892391, + li: -9.6479357985, + lcl: (t:23.313702311,p:875.993514692), + lfc: (t:19.128312456,p:773.191440284), + el: (t:-79.094906488,p:102.569362608), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 91, + p_count: 91, + t_first: 26.885543823, + t_last: -109.663085937, + t_mean: -18.1229361082, + p_first: 913.505126953, + p_last: 56.2566757202, + p_mean: 467.575051227 + ) + + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 5844.45396746, + cin: 18.2945644127, + li: -9.0877570475, + lcl: (t:27.021779322,p:875.993514692), + lfc: (t:24.990880114,p:829.722655181), + el: (t:-79.094675213,p:102.568226728), + top: nil, + area_count: 4, + area_type: "a0101", + t_count: 93, + p_count: 93, + t_first: 30.638294824, + t_last: -109.663082925, + t_mean: -15.4887494816, + p_first: 913.505126953, + p_last: 56.2566757202, + p_mean: 477.575202786 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_unstable_red_sea + +#-------------------------------------- +# use case : India (PL) +#-------------------------------------- +function test_parcel_grib_pl_unstable_india() + + fn_name = "test_parcel_grib_unstable_india" + + data_grb=read("thermo_profile_pl_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [20,85], + data : data_grb + ) + + # 1. surface, non-virtual + ref = ( + cape: 3906.26091767, + cin: 157.969138622, + li: -9.1297454835, + lcl: (t:25.637553196,p:947.428218529), + lfc: (t:17.96618347,p:757.608263855), + el: (t:-75.09489288,p:113.249224647), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 16, + p_count: 16, + t_first: 30.281982422, + t_last: -81.274414062, + t_mean: -13.6751979958, + p_first: 1000, + p_last: 100, + p_mean: 518.330356689 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + ref = ( + cape: 3906.26091767, + cin: 157.969138622, + li: -9.1297454835, + lcl: (t:25.637553196,p:947.428218529), + lfc: (t:17.96618347,p:757.608263855), + el: (t:-75.09489288,p:113.249224647), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 16, + p_count: 16, + t_first: 30.281982422, + t_last: -81.274414062, + t_mean: -13.6751979958, + p_first: 1000, + p_last: 100, + p_mean: 518.330356689 + ) + + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 4197.02332118, + cin: 59.3273978973, + li: -8.3938820535, + lcl: (t:29.611677169,p:947.428218529), + lfc: (t:23.16719917,p:801.518334019), + el: (t:-75.099118135,p:113.231849753), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 16, + p_count: 16, + t_first: 34.317879115, + t_last: -81.27381381, + t_mean: -11.7498148404, + p_first: 1000, + p_last: 100, + p_mean: 521.073650144 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_unstable_india diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_grib_warm_atl.mv metview-5.19.2/metview/test/macros/thermo_parcel_grib_warm_atl.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_grib_warm_atl.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_grib_warm_atl.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,111 @@ +#Metview Macro + + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + +include "test_utils.mv" +include "thermo_parcel_utils.mv" + +test_parcel_grib_warm_atl() + +#--------------------------------------- +# use case : North Atlantic near Africa +#--------------------------------------- +function test_parcel_grib_warm_atl() + + fn_name = "test_parcel_grib_warm_atl" + + data_grb=read("thermo_profile_east.grib") + + # extract thermo profile + prof = thermo_grib( + coordinates : [10,-20], + data : data_grb + ) + + # 1. surface, top, non-virtual + ref = ( + cape: 1368.95064427, + cin: 123.025933505, + li: -3.7620992685, + lcl: (t:22.448457063,p:968.899173957), + lfc: (t:11.697744605,p:719.451607078), + el: (t:-67.71947392,p:154.092224549), + top: (t:-98.565467401,p:87.0463373065), + area_count: 3, + area_type: "a010", + t_count: 84, + p_count: 84, + t_first: 26.143447876, + t_last: -97.7392578125, + t_mean: -13.3441105327, + p_first: 1011.96954346, + p_last: 88.5111694336, + p_mean: 562.315255268 + ) + + parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off", comp_top: "on")) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,1) + + # 2. mucape, non-virtual + ref = ( + cape: 1420.74987416, + cin: 113.173552339, + li: -3.8499898935, + lcl: (t:21.738479335,p:947.983566793), + lfc: (t:11.912316537,p:722.101048795), + el: (t:-68.197574586,p:152.457283326), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 81, + p_count: 81, + t_first: 22.920669556, + t_last: -118.920898437, + t_mean: -29.7166030558, + p_first: 961.356201172, + p_last: 56.2566757202, + p_mean: 442.728373424 + ) + parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,2) + + # 3. mucape, virtual + ref = ( + cape: 1581.39134697, + cin: 57.2346574351, + li: -3.5149876645, + lcl: (t:24.829383176,p:947.983566793), + lfc: (t:16.146147453,p:761.347808892), + el: (t:-68.198986663,p:152.445349872), + top: nil, + area_count: 2, + area_type: "a01", + t_count: 81, + p_count: 81, + t_first: 26.023964225, + t_last: -118.920898189, + t_mean: -28.6433312508, + p_first: 961.356201172, + p_last: 56.2566757202, + p_mean: 443.212754 + ) + parcel = thermo_parcel_path(prof, (top_p: 700)) + #plot_parcel(prof, parcel) + #__print_parcel_result_for_test(parcel) + test_parcel_core(parcel,ref,fn_name,3) + +end test_parcel_grib_warm_atl + diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel.mv metview-5.19.2/metview/test/macros/thermo_parcel.mv --- metview-5.17.4/metview/test/macros/thermo_parcel.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel.mv 1970-01-01 00:00:00.000000000 +0000 @@ -1,1532 +0,0 @@ -#Metview Macro - - -# **************************** LICENSE START *********************************** -# -# Copyright 2019 ECMWF. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ -# - -include "test_utils.mv" - -# GRIB - model levels -test_parcel_grib_amazon() -test_parcel_grib_sahara() -test_parcel_grib_warm_atl() -test_parcel_grib_inversion_warm_sea() -test_parcel_grib_inversion_cold() -test_parcel_grib_inversion_unstable() -test_parcel_grib_himalayas() -test_parcel_grib_unstable_india() -test_parcel_grib_unstable_red_sea() -test_parcel_grib_large_cin() -test_parcel_grib_capping_cin() - -# GRIB - pressure levels -test_parcel_grib_pl_unstable_india() - -# BUFR -test_parcel_bufr_unstable() - -#--------------------------------- -# use case : Amazon rainforest -#--------------------------------- -function test_parcel_grib_amazon() - - fn_name = "test_parcel_grib_amazon" - - data_grb=read("thermo_profile.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [0,-60], - data : data_grb - ) - - # 0. surface, top, non-virtual - ref = ( - cape: 1672.86107626, - cin: 2.96158852846, - li: -4.4753504185, - lcl: (t:23.212939019,p:979.738781199), - lfc: (t:21.466259477,p:932.203981587), - el: (t:-66.587576048,p:154.403688225), - top: (t:-104.884062131,p:75.2039485425), - area_count: 4, - area_type: "a1010", - t_count: 87, - p_count: 87, - t_first: 24.683532715, - t_last: -102.221679688, - t_mean: -14.6652398094, - p_first: 996.865844727, - p_last: 79.4493560791, - p_mean: 552.416078479 - ) - - #stopwatch_start("1") - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off", comp_top: "on")) - #plot_parcel(prof, parcel) - #stopwatch_stop() - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,0) - - # 1. surface, top, non-virtual, using keywords (to simulate the call from Python) - parcel = thermo_parcel_path(prof, "mode", "surface", "virtual", "off", "comp_top", "on") - test_parcel_core(parcel,ref,fn_name,1) - - # 2. surface, top, non-virtual - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 0, comp_top: 1)) - test_parcel_core(parcel,ref,fn_name,2) - -# # 3. surface, el_area, non-virtual -# ref = ( -# cape: 1672.86107626, -# cin: 2.96158852846, -# li: -4.4753504185, -# lcl: (t:23.212939019,p:979.738781199), -# lfc: (t:21.466259477,p:932.203981587), -# el: (t:-66.587576048,p:154.403688225), -# top: nil, -# area_count: 4, -# area_type: "a1010", -# t_count: 95, -# p_count: 95, -# t_first: 24.683532715, -# t_last: -121.000976562, -# t_mean: -23.0240222465, -# p_first: 996.865844727, -# p_last: 52.8644294739, -# p_mean: 511.146149103 -# ) -# -# parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 0, el_area: 1)) -# #__print_parcel_result_for_test(parcel) -# test_parcel_core(parcel,ref,fn_name,3) - - # 4. surface, stop_at_el, non-virtual - ref = ( - cape: 1672.86107626, - cin: 2.96158852846, - li: -4.4753504185, - lcl: (t:23.212939019,p:979.738781199), - lfc: (t:21.466259477,p:932.203981587), - el: (t:-66.587576048,p:154.403688225), - top: nil, - area_count: 3, - area_type: "a101", - t_count: 74, - p_count: 74, - t_first: 24.683532715, - t_last: -66.587576048, - t_mean: -2.16073537975, - p_first: 996.865844727, - p_last: 154.403688225, - p_mean: 629.972289291 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 0, stop_at_el: 1)) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name, 4) - - # 5. surface, non-virtual - ref = ( - cape: 1672.86107626, - cin: 2.96158852846, - li: -4.4753504185, - lcl: (t:23.212939019,p:979.738781199), - lfc: (t:21.466259477,p:932.203981587), - el: (t:-66.587576048,p:154.403688225), - top: nil, - area_count: 3, - area_type: "a101", - t_count: 95, - p_count: 95, - t_first: 24.683532715, - t_last: -121.000976562, - t_mean: -23.0240222465, - p_first: 996.865844727, - p_last: 52.8644294739, - p_mean: 511.146149103 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 0)) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name, 5) - - # 6. custom, non-virtual - ref = ( - cape: 2844.99479448, - cin: 0, - li: -6.1159754185, - lcl: (t:22.253283037,p:924.471194437), - lfc: (t:28.683532715,p:996.865844727), - el: (t:-68.624110809,p:141.987453431), - top: nil, - area_count: 1, - area_type: "a1", - t_count: 93, - p_count: 93, - t_first: 28.683532715, - t_last: -118.862304687, - t_mean: -21.8091460709, - p_first: 996.865844727, - p_last: 52.8644294739, - p_mean: 500.83492028 - ) - info = thermo_data_info(prof) - opt = (mode: "custom", - start_p: info.bottom_p, - start_t: info.bottom_t + 4, - start_td: info.bottom_td, - virtual: 0) - - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,6) - - # 7. mean layer, non-virtual - ref = ( - cape: 143.6538341, - cin: 58.6754635717, - li: -1.3698816685, - lcl: (t:16.986701813,p:869.840324866), - lfc: (t:2.790296854,p:603.122620868), - el: (t:-32.713065145,p:295.173075496), - top: nil, - area_count: 5, - area_type: "a10101", - t_count: 78, - p_count: 78, - t_first: 19.396555901, - t_last: -124.663085937, - t_mean: -36.8208262852, - p_first: 895.399343491, - p_last: 52.8644294739, - p_mean: 399.001046631 - ) - - info = thermo_data_info(prof) - opt = (mode: "mean_layer", - bottom_p: info.bottom_p, - top_p: 700, - mean_start_from_theta: 0, - virtual: 0) - - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name, 7) - - # 8. mucape, non-virtual - ref = ( - cape: 1672.86107626, - cin: 2.96158852846, - li: -4.4753504185, - lcl: (t:23.212939019,p:979.738781199), - lfc: (t:21.466259477,p:932.203981587), - el: (t:-66.587576048,p:154.403688225), - top: nil, - area_count: 3, - area_type: "a101", - t_count: 95, - p_count: 95, - t_first: 24.683532715, - t_last: -121.000976562, - t_mean: -23.0240222465, - p_first: 996.865844727, - p_last: 52.8644294739, - p_mean: 511.146149103 - ) - - info = thermo_data_info(prof) - opt = (mode: "mucape", - top_p: 700, - virtual: 0) - - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name, 8) - - # 9. surface, explicit virtual (string) - ref = ( - cape: 1842.38184522, - cin: 0, - li: -3.8547100225, - lcl: (t:26.502372912,p:979.738781199), - lfc: (t:25.63666154,p:958.466798426), - el: (t:-66.58861251,p:154.390847059), - top: nil, - area_count: 3, - area_type: "a101", - t_count: 95, - p_count: 95, - t_first: 27.989288681, - t_last: -121.000976419, - t_mean: -21.6594902733, - p_first: 996.865844727, - p_last: 52.8644294739, - p_mean: 511.229215802 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "on")) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,9) - - # 10. surface , explicit virtual (number) - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: 1)) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,10) - - # 11. surface , implicit virtual - parcel = thermo_parcel_path(prof, (mode: "surface")) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,11) - - # 12. mucape explicit , implicit virtual - parcel = thermo_parcel_path(prof, (mode: "mucape", top_p: 700)) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,12) - - # 13. mucape implicit , implicit virtual - parcel = thermo_parcel_path(prof, (top_p: 700)) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,13) - - # 14. mucape implicit , implicit virtual, layer - parcel = thermo_parcel_path(prof, (layer_depth: 300)) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,14) - - # 15. mean_layer, implicit virtual - ref = ( - cape: 204.840069774, - cin: 36.8992628233, - li: -0.7492412725, - lcl: (t:19.447800848,p:869.840324866), - lfc: (t:9.69979889,p:686.928740465), - el: (t:-33.069884476,p:292.844083873), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 75, - p_count: 75, - t_first: 21.878095939, - t_last: -124.663085891, - t_mean: -37.8973075448, - p_first: 895.399343491, - p_last: 52.8644294739, - p_mean: 387.376783238 - ) - info = thermo_data_info(prof) - opt = (mode: "mean_layer", - bottom_p: info.bottom_p, - top_p: 700, - mean_start_from_theta: 0) - - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,15) - - # 16. mean_layer, theta mean, implicit virtual - ref = ( - cape: 0, - cin: 0, - li: 0.7741962275, - lcl: (t:17.000521874,p:842.974355672), - lfc: nil, - el: nil, - top: nil, - area_count: 2, - area_type: "a10", - t_count: 93, - p_count: 93, - t_first: 31.234771756, - t_last: -126.30371091, - t_mean: -25.6626788631, - p_first: 996.865844727, - p_last: 52.8644294739, - p_mean: 508.028439142 - ) - opt = (mode: "ml", - top_p: 700) - - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,16) - - # 17. mean_layer, depth=50hpa, theta mean, implicit virtual - ref = ( - cape: 766.01129084, - cin: 18.7511630774, - li: -2.1261943975, - lcl: (t:23.903070817,p:947.911666671), - lfc: (t:20.610921306,p:872.584255166), - el: (t:-55.552685332,p:195.087842543), - top: nil, - area_count: 3, - area_type: "a101", - t_count: 95, - p_count: 95, - t_first: 28.206274658, - t_last: -123.110351487, - t_mean: -23.3786116226, - p_first: 996.865844727, - p_last: 52.8644294739, - p_mean: 510.517363109 - ) - info = thermo_data_info(prof) - opt = (mode: "ml", - layer_depth: 50) - - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,17) - - # 18. ml50, theta mean, implicit virtual - opt = (mode: "ml50") - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,18) - - # 19. mean_layer, depth=100hpa, theta mean, implicit virtual - ref = ( - cape: 514.589755616, - cin: 23.4780659507, - li: -1.5988506475, - lcl: (t:22.658128624,p:927.504967924), - lfc: (t:18.445959733,p:834.968816789), - el: (t:-47.120520308,p:227.143697673), - top: nil, - area_count: 3, - area_type: "a101", - t_count: 95, - p_count: 95, - t_first: 28.814490086, - t_last: -123.696289, - t_mean: -23.725023991, - p_first: 996.865844727, - p_last: 52.8644294739, - p_mean: 510.141148607 - ) - opt = (mode: "ml", - layer_depth: 100) - - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,19) - - # 20. ml100, theta mean, implicit virtual - opt = (mode: "ml100") - parcel = thermo_parcel_path(prof, opt) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,20) - -end test_parcel_grib_amazon - -#--------------------------------- -# use case : Sahara -#--------------------------------- -function test_parcel_grib_sahara - - fn_name = "test_parcel_grib_sahara" - - data_grb=read("thermo_profile.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [15,0], - data : data_grb - ) - - # 1. surface, top, non-virtual - ref = ( - cape: 0, - cin: 0, - li: 15.3632783055, - lcl: (t:-19.579410263,p:524.034000658), - lfc: nil, - el: nil, - top: nil, - area_count: 2, - area_type: "a10", - t_count: 93, - p_count: 93, - t_first: 29.996032715, - t_last: -139.252929687, - t_mean: -37.1011922795, - p_first: 979.226928711, - p_last: 52.8644294739, - p_mean: 497.927884898 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off", comp_top: "on")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 0, - cin: 0, - li: 15.4237942535, - lcl: (t:-19.340482548,p:524.034000658), - lfc: nil, - el: nil, - top: nil, - area_count: 2, - area_type: "a10", - t_count: 93, - p_count: 93, - t_first: 30.281671211, - t_last: -139.252929687, - t_mean: -36.9633570008, - p_first: 979.226928711, - p_last: 52.8644294739, - p_mean: 497.919274643 - ) - parcel = thermo_parcel_path(prof, (top_p: 700)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_sahara - -#--------------------------------------- -# use case : North Atlantic near Africa -#--------------------------------------- -function test_parcel_grib_warm_atl() - - fn_name = "test_parcel_grib_warm_atl" - - data_grb=read("thermo_profile_east.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [10,-20], - data : data_grb - ) - - # 1. surface, top, non-virtual - ref = ( - cape: 1368.95064427, - cin: 123.025933505, - li: -3.7620992685, - lcl: (t:22.448457063,p:968.899173957), - lfc: (t:11.697744605,p:719.451607078), - el: (t:-67.71947392,p:154.092224549), - top: (t:-98.565467401,p:87.0463373065), - area_count: 3, - area_type: "a010", - t_count: 84, - p_count: 84, - t_first: 26.143447876, - t_last: -97.7392578125, - t_mean: -13.3441105327, - p_first: 1011.96954346, - p_last: 88.5111694336, - p_mean: 562.315255268 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off", comp_top: "on")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - ref = ( - cape: 1420.74987416, - cin: 113.173552339, - li: -3.8499898935, - lcl: (t:21.738479335,p:947.983566793), - lfc: (t:11.912316537,p:722.101048795), - el: (t:-68.197574586,p:152.457283326), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 81, - p_count: 81, - t_first: 22.920669556, - t_last: -118.920898437, - t_mean: -29.7166030558, - p_first: 961.356201172, - p_last: 56.2566757202, - p_mean: 442.728373424 - ) - parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 1581.39134697, - cin: 57.2346574351, - li: -3.5149876645, - lcl: (t:24.829383176,p:947.983566793), - lfc: (t:16.146147453,p:761.347808892), - el: (t:-68.198986663,p:152.445349872), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 81, - p_count: 81, - t_first: 26.023964225, - t_last: -118.920898189, - t_mean: -28.6433312508, - p_first: 961.356201172, - p_last: 56.2566757202, - p_mean: 443.212754 - ) - parcel = thermo_parcel_path(prof, (top_p: 700)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_warm_atl - -#------------------------------------------------- -# use case : strong inversion in the tropics -# over sea -#------------------------------------------------- -function test_parcel_grib_inversion_warm_sea() - - fn_name = "test_parcel_grib_inversion_warm_sea" - - data_grb=read("thermo_profile_east.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [-20,-10], - data : data_grb - ) - - # 1. surface, non-virtual - ref = ( - cape: 4.64192296131, - cin: 0, - li: 8.3812020345, - lcl: (t:13.861418388,p:924.80649016), - lfc: (t:21.299697876,p:1011.4755249), - el: (t:13.837027864,p:922.819124892), - top: nil, - area_count: 1, - area_type: "a1", - t_count: 92, - p_count: 92, - t_first: 21.299697876, - t_last: -130.463867187, - t_mean: -32.8533671847, - p_first: 1011.4755249, - p_last: 56.2566757202, - p_mean: 519.939701753 - ) - - #stopwatch_start("1") - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #stopwatch_stop() - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 7.47356572127, - cin: 0, - li: 8.4430773625, - lcl: (t:15.732086262,p:924.80649016), - lfc: (t:23.218844887,p:1011.4755249), - el: (t:14.770261296,p:904.320584596), - top: nil, - area_count: 1, - area_type: "a1", - t_count: 92, - p_count: 92, - t_first: 23.218844887, - t_last: -130.463867181, - t_mean: -32.0986103672, - p_first: 1011.4755249, - p_last: 56.2566757202, - p_mean: 519.738630663 - ) - parcel = thermo_parcel_path(prof, (top_p: 600)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_inversion_warm_sea - - -#-------------------------------------- -# use case : inversion in Antarctica -#-------------------------------------- -function test_parcel_grib_inversion_cold() - - fn_name = "test_parcel_grib_inversion_cold" - - data_grb=read("thermo_profile_east.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [-80,20], - data : data_grb - ) - - # 1. surface, non-virtual - ref = ( - cape: 0, - cin: 0, - li: 25.7207087535, - lcl: (t:-54.856552124,p:662.370849609), - lfc: nil, - el: nil, - top: nil, - area_count: 1, - area_type: "a0", - t_count: 91, - p_count: 91, - t_first: -54.856552124, - t_last: -139.985351562, - t_mean: -93.3388707088, - p_first: 662.370849609, - p_last: 56.2566757202, - p_mean: 374.741248204 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 0, - cin: 0, - li: 25.7303377345, - lcl: (t:-54.851819779,p:662.370849609), - lfc: nil, - el: nil, - top: nil, - area_count: 1, - area_type: "a0", - t_count: 91, - p_count: 91, - t_first: -54.851819779, - t_last: -139.985351562, - t_mean: -93.3377993121, - p_first: 662.370849609, - p_last: 56.2566757202, - p_mean: 374.741248204 - ) - parcel = thermo_parcel_path(prof, (top_p: 600)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_inversion_cold - -#-------------------------------------- -# use case : inversion with unstable conditions -# in the Baltic -#-------------------------------------- -function test_parcel_grib_inversion_unstable() - - fn_name = "test_parcel_grib_inversion_unstable" - - data_grb=read("thermo_profile_baltic.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [56.5, 24.7], - data : data_grb - ) - - # 1. surface, non-virtual - ref = ( - cape: 981.244463986, - cin: 79.6396786209, - li: -3.8461594375, - lcl: (t:20.102841941,p:974.7625569), - lfc: (t:12.406078349,p:793.511724936), - el: (t:-48.18916193,p:238.263931328), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 83, - p_count: 83, - t_first: 22.511077881, - t_last: -97.973632812, - t_mean: -16.5319233796, - p_first: 1003.07788086, - p_last: 98.4139328003, - p_mean: 566.211329419 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual, layer=1hPa, - # it should be the same as the surface since the - # layer is very thin - parcel = thermo_parcel_path(prof, (layer_depth: 1, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, non-virtual - ref = ( - cape: 1603.91200489, - cin: 9.06396065273, - li: -5.2817063125, - lcl: (t:15.923494858,p:848.691578958), - lfc: (t:14.514096849,p:816.961565668), - el: (t:-56.603712961,p:200.091734298), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 62, - p_count: 62, - t_first: 17.896392822, - t_last: -96.127929687, - t_mean: -27.4667325322, - p_first: 869.144714355, - p_last: 98.4139328003, - p_mean: 429.496244341 - ) - - parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - - # 4. mucape, virtual - ref = ( - cape: 1742.98080645, - cin: 6.52959457711, - li: -4.9898964415, - lcl: (t:18.271378717,p:848.691578958), - lfc: (t:17.031158469,p:823.146292527), - el: (t:-56.617700223,p:200.005985309), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 62, - p_count: 62, - t_first: 20.260300202, - t_last: -96.127892182, - t_mean: -26.6880648133, - p_first: 869.144714355, - p_last: 98.4139328003, - p_mean: 429.594614952 - ) - parcel = thermo_parcel_path(prof, (top_p: 700)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,4) - - # 5. mucape implicite, virtual, default layer - parcel = thermo_parcel_path(prof) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,5) - -end test_parcel_grib_inversion_unstable - -#-------------------------------------- -# use case : Himalayas -#-------------------------------------- -function test_parcel_grib_himalayas() - - fn_name = "test_parcel_grib_himalayas" - - data_grb=read("thermo_profile_east.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [30,80], - data : data_grb - ) - - # 1. surface, non-virtual - ref = ( - cape: 0, - cin: 0, - li: 6.4110684865, - lcl: (t:-0.375000251,p:635.596916122), - lfc: nil, - el: nil, - top: nil, - area_count: 1, - area_type: "a0", - t_count: 91, - p_count: 91, - t_first: 11.299697876, - t_last: -128.559570312, - t_mean: -38.4291593194, - p_first: 736.047302246, - p_last: 56.2566757202, - p_mean: 403.547307737 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - parcel = thermo_parcel_path(prof, (top_p: 600, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 0, - cin: 0, - li: 6.6983161235, - lcl: (t:0.594173086,p:635.596916122), - lfc: nil, - el: nil, - top: nil, - area_count: 1, - area_type: "a0", - t_count: 91, - p_count: 91, - t_first: 12.310350056, - t_last: -128.5595703, - t_mean: -38.0115108289, - p_first: 736.047302246, - p_last: 56.2566757202, - p_mean: 403.547307737 - ) - - parcel = thermo_parcel_path(prof, (top_p: 600)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_himalayas - - -#-------------------------------------- -# use case : India -#-------------------------------------- -function test_parcel_grib_unstable_india() - - fn_name = "test_parcel_grib_unstable_india" - - data_grb=read("thermo_profile_east.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [20,85], - data : data_grb - ) - - # 1. surface, non-virtual - ref = ( - cape: 3944.81105942, - cin: 195.781841881, - li: -8.5398427825, - lcl: (t:25.818828091,p:957.645019851), - lfc: (t:17.497766668,p:747.815475607), - el: (t:-77.232369652,p:108.559184976), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 93, - p_count: 93, - t_first: 29.299697876, - t_last: -110.747070312, - t_mean: -16.4547600578, - p_first: 997.25378418, - p_last: 56.2566757202, - p_mean: 508.491185511 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - ref = ( - cape: 4035.69945142, - cin: 183.109400081, - li: -8.6570302825, - lcl: (t:25.541316037,p:947.580057765), - lfc: (t:17.673029471,p:749.713012081), - el: (t:-77.353022257,p:107.925208407), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 89, - p_count: 89, - t_first: 28.942886353, - t_last: -110.571289062, - t_mean: -18.3227683131, - p_first: 985.903076172, - p_last: 56.2566757202, - p_mean: 486.47529522 - ) - - parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 4308.06924351, - cin: 71.7771979858, - li: -7.9496169905, - lcl: (t:29.490505797,p:947.580057765), - lfc: (t:22.597289355,p:788.798470432), - el: (t:-77.353106417,p:107.922961121), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 89, - p_count: 89, - t_first: 32.937048953, - t_last: -110.571286667, - t_mean: -16.6451556846, - p_first: 985.903076172, - p_last: 56.2566757202, - p_mean: 486.914432423 - ) - parcel = thermo_parcel_path(prof, (top_p: 700)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_unstable_india - - -#-------------------------------------- -# use case : Red Sea -#-------------------------------------- -function test_parcel_grib_unstable_red_sea() - - fn_name = "test_parcel_grib_red_sea" - - data_grb=read("thermo_profile_east.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [15,40], - data : data_grb - ) - - # 1. surface, non-virtual - ref = ( - cape: 5317.06938253, - cin: 105.890041808, - li: -9.4428576735, - lcl: (t:23.705214755,p:889.734498437), - lfc: (t:18.896936164,p:770.60466348), - el: (t:-79.009818892,p:103.360646362), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 93, - p_count: 93, - t_first: 26.393447876, - t_last: -109.956054687, - t_mean: -17.4654646938, - p_first: 918.264770508, - p_last: 56.2566757202, - p_mean: 477.422428974 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - ref = ( - cape: 5478.93387281, - cin: 91.1731892391, - li: -9.6479357985, - lcl: (t:23.313702311,p:875.993514692), - lfc: (t:19.128312456,p:773.191440284), - el: (t:-79.094906488,p:102.569362608), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 91, - p_count: 91, - t_first: 26.885543823, - t_last: -109.663085937, - t_mean: -18.1229361082, - p_first: 913.505126953, - p_last: 56.2566757202, - p_mean: 467.575051227 - ) - - parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 5844.45396746, - cin: 18.2945644127, - li: -9.0877570475, - lcl: (t:27.021779322,p:875.993514692), - lfc: (t:24.990880114,p:829.722655181), - el: (t:-79.094675213,p:102.568226728), - top: nil, - area_count: 4, - area_type: "a0101", - t_count: 93, - p_count: 93, - t_first: 30.638294824, - t_last: -109.663082925, - t_mean: -15.4887494816, - p_first: 913.505126953, - p_last: 56.2566757202, - p_mean: 477.575202786 - ) - parcel = thermo_parcel_path(prof, (top_p: 700)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_unstable_red_sea - -#-------------------------------------- -# use case : large cin near Italy -#-------------------------------------- -function test_parcel_grib_large_cin() - - fn_name = "test_parcel_grib_large_cin" - - data_grb=read("thermo_profile_east.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [40,10], - data : data_grb - ) - - # 1. surface, non-virtual - ref = ( - cape: 1322.74635153, - cin: 786.921305892, - li: -3.4988896805, - lcl: (t:19.26419474,p:953.782420839), - lfc: (t:3.539373348,p:636.165943283), - el: (t:-60.769950399,p:193.938640909), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 93, - p_count: 93, - t_first: 23.299697876, - t_last: -123.901367187, - t_mean: -27.3418373984, - p_first: 1000.66821289, - p_last: 56.2566757202, - p_mean: 509.486782363 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 1391.38631069, - cin: 632.083879166, - li: -3.1723186605, - lcl: (t:21.875563159,p:953.782420839), - lfc: (t:5.859350843,p:651.073646741), - el: (t:-60.769705583,p:193.916764654), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 93, - p_count: 93, - t_first: 25.947103619, - t_last: -123.901367132, - t_mean: -26.2791649056, - p_first: 1000.66821289, - p_last: 56.2566757202, - p_mean: 509.646845021 - ) - parcel = thermo_parcel_path(prof, (top_p: 700)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_large_cin - -#-------------------------------------- -# use case : capping cin -#-------------------------------------- -function test_parcel_grib_capping_cin() - - fn_name = "test_parcel_grib_capping_cin" - - data_grb=read("thermo_profile_capping_cin.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [24.4,-90.8], - data : data_grb - ) - - # 1. surface, virtual - ref = ( - cape: 1581.58708203, - cin: 26.0327675077, - li: -4.5345222805, - lcl: (t:25.914044511,p:983.291525421), - lfc: (t:17.041808375,p:785.84564365), - el: (t:-63.141607447,p:168.297424297), - top: nil, - area_count: 6, - area_type: "a010101", - t_count: 77, - p_count: 77, - t_first: 28.302976144, - t_last: -64.980749772, - t_mean: -0.181745758428, - p_first: 1011.06732178, - p_last: 163.082321167, - p_mean: 643.689105621 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "on")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. ml50, virtual - ref = ( - cape: 1103.85580005, - cin: 70.4889565715, - li: -3.6556160305, - lcl: (t:24.658549068,p:968.056298047), - lfc: (t:12.554736345,p:716.46978987), - el: (t:-54.984084744,p:197.430559437), - top: nil, - area_count: 3, - area_type: "a101", - t_count: 74, - p_count: 74, - t_first: 28.379301656, - t_last: -66.387833265, - t_mean: -1.72765083996, - p_first: 1011.06732178, - p_last: 163.082321167, - p_mean: 634.673725143 - ) - parcel = thermo_parcel_path(prof, (mode: "ml50")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - -end test_parcel_grib_capping_cin - - -#-------------------------------------- -# use case : India (PL) -#-------------------------------------- -function test_parcel_grib_pl_unstable_india() - - fn_name = "test_parcel_grib_unstable_india" - - data_grb=read("thermo_profile_pl_east.grib") - - # extract thermo profile - prof = thermo_grib( - coordinates : [20,85], - data : data_grb - ) - - # 1. surface, non-virtual - ref = ( - cape: 3906.26091767, - cin: 157.969138622, - li: -9.1297454835, - lcl: (t:25.637553196,p:947.428218529), - lfc: (t:17.96618347,p:757.608263855), - el: (t:-75.09489288,p:113.249224647), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 16, - p_count: 16, - t_first: 30.281982422, - t_last: -81.274414062, - t_mean: -13.6751979958, - p_first: 1000, - p_last: 100, - p_mean: 518.330356689 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - ref = ( - cape: 3906.26091767, - cin: 157.969138622, - li: -9.1297454835, - lcl: (t:25.637553196,p:947.428218529), - lfc: (t:17.96618347,p:757.608263855), - el: (t:-75.09489288,p:113.249224647), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 16, - p_count: 16, - t_first: 30.281982422, - t_last: -81.274414062, - t_mean: -13.6751979958, - p_first: 1000, - p_last: 100, - p_mean: 518.330356689 - ) - - parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 4197.02332118, - cin: 59.3273978973, - li: -8.3938820535, - lcl: (t:29.611677169,p:947.428218529), - lfc: (t:23.16719917,p:801.518334019), - el: (t:-75.099118135,p:113.231849753), - top: nil, - area_count: 2, - area_type: "a01", - t_count: 16, - p_count: 16, - t_first: 34.317879115, - t_last: -81.27381381, - t_mean: -11.7498148404, - p_first: 1000, - p_last: 100, - p_mean: 521.073650144 - ) - parcel = thermo_parcel_path(prof, (top_p: 700)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_grib_unstable_india - - -#--------------------------------- -# use case : unstable, USA -#--------------------------------- -function test_parcel_bufr_unstable() - - fn_name = "test_parcel_bufr_unstable" - - data_grb=read("thermo_profile_obs.bufr") - - # extract thermo profile - prof = thermo_bufr(data: data_grb, - station: stations(search_key: "ident", - ident: 72249)) - - # 1. surface, non-virtual - ref = ( - cape: 3923.56965701, - cin: 2.73849177608, - li: -7.7001953125, - lcl: (t:16.697974597,p:835.964161938), - lfc: (t:15.918665343,p:818.560036013), - el: (t:-59.809778136,p:179.882712634), - top: nil, - area_count: 3, - area_type: "a101", - t_count: 80, - p_count: 80, - t_first: 30.25, - t_last: -125.014648437, - t_mean: -33.0192663505, - p_first: 981, - p_last: 50, - p_mean: 438.273783745 - ) - - parcel = thermo_parcel_path(prof, (mode: "surface", virtual: "off")) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,1) - - # 2. mucape, non-virtual - parcel = thermo_parcel_path(prof, (top_p: 700, virtual: 0)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,2) - - # 3. mucape, virtual - ref = ( - cape: 4221.55914588, - cin: 0, - li: -7.6398622225, - lcl: (t:19.21137753,p:835.964161938), - lfc: (t:32.880914623,p:981), - el: (t:-59.805292022,p:179.870783592), - top: nil, - area_count: 1, - area_type: "a1", - t_count: 78, - p_count: 78, - t_first: 32.880914623, - t_last: -125.014648394, - t_mean: -33.3475884794, - p_first: 981, - p_last: 50, - p_mean: 428.132499302 - ) - parcel = thermo_parcel_path(prof, (top_p: 700)) - #plot_parcel(prof, parcel) - #__print_parcel_result_for_test(parcel) - test_parcel_core(parcel,ref,fn_name,3) - -end test_parcel_bufr_unstable - - -function plot_parcel(prof, parcel) - - parcel_area = thermo_parcel_area(parcel) - - if parcel_area <> nil and parcel["t"] <> nil then - parcel_vis = xy_curve(parcel["t"], parcel["p"], "charcoal", "dash", 6) - end if - - prof_vis = mthermo( - thermo_temperature_line_thickness:5, thermo_dewpoint_line_thickness:5 - ) - - view = thermoview( - type:"skewt", - minimum_temperature:-140, - maximum_temperature:40, - top_pressure:100, - subpage_clipping:"on" - ) - if parcel_area <> nil then - plot(view, parcel_area, prof, prof_vis, parcel_vis) - else - plot(view, prof, prof_vis) - end if - -end plot_parcel - -function test_parcel_core(parcel,ref, fn_name, id) - - #print("fn_name=",fn_name, " id=", id) - if ref = nil then - assert(parcel = nil,fn_name & " parcel_nil",id) - return - else - assert(parcel <> nil,fn_name & " parcel_not_nil",id) - end if - - assert_equal(parcel.cape,ref.cape,fn_name & " parcel_cape",id) - assert_equal(parcel.cin,ref.cin,fn_name & " parcel_cin",id) - assert_equal(parcel.li,ref.li,fn_name & " parcel_li",id) - - if ref.lcl = nil then - assert(parcel.lcl = nil,fn_name & " parcel_lcl",id) - else - assert(parcel.lcl <> nil,fn_name & " parcel_lcl valid",id) - assert_equal(parcel.lcl.t,ref.lcl.t,fn_name & " parcel_lcl_t",id) - assert_equal(parcel.lcl.p,ref.lcl.p,fn_name & " parcel_lcl_p",id) - end if - - if ref.lfc = nil then - assert(parcel.lfc = nil,fn_name & " parcel_lfc",id) - else - assert(parcel.lfc <> nil,fn_name & " parcel_lfc valid",id) - assert_equal(parcel.lfc.t,ref.lfc.t,fn_name & " parcel_lfc_t",id) - assert_equal(parcel.lfc.p,ref.lfc.p,fn_name & " parcel_lfc_p",id) - end if - - if ref.el = nil then - assert(parcel.el = nil,fn_name & " parcel_el",id) - else - assert(parcel.el <> nil,fn_name & " parcel_el valid",id) - assert_equal(parcel.el.t,ref.el.t,fn_name & " parcel_el_t",id) - assert_equal(parcel.el.p,ref.el.p,fn_name & " parcel_el_p",id) - end if - - if ref.top = nil then - assert(parcel.top = nil,fn_name & " parcel_top",id) - else - assert(parcel.top <> nil,fn_name & " parcel_top valid",id) - assert_equal(parcel.top.t,ref.top.t,fn_name & " parcel_top_t",id) - assert_equal(parcel.top.p,ref.top.p,fn_name & " parcel_top_p",id) - end if - - assert_equal(count(parcel.area),ref.area_count,fn_name & " parcel_area_count",id) - - aStr="a" - if parcel.area <> nil then - loop a in parcel.area - aStr = aStr & a.positive - end loop - end if - assert_equal(aStr, ref.area_type,fn_name & " parcel_area_type",id) - - assert_equal(count(parcel.t),count(parcel.p),fn_name & " parcel_path_count",id) - assert_equal(count(parcel.t),ref.t_count,fn_name & " parcel_t_count",id) - assert_equal(count(parcel.p),ref.p_count,fn_name & " parcel_p_count",id) - - num = count(parcel.t) - assert_equal(parcel.t[1],ref.t_first,fn_name & " parcel_t_first",id) - assert_equal(parcel.t[num],ref.t_last,fn_name & " parcel_t_last",id) - - assert_equal(parcel.p[1],ref.p_first,fn_name & " parcel_p_first",id) - assert_equal(parcel.p[num],ref.p_last,fn_name & " parcel_p_last",id) - - assert_equal(mean(parcel.t),ref.t_mean,fn_name & " parcel_t_mean",id) - assert_equal(mean(parcel.p),ref.p_mean,fn_name & " parcel_p_mean",id) - -end test_parcel_core \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/thermo_parcel_utils.mv metview-5.19.2/metview/test/macros/thermo_parcel_utils.mv --- metview-5.17.4/metview/test/macros/thermo_parcel_utils.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/thermo_parcel_utils.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,113 @@ +#Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ +# + + +# thermo parcel utility + +function test_parcel_core(parcel,ref, fn_name, id) + + #print("fn_name=",fn_name, " id=", id) + if ref = nil then + assert(parcel = nil,fn_name & " parcel_nil",id) + return + else + assert(parcel <> nil,fn_name & " parcel_not_nil",id) + end if + + assert_equal(parcel.cape,ref.cape,fn_name & " parcel_cape",id) + assert_equal(parcel.cin,ref.cin,fn_name & " parcel_cin",id) + assert_equal(parcel.li,ref.li,fn_name & " parcel_li",id) + + if ref.lcl = nil then + assert(parcel.lcl = nil,fn_name & " parcel_lcl",id) + else + assert(parcel.lcl <> nil,fn_name & " parcel_lcl valid",id) + assert_equal(parcel.lcl.t,ref.lcl.t,fn_name & " parcel_lcl_t",id) + assert_equal(parcel.lcl.p,ref.lcl.p,fn_name & " parcel_lcl_p",id) + end if + + if ref.lfc = nil then + assert(parcel.lfc = nil,fn_name & " parcel_lfc",id) + else + assert(parcel.lfc <> nil,fn_name & " parcel_lfc valid",id) + assert_equal(parcel.lfc.t,ref.lfc.t,fn_name & " parcel_lfc_t",id) + assert_equal(parcel.lfc.p,ref.lfc.p,fn_name & " parcel_lfc_p",id) + end if + + if ref.el = nil then + assert(parcel.el = nil,fn_name & " parcel_el",id) + else + assert(parcel.el <> nil,fn_name & " parcel_el valid",id) + assert_equal(parcel.el.t,ref.el.t,fn_name & " parcel_el_t",id) + assert_equal(parcel.el.p,ref.el.p,fn_name & " parcel_el_p",id) + end if + + if ref.top = nil then + assert(parcel.top = nil,fn_name & " parcel_top",id) + else + assert(parcel.top <> nil,fn_name & " parcel_top valid",id) + assert_equal(parcel.top.t,ref.top.t,fn_name & " parcel_top_t",id) + assert_equal(parcel.top.p,ref.top.p,fn_name & " parcel_top_p",id) + end if + + assert_equal(count(parcel.area),ref.area_count,fn_name & " parcel_area_count",id) + + aStr="a" + if parcel.area <> nil then + loop a in parcel.area + aStr = aStr & a.positive + end loop + end if + assert_equal(aStr, ref.area_type,fn_name & " parcel_area_type",id) + + assert_equal(count(parcel.t),count(parcel.p),fn_name & " parcel_path_count",id) + assert_equal(count(parcel.t),ref.t_count,fn_name & " parcel_t_count",id) + assert_equal(count(parcel.p),ref.p_count,fn_name & " parcel_p_count",id) + + num = count(parcel.t) + assert_equal(parcel.t[1],ref.t_first,fn_name & " parcel_t_first",id) + assert_equal(parcel.t[num],ref.t_last,fn_name & " parcel_t_last",id) + + assert_equal(parcel.p[1],ref.p_first,fn_name & " parcel_p_first",id) + assert_equal(parcel.p[num],ref.p_last,fn_name & " parcel_p_last",id) + + assert_equal(mean(parcel.t),ref.t_mean,fn_name & " parcel_t_mean",id) + assert_equal(mean(parcel.p),ref.p_mean,fn_name & " parcel_p_mean",id) + +end test_parcel_core + +function plot_parcel(prof, parcel) + + parcel_area = thermo_parcel_area(parcel) + + if parcel_area <> nil and parcel["t"] <> nil then + parcel_vis = xy_curve(parcel["t"], parcel["p"], "charcoal", "dash", 6) + end if + + prof_vis = mthermo( + thermo_temperature_line_thickness:5, thermo_dewpoint_line_thickness:5 + ) + + view = thermoview( + type:"skewt", + minimum_temperature:-140, + maximum_temperature:40, + top_pressure:100, + subpage_clipping:"on" + ) + if parcel_area <> nil then + plot(view, parcel_area, prof, prof_vis, parcel_vis) + else + plot(view, prof, prof_vis) + end if + +end plot_parcel \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/xsection_ml_curve.mv metview-5.19.2/metview/test/macros/xsection_ml_curve.mv --- metview-5.17.4/metview/test/macros/xsection_ml_curve.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/xsection_ml_curve.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,117 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include 'test_utils.mv' + +#build curve +test_build_curve_interpolate() +test_build_curve_nearest() + +#------------------------------------------ +# Tests +#------------------------------------------ + +function test_build_curve_interpolate() + + test_name = "build_curve_interpolate" + + # read input grib data + fs = read("t_lnsp_ml137.grb") + + # surface pressure in hPa + sp = exp(read(data: fs, param: "lnsp"))/100 + + # read xs reference data + nc = read("t_lnsp_ml137_xs_ref.nc") + + # define variable to be checked + setcurrent(nc,"orography_x_values") + xp_ref = values(nc) + + setcurrent(nc,"orography_y1_values") + yp1_ref = values(nc) + + setcurrent(nc,"orography_y2_values") + yp2_ref = values(nc) + + curve = xs_build_curve(nc, sp, "charcoal", "solid", 3) + + assert_equal(count(curve), 2, test_name & " num",1) + + # x values + xp = vector(curve[1].INPUT_X_VALUES) + assert(vec_same(xp, xp_ref, 1E-5), test_name & " xp", 1) + + # y values + yp = vector(curve[1].INPUT_Y_VALUES) + assert(vec_same(yp, yp1_ref, 0.8), test_name & " yp", 1) + + # graph + assert_equal(curve[2].GRAPH_TYPE, "CURVE", test_name & " graph-type",1) + assert_equal(curve[2].GRAPH_LINE_COLOUR, "charcoal", test_name & " graph-colour",1) + assert_equal(curve[2].GRAPH_LINE_STYLE, "SOLID", test_name & " graph-style",1) + assert_equal(curve[2].GRAPH_LINE_THICKNESS, 3, test_name & " graph-thickness",1) + +end test_build_curve_interpolate + +function test_build_curve_nearest() + + test_name = "build_curve_nearest" + + # read input grib data + fs = read("t_lnsp_ml137.grb") + + # surface pressure in hPa + sp = exp(read(data: fs, param: "lnsp"))/100 + + lines = [[47, 7, 45, 16], + [47, 7, 47, 16], + [47, 7, 38, 7]] + + for i=1 to count(lines) do + # generate xs reference data + nc = mcross_sect( + line : lines[i], + data : fs, + horizontal_point_mode: "nearest_gridpoint" + ) + + # define variable to be checked + setcurrent(nc,"orography_x_values") + xp_ref = values(nc) + + setcurrent(nc,"orography_y1_values") + yp1_ref = values(nc) + + setcurrent(nc,"orography_y2_values") + yp2_ref = values(nc) + + curve = xs_build_curve(nc, sp, "charcoal", "solid", 3) + + assert_equal(count(curve), 2, test_name & " num",i) + + # x values + xp = vector(curve[1].INPUT_X_VALUES) + assert(vec_same(xp, xp_ref, 1E-5), test_name & " xp", i) + + # y values + yp = vector(curve[1].INPUT_Y_VALUES) + assert(vec_same(yp, yp1_ref, 1E-4), test_name & " yp", i) + + # graph + assert_equal(curve[2].GRAPH_TYPE, "CURVE", test_name & " graph-type",i) + assert_equal(curve[2].GRAPH_LINE_COLOUR, "charcoal", test_name & " graph-colour",i) + assert_equal(curve[2].GRAPH_LINE_STYLE, "SOLID", test_name & " graph-style",i) + assert_equal(curve[2].GRAPH_LINE_THICKNESS, 3, test_name & " graph-thickness",i) + end for + + +end test_build_curve_nearest \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/xsection_ml_ghbc.mv metview-5.19.2/metview/test/macros/xsection_ml_ghbc.mv --- metview-5.17.4/metview/test/macros/xsection_ml_ghbc.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/xsection_ml_ghbc.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,796 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include 'test_utils.mv' + +#GHBC +test_wind_2d_intensity_ghbc_ml() +test_wind_3d_w_compute_ghbc_ml() +test_scalar_ghbc_ml() +test_scalar_ghbc_level_selection_ml() +test_scalar_ghbc_extrapolate_ml() + + +#------------------------------------------ +# Tests +#------------------------------------------ + + +function test_wind_2d_intensity_ghbc_ml() + + fn_name = "wind_2d_intensity_ghbc_ml" + + fs = read("xs_ml_input.grib") + lnsp = read(data: fs, param: ['lnsp'], step:12) + + # we use pressure as ghbc!!! + ghbc = nil + pres = pressure(lnsp) + + #------------------------------ + # Single step + #------------------------------ + + f = read(data: fs, param: ['u', 'v'], step:12) + + line = [54.39,-18.22,44.42,8.26] + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "on", + vertical_coordinates: "user", + vertical_coordinate_param: 54, + data : f & pres + ) + + #examine(nc) + #sleep(1000) + #stop + + nc_ref = read("xs_ml_ghbc_wind_2d_intensity.nc") + nlev = 91 + num_line = 64 + check_xs_result(nc, nc_ref, nlev, num_line, "u", "u_lev", fn_name, 1) + +end test_wind_2d_intensity_ghbc_ml + +function test_wind_3d_w_compute_ml() + + V1 = nil + V2 = nil + + fs=read("xs_ml_input.grib") + f_u = read(data: fs, param: ['u'], step:12) + f_v = read(data: fs, param: ['v'], step:12) + f_w = read(data: fs, param: ['w'], step:12) + t = read(data: fs, param: ['t'], step:12) + lnsp = read(data: fs, param: 'lnsp', step:12) + + # we focus on w + f_u = f_u * 0 + f_v = f_v * 0 + + g = 9.81 + Rd = 287.058 + t0 = 273.16 + + line = [50,-10,44,8] + w_scaling_lst = [-10, 1] + v_lev = |100, 300, 400, 500, 700, 850| + + # will not get perfect match because the in XS the + # vertical interpolation is performed after w is computed + + #---------------------------- + # Intensity - without T + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "on", + w_wind_scaling_factor_mode: 'compute', + w_wind_scaling_factor: w_scaling, + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_u & f_v & f_w & lnsp + ) + + num_lev = count(v_lev) + num_line = 64 + + ref = (var_name: 'u', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,1) + + ref = (var_name: 'u_lev', + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: v_lev) + check_xs_var(nc, ref, test_name,1) + + # this should contain the wind speed + setcurrent(nc, 'u') + v = values(nc) + + # build reference + nc_w = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_w & lnsp + ) + + setcurrent(nc_w,'w') + v_w = values(nc_w) + + for i=1 to num_lev do + for j=1 to num_line do + idx = (i-1)*num_line + j + pres = v_lev[i]*100 + v_w[idx] = -v_w[idx] / (g*pres/(Rd*t0)) + end for + end for + + v_w = w_scaling*v_w + v_ref = abs(v_w) + + assert(vec_same(v, v_ref, 0.1), test_name & " values",1) + end for + + #---------------------------- + # Intensity - with T + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "on", + w_wind_scaling_factor_mode: 'compute', + w_wind_scaling_factor: w_scaling, + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_u & f_v & f_w & lnsp & t + ) + + num_lev = count(v_lev) + num_line = 64 + + ref = (var_name: 'u', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,2) + + ref = (var_name: 'u_lev', + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: v_lev) + check_xs_var(nc, ref, test_name,2) + + # this should contain the wind speed + setcurrent(nc, 'u') + v = values(nc) + + # build reference + nc_w = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_w & lnsp + ) + + nc_t = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : t & lnsp + ) + + setcurrent(nc_w,'w') + v_w = values(nc_w) + + setcurrent(nc_t,'t') + v_t = values(nc_t) + + for i=1 to num_lev do + for j=1 to num_line do + idx = (i-1)*num_line + j + pres = v_lev[i]*100 + v_w[idx] = -v_w[idx] / (g*pres/(Rd*v_t[idx])) + end for + end for + + v_w = w_scaling*v_w + v_ref = abs(v_w) + + assert(vec_same(v, v_ref,0.1), test_name & " values",2) + + end for + + #---------------------------- + # parallel - without T + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "on", + wind_perpendicular : "off", + wind_intensity : "off", + w_wind_scaling_factor_mode: 'compute', + w_wind_scaling_factor: w_scaling, + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_u & f_v & f_w & lnsp + ) + + num_lev = count(v_lev) + num_line = 64 + + ref = (var_name: 'x_component', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,3) + + ref = (var_name: 'y_component', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,3) + + ref = (var_name: 'lev', + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: v_lev) + check_xs_var(nc, ref,test_name,3) + + # we only check the y component + setcurrent(nc, 'y_component') + v = values(nc) + + f_w = read(data: fs, param: 'w', step:12) + nc_w = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_w & lnsp + ) + + setcurrent(nc_w,'w') + v_w = values(nc_w) + + for i=1 to num_lev do + for j=1 to num_line do + idx = (i-1)*num_line + j + pres = v_lev[i]*100 + v_w[idx] = -v_w[idx] / (g*pres/(Rd*t0)) + end for + end for + + v_ref = w_scaling*v_w + assert(vec_same(v, v_ref,0.1), test_name & " values",3) + + end for + + #---------------------------- + # parallel - with T + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "on", + wind_perpendicular : "off", + wind_intensity : "off", + w_wind_scaling_factor_mode: 'compute', + w_wind_scaling_factor: w_scaling, + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_u & f_v & f_w & t & lnsp + ) + + num_lev = count(v_lev) + num_line = 64 + + ref = (var_name: 'x_component', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,4) + + ref = (var_name: 'y_component', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,4) + + ref = (var_name: 'lev', + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: v_lev) + check_xs_var(nc, ref,test_name,4) + + # we only check the y component + setcurrent(nc, 'y_component') + v = values(nc) + + f_w = read(data: fs, param: 'w', step:12) + nc_w = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_w & lnsp + ) + + nc_t = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : t & lnsp + ) + + setcurrent(nc_w,'w') + v_w = values(nc_w) + + setcurrent(nc_t,'t') + v_t = values(nc_t) + + for i=1 to num_lev do + for j=1 to num_line do + idx = (i-1)*num_line + j + pres = v_lev[i]*100 + v_w[idx] = -v_w[idx] / (g*pres/(Rd*v_t[idx])) + end for + end for + + v_ref = w_scaling*v_w + assert(vec_same(v, v_ref,0.1), test_name & " values",4) + + end for + + +end test_wind_3d_w_compute_ml + +function test_wind_3d_w_compute_ghbc_ml() + + fn_name = "wind_3d_w_compute_ghbc_ml" + + fs=read("xs_ml_input.grib") + f_u = read(data: fs, param: ['u'], step:12) + f_v = read(data: fs, param: ['v'], step:12) + f_w = read(data: fs, param: ['w'], step:12) + t = read(data: fs, param: ['t'], step:12) + lnsp = read(data: fs, param: 'lnsp', step:12) + + # we use pressure as ghbc + ghbc = nil + pres = pressure(lnsp) + + # we focus on w + #f_u = f_u * 0 + #f_v = f_v * 0 + + line = [50,-10,44,8] + w_scaling_lst = [-10, 1] + + if 1 =0 then + #---------------------------- + # Intensity + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = fn_name & " intenisty scaling=" & w_scaling + + nc = mcross_sect( + + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "on", + w_wind_scaling_factor_mode: 'user', + w_wind_scaling_factor: w_scaling, + vertical_coordinates: "user", + vertical_coordinate_param: 54, + data : f_u & f_v & f_w & pres + ) + + #examine(nc) + #sleep(1000) + #stop + + nc_ref = read("xs_ml_ghbc_wind_3d_intensity_" & k & ".nc") + nlev = 91 + num_line = 64 + check_xs_result(nc, nc_ref, nlev, num_line, "u", "u_lev", test_name, 1) + + end for + end if + + #---------------------------- + # parallel + #---------------------------- + + for k=2 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = fn_name & " parallel scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "on", + wind_perpendicular : "off", + wind_intensity : "off", + w_wind_scaling_factor_mode: 'user', + w_wind_scaling_factor: w_scaling, + vertical_coordinates: "user", + vertical_coordinate_param: 54, + data : f_u & f_v & f_w & pres + ) + + #write("xs_ml_ghbc_wind_3d_parallel_" & k & ".nc", nc) + nc_ref = read("xs_ml_ghbc_wind_3d_parallel_" & k & ".nc") + nlev = 91 + num_line = 64 + + check_xs_result(nc, nc_ref, nlev, num_line, "x_component", "lev", test_name, 2) + check_xs_result(nc, nc_ref, nlev, num_line, "y_component", "lev", test_name, 2) + + end for + +end test_wind_3d_w_compute_ghbc_ml + +function test_scalar_ghbc_ml() + + fs = read("xs_ml_input.grib") + f = read(data: fs, param: ['t'], step:12) + f_u = read(data: fs, param: ['u'], step:12) + lnsp = read(data: fs, param: ['lnsp'], step:12) + + # we use pressure as ghbc!!! + ghbc = nil + pres = unipressure(lnsp) + ghbc = grib_set_long(pres,['paramId',131]) + + point_modes = ['interpolate','nearest_gridpoint'] + + line = [40, -10, 50.3, 5] + + for k=1 to count(point_modes) do + + pmode = point_modes[k] + test_name = 'scalar_ghbc_ml pm=' & pmode + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + horizontal_point_mode: pmode, + vertical_coordinates: "user", + vertical_coordinate_param: 131, + data : f & ghbc + ) + + # get number of points and levels along the line + if pmode = 'interpolate' then + num_line = 64 + else + num_line = 24 + end if + + nlev = 91 + + # get ghbc values on the cross section line + nc_ghbc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + horizontal_point_mode: pmode, + data : ghbc + ) + + v_lev_ghbc = vector(nlev) + for mm=1 to count(v_lev_ghbc) do + v_lev_ghbc[mm]=mm + end for + + # !! ghbc stored as u!!! + ref = (var_name: 'u', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc_ghbc, ref, test_name & " ghbc levels",1) + + ref = (var_name: 'u_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev_ghbc) + check_xs_var(nc_ghbc, ref, 1E-5, test_name & " ghbc levels",1) + + setcurrent(nc_ghbc, 'u') + v_ghbc = values(nc_ghbc) + + # the averages of the ghbc on each level define the + # target ghbc level values! + v_lev = vector(nlev) + for mm=1 to nlev do + pos = 1 + (mm-1)*num_line + v_lev[mm] = mean(v_ghbc[pos, pos + num_line-1]) + end for + + # the resulting xs + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc, ref, test_name,1) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev) + check_xs_var(nc, ref, 1E-5, test_name,1) + + setcurrent(nc, "t") + v = values(nc) + + # having checked the levels we derive the reference values independently + nc_ref = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + horizontal_point_mode: pmode, + level_selection_type: "level_list", + level_list: tolist(v_lev/100), # has to be hPa + vertical_scaling: "linear", + data : f & lnsp + ) + + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc_ref, ref, test_name & " ref",1) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev/100) + check_xs_var(nc_ref, ref, 1E-5, test_name & " ref",1) + + setcurrent(nc_ref, "t") + v_ref = values(nc_ref) + assert(vec_same(v, v_ref, 1E-1), test_name & " values",1) + + end for + +end test_scalar_ghbc_ml + +function test_scalar_ghbc_level_selection_ml() + + fn_name = "scalar_ghbc_level_selection_ml" + + fs = read("xs_tz_ml.grib") + f_t = read(data: fs, param: 't') + f_z = read(data: fs, param: 'z')/9.81 + + line = [20, -112, 24.2, -93.5] + + # -------------------------- + # adaptive + # -------------------------- + + # TODO: enable it when fully implemented + if 1 = 0 then + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "adaptive", + vertical_coordinates: "user", + vertical_coordinate_param: 129, + data : f_t & f_z + ) + + # read reference data + nc_ref = read("xs_ml_ghbc_adaptive_ref.nc") + + nlev = 38 + num_line = 64 + check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 1) + end if + # -------------------------- + # from_data + # -------------------------- + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "from_data", + vertical_coordinates: "user", + vertical_coordinate_param: 129, + data : f_t & f_z + ) + + # read reference data + nc_ref = read("xs_ml_ghbc_from_data_ref.nc") + + nlev = 33 + num_line = 64 + check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 2) + + +end test_scalar_ghbc_level_selection_ml + + +function test_scalar_ghbc_extrapolate_ml() + + fn_name = "scalar_ghbc_extrapolate_ml" + + fs = read("xs_tz_ml.grib") + f_t = read(data: fs, param: 't') + f_z = read(data: fs, param: 'z')/9.81 + + line = [20, -112, 24.2, -93.5] + + # -------------------------- + # 1. adaptive, linear + # -------------------------- + # TODO: enable it when fully implemented + if 1 = 0 then + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "adaptive", + vertical_coordinates: "user", + vertical_coordinate_param: 129, + vertical_coordinate_extrapolate: "on", + vertical_coordinate_extrapolate_mode: "linear", + vertical_coordinate_extrapolate_fixed_sign: "on", + data : f_t & f_z + ) + + # read reference data + nc_ref = read("xs_ml_ghbc_adaptive_extra_linear_ref.nc") + + nlev = 40 + num_line = 64 + check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 1) + + # -------------------------- + # 2. adaptive, constant + # -------------------------- + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "adaptive", + vertical_coordinates: "user", + vertical_coordinate_param: 129, + vertical_coordinate_extrapolate: "on", + vertical_coordinate_extrapolate_mode: "constant", + data : f_t & f_z + ) + + # read reference data + nc_ref = read("xs_ml_ghbc_adaptive_extra_const_ref.nc") + + nlev = 40 + num_line = 64 + check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 2) + end if + + # -------------------------- + # 3. from_data, linear + # -------------------------- + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "from_data", + vertical_coordinates: "user", + vertical_coordinate_param: 129, + vertical_coordinate_extrapolate: "on", + vertical_coordinate_extrapolate_mode: "linear", + vertical_coordinate_extrapolate_fixed_sign: "on", + data : f_t & f_z + ) + + # read reference data + nc_ref = read("xs_ml_ghbc_from_data_extra_linear_ref.nc") + + nlev = 35 + num_line = 64 + check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 3) + + # -------------------------- + # 4. from_data, constant + # -------------------------- + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "from_data", + vertical_coordinates: "user", + vertical_coordinate_param: 129, + vertical_coordinate_extrapolate: "on", + vertical_coordinate_extrapolate_mode: "constant", + data : f_t & f_z + ) + + # read reference data + nc_ref = read("xs_ml_ghbc_from_data_extra_constant_ref.nc") + + nlev = 35 + num_line = 64 + check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 4) + +end test_scalar_ghbc_extrapolate_ml diff -Nru metview-5.17.4/metview/test/macros/xsection_ml.mv metview-5.19.2/metview/test/macros/xsection_ml.mv --- metview-5.17.4/metview/test/macros/xsection_ml.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/xsection_ml.mv 1970-01-01 00:00:00.000000000 +0000 @@ -1,1589 +0,0 @@ -# Metview Macro - -# **************************** LICENSE START *********************************** -# -# Copyright 2019 ECMWF. This software is distributed under the terms -# of the Apache License version 2.0. In applying this license, ECMWF does not -# waive the privileges and immunities granted to it by virtue of its status as -# an Intergovernmental Organization or submit itself to any jurisdiction. -# -# ***************************** LICENSE END ************************************ - -include 'test_utils.mv' - -test_scalar_ml() -test_scalar_level_selection_ml() -test_scalar_nolnsp_ml() - -# 2D wind -test_wind_2d_intensity_ml() - -# 3D wind -test_wind_3d_w_compute_ml() - -#GHBC -test_scalar_ghbc_ml() -test_scalar_ghbc_level_selection_ml() -test_scalar_ghbc_extrapolate_ml() -test_wind_2d_intensity_ghbc_ml() -test_wind_3d_w_compute_ghbc_ml() - -#build orog -test_build_orog_interpolate() -test_build_orog_nearest() - -#build curve -test_build_curve_interpolate() -test_build_curve_nearest() - -#------------------------------------------ -# Tests -#------------------------------------------ - -function test_scalar_ml() - - # read input grib data - fs = read("t_lnsp_ml137.grb") - - # read reference data - nc_ref = read("t_lnsp_ml137_xs_ref.nc") - - # compute xsection and save it in a netcdf file - nc = mcross_sect( - line : [47,7,45,16], - data : fs - ) - - # variables - vars_ref = ["time","lat","lon","t_lev","t","lnsp","orography_x_values", - "orography_y1_values", "orography_y2_values"] - - vars = variables(nc) - assert_equal(vars, vars_ref,"scalar_ml - vars",1) - - # global attributes - gattr = global_attributes(nc) - assert_equal(count(keywords(gattr)),5,'scalar_ml - global_attributes', 1) - assert_equal(gattr.type,"MXSECTION",'scalar_ml - global_attribute type',1) - - # define variable to be checked - setcurrent(nc,"t") - - # attributes of a variable - attr = attributes(nc) - - assert_equal(count(keywords(attr)),4,'scalar_ml - t attributes count', 1) - assert_equal(attr.long_name,"Temperature",'scalar_ml - t long_name', 1) - assert_equal(attr.units,"K",'scalar_ml - t units', 1) - - num_line=64 - num_lev=146 - - # t - setcurrent(nc_ref,"t") - vals_ref = values(nc_ref) - - ref = (var_name: "t", - dim_names: ["time","nlev","lon"], - dim_values: [1,num_lev,num_line], - values: vals_ref) - check_xs_var(nc, ref, "scalar_ml",1) - - # t_lev - setcurrent(nc_ref,"t_lev") - vals_ref = values(nc_ref) - - ref = (var_name: "t_lev", - dim_names: ["time","nlev"], - dim_values: [1,num_lev], - values: vals_ref) - check_xs_var(nc, ref, "scalar_ml",1) - - # orography_x_values - setcurrent(nc_ref,"orography_x_values") - vals_ref = values(nc_ref) - - ref = (var_name: "orography_x_values", - dim_names: ["time","npoints"], - dim_values: [1,num_line], - values: vals_ref) - check_xs_var(nc, ref, "scalar_ml",1) - - # orography_y1_values - setcurrent(nc_ref,"orography_y1_values") - vals_ref = values(nc_ref) - - ref = (var_name: "orography_y1_values", - dim_names: ["time","npoints"], - dim_values: [1,num_line], - values: vals_ref) - check_xs_var(nc, ref, "scalar_ml",1) - - # orography_y2_values - setcurrent(nc_ref,"orography_y2_values") - vals_ref = values(nc_ref) - - ref = (var_name: "orography_y2_values", - dim_names: ["time","npoints"], - dim_values: [1,num_line], - values: vals_ref) - check_xs_var(nc, ref, "scalar_ml",1) - - # orography_x_values - setcurrent(nc_ref,"orography_x_values") - vals_ref = values(nc_ref) - - ref = (var_name: "lnsp", - dim_names: ["time","npoints"], - dim_values: [1,num_line]) - check_xs_var(nc, ref, "scalar_ml",1) - - setcurrent(nc,'orography_y1_values') - v_orog_y1 = values(nc) - - setcurrent(nc,'lnsp') - v = values(nc) - v = exp(v)/100 - # first 20 values are missing - assert(vec_same(v[20,num_line],v_orog_y1[20,num_line]),"scalar_ml lnsp",1) - -end test_scalar_ml - -function test_scalar_level_selection_ml() - fs = read("xs_ml_input.grib") - - f = read(data: fs, param: ['lnsp','t'], step:12) - t = read(data: f, param: 't') - lnsp = read(data: f, param: 'lnsp') - - # create artificial field with known values - - pres = pressure(lnsp)/100 - - ft = lnsp - for i=1 to count(t) do - lev = grib_get_long(t[i],'level') - v = 100*values(coslat(t[i])) + values(pres[i]) - ft = ft & (set_values(t[i],v)) - end for - - #-------------------------------------- - # case 1 - COUNT - # east west line lying on grid points - # level selection: - #-------------------------------------- - lat = 50 - line = [lat, -10, lat, 5] - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "count", - level_count: 16, - bottom_level: 800, - top_level: 50, - vertical_scaling: "linear", - data : ft - ) - - v_lev = |50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, - 800| - - setcurrent(nc, 't') - v = values(nc) - - nlev = count(v_lev) - num_line = 64 - - ref = (var_name: 't', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc, ref, "scalar_level_selection_ml",1) - - ref = (var_name: 't_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev) - check_xs_var(nc, ref, "scalar_level_selection_ml",1) - - # build reference - v_ref = v*0 - - cos_lat = 100*cos(pi*lat/180.) - v = v - cos_lat - - for i=1 to nlev do - for j=1 to num_line do - v_ref[(i-1)*num_line + j] = v_lev[i] - end for - end for - - # we do not expect perfect match since the pressure is interpolated - # to target levels - assert(vec_same(v, v_ref,0.2), "scalar_level_selection_ml values",1) - - #-------------------------------------- - # case 2 - COUNT - # north south line lying on grid points - #-------------------------------------- - - lon = -5 - line = [42, lon, 52, lon] - xs = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "count", - level_count: 16, - bottom_level: 800, - top_level: 50, - vertical_scaling: "linear", - data : ft - ) - - v_lev = |50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, - 800| - - nlev = count(v_lev) - num_line = 64 - - setcurrent(nc, 't') - v = values(nc) - - setcurrent(nc, 'lat') - v_lat = values(nc) - assert_equal(count(v_lat),num_line,'scalar_level_selection_ml v_lat',2) - - ref = (var_name: 't', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc, ref, "scalar_level_selection_ml",2) - - ref = (var_name: 't_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev) - check_xs_var(nc, ref, "scalar_level_selection_ml",2) - - # build reference - v_ref = v*0 - - for i=1 to nlev do - for j=1 to num_line do - cos_lat = 100*cos(pi*v_lat[j]/180.) - v_ref[(i-1)*num_line + j] = cos_lat + v_lev[i] - end for - end for - - # we do not expect perfect match since both the coslat and pressure are - # interpolated - assert(vec_same(v, v_ref,0.2), "scalar_level_selection_ml values",2) - - #-------------------------------------- - # case 3 - LEVEL_LIST - # east west line lying on grid points - # level selection: - #-------------------------------------- - lat = 50 - line = [lat, -10, lat, 5] - v_lev = |50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, - 800| - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : ft - ) - - setcurrent(nc, 't') - v = values(nc) - - nlev = count(v_lev) - num_line = 64 - - ref = (var_name: 't', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc, ref, "scalar_level_selection_ml",3) - - ref = (var_name: 't_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev) - check_xs_var(nc, ref, "scalar_level_selection_ml",3) - - # build reference - v_ref = v*0 - - cos_lat = 100*cos(pi*lat/180.) - v = v - cos_lat - - for i=1 to nlev do - for j=1 to num_line do - v_ref[(i-1)*num_line + j] = v_lev[i] - end for - end for - - # we do not expect perfect match since the pressure is interpolated - # to target levels - assert(vec_same(v, v_ref,0.2), "scalar_level_selection_ml values",3) - - #-------------------------------------- - # case 4 - LEVEL_LIST - # north south line lying on grid points - #-------------------------------------- - - lon = -5 - line = [42, lon, 52, lon] - v_lev = |50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, - 800| - - xs = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : ft - ) - - nlev = count(v_lev) - num_line = 64 - - setcurrent(nc, 't') - v = values(nc) - - setcurrent(nc, 'lat') - v_lat = values(nc) - assert_equal(count(v_lat),num_line,'scalar_level_selection_ml v_lat',4) - - ref = (var_name: 't', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc, ref, "scalar_level_selection_ml",4) - - ref = (var_name: 't_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev) - check_xs_var(nc, ref, "scalar_level_selection_ml",4) - - # build reference - v_ref = v*0 - - for i=1 to nlev do - for j=1 to num_line do - cos_lat = 100*cos(pi*v_lat[j]/180.) - v_ref[(i-1)*num_line + j] = cos_lat + v_lev[i] - end for - end for - - # we do not expect perfect match since both the coslat and pressure are - # interpolated - assert(vec_same(v, v_ref,0.2), "scalar_level_selection_ml values",4) - -end test_scalar_level_selection_ml - - -function test_scalar_nolnsp_ml() - fs = read("xs_ml_input.grib") - t = read(data: fs, param: 't', step:12) - - # create artificial field with known values - ft = nil - for i=1 to count(t) do - lev = grib_get_long(t[i],'level') - v = 10*values(coslat(t[i])) + 100*lev - ft = ft & (set_values(t[i],v)) - end for - - #-------------------------------------- - # case 1 - COUNT - # east west line lying on grid points - # level selection: - #-------------------------------------- - lat = 50.3 - line = [lat, -10, lat, 5] - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - data : ft - ) - - setcurrent(nc, 't') - v = values(nc) - - nlev = 91 - num_line = 64 - - v_lev =vector(nlev) - for i=1 to count(v_lev) do - v_lev[i]=i - end for - - ref = (var_name: 't', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc, ref, "scalar_nolnsp_ml",1) - - ref = (var_name: 't_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev) - check_xs_var(nc, ref, "scalar_nolnsp_ml",1) - - # build reference - v_ref = v*0 - - cos_lat = 10*cos(pi*lat/180.) - v = v - cos_lat - - for i=1 to nlev do - for j=1 to num_line do - v_ref[(i-1)*num_line + j] = 100*v_lev[i] - end for - end for - - # we do not expect perfect match since the pressure is interpolated - # to target levels - assert(vec_same(v, v_ref,0.2), "scalar_nolnsp_ml values",1) - - #-------------------------------------- - # case 2 - COUNT - # north south line lying on grid points - #-------------------------------------- - - lon = -5.2 - line = [42, lon, 52, lon] - xs = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - data : ft - ) - - nlev = 91 - num_line = 64 - - v_lev =vector(nlev) - for i=1 to count(v_lev) do - v_lev[i]=i - end for - - setcurrent(nc, 't') - v = values(nc) - - setcurrent(nc, 'lat') - v_lat = values(nc) - assert_equal(count(v_lat),num_line,'scalar_nolnsp_ml v_lat',2) - - ref = (var_name: 't', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc, ref, "scalar_nolnsp_ml",2) - - ref = (var_name: 't_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev) - check_xs_var(nc, ref, "scalar_nolnsp_ml",2) - - # build reference - v_ref = v*0 - - for i=1 to nlev do - for j=1 to num_line do - cos_lat = 10*cos(pi*v_lat[j]/180.) - v_ref[(i-1)*num_line + j] = cos_lat + 100*v_lev[i] - end for - end for - - # we do not expect perfect match since both the coslat and pressure are - # interpolated - assert(vec_same(v, v_ref,0.2), "scalar_nolnsp_ml values",2) - -end test_scalar_nolnsp_ml - -function test_wind_2d_intensity_ml() - - fs=read("xs_ml_input.grib") - - #------------------------------ - # Single step - #------------------------------ - - f = read(data: fs, param: ['lnsp', 'u', 'v'], step:12) - - line = [54.39,-18.22,44.42,8.26] - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "on", - data : f - ) - - #examine(nc) - #sleep(5) - #stop - - v_lev = |300, 400, 500, 700, 850, 1000| - - ref = (var_name: 'u', - dim_names: ["time","nlev","lon"], - dim_values: [1,97,64]) - check_xs_var(nc, ref, 'wind_2d_intensity_ml',1) - - ref = (var_name: 'u_lev', - dim_names: ["time","nlev"], - dim_values: [1,97]) - check_xs_var(nc, ref, 'wind_2d_intensity_ml',1) - - v_lev_start = |0.0100002002716064, 0.0299043607711792, 0.0568400907516479| - v_lev_end = |994.222724269193, 1004.22272426919, 1014.22272426919, 1024.22272426919| - - setcurrent(nc, 'u_lev') - v = values(nc) - - assert(vec_same(v[1,3], v_lev_start), "wind_2d_intensity_ml levels start",1) - assert(vec_same(v[97-3,97], v_lev_end), "wind_2d_intensity_ml levels end",1) - - # this should contain the wind speed - setcurrent(nc, 'u') - v = values(nc) - - # build reference - f_u = read(data: fs, param: ['lnsp','u'], step:12) - nc_u = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - data : f_u - ) - - f_v = read(data: fs, param: ['lnsp','v'], step:12) - nc_v = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - data : f_v - ) - - setcurrent(nc_u,'u') - v_u = values(nc_u) - - setcurrent(nc_v,'v') - v_v = values(nc_v) - - v_ref = sqrt(v_u*v_u + v_v*v_v) - assert(vec_same_missing(v, v_ref, 1E-1), "wind_2d_intensity_ml values",1) - -end test_wind_2d_intensity_ml - -function test_wind_2d_intensity_ghbc_ml() - - fn_name = "wind_2d_intensity_ghbc_ml" - - fs = read("xs_ml_input.grib") - lnsp = read(data: fs, param: ['lnsp'], step:12) - - # we use pressure as ghbc!!! - ghbc = nil - pres = pressure(lnsp) - - #------------------------------ - # Single step - #------------------------------ - - f = read(data: fs, param: ['u', 'v'], step:12) - - line = [54.39,-18.22,44.42,8.26] - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "on", - vertical_coordinates: "user", - vertical_coordinate_param: 54, - data : f & pres - ) - - #examine(nc) - #sleep(1000) - #stop - - nc_ref = read("xs_ml_ghbc_wind_2d_intensity.nc") - nlev = 91 - num_line = 64 - check_xs_result(nc, nc_ref, nlev, num_line, "u", "u_lev", fn_name, 1) - -end test_wind_2d_intensity_ghbc_ml - -function test_wind_3d_w_compute_ml() - - V1 = nil - V2 = nil - - fs=read("xs_ml_input.grib") - f_u = read(data: fs, param: ['u'], step:12) - f_v = read(data: fs, param: ['v'], step:12) - f_w = read(data: fs, param: ['w'], step:12) - t = read(data: fs, param: ['t'], step:12) - lnsp = read(data: fs, param: 'lnsp', step:12) - - # we focus on w - f_u = f_u * 0 - f_v = f_v * 0 - - g = 9.81 - Rd = 287.058 - t0 = 273.16 - - line = [50,-10,44,8] - w_scaling_lst = [-10, 1] - v_lev = |100, 300, 400, 500, 700, 850| - - # will not get perfect match because the in XS the - # vertical interpolation is performed after w is computed - - #---------------------------- - # Intensity - without T - #---------------------------- - - for k=1 to count(w_scaling_lst) do - - w_scaling = w_scaling_lst[k] - test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "on", - w_wind_scaling_factor_mode: 'compute', - w_wind_scaling_factor: w_scaling, - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : f_u & f_v & f_w & lnsp - ) - - num_lev = count(v_lev) - num_line = 64 - - ref = (var_name: 'u', - dim_names: ["time","nlev","lon"], - dim_values: [1,num_lev,num_line]) - check_xs_var(nc, ref, test_name,1) - - ref = (var_name: 'u_lev', - dim_names: ["time","nlev"], - dim_values: [1,num_lev], - values: v_lev) - check_xs_var(nc, ref, test_name,1) - - # this should contain the wind speed - setcurrent(nc, 'u') - v = values(nc) - - # build reference - nc_w = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : f_w & lnsp - ) - - setcurrent(nc_w,'w') - v_w = values(nc_w) - - for i=1 to num_lev do - for j=1 to num_line do - idx = (i-1)*num_line + j - pres = v_lev[i]*100 - v_w[idx] = -v_w[idx] / (g*pres/(Rd*t0)) - end for - end for - - v_w = w_scaling*v_w - v_ref = abs(v_w) - - assert(vec_same(v, v_ref, 0.1), test_name & " values",1) - end for - - #---------------------------- - # Intensity - with T - #---------------------------- - - for k=1 to count(w_scaling_lst) do - - w_scaling = w_scaling_lst[k] - test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "on", - w_wind_scaling_factor_mode: 'compute', - w_wind_scaling_factor: w_scaling, - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : f_u & f_v & f_w & lnsp & t - ) - - num_lev = count(v_lev) - num_line = 64 - - ref = (var_name: 'u', - dim_names: ["time","nlev","lon"], - dim_values: [1,num_lev,num_line]) - check_xs_var(nc, ref, test_name,2) - - ref = (var_name: 'u_lev', - dim_names: ["time","nlev"], - dim_values: [1,num_lev], - values: v_lev) - check_xs_var(nc, ref, test_name,2) - - # this should contain the wind speed - setcurrent(nc, 'u') - v = values(nc) - - # build reference - nc_w = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : f_w & lnsp - ) - - nc_t = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : t & lnsp - ) - - setcurrent(nc_w,'w') - v_w = values(nc_w) - - setcurrent(nc_t,'t') - v_t = values(nc_t) - - for i=1 to num_lev do - for j=1 to num_line do - idx = (i-1)*num_line + j - pres = v_lev[i]*100 - v_w[idx] = -v_w[idx] / (g*pres/(Rd*v_t[idx])) - end for - end for - - v_w = w_scaling*v_w - v_ref = abs(v_w) - - assert(vec_same(v, v_ref,0.1), test_name & " values",2) - - end for - - #---------------------------- - # parallel - without T - #---------------------------- - - for k=1 to count(w_scaling_lst) do - - w_scaling = w_scaling_lst[k] - test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling - - nc = mcross_sect( - line : line, - wind_parallel : "on", - wind_perpendicular : "off", - wind_intensity : "off", - w_wind_scaling_factor_mode: 'compute', - w_wind_scaling_factor: w_scaling, - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : f_u & f_v & f_w & lnsp - ) - - num_lev = count(v_lev) - num_line = 64 - - ref = (var_name: 'x_component', - dim_names: ["time","nlev","lon"], - dim_values: [1,num_lev,num_line]) - check_xs_var(nc, ref, test_name,3) - - ref = (var_name: 'y_component', - dim_names: ["time","nlev","lon"], - dim_values: [1,num_lev,num_line]) - check_xs_var(nc, ref, test_name,3) - - ref = (var_name: 'lev', - dim_names: ["time","nlev"], - dim_values: [1,num_lev], - values: v_lev) - check_xs_var(nc, ref,test_name,3) - - # we only check the y component - setcurrent(nc, 'y_component') - v = values(nc) - - f_w = read(data: fs, param: 'w', step:12) - nc_w = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : f_w & lnsp - ) - - setcurrent(nc_w,'w') - v_w = values(nc_w) - - for i=1 to num_lev do - for j=1 to num_line do - idx = (i-1)*num_line + j - pres = v_lev[i]*100 - v_w[idx] = -v_w[idx] / (g*pres/(Rd*t0)) - end for - end for - - v_ref = w_scaling*v_w - assert(vec_same(v, v_ref,0.1), test_name & " values",3) - - end for - - #---------------------------- - # parallel - with T - #---------------------------- - - for k=1 to count(w_scaling_lst) do - - w_scaling = w_scaling_lst[k] - test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling - - nc = mcross_sect( - line : line, - wind_parallel : "on", - wind_perpendicular : "off", - wind_intensity : "off", - w_wind_scaling_factor_mode: 'compute', - w_wind_scaling_factor: w_scaling, - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : f_u & f_v & f_w & t & lnsp - ) - - num_lev = count(v_lev) - num_line = 64 - - ref = (var_name: 'x_component', - dim_names: ["time","nlev","lon"], - dim_values: [1,num_lev,num_line]) - check_xs_var(nc, ref, test_name,4) - - ref = (var_name: 'y_component', - dim_names: ["time","nlev","lon"], - dim_values: [1,num_lev,num_line]) - check_xs_var(nc, ref, test_name,4) - - ref = (var_name: 'lev', - dim_names: ["time","nlev"], - dim_values: [1,num_lev], - values: v_lev) - check_xs_var(nc, ref,test_name,4) - - # we only check the y component - setcurrent(nc, 'y_component') - v = values(nc) - - f_w = read(data: fs, param: 'w', step:12) - nc_w = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : f_w & lnsp - ) - - nc_t = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "level_list", - level_list: tolist(v_lev), - vertical_scaling: "linear", - data : t & lnsp - ) - - setcurrent(nc_w,'w') - v_w = values(nc_w) - - setcurrent(nc_t,'t') - v_t = values(nc_t) - - for i=1 to num_lev do - for j=1 to num_line do - idx = (i-1)*num_line + j - pres = v_lev[i]*100 - v_w[idx] = -v_w[idx] / (g*pres/(Rd*v_t[idx])) - end for - end for - - v_ref = w_scaling*v_w - assert(vec_same(v, v_ref,0.1), test_name & " values",4) - - end for - - -end test_wind_3d_w_compute_ml - -function test_wind_3d_w_compute_ghbc_ml() - - fn_name = "wind_3d_w_compute_ghbc_ml" - - fs=read("xs_ml_input.grib") - f_u = read(data: fs, param: ['u'], step:12) - f_v = read(data: fs, param: ['v'], step:12) - f_w = read(data: fs, param: ['w'], step:12) - t = read(data: fs, param: ['t'], step:12) - lnsp = read(data: fs, param: 'lnsp', step:12) - - # we use pressure as ghbc - ghbc = nil - pres = pressure(lnsp) - - # we focus on w - #f_u = f_u * 0 - #f_v = f_v * 0 - - line = [50,-10,44,8] - w_scaling_lst = [-10, 1] - - if 1 =0 then - #---------------------------- - # Intensity - #---------------------------- - - for k=1 to count(w_scaling_lst) do - - w_scaling = w_scaling_lst[k] - test_name = fn_name & " intenisty scaling=" & w_scaling - - nc = mcross_sect( - - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "on", - w_wind_scaling_factor_mode: 'user', - w_wind_scaling_factor: w_scaling, - vertical_coordinates: "user", - vertical_coordinate_param: 54, - data : f_u & f_v & f_w & pres - ) - - #examine(nc) - #sleep(1000) - #stop - - nc_ref = read("xs_ml_ghbc_wind_3d_intensity_" & k & ".nc") - nlev = 91 - num_line = 64 - check_xs_result(nc, nc_ref, nlev, num_line, "u", "u_lev", test_name, 1) - - end for - end if - - #---------------------------- - # parallel - #---------------------------- - - for k=2 to count(w_scaling_lst) do - - w_scaling = w_scaling_lst[k] - test_name = fn_name & " parallel scaling=" & w_scaling - - nc = mcross_sect( - line : line, - wind_parallel : "on", - wind_perpendicular : "off", - wind_intensity : "off", - w_wind_scaling_factor_mode: 'user', - w_wind_scaling_factor: w_scaling, - vertical_coordinates: "user", - vertical_coordinate_param: 54, - data : f_u & f_v & f_w & pres - ) - - #write("xs_ml_ghbc_wind_3d_parallel_" & k & ".nc", nc) - nc_ref = read("xs_ml_ghbc_wind_3d_parallel_" & k & ".nc") - nlev = 91 - num_line = 64 - - check_xs_result(nc, nc_ref, nlev, num_line, "x_component", "lev", test_name, 2) - check_xs_result(nc, nc_ref, nlev, num_line, "y_component", "lev", test_name, 2) - - end for - -end test_wind_3d_w_compute_ghbc_ml - -function test_scalar_ghbc_ml() - - fs = read("xs_ml_input.grib") - f = read(data: fs, param: ['t'], step:12) - f_u = read(data: fs, param: ['u'], step:12) - lnsp = read(data: fs, param: ['lnsp'], step:12) - - # we use pressure as ghbc!!! - ghbc = nil - pres = unipressure(lnsp) - ghbc = grib_set_long(pres,['paramId',131]) - - point_modes = ['interpolate','nearest_gridpoint'] - - line = [40, -10, 50.3, 5] - - for k=1 to count(point_modes) do - - pmode = point_modes[k] - test_name = 'scalar_ghbc_ml pm=' & pmode - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - horizontal_point_mode: pmode, - vertical_coordinates: "user", - vertical_coordinate_param: 131, - data : f & ghbc - ) - - # get number of points and levels along the line - if pmode = 'interpolate' then - num_line = 64 - else - num_line = 24 - end if - - nlev = 91 - - # get ghbc values on the cross section line - nc_ghbc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - horizontal_point_mode: pmode, - data : ghbc - ) - - v_lev_ghbc = vector(nlev) - for mm=1 to count(v_lev_ghbc) do - v_lev_ghbc[mm]=mm - end for - - # !! ghbc stored as u!!! - ref = (var_name: 'u', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc_ghbc, ref, test_name & " ghbc levels",1) - - ref = (var_name: 'u_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev_ghbc) - check_xs_var(nc_ghbc, ref, 1E-5, test_name & " ghbc levels",1) - - setcurrent(nc_ghbc, 'u') - v_ghbc = values(nc_ghbc) - - # the averages of the ghbc on each level define the - # target ghbc level values! - v_lev = vector(nlev) - for mm=1 to nlev do - pos = 1 + (mm-1)*num_line - v_lev[mm] = mean(v_ghbc[pos, pos + num_line-1]) - end for - - # the resulting xs - ref = (var_name: 't', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc, ref, test_name,1) - - ref = (var_name: 't_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev) - check_xs_var(nc, ref, 1E-5, test_name,1) - - setcurrent(nc, "t") - v = values(nc) - - # having checked the levels we derive the reference values independently - nc_ref = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - horizontal_point_mode: pmode, - level_selection_type: "level_list", - level_list: tolist(v_lev/100), # has to be hPa - vertical_scaling: "linear", - data : f & lnsp - ) - - ref = (var_name: 't', - dim_names: ["time","nlev","lon"], - dim_values: [1,nlev,num_line]) - check_xs_var(nc_ref, ref, test_name & " ref",1) - - ref = (var_name: 't_lev', - dim_names: ["time","nlev"], - dim_values: [1,nlev], - values: v_lev/100) - check_xs_var(nc_ref, ref, 1E-5, test_name & " ref",1) - - setcurrent(nc_ref, "t") - v_ref = values(nc_ref) - assert(vec_same(v, v_ref, 1E-1), test_name & " values",1) - - end for - -end test_scalar_ghbc_ml - -function test_scalar_ghbc_level_selection_ml() - - fn_name = "scalar_ghbc_level_selection_ml" - - fs = read("xs_tz_ml.grib") - f_t = read(data: fs, param: 't') - f_z = read(data: fs, param: 'z')/9.81 - - line = [20, -112, 24.2, -93.5] - - # -------------------------- - # adaptive - # -------------------------- - - # TODO: enable it when fully implemented - if 1 = 0 then - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "adaptive", - vertical_coordinates: "user", - vertical_coordinate_param: 129, - data : f_t & f_z - ) - - # read reference data - nc_ref = read("xs_ml_ghbc_adaptive_ref.nc") - - nlev = 38 - num_line = 64 - check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 1) - end if - # -------------------------- - # from_data - # -------------------------- - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "from_data", - vertical_coordinates: "user", - vertical_coordinate_param: 129, - data : f_t & f_z - ) - - # read reference data - nc_ref = read("xs_ml_ghbc_from_data_ref.nc") - - nlev = 33 - num_line = 64 - check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 2) - - -end test_scalar_ghbc_level_selection_ml - - -function test_scalar_ghbc_extrapolate_ml() - - fn_name = "scalar_ghbc_extrapolate_ml" - - fs = read("xs_tz_ml.grib") - f_t = read(data: fs, param: 't') - f_z = read(data: fs, param: 'z')/9.81 - - line = [20, -112, 24.2, -93.5] - - # -------------------------- - # 1. adaptive, linear - # -------------------------- - # TODO: enable it when fully implemented - if 1 = 0 then - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "adaptive", - vertical_coordinates: "user", - vertical_coordinate_param: 129, - vertical_coordinate_extrapolate: "on", - vertical_coordinate_extrapolate_mode: "linear", - vertical_coordinate_extrapolate_fixed_sign: "on", - data : f_t & f_z - ) - - # read reference data - nc_ref = read("xs_ml_ghbc_adaptive_extra_linear_ref.nc") - - nlev = 40 - num_line = 64 - check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 1) - - # -------------------------- - # 2. adaptive, constant - # -------------------------- - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "adaptive", - vertical_coordinates: "user", - vertical_coordinate_param: 129, - vertical_coordinate_extrapolate: "on", - vertical_coordinate_extrapolate_mode: "constant", - data : f_t & f_z - ) - - # read reference data - nc_ref = read("xs_ml_ghbc_adaptive_extra_const_ref.nc") - - nlev = 40 - num_line = 64 - check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 2) - end if - - # -------------------------- - # 3. from_data, linear - # -------------------------- - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "from_data", - vertical_coordinates: "user", - vertical_coordinate_param: 129, - vertical_coordinate_extrapolate: "on", - vertical_coordinate_extrapolate_mode: "linear", - vertical_coordinate_extrapolate_fixed_sign: "on", - data : f_t & f_z - ) - - # read reference data - nc_ref = read("xs_ml_ghbc_from_data_extra_linear_ref.nc") - - nlev = 35 - num_line = 64 - check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 3) - - # -------------------------- - # 4. from_data, constant - # -------------------------- - - nc = mcross_sect( - line : line, - wind_parallel : "off", - wind_perpendicular : "off", - wind_intensity : "off", - level_selection_type: "from_data", - vertical_coordinates: "user", - vertical_coordinate_param: 129, - vertical_coordinate_extrapolate: "on", - vertical_coordinate_extrapolate_mode: "constant", - data : f_t & f_z - ) - - # read reference data - nc_ref = read("xs_ml_ghbc_from_data_extra_constant_ref.nc") - - nlev = 35 - num_line = 64 - check_xs_result(nc, nc_ref, nlev, num_line, "t", "t_lev", fn_name, 4) - -end test_scalar_ghbc_extrapolate_ml - -function test_build_orog_interpolate() - - test_name = "build_orog_interpolate" - - # read input grib data - fs = read("t_lnsp_ml137.grb") - - # surface pressure in hPa - sp = exp(read(data: fs, param: "lnsp"))/100 - - # read xs reference data - nc = read("t_lnsp_ml137_xs_ref.nc") - - # define variable to be checked - setcurrent(nc,"orography_x_values") - xp_ref = values(nc) - - setcurrent(nc,"orography_y1_values") - yp1_ref = values(nc) - - setcurrent(nc,"orography_y2_values") - yp2_ref = values(nc) - - orog = xs_build_orog(nc, sp, 1045.58853353987, "charcoal") - - assert_equal(count(orog), 2, test_name & " num",1) - - # x values - xp = orog[1].INPUT_X_VALUES - assert_equal(xp[1], xp[2], test_name & " xp-first",1) - assert_equal(xp[count(xp)], xp[count(xp)-1], test_name & " xp-last",1) - xp_ori = xp - xp = vector(count(xp_ori)-2) - for i=1 to count(xp) do - xp[i] = xp_ori[i+1] - end for - - assert(vec_same(xp, xp_ref, 1E-5), test_name & " xp", 1) - - # y values - yp = orog[1].INPUT_Y_VALUES - assert_equal(yp[1], yp2_ref[1], test_name & " yp-first",1) - assert_equal(yp[count(yp)], yp2_ref[count(yp2_ref)], test_name & " yp-last",1) - - yp_ori = yp - yp = vector(count(yp_ori)-2) - for i=1 to count(yp) do - yp[i] = yp_ori[i+1] - end for - - assert(vec_same(yp, yp1_ref, 0.8), test_name & " yp", 1) - - # graph - assert_equal(orog[2].GRAPH_TYPE, "AREA", test_name & " graph-type",1) - assert_equal(orog[2].GRAPH_SHADE_COLOUR, "charcoal", test_name & " graph-colour",1) - -end test_build_orog_interpolate - -function test_build_orog_nearest() - - test_name = "build_orog_nearest" - - # read input grib data - fs = read("t_lnsp_ml137.grb") - - # surface pressure in hPa - sp = exp(read(data: fs, param: "lnsp"))/100 - - lines = [[47, 7, 45, 16], - [47, 7, 47, 16], - [47, 7, 38, 7]] - - for i=1 to count(lines) do - # generate xs reference data - nc = mcross_sect( - line : lines[i], - data : fs, - horizontal_point_mode: "nearest_gridpoint" - ) - - # define variable to be checked - setcurrent(nc,"orography_x_values") - xp_ref = values(nc) - - setcurrent(nc,"orography_y1_values") - yp1_ref = values(nc) - - setcurrent(nc,"orography_y2_values") - yp2_ref = values(nc) - - orog = xs_build_orog(nc, sp, 1045.58853353987, "charcoal") - - assert_equal(count(orog), 2, test_name & " num",i) - - # x values - xp = orog[1].INPUT_X_VALUES - assert_equal(xp[1], xp[2], test_name & " xp-first",i) - assert_equal(xp[count(xp)], xp[count(xp)-1], test_name & " xp-last",i) - xp_ori = xp - xp = vector(count(xp_ori)-2) - for k=1 to count(xp) do - xp[k] = xp_ori[k+1] - end for - - assert(vec_same(xp, xp_ref, 1E-5), test_name & " xp", i) - - # y values - yp = orog[1].INPUT_Y_VALUES - assert_equal(yp[1], yp2_ref[1], test_name & " yp-first",i) - assert_equal(yp[count(yp)], yp2_ref[count(yp2_ref)], test_name & " yp-last",i) - - yp_ori = yp - yp = vector(count(yp_ori)-2) - for k=1 to count(yp) do - yp[k] = yp_ori[k+1] - end for - - assert(vec_same(yp, yp1_ref, 1E-4), test_name & " yp", i) - - # graph - assert_equal(orog[2].GRAPH_TYPE, "AREA", test_name & " graph-type",i) - assert_equal(orog[2].GRAPH_SHADE_COLOUR, "charcoal", test_name & " graph-colour",i) - end for -end test_build_orog_nearest - -function test_build_curve_interpolate() - - test_name = "build_curve_interpolate" - - # read input grib data - fs = read("t_lnsp_ml137.grb") - - # surface pressure in hPa - sp = exp(read(data: fs, param: "lnsp"))/100 - - # read xs reference data - nc = read("t_lnsp_ml137_xs_ref.nc") - - # define variable to be checked - setcurrent(nc,"orography_x_values") - xp_ref = values(nc) - - setcurrent(nc,"orography_y1_values") - yp1_ref = values(nc) - - setcurrent(nc,"orography_y2_values") - yp2_ref = values(nc) - - curve = xs_build_curve(nc, sp, "charcoal", "solid", 3) - - assert_equal(count(curve), 2, test_name & " num",1) - - # x values - xp = vector(curve[1].INPUT_X_VALUES) - assert(vec_same(xp, xp_ref, 1E-5), test_name & " xp", 1) - - # y values - yp = vector(curve[1].INPUT_Y_VALUES) - assert(vec_same(yp, yp1_ref, 0.8), test_name & " yp", 1) - - # graph - assert_equal(curve[2].GRAPH_TYPE, "CURVE", test_name & " graph-type",1) - assert_equal(curve[2].GRAPH_LINE_COLOUR, "charcoal", test_name & " graph-colour",1) - assert_equal(curve[2].GRAPH_LINE_STYLE, "SOLID", test_name & " graph-style",1) - assert_equal(curve[2].GRAPH_LINE_THICKNESS, 3, test_name & " graph-thickness",1) - -end test_build_curve_interpolate - -function test_build_curve_nearest() - - test_name = "build_curve_nearest" - - # read input grib data - fs = read("t_lnsp_ml137.grb") - - # surface pressure in hPa - sp = exp(read(data: fs, param: "lnsp"))/100 - - lines = [[47, 7, 45, 16], - [47, 7, 47, 16], - [47, 7, 38, 7]] - - for i=1 to count(lines) do - # generate xs reference data - nc = mcross_sect( - line : lines[i], - data : fs, - horizontal_point_mode: "nearest_gridpoint" - ) - - # define variable to be checked - setcurrent(nc,"orography_x_values") - xp_ref = values(nc) - - setcurrent(nc,"orography_y1_values") - yp1_ref = values(nc) - - setcurrent(nc,"orography_y2_values") - yp2_ref = values(nc) - - curve = xs_build_curve(nc, sp, "charcoal", "solid", 3) - - assert_equal(count(curve), 2, test_name & " num",i) - - # x values - xp = vector(curve[1].INPUT_X_VALUES) - assert(vec_same(xp, xp_ref, 1E-5), test_name & " xp", i) - - # y values - yp = vector(curve[1].INPUT_Y_VALUES) - assert(vec_same(yp, yp1_ref, 1E-4), test_name & " yp", i) - - # graph - assert_equal(curve[2].GRAPH_TYPE, "CURVE", test_name & " graph-type",i) - assert_equal(curve[2].GRAPH_LINE_COLOUR, "charcoal", test_name & " graph-colour",i) - assert_equal(curve[2].GRAPH_LINE_STYLE, "SOLID", test_name & " graph-style",i) - assert_equal(curve[2].GRAPH_LINE_THICKNESS, 3, test_name & " graph-thickness",i) - end for - - -end test_build_curve_nearest \ No newline at end of file diff -Nru metview-5.17.4/metview/test/macros/xsection_ml_orog.mv metview-5.19.2/metview/test/macros/xsection_ml_orog.mv --- metview-5.17.4/metview/test/macros/xsection_ml_orog.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/xsection_ml_orog.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,145 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include 'test_utils.mv' + +#build orog +test_build_orog_interpolate() +test_build_orog_nearest() + +#------------------------------------------ +# Tests +#------------------------------------------ + +function test_build_orog_interpolate() + + test_name = "build_orog_interpolate" + + # read input grib data + fs = read("t_lnsp_ml137.grb") + + # surface pressure in hPa + sp = exp(read(data: fs, param: "lnsp"))/100 + + # read xs reference data + nc = read("t_lnsp_ml137_xs_ref.nc") + + # define variable to be checked + setcurrent(nc,"orography_x_values") + xp_ref = values(nc) + + setcurrent(nc,"orography_y1_values") + yp1_ref = values(nc) + + setcurrent(nc,"orography_y2_values") + yp2_ref = values(nc) + + orog = xs_build_orog(nc, sp, 1045.58853353987, "charcoal") + + assert_equal(count(orog), 2, test_name & " num",1) + + # x values + xp = orog[1].INPUT_X_VALUES + assert_equal(xp[1], xp[2], test_name & " xp-first",1) + assert_equal(xp[count(xp)], xp[count(xp)-1], test_name & " xp-last",1) + xp_ori = xp + xp = vector(count(xp_ori)-2) + for i=1 to count(xp) do + xp[i] = xp_ori[i+1] + end for + + assert(vec_same(xp, xp_ref, 1E-5), test_name & " xp", 1) + + # y values + yp = orog[1].INPUT_Y_VALUES + assert_equal(yp[1], yp2_ref[1], test_name & " yp-first",1) + assert_equal(yp[count(yp)], yp2_ref[count(yp2_ref)], test_name & " yp-last",1) + + yp_ori = yp + yp = vector(count(yp_ori)-2) + for i=1 to count(yp) do + yp[i] = yp_ori[i+1] + end for + + assert(vec_same(yp, yp1_ref, 0.8), test_name & " yp", 1) + + # graph + assert_equal(orog[2].GRAPH_TYPE, "AREA", test_name & " graph-type",1) + assert_equal(orog[2].GRAPH_SHADE_COLOUR, "charcoal", test_name & " graph-colour",1) + +end test_build_orog_interpolate + +function test_build_orog_nearest() + + test_name = "build_orog_nearest" + + # read input grib data + fs = read("t_lnsp_ml137.grb") + + # surface pressure in hPa + sp = exp(read(data: fs, param: "lnsp"))/100 + + lines = [[47, 7, 45, 16], + [47, 7, 47, 16], + [47, 7, 38, 7]] + + for i=1 to count(lines) do + # generate xs reference data + nc = mcross_sect( + line : lines[i], + data : fs, + horizontal_point_mode: "nearest_gridpoint" + ) + + # define variable to be checked + setcurrent(nc,"orography_x_values") + xp_ref = values(nc) + + setcurrent(nc,"orography_y1_values") + yp1_ref = values(nc) + + setcurrent(nc,"orography_y2_values") + yp2_ref = values(nc) + + orog = xs_build_orog(nc, sp, 1045.58853353987, "charcoal") + + assert_equal(count(orog), 2, test_name & " num",i) + + # x values + xp = orog[1].INPUT_X_VALUES + assert_equal(xp[1], xp[2], test_name & " xp-first",i) + assert_equal(xp[count(xp)], xp[count(xp)-1], test_name & " xp-last",i) + xp_ori = xp + xp = vector(count(xp_ori)-2) + for k=1 to count(xp) do + xp[k] = xp_ori[k+1] + end for + + assert(vec_same(xp, xp_ref, 1E-5), test_name & " xp", i) + + # y values + yp = orog[1].INPUT_Y_VALUES + assert_equal(yp[1], yp2_ref[1], test_name & " yp-first",i) + assert_equal(yp[count(yp)], yp2_ref[count(yp2_ref)], test_name & " yp-last",i) + + yp_ori = yp + yp = vector(count(yp_ori)-2) + for k=1 to count(yp) do + yp[k] = yp_ori[k+1] + end for + + assert(vec_same(yp, yp1_ref, 1E-4), test_name & " yp", i) + + # graph + assert_equal(orog[2].GRAPH_TYPE, "AREA", test_name & " graph-type",i) + assert_equal(orog[2].GRAPH_SHADE_COLOUR, "charcoal", test_name & " graph-colour",i) + end for +end test_build_orog_nearest diff -Nru metview-5.17.4/metview/test/macros/xsection_ml_scalar.mv metview-5.19.2/metview/test/macros/xsection_ml_scalar.mv --- metview-5.17.4/metview/test/macros/xsection_ml_scalar.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/xsection_ml_scalar.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,496 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include 'test_utils.mv' + +test_scalar_ml() +test_scalar_level_selection_ml() +test_scalar_nolnsp_ml() + +#------------------------------------------ +# Tests +#------------------------------------------ + +function test_scalar_ml() + + # read input grib data + fs = read("t_lnsp_ml137.grb") + + # read reference data + nc_ref = read("t_lnsp_ml137_xs_ref.nc") + + # compute xsection and save it in a netcdf file + nc = mcross_sect( + line : [47,7,45,16], + data : fs + ) + + # variables + vars_ref = ["time","lat","lon","t_lev","t","lnsp","orography_x_values", + "orography_y1_values", "orography_y2_values"] + + vars = variables(nc) + assert_equal(vars, vars_ref,"scalar_ml - vars",1) + + # global attributes + gattr = global_attributes(nc) + assert_equal(count(keywords(gattr)),5,'scalar_ml - global_attributes', 1) + assert_equal(gattr.type,"MXSECTION",'scalar_ml - global_attribute type',1) + + # define variable to be checked + setcurrent(nc,"t") + + # attributes of a variable + attr = attributes(nc) + + assert_equal(count(keywords(attr)),4,'scalar_ml - t attributes count', 1) + assert_equal(attr.long_name,"Temperature",'scalar_ml - t long_name', 1) + assert_equal(attr.units,"K",'scalar_ml - t units', 1) + + num_line=64 + num_lev=146 + + # t + setcurrent(nc_ref,"t") + vals_ref = values(nc_ref) + + ref = (var_name: "t", + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line], + values: vals_ref) + check_xs_var(nc, ref, "scalar_ml",1) + + # t_lev + setcurrent(nc_ref,"t_lev") + vals_ref = values(nc_ref) + + ref = (var_name: "t_lev", + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: vals_ref) + check_xs_var(nc, ref, "scalar_ml",1) + + # orography_x_values + setcurrent(nc_ref,"orography_x_values") + vals_ref = values(nc_ref) + + ref = (var_name: "orography_x_values", + dim_names: ["time","npoints"], + dim_values: [1,num_line], + values: vals_ref) + check_xs_var(nc, ref, "scalar_ml",1) + + # orography_y1_values + setcurrent(nc_ref,"orography_y1_values") + vals_ref = values(nc_ref) + + ref = (var_name: "orography_y1_values", + dim_names: ["time","npoints"], + dim_values: [1,num_line], + values: vals_ref) + check_xs_var(nc, ref, "scalar_ml",1) + + # orography_y2_values + setcurrent(nc_ref,"orography_y2_values") + vals_ref = values(nc_ref) + + ref = (var_name: "orography_y2_values", + dim_names: ["time","npoints"], + dim_values: [1,num_line], + values: vals_ref) + check_xs_var(nc, ref, "scalar_ml",1) + + # orography_x_values + setcurrent(nc_ref,"orography_x_values") + vals_ref = values(nc_ref) + + ref = (var_name: "lnsp", + dim_names: ["time","npoints"], + dim_values: [1,num_line]) + check_xs_var(nc, ref, "scalar_ml",1) + + setcurrent(nc,'orography_y1_values') + v_orog_y1 = values(nc) + + setcurrent(nc,'lnsp') + v = values(nc) + v = exp(v)/100 + # first 20 values are missing + assert(vec_same(v[20,num_line],v_orog_y1[20,num_line]),"scalar_ml lnsp",1) + +end test_scalar_ml + +function test_scalar_level_selection_ml() + fs = read("xs_ml_input.grib") + + f = read(data: fs, param: ['lnsp','t'], step:12) + t = read(data: f, param: 't') + lnsp = read(data: f, param: 'lnsp') + + # create artificial field with known values + + pres = pressure(lnsp)/100 + + ft = lnsp + for i=1 to count(t) do + lev = grib_get_long(t[i],'level') + v = 100*values(coslat(t[i])) + values(pres[i]) + ft = ft & (set_values(t[i],v)) + end for + + #-------------------------------------- + # case 1 - COUNT + # east west line lying on grid points + # level selection: + #-------------------------------------- + lat = 50 + line = [lat, -10, lat, 5] + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "count", + level_count: 16, + bottom_level: 800, + top_level: 50, + vertical_scaling: "linear", + data : ft + ) + + v_lev = |50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, + 800| + + setcurrent(nc, 't') + v = values(nc) + + nlev = count(v_lev) + num_line = 64 + + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc, ref, "scalar_level_selection_ml",1) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev) + check_xs_var(nc, ref, "scalar_level_selection_ml",1) + + # build reference + v_ref = v*0 + + cos_lat = 100*cos(pi*lat/180.) + v = v - cos_lat + + for i=1 to nlev do + for j=1 to num_line do + v_ref[(i-1)*num_line + j] = v_lev[i] + end for + end for + + # we do not expect perfect match since the pressure is interpolated + # to target levels + assert(vec_same(v, v_ref,0.2), "scalar_level_selection_ml values",1) + + #-------------------------------------- + # case 2 - COUNT + # north south line lying on grid points + #-------------------------------------- + + lon = -5 + line = [42, lon, 52, lon] + xs = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "count", + level_count: 16, + bottom_level: 800, + top_level: 50, + vertical_scaling: "linear", + data : ft + ) + + v_lev = |50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, + 800| + + nlev = count(v_lev) + num_line = 64 + + setcurrent(nc, 't') + v = values(nc) + + setcurrent(nc, 'lat') + v_lat = values(nc) + assert_equal(count(v_lat),num_line,'scalar_level_selection_ml v_lat',2) + + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc, ref, "scalar_level_selection_ml",2) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev) + check_xs_var(nc, ref, "scalar_level_selection_ml",2) + + # build reference + v_ref = v*0 + + for i=1 to nlev do + for j=1 to num_line do + cos_lat = 100*cos(pi*v_lat[j]/180.) + v_ref[(i-1)*num_line + j] = cos_lat + v_lev[i] + end for + end for + + # we do not expect perfect match since both the coslat and pressure are + # interpolated + assert(vec_same(v, v_ref,0.2), "scalar_level_selection_ml values",2) + + #-------------------------------------- + # case 3 - LEVEL_LIST + # east west line lying on grid points + # level selection: + #-------------------------------------- + lat = 50 + line = [lat, -10, lat, 5] + v_lev = |50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, + 800| + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : ft + ) + + setcurrent(nc, 't') + v = values(nc) + + nlev = count(v_lev) + num_line = 64 + + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc, ref, "scalar_level_selection_ml",3) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev) + check_xs_var(nc, ref, "scalar_level_selection_ml",3) + + # build reference + v_ref = v*0 + + cos_lat = 100*cos(pi*lat/180.) + v = v - cos_lat + + for i=1 to nlev do + for j=1 to num_line do + v_ref[(i-1)*num_line + j] = v_lev[i] + end for + end for + + # we do not expect perfect match since the pressure is interpolated + # to target levels + assert(vec_same(v, v_ref,0.2), "scalar_level_selection_ml values",3) + + #-------------------------------------- + # case 4 - LEVEL_LIST + # north south line lying on grid points + #-------------------------------------- + + lon = -5 + line = [42, lon, 52, lon] + v_lev = |50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, + 800| + + xs = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : ft + ) + + nlev = count(v_lev) + num_line = 64 + + setcurrent(nc, 't') + v = values(nc) + + setcurrent(nc, 'lat') + v_lat = values(nc) + assert_equal(count(v_lat),num_line,'scalar_level_selection_ml v_lat',4) + + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc, ref, "scalar_level_selection_ml",4) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev) + check_xs_var(nc, ref, "scalar_level_selection_ml",4) + + # build reference + v_ref = v*0 + + for i=1 to nlev do + for j=1 to num_line do + cos_lat = 100*cos(pi*v_lat[j]/180.) + v_ref[(i-1)*num_line + j] = cos_lat + v_lev[i] + end for + end for + + # we do not expect perfect match since both the coslat and pressure are + # interpolated + assert(vec_same(v, v_ref,0.2), "scalar_level_selection_ml values",4) + +end test_scalar_level_selection_ml + + +function test_scalar_nolnsp_ml() + fs = read("xs_ml_input.grib") + t = read(data: fs, param: 't', step:12) + + # create artificial field with known values + ft = nil + for i=1 to count(t) do + lev = grib_get_long(t[i],'level') + v = 10*values(coslat(t[i])) + 100*lev + ft = ft & (set_values(t[i],v)) + end for + + #-------------------------------------- + # case 1 - COUNT + # east west line lying on grid points + # level selection: + #-------------------------------------- + lat = 50.3 + line = [lat, -10, lat, 5] + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + data : ft + ) + + setcurrent(nc, 't') + v = values(nc) + + nlev = 91 + num_line = 64 + + v_lev =vector(nlev) + for i=1 to count(v_lev) do + v_lev[i]=i + end for + + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc, ref, "scalar_nolnsp_ml",1) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev) + check_xs_var(nc, ref, "scalar_nolnsp_ml",1) + + # build reference + v_ref = v*0 + + cos_lat = 10*cos(pi*lat/180.) + v = v - cos_lat + + for i=1 to nlev do + for j=1 to num_line do + v_ref[(i-1)*num_line + j] = 100*v_lev[i] + end for + end for + + # we do not expect perfect match since the pressure is interpolated + # to target levels + assert(vec_same(v, v_ref,0.2), "scalar_nolnsp_ml values",1) + + #-------------------------------------- + # case 2 - COUNT + # north south line lying on grid points + #-------------------------------------- + + lon = -5.2 + line = [42, lon, 52, lon] + xs = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + data : ft + ) + + nlev = 91 + num_line = 64 + + v_lev =vector(nlev) + for i=1 to count(v_lev) do + v_lev[i]=i + end for + + setcurrent(nc, 't') + v = values(nc) + + setcurrent(nc, 'lat') + v_lat = values(nc) + assert_equal(count(v_lat),num_line,'scalar_nolnsp_ml v_lat',2) + + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc, ref, "scalar_nolnsp_ml",2) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev) + check_xs_var(nc, ref, "scalar_nolnsp_ml",2) + + # build reference + v_ref = v*0 + + for i=1 to nlev do + for j=1 to num_line do + cos_lat = 10*cos(pi*v_lat[j]/180.) + v_ref[(i-1)*num_line + j] = cos_lat + 100*v_lev[i] + end for + end for + + # we do not expect perfect match since both the coslat and pressure are + # interpolated + assert(vec_same(v, v_ref,0.2), "scalar_nolnsp_ml values",2) + +end test_scalar_nolnsp_ml diff -Nru metview-5.17.4/metview/test/macros/xsection_ml_wind.mv metview-5.19.2/metview/test/macros/xsection_ml_wind.mv --- metview-5.17.4/metview/test/macros/xsection_ml_wind.mv 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/test/macros/xsection_ml_wind.mv 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,445 @@ +# Metview Macro + +# **************************** LICENSE START *********************************** +# +# Copyright 2019 ECMWF. This software is distributed under the terms +# of the Apache License version 2.0. In applying this license, ECMWF does not +# waive the privileges and immunities granted to it by virtue of its status as +# an Intergovernmental Organization or submit itself to any jurisdiction. +# +# ***************************** LICENSE END ************************************ + +include 'test_utils.mv' + +# 2D wind +test_wind_2d_intensity_ml() + +# 3D wind +test_wind_3d_w_compute_ml() + +#------------------------------------------ +# Tests +#------------------------------------------ + + +function test_wind_2d_intensity_ml() + + fs=read("xs_ml_input.grib") + + #------------------------------ + # Single step + #------------------------------ + + f = read(data: fs, param: ['lnsp', 'u', 'v'], step:12) + + line = [54.39,-18.22,44.42,8.26] + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "on", + data : f + ) + + #examine(nc) + #sleep(5) + #stop + + v_lev = |300, 400, 500, 700, 850, 1000| + + ref = (var_name: 'u', + dim_names: ["time","nlev","lon"], + dim_values: [1,97,64]) + check_xs_var(nc, ref, 'wind_2d_intensity_ml',1) + + ref = (var_name: 'u_lev', + dim_names: ["time","nlev"], + dim_values: [1,97]) + check_xs_var(nc, ref, 'wind_2d_intensity_ml',1) + + v_lev_start = |0.0100002002716064, 0.0299043607711792, 0.0568400907516479| + v_lev_end = |994.222724269193, 1004.22272426919, 1014.22272426919, 1024.22272426919| + + setcurrent(nc, 'u_lev') + v = values(nc) + + assert(vec_same(v[1,3], v_lev_start), "wind_2d_intensity_ml levels start",1) + assert(vec_same(v[97-3,97], v_lev_end), "wind_2d_intensity_ml levels end",1) + + # this should contain the wind speed + setcurrent(nc, 'u') + v = values(nc) + + # build reference + f_u = read(data: fs, param: ['lnsp','u'], step:12) + nc_u = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + data : f_u + ) + + f_v = read(data: fs, param: ['lnsp','v'], step:12) + nc_v = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + data : f_v + ) + + setcurrent(nc_u,'u') + v_u = values(nc_u) + + setcurrent(nc_v,'v') + v_v = values(nc_v) + + v_ref = sqrt(v_u*v_u + v_v*v_v) + assert(vec_same_missing(v, v_ref, 1E-1), "wind_2d_intensity_ml values",1) + +end test_wind_2d_intensity_ml + +function test_wind_3d_w_compute_ml() + + V1 = nil + V2 = nil + + fs=read("xs_ml_input.grib") + f_u = read(data: fs, param: ['u'], step:12) + f_v = read(data: fs, param: ['v'], step:12) + f_w = read(data: fs, param: ['w'], step:12) + t = read(data: fs, param: ['t'], step:12) + lnsp = read(data: fs, param: 'lnsp', step:12) + + # we focus on w + f_u = f_u * 0 + f_v = f_v * 0 + + g = 9.81 + Rd = 287.058 + t0 = 273.16 + + line = [50,-10,44,8] + w_scaling_lst = [-10, 1] + v_lev = |100, 300, 400, 500, 700, 850| + + # will not get perfect match because the in XS the + # vertical interpolation is performed after w is computed + + #---------------------------- + # Intensity - without T + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "on", + w_wind_scaling_factor_mode: 'compute', + w_wind_scaling_factor: w_scaling, + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_u & f_v & f_w & lnsp + ) + + num_lev = count(v_lev) + num_line = 64 + + ref = (var_name: 'u', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,1) + + ref = (var_name: 'u_lev', + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: v_lev) + check_xs_var(nc, ref, test_name,1) + + # this should contain the wind speed + setcurrent(nc, 'u') + v = values(nc) + + # build reference + nc_w = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_w & lnsp + ) + + setcurrent(nc_w,'w') + v_w = values(nc_w) + + for i=1 to num_lev do + for j=1 to num_line do + idx = (i-1)*num_line + j + pres = v_lev[i]*100 + v_w[idx] = -v_w[idx] / (g*pres/(Rd*t0)) + end for + end for + + v_w = w_scaling*v_w + v_ref = abs(v_w) + + assert(vec_same(v, v_ref, 0.1), test_name & " values",1) + end for + + #---------------------------- + # Intensity - with T + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "on", + w_wind_scaling_factor_mode: 'compute', + w_wind_scaling_factor: w_scaling, + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_u & f_v & f_w & lnsp & t + ) + + num_lev = count(v_lev) + num_line = 64 + + ref = (var_name: 'u', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,2) + + ref = (var_name: 'u_lev', + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: v_lev) + check_xs_var(nc, ref, test_name,2) + + # this should contain the wind speed + setcurrent(nc, 'u') + v = values(nc) + + # build reference + nc_w = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_w & lnsp + ) + + nc_t = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : t & lnsp + ) + + setcurrent(nc_w,'w') + v_w = values(nc_w) + + setcurrent(nc_t,'t') + v_t = values(nc_t) + + for i=1 to num_lev do + for j=1 to num_line do + idx = (i-1)*num_line + j + pres = v_lev[i]*100 + v_w[idx] = -v_w[idx] / (g*pres/(Rd*v_t[idx])) + end for + end for + + v_w = w_scaling*v_w + v_ref = abs(v_w) + + assert(vec_same(v, v_ref,0.1), test_name & " values",2) + + end for + + #---------------------------- + # parallel - without T + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "on", + wind_perpendicular : "off", + wind_intensity : "off", + w_wind_scaling_factor_mode: 'compute', + w_wind_scaling_factor: w_scaling, + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_u & f_v & f_w & lnsp + ) + + num_lev = count(v_lev) + num_line = 64 + + ref = (var_name: 'x_component', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,3) + + ref = (var_name: 'y_component', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,3) + + ref = (var_name: 'lev', + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: v_lev) + check_xs_var(nc, ref,test_name,3) + + # we only check the y component + setcurrent(nc, 'y_component') + v = values(nc) + + f_w = read(data: fs, param: 'w', step:12) + nc_w = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_w & lnsp + ) + + setcurrent(nc_w,'w') + v_w = values(nc_w) + + for i=1 to num_lev do + for j=1 to num_line do + idx = (i-1)*num_line + j + pres = v_lev[i]*100 + v_w[idx] = -v_w[idx] / (g*pres/(Rd*t0)) + end for + end for + + v_ref = w_scaling*v_w + assert(vec_same(v, v_ref,0.1), test_name & " values",3) + + end for + + #---------------------------- + # parallel - with T + #---------------------------- + + for k=1 to count(w_scaling_lst) do + + w_scaling = w_scaling_lst[k] + test_name = "test_wind_3d_w_compute_ml scaling=" & w_scaling + + nc = mcross_sect( + line : line, + wind_parallel : "on", + wind_perpendicular : "off", + wind_intensity : "off", + w_wind_scaling_factor_mode: 'compute', + w_wind_scaling_factor: w_scaling, + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_u & f_v & f_w & t & lnsp + ) + + num_lev = count(v_lev) + num_line = 64 + + ref = (var_name: 'x_component', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,4) + + ref = (var_name: 'y_component', + dim_names: ["time","nlev","lon"], + dim_values: [1,num_lev,num_line]) + check_xs_var(nc, ref, test_name,4) + + ref = (var_name: 'lev', + dim_names: ["time","nlev"], + dim_values: [1,num_lev], + values: v_lev) + check_xs_var(nc, ref,test_name,4) + + # we only check the y component + setcurrent(nc, 'y_component') + v = values(nc) + + f_w = read(data: fs, param: 'w', step:12) + nc_w = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : f_w & lnsp + ) + + nc_t = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "level_list", + level_list: tolist(v_lev), + vertical_scaling: "linear", + data : t & lnsp + ) + + setcurrent(nc_w,'w') + v_w = values(nc_w) + + setcurrent(nc_t,'t') + v_t = values(nc_t) + + for i=1 to num_lev do + for j=1 to num_line do + idx = (i-1)*num_line + j + pres = v_lev[i]*100 + v_w[idx] = -v_w[idx] / (g*pres/(Rd*v_t[idx])) + end for + end for + + v_ref = w_scaling*v_w + assert(vec_same(v, v_ref,0.1), test_name & " values",4) + + end for + + +end test_wind_3d_w_compute_ml diff -Nru metview-5.17.4/metview/test/macros/xsection_pl.mv metview-5.19.2/metview/test/macros/xsection_pl.mv --- metview-5.17.4/metview/test/macros/xsection_pl.mv 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/metview/test/macros/xsection_pl.mv 2023-07-15 08:28:47.000000000 +0000 @@ -14,6 +14,7 @@ test_scalar_core_pl() test_scalar_steps_pl() test_scalar_level_selection_pl() +test_scalar_level_selection_pl_log() # 2D wind test_wind_2d_intensity_pl() @@ -2052,7 +2053,7 @@ top_level: 350, data : ft ) - + v_lev = |350, 450, 550, 650, 750, 850, 950| setcurrent(nc, 't') @@ -2256,6 +2257,80 @@ end test_scalar_level_selection_pl +function test_scalar_level_selection_pl_log() + fs = read("xs_pl_input.grib") + t = read(data: fs, param: 't', step: 12) + + # create artificial field with known values + ft = nil + for i=1 to count(t) do + lev = grib_get_long(t[i],'level') + v = 100*values(coslat(t[i])) + lev + ft = ft & (set_values(t[i],v)) + end for + + v_lev = |400, 500| + v_lev = |300, 400, 500, 700, 850, 1000| + + #-------------------------------------- + # case 1 - COUNT + # east west line lying on grid points + # level selection: + #-------------------------------------- + lat = 50 + line = [lat, -10, lat, 5] + nc = mcross_sect( + line : line, + wind_parallel : "off", + wind_perpendicular : "off", + wind_intensity : "off", + level_selection_type: "count", + level_count: 7, + bottom_level: 950, + top_level: 350, + vertical_scaling: "log", + data : ft + ) + + v_lev = |350, 450, 550, 650, 750, 850, 950| + v_lev_ref = |350,413.375,488.225,576.628,681.039,804.355,950| + + setcurrent(nc, 't') + v = values(nc) + + nlev = count(v_lev) + num_line = 64 + + ref = (var_name: 't', + dim_names: ["time","nlev","lon"], + dim_values: [1,nlev,num_line]) + check_xs_var(nc, ref, "scalar_level_selection_pl_log",1) + + ref = (var_name: 't_lev', + dim_names: ["time","nlev"], + dim_values: [1,nlev], + values: v_lev_ref) + check_xs_var(nc, ref, 1E-3, "scalar_level_selection_pl_log",1) + + # build reference + v_ref = v*0 + + cos_lat = 100*cos(pi*lat/180.) + v = v - cos_lat + + for i=1 to nlev do + for j=1 to num_line do + v_ref[(i-1)*num_line + j] = v_lev_ref[i] + end for + end for + + # we do not expect perfect match since the pressure is interpolated + # to target levels + assert(vec_same(v, v_ref,0.2), "scalar_level_selection_pl_log values",1) + +end test_scalar_level_selection_pl_log + + function test_line_via_pole_pl() fs = read("tuv_pl.grib") diff -Nru metview-5.17.4/metview/VERSION metview-5.19.2/metview/VERSION --- metview-5.17.4/metview/VERSION 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/metview/VERSION 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1 @@ +5.19.2 diff -Nru metview-5.17.4/mir/bamboo/flags.cmake metview-5.19.2/mir/bamboo/flags.cmake --- metview-5.17.4/mir/bamboo/flags.cmake 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/bamboo/flags.cmake 2023-07-15 08:28:47.000000000 +0000 @@ -1 +1 @@ -set( ENABLE_TEST_ASSERTIONS ON CACHE STRING "Disable assertion tests" ) +set(ENABLE_BUILD_TOOLS ON CACHE BOOL "Build tools") diff -Nru metview-5.17.4/mir/CMakeLists.txt metview-5.19.2/mir/CMakeLists.txt --- metview-5.17.4/mir/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -8,20 +8,19 @@ # does it submit to any jurisdiction. -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) find_package(ecbuild 3.4 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild) -project(mir VERSION 1.13.0 LANGUAGES CXX) +project(mir LANGUAGES CXX) set(PERSISTENT_NAMESPACE "eckit" CACHE INTERNAL "") # needed for generating .b files for persistent support -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) ecbuild_add_option(FEATURE BUILD_TOOLS DEFAULT OFF DESCRIPTION "build the command line tools (install)") ecbuild_add_option(FEATURE MIR_DOWNLOAD_MASKS DEFAULT ON DESCRIPTION "download LSM files") -ecbuild_add_option(FEATURE TEST_ASSERTIONS DEFAULT ON DESCRIPTION "test: regressions") ecbuild_add_option(FEATURE NETCDF DEFAULT ON DESCRIPTION "support for netCDF" REQUIRED_PACKAGES "NetCDF COMPONENTS C") ecbuild_add_option(FEATURE PNG DEFAULT OFF DESCRIPTION "support for PNG encoding" REQUIRED_PACKAGES PNG) ecbuild_add_option(FEATURE OMP DEFAULT OFF DESCRIPTION "support for OpenMP shared memory parallelism" REQUIRED_PACKAGES "OpenMP COMPONENTS CXX") @@ -31,7 +30,7 @@ endif() ecbuild_find_package(NAME eccodes VERSION 2.24 REQUIRED) -ecbuild_find_package(NAME eckit VERSION 1.19 REQUIRED) +ecbuild_find_package(NAME eckit VERSION 1.22 REQUIRED) ecbuild_add_option(FEATURE ATLAS DEFAULT ON DESCRIPTION "support for Atlas" REQUIRED_PACKAGES "atlas VERSION 0.25") @@ -49,7 +48,10 @@ add_subdirectory(src) add_subdirectory(etc) add_subdirectory(share) -add_subdirectory(tests) + +if(HAVE_TESTS) + add_subdirectory(tests) +endif() ecbuild_add_resources(TARGET ${PROJECT_NAME}_top_files SOURCES AUTHORS README NOTICE LICENSE INSTALL COPYING) diff -Nru metview-5.17.4/mir/etc/mir/classes.yaml metview-5.19.2/mir/etc/mir/classes.yaml --- metview-5.17.4/mir/etc/mir/classes.yaml 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/etc/mir/classes.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -148,6 +148,10 @@ # quantity expressing the internal forces arising from deformation exerted from external forces (typical units: [Pa]) stress: {} +# fractional quantity (relative to total) in a grid-box description +tile-fraction: + interpolation: nearest-neighbour + orca.arrangement.f: orca-arrangement: F diff -Nru metview-5.17.4/mir/etc/mir/config.yaml metview-5.19.2/mir/etc/mir/config.yaml --- metview-5.17.4/mir/etc/mir/config.yaml 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/etc/mir/config.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -1,25 +1,31 @@ -{ - "legendre-loader": "mapped-memory", - "matrix-loader": "file-io", +--- - "mir-cache-path": "/tmp/cache", +post-process: + - accuracy + - bitmap + - checkerboard + - compatibility + - edition + - filter + - format + - formula + - frame + - griddef + - latitudes + - longitudes + - nabla + - packing + - pattern + - vod2uv + +mir-cache-path: /tmp/cache + +mir-config-area: ~mir/etc/mir/area.yaml +mir-config-classes: ~mir/etc/mir/classes.yaml +mir-config-grib-input: ~mir/etc/mir/grib-input.yaml +mir-config-grib-output: ~mir/etc/mir/grib-output.yaml +mir-config-grids: ~mir/etc/mir/grids.yaml +mir-config-netcdf: ~mir/etc/mir/netcdf.yaml +mir-config-parameter-class: ~mir/etc/mir/parameter-class.yaml +mir-config-parameters: ~mir/etc/mir/parameters.yaml - "post-process": [ - "accuracy", - "bitmap", - "checkerboard", - "compatibility", - "edition", - "filter", - "format", - "formula", - "frame", - "griddef", - "latitudes", - "longitudes", - "nabla", - "packing", - "pattern", - "vod2uv" - ] -} diff -Nru metview-5.17.4/mir/etc/mir/grib-input.yaml metview-5.19.2/mir/etc/mir/grib-input.yaml --- metview-5.17.4/mir/etc/mir/grib-input.yaml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/etc/mir/grib-input.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,26 @@ +--- + +# (centre=ecmf) +md5GridSection=51ea7dcd62e71c9707157a2d15247593, centre:i=98, gridName=N640, edition=2: +- east: 359.859375 + +# (centre=ecmf) +md5GridSection=8a6f6c4cc9ad3f64546773b87566bc72, centre:i=98, gridName=O2560, edition=1, experimentVersionNumber=h5xa/h5zi: +- north: 89.973091 +- south: -89.973091 + +# IFS-828: Tco639 single precision (centre=ecmf) +md5GridSection=f5dc74ec36353f4c83f7de3bf46e1aef, centre:i=98, gridName=O640, edition=1, experimentVersionNumber=h5wk/h6en/hc9k: +- north: 89.892396 +- south: -89.892396 + +# Lambert conformal conic projection, non-standard interpretation (Toulouse, RSMC, centre=lfpw) +md5GridSection=6ae0076681a2541abe053ab52fa60f30, centre:i=84/85, gridType=lambert, edition=1: +- first_point_bottom_left: true + +# gridType=space_view does not support the default interpolation method +gridType=space_view: +- interpolation: k-nearest +- nearest-method: longest-element-diagonal-and-nclosest +- reset-missing-values: true + diff -Nru metview-5.17.4/mir/etc/mir/grib-output-iii.yaml metview-5.19.2/mir/etc/mir/grib-output-iii.yaml --- metview-5.17.4/mir/etc/mir/grib-output-iii.yaml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/etc/mir/grib-output-iii.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,17 @@ +--- + +edition=0: +- grib-packing-gridded: ccsds +- grib-packing-spectral: complex +- grib-packing-always-set: true + +edition=1: +- grib-packing-gridded: simple +- grib-packing-spectral: complex +- grib-packing-always-set: true + +edition=2: +- grib-packing-gridded: ccsds +- grib-packing-spectral: complex +- grib-packing-always-set: true + diff -Nru metview-5.17.4/mir/etc/mir/grib-output-ii.yaml metview-5.19.2/mir/etc/mir/grib-output-ii.yaml --- metview-5.17.4/mir/etc/mir/grib-output-ii.yaml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/etc/mir/grib-output-ii.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,15 @@ +--- + +edition=0: +- grib-packing-gridded: ccsds +- grib-packing-spectral: complex +- grib-packing-always-set: true + +edition=1: +- grib-packing-gridded: simple +- grib-packing-spectral: complex + +edition=2: +- grib-packing-gridded: ccsds +- grib-packing-spectral: complex + diff -Nru metview-5.17.4/mir/etc/mir/grib-output.yaml metview-5.19.2/mir/etc/mir/grib-output.yaml --- metview-5.17.4/mir/etc/mir/grib-output.yaml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/etc/mir/grib-output.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,11 @@ +--- + +edition=0: +- grib-packing-gridded: simple +- grib-packing-spectral: complex +- grib-packing-always-set: true + +edition=1/2: +- grib-packing-gridded: simple +- grib-packing-spectral: complex + diff -Nru metview-5.17.4/mir/etc/mir/GRIB.yaml metview-5.19.2/mir/etc/mir/GRIB.yaml --- metview-5.17.4/mir/etc/mir/GRIB.yaml 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/etc/mir/GRIB.yaml 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ ---- - -# (centre=ecmf) -md5GridSection=51ea7dcd62e71c9707157a2d15247593, centre:i=98, gridName=N640, edition=2: -- east: 359.859375 - -# (centre=ecmf) -md5GridSection=8a6f6c4cc9ad3f64546773b87566bc72, centre:i=98, gridName=O2560, edition=1, experimentVersionNumber=h5xa/h5zi: -- north: 89.973091 -- south: -89.973091 - -# IFS-828: Tco639 single precision (centre=ecmf) -md5GridSection=f5dc74ec36353f4c83f7de3bf46e1aef, centre:i=98, gridName=O640, edition=1, experimentVersionNumber=h5wk/h6en/hc9k: -- north: 89.892396 -- south: -89.892396 - -# climate.v014 files (md5GridSection for lsm, clake) (centre=ecmf) -md5GridSection=ffa89d4755e4c0b06f712279d96d0dde/0e622d0d974f9f7e24ac408a31eadb3d, centre:i=98, gridType=regular_ll, edition=2: -- west_east_increment: 0.008333333 -- south_north_increment: 0.008333333 -- north: 89.995833333 -- west: 0.004166667 -- south: -89.995833333 -- east: 359.995833333 - -# Lambert conformal conic projection, non-standard interpretation (Toulouse, RSMC, centre=lfpw) -md5GridSection=6ae0076681a2541abe053ab52fa60f30, centre:i=84/85, gridType=lambert, edition=1: -- first_point_bottom_left: true - -# gridType=space_view does not support the default interpolation method -gridType=space_view: -- interpolation: k-nearest -- nearest-method: longest-element-diagonal-and-nclosest -- reset-missing-values: true - diff -Nru metview-5.17.4/mir/etc/mir/parameter-class.yaml metview-5.19.2/mir/etc/mir/parameter-class.yaml --- metview-5.17.4/mir/etc/mir/parameter-class.yaml 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/etc/mir/parameter-class.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -530,6 +530,7 @@ - 228246 # 100 metre U wind component - 230180 # East-West surface stress (variable resolution) - 230195 # Longitudinal component of gravity wave stress (variable resolution) +- 233000 # Time-integrated total column vertically-integrated eastward geopotential flux - 235041 # Mean eastward turbulent surface stress - 235045 # Mean eastward gravity wave surface stress - 260062 # Momentum flux, u component @@ -625,6 +626,7 @@ - 228247 # 100 metre V wind component - 230181 # North-South surface stress (variable resolution) - 230196 # Meridional component of gravity wave stress (variable resolution) +- 233001 # Time-integrated total column vertically-integrated northward geopotential flux - 235042 # Mean northward turbulent surface stress - 235046 # Mean northward gravity wave surface stress - 260063 # Momentum flux, v component @@ -887,8 +889,6 @@ - 3096 # V-component of ice drift - 3098 # Ice divergence - 3100 # Signific.height,combined wind waves+swell -- 3102 # Significant height of wind waves -- 3103 # Mean period of wind waves - 3105 # Significant height of swell waves - 3106 # Mean period of swell waves - 3108 # Primary wave mean period @@ -1684,6 +1684,10 @@ - 230082 # Accumulated Carbon Dioxide Ecosystem Respiration (variable resolution) - 230189 # Sunshine duration (variable resolution) - 230198 # Skin reservoir content (variable resolution) +- 231008 # Forecast logarithm of surface roughness length for moisture +- 232004 # Fuel load +- 233002 # Time-integrated total column vertically-integrated divergence of water geopotential flux +- 233003 # Time-integrated total column vertically-integrated divergence of geopotential flux - 235001 # Mean temperature tendency due to short-wave radiation - 235002 # Mean temperature tendency due to long-wave radiation - 235003 # Mean temperature tendency due to short-wave radiation, clear sky @@ -1715,7 +1719,6 @@ - 260071 # V-component storm motion - 260073 # Frictional velocity - 260074 # Pressure reduced to MSL -- 260075 # Geometric height - 260076 # Altimeter setting - 260077 # Thickness - 260078 # Pressure altitude @@ -1723,7 +1726,6 @@ - 260080 # 5-wave geopotential height - 260081 # Zonal flux of gravity wave stress - 260082 # Meridional flux of gravity wave stress -- 260083 # Planetary boundary layer height - 260084 # 5-wave geopotential height anomaly - 260085 # Standard deviation of sub-grid scale orography - 260101 # Cloud Ice @@ -1911,6 +1913,7 @@ - 261020 # Physiological equivalent temperature - 261021 # Saturation water vapor pressure - 261022 # Wet-bulb potential temperature +- 262143 # Sea surface height with inverse barometer correction - 300001 # Pressure - 300002 # Pressure reduced to msl - 300003 # Pressure tendency @@ -2128,6 +2131,9 @@ - 260472 # Time-mean snow depth water equivalent - 260473 # Time-mean skin temperature - 260477 # Time-mean snow melt rate in the last 24h +- 435001 # mean net ecosystem exchange flux +- 436001 # mean gross primary production flux  +- 437001 # mean ecosystem respiration flux numerics.accumulated: - 8 # Surface runoff @@ -2453,6 +2459,7 @@ - 228101 # Evaporation from bare soil - 228102 # Evaporation from open water surfaces excluding oceans - 228103 # Evaporation from vegetation transpiration +- 228109 # Accumulated mass emission of methane from Wetlands - 228129 # Surface solar radiation downward clear-sky - 228130 # Surface thermal radiation downward clear-sky - 228141 # Snow depth water equivalent @@ -2506,6 +2513,16 @@ - 230239 # Convective snowfall (variable resolution) - 230240 # Large-scale snowfall (variable resolution) - 230251 # Potential evaporation (variable resolution) +- 231001 # Accumulated freezing rain water equivalent +- 231002 # Runoff water equivalent +- 231003 # Snow evaporation water equivalent +- 231005 # Potential evaporation +- 231010 # Surface runoff +- 231012 # Sub-surface runoff +- 233000 # Time-integrated total column vertically-integrated eastward geopotential flux +- 233001 # Time-integrated total column vertically-integrated northward geopotential flux +- 233002 # Time-integrated total column vertically-integrated divergence of water geopotential flux +- 233003 # Time-integrated total column vertically-integrated divergence of geopotential flux - 235015 # Time integral of rain flux - 235017 # Time integral of surface eastward momentum flux - 235018 # Time integral of surface northward momentum flux @@ -2553,6 +2570,9 @@ - 260645 # Time integral of total solid precipitation flux - 300065 # Wat equiv acc snow depth - 300177 # Potential sfc evaporation +- 435002 # Accumulated net ecosystem exchange flux +- 436002 # Accumulated gross primary production flux  +- 437002 # Accumulated ecosystem respiration flux numerics.vertical-integral: - 78 # Total column cloud liquid water @@ -2939,6 +2959,10 @@ - 228088 # Total column supercooled liquid water - 228089 # Total column rain water - 228090 # Total column snow water +- 233000 # Time-integrated total column vertically-integrated eastward geopotential flux +- 233001 # Time-integrated total column vertically-integrated northward geopotential flux +- 233002 # Time-integrated total column vertically-integrated divergence of water geopotential flux +- 233003 # Time-integrated total column vertically-integrated divergence of geopotential flux - 235054 # Mean vertically integrated moisture divergence - 260001 # Total column graupel - 260041 # Total column integrated rain @@ -3270,6 +3294,8 @@ - 230210 # Surface net solar radiation, clear sky (variable resolution) - 230211 # Surface net thermal radiation, clear sky (variable resolution) - 230212 # TOA incident solar radiation (variable resolution) +- 233000 # Time-integrated total column vertically-integrated eastward geopotential flux +- 233001 # Time-integrated total column vertically-integrated northward geopotential flux - 235019 # Time integral of surface latent heat evaporation flux - 235022 # Mean surface photosynthetically active radiation flux, clear sky - 235027 # Mean surface downward UV radiation flux @@ -3297,7 +3323,6 @@ - 235069 # Mean surface downward long-wave radiation flux, clear sky - 235071 # Time integral of surface latent heat sublimation flux - 260002 # Latent heat net flux -- 260003 # Sensible heat net flux - 260007 # Snow phase change heat flux - 260037 # Potential evaporation rate - 260086 # Net short-wave radiation flux (top of atmosphere) @@ -3987,6 +4012,7 @@ - 228102 # Evaporation from open water surfaces excluding oceans - 228103 # Evaporation from vegetation transpiration - 228104 # Atmosphere emission mass flux of Methane from Wetlands +- 228109 # Accumulated mass emission of methane from Wetlands - 228141 # Snow depth water equivalent - 228143 # Convective precipitation - 228144 # Snow Fall water equivalent @@ -3995,6 +4021,15 @@ - 230044 # Snow evaporation (variable resolution) - 230045 # Snowmelt (variable resolution) - 230182 # Evaporation (variable resolution) +- 231001 # Accumulated freezing rain water equivalent +- 231002 # Runoff water equivalent +- 231003 # Snow evaporation water equivalent +- 231004 # Potential evaporation rate +- 231005 # Potential evaporation +- 231009 # Surface runoff rate +- 231010 # Surface runoff +- 231011 # Sub-surface runoff rate +- 231012 # Sub-surface runoff - 235009 # Mean updraught mass flux - 235010 # Mean downdraught mass flux - 235013 # Mean total precipitation flux @@ -4052,7 +4087,6 @@ - 260188 # Exchange coefficient - 260218 # Estimated precipitation - 260219 # Instantaneous rain rate -- 260258 # Evaporation rate - 260259 # Evaporation - 260284 # Liquid precipitation (rainfall) - 260286 # Total precipitation (nearest grid point) @@ -4087,6 +4121,15 @@ - 300065 # Wat equiv acc snow depth - 300169 # Vert. integrated moisture flux conv. - 300178 # Runoff +- 435000 # Net ecosystem exchange flux +- 435001 # Mean net ecosystem exchange flux +- 435002 # Accumulated net ecosystem exchange flux +- 436000 # Gross primary production flux  +- 436001 # Mean gross primary production flux  +- 436002 # Accumulated gross primary production flux  +- 437000 # Ecosystem respiration flux +- 437001 # Mean ecosystem respiration flux +- 437002 # Accumulated ecosystem respiration flux rate.volume-flux: - 8 # Surface runoff @@ -4401,6 +4444,16 @@ - 162229 # Variance of relative humidity - 171157 # Relative humidity anomaly - 200157 # Relative humidity difference +- 210198 # UV visible albedo for diffuse radiation (climatological) +- 210199 # UV visible albedo for direct radiation (climatological) +- 210200 # UV visible albedo for direct radiation, geometric component (climatological) +- 210201 # UV visible albedo for direct radiation, isotropic component (climatological) +- 210202 # UV visible albedo for direct radiation, volumetric component (climatological) +- 210260 # Near IR albedo for diffuse radiation (climatological) +- 210261 # Near IR albedo for direct radiation (climatological) +- 210262 # Near IR albedo for direct radiation, geometric component (climatological) +- 210263 # Near IR albedo for direct radiation, isotropic component (climatological) +- 210264 # Near IR albedo for direct radiation, volumetric component (climatological) - 228012 # Lake shape factor - 228030 # Relative humidity with respect to water - 228031 # Relative humidity with respect to ice @@ -4408,6 +4461,7 @@ - 228041 # Soil wetness index in layer 2 - 228042 # Soil wetness index in layer 3 - 228043 # Soil wetness index in layer 4 +- 231013 # Reflectance in 0.4 micron channel - 260023 # Maximum relative humidity - 260034 # Horizontal moisture divergence - 260112 # Convective cloud efficiency @@ -4461,7 +4515,6 @@ - 200026 # Lake cover difference - 200031 # Sea-ice cover difference - 260038 # Snow cover -- 260179 # Land cover (1=land, 0=sea) - 260459 # Land-sea coverage (nearest neighbor) [land=1,sea=0] ratio.cover.cloud: @@ -4636,7 +4689,6 @@ - 215149 # Single scattering albedo at 1640 nm - 215178 # Single scattering albedo at 2130 nm - 228032 # Snow albedo -- 228033 # Fraction of stratiform precipitation cover - 228034 # Fraction of convective precipitation cover - 228091 # Canopy cover fraction - 228092 # Soil texture fraction @@ -4647,6 +4699,13 @@ - 228255 # Surface long wave-effective total cloudiness - 230050 # Large-scale precipitation fraction (variable resolution) - 230174 # Albedo (variable resolution) +- 231006 # Tile fraction +- 231007 # Tile percentage +- 232000 # Burned area +- 232001 # Burning area +- 232002 # Burnable area +- 232003 # Un-burnable area +- 232005 # Combustion completeness - 235026 # Mean large-scale precipitation fraction - 235044 # Sunshine duration fraction - 240016 # Water fraction @@ -4797,7 +4856,7 @@ - 210170 # Volcanic sulfur dioxide mass mixing ratio - 210181 # Radon - 210182 # Sulphur Hexafluoride -- 210203 # GEMS Ozone +- 210203 # Ozone mass mixing ratio (full chemistry scheme) - 210247 # Nitrate fine mode aerosol mass mixing ratio - 210248 # Nitrate coarse mode aerosol mass mixing ratio - 210249 # Ammonium aerosol mass mixing ratio @@ -5066,6 +5125,7 @@ - 228054 # Unbalanced component of specific humidity - 228055 # Unbalanced component of specific cloud liquid water content - 228056 # Unbalanced component of specific cloud ice water content +- 232006 # Fuel moisture content - 235006 # Mean specific humidity tendency due to parametrisations - 260017 # Condensate - 260018 # Cloud mixing ratio @@ -5341,6 +5401,77 @@ - 213148 # Random pattern 48 for SPP scheme - 213149 # Random pattern 49 for SPP scheme - 213150 # Random pattern 50 for SPP scheme +- 213151 # Random pattern 51 for SPP scheme +- 213152 # Random pattern 52 for SPP scheme +- 213153 # Random pattern 53 for SPP scheme +- 213154 # Random pattern 54 for SPP scheme +- 213155 # Random pattern 55 for SPP scheme +- 213156 # Random pattern 56 for SPP scheme +- 213157 # Random pattern 57 for SPP scheme +- 213158 # Random pattern 58 for SPP scheme +- 213159 # Random pattern 59 for SPP scheme +- 213160 # Random pattern 60 for SPP scheme +- 213161 # Random pattern 61 for SPP scheme +- 213162 # Random pattern 62 for SPP scheme +- 213163 # Random pattern 63 for SPP scheme +- 213164 # Random pattern 64 for SPP scheme +- 213165 # Random pattern 65 for SPP scheme +- 213166 # Random pattern 66 for SPP scheme +- 213167 # Random pattern 67 for SPP scheme +- 213168 # Random pattern 68 for SPP scheme +- 213169 # Random pattern 69 for SPP scheme +- 213170 # Random pattern 70 for SPP scheme +- 213171 # Random pattern 71 for SPP scheme +- 213172 # Random pattern 72 for SPP scheme +- 213173 # Random pattern 73 for SPP scheme +- 213174 # Random pattern 74 for SPP scheme +- 213175 # Random pattern 75 for SPP scheme +- 213176 # Random pattern 76 for SPP scheme +- 213177 # Random pattern 77 for SPP scheme +- 213178 # Random pattern 78 for SPP scheme +- 213179 # Random pattern 79 for SPP scheme +- 213180 # Random pattern 80 for SPP scheme +- 213181 # Random pattern 81 for SPP scheme +- 213182 # Random pattern 82 for SPP scheme +- 213183 # Random pattern 83 for SPP scheme +- 213184 # Random pattern 84 for SPP scheme +- 213185 # Random pattern 85 for SPP scheme +- 213186 # Random pattern 86 for SPP scheme +- 213187 # Random pattern 87 for SPP scheme +- 213188 # Random pattern 88 for SPP scheme +- 213189 # Random pattern 89 for SPP scheme +- 213190 # Random pattern 90 for SPP scheme +- 213191 # Random pattern 91 for SPP scheme +- 213192 # Random pattern 92 for SPP scheme +- 213193 # Random pattern 93 for SPP scheme +- 213194 # Random pattern 94 for SPP scheme +- 213195 # Random pattern 95 for SPP scheme +- 213196 # Random pattern 96 for SPP scheme +- 213197 # Random pattern 97 for SPP scheme +- 213198 # Random pattern 98 for SPP scheme +- 213199 # Random pattern 99 for SPP scheme +- 213200 # Random pattern 100 for SPP scheme +- 213201 # Random pattern 101 for SPP scheme +- 213202 # Random pattern 102 for SPP scheme +- 213203 # Random pattern 103 for SPP scheme +- 213204 # Random pattern 104 for SPP scheme +- 213205 # Random pattern 105 for SPP scheme +- 213206 # Random pattern 106 for SPP scheme +- 213207 # Random pattern 107 for SPP scheme +- 213208 # Random pattern 108 for SPP scheme +- 213209 # Random pattern 109 for SPP scheme +- 213210 # Random pattern 110 for SPP scheme +- 213211 # Random pattern 111 for SPP scheme +- 213212 # Random pattern 112 for SPP scheme +- 213213 # Random pattern 113 for SPP scheme +- 213214 # Random pattern 114 for SPP scheme +- 213215 # Random pattern 115 for SPP scheme +- 213216 # Random pattern 116 for SPP scheme +- 213217 # Random pattern 117 for SPP scheme +- 213218 # Random pattern 118 for SPP scheme +- 213219 # Random pattern 119 for SPP scheme +- 213220 # Random pattern 120 for SPP scheme +- 213221 # Random pattern 121 for SPP scheme spectrum: - 3021 # Radar spectra (1) @@ -5453,6 +5584,10 @@ - 300193 # Surface zonal wind stress - 300195 # Surface meridional wind stress +tile-fraction: +- 231006 # Tile fraction +- 231007 # Tile percentage + orca.arrangement.f: - 250011 # lat_F (coordinate) FIXME - 250012 # lon_F (coordinate) FIXME diff -Nru metview-5.17.4/mir/.github/ci-config.yml metview-5.19.2/mir/.github/ci-config.yml --- metview-5.17.4/mir/.github/ci-config.yml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/.github/ci-config.yml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +dependencies: | + ecmwf/ecbuild + MathisRosenhauer/libaec@master + ecmwf/eccodes + ecmwf/eckit + ecmwf/atlas +dependency_branch: develop +parallelism_factor: 8 diff -Nru metview-5.17.4/mir/.github/ci-hpc-config.yml metview-5.19.2/mir/.github/ci-hpc-config.yml --- metview-5.17.4/mir/.github/ci-hpc-config.yml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/.github/ci-hpc-config.yml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +build: + modules: + - ninja + dependencies: + - ecmwf/ecbuild@develop + - ecmwf/eccodes@develop + - ecmwf/eckit@develop + - ecmwf/atlas@develop + parallel: 64 diff -Nru metview-5.17.4/mir/.github/workflows/ci.yml metview-5.19.2/mir/.github/workflows/ci.yml --- metview-5.17.4/mir/.github/workflows/ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/.github/workflows/ci.yml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,84 @@ +name: ci + +on: + # Trigger the workflow on push to master or develop, except tag creation + push: + branches: + - 'master' + - 'develop' + tags-ignore: + - '**' + + # Trigger the workflow on pull request + pull_request: ~ + + # Trigger the workflow manually + workflow_dispatch: ~ + + # Trigger after public PR approved for CI + pull_request_target: + types: [labeled] + +jobs: + # Run CI including downstream packages on self-hosted runners + downstream-ci: + name: downstream-ci + if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} + uses: ecmwf-actions/downstream-ci/.github/workflows/downstream-ci.yml@main + with: + mir: ecmwf/mir@${{ github.event.pull_request.head.sha || github.sha }} + secrets: inherit + + # Run CI of private downstream packages on self-hosted runners + private-downstream-ci: + name: private-downstream-ci + needs: [downstream-ci] + if: (success() || failure()) && ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Dispatch private downstream CI + uses: ecmwf-actions/dispatch-private-downstream-ci@v1 + with: + token: ${{ secrets.GH_REPO_READ_TOKEN }} + owner: ecmwf-actions + repository: private-downstream-ci + event_type: downstream-ci + payload: '{"mir": "ecmwf/mir@${{ github.event.pull_request.head.sha || github.sha }}"}' + + # Build downstream packages on HPC + downstream-ci-hpc: + name: downstream-ci-hpc + if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} + uses: ecmwf-actions/downstream-ci/.github/workflows/downstream-ci-hpc.yml@main + with: + mir: ecmwf/mir@${{ github.event.pull_request.head.sha || github.sha }} + secrets: inherit + + # Run CI of private downstream packages on HPC + private-downstream-ci-hpc: + name: private-downstream-ci-hpc + needs: [downstream-ci-hpc] + if: (success() || failure()) && ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Dispatch private downstream CI + uses: ecmwf-actions/dispatch-private-downstream-ci@v1 + with: + token: ${{ secrets.GH_REPO_READ_TOKEN }} + owner: ecmwf-actions + repository: private-downstream-ci + event_type: downstream-ci-hpc + payload: '{"mir": "ecmwf/mir@${{ github.event.pull_request.head.sha || github.sha }}"}' + + codecov: + name: code-coverage + if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }} + uses: ./.github/workflows/reusable-ci.yml + with: + mir: ecmwf/mir@${{ github.event.pull_request.head.sha || github.sha }} + codecov: true + secrets: inherit diff -Nru metview-5.17.4/mir/.github/workflows/reusable-ci-hpc.yml metview-5.19.2/mir/.github/workflows/reusable-ci-hpc.yml --- metview-5.17.4/mir/.github/workflows/reusable-ci-hpc.yml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/.github/workflows/reusable-ci-hpc.yml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,38 @@ +name: reusable-ci-hpc + +on: + workflow_call: + inputs: + mir: + required: false + type: string + eccodes: + required: false + type: string + eckit: + required: false + type: string + atlas: + required: false + type: string + ecbuild: + required: false + type: string + +jobs: + ci-hpc: + name: ci-hpc + uses: ecmwf-actions/reusable-workflows/.github/workflows/ci-hpc.yml@v2 + with: + name-prefix: mir- + build-inputs: | + --package: ${{ inputs.mir || 'ecmwf/mir@develop' }} + --modules: | + ninja + --dependencies: | + ${{ inputs.ecbuild || 'ecmwf/ecbuild@develop' }} + ${{ inputs.eccodes || 'ecmwf/eccodes@develop' }} + ${{ inputs.eckit || 'ecmwf/eckit@develop' }} + ${{ inputs.atlas || 'ecmwf/atlas@develop' }} + --parallel: 64 + secrets: inherit \ No newline at end of file diff -Nru metview-5.17.4/mir/.github/workflows/reusable-ci.yml metview-5.19.2/mir/.github/workflows/reusable-ci.yml --- metview-5.17.4/mir/.github/workflows/reusable-ci.yml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/.github/workflows/reusable-ci.yml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,44 @@ +name: reusable-ci + +on: + workflow_call: + inputs: + eccodes: + required: false + type: string + eckit: + required: false + type: string + atlas: + required: false + type: string + mir: + required: false + type: string + codecov: + required: false + type: boolean + default: false + +jobs: + ci: + name: ci + uses: ecmwf-actions/reusable-workflows/.github/workflows/ci.yml@v2 + with: + repository: ${{ inputs.mir || 'ecmwf/mir@develop' }} + name_prefix: mir- + codecov_upload: ${{ inputs.codecov }} + build_package_inputs: | + repository: ${{ inputs.mir || 'ecmwf/mir@develop' }} + self_coverage: true + dependencies: | + ecmwf/ecbuild + MathisRosenhauer/libaec@master + ${{ inputs.eccodes || 'ecmwf/eccodes' }} + ${{ inputs.eckit || 'ecmwf/eckit' }} + ${{ inputs.atlas || 'ecmwf/atlas' }} + dependency_branch: develop + dependency_cmake_options: | + ${{ inputs.codecov && 'ecmwf/atlas: "-DENABLE_OMP=0"' || '' }} + parallelism_factor: 8 + secrets: inherit diff -Nru metview-5.17.4/mir/.github/workflows/sync.yml metview-5.19.2/mir/.github/workflows/sync.yml --- metview-5.17.4/mir/.github/workflows/sync.yml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/.github/workflows/sync.yml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,24 @@ +name: sync + +# Controls when the workflow will run +on: + # Trigger the workflow on all pushes + push: + branches: + - '**' + tags: + - '**' + + # Trigger the workflow when a branch or tag is deleted + delete: ~ + +jobs: + # Calls a reusable CI workflow to sync the current with a remote repository. + # It will correctly handle addition of any new and removal of existing Git objects. + sync: + name: sync + uses: ecmwf-actions/reusable-workflows/.github/workflows/sync.yml@v2 + secrets: + target_repository: mir/mir + target_username: ClonedDuck + target_token: ${{ secrets.BITBUCKET_PAT }} diff -Nru metview-5.17.4/mir/MIR-513.packingType=spectral_complex.001.test metview-5.19.2/mir/MIR-513.packingType=spectral_complex.001.test --- metview-5.17.4/mir/MIR-513.packingType=spectral_complex.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/MIR-513.packingType=spectral_complex.001.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none --packing=complex -# grib_get assertions -packingType=grid_complex -edition=2 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/MIR-513.packingType=spectral_complex.003.test metview-5.19.2/mir/MIR-513.packingType=spectral_complex.003.test --- metview-5.17.4/mir/MIR-513.packingType=spectral_complex.003.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/MIR-513.packingType=spectral_complex.003.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none --packing=ccsds -# grib_get assertions -packingType=grid_ccsds -edition=2 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/MIR-513.packingType=spectral_complex.007.test metview-5.19.2/mir/MIR-513.packingType=spectral_complex.007.test --- metview-5.17.4/mir/MIR-513.packingType=spectral_complex.007.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/MIR-513.packingType=spectral_complex.007.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none --packing=av -# grib_get assertions -packingType=grid_complex -edition=2 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/MIR-513.packingType=spectral_complex.009.test metview-5.19.2/mir/MIR-513.packingType=spectral_complex.009.test --- metview-5.17.4/mir/MIR-513.packingType=spectral_complex.009.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/MIR-513.packingType=spectral_complex.009.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib2 -# mir ---grid=1/1 --intgrid=none --packing=complex -# grib_get assertions -packingType=grid_complex -edition=2 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/MIR-513.packingType=spectral_simple.003.test metview-5.19.2/mir/MIR-513.packingType=spectral_simple.003.test --- metview-5.17.4/mir/MIR-513.packingType=spectral_simple.003.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/MIR-513.packingType=spectral_simple.003.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_simple.grib1 -# mir ---grid=1/1 --intgrid=none --packing=ccsds -# grib_get assertions -packingType=grid_ccsds -edition=2 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/src/mir/action/calc/FormulaAction.cc metview-5.19.2/mir/src/mir/action/calc/FormulaAction.cc --- metview-5.17.4/mir/src/mir/action/calc/FormulaAction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/calc/FormulaAction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { +namespace mir::action { FormulaAction::FormulaAction(const param::MIRParametrisation& parametrisation) : Action(parametrisation) { @@ -96,5 +95,4 @@ static const ActionBuilder __action("calc.formula"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/calc/FormulaAction.h metview-5.19.2/mir/src/mir/action/calc/FormulaAction.h --- metview-5.17.4/mir/src/mir/action/calc/FormulaAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/calc/FormulaAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,15 +18,12 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace util { +namespace mir::util { class Formula; -} -} // namespace mir +} // namespace mir::util -namespace mir { -namespace action { +namespace mir::action { class FormulaAction : public Action { @@ -105,5 +102,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/context/Context.cc metview-5.19.2/mir/src/mir/action/context/Context.cc --- metview-5.17.4/mir/src/mir/action/context/Context.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/context/Context.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace context { +namespace mir::context { namespace { @@ -55,10 +54,10 @@ Content() = default; virtual ~Content() = default; - Content(const Content&) = delete; - Content(Content&&) = delete; + Content(const Content&) = delete; + Content(Content&&) = delete; Content& operator=(const Content&) = delete; - Content& operator=(Content&&) = delete; + Content& operator=(Content&&) = delete; virtual data::MIRField& field() { std::ostringstream oss; @@ -188,7 +187,7 @@ void Context::field(data::MIRField& other) { - content_.reset(new FieldContent(other)); + content_ = std::make_unique(other); } @@ -202,7 +201,7 @@ if (!content_) { auto timer(statistics().gribDecodingTimer()); - content_.reset(new FieldContent(input_.field())); + content_ = std::make_unique(input_.field()); } return content_->field(); } @@ -216,7 +215,7 @@ void Context::extension(Extension* e) { - content_.reset(new ExtensionContent(e)); + content_ = std::make_unique(e); } @@ -230,7 +229,7 @@ void Context::scalar(double value) { util::lock_guard lock(mutex_); - content_.reset(new ScalarContent(value)); + content_ = std::make_unique(value); } @@ -267,7 +266,7 @@ Context Context::pop() { util::lock_guard lock(mutex_); - ASSERT(stack_.size()); + ASSERT(!stack_.empty()); Context ctx = stack_.back(); stack_.pop_back(); return ctx; @@ -284,5 +283,4 @@ } -} // namespace context -} // namespace mir +} // namespace mir::context diff -Nru metview-5.17.4/mir/src/mir/action/context/Context.h metview-5.19.2/mir/src/mir/action/context/Context.h --- metview-5.17.4/mir/src/mir/action/context/Context.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/context/Context.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,7 @@ } // namespace mir -namespace mir { -namespace context { +namespace mir::context { class Extension { public: @@ -159,5 +158,4 @@ }; -} // namespace context -} // namespace mir +} // namespace mir::context diff -Nru metview-5.17.4/mir/src/mir/action/filter/AddRandomFilter.cc metview-5.19.2/mir/src/mir/action/filter/AddRandomFilter.cc --- metview-5.17.4/mir/src/mir/action/filter/AddRandomFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/AddRandomFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace filter { +namespace mir::action::filter { AddRandomFilter::AddRandomFilter(const param::MIRParametrisation& param) : Action(param) { @@ -67,6 +65,4 @@ static const ActionBuilder __action("filter.add-random"); -} // namespace filter -} // namespace action -} // namespace mir +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/AddRandomFilter.h metview-5.19.2/mir/src/mir/action/filter/AddRandomFilter.h --- metview-5.17.4/mir/src/mir/action/filter/AddRandomFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/AddRandomFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,16 +17,12 @@ #include -namespace mir { -namespace stats { +namespace mir::stats { class Distribution; -} -} // namespace mir +} // namespace mir::stats -namespace mir { -namespace action { -namespace filter { +namespace mir::action::filter { class AddRandomFilter : public Action { @@ -107,6 +103,4 @@ }; -} // namespace filter -} // namespace action -} // namespace mir +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/AdjustWindsDirections.cc metview-5.19.2/mir/src/mir/action/filter/AdjustWindsDirections.cc --- metview-5.17.4/mir/src/mir/action/filter/AdjustWindsDirections.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/AdjustWindsDirections.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { +namespace mir::action { AdjustWindsDirections::AdjustWindsDirections(const param::MIRParametrisation& parametrisation) : @@ -77,5 +76,4 @@ static const ActionBuilder __action("filter.adjust-winds-directions"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/AdjustWindsDirections.h metview-5.19.2/mir/src/mir/action/filter/AdjustWindsDirections.h --- metview-5.17.4/mir/src/mir/action/filter/AdjustWindsDirections.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/AdjustWindsDirections.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace action { +namespace mir::action { class AdjustWindsDirections : public Action { @@ -93,5 +92,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/AdjustWindsScaleCosLatitude.cc metview-5.19.2/mir/src/mir/action/filter/AdjustWindsScaleCosLatitude.cc --- metview-5.17.4/mir/src/mir/action/filter/AdjustWindsScaleCosLatitude.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/AdjustWindsScaleCosLatitude.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { +namespace mir::action { AdjustWindsScaleCosLatitude::AdjustWindsScaleCosLatitude(const param::MIRParametrisation& parametrisation) : @@ -86,5 +85,4 @@ static const ActionBuilder __action("filter.adjust-winds-scale-cos-latitude"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/AdjustWindsScaleCosLatitude.h metview-5.19.2/mir/src/mir/action/filter/AdjustWindsScaleCosLatitude.h --- metview-5.17.4/mir/src/mir/action/filter/AdjustWindsScaleCosLatitude.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/AdjustWindsScaleCosLatitude.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class AdjustWindsScaleCosLatitude : public Action { @@ -92,5 +91,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/Bandpass.cc metview-5.19.2/mir/src/mir/action/filter/Bandpass.cc --- metview-5.17.4/mir/src/mir/action/filter/Bandpass.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/Bandpass.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,91 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include "mir/action/filter/Bandpass.h" + +#include + +#include "mir/action/context/Context.h" +#include "mir/api/MIREstimation.h" +#include "mir/data/MIRField.h" +#include "mir/param/MIRParametrisation.h" +#include "mir/repres/sh/SphericalHarmonics.h" +#include "mir/util/Exceptions.h" + + +namespace mir::action::filter { + + +Bandpass::Bandpass(const param::MIRParametrisation& param) : Action(param) { + ASSERT(param.get("truncation", truncation_)); + + std::vector b; + ASSERT(param.userParametrisation().get("bandpass", b) && b.size() == 4); + + minM_ = static_cast(b[0]); + maxM_ = static_cast(b[1]); + minN_ = static_cast(b[2]); + maxN_ = static_cast(b[3]); + ASSERT(minM_ <= maxM_ && maxM_ <= truncation_); + ASSERT(minN_ <= maxN_ && maxN_ <= truncation_); +} + + +bool Bandpass::sameAs(const Action& other) const { + const auto* o = dynamic_cast(&other); + return (o != nullptr) && minM_ == o->minM_ && maxM_ == o->maxM_ && minN_ == o->minN_ && maxN_ == o->maxN_; +} + + +void Bandpass::print(std::ostream& out) const { + out << "Bandpass[M=" << minM_ << "/" << maxM_ << ",N=" << minN_ << "/" << maxN_ << "]"; +} + + +void Bandpass::execute(context::Context& ctx) const { + const auto N = repres::sh::SphericalHarmonics::number_of_complex_coefficients(truncation_); + + auto& field = ctx.field(); + for (size_t i = 0; i < field.dimensions(); ++i) { + const auto& in = field.values(i); + ASSERT(in.size() == N * 2); + + MIRValuesVector out(in.size(), 0.); + + for (size_t m = 0, j = 0; m <= truncation_; m++) { + for (size_t n = m; n <= truncation_; n++, j += 2) { + if (minM_ <= m && m <= maxM_ && minN_ <= n && n <= maxN_) { + out[j] = in[j]; + out[j + 1] = in[j + 1]; + } + } + } + + field.update(out, i); + } +} + + +const char* Bandpass::name() const { + return "Bandpass"; +} + + +void Bandpass::estimate(context::Context& /*unused*/, api::MIREstimation& estimation) const { + estimation.sameAsInput(); +} + + +static const ActionBuilder __action("filter.sh-bandpass"); + + +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/Bandpass.h metview-5.19.2/mir/src/mir/action/filter/Bandpass.h --- metview-5.17.4/mir/src/mir/action/filter/Bandpass.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/Bandpass.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,87 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#pragma once + +#include "mir/action/plan/Action.h" + + +namespace mir::action::filter { + + +class Bandpass final : public Action { +public: + // -- Exceptions + // None + + // -- Constructors + + explicit Bandpass(const param::MIRParametrisation&); + Bandpass(const Bandpass&) = delete; + Bandpass(Bandpass&&) = delete; + + // -- Destructor + // None + + // -- Convertors + // None + + // -- Operators + + void operator=(const Bandpass&) = delete; + void operator=(Bandpass&&) = delete; + + // -- Methods + // None + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + // None + +private: + // -- Members + + size_t truncation_; + size_t minM_; + size_t maxM_; + size_t minN_; + size_t maxN_; + + // -- Methods + // None + + // -- Overridden methods + + void print(std::ostream&) const override; + + void execute(context::Context&) const override; + bool sameAs(const Action&) const override; + const char* name() const override; + void estimate(context::Context&, api::MIREstimation&) const override; + + // -- Class members + // None + + // -- Class methods + // None + + // -- Friends + // None +}; + + +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/BitmapFilter.cc metview-5.19.2/mir/src/mir/action/filter/BitmapFilter.cc --- metview-5.17.4/mir/src/mir/action/filter/BitmapFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/BitmapFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace action { +namespace mir::action { constexpr size_t CAPACITY = 256 * 1024 * 1024; @@ -142,5 +141,4 @@ static const ActionBuilder __action("filter.bitmap"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/CesaroSummationFilter.cc metview-5.19.2/mir/src/mir/action/filter/CesaroSummationFilter.cc --- metview-5.17.4/mir/src/mir/action/filter/CesaroSummationFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/CesaroSummationFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace filter { +namespace mir::action::filter { CesaroSummationFilter::CesaroSummationFilter(const param::MIRParametrisation& parametrisation) : @@ -99,6 +97,4 @@ static const ActionBuilder __action("filter.sh-cesaro-summation-filter"); -} // namespace filter -} // namespace action -} // namespace mir +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/CesaroSummationFilter.h metview-5.19.2/mir/src/mir/action/filter/CesaroSummationFilter.h --- metview-5.17.4/mir/src/mir/action/filter/CesaroSummationFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/CesaroSummationFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { -namespace filter { +namespace mir::action::filter { class CesaroSummationFilter : public Action { @@ -97,6 +95,4 @@ }; -} // namespace filter -} // namespace action -} // namespace mir +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/FrameFilter.cc metview-5.19.2/mir/src/mir/action/filter/FrameFilter.cc --- metview-5.17.4/mir/src/mir/action/filter/FrameFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/FrameFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { +namespace mir::action { FrameFilter::FrameFilter(const param::MIRParametrisation& parametrisation) : Action(parametrisation), size_(0) { @@ -88,5 +87,4 @@ static const ActionBuilder __action("filter.frame"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/FrameFilter.h metview-5.19.2/mir/src/mir/action/filter/FrameFilter.h --- metview-5.17.4/mir/src/mir/action/filter/FrameFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/FrameFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class FrameFilter : public Action { @@ -95,5 +94,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/GlobaliseFilter.cc metview-5.19.2/mir/src/mir/action/filter/GlobaliseFilter.cc --- metview-5.17.4/mir/src/mir/action/filter/GlobaliseFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/GlobaliseFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { +namespace mir::action { GlobaliseFilter::GlobaliseFilter(const param::MIRParametrisation& parametrisation) : Action(parametrisation) { @@ -73,5 +72,4 @@ static const ActionBuilder __action("filter.globalise"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/GlobaliseFilter.h metview-5.19.2/mir/src/mir/action/filter/GlobaliseFilter.h --- metview-5.17.4/mir/src/mir/action/filter/GlobaliseFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/GlobaliseFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class GlobaliseFilter : public Action { @@ -94,5 +93,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/NablaFilter.cc metview-5.19.2/mir/src/mir/action/filter/NablaFilter.cc --- metview-5.17.4/mir/src/mir/action/filter/NablaFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/NablaFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace action { +namespace mir::action { NablaFilter::NablaFilter(const param::MIRParametrisation& param) : Action(param), meshGeneratorParams_(param, "input") { @@ -74,5 +73,4 @@ } -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/NablaFilterFVMT.cc metview-5.19.2/mir/src/mir/action/filter/NablaFilterFVMT.cc --- metview-5.17.4/mir/src/mir/action/filter/NablaFilterFVMT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/NablaFilterFVMT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,8 +30,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace action { +namespace mir::action { struct NablaOperation { @@ -268,5 +267,4 @@ static const NablaFilterBuilder> __nabla5("uv-vorticity"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/NablaFilterFVMT.h metview-5.19.2/mir/src/mir/action/filter/NablaFilterFVMT.h --- metview-5.17.4/mir/src/mir/action/filter/NablaFilterFVMT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/NablaFilterFVMT.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/filter/NablaFilter.h" -namespace mir { -namespace action { +namespace mir::action { template @@ -91,5 +90,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/NablaFilter.h metview-5.19.2/mir/src/mir/action/filter/NablaFilter.h --- metview-5.17.4/mir/src/mir/action/filter/NablaFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/NablaFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/MeshGeneratorParameters.h" -namespace mir { -namespace action { +namespace mir::action { class NablaFilter : public Action { @@ -113,5 +112,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/ShTruncate.cc metview-5.19.2/mir/src/mir/action/filter/ShTruncate.cc --- metview-5.17.4/mir/src/mir/action/filter/ShTruncate.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/ShTruncate.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace filter { +namespace mir::action::filter { ShTruncate::ShTruncate(const param::MIRParametrisation& parametrisation) : Action(parametrisation), truncation_(0) { @@ -86,6 +84,4 @@ static const ActionBuilder __action("filter.sh-truncate"); -} // namespace filter -} // namespace action -} // namespace mir +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/ShTruncate.h metview-5.19.2/mir/src/mir/action/filter/ShTruncate.h --- metview-5.17.4/mir/src/mir/action/filter/ShTruncate.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/ShTruncate.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { -namespace filter { +namespace mir::action::filter { class ShTruncate : public Action { @@ -97,6 +95,4 @@ }; -} // namespace filter -} // namespace action -} // namespace mir +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/StatisticsFilter.cc metview-5.19.2/mir/src/mir/action/filter/StatisticsFilter.cc --- metview-5.17.4/mir/src/mir/action/filter/StatisticsFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/StatisticsFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace action { -namespace filter { +namespace mir::action::filter { StatisticsFilter::StatisticsFilter(const param::MIRParametrisation& param) : Action(param) { @@ -105,6 +103,4 @@ static const ActionBuilder __action("filter.statistics"); -} // namespace filter -} // namespace action -} // namespace mir +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/StatisticsFilter.h metview-5.19.2/mir/src/mir/action/filter/StatisticsFilter.h --- metview-5.17.4/mir/src/mir/action/filter/StatisticsFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/StatisticsFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,16 +18,12 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace stats { +namespace mir::stats { class Statistics; -} -} // namespace mir +} // namespace mir::stats -namespace mir { -namespace action { -namespace filter { +namespace mir::action::filter { class StatisticsFilter : public Action { @@ -109,6 +105,4 @@ }; -} // namespace filter -} // namespace action -} // namespace mir +} // namespace mir::action::filter diff -Nru metview-5.17.4/mir/src/mir/action/filter/UnstructuredFilter.cc metview-5.19.2/mir/src/mir/action/filter/UnstructuredFilter.cc --- metview-5.17.4/mir/src/mir/action/filter/UnstructuredFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/UnstructuredFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace action { +namespace mir::action { UnstructuredFilter::~UnstructuredFilter() = default; @@ -77,5 +76,4 @@ static const ActionBuilder __action("filter.unstructured"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/filter/UnstructuredFilter.h metview-5.19.2/mir/src/mir/action/filter/UnstructuredFilter.h --- metview-5.17.4/mir/src/mir/action/filter/UnstructuredFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/filter/UnstructuredFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class UnstructuredFilter : public Action { @@ -92,5 +91,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2GriddedInterpolation.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2GriddedInterpolation.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2GriddedInterpolation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2GriddedInterpolation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,9 +26,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2GriddedInterpolation::Gridded2GriddedInterpolation(const param::MIRParametrisation& param) : Action(param) { @@ -161,6 +159,4 @@ } -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2GriddedInterpolation.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2GriddedInterpolation.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2GriddedInterpolation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2GriddedInterpolation.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,9 +28,7 @@ } // namespace mir -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2GriddedInterpolation : public Action { @@ -115,6 +113,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2GridDef.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2GridDef.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2GridDef.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2GridDef.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2GridDef::Gridded2GridDef(const param::MIRParametrisation& parametrisation) : @@ -69,6 +67,4 @@ static const ActionBuilder grid2grid("interpolate.grid2griddef"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2GridDef.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2GridDef.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2GridDef.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2GridDef.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2GridDef : public Gridded2UnrotatedGrid { @@ -98,6 +96,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2NamedGrid.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2NamedGrid.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2NamedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2NamedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2NamedGrid::Gridded2NamedGrid(const param::MIRParametrisation& parametrisation) : @@ -60,6 +58,4 @@ static const ActionBuilder grid2grid("interpolate.grid2namedgrid"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2NamedGrid.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2NamedGrid.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2NamedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2NamedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2NamedGrid : public Gridded2UnrotatedGrid { @@ -97,6 +95,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2OctahedralGG.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2OctahedralGG.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2OctahedralGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2OctahedralGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2OctahedralGG::Gridded2OctahedralGG(const param::MIRParametrisation& parametrisation) : @@ -61,6 +59,4 @@ static const ActionBuilder grid2grid("interpolate.grid2octahedral-gg"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2OctahedralGG.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2OctahedralGG.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2OctahedralGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2OctahedralGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2OctahedralGG : public Gridded2UnrotatedGrid { @@ -97,6 +95,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2Points.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2Points.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2Points.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2Points.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2Points::Gridded2Points(const param::MIRParametrisation& parametrisation) : @@ -68,6 +66,4 @@ static const ActionBuilder grid2grid("interpolate.grid2points"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2Points.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2Points.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2Points.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2Points.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2Points : public Gridded2UnrotatedGrid { @@ -100,6 +98,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedGG.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedGG.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2ReducedGG::Gridded2ReducedGG(const param::MIRParametrisation& parametrisation) : @@ -61,6 +59,4 @@ static const ActionBuilder grid2grid("interpolate.grid2reduced-gg"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedGG.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedGG.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2ReducedGG : public Gridded2UnrotatedGrid { @@ -97,6 +95,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedGGPLGiven.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedGGPLGiven.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedGGPLGiven.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedGGPLGiven.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2ReducedGGPLGiven::Gridded2ReducedGGPLGiven(const param::MIRParametrisation& parametrisation) : @@ -62,6 +60,4 @@ static const ActionBuilder grid2grid("interpolate.grid2reduced-gg-pl-given"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedGGPLGiven.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedGGPLGiven.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedGGPLGiven.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedGGPLGiven.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2ReducedGGPLGiven : public Gridded2UnrotatedGrid { @@ -99,6 +97,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedLL.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedLL.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2ReducedLL::Gridded2ReducedLL(const param::MIRParametrisation& parametrisation) : @@ -54,6 +52,4 @@ static const ActionBuilder grid2grid("interpolate.grid2reduced-ll"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedLL.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedLL.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2ReducedLL : public Gridded2UnrotatedGrid { @@ -96,6 +94,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedLLPLGiven.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedLLPLGiven.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedLLPLGiven.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedLLPLGiven.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2ReducedLLPLGiven::Gridded2ReducedLLPLGiven(const param::MIRParametrisation& parametrisation) : @@ -54,6 +52,4 @@ static const ActionBuilder grid2grid("interpolate.grid2reduced-ll-pl-given"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedLLPLGiven.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedLLPLGiven.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2ReducedLLPLGiven.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2ReducedLLPLGiven.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2ReducedLLPLGiven : public Gridded2UnrotatedGrid { @@ -96,6 +94,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RegularGG.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RegularGG.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RegularGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RegularGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RegularGG::Gridded2RegularGG(const param::MIRParametrisation& parametrisation) : @@ -62,6 +60,4 @@ static const ActionBuilder grid2grid("interpolate.grid2regular-gg"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RegularGG.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RegularGG.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RegularGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RegularGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2UnrotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RegularGG : public Gridded2UnrotatedGrid { @@ -97,6 +95,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RegularLL.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RegularLL.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RegularLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RegularLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RegularLL::Gridded2RegularLL(const param::MIRParametrisation& parametrisation) : @@ -88,6 +86,4 @@ static const ActionBuilder grid2grid("interpolate.grid2regular-ll"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RegularLL.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RegularLL.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RegularLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RegularLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Increments.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RegularLL : public Gridded2UnrotatedGrid { @@ -101,6 +99,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedGrid.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedGrid.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RotatedGrid::Gridded2RotatedGrid(const param::MIRParametrisation& parametrisation) : @@ -61,6 +59,4 @@ } -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedGrid.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedGrid.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RotatedGrid : public Gridded2GriddedInterpolation { @@ -97,6 +95,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedLL.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedLL.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RotatedLL::Gridded2RotatedLL(const param::MIRParametrisation& parametrisation) : @@ -90,6 +88,4 @@ static const ActionBuilder grid2grid("interpolate.grid2rotated-regular-ll"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedLL.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedLL.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Increments.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RotatedLL : public Gridded2RotatedGrid { @@ -103,6 +101,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedNamedGrid.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedNamedGrid.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedNamedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedNamedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RotatedNamedGrid::Gridded2RotatedNamedGrid(const param::MIRParametrisation& parametrisation) : @@ -60,6 +58,4 @@ static const ActionBuilder grid2grid("interpolate.grid2rotated-namedgrid"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedNamedGrid.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedNamedGrid.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedNamedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedNamedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2RotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RotatedNamedGrid : public Gridded2RotatedGrid { @@ -99,6 +97,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedOctahedralGG.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedOctahedralGG.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedOctahedralGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedOctahedralGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RotatedOctahedralGG::Gridded2RotatedOctahedralGG(const param::MIRParametrisation& parametrisation) : @@ -65,6 +63,4 @@ static const ActionBuilder grid2grid("interpolate.grid2rotated-octahedral-gg"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedOctahedralGG.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedOctahedralGG.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedOctahedralGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedOctahedralGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2RotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RotatedOctahedralGG : public Gridded2RotatedGrid { @@ -99,6 +97,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedReducedGG.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedReducedGG.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedReducedGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedReducedGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RotatedReducedGG::Gridded2RotatedReducedGG(const param::MIRParametrisation& parametrisation) : @@ -65,6 +63,4 @@ static const ActionBuilder grid2grid("interpolate.grid2rotated-reduced-gg"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedReducedGG.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedReducedGG.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedReducedGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedReducedGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2RotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RotatedReducedGG : public Gridded2RotatedGrid { @@ -99,6 +97,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedReducedGGPLGiven.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedReducedGGPLGiven.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedReducedGGPLGiven.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedReducedGGPLGiven.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RotatedReducedGGPLGiven::Gridded2RotatedReducedGGPLGiven(const param::MIRParametrisation& parametrisation) : @@ -67,6 +65,4 @@ static const ActionBuilder grid2grid("interpolate.grid2rotated-reduced-gg-pl-given"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedReducedGGPLGiven.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedReducedGGPLGiven.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedReducedGGPLGiven.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedReducedGGPLGiven.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/action/interpolate/Gridded2RotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RotatedReducedGGPLGiven : public Gridded2RotatedGrid { @@ -101,6 +99,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedRegularGG.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedRegularGG.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedRegularGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedRegularGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2RotatedRegularGG::Gridded2RotatedRegularGG(const param::MIRParametrisation& parametrisation) : @@ -65,6 +63,4 @@ static const ActionBuilder grid2grid("interpolate.grid2rotated-regular-gg"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedRegularGG.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedRegularGG.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2RotatedRegularGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2RotatedRegularGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2RotatedGrid.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2RotatedRegularGG : public Gridded2RotatedGrid { @@ -99,6 +97,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2TypedGrid.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2TypedGrid.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2TypedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2TypedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2TypedGrid::Gridded2TypedGrid(const param::MIRParametrisation& parametrisation) : @@ -67,6 +65,4 @@ static const ActionBuilder grid2grid("interpolate.grid2typedgrid"); -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2TypedGrid.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2TypedGrid.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2TypedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2TypedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2TypedGrid : public Gridded2UnrotatedGrid { @@ -99,6 +97,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2UnrotatedGrid.cc metview-5.19.2/mir/src/mir/action/interpolate/Gridded2UnrotatedGrid.cc --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2UnrotatedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2UnrotatedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Domain.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { Gridded2UnrotatedGrid::~Gridded2UnrotatedGrid() = default; @@ -32,6 +30,4 @@ } -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/interpolate/Gridded2UnrotatedGrid.h metview-5.19.2/mir/src/mir/action/interpolate/Gridded2UnrotatedGrid.h --- metview-5.17.4/mir/src/mir/action/interpolate/Gridded2UnrotatedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/interpolate/Gridded2UnrotatedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/interpolate/Gridded2GriddedInterpolation.h" -namespace mir { -namespace action { -namespace interpolate { +namespace mir::action::interpolate { class Gridded2UnrotatedGrid : public Gridded2GriddedInterpolation { @@ -90,6 +88,4 @@ }; -} // namespace interpolate -} // namespace action -} // namespace mir +} // namespace mir::action::interpolate diff -Nru metview-5.17.4/mir/src/mir/action/io/Copy.cc metview-5.19.2/mir/src/mir/action/io/Copy.cc --- metview-5.17.4/mir/src/mir/action/io/Copy.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/io/Copy.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { -namespace io { +namespace mir::action::io { Copy::Copy(const param::MIRParametrisation& parametrisation, output::MIROutput& output) : @@ -60,6 +58,4 @@ } -} // namespace io -} // namespace action -} // namespace mir +} // namespace mir::action::io diff -Nru metview-5.17.4/mir/src/mir/action/io/Copy.h metview-5.19.2/mir/src/mir/action/io/Copy.h --- metview-5.17.4/mir/src/mir/action/io/Copy.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/io/Copy.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/io/EndAction.h" -namespace mir { -namespace action { -namespace io { +namespace mir::action::io { class Copy : public EndAction { @@ -98,6 +96,4 @@ }; -} // namespace io -} // namespace action -} // namespace mir +} // namespace mir::action::io diff -Nru metview-5.17.4/mir/src/mir/action/io/EndAction.cc metview-5.19.2/mir/src/mir/action/io/EndAction.cc --- metview-5.17.4/mir/src/mir/action/io/EndAction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/io/EndAction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/output/MIROutput.h" -namespace mir { -namespace action { -namespace io { +namespace mir::action::io { EndAction::EndAction(const param::MIRParametrisation& param, output::MIROutput& output) : @@ -59,6 +57,4 @@ } -} // namespace io -} // namespace action -} // namespace mir +} // namespace mir::action::io diff -Nru metview-5.17.4/mir/src/mir/action/io/EndAction.h metview-5.19.2/mir/src/mir/action/io/EndAction.h --- metview-5.17.4/mir/src/mir/action/io/EndAction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/io/EndAction.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,16 +15,12 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace output { +namespace mir::output { class MIROutput; -} -} // namespace mir +} // namespace mir::output -namespace mir { -namespace action { -namespace io { +namespace mir::action::io { class EndAction : public Action { @@ -105,6 +101,4 @@ }; -} // namespace io -} // namespace action -} // namespace mir +} // namespace mir::action::io diff -Nru metview-5.17.4/mir/src/mir/action/io/Save.cc metview-5.19.2/mir/src/mir/action/io/Save.cc --- metview-5.17.4/mir/src/mir/action/io/Save.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/io/Save.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { -namespace io { +namespace mir::action::io { Save::Save(const param::MIRParametrisation& parametrisation, output::MIROutput& output) : @@ -47,6 +45,4 @@ } -} // namespace io -} // namespace action -} // namespace mir +} // namespace mir::action::io diff -Nru metview-5.17.4/mir/src/mir/action/io/Save.h metview-5.19.2/mir/src/mir/action/io/Save.h --- metview-5.17.4/mir/src/mir/action/io/Save.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/io/Save.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/io/EndAction.h" -namespace mir { -namespace action { -namespace io { +namespace mir::action::io { class Save : public EndAction { @@ -94,6 +92,4 @@ }; -} // namespace io -} // namespace action -} // namespace mir +} // namespace mir::action::io diff -Nru metview-5.17.4/mir/src/mir/action/io/Set.cc metview-5.19.2/mir/src/mir/action/io/Set.cc --- metview-5.17.4/mir/src/mir/action/io/Set.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/io/Set.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { -namespace io { +namespace mir::action::io { Set::Set(const param::MIRParametrisation& parametrisation, output::MIROutput& output) : @@ -47,6 +45,4 @@ } -} // namespace io -} // namespace action -} // namespace mir +} // namespace mir::action::io diff -Nru metview-5.17.4/mir/src/mir/action/io/Set.h metview-5.19.2/mir/src/mir/action/io/Set.h --- metview-5.17.4/mir/src/mir/action/io/Set.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/io/Set.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/io/EndAction.h" -namespace mir { -namespace action { -namespace io { +namespace mir::action::io { class Set : public EndAction { @@ -94,6 +92,4 @@ }; -} // namespace io -} // namespace action -} // namespace mir +} // namespace mir::action::io diff -Nru metview-5.17.4/mir/src/mir/action/misc/AreaCropper.cc metview-5.19.2/mir/src/mir/action/misc/AreaCropper.cc --- metview-5.17.4/mir/src/mir/action/misc/AreaCropper.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/AreaCropper.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,8 +33,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace action { +namespace mir::action { constexpr size_t CAPACITY = 256 * 1024 * 1024; @@ -57,18 +56,9 @@ }; -AreaCropper::AreaCropper(const param::MIRParametrisation& parametrisation) : Action(parametrisation), caching_(true) { +AreaCropper::AreaCropper(const param::MIRParametrisation& parametrisation) : + Action(parametrisation), caching_(LibMir::caching()) { ASSERT(key::Area::get(parametrisation_.userParametrisation(), bbox_)); - - caching_ = LibMir::caching(); - parametrisation_.get("caching", caching_); -} - - -AreaCropper::AreaCropper(const param::MIRParametrisation& parametrisation, const util::BoundingBox& bbox) : - Action(parametrisation), bbox_(bbox), caching_(true) { - - caching_ = LibMir::caching(); parametrisation_.get("caching", caching_); } @@ -201,10 +191,10 @@ representation_(representation), bbox_(bbox) {} ~CroppingCacheCreator() override = default; - CroppingCacheCreator(const CroppingCacheCreator&) = delete; - CroppingCacheCreator(CroppingCacheCreator&&) = delete; + CroppingCacheCreator(const CroppingCacheCreator&) = delete; + CroppingCacheCreator(CroppingCacheCreator&&) = delete; CroppingCacheCreator& operator=(const CroppingCacheCreator&) = delete; - CroppingCacheCreator& operator=(CroppingCacheCreator&&) = delete; + CroppingCacheCreator& operator=(CroppingCacheCreator&&) = delete; }; CroppingCacheCreator creator(representation, bbox); @@ -311,5 +301,4 @@ static const ActionBuilder __action("crop.area"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/AreaCropper.h metview-5.19.2/mir/src/mir/action/misc/AreaCropper.h --- metview-5.17.4/mir/src/mir/action/misc/AreaCropper.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/AreaCropper.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,15 +17,12 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace repres { +namespace mir::repres { class Representation; -} // namespace repres -} // namespace mir +} // namespace mir::repres -namespace mir { -namespace action { +namespace mir::action { class AreaCropper : public Action { @@ -35,8 +32,7 @@ // -- Constructors - AreaCropper(const param::MIRParametrisation&); - AreaCropper(const param::MIRParametrisation&, const util::BoundingBox&); + explicit AreaCropper(const param::MIRParametrisation&); // -- Destructor @@ -108,5 +104,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/CheckerBoard.cc metview-5.19.2/mir/src/mir/action/misc/CheckerBoard.cc --- metview-5.17.4/mir/src/mir/action/misc/CheckerBoard.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/CheckerBoard.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { +namespace mir::action { CheckerBoard::CheckerBoard(const param::MIRParametrisation& parametrisation) : Action(parametrisation) {} @@ -134,5 +133,4 @@ static const ActionBuilder __action("misc.checkerboard"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/CheckerBoard.h metview-5.19.2/mir/src/mir/action/misc/CheckerBoard.h --- metview-5.17.4/mir/src/mir/action/misc/CheckerBoard.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/CheckerBoard.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class CheckerBoard : public Action { @@ -94,5 +93,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/Noop.cc metview-5.19.2/mir/src/mir/action/misc/Noop.cc --- metview-5.17.4/mir/src/mir/action/misc/Noop.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/Noop.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace action { +namespace mir::action { Noop::Noop(const param::MIRParametrisation& parametrisation) : Action(parametrisation) {} @@ -47,5 +46,4 @@ static const ActionBuilder __action("noop"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/Noop.h metview-5.19.2/mir/src/mir/action/misc/Noop.h --- metview-5.17.4/mir/src/mir/action/misc/Noop.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/Noop.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class Noop : public Action { @@ -94,5 +93,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/ReferencePattern.cc metview-5.19.2/mir/src/mir/action/misc/ReferencePattern.cc --- metview-5.17.4/mir/src/mir/action/misc/ReferencePattern.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/ReferencePattern.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { +namespace mir::action { ReferencePattern::ReferencePattern(const param::MIRParametrisation& parametrisation) : Action(parametrisation) {} @@ -120,5 +119,4 @@ static const ActionBuilder __action("misc.pattern"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/ReferencePattern.h metview-5.19.2/mir/src/mir/action/misc/ReferencePattern.h --- metview-5.17.4/mir/src/mir/action/misc/ReferencePattern.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/ReferencePattern.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class ReferencePattern : public Action { @@ -94,5 +93,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/ResetMissingValues.cc metview-5.19.2/mir/src/mir/action/misc/ResetMissingValues.cc --- metview-5.17.4/mir/src/mir/action/misc/ResetMissingValues.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/ResetMissingValues.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace action { +namespace mir::action { void ResetMissingValues::execute(context::Context& ctx) const { @@ -95,5 +94,4 @@ static const ActionBuilder __action("misc.reset-missing-values"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/ResetMissingValues.h metview-5.19.2/mir/src/mir/action/misc/ResetMissingValues.h --- metview-5.17.4/mir/src/mir/action/misc/ResetMissingValues.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/ResetMissingValues.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class ResetMissingValues : public Action { @@ -91,5 +90,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/SelectField.cc metview-5.19.2/mir/src/mir/action/misc/SelectField.cc --- metview-5.17.4/mir/src/mir/action/misc/SelectField.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/SelectField.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { +namespace mir::action { SelectField::SelectField(const param::MIRParametrisation& parametrisation) : Action(parametrisation) { @@ -57,5 +56,4 @@ static const ActionBuilder __action("select.field"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/SelectField.h metview-5.19.2/mir/src/mir/action/misc/SelectField.h --- metview-5.17.4/mir/src/mir/action/misc/SelectField.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/SelectField.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class SelectField : public Action { @@ -95,5 +94,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/SetMetadata.cc metview-5.19.2/mir/src/mir/action/misc/SetMetadata.cc --- metview-5.17.4/mir/src/mir/action/misc/SetMetadata.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/SetMetadata.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { +namespace mir::action { SetMetadata::SetMetadata(const param::MIRParametrisation& parametrisation) : Action(parametrisation) { @@ -80,5 +79,4 @@ static const ActionBuilder __action("set.metadata"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/misc/SetMetadata.h metview-5.19.2/mir/src/mir/action/misc/SetMetadata.h --- metview-5.17.4/mir/src/mir/action/misc/SetMetadata.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/misc/SetMetadata.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace action { +namespace mir::action { class SetMetadata : public Action { @@ -97,5 +96,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/Action.cc metview-5.19.2/mir/src/mir/action/plan/Action.cc --- metview-5.17.4/mir/src/mir/action/plan/Action.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/Action.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace action { +namespace mir::action { Action::Action(const param::MIRParametrisation& parametrisation) : parametrisation_(parametrisation) {} @@ -211,5 +210,4 @@ } -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/ActionGraph.cc metview-5.19.2/mir/src/mir/action/plan/ActionGraph.cc --- metview-5.17.4/mir/src/mir/action/plan/ActionGraph.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/ActionGraph.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/api/MIRWatcher.h" -namespace mir { -namespace action { +namespace mir::action { ActionGraph::ActionGraph() = default; @@ -106,5 +105,4 @@ } -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/ActionGraph.h metview-5.19.2/mir/src/mir/action/plan/ActionGraph.h --- metview-5.17.4/mir/src/mir/action/plan/ActionGraph.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/ActionGraph.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,8 +33,7 @@ } // namespace mir -namespace mir { -namespace action { +namespace mir::action { class ActionGraph : protected std::vector { @@ -128,5 +127,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/Action.h metview-5.19.2/mir/src/mir/action/plan/Action.h --- metview-5.17.4/mir/src/mir/action/plan/Action.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/Action.h 2023-07-15 08:28:47.000000000 +0000 @@ -35,8 +35,7 @@ } // namespace mir -namespace mir { -namespace action { +namespace mir::action { class Action { @@ -140,7 +139,7 @@ virtual Action* make(const param::MIRParametrisation&) = 0; - ActionFactory(const ActionFactory&) = delete; + ActionFactory(const ActionFactory&) = delete; ActionFactory& operator=(const ActionFactory&) = delete; protected: @@ -164,5 +163,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/ActionNode.cc metview-5.19.2/mir/src/mir/action/plan/ActionNode.cc --- metview-5.17.4/mir/src/mir/action/plan/ActionNode.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/ActionNode.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace action { +namespace mir::action { ActionNode::ActionNode(const Action& action, api::MIRWatcher* watcher) : action_(action), watcher_(watcher) {} @@ -74,5 +73,4 @@ } -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/ActionNode.h metview-5.19.2/mir/src/mir/action/plan/ActionNode.h --- metview-5.17.4/mir/src/mir/action/plan/ActionNode.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/ActionNode.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ } // namespace mir -namespace mir { -namespace action { +namespace mir::action { class ActionNode { @@ -118,5 +117,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/ActionPlan.cc metview-5.19.2/mir/src/mir/action/plan/ActionPlan.cc --- metview-5.17.4/mir/src/mir/action/plan/ActionPlan.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/ActionPlan.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { +namespace mir::action { namespace { @@ -291,5 +290,4 @@ } -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/ActionPlan.h metview-5.19.2/mir/src/mir/action/plan/ActionPlan.h --- metview-5.17.4/mir/src/mir/action/plan/ActionPlan.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/ActionPlan.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,8 +32,7 @@ } // namespace mir -namespace mir { -namespace action { +namespace mir::action { class ActionPlan : protected std::vector { @@ -153,5 +152,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/Executor.cc metview-5.19.2/mir/src/mir/action/plan/Executor.cc --- metview-5.17.4/mir/src/mir/action/plan/Executor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/Executor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace action { +namespace mir::action { static util::recursive_mutex* local_mutex = nullptr; @@ -89,5 +88,4 @@ } -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/Executor.h metview-5.19.2/mir/src/mir/action/plan/Executor.h --- metview-5.17.4/mir/src/mir/action/plan/Executor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/Executor.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,8 +29,7 @@ } // namespace mir -namespace mir { -namespace action { +namespace mir::action { class Executor { public: // -- Exceptions @@ -113,5 +112,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/Job.cc metview-5.19.2/mir/src/mir/action/plan/Job.cc --- metview-5.17.4/mir/src/mir/action/plan/Job.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/Job.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace action { +namespace mir::action { Job::Job(const api::MIRJob& job, input::MIRInput& input, output::MIROutput& output, bool compress) : @@ -37,8 +36,8 @@ static param::DefaultParametrisation defaults; const param::MIRParametrisation& metadata = input.parametrisation(); - combined_.reset(new param::CombinedParametrisation(job, metadata, defaults)); - plan_.reset(new ActionPlan(*combined_)); + combined_ = std::make_unique(job, metadata, defaults); + plan_ = std::make_unique(*combined_); // skip preparing an Action plan if nothing to do, or input is already what was specified @@ -93,5 +92,4 @@ } -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/Job.h metview-5.19.2/mir/src/mir/action/plan/Job.h --- metview-5.17.4/mir/src/mir/action/plan/Job.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/Job.h 2023-07-15 08:28:47.000000000 +0000 @@ -38,8 +38,7 @@ } // namespace mir -namespace mir { -namespace action { +namespace mir::action { class Job { @@ -120,5 +119,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/SimpleExecutor.cc metview-5.19.2/mir/src/mir/action/plan/SimpleExecutor.cc --- metview-5.17.4/mir/src/mir/action/plan/SimpleExecutor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/SimpleExecutor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/action/plan/ActionNode.h" -namespace mir { -namespace action { +namespace mir::action { SimpleExecutor::SimpleExecutor(const std::string& name) : Executor(name) {} @@ -43,5 +42,4 @@ static const SimpleExecutor executor("simple"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/SimpleExecutor.h metview-5.19.2/mir/src/mir/action/plan/SimpleExecutor.h --- metview-5.17.4/mir/src/mir/action/plan/SimpleExecutor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/SimpleExecutor.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/action/plan/Executor.h" -namespace mir { -namespace action { +namespace mir::action { class SimpleExecutor : public Executor { @@ -94,5 +93,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/ThreadExecutor.cc metview-5.19.2/mir/src/mir/action/plan/ThreadExecutor.cc --- metview-5.17.4/mir/src/mir/action/plan/ThreadExecutor.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/ThreadExecutor.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace action { +namespace mir::action { static util::once_flag once; @@ -48,10 +47,10 @@ owner_(owner), ctx_(ctx), node_(node) {} ~ThreadExecutorTask() override = default; - ThreadExecutorTask(const ThreadExecutorTask&) = delete; - ThreadExecutorTask(ThreadExecutorTask&&) = delete; + ThreadExecutorTask(const ThreadExecutorTask&) = delete; + ThreadExecutorTask(ThreadExecutorTask&&) = delete; ThreadExecutorTask& operator=(const ThreadExecutorTask&) = delete; - ThreadExecutorTask& operator=(ThreadExecutorTask&&) = delete; + ThreadExecutorTask& operator=(ThreadExecutorTask&&) = delete; }; @@ -87,5 +86,4 @@ static const ThreadExecutor executor("thread"); -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/plan/ThreadExecutor.h metview-5.19.2/mir/src/mir/action/plan/ThreadExecutor.h --- metview-5.17.4/mir/src/mir/action/plan/ThreadExecutor.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/plan/ThreadExecutor.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/action/plan/Executor.h" -namespace mir { -namespace action { +namespace mir::action { class ThreadExecutor : public Executor { @@ -94,5 +93,4 @@ }; -} // namespace action -} // namespace mir +} // namespace mir::action diff -Nru metview-5.17.4/mir/src/mir/action/transform/InvtransScalar.cc metview-5.19.2/mir/src/mir/action/transform/InvtransScalar.cc --- metview-5.17.4/mir/src/mir/action/transform/InvtransScalar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/InvtransScalar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { void InvtransScalar::print(std::ostream& out) const { @@ -105,6 +103,4 @@ } -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/InvtransScalar.h metview-5.19.2/mir/src/mir/action/transform/InvtransScalar.h --- metview-5.17.4/mir/src/mir/action/transform/InvtransScalar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/InvtransScalar.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { class InvtransScalar { @@ -88,6 +86,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/InvtransVodTouv.cc metview-5.19.2/mir/src/mir/action/transform/InvtransVodTouv.cc --- metview-5.17.4/mir/src/mir/action/transform/InvtransVodTouv.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/InvtransVodTouv.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,7 @@ #include "mir/util/Wind.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { void InvtransVodTouv::print(std::ostream& out) const { @@ -124,6 +122,4 @@ } -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/InvtransVodTouv.h metview-5.19.2/mir/src/mir/action/transform/InvtransVodTouv.h --- metview-5.17.4/mir/src/mir/action/transform/InvtransVodTouv.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/InvtransVodTouv.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { class InvtransVodTouv { @@ -88,6 +86,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToGridded.cc metview-5.19.2/mir/src/mir/action/transform/ShToGridded.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToGridded.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToGridded.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,9 +36,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { constexpr size_t CAPACITY_MEMORY = 8L * 1024 * 1024 * 1024; @@ -88,10 +86,10 @@ creator_(creator), ctx_(ctx) {} ~LegendreCacheCreator() override = default; - LegendreCacheCreator(const LegendreCacheCreator&) = delete; - LegendreCacheCreator(LegendreCacheCreator&&) = delete; + LegendreCacheCreator(const LegendreCacheCreator&) = delete; + LegendreCacheCreator(LegendreCacheCreator&&) = delete; LegendreCacheCreator& operator=(const LegendreCacheCreator&) = delete; - LegendreCacheCreator& operator=(LegendreCacheCreator&&) = delete; + LegendreCacheCreator& operator=(LegendreCacheCreator&&) = delete; }; static caching::LegendreCache cache; @@ -333,6 +331,4 @@ } -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToGridded.h metview-5.19.2/mir/src/mir/action/transform/ShToGridded.h --- metview-5.17.4/mir/src/mir/action/transform/ShToGridded.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToGridded.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,9 +28,7 @@ } // namespace mir -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { class ShToGridded : public Action { @@ -119,6 +117,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToGridDef.cc metview-5.19.2/mir/src/mir/action/transform/ShToGridDef.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToGridDef.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToGridDef.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -76,6 +74,4 @@ static const ActionBuilder > __action2("transform.sh-vod-to-uv-griddef"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToGridDef.h metview-5.19.2/mir/src/mir/action/transform/ShToGridDef.h --- metview-5.17.4/mir/src/mir/action/transform/ShToGridDef.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToGridDef.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -82,6 +80,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToNamedGrid.cc metview-5.19.2/mir/src/mir/action/transform/ShToNamedGrid.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToNamedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToNamedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -78,6 +76,4 @@ static const ActionBuilder > __action2("transform.sh-vod-to-uv-namedgrid"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToNamedGrid.h metview-5.19.2/mir/src/mir/action/transform/ShToNamedGrid.h --- metview-5.17.4/mir/src/mir/action/transform/ShToNamedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToNamedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -79,6 +77,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToOctahedralGG.cc metview-5.19.2/mir/src/mir/action/transform/ShToOctahedralGG.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToOctahedralGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToOctahedralGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -77,6 +75,4 @@ static const ActionBuilder > __action2("transform.sh-vod-to-uv-octahedral-gg"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToOctahedralGG.h metview-5.19.2/mir/src/mir/action/transform/ShToOctahedralGG.h --- metview-5.17.4/mir/src/mir/action/transform/ShToOctahedralGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToOctahedralGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -80,6 +78,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToPoints.cc metview-5.19.2/mir/src/mir/action/transform/ShToPoints.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToPoints.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToPoints.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -83,6 +81,4 @@ static const ActionBuilder > __action2("transform.sh-vod-to-uv-points"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToPoints.h metview-5.19.2/mir/src/mir/action/transform/ShToPoints.h --- metview-5.17.4/mir/src/mir/action/transform/ShToPoints.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToPoints.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -83,6 +81,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToReducedGG.cc metview-5.19.2/mir/src/mir/action/transform/ShToReducedGG.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToReducedGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToReducedGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -77,6 +75,4 @@ static const ActionBuilder > __action2("transform.sh-vod-to-uv-reduced-gg"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToReducedGG.h metview-5.19.2/mir/src/mir/action/transform/ShToReducedGG.h --- metview-5.17.4/mir/src/mir/action/transform/ShToReducedGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToReducedGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -79,6 +77,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToReducedGGPLGiven.cc metview-5.19.2/mir/src/mir/action/transform/ShToReducedGGPLGiven.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToReducedGGPLGiven.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToReducedGGPLGiven.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -80,6 +78,4 @@ "transform.sh-vod-to-uv-reduced-gg-pl-given"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToReducedGGPLGiven.h metview-5.19.2/mir/src/mir/action/transform/ShToReducedGGPLGiven.h --- metview-5.17.4/mir/src/mir/action/transform/ShToReducedGGPLGiven.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToReducedGGPLGiven.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -81,6 +79,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRegularGG.cc metview-5.19.2/mir/src/mir/action/transform/ShToRegularGG.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToRegularGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRegularGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -77,6 +75,4 @@ static const ActionBuilder > __action2("transform.sh-vod-to-uv-regular-gg"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRegularGG.h metview-5.19.2/mir/src/mir/action/transform/ShToRegularGG.h --- metview-5.17.4/mir/src/mir/action/transform/ShToRegularGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRegularGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -79,6 +77,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRegularLL.cc metview-5.19.2/mir/src/mir/action/transform/ShToRegularLL.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToRegularLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRegularLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -90,6 +88,4 @@ static const ActionBuilder > __action2("transform.sh-vod-to-uv-regular-ll"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRegularLL.h metview-5.19.2/mir/src/mir/action/transform/ShToRegularLL.h --- metview-5.17.4/mir/src/mir/action/transform/ShToRegularLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRegularLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Increments.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -82,6 +80,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedNamedGrid.cc metview-5.19.2/mir/src/mir/action/transform/ShToRotatedNamedGrid.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedNamedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedNamedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -85,6 +83,4 @@ "transform.sh-vod-to-uv-rotated-namedgrid"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedNamedGrid.h metview-5.19.2/mir/src/mir/action/transform/ShToRotatedNamedGrid.h --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedNamedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedNamedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -81,6 +79,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedOctahedralGG.cc metview-5.19.2/mir/src/mir/action/transform/ShToRotatedOctahedralGG.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedOctahedralGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedOctahedralGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -84,6 +82,4 @@ "transform.sh-vod-to-uv-rotated-octahedral-gg"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedOctahedralGG.h metview-5.19.2/mir/src/mir/action/transform/ShToRotatedOctahedralGG.h --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedOctahedralGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedOctahedralGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -82,6 +80,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedReducedGG.cc metview-5.19.2/mir/src/mir/action/transform/ShToRotatedReducedGG.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedReducedGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedReducedGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -84,6 +82,4 @@ "transform.sh-vod-to-uv-rotated-reduced-gg"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedReducedGG.h metview-5.19.2/mir/src/mir/action/transform/ShToRotatedReducedGG.h --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedReducedGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedReducedGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -81,6 +79,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedReducedGGPLGiven.cc metview-5.19.2/mir/src/mir/action/transform/ShToRotatedReducedGGPLGiven.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedReducedGGPLGiven.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedReducedGGPLGiven.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -85,6 +83,4 @@ "transform.sh-vod-to-uv-rotated-reduced-gg-pl-given"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedReducedGGPLGiven.h metview-5.19.2/mir/src/mir/action/transform/ShToRotatedReducedGGPLGiven.h --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedReducedGGPLGiven.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedReducedGGPLGiven.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -83,6 +81,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedRegularGG.cc metview-5.19.2/mir/src/mir/action/transform/ShToRotatedRegularGG.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedRegularGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedRegularGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -84,6 +82,4 @@ "transform.sh-vod-to-uv-rotated-regular-gg"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedRegularGG.h metview-5.19.2/mir/src/mir/action/transform/ShToRotatedRegularGG.h --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedRegularGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedRegularGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -81,6 +79,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedRegularLL.cc metview-5.19.2/mir/src/mir/action/transform/ShToRotatedRegularLL.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedRegularLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedRegularLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -97,6 +95,4 @@ "transform.sh-vod-to-uv-rotated-regular-ll"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToRotatedRegularLL.h metview-5.19.2/mir/src/mir/action/transform/ShToRotatedRegularLL.h --- metview-5.17.4/mir/src/mir/action/transform/ShToRotatedRegularLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToRotatedRegularLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -83,6 +81,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToTypedGrid.cc metview-5.19.2/mir/src/mir/action/transform/ShToTypedGrid.cc --- metview-5.17.4/mir/src/mir/action/transform/ShToTypedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToTypedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -78,6 +76,4 @@ static const ActionBuilder > __action2("transform.sh-vod-to-uv-typedgrid"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShToTypedGrid.h metview-5.19.2/mir/src/mir/action/transform/ShToTypedGrid.h --- metview-5.17.4/mir/src/mir/action/transform/ShToTypedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShToTypedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/action/transform/ShToGridded.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { template @@ -79,6 +77,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShVodToUV.cc metview-5.19.2/mir/src/mir/action/transform/ShVodToUV.cc --- metview-5.17.4/mir/src/mir/action/transform/ShVodToUV.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShVodToUV.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,7 @@ #include "mir/util/Wind.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { ShVodToUV::ShVodToUV(const param::MIRParametrisation& parametrisation) : Action(parametrisation) { @@ -127,6 +125,4 @@ static const ActionBuilder __action("transform.sh-vod-to-UV"); -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/ShVodToUV.h metview-5.19.2/mir/src/mir/action/transform/ShVodToUV.h --- metview-5.17.4/mir/src/mir/action/transform/ShVodToUV.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/ShVodToUV.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { class ShVodToUV : public Action { @@ -99,6 +97,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/TransCache.cc metview-5.19.2/mir/src/mir/action/transform/TransCache.cc --- metview-5.17.4/mir/src/mir/action/transform/TransCache.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/TransCache.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { TransCache::TransCache() : loader_(nullptr) {} @@ -48,6 +46,4 @@ } -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/action/transform/TransCache.h metview-5.19.2/mir/src/mir/action/transform/TransCache.h --- metview-5.17.4/mir/src/mir/action/transform/TransCache.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/action/transform/TransCache.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace action { -namespace transform { +namespace mir::action::transform { struct TransCache { @@ -49,6 +47,4 @@ }; -} // namespace transform -} // namespace action -} // namespace mir +} // namespace mir::action::transform diff -Nru metview-5.17.4/mir/src/mir/api/MIRComplexJob.cc metview-5.19.2/mir/src/mir/api/MIRComplexJob.cc --- metview-5.17.4/mir/src/mir/api/MIRComplexJob.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/api/MIRComplexJob.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace api { +namespace mir::api { MIRComplexJob::MIRComplexJob() : input_(nullptr) {} @@ -129,5 +128,4 @@ } -} // namespace api -} // namespace mir +} // namespace mir::api diff -Nru metview-5.17.4/mir/src/mir/api/MIREstimation.h metview-5.19.2/mir/src/mir/api/MIREstimation.h --- metview-5.17.4/mir/src/mir/api/MIREstimation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/api/MIREstimation.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include -namespace mir { -namespace api { +namespace mir::api { class MIREstimation { @@ -25,7 +24,7 @@ MIREstimation() = default; virtual ~MIREstimation() = default; - MIREstimation(const MIREstimation&) = delete; + MIREstimation(const MIREstimation&) = delete; MIREstimation& operator=(const MIREstimation&) = delete; virtual void numberOfGridPoints(size_t count) = 0; @@ -40,5 +39,4 @@ }; -} // namespace api -} // namespace mir +} // namespace mir::api diff -Nru metview-5.17.4/mir/src/mir/api/MIRJob.cc metview-5.19.2/mir/src/mir/api/MIRJob.cc --- metview-5.17.4/mir/src/mir/api/MIRJob.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/api/MIRJob.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace api { +namespace mir::api { MIRJob::MIRJob() = default; @@ -288,5 +287,4 @@ SimpleParametrisation::json(json); } -} // namespace api -} // namespace mir +} // namespace mir::api diff -Nru metview-5.17.4/mir/src/mir/api/MIRJob.h metview-5.19.2/mir/src/mir/api/MIRJob.h --- metview-5.17.4/mir/src/mir/api/MIRJob.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/api/MIRJob.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,8 +32,7 @@ } // namespace mir -namespace mir { -namespace api { +namespace mir::api { class MIREstimation; @@ -148,5 +147,4 @@ }; -} // namespace api -} // namespace mir +} // namespace mir::api diff -Nru metview-5.17.4/mir/src/mir/api/MIRWatcher.cc metview-5.19.2/mir/src/mir/api/MIRWatcher.cc --- metview-5.17.4/mir/src/mir/api/MIRWatcher.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/api/MIRWatcher.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,8 +13,7 @@ #include "mir/api/MIRWatcher.h" -namespace mir { -namespace api { +namespace mir::api { MIRWatcher::MIRWatcher() = default; @@ -23,5 +22,4 @@ MIRWatcher::~MIRWatcher() = default; -} // namespace api -} // namespace mir +} // namespace mir::api diff -Nru metview-5.17.4/mir/src/mir/api/MIRWatcher.h metview-5.19.2/mir/src/mir/api/MIRWatcher.h --- metview-5.17.4/mir/src/mir/api/MIRWatcher.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/api/MIRWatcher.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include -namespace mir { -namespace action { +namespace mir::action { class Action; -} -} // namespace mir +} // namespace mir::action -namespace mir { -namespace api { +namespace mir::api { class MIRWatcher { @@ -104,5 +101,4 @@ }; -} // namespace api -} // namespace mir +} // namespace mir::api diff -Nru metview-5.17.4/mir/src/mir/caching/CroppingCache.cc metview-5.19.2/mir/src/mir/caching/CroppingCache.cc --- metview-5.17.4/mir/src/mir/caching/CroppingCache.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/CroppingCache.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace caching { +namespace mir::caching { CroppingCache::CroppingCache() : @@ -84,12 +83,9 @@ size_t size; f >> size; - mapping_.clear(); - mapping_.reserve(size); + mapping_.resize(size); for (size_t i = 0; i < size; ++i) { - util::AreaCropperMapping::value_type j; - f >> j; - mapping_.push_back(j); + f >> mapping_[i]; } } @@ -120,5 +116,4 @@ } -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/CroppingCache.h metview-5.19.2/mir/src/mir/caching/CroppingCache.h --- metview-5.17.4/mir/src/mir/caching/CroppingCache.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/CroppingCache.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace caching { +namespace mir::caching { struct CroppingCacheEntry { @@ -64,5 +63,4 @@ }; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryCacheBase.cc metview-5.19.2/mir/src/mir/caching/InMemoryCacheBase.cc --- metview-5.17.4/mir/src/mir/caching/InMemoryCacheBase.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryCacheBase.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace caching { +namespace mir::caching { static util::recursive_mutex* local_mutex = nullptr; @@ -105,5 +104,4 @@ } -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryCacheBase.h metview-5.19.2/mir/src/mir/caching/InMemoryCacheBase.h --- metview-5.17.4/mir/src/mir/caching/InMemoryCacheBase.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryCacheBase.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/caching/InMemoryCacheUsage.h" -namespace mir { -namespace caching { +namespace mir::caching { class InMemoryCacheBase { @@ -27,7 +26,7 @@ InMemoryCacheBase(); InMemoryCacheBase(const InMemoryCacheBase&) = delete; - void operator=(const InMemoryCacheBase&) = delete; + void operator=(const InMemoryCacheBase&) = delete; virtual ~InMemoryCacheBase(); @@ -45,5 +44,4 @@ }; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryCache.h metview-5.19.2/mir/src/mir/caching/InMemoryCache.h --- metview-5.17.4/mir/src/mir/caching/InMemoryCache.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryCache.h 2023-07-15 08:28:47.000000000 +0000 @@ -91,7 +91,7 @@ InMemoryCache& cache_; InMemoryCacheStatistics& statistics_; - InMemoryCacheUser(const InMemoryCacheUser&) = delete; + InMemoryCacheUser(const InMemoryCacheUser&) = delete; InMemoryCacheUser& operator=(const InMemoryCacheUser&) = delete; public: diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryCacheStatistics.cc metview-5.19.2/mir/src/mir/caching/InMemoryCacheStatistics.cc --- metview-5.17.4/mir/src/mir/caching/InMemoryCacheStatistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryCacheStatistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "eckit/serialisation/Stream.h" -namespace mir { -namespace caching { +namespace mir::caching { InMemoryCacheStatistics::InMemoryCacheStatistics() : @@ -106,5 +105,4 @@ } -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryCacheStatistics.h metview-5.19.2/mir/src/mir/caching/InMemoryCacheStatistics.h --- metview-5.17.4/mir/src/mir/caching/InMemoryCacheStatistics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryCacheStatistics.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ } -namespace mir { -namespace caching { +namespace mir::caching { class InMemoryCacheStatistics : public eckit::Statistics { @@ -60,5 +59,4 @@ }; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryCacheUsage.cc metview-5.19.2/mir/src/mir/caching/InMemoryCacheUsage.cc --- metview-5.17.4/mir/src/mir/caching/InMemoryCacheUsage.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryCacheUsage.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace caching { +namespace mir::caching { InMemoryCacheUsage::InMemoryCacheUsage() : memory_(0), shared_(0) {} @@ -136,5 +135,4 @@ return shared_; } -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryCacheUsage.h metview-5.19.2/mir/src/mir/caching/InMemoryCacheUsage.h --- metview-5.17.4/mir/src/mir/caching/InMemoryCacheUsage.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryCacheUsage.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ } -namespace mir { -namespace caching { +namespace mir::caching { class InMemoryCacheUsage { @@ -75,5 +74,4 @@ }; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryMeshCache.cc metview-5.19.2/mir/src/mir/caching/InMemoryMeshCache.cc --- metview-5.17.4/mir/src/mir/caching/InMemoryMeshCache.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryMeshCache.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace caching { +namespace mir::caching { static util::recursive_mutex local_mutex; @@ -145,5 +144,4 @@ InMemoryMeshCache::InMemoryMeshCache() = default; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/InMemoryMeshCache.h metview-5.19.2/mir/src/mir/caching/InMemoryMeshCache.h --- metview-5.17.4/mir/src/mir/caching/InMemoryMeshCache.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/InMemoryMeshCache.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,16 +20,13 @@ class Grid; } // namespace atlas -namespace mir { -namespace util { +namespace mir::util { class MIRStatistics; class MeshGeneratorParameters; -} // namespace util -} // namespace mir +} // namespace mir::util -namespace mir { -namespace caching { +namespace mir::caching { class InMemoryMeshCache { @@ -121,5 +118,4 @@ }; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/FileLoader.cc metview-5.19.2/mir/src/mir/caching/legendre/FileLoader.cc --- metview-5.17.4/mir/src/mir/caching/legendre/FileLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/FileLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { FileLoader::FileLoader(const param::MIRParametrisation& parametrisation, const eckit::PathName& path) : @@ -62,6 +60,4 @@ static const LegendreLoaderBuilder loader("file-io"); -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/FileLoader.h metview-5.19.2/mir/src/mir/caching/legendre/FileLoader.h --- metview-5.17.4/mir/src/mir/caching/legendre/FileLoader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/FileLoader.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/caching/legendre/LegendreLoader.h" -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { class FileLoader : public LegendreLoader { @@ -42,6 +40,4 @@ }; -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/LegendreLoader.cc metview-5.19.2/mir/src/mir/caching/legendre/LegendreLoader.cc --- metview-5.17.4/mir/src/mir/caching/legendre/LegendreLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/LegendreLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,15 +14,14 @@ #include +#include "mir/config/LibMir.h" #include "mir/param/MIRParametrisation.h" #include "mir/util/Exceptions.h" #include "mir/util/Log.h" #include "mir/util/Mutex.h" -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { LegendreLoader::LegendreLoader(const param::MIRParametrisation& parametrisation, const eckit::PathName& path) : @@ -70,7 +69,7 @@ util::call_once(once, init); util::lock_guard guard(*local_mutex); - std::string name = "mapped-memory"; + std::string name = LibMir::cacheLoader(LibMir::cache_loader::LEGENDRE); params.get("legendre-loader", name); Log::debug() << "LegendreLoaderFactory: looking for '" << name << "'" << std::endl; @@ -89,7 +88,7 @@ util::call_once(once, init); util::lock_guard guard(*local_mutex); - std::string name = "mapped-memory"; + std::string name = LibMir::cacheLoader(LibMir::cache_loader::LEGENDRE); params.get("legendre-loader", name); Log::debug() << "LegendreLoaderFactory: looking for '" << name << "'" << std::endl; @@ -116,6 +115,4 @@ } -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/LegendreLoader.h metview-5.19.2/mir/src/mir/caching/legendre/LegendreLoader.h --- metview-5.17.4/mir/src/mir/caching/legendre/LegendreLoader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/LegendreLoader.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,22 +20,16 @@ #include "mir/util/Types.h" -namespace atlas { -namespace trans { +namespace atlas::trans { class LegendreCache; -} -} // namespace atlas +} // namespace atlas::trans -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { class LegendreLoader { @@ -44,7 +38,7 @@ LegendreLoader(const param::MIRParametrisation&, const eckit::PathName&); virtual ~LegendreLoader(); - LegendreLoader(const LegendreLoader&) = delete; + LegendreLoader(const LegendreLoader&) = delete; LegendreLoader& operator=(const LegendreLoader&) = delete; virtual const void* address() const = 0; @@ -72,7 +66,7 @@ virtual LegendreLoader* make(const param::MIRParametrisation&, const eckit::PathName& path) = 0; virtual bool shared() const = 0; - LegendreLoaderFactory(const LegendreLoaderFactory&) = delete; + LegendreLoaderFactory(const LegendreLoaderFactory&) = delete; LegendreLoaderFactory& operator=(const LegendreLoaderFactory&) = delete; protected: @@ -100,6 +94,4 @@ }; -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/MappedMemoryLoader.cc metview-5.19.2/mir/src/mir/caching/legendre/MappedMemoryLoader.cc --- metview-5.17.4/mir/src/mir/caching/legendre/MappedMemoryLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/MappedMemoryLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { MappedMemoryLoader::MappedMemoryLoader(const param::MIRParametrisation& parametrisation, const eckit::PathName& path) : @@ -88,6 +86,4 @@ static const LegendreLoaderBuilder loader2("mmap"); -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/MappedMemoryLoader.h metview-5.19.2/mir/src/mir/caching/legendre/MappedMemoryLoader.h --- metview-5.17.4/mir/src/mir/caching/legendre/MappedMemoryLoader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/MappedMemoryLoader.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/caching/legendre/LegendreLoader.h" -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { class MappedMemoryLoader : public LegendreLoader { @@ -43,6 +41,4 @@ }; -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/NoLoader.cc metview-5.19.2/mir/src/mir/caching/legendre/NoLoader.cc --- metview-5.17.4/mir/src/mir/caching/legendre/NoLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/NoLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { NoLoader::NoLoader(const param::MIRParametrisation& parametrisation, const eckit::PathName& path) : @@ -49,6 +47,4 @@ static const LegendreLoaderBuilder loader("none"); -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/NoLoader.h metview-5.19.2/mir/src/mir/caching/legendre/NoLoader.h --- metview-5.17.4/mir/src/mir/caching/legendre/NoLoader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/NoLoader.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/caching/legendre/LegendreLoader.h" -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { /// NoLoader turns off loading of coefficients but will not prevent the creation of the file class NoLoader : public LegendreLoader { @@ -38,6 +36,4 @@ }; -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/SharedMemoryLoader.cc metview-5.19.2/mir/src/mir/caching/legendre/SharedMemoryLoader.cc --- metview-5.17.4/mir/src/mir/caching/legendre/SharedMemoryLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/SharedMemoryLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,12 +27,13 @@ #include #include -//#include "eckit/config/Resource.h" +// #include "eckit/config/Resource.h" #include "eckit/io/StdFile.h" #include "eckit/memory/Shmget.h" -//#include "eckit/os/SemLocker.h" +// #include "eckit/os/SemLocker.h" #include "eckit/runtime/Main.h" +#include "mir/config/LibMir.h" #include "mir/param/SimpleParametrisation.h" #include "mir/util/Error.h" #include "mir/util/Exceptions.h" @@ -40,9 +41,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { namespace { @@ -74,10 +73,10 @@ void add(const eckit::PathName& path) { paths_.push_back(path); } - Unloader(const Unloader&) = delete; - Unloader(Unloader&&) = delete; + Unloader(const Unloader&) = delete; + Unloader(Unloader&&) = delete; Unloader& operator=(const Unloader&) = delete; - Unloader& operator=(Unloader&&) = delete; + Unloader& operator=(Unloader&&) = delete; ~Unloader() { for (auto& path : paths_) { @@ -117,7 +116,7 @@ trace::Timer timer("SharedMemoryLoader: loading '" + path.asString() + "'"); - std::string name; + std::string name = LibMir::cacheLoader(LibMir::cache_loader::LEGENDRE); if (parametrisation.get("legendre-loader", name)) { unload_ = name.substr(0, 4) == "tmp-"; } @@ -161,8 +160,8 @@ #endif // This may return EINVAL is the segment is too large 256MB - int shmid; - if ((shmid = eckit::Shmget::shmget(key, shmsize, IPC_CREAT | 0600)) < 0) { + int shmid = eckit::Shmget::shmget(key, shmsize, IPC_CREAT | 0600); + if (shmid < 0) { Log::warning() << msg.str() << ", shmget: failed to acquire shared memory, check the maximum authorised on this system (Linux ipcs " @@ -329,6 +328,4 @@ static const LegendreLoaderBuilder loader5("tmp-shared-memory"); -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/legendre/SharedMemoryLoader.h metview-5.19.2/mir/src/mir/caching/legendre/SharedMemoryLoader.h --- metview-5.17.4/mir/src/mir/caching/legendre/SharedMemoryLoader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/legendre/SharedMemoryLoader.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/caching/legendre/LegendreLoader.h" -namespace mir { -namespace caching { -namespace legendre { +namespace mir::caching::legendre { class SharedMemoryLoader : public LegendreLoader { @@ -45,6 +43,4 @@ }; -} // namespace legendre -} // namespace caching -} // namespace mir +} // namespace mir::caching::legendre diff -Nru metview-5.17.4/mir/src/mir/caching/LegendreCache.cc metview-5.19.2/mir/src/mir/caching/LegendreCache.cc --- metview-5.17.4/mir/src/mir/caching/LegendreCache.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/LegendreCache.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/config/LibMir.h" -namespace mir { -namespace caching { +namespace mir::caching { LegendreCache::LegendreCache() : @@ -44,5 +43,4 @@ const eckit::PathName& /*unused*/) {} -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/LegendreCache.h metview-5.19.2/mir/src/mir/caching/LegendreCache.h --- metview-5.17.4/mir/src/mir/caching/LegendreCache.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/LegendreCache.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "eckit/container/CacheManager.h" -namespace mir { -namespace caching { +namespace mir::caching { struct LegendreCacheTraits { @@ -38,5 +37,4 @@ }; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/matrix/FileLoader.cc metview-5.19.2/mir/src/mir/caching/matrix/FileLoader.cc --- metview-5.17.4/mir/src/mir/caching/matrix/FileLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/matrix/FileLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace caching { -namespace matrix { +namespace mir::caching::matrix { FileLoader::FileLoader(const std::string& name, const eckit::PathName& path) : @@ -56,6 +54,4 @@ static const MatrixLoaderBuilder loader("file-io"); -} // namespace matrix -} // namespace caching -} // namespace mir +} // namespace mir::caching::matrix diff -Nru metview-5.17.4/mir/src/mir/caching/matrix/FileLoader.h metview-5.19.2/mir/src/mir/caching/matrix/FileLoader.h --- metview-5.17.4/mir/src/mir/caching/matrix/FileLoader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/matrix/FileLoader.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/caching/matrix/MatrixLoader.h" -namespace mir { -namespace caching { -namespace matrix { +namespace mir::caching::matrix { class FileLoader : public MatrixLoader { @@ -42,6 +40,4 @@ }; -} // namespace matrix -} // namespace caching -} // namespace mir +} // namespace mir::caching::matrix diff -Nru metview-5.17.4/mir/src/mir/caching/matrix/MatrixLoader.cc metview-5.19.2/mir/src/mir/caching/matrix/MatrixLoader.cc --- metview-5.17.4/mir/src/mir/caching/matrix/MatrixLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/matrix/MatrixLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace caching { -namespace matrix { +namespace mir::caching::matrix { MatrixLoader::MatrixLoader(const std::string& /*unused*/, const eckit::PathName& path) : path_(path.realName()) {} @@ -99,6 +97,4 @@ } -} // namespace matrix -} // namespace caching -} // namespace mir +} // namespace mir::caching::matrix diff -Nru metview-5.17.4/mir/src/mir/caching/matrix/MatrixLoader.h metview-5.19.2/mir/src/mir/caching/matrix/MatrixLoader.h --- metview-5.17.4/mir/src/mir/caching/matrix/MatrixLoader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/matrix/MatrixLoader.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "eckit/linalg/SparseMatrix.h" -namespace mir { -namespace caching { -namespace matrix { +namespace mir::caching::matrix { class MatrixLoader : public eckit::linalg::SparseMatrix::Allocator { @@ -29,7 +27,7 @@ MatrixLoader(const std::string&, const eckit::PathName&); ~MatrixLoader() override; - MatrixLoader(const MatrixLoader&) = delete; + MatrixLoader(const MatrixLoader&) = delete; MatrixLoader& operator=(const MatrixLoader&) = delete; virtual const void* address() const = 0; @@ -48,7 +46,7 @@ std::string name_; virtual MatrixLoader* make(const std::string& name, const eckit::PathName&) = 0; - MatrixLoaderFactory(const MatrixLoaderFactory&) = delete; + MatrixLoaderFactory(const MatrixLoaderFactory&) = delete; MatrixLoaderFactory& operator=(const MatrixLoaderFactory&) = delete; protected: @@ -70,6 +68,4 @@ }; -} // namespace matrix -} // namespace caching -} // namespace mir +} // namespace mir::caching::matrix diff -Nru metview-5.17.4/mir/src/mir/caching/matrix/SharedMemoryLoader.cc metview-5.19.2/mir/src/mir/caching/matrix/SharedMemoryLoader.cc --- metview-5.17.4/mir/src/mir/caching/matrix/SharedMemoryLoader.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/matrix/SharedMemoryLoader.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,11 +26,11 @@ #include #include -//#include "eckit/config/Resource.h" +// #include "eckit/config/Resource.h" #include "eckit/maths/Functions.h" #include "eckit/memory/Padded.h" #include "eckit/memory/Shmget.h" -//#include "eckit/os/SemLocker.h" +// #include "eckit/os/SemLocker.h" #include "eckit/runtime/Main.h" #include "mir/method/WeightMatrix.h" @@ -40,9 +40,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace caching { -namespace matrix { +namespace mir::caching::matrix { namespace { @@ -76,10 +74,10 @@ void add(const eckit::PathName& path) { paths_.push_back(path); } - Unloader(const Unloader&) = delete; - Unloader(Unloader&&) = delete; + Unloader(const Unloader&) = delete; + Unloader(Unloader&&) = delete; Unloader& operator=(const Unloader&) = delete; - Unloader& operator=(Unloader&&) = delete; + Unloader& operator=(Unloader&&) = delete; ~Unloader() { for (auto& path : paths_) { @@ -165,8 +163,8 @@ #endif // This may return EINVAL is the segment is too large 256MB - int shmid; - if ((shmid = eckit::Shmget::shmget(key, shmsize, IPC_CREAT | 0600)) < 0) { + int shmid = eckit::Shmget::shmget(key, shmsize, IPC_CREAT | 0600); + if (shmid < 0) { Log::warning() << msg.str() << ", shmget: failed to acquire shared memory, check the maximum authorised on this system (Linux ipcs " @@ -326,6 +324,4 @@ static const MatrixLoaderBuilder loader5("tmp-shared-memory"); -} // namespace matrix -} // namespace caching -} // namespace mir +} // namespace mir::caching::matrix diff -Nru metview-5.17.4/mir/src/mir/caching/matrix/SharedMemoryLoader.h metview-5.19.2/mir/src/mir/caching/matrix/SharedMemoryLoader.h --- metview-5.17.4/mir/src/mir/caching/matrix/SharedMemoryLoader.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/matrix/SharedMemoryLoader.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/caching/matrix/MatrixLoader.h" -namespace mir { -namespace caching { -namespace matrix { +namespace mir::caching::matrix { class SharedMemoryLoader : public MatrixLoader { @@ -43,6 +41,4 @@ }; -} // namespace matrix -} // namespace caching -} // namespace mir +} // namespace mir::caching::matrix diff -Nru metview-5.17.4/mir/src/mir/caching/MeshCache.cc metview-5.19.2/mir/src/mir/caching/MeshCache.cc --- metview-5.17.4/mir/src/mir/caching/MeshCache.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/MeshCache.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/config/LibMir.h" -namespace mir { -namespace caching { +namespace mir::caching { MeshCache::MeshCache() : @@ -53,5 +52,4 @@ } -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/MeshCache.h metview-5.19.2/mir/src/mir/caching/MeshCache.h --- metview-5.17.4/mir/src/mir/caching/MeshCache.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/MeshCache.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "eckit/container/CacheManager.h" -namespace mir { -namespace caching { +namespace mir::caching { struct MeshCacheTraits { @@ -37,5 +36,4 @@ }; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/caching/WeightCache.cc metview-5.19.2/mir/src/mir/caching/WeightCache.cc --- metview-5.17.4/mir/src/mir/caching/WeightCache.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/WeightCache.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,13 +28,9 @@ static std::string extract_loader(const param::MIRParametrisation& param) { - - std::string name; - if (param.get("matrix-loader", name)) { - return name; - } - - return "file-io"; + std::string name = LibMir::cacheLoader(LibMir::cache_loader::MATRIX); + param.get("matrix-loader", name); + return name; } diff -Nru metview-5.17.4/mir/src/mir/caching/WeightCache.h metview-5.19.2/mir/src/mir/caching/WeightCache.h --- metview-5.17.4/mir/src/mir/caching/WeightCache.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/caching/WeightCache.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ } // namespace mir -namespace mir { -namespace caching { +namespace mir::caching { struct WeightCacheTraits { @@ -52,5 +51,4 @@ }; -} // namespace caching -} // namespace mir +} // namespace mir::caching diff -Nru metview-5.17.4/mir/src/mir/CMakeLists.txt metview-5.19.2/mir/src/mir/CMakeLists.txt --- metview-5.17.4/mir/src/mir/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -26,6 +26,8 @@ action/filter/AdjustWindsDirections.h action/filter/AdjustWindsScaleCosLatitude.cc action/filter/AdjustWindsScaleCosLatitude.h + action/filter/Bandpass.cc + action/filter/Bandpass.h action/filter/BitmapFilter.cc action/filter/BitmapFilter.h action/filter/CesaroSummationFilter.cc @@ -191,6 +193,12 @@ data/space/SpaceLinear.h data/space/SpaceLogarithmic.cc data/space/SpaceLogarithmic.h + grib/BasicAngle.cc + grib/BasicAngle.h + grib/Packing.cc + grib/Packing.h + grib/Config.cc + grib/Config.h input/ArtificialInput.cc input/ArtificialInput.h input/ConstantInput.cc @@ -209,8 +217,6 @@ input/GribDataHandleInput.h input/GribFileInput.cc input/GribFileInput.h - input/GribFixes.cc - input/GribFixes.h input/GribInput.cc input/GribInput.h input/GribMemoryInput.cc @@ -227,8 +233,6 @@ input/MultiStreamInput.h input/RawInput.cc input/RawInput.h - input/RawMetadata.cc - input/RawMetadata.h input/VectorInput.cc input/VectorInput.h iterator/UnstructuredIterator.h @@ -273,22 +277,6 @@ key/intgrid/None.h key/intgrid/Source.cc key/intgrid/Source.h - key/packing/ArchivedValue.cc - key/packing/ArchivedValue.h - key/packing/CCSDS.cc - key/packing/CCSDS.h - key/packing/Complex.cc - key/packing/Complex.h - key/packing/IEEE.cc - key/packing/IEEE.h - key/packing/JPEG2000.cc - key/packing/JPEG2000.h - key/packing/Packing.cc - key/packing/Packing.h - key/packing/SecondOrder.cc - key/packing/SecondOrder.h - key/packing/Simple.cc - key/packing/Simple.h key/resol/Resol.cc key/resol/Resol.h key/style/CustomParametrisation.cc @@ -450,6 +438,8 @@ output/MultiDimensionalOutput.h output/RawOutput.cc output/RawOutput.h + output/ResizableOutput.cc + output/ResizableOutput.h output/ValuesOutput.cc output/ValuesOutput.h output/VectorOutput.cc diff -Nru metview-5.17.4/mir/src/mir/compare/BufrField.cc metview-5.19.2/mir/src/mir/compare/BufrField.cc --- metview-5.17.4/mir/src/mir/compare/BufrField.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/BufrField.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace compare { +namespace mir::compare { static double bufrRelativeError_ = 0.; @@ -99,7 +98,7 @@ std::vector v; parse(full_, v); - ASSERT(v.size()); + ASSERT(!v.empty()); name_ = v.back(); ignore_ = ignoreBufrKeys.find(name_) != ignoreBufrKeys.end(); @@ -309,7 +308,7 @@ descriptors_.resize(nDescriptors); size_t n = nDescriptors; - GRIB_CALL(codes_get_long_array(h, "unexpandedDescriptors", &descriptors_[0], &n)); + GRIB_CALL(codes_get_long_array(h, "unexpandedDescriptors", descriptors_.data(), &n)); ASSERT(n == nDescriptors); @@ -355,13 +354,13 @@ case CODES_TYPE_LONG: l.resize(count); - GRIB_CALL(codes_get_long_array(h, name, &l[0], &count)); + GRIB_CALL(codes_get_long_array(h, name, l.data(), &count)); ASSERT(l.size() == count); break; case CODES_TYPE_DOUBLE: d.resize(count); - GRIB_CALL(codes_get_double_array(h, name, &d[0], &count)); + GRIB_CALL(codes_get_double_array(h, name, d.data(), &count)); ASSERT(d.size() == count); break; @@ -645,6 +644,4 @@ } -} // namespace compare - -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/BufrField.h metview-5.19.2/mir/src/mir/compare/BufrField.h --- metview-5.17.4/mir/src/mir/compare/BufrField.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/BufrField.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/compare/Field.h" -namespace mir { -namespace compare { +namespace mir::compare { class BufrEntry { @@ -109,5 +108,4 @@ }; -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/Field.cc metview-5.19.2/mir/src/mir/compare/Field.cc --- metview-5.17.4/mir/src/mir/compare/Field.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/Field.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace compare { +namespace mir::compare { static bool normaliseLongitudes_ = false; @@ -249,5 +248,4 @@ } -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/FieldComparator.cc metview-5.19.2/mir/src/mir/compare/FieldComparator.cc --- metview-5.17.4/mir/src/mir/compare/FieldComparator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/FieldComparator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -45,8 +45,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace compare { +namespace mir::compare { constexpr long bufferSize = 5L * 1024 * 1024 * 1024; @@ -859,5 +858,4 @@ } -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/FieldComparator.h metview-5.19.2/mir/src/mir/compare/FieldComparator.h --- metview-5.17.4/mir/src/mir/compare/FieldComparator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/FieldComparator.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,20 +26,17 @@ } // namespace eckit -namespace mir { -namespace compare { +namespace mir::compare { class Field; class FieldSet; class MultiFile; -} // namespace compare -} // namespace mir +} // namespace mir::compare -namespace mir { -namespace compare { +namespace mir::compare { class WhiteLister { - WhiteLister(const WhiteLister&) = delete; + WhiteLister(const WhiteLister&) = delete; WhiteLister& operator=(const WhiteLister&) = delete; public: @@ -139,5 +136,4 @@ }; -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/Field.h metview-5.19.2/mir/src/mir/compare/Field.h --- metview-5.17.4/mir/src/mir/compare/Field.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/Field.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,15 +29,12 @@ } // namespace option } // namespace eckit -namespace mir { -namespace compare { +namespace mir::compare { class FieldSet; -} -} // namespace mir +} // namespace mir::compare -namespace mir { -namespace compare { +namespace mir::compare { class FieldBase : public eckit::Counted { public: @@ -144,5 +141,4 @@ }; -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/FieldInfo.cc metview-5.19.2/mir/src/mir/compare/FieldInfo.cc --- metview-5.17.4/mir/src/mir/compare/FieldInfo.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/FieldInfo.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "eckit/log/JSON.h" -namespace mir { -namespace compare { +namespace mir::compare { FieldInfo::FieldInfo(const std::string& path, off_t offset, size_t length) : @@ -49,5 +48,4 @@ } -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/FieldInfo.h metview-5.19.2/mir/src/mir/compare/FieldInfo.h --- metview-5.17.4/mir/src/mir/compare/FieldInfo.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/FieldInfo.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ } -namespace mir { -namespace compare { +namespace mir::compare { class FieldInfo { @@ -55,5 +54,4 @@ }; -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/FieldSet.cc metview-5.19.2/mir/src/mir/compare/FieldSet.cc --- metview-5.17.4/mir/src/mir/compare/FieldSet.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/FieldSet.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,8 +13,7 @@ #include "mir/compare/FieldSet.h" -namespace mir { -namespace compare { +namespace mir::compare { void FieldSet::clear() { @@ -63,5 +62,4 @@ } -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/FieldSet.h metview-5.19.2/mir/src/mir/compare/FieldSet.h --- metview-5.17.4/mir/src/mir/compare/FieldSet.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/FieldSet.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/compare/Field.h" -namespace mir { -namespace compare { +namespace mir::compare { class FieldSet { @@ -41,5 +40,4 @@ }; -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/GribField.cc metview-5.19.2/mir/src/mir/compare/GribField.cc --- metview-5.17.4/mir/src/mir/compare/GribField.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/GribField.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace compare { +namespace mir::compare { static bool ignoreAccuracy_ = false; @@ -1289,5 +1288,4 @@ } -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/GribField.h metview-5.19.2/mir/src/mir/compare/GribField.h --- metview-5.17.4/mir/src/mir/compare/GribField.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/GribField.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ struct grib_handle; -namespace mir { -namespace compare { +namespace mir::compare { class GribField : public FieldBase { @@ -148,5 +147,4 @@ }; -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/MultiFile.cc metview-5.19.2/mir/src/mir/compare/MultiFile.cc --- metview-5.17.4/mir/src/mir/compare/MultiFile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/MultiFile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace compare { +namespace mir::compare { MultiFile::MultiFile(const std::string& name, const std::string& from) : name_(name), from_(from) {} @@ -152,5 +151,4 @@ return paths_; } -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compare/MultiFile.h metview-5.19.2/mir/src/mir/compare/MultiFile.h --- metview-5.17.4/mir/src/mir/compare/MultiFile.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compare/MultiFile.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ } -namespace mir { -namespace compare { +namespace mir::compare { class MultiFile { @@ -74,5 +73,4 @@ }; -} // namespace compare -} // namespace mir +} // namespace mir::compare diff -Nru metview-5.17.4/mir/src/mir/compat/GribCompatibility.cc metview-5.19.2/mir/src/mir/compat/GribCompatibility.cc --- metview-5.17.4/mir/src/mir/compat/GribCompatibility.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compat/GribCompatibility.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace compat { +namespace mir::compat { static util::once_flag once; @@ -141,5 +140,4 @@ } -} // namespace compat -} // namespace mir +} // namespace mir::compat diff -Nru metview-5.17.4/mir/src/mir/compat/GribCompatibility.h metview-5.19.2/mir/src/mir/compat/GribCompatibility.h --- metview-5.17.4/mir/src/mir/compat/GribCompatibility.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/compat/GribCompatibility.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,11 +20,9 @@ struct grib_info; struct grib_handle; -namespace metkit { -namespace mars { +namespace metkit::mars { class MarsRequest; -} -} // namespace metkit +} // namespace metkit::mars namespace mir { namespace param { @@ -36,14 +34,13 @@ } // namespace mir -namespace mir { -namespace compat { +namespace mir::compat { class GribCompatibility { public: GribCompatibility(const GribCompatibility&) = delete; - void operator=(const GribCompatibility&) = delete; + void operator=(const GribCompatibility&) = delete; virtual void execute(const output::MIROutput&, const param::MIRParametrisation&, grib_handle*, grib_info&) const = 0; @@ -74,5 +71,4 @@ }; -} // namespace compat -} // namespace mir +} // namespace mir::compat diff -Nru metview-5.17.4/mir/src/mir/config/LibMir.cc metview-5.19.2/mir/src/mir/config/LibMir.cc --- metview-5.17.4/mir/src/mir/config/LibMir.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/config/LibMir.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,10 +12,15 @@ #include "mir/config/LibMir.h" -#include "mir/api/mir_version.h" +#include #include "eckit/config/Resource.h" #include "eckit/filesystem/PathName.h" +#include "eckit/utils/MD5.h" + +#include "mir/api/mir_version.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Log.h" namespace mir { @@ -29,22 +34,76 @@ std::string LibMir::cacheDir() { static std::string mirCachePath = - eckit::PathName(eckit::LibResource("mir-cache-path;" - "$MIR_CACHE_PATH", - "/tmp/cache")); + eckit::PathName(eckit::LibResource("mir-cache-path;$MIR_CACHE_PATH", "/tmp/cache")); return mirCachePath; } bool LibMir::caching() { - static bool mirCaching = eckit::LibResource( - "mir-caching;" - "$MIR_CACHING", - true); + static bool mirCaching = eckit::LibResource("mir-caching;$MIR_CACHING", true); return mirCaching; } +const std::string& LibMir::lsmNamed() { + static const std::string mirLsmNamed = + eckit::LibResource("mir-lsm-named;$MIR_LSM_NAMED", "1km.climate.v020"); + return mirLsmNamed; +} + + +eckit::PathName LibMir::configFile(config_file c) { + using r = eckit::LibResource; + + static const eckit::PathName files[]{ + {r("mir-config-area;$MIR_CONFIG_AREA", "~mir/etc/mir/area.yaml")}, + {r("mir-config-classes;$MIR_CONFIG_CLASSES", "~mir/etc/mir/classes.yaml")}, + {r("mir-config-grib-input;$MIR_CONFIG_GRIB_INPUT", "~mir/etc/mir/grib-input.yaml")}, + {r("mir-config-grib-output;$MIR_CONFIG_GRIB_OUTPUT", "~mir/etc/mir/grib-output.yaml")}, + {r("mir-config-grids;$MIR_CONFIG_GRIDS", "~mir/etc/mir/grids.yaml")}, + {r("mir-config-netcdf;$MIR_CONFIG_NETCDF", "~mir/etc/mir/netcdf.yaml")}, + {r("mir-config-parameter-class;$MIR_CONFIG_PARAMETER_CLASS", "~mir/etc/mir/parameter-class.yaml")}, + {r("mir-config-parameters;$MIR_CONFIG_PARAMETERS", "~mir/etc/mir/parameters.yaml")}, + }; + + ASSERT(0 <= c && c < config_file::ALL_CONFIG_FILES); + const auto& path = files[c]; + + if (!path.exists()) { + const std::string msg = + "Configuration file '" + path.fullName() + "' not found, post-processing defaults might not be appropriate"; + + static bool abort = eckit::Resource("$MIR_ABORT_IF_CONFIGURATION_NOT_FOUND", true); + if (abort) { + Log::error() << msg << std::endl; + throw exception::UserError(msg); + } + + // only log messages once + static std::set known_messages; + if (known_messages.insert(eckit::MD5(msg).digest()).second) { + Log::warning() << msg << std::endl; + } + } + + return path; +} + + +std::string LibMir::cacheLoader(cache_loader l) { + using r = eckit::LibResource; + + static const std::string loaders[]{ + {r("$MIR_LEGENDRE_LOADER;mirLegendreLoader", "mapped-memory")}, + {r("$MIR_MATRIX_LOADER;mirMatrixLoader", "file-io")}, + {r("$MIR_POINT_SEARCH_LOADER;mirPointSearchLoader", "mapped-cache-file")}, + }; + + ASSERT(0 <= l && l < cache_loader::ALL_CACHE_LOADERS); + return loaders[l]; +} + + const LibMir& LibMir::instance() { static LibMir libmir; return libmir; diff -Nru metview-5.17.4/mir/src/mir/config/LibMir.h metview-5.19.2/mir/src/mir/config/LibMir.h --- metview-5.17.4/mir/src/mir/config/LibMir.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/config/LibMir.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,19 +17,52 @@ #include "eckit/system/Library.h" +namespace eckit { +class PathName; +} + + namespace mir { class LibMir : public eckit::system::Library { public: - LibMir(); static const LibMir& instance(); static std::string homeDir(); static std::string cacheDir(); + static bool caching(); + static const std::string& lsmNamed(); + + enum config_file + { + AREA = 0, + CLASSES, + GRIB_INPUT, + GRIB_OUTPUT, + GRIDS, + NETCDF, + PARAMETER_CLASS, + PARAMETERS, + ALL_CONFIG_FILES + }; + + static eckit::PathName configFile(config_file); + + enum cache_loader + { + LEGENDRE, + MATRIX, + POINT_SEARCH, + ALL_CACHE_LOADERS, + }; + + static std::string cacheLoader(cache_loader); + +private: + LibMir(); -protected: const void* addr() const override; std::string version() const override; std::string gitsha1(unsigned int count) const override; diff -Nru metview-5.17.4/mir/src/mir/data/CartesianVector2DField.cc metview-5.19.2/mir/src/mir/data/CartesianVector2DField.cc --- metview-5.17.4/mir/src/mir/data/CartesianVector2DField.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/CartesianVector2DField.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace data { +namespace mir::data { namespace { @@ -54,8 +53,8 @@ void CartesianVector2DField::rotate(const util::Rotation& rotation, MIRValuesVector& valuesX, MIRValuesVector& valuesY) const { // setup results vectors + ASSERT(!valuesX.empty()); ASSERT(valuesX.size() == valuesY.size()); - ASSERT(valuesX.size()); // const size_t N = valuesX.size(); // determine angle between meridians (c) using the (first) spherical law of cosines: @@ -101,5 +100,4 @@ } -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/CartesianVector2DField.h metview-5.19.2/mir/src/mir/data/CartesianVector2DField.h --- metview-5.17.4/mir/src/mir/data/CartesianVector2DField.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/CartesianVector2DField.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ } // namespace mir -namespace mir { -namespace data { +namespace mir::data { class CartesianVector2DField { @@ -111,5 +110,4 @@ }; -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/Field.cc metview-5.19.2/mir/src/mir/data/Field.cc --- metview-5.17.4/mir/src/mir/data/Field.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/Field.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace data { +namespace mir::data { Field::Field(const param::MIRParametrisation& param, bool hasMissing, double missingValue) : @@ -137,20 +136,20 @@ } if (!metadata_.empty()) { - out << ",params="; - char sep = '('; + out << ",params=("; + const char* sep = ""; for (const auto& m : metadata_) { out << sep << m; - sep = ','; + sep = ","; } out << ')'; } - out << ",handles="; - char sep = '('; + out << ",handles=("; + const char* sep = ""; for (auto h : handles_) { out << sep << h.first << "=>" << h.second; - sep = ','; + sep = ","; } out << ')'; @@ -320,5 +319,4 @@ } -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/Field.h metview-5.19.2/mir/src/mir/data/Field.h --- metview-5.17.4/mir/src/mir/data/Field.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/Field.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,7 @@ } // namespace mir -namespace mir { -namespace data { +namespace mir::data { class Field : public eckit::Counted { @@ -163,5 +162,4 @@ }; -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/MIRField.cc metview-5.19.2/mir/src/mir/data/MIRField.cc --- metview-5.17.4/mir/src/mir/data/MIRField.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/MIRField.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace data { +namespace mir::data { MIRField::MIRField(const param::MIRParametrisation& param, bool hasMissing, double missingValue) : @@ -273,5 +272,4 @@ } -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/MIRField.h metview-5.19.2/mir/src/mir/data/MIRField.h --- metview-5.17.4/mir/src/mir/data/MIRField.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/MIRField.h 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,7 @@ } // namespace mir -namespace mir { -namespace data { +namespace mir::data { class MIRField { @@ -155,7 +154,7 @@ std::string name_; virtual MIRField* make(const param::MIRParametrisation&, bool hasMissing, double missingValue) = 0; - FieldFactory(const FieldFactory&) = delete; + FieldFactory(const FieldFactory&) = delete; FieldFactory& operator=(const FieldFactory&) = delete; protected: @@ -180,5 +179,4 @@ }; -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/MIRFieldStats.cc metview-5.19.2/mir/src/mir/data/MIRFieldStats.cc --- metview-5.17.4/mir/src/mir/data/MIRFieldStats.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/MIRFieldStats.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include -namespace mir { -namespace data { +namespace mir::data { MIRFieldStats::MIRFieldStats() : count_(0), missing_(0), min_(0), max_(0), mean_(0), sqsum_(0), stdev_(0) {} @@ -61,5 +60,4 @@ } -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/MIRFieldStats.h metview-5.19.2/mir/src/mir/data/MIRFieldStats.h --- metview-5.17.4/mir/src/mir/data/MIRFieldStats.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/MIRFieldStats.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace data { +namespace mir::data { class MIRFieldStats { @@ -47,5 +46,4 @@ }; -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/space/Space1DAngleT.cc metview-5.19.2/mir/src/mir/data/space/Space1DAngleT.cc --- metview-5.17.4/mir/src/mir/data/space/Space1DAngleT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space1DAngleT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { namespace { @@ -181,6 +179,4 @@ } -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space1DAngleT.h metview-5.19.2/mir/src/mir/data/space/Space1DAngleT.h --- metview-5.17.4/mir/src/mir/data/space/Space1DAngleT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space1DAngleT.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,9 +14,7 @@ #include "mir/data/Space.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { template @@ -77,6 +75,4 @@ }; -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space1DLinear.cc metview-5.19.2/mir/src/mir/data/space/Space1DLinear.cc --- metview-5.17.4/mir/src/mir/data/space/Space1DLinear.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space1DLinear.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/data/space/Space1DLinear.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { static const SpaceChoice __space("1d-linear"); @@ -26,6 +24,4 @@ } -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space1DLinear.h metview-5.19.2/mir/src/mir/data/space/Space1DLinear.h --- metview-5.17.4/mir/src/mir/data/space/Space1DLinear.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space1DLinear.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/data/space/SpaceLinear.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { class Space1DLinear : public SpaceLinear { @@ -28,6 +26,4 @@ }; -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space2DVectorZonalMeridional.cc metview-5.19.2/mir/src/mir/data/space/Space2DVectorZonalMeridional.cc --- metview-5.17.4/mir/src/mir/data/space/Space2DVectorZonalMeridional.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space2DVectorZonalMeridional.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/data/space/Space2DVectorZonalMeridional.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { static const SpaceChoice __space1("2d-vector-u", 0, 2); @@ -27,6 +25,4 @@ } -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space2DVectorZonalMeridional.h metview-5.19.2/mir/src/mir/data/space/Space2DVectorZonalMeridional.h --- metview-5.17.4/mir/src/mir/data/space/Space2DVectorZonalMeridional.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space2DVectorZonalMeridional.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/data/space/SpaceLinear.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { class Space2DVectorZonalMeridional : public SpaceLinear { @@ -28,6 +26,4 @@ }; -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space3DCartesian.cc metview-5.19.2/mir/src/mir/data/space/Space3DCartesian.cc --- metview-5.17.4/mir/src/mir/data/space/Space3DCartesian.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space3DCartesian.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/data/space/Space3DCartesian.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { static const SpaceChoice __space1("3d-cartesian-x", 0, 3); @@ -28,6 +26,4 @@ } -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space3DCartesian.h metview-5.19.2/mir/src/mir/data/space/Space3DCartesian.h --- metview-5.17.4/mir/src/mir/data/space/Space3DCartesian.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space3DCartesian.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/data/space/SpaceLinear.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { class Space3DCartesian : public SpaceLinear { @@ -28,6 +26,4 @@ }; -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space3DVectorZonalMeridionalVertical.cc metview-5.19.2/mir/src/mir/data/space/Space3DVectorZonalMeridionalVertical.cc --- metview-5.17.4/mir/src/mir/data/space/Space3DVectorZonalMeridionalVertical.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space3DVectorZonalMeridionalVertical.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/data/space/Space3DVectorZonalMeridionalVertical.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { static const SpaceChoice __space1("3d-vector-u", 0, 3); @@ -28,6 +26,4 @@ } -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/Space3DVectorZonalMeridionalVertical.h metview-5.19.2/mir/src/mir/data/space/Space3DVectorZonalMeridionalVertical.h --- metview-5.17.4/mir/src/mir/data/space/Space3DVectorZonalMeridionalVertical.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/Space3DVectorZonalMeridionalVertical.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/data/space/SpaceLinear.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { class Space3DVectorZonalMeridionalVertical : public SpaceLinear { @@ -28,6 +26,4 @@ }; -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/SpaceLinear.cc metview-5.19.2/mir/src/mir/data/space/SpaceLinear.cc --- metview-5.17.4/mir/src/mir/data/space/SpaceLinear.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/SpaceLinear.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/data/space/SpaceLinear.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { SpaceLinear::SpaceLinear() = default; @@ -41,6 +39,4 @@ } -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/SpaceLinear.h metview-5.19.2/mir/src/mir/data/space/SpaceLinear.h --- metview-5.17.4/mir/src/mir/data/space/SpaceLinear.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/SpaceLinear.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/data/Space.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { class SpaceLinear : public Space { @@ -76,6 +74,4 @@ }; -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/SpaceLogarithmic.cc metview-5.19.2/mir/src/mir/data/space/SpaceLogarithmic.cc --- metview-5.17.4/mir/src/mir/data/space/SpaceLogarithmic.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/SpaceLogarithmic.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { static const SpaceChoice __space("1d-logarithmic"); @@ -62,6 +60,4 @@ } -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/space/SpaceLogarithmic.h metview-5.19.2/mir/src/mir/data/space/SpaceLogarithmic.h --- metview-5.17.4/mir/src/mir/data/space/SpaceLogarithmic.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/space/SpaceLogarithmic.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/data/Space.h" -namespace mir { -namespace data { -namespace space { +namespace mir::data::space { class SpaceLogarithmic : public Space { @@ -77,6 +75,4 @@ }; -} // namespace space -} // namespace data -} // namespace mir +} // namespace mir::data::space diff -Nru metview-5.17.4/mir/src/mir/data/Space.cc metview-5.19.2/mir/src/mir/data/Space.cc --- metview-5.17.4/mir/src/mir/data/Space.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/Space.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace data { +namespace mir::data { Space::Space() = default; @@ -92,5 +91,4 @@ } -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/data/Space.h metview-5.19.2/mir/src/mir/data/Space.h --- metview-5.17.4/mir/src/mir/data/Space.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/data/Space.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "eckit/linalg/Matrix.h" -namespace mir { -namespace data { +namespace mir::data { class Space { @@ -102,7 +101,7 @@ class SpaceChooser { private: - SpaceChooser(const SpaceChooser&) = delete; + SpaceChooser(const SpaceChooser&) = delete; SpaceChooser& operator=(const SpaceChooser&) = delete; std::string name_; @@ -128,5 +127,4 @@ }; -} // namespace data -} // namespace mir +} // namespace mir::data diff -Nru metview-5.17.4/mir/src/mir/grib/BasicAngle.cc metview-5.19.2/mir/src/mir/grib/BasicAngle.cc --- metview-5.17.4/mir/src/mir/grib/BasicAngle.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/grib/BasicAngle.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,115 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include "mir/grib/BasicAngle.h" + +#include +// #include std::lcm, std::gcd (C++ 17) +#include + +#include "eckit/types/Fraction.h" + +#include "mir/util/Angles.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Grib.h" + + +namespace mir::grib { + + +Fraction::Fraction(double d) : Fraction(eckit::Fraction(d)) {} + + +Fraction::Fraction(const eckit::Fraction& frac) : + num(static_cast(frac.numerator())), den(static_cast(frac.denominator())) { + constexpr auto min = static_cast(std::numeric_limits::lowest()); + constexpr auto max = static_cast(std::numeric_limits::max()); + ASSERT(frac.denominator() != 0); + ASSERT(min <= frac.denominator() && frac.denominator() <= max); + ASSERT(min <= frac.numerator() && frac.numerator() <= max); +} + + +Fraction::value_type lcm(Fraction::value_type a, Fraction::value_type b) { + if (a == 0 || b == 0) { + return 0; + } + + return a * (b / gcd(a, b)); +} + + +Fraction::value_type gcd(Fraction::value_type a, Fraction::value_type b) { + if (a == 0 && b == 0) { + return 0; + } + + // Euclidean algorithm + while (b != 0) { + auto r = a % b; + a = b; + b = r; + } + return a; +} + + +BasicAngle::BasicAngle(Fraction a, Fraction b, Fraction c, Fraction d, Fraction e, Fraction f) : + Fraction(gcd(a.num, b.num, c.num, d.num, e.num, f.num), lcm(a.den, b.den, c.den, d.den, e.den, f.den)) { + ASSERT(den != 0); +} + + +BasicAngle::BasicAngle(const grib_info& info) : + BasicAngle(Fraction(info.grid.latitudeOfFirstGridPointInDegrees), + Fraction(util::normalise_longitude(info.grid.longitudeOfFirstGridPointInDegrees, 0.)), + Fraction(info.grid.latitudeOfLastGridPointInDegrees), + Fraction(util::normalise_longitude(info.grid.longitudeOfLastGridPointInDegrees, 0.)), + Fraction(info.grid.iDirectionIncrementInDegrees), Fraction(info.grid.jDirectionIncrementInDegrees)) {} + + +void BasicAngle::fillGrib(grib_info& info) const { + auto fill = [this, &info](const char* key, double value) { + Fraction f(value); + ASSERT(f.den != 0); + if (f.num != 0) { + info.extra_set(key, numerator(f)); + } + }; + + info.extra_set("basicAngleOfTheInitialProductionDomain", num); + info.extra_set("subdivisionsOfBasicAngle", den); + + fill("latitudeOfFirstGridPoint", info.grid.latitudeOfFirstGridPointInDegrees); + fill("longitudeOfFirstGridPoint", util::normalise_longitude(info.grid.longitudeOfFirstGridPointInDegrees, 0.)); + fill("latitudeOfLastGridPoint", info.grid.latitudeOfLastGridPointInDegrees); + fill("longitudeOfLastGridPoint", util::normalise_longitude(info.grid.longitudeOfLastGridPointInDegrees, 0.)); + fill("iDirectionIncrement", info.grid.iDirectionIncrementInDegrees); + fill("jDirectionIncrement", info.grid.jDirectionIncrementInDegrees); +} + + +Fraction::value_type BasicAngle::numerator(const Fraction& f) const { + Fraction x(f.num * den, f.den * num); + const auto div = gcd(x.num, x.den); + + ASSERT(x.den == div); // if BasicAngle is adequate + return x.num / div; +} + + +void BasicAngle::list(std::ostream& out) { + out << "as-input, decimal, fraction"; +} + + +} // namespace mir::grib diff -Nru metview-5.17.4/mir/src/mir/grib/BasicAngle.h metview-5.19.2/mir/src/mir/grib/BasicAngle.h --- metview-5.17.4/mir/src/mir/grib/BasicAngle.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/grib/BasicAngle.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,107 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include + + +struct grib_info; + +namespace eckit { +class Fraction; +} + + +namespace mir::grib { + + +struct Fraction { + // -- Types + + using value_type = long; + + // -- Exceptions + // None + + // -- Constructors + + explicit Fraction(double); + + explicit Fraction(const eckit::Fraction&); + + Fraction(value_type _numerator, value_type _denominator) : + num(_numerator), den(_denominator == 0 || _numerator == 0 ? 1 : _denominator) {} + + // -- Members + + const value_type num; + const value_type den; +}; + + +Fraction::value_type lcm(Fraction::value_type a, Fraction::value_type b); + + +template +Fraction::value_type lcm(Fraction::value_type a, Fraction::value_type b, Longs... cde) { + return lcm(a, lcm(b, cde...)); +} + + +long gcd(long a, long b); + + +template +long gcd(long a, long b, Longs... cde) { + return gcd(a, gcd(b, cde...)); +} + + +struct BasicAngle : Fraction { + // -- Types + // None + + // -- Exceptions + // None + + // -- Constructors + + using Fraction::Fraction; + BasicAngle(Fraction, Fraction, Fraction, Fraction, Fraction, Fraction); + explicit BasicAngle(const grib_info&); + + // -- Destructor + // None + + // -- Convertors + // None + + // -- Operators + // None + + // -- Methods + + void fillGrib(grib_info&) const; + Fraction::value_type numerator(const Fraction&) const; + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + + static void list(std::ostream&); +}; + + +} // namespace mir::grib diff -Nru metview-5.17.4/mir/src/mir/grib/Config.cc metview-5.19.2/mir/src/mir/grib/Config.cc --- metview-5.17.4/mir/src/mir/grib/Config.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/grib/Config.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,156 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include "mir/grib/Config.h" + +#include +#include + +#include "eckit/filesystem/PathName.h" +#include "eckit/log/JSON.h" +#include "eckit/parser/YAMLParser.h" +#include "eckit/utils/StringTools.h" +#include "eckit/utils/Translator.h" + +#include "mir/param/SimpleParametrisation.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Log.h" +#include "mir/util/Mutex.h" +#include "mir/util/ValueMap.h" + + +namespace mir::grib { + + +Config::Config(const eckit::PathName& path, bool silent) : silent_(silent) { + readConfigurationFiles(path); +} + + +Config::~Config() { + for (auto& rule : fixes_) { + delete rule.first; + delete rule.second; + } +} + + +const param::SimpleParametrisation& Config::find(const param::MIRParametrisation& param) const { + static util::recursive_mutex mtx; + util::lock_guard lock(mtx); + + // select best fix by number of matching keys + static const param::SimpleParametrisation empty; + size_t match = 0; + const auto* fixes = ∅ + + for (const auto& f : fixes_) { + if ((f.first)->matchAny(param) && match < (f.first)->size()) { + ASSERT(f.second); + match = (f.first)->size(); + fixes = f.second; + } + } + + if (!silent_ && fixes->size() > 0) { + Log::warning() << "Config: " << *fixes << std::endl; + } + + return *fixes; +} + + +void Config::print(std::ostream& s) const { + eckit::JSON json(s); + json.startObject(); + for (const auto& fix : fixes_) { + json << *(fix.first) << *(fix.second); + } + json.endObject(); +} + + +void Config::readConfigurationFiles(const eckit::PathName& path) { + static util::recursive_mutex mtx; + util::lock_guard lock(mtx); + + ASSERT(fixes_.empty()); + + if (!path.exists()) { + return; + } + + // value type conversions + using eckit::StringTools; + + eckit::Translator i; + eckit::Translator d; + + auto k = [](const std::string& key) { + ASSERT(key.size() >= 2); + return key.substr(0, key.size() - 2); + }; + + auto vi = [&i](const std::vector& values) { + std::vector v(values.size()); + std::transform(values.begin(), values.end(), v.begin(), [&i](const std::string& s) { return i(s); }); + return v; + }; + + auto vd = [&d](const std::vector& values) { + std::vector v(values.size()); + std::transform(values.begin(), values.end(), v.begin(), [&d](const std::string& s) { return d(s); }); + return v; + }; + + eckit::ValueMap rules(eckit::YAMLParser::decodeFile(path)); + for (const auto& rule : rules) { + + // how the input is to be identified + auto* id = new param::SimpleParametrisation; + ASSERT(id); + + for (auto& ids : StringTools::split(",", rule.first)) { + auto keyValue = StringTools::split("=", ids); + ASSERT(keyValue.size() == 2); + + auto key = StringTools::trim(keyValue[0]); + auto value = StringTools::trim(keyValue[1]); + + if (value.find('/') != std::string::npos) { + auto values = StringTools::split("/", value); + StringTools::endsWith(key, ":i") ? id->set(k(key), vi(values)) + : StringTools::endsWith(key, ":d") ? id->set(k(key), vd(values)) + : id->set(key, values); + } + else { + StringTools::endsWith(key, ":i") ? id->set(k(key), i(value)) + : StringTools::endsWith(key, ":d") ? id->set(k(key), d(value)) + : id->set(key, value); + } + } + + // how the input is to be corrected + auto* fix = new param::SimpleParametrisation; + ASSERT(fix); + + for (const auto& fixes : static_cast(rule.second)) { + util::ValueMap map(fixes); + map.set(*fix); + } + + fixes_.emplace_back(id, fix); + } +} + + +} // namespace mir::grib diff -Nru metview-5.17.4/mir/src/mir/grib/Config.h metview-5.19.2/mir/src/mir/grib/Config.h --- metview-5.17.4/mir/src/mir/grib/Config.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/grib/Config.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,121 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#pragma once + +#include +#include +#include + + +namespace eckit { +class PathName; +} +namespace mir::param { +class MIRParametrisation; +class SimpleParametrisation; +} // namespace mir::param + + +namespace mir::grib { + + +class Config { +public: + // -- Types + // None + + // -- Exceptions + // None + + // -- Constructors + + Config(const eckit::PathName&, bool silent); + + Config(const Config&) = delete; + Config(Config&&) = delete; + + // -- Destructor + + ~Config(); + + // -- Convertors + // None + + // -- Operators + + void operator=(const Config&) = delete; + void operator=(Config&&) = delete; + + // -- Methods + + const param::SimpleParametrisation& find(const param::MIRParametrisation&) const; + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + // None + +protected: + // -- Members + // None + + // -- Methods + // None + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + // None + +private: + // -- Types + + using fix_t = std::pair; + + // -- Members + + std::vector fixes_; + bool silent_; + + // -- Methods + + void readConfigurationFiles(const eckit::PathName&); + void print(std::ostream&) const; + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + // None + + // -- Friends + + friend std::ostream& operator<<(std::ostream& s, const Config& p) { + p.print(s); + return s; + } +}; + + +} // namespace mir::grib diff -Nru metview-5.17.4/mir/src/mir/grib/Packing.cc metview-5.19.2/mir/src/mir/grib/Packing.cc --- metview-5.17.4/mir/src/mir/grib/Packing.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/grib/Packing.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,399 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include "mir/grib/Packing.h" + +#include +#include + +#include "eckit/filesystem/PathName.h" + +#include "mir/config/LibMir.h" +#include "mir/grib/Config.h" +#include "mir/param/CombinedParametrisation.h" +#include "mir/param/MIRParametrisation.h" +#include "mir/param/SimpleParametrisation.h" +#include "mir/repres/Representation.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Grib.h" +#include "mir/util/Log.h" + + +namespace mir::grib { + + +void check(bool ok, const std::string& message) { + if (!ok) { + Log::error() << message << std::endl; + throw exception::UserError(message); + } +}; + + +Packing::Packing(const std::string& name, const param::MIRParametrisation& param) : + bitsPerValue_(0), + precision_(0), + definePrecision_(false), + gridded_(param.userParametrisation().has("grid") || param.fieldParametrisation().has("gridded")) { + const auto& user = param.userParametrisation(); + const auto& field = param.fieldParametrisation(); + + ASSERT(!name.empty()); + packing_ = name; + std::string packing; + + bool gridded = false; + field.get("gridded", gridded); + + definePacking_ = !field.get("packing", packing) || packing_ != packing || gridded_ != gridded; + defineBitsPerValueBeforePacking_ = definePacking_ && packing == "ieee"; + + defineBitsPerValue_ = false; + if (defineBitsPerValueBeforePacking_) { + ASSERT(param.get("accuracy", bitsPerValue_)); + defineBitsPerValue_ = true; + } + else if (user.get("accuracy", bitsPerValue_)) { + long accuracy = 0; + defineBitsPerValue_ = !field.get("accuracy", accuracy) || bitsPerValue_ != accuracy; + } + + long edition = 0; + param.get("edition", edition_ = field.get("edition", edition) ? 0 : 2); + + defineEdition_ = edition_ > 0 && edition_ != edition; +} + + +bool Packing::sameAs(const Packing* other) const { + if (definePacking_ != other->definePacking_ || defineBitsPerValue_ != other->defineBitsPerValue_ || + defineEdition_ != other->defineEdition_ || definePrecision_ != other->definePrecision_) { + return false; + } + + bool samePacking = !definePacking_ || packing_ == other->packing_; + bool sameAccuracy = !defineBitsPerValue_ || bitsPerValue_ == other->bitsPerValue_; + bool sameEdition = !defineEdition_ || edition_ == other->edition_; + bool sameprecision = !definePrecision_ || precision_ == other->precision_; + + return samePacking && sameAccuracy && sameEdition && sameprecision; +} + + +bool Packing::printParametrisation(std::ostream& out) const { + std::string sep; + + if (definePacking_) { + out << sep << "packing=" << packing_; + sep = ","; + } + + if (defineEdition_) { + out << sep << "edition=" << edition_; + sep = ","; + } + + if (defineBitsPerValue_) { + out << sep << "accuracy=" << bitsPerValue_; + sep = ","; + } + + if (definePrecision_) { + out << sep << "precision=" << precision_; + sep = ","; + } + + return !sep.empty(); +} + + +bool Packing::empty() const { + return !definePacking_ && !defineBitsPerValue_ && !defineEdition_ && !definePrecision_; +} + + +void Packing::fill(grib_info& info, long pack) const { + info.packing.packing = CODES_UTIL_PACKING_SAME_AS_INPUT; + info.packing.accuracy = CODES_UTIL_ACCURACY_SAME_BITS_PER_VALUES_AS_INPUT; + // (Representation can set edition, so it isn't reset) + + if (definePacking_) { + info.packing.packing = CODES_UTIL_PACKING_USE_PROVIDED; + info.packing.packing_type = pack; + } + + if (defineBitsPerValue_ && !definePrecision_) { + info.packing.accuracy = CODES_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; + info.packing.bitsPerValue = bitsPerValue_; + } + + if (defineEdition_) { + info.packing.editionNumber = edition_; + } + + if (definePrecision_) { + info.extra_set("precision", precision_); + } +} + + +void Packing::set(grib_handle* h, const std::string& type) const { + // Note: order is important, it is not applicable to all packing's. + + if (defineEdition_) { + GRIB_CALL(codes_set_long(h, "edition", edition_)); + } + + if (defineBitsPerValueBeforePacking_) { + GRIB_CALL(codes_set_long(h, "bitsPerValue", bitsPerValue_)); + } + + if (definePacking_) { + auto len = type.length(); + GRIB_CALL(codes_set_string(h, "packingType", type.c_str(), &len)); + } + + if (definePrecision_) { + GRIB_CALL(codes_set_long(h, "precision", precision_)); + } + else if (defineBitsPerValue_) { + GRIB_CALL(codes_set_long(h, "bitsPerValue", bitsPerValue_)); + } +} + + +namespace packing { + + +struct ArchivedValue : Packing { + ArchivedValue(const std::string& name, const param::MIRParametrisation& param) : Packing(name, param) { + ASSERT(!definePacking_); + } + + void fill(const repres::Representation*, grib_info& info) const override { + Packing::fill(info, CODES_UTIL_PACKING_SAME_AS_INPUT); + } + + void set(const repres::Representation*, grib_handle* handle) const override { Packing::set(handle, ""); } +}; + + +struct CCSDS : Packing { + CCSDS(const std::string& name, const param::MIRParametrisation& param) : Packing(name, param) { + edition_ = 2; + long edition = 0; + defineEdition_ = !param.fieldParametrisation().get("edition", edition) || edition_ != edition; + } + + void fill(const repres::Representation*, grib_info& info) const override { + Packing::fill(info, CODES_UTIL_PACKING_TYPE_CCSDS); + } + + void set(const repres::Representation*, grib_handle* handle) const override { Packing::set(handle, "grid_ccsds"); } +}; + + +struct Complex : Packing { + using Packing::Packing; + + void fill(const repres::Representation*, grib_info& info) const override { + Packing::fill(info, CODES_UTIL_PACKING_TYPE_SPECTRAL_COMPLEX); + } + + void set(const repres::Representation*, grib_handle* handle) const override { + Packing::set(handle, "spectral_complex"); + } +}; + + +struct IEEE : Packing { + IEEE(const std::string& name, const param::MIRParametrisation& param) : Packing(name, param) { + constexpr long L32 = 32; + constexpr long L64 = 64; + constexpr long L128 = 128; + + // Accuracy set by user, otherwise by field (rounded up to a supported precision) + long bits = L32; + param.fieldParametrisation().get("accuracy", bits); + + if (!param.userParametrisation().get("accuracy", bitsPerValue_)) { + bitsPerValue_ = bits <= L32 ? L32 : bits <= L64 ? L64 : L128; + } + + definePrecision_ = bitsPerValue_ != bits || definePacking_ || !param.fieldParametrisation().has("accuracy"); + precision_ = bitsPerValue_ == L32 ? 1 : bitsPerValue_ == L64 ? 2 : bitsPerValue_ == L128 ? 3 : 0; + + if (precision_ == 0) { + std::string msg = "packing=ieee: only supports accuracy=32, 64 and 128"; + Log::error() << msg << std::endl; + throw exception::UserError(msg); + } + } + + void fill(const repres::Representation*, grib_info& info) const override { + Packing::fill(info, CODES_UTIL_PACKING_TYPE_IEEE); + } + + void set(const repres::Representation*, grib_handle* handle) const override { + Packing::set(handle, gridded() ? "grid_ieee" : "spectral_ieee"); + } +}; + + +struct Simple : Packing { + using Packing::Packing; + + void fill(const repres::Representation*, grib_info& info) const override { + Packing::fill(info, gridded() ? CODES_UTIL_PACKING_TYPE_GRID_SIMPLE : CODES_UTIL_PACKING_TYPE_SPECTRAL_SIMPLE); + } + void set(const repres::Representation*, grib_handle* handle) const override { + Packing::set(handle, gridded() ? "grid_simple" : "spectral_simple"); + } +}; + + +struct SecondOrder : Packing { + SecondOrder(const std::string& name, const param::MIRParametrisation& param) : + Packing(name, param), simple_(name, param) {} + + Simple simple_; + + static bool check(const repres::Representation* repres) { + ASSERT(repres != nullptr); + + auto n = repres->numberOfPoints(); + if (n < 4) { + Log::warning() << "packing=second-order: does not support less than 4 values, using packing=simple" + << std::endl; + return false; + } + return true; + } + + void fill(const repres::Representation* repres, grib_info& info) const override { + if (!check(repres)) { + simple_.fill(repres, info); + return; + } + + Packing::fill(info, CODES_UTIL_PACKING_TYPE_GRID_SECOND_ORDER); + } + void set(const repres::Representation* repres, grib_handle* handle) const override { + if (!check(repres)) { + simple_.set(repres, handle); + return; + } + + Packing::set(handle, "grid_second_order"); + } +}; + + +} // namespace packing + + +Packing* Packing::build(const param::MIRParametrisation& param) { + const auto& user = param.userParametrisation(); + const auto& field = param.fieldParametrisation(); + + + // Defaults + long edition = 2; + param.get("edition", edition); + + static const grib::Config config(LibMir::configFile(LibMir::config_file::GRIB_OUTPUT), true); + std::unique_ptr grib_config( + new param::CombinedParametrisation(user, field, config.find(param))); + + + // Check edition conversion + bool edition_conversion = false; + grib_config->get("grib-edition-conversion", edition_conversion); + + if (!edition_conversion && !user.has("edition")) { + long field_edition = 0; + field.get("edition", field_edition); + check(field_edition == 0 || field_edition == edition, "GRIB edition conversion is disabled)"); + } + + + // Packing + std::string packing_spectral = "complex"; + std::string packing_gridded = "ccsds"; + bool packing_always_set = false; + grib_config->get("grib-packing-gridded", packing_gridded); + grib_config->get("grib-packing-spectral", packing_spectral); + grib_config->get("grib-packing-always-set", packing_always_set); + + ASSERT(field.has("spectral") != field.has("gridded")); + auto gridded = user.has("grid") || (field.has("gridded")); + auto packing = packing_always_set ? (gridded ? packing_gridded : packing_spectral) + : field.has("spectral") && user.has("grid") ? packing_gridded + : "av"; + user.get("packing", packing); + + + // Aliasing + auto av = packing == "av" || packing == "archived-value"; + if (av) { + packing = field.has("spectral") ? packing_spectral : packing_gridded; + field.get("packing", packing); + } + else if (packing == "co") { + packing = "complex"; + } + else if (packing == "so") { + packing = "second-order"; + } + + + // Instantiate packing method + if (packing == "ccsds") { + check(edition_conversion || edition == 2, "GRIB packing=ccsds requires edition conversion (disabled)"); + check(gridded, "GRIB packing=ccsds requires gridded data"); + return new packing::CCSDS(packing, param); + } + + if (packing == "complex") { + check(!gridded, "GRIB packing=complex requires spectral data"); + return new packing::Complex(packing, param); + } + + if (packing == "ieee") { + return new packing::IEEE(packing, param); + } + + if (packing.compare(0, 12, "second-order") == 0) { + check(gridded, "GRIB packing=second-order requires gridded data"); + return new packing::SecondOrder(packing, param); + } + + if (packing.compare(0, 6, "simple") == 0) { + return new packing::Simple(packing, param); + } + + if (av) { + return new packing::ArchivedValue(packing, param); + } + + + list(Log::error() << "Packing: unknown packing '" << packing << "', choices are: "); + throw exception::UserError("Packing: unknown packing '" + packing + "'"); +} + + +void Packing::list(std::ostream& out) { + out << "archived-value, av, ccsds, co, complex, ieee, second-order, simple, so" << std::endl; +} + + +} // namespace mir::grib diff -Nru metview-5.17.4/mir/src/mir/grib/Packing.h metview-5.19.2/mir/src/mir/grib/Packing.h --- metview-5.17.4/mir/src/mir/grib/Packing.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/grib/Packing.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,133 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#pragma once + +#include +#include + + +struct grib_info; +struct grib_handle; + +namespace mir { +namespace param { +class MIRParametrisation; +} +namespace repres { +class Representation; +} +} // namespace mir + + +namespace mir::grib { + + +class Packing { +public: + // -- Types + // None + + // -- Exceptions + // None + + // -- Constructors + + Packing(const std::string& name, const param::MIRParametrisation&); + + Packing(const Packing&) = delete; + Packing(Packing&&) = delete; + + // -- Destructor + + virtual ~Packing() = default; + + // -- Convertors + // None + + // -- Operators + + void operator=(const Packing&) = delete; + void operator=(Packing&&) = delete; + + // -- Methods + + virtual void fill(const repres::Representation*, grib_info&) const = 0; + virtual void set(const repres::Representation*, grib_handle*) const = 0; + + bool sameAs(const Packing*) const; + bool printParametrisation(std::ostream&) const; + bool empty() const; + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + + static Packing* build(const param::MIRParametrisation&); + static void list(std::ostream&); + +protected: + // -- Members + + long bitsPerValue_; + long edition_; + std::string packing_; + long precision_; + + bool defineBitsPerValue_; + bool defineBitsPerValueBeforePacking_; + bool defineEdition_; + bool definePacking_; + bool definePrecision_; + + // -- Methods + + bool gridded() const { return gridded_; } + void fill(grib_info&, long) const; + void set(grib_handle*, const std::string&) const; + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + // None + +private: + // -- Members + + const bool gridded_; + + // -- Methods + // None + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + // None + + // -- Friends + // None +}; + + +} // namespace mir::grib diff -Nru metview-5.17.4/mir/src/mir/input/ArtificialInput.cc metview-5.19.2/mir/src/mir/input/ArtificialInput.cc --- metview-5.17.4/mir/src/mir/input/ArtificialInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/ArtificialInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,13 @@ #include #include "mir/param/SimpleParametrisation.h" -#include "mir/repres/Representation.h" #include "mir/util/Exceptions.h" #include "mir/util/Log.h" #include "mir/util/Mutex.h" #include "mir/util/ValueMap.h" -namespace mir { -namespace input { +namespace mir::input { static util::once_flag once; @@ -36,9 +34,6 @@ } -ArtificialInput::ArtificialInput(const param::MIRParametrisation& /*ignored*/) : calls_(0) {} - - ArtificialInput::~ArtificialInput() = default; @@ -64,24 +59,6 @@ } -data::MIRField ArtificialInput::field() const { - ASSERT(dimensions()); - - data::MIRField field(parametrisation(0), false, 9999.); - - repres::RepresentationHandle repres(field.representation()); - auto n = repres->numberOfPoints(); - ASSERT(n); - - for (size_t which = 0; which < dimensions(); ++which) { - auto values = fill(n); - field.update(values, which); - } - - return field; -} - - void ArtificialInput::setAuxiliaryInformation(const util::ValueMap& map) { map.set(parametrisation_); @@ -198,7 +175,7 @@ util::call_once(once, init); util::lock_guard lock(*local_mutex); - Log::debug() << "ArtificialInputFactory: looking for '" << name << "'" << std::endl; + // Log::debug() << "ArtificialInputFactory: looking for '" << name << "'" << std::endl; auto j = m->find(name); if (j == m->end()) { @@ -222,5 +199,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/ArtificialInput.h metview-5.19.2/mir/src/mir/input/ArtificialInput.h --- metview-5.17.4/mir/src/mir/input/ArtificialInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/ArtificialInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -12,18 +12,21 @@ #pragma once -#include "mir/data/MIRField.h" #include "mir/input/MIRInput.h" #include "mir/param/FieldParametrisation.h" #include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace input { +namespace mir::input { class ArtificialInput : public MIRInput, protected param::FieldParametrisation { public: + // -- Constructors + + ArtificialInput(const ArtificialInput&) = delete; + ArtificialInput(ArtificialInput&&) = delete; + // -- Destructor ~ArtificialInput() override; @@ -35,7 +38,9 @@ // None // -- Methods - // None + + void operator=(const ArtificialInput&) = delete; + void operator=(ArtificialInput&&) = delete; // -- Overridden methods // None @@ -49,14 +54,13 @@ protected: // -- Constructors - ArtificialInput(const param::MIRParametrisation&); + ArtificialInput() : calls_(0) {} // -- Members // None // -- Methods - virtual MIRValuesVector fill(size_t) const = 0; param::SimpleParametrisation& parametrisation(size_t which = 0); // -- Overridden methods @@ -65,7 +69,6 @@ bool next() override; size_t dimensions() const override; const param::MIRParametrisation& parametrisation(size_t which = 0) const override; - data::MIRField field() const override; void setAuxiliaryInformation(const util::ValueMap&) override; void print(std::ostream&) const override; bool sameAs(const MIRInput&) const override; @@ -120,16 +123,19 @@ class ArtificialInputFactory { - ArtificialInputFactory(const ArtificialInputFactory&) = delete; - void operator=(const ArtificialInputFactory&) = delete; virtual ArtificialInput* make(const param::MIRParametrisation&) = 0; const std::string name_; protected: - ArtificialInputFactory(const std::string& name); + explicit ArtificialInputFactory(const std::string& name); virtual ~ArtificialInputFactory(); public: + ArtificialInputFactory(const ArtificialInputFactory&) = delete; + ArtificialInputFactory(ArtificialInputFactory&&) = delete; + void operator=(const ArtificialInputFactory&) = delete; + void operator=(ArtificialInputFactory&&) = delete; + static ArtificialInput* build(const std::string&, const param::MIRParametrisation&); static void list(std::ostream&); }; @@ -140,9 +146,8 @@ ArtificialInput* make(const param::MIRParametrisation& param) override { return new T(param); } public: - ArtificialInputBuilder(const std::string& name) : ArtificialInputFactory(name) {} + explicit ArtificialInputBuilder(const std::string& name) : ArtificialInputFactory(name) {} }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/ConstantInput.cc metview-5.19.2/mir/src/mir/input/ConstantInput.cc --- metview-5.17.4/mir/src/mir/input/ConstantInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/ConstantInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,22 +12,41 @@ #include "mir/input/ConstantInput.h" +#include "mir/data/MIRField.h" +#include "mir/repres/Representation.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Types.h" -namespace mir { -namespace input { + +namespace mir::input { static const ArtificialInputBuilder __artificial("constant"); -MIRValuesVector ConstantInput::fill(size_t n) const { +ConstantInput::ConstantInput(const param::MIRParametrisation& /*ignored*/) {} + + +data::MIRField ConstantInput::field() const { + ASSERT(dimensions() > 0); + double constant = 0; parametrisation().get("constant", constant); + data::MIRField field(parametrisation(0), false, 9999.); + + repres::RepresentationHandle repres(field.representation()); + auto n = repres->numberOfValues(); + ASSERT(n > 0); + MIRValuesVector values(n, constant); - return values; + + for (size_t which = 0; which < dimensions(); ++which) { + field.update(values, which); + } + + return field; } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/ConstantInput.h metview-5.19.2/mir/src/mir/input/ConstantInput.h --- metview-5.17.4/mir/src/mir/input/ConstantInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/ConstantInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,18 +15,17 @@ #include "mir/input/ArtificialInput.h" -namespace mir { -namespace input { +namespace mir::input { -class ConstantInput : public ArtificialInput { +class ConstantInput final : public ArtificialInput { public: // -- Exceptions // None // -- Constructors - ConstantInput(const param::MIRParametrisation& param) : ArtificialInput(param) {} + explicit ConstantInput(const param::MIRParametrisation&); // -- Destructor // None @@ -74,8 +73,8 @@ // -- Overridden methods - // From ArtificialInput - MIRValuesVector fill(size_t) const override; + // From MIRInput + data::MIRField field() const override; // -- Class members // None @@ -88,5 +87,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/DistributionInput.cc metview-5.19.2/mir/src/mir/input/DistributionInput.cc --- metview-5.17.4/mir/src/mir/input/DistributionInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/DistributionInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,31 +13,49 @@ #include "mir/input/DistributionInput.h" #include +#include #include +#include "mir/data/MIRField.h" +#include "mir/repres/Representation.h" #include "mir/stats/Distribution.h" #include "mir/util/Exceptions.h" -namespace mir { -namespace input { +namespace mir::input { static const ArtificialInputBuilder __artificial("distribution"); -MIRValuesVector DistributionInput::fill(size_t n) const { - std::string distribution; - ASSERT(parametrisation().get("distribution", distribution)); +DistributionInput::DistributionInput(const param::MIRParametrisation& /*ignored*/) {} + + +data::MIRField DistributionInput::field() const { + ASSERT(dimensions() > 0); + + std::string distribution = 0; + parametrisation().get("distribution", distribution); + + data::MIRField field(parametrisation(0), false, 9999.); + + repres::RepresentationHandle repres(field.representation()); + auto n = repres->numberOfValues(); + ASSERT(n > 0); std::unique_ptr dis(stats::DistributionFactory::build(distribution)); ASSERT(dis); - MIRValuesVector values(n); - std::generate(values.begin(), values.end(), [&]() -> double { return (*dis)(); }); - return values; + for (size_t which = 0; which < dimensions(); ++which) { + + MIRValuesVector values(n); + std::generate(values.begin(), values.end(), [&]() -> double { return (*dis)(); }); + + field.update(values, which); + } + + return field; } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/DistributionInput.h metview-5.19.2/mir/src/mir/input/DistributionInput.h --- metview-5.17.4/mir/src/mir/input/DistributionInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/DistributionInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,25 +15,22 @@ #include "mir/input/ArtificialInput.h" -namespace mir { -namespace stats { +namespace mir::stats { class Distribution; -} -} // namespace mir +} // namespace mir::stats -namespace mir { -namespace input { +namespace mir::input { -class DistributionInput : public ArtificialInput { +class DistributionInput final : public ArtificialInput { public: // -- Exceptions // None // -- Constructors - DistributionInput(const param::MIRParametrisation& param) : ArtificialInput(param) {} + explicit DistributionInput(const param::MIRParametrisation& /*ignored*/); // -- Destructor // None @@ -82,8 +79,8 @@ // -- Overridden methods - // From ArtificialInput - MIRValuesVector fill(size_t) const override; + // From MIRInput + data::MIRField field() const override; // -- Class members // None @@ -96,5 +93,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/DummyInput.cc metview-5.19.2/mir/src/mir/input/DummyInput.cc --- metview-5.17.4/mir/src/mir/input/DummyInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/DummyInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,10 @@ #include #include "mir/data/MIRField.h" +#include "mir/util/Exceptions.h" -namespace mir { -namespace input { +namespace mir::input { static const ArtificialInputBuilder __artificial("dummy"); @@ -27,7 +27,7 @@ static const param::SimpleParametrisation empty; -DummyInput::DummyInput(const param::MIRParametrisation& /*ignored*/) : ArtificialInput(empty) { +DummyInput::DummyInput(const param::MIRParametrisation& /*ignored*/) { parametrisation().set("gridded", true); parametrisation().set("gridType", "regular_ll"); parametrisation().set("north", 90.0); @@ -41,7 +41,10 @@ } -MIRValuesVector DummyInput::fill(size_t /*ignored*/) const { +data::MIRField DummyInput::field() const { + ASSERT(dimensions() > 0); + + data::MIRField field(parametrisation(0), false, 9999.); MIRValuesVector values(360 * 181, 42.); size_t k = 0; @@ -51,9 +54,12 @@ } } - return values; + for (size_t which = 0; which < dimensions(); ++which) { + field.update(values, which); + } + + return field; } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/DummyInput.h metview-5.19.2/mir/src/mir/input/DummyInput.h --- metview-5.17.4/mir/src/mir/input/DummyInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/DummyInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,18 +15,17 @@ #include "mir/input/ArtificialInput.h" -namespace mir { -namespace input { +namespace mir::input { -class DummyInput : public ArtificialInput { +class DummyInput final : public ArtificialInput { public: // -- Exceptions // None // -- Constructors - DummyInput(const param::MIRParametrisation&); + explicit DummyInput(const param::MIRParametrisation&); // -- Destructor // None @@ -74,8 +73,8 @@ // -- Overridden methods - // From ArtificialInput - MIRValuesVector fill(size_t) const override; + // From MIRInput + data::MIRField field() const override; // -- Class members // None @@ -88,5 +87,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/EmptyInput.cc metview-5.19.2/mir/src/mir/input/EmptyInput.cc --- metview-5.17.4/mir/src/mir/input/EmptyInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/EmptyInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace input { +namespace mir::input { EmptyInput::EmptyInput() : calls_(0) { @@ -64,5 +63,4 @@ void EmptyInput::longitudes(std::vector& /*unused*/) const {} -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/EmptyInput.h metview-5.19.2/mir/src/mir/input/EmptyInput.h --- metview-5.17.4/mir/src/mir/input/EmptyInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/EmptyInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace input { +namespace mir::input { class EmptyInput : public MIRInput { @@ -101,5 +100,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GeoPointsFileInput.cc metview-5.19.2/mir/src/mir/input/GeoPointsFileInput.cc --- metview-5.17.4/mir/src/mir/input/GeoPointsFileInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GeoPointsFileInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,8 +30,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace input { +namespace mir::input { static constexpr double missingValueGeoPoints = 3e38; @@ -363,5 +362,4 @@ static const MIRInputBuilder __mirinput(0x2347454f); // "#GEO" -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GeoPointsFileInput.h metview-5.19.2/mir/src/mir/input/GeoPointsFileInput.h --- metview-5.17.4/mir/src/mir/input/GeoPointsFileInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GeoPointsFileInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace input { +namespace mir::input { class GeoPointsFileInput : public MIRInput { @@ -123,5 +122,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribAllFileInput.cc metview-5.19.2/mir/src/mir/input/GribAllFileInput.cc --- metview-5.17.4/mir/src/mir/input/GribAllFileInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribAllFileInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace input { +namespace mir::input { GribAllFileInput::GribAllFileInput(const std::string& path) : path_(path), count_(0) { @@ -74,7 +73,7 @@ data::MIRField GribAllFileInput::field() const { - ASSERT(inputs_.size()); + ASSERT(!inputs_.empty()); data::MIRField f(inputs_[0]->field()); ASSERT(f.dimensions() == 1); for (size_t i = 1; i < inputs_.size(); i++) { @@ -115,5 +114,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribAllFileInput.h metview-5.19.2/mir/src/mir/input/GribAllFileInput.h --- metview-5.17.4/mir/src/mir/input/GribAllFileInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribAllFileInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/input/MIRInput.h" -namespace mir { -namespace input { +namespace mir::input { class GribAllFileInput : public MIRInput { @@ -103,5 +102,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribDataHandleInput.cc metview-5.19.2/mir/src/mir/input/GribDataHandleInput.cc --- metview-5.17.4/mir/src/mir/input/GribDataHandleInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribDataHandleInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "eckit/io/DataHandle.h" -namespace mir { -namespace input { +namespace mir::input { GribDataHandleInput::GribDataHandleInput(eckit::DataHandle& handle, size_t skip, size_t step) : GribStreamInput(skip, step), handle_(handle) { @@ -48,5 +47,4 @@ return handle_; } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribDataHandleInput.h metview-5.19.2/mir/src/mir/input/GribDataHandleInput.h --- metview-5.17.4/mir/src/mir/input/GribDataHandleInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribDataHandleInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/input/GribStreamInput.h" -namespace mir { -namespace input { +namespace mir::input { class GribDataHandleInput : public GribStreamInput { @@ -96,5 +95,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribFileInput.cc metview-5.19.2/mir/src/mir/input/GribFileInput.cc --- metview-5.17.4/mir/src/mir/input/GribFileInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribFileInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "eckit/io/BufferedHandle.h" -namespace mir { -namespace input { +namespace mir::input { GribFileInput::GribFileInput(const eckit::PathName& path, size_t skip, size_t step) : @@ -54,5 +53,4 @@ static const MIRInputBuilder input(0x47524942); // "GRIB" -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribFileInput.h metview-5.19.2/mir/src/mir/input/GribFileInput.h --- metview-5.17.4/mir/src/mir/input/GribFileInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribFileInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/input/GribStreamInput.h" -namespace mir { -namespace input { +namespace mir::input { class GribFileInput : public GribStreamInput { @@ -99,5 +98,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribFixes.cc metview-5.19.2/mir/src/mir/input/GribFixes.cc --- metview-5.17.4/mir/src/mir/input/GribFixes.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribFixes.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/input/GribFixes.h" - -#include -#include - -#include "eckit/filesystem/PathName.h" -#include "eckit/log/JSON.h" -#include "eckit/parser/YAMLParser.h" -#include "eckit/utils/StringTools.h" -#include "eckit/utils/Translator.h" - -#include "mir/param/SimpleParametrisation.h" -#include "mir/util/Exceptions.h" -#include "mir/util/Log.h" -#include "mir/util/Mutex.h" -#include "mir/util/ValueMap.h" - - -namespace mir { -namespace input { - - -GribFixes::GribFixes() { - readConfigurationFiles(); -} - - -GribFixes::~GribFixes() { - for (auto& rule : fixes_) { - delete rule.first; - delete rule.second; - } -} - - -const param::SimpleParametrisation& GribFixes::find(const param::MIRParametrisation& param) const { - static util::recursive_mutex mtx; - util::lock_guard lock(mtx); - - // select best fix by number of matching keys - static const param::SimpleParametrisation empty; - size_t match = 0; - const auto* fixes = ∅ - - for (const auto& f : fixes_) { - if ((f.first)->matchAny(param) && match < (f.first)->size()) { - ASSERT(f.second); - match = (f.first)->size(); - fixes = f.second; - } - } - - if (fixes->size() > 0) { - Log::warning() << "GribFixes: " << *fixes << std::endl; - } - - return *fixes; -} - - -void GribFixes::print(std::ostream& s) const { - s << "GribFixes"; - eckit::JSON json(s); - - json.startObject(); - for (const auto& fix : fixes_) { - json << *(fix.first) << *(fix.second); - } - json.endObject(); -} - - -void GribFixes::readConfigurationFiles() { - static util::recursive_mutex mtx; - util::lock_guard lock(mtx); - - ASSERT(fixes_.empty()); - - const eckit::PathName path = "~mir/etc/mir/GRIB.yaml"; - if (!path.exists()) { - return; - } - - // value type conversions - using eckit::StringTools; - - eckit::Translator i; - eckit::Translator d; - - auto k = [](const std::string& key) { - ASSERT(key.size() >= 2); - return key.substr(0, key.size() - 2); - }; - - auto vi = [&i](const std::vector& values) { - std::vector v(values.size()); - std::transform(values.begin(), values.end(), v.begin(), [&i](const std::string& s) { return i(s); }); - return v; - }; - - auto vd = [&d](const std::vector& values) { - std::vector v(values.size()); - std::transform(values.begin(), values.end(), v.begin(), [&d](const std::string& s) { return d(s); }); - return v; - }; - - eckit::ValueMap rules(eckit::YAMLParser::decodeFile(path)); - for (const auto& rule : rules) { - - // how the input is to be identified - auto* id = new param::SimpleParametrisation; - ASSERT(id); - - for (auto& ids : StringTools::split(",", rule.first)) { - auto keyValue = StringTools::split("=", ids); - ASSERT(keyValue.size() == 2); - - auto key = StringTools::trim(keyValue[0]); - auto value = StringTools::trim(keyValue[1]); - - if (value.find('/') != std::string::npos) { - auto values = StringTools::split("/", value); - StringTools::endsWith(key, ":i") ? id->set(k(key), vi(values)) - : StringTools::endsWith(key, ":d") ? id->set(k(key), vd(values)) - : id->set(key, values); - } - else { - StringTools::endsWith(key, ":i") ? id->set(k(key), i(value)) - : StringTools::endsWith(key, ":d") ? id->set(k(key), d(value)) - : id->set(key, value); - } - } - - // how the input is to be corrected - auto* fix = new param::SimpleParametrisation; - ASSERT(fix); - - for (const auto& fixes : static_cast(rule.second)) { - util::ValueMap map(fixes); - map.set(*fix); - } - - fixes_.emplace_back(id, fix); - } -} - - -} // namespace input -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/input/GribFixes.h metview-5.19.2/mir/src/mir/input/GribFixes.h --- metview-5.17.4/mir/src/mir/input/GribFixes.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribFixes.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include -#include -#include - - -namespace mir { -namespace param { -class MIRParametrisation; -class SimpleParametrisation; -} // namespace param -} // namespace mir - - -namespace mir { -namespace input { - - -class GribFixes { -public: - // -- Types - // None - - // -- Exceptions - // None - - // -- Constructors - - GribFixes(); - - // -- Destructor - - ~GribFixes(); - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - - const param::SimpleParametrisation& find(const param::MIRParametrisation&) const; - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Types - - using fix_t = std::pair; - - // -- Members - - std::vector fixes_; - - // -- Methods - - void readConfigurationFiles(); - void print(std::ostream&) const; - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - - friend std::ostream& operator<<(std::ostream& s, const GribFixes& p) { - p.print(s); - return s; - } -}; - - -} // namespace input -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/input/GribInput.cc metview-5.19.2/mir/src/mir/input/GribInput.cc --- metview-5.17.4/mir/src/mir/input/GribInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,9 @@ #include "eckit/types/FloatCompare.h" #include "eckit/types/Fraction.h" +#include "mir/config/LibMir.h" #include "mir/data/MIRField.h" -#include "mir/input/GribFixes.h" +#include "mir/grib/Config.h" #include "mir/repres/Representation.h" #include "mir/util/Exceptions.h" #include "mir/util/Grib.h" @@ -43,8 +44,7 @@ #include "mir/util/Wind.h" -namespace mir { -namespace input { +namespace mir::input { namespace { @@ -54,10 +54,10 @@ public: Condition() = default; - Condition(const Condition&) = delete; - Condition(Condition&&) = delete; + Condition(const Condition&) = delete; + Condition(Condition&&) = delete; Condition& operator=(const Condition&) = delete; - Condition& operator=(Condition&&) = delete; + Condition& operator=(Condition&&) = delete; virtual ~Condition() = default; virtual bool eval(grib_handle*) const = 0; @@ -148,10 +148,10 @@ public: ConditionOR(const Condition* left, const Condition* right) : left_(left), right_(right) {} - ConditionOR(const ConditionOR&) = delete; - ConditionOR(ConditionOR&&) = delete; + ConditionOR(const ConditionOR&) = delete; + ConditionOR(ConditionOR&&) = delete; ConditionOR& operator=(const ConditionOR&) = delete; - ConditionOR& operator=(ConditionOR&&) = delete; + ConditionOR& operator=(ConditionOR&&) = delete; }; @@ -362,11 +362,11 @@ using fun_t = std::function; fun_t fun_; ProcessingT(fun_t&& fun) : fun_(fun) {} - ~ProcessingT() = default; - ProcessingT(const ProcessingT&) = delete; - ProcessingT(ProcessingT&&) = delete; + ~ProcessingT() = default; + ProcessingT(const ProcessingT&) = delete; + ProcessingT(ProcessingT&&) = delete; void operator=(const ProcessingT&) = delete; - void operator=(ProcessingT&&) = delete; + void operator=(ProcessingT&&) = delete; bool eval(grib_handle* h, T& v) const { return fun_(h, v); } }; @@ -946,10 +946,10 @@ value.resize(count); - GRIB_CALL(codes_get_long_array(grib_, key, &value[0], &size)); + GRIB_CALL(codes_get_long_array(grib_, key, value.data(), &size)); ASSERT(count == size); - ASSERT(value.size()); + ASSERT(!value.empty()); // Log::debug() << "codes_get_long_array(" << name << ",key=" << key << ") size=" << value.size() << // std::endl; @@ -1074,7 +1074,7 @@ value.resize(count); - GRIB_CALL(codes_get_double_array(grib_, key, &value[0], &size)); + GRIB_CALL(codes_get_double_array(grib_, key, value.data(), &size)); ASSERT(count == size); // Log::debug() << "codes_get_double_array(" << name << ",key=" << key << ") size=" << value.size() @@ -1104,8 +1104,8 @@ GRIB_CALL(codes_get_long(h, "7777", &value)); // apply user-defined fixes, if any - static const GribFixes gribFixes; - gribFixes.find(parametrisation(0)).copyValuesTo(cache_.cache_); + static const grib::Config config(LibMir::configFile(LibMir::config_file::GRIB_INPUT), false); + config.find(parametrisation(0)).copyValuesTo(cache_.cache_); return true; } @@ -1286,5 +1286,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribInput.h metview-5.19.2/mir/src/mir/input/GribInput.h --- metview-5.17.4/mir/src/mir/input/GribInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace input { +namespace mir::input { class GribInput : public MIRInput, public param::FieldParametrisation { @@ -83,5 +82,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribMemoryInput.cc metview-5.19.2/mir/src/mir/input/GribMemoryInput.cc --- metview-5.17.4/mir/src/mir/input/GribMemoryInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribMemoryInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace input { +namespace mir::input { GribMemoryInput::GribMemoryInput(const void* message, size_t length) { @@ -41,5 +40,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribMemoryInput.h metview-5.19.2/mir/src/mir/input/GribMemoryInput.h --- metview-5.17.4/mir/src/mir/input/GribMemoryInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribMemoryInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/input/GribInput.h" -namespace mir { -namespace input { +namespace mir::input { class GribMemoryInput : public GribInput { @@ -89,5 +88,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribStreamInput.cc metview-5.19.2/mir/src/mir/input/GribStreamInput.cc --- metview-5.17.4/mir/src/mir/input/GribStreamInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribStreamInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace input { +namespace mir::input { static size_t buffer_size() { @@ -121,5 +120,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/GribStreamInput.h metview-5.19.2/mir/src/mir/input/GribStreamInput.h --- metview-5.17.4/mir/src/mir/input/GribStreamInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/GribStreamInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ } -namespace mir { -namespace input { +namespace mir::input { class GribStreamInput : public GribInput { @@ -103,5 +102,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/MIRInput.cc metview-5.19.2/mir/src/mir/input/MIRInput.cc --- metview-5.17.4/mir/src/mir/input/MIRInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/MIRInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,8 +29,7 @@ #include "mir/util/ValueMap.h" -namespace mir { -namespace input { +namespace mir::input { MIRInput::MIRInput() = default; @@ -43,11 +42,10 @@ // ASSERT(which == 0); static grib_handle* handle = nullptr; if (handle == nullptr) { + // NOTE: starts from GRIB1 to avoid supporting user-requested conversions of GRIB2 to 1 + // FIXME: make this edition-independent handle = codes_grib_handle_new_from_samples(nullptr, "GRIB1"); - - constexpr long MISSING = 255; - codes_set_long(handle, "paramId", MISSING); - ASSERT(handle); + ASSERT(handle != nullptr); } return handle; } @@ -146,7 +144,7 @@ } // attach information after construction (pe. extra files), so virtual methods are specific to child class - auto aux = [&map](MIRInput* in) { + auto aux = [](MIRInput* in, const util::ValueMap& map) { ASSERT(in); if (!map.empty()) { in->setAuxiliaryInformation(map); @@ -157,7 +155,7 @@ // Special case: artificial input auto ai = map.find("artificialInput"); if (ai != map.end() && ai->second.isString()) { - return aux(ArtificialInputFactory::build(ai->second, param)); + return aux(ArtificialInputFactory::build(ai->second, param), map); } // Special case: multi-dimensional input @@ -176,7 +174,7 @@ } if (N > 1) { - return aux(new MultiDimensionalGribFileInput(path, N)); + return aux(new MultiDimensionalGribFileInput(path, N), map); } eckit::AutoStdFile f(path); @@ -203,10 +201,10 @@ Log::warning() << std::endl; Log::warning() << "MIRInputFactory: assuming 'GRIB'" << std::endl; - return aux(new GribFileInput(path)); + return aux(new GribFileInput(path), map); } - return aux(j->second->make(path)); + return aux(j->second->make(path), map); } @@ -223,5 +221,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/MIRInput.h metview-5.19.2/mir/src/mir/input/MIRInput.h --- metview-5.17.4/mir/src/mir/input/MIRInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/MIRInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,8 +33,7 @@ } // namespace mir -namespace mir { -namespace input { +namespace mir::input { class MIRInput { @@ -151,5 +150,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/MultiDimensionalGribFileInput.cc metview-5.19.2/mir/src/mir/input/MultiDimensionalGribFileInput.cc --- metview-5.17.4/mir/src/mir/input/MultiDimensionalGribFileInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/MultiDimensionalGribFileInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/input/GribFileInput.h" -namespace mir { -namespace input { +namespace mir::input { MultiDimensionalGribFileInput::MultiDimensionalGribFileInput(const eckit::PathName& path, size_t dim, size_t skip) { @@ -26,5 +25,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/MultiDimensionalGribFileInput.h metview-5.19.2/mir/src/mir/input/MultiDimensionalGribFileInput.h --- metview-5.17.4/mir/src/mir/input/MultiDimensionalGribFileInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/MultiDimensionalGribFileInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ } -namespace mir { -namespace input { +namespace mir::input { class MultiDimensionalGribFileInput : public MultiDimensionalInput { @@ -94,5 +93,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/MultiDimensionalInput.cc metview-5.19.2/mir/src/mir/input/MultiDimensionalInput.cc --- metview-5.17.4/mir/src/mir/input/MultiDimensionalInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/MultiDimensionalInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace input { +namespace mir::input { MultiDimensionalInput::MultiDimensionalInput() = default; @@ -136,5 +135,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/MultiDimensionalInput.h metview-5.19.2/mir/src/mir/input/MultiDimensionalInput.h --- metview-5.17.4/mir/src/mir/input/MultiDimensionalInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/MultiDimensionalInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,15 +17,12 @@ #include "mir/input/MIRInput.h" -namespace mir { -namespace output { +namespace mir::output { class MultiDimensionalOutput; -} -} // namespace mir +} // namespace mir::output -namespace mir { -namespace input { +namespace mir::input { class MultiDimensionalInput : public MIRInput { @@ -108,5 +105,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/MultiStreamInput.cc metview-5.19.2/mir/src/mir/input/MultiStreamInput.cc --- metview-5.17.4/mir/src/mir/input/MultiStreamInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/MultiStreamInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace input { +namespace mir::input { MultiStreamInput::MultiStreamInput() = default; @@ -102,5 +101,4 @@ } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/MultiStreamInput.h metview-5.19.2/mir/src/mir/input/MultiStreamInput.h --- metview-5.17.4/mir/src/mir/input/MultiStreamInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/MultiStreamInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/input/MIRInput.h" -namespace mir { -namespace input { +namespace mir::input { class MultiStreamInput : public MIRInput { @@ -98,5 +97,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/NetcdfFileInput.cc metview-5.19.2/mir/src/mir/input/NetcdfFileInput.cc --- metview-5.17.4/mir/src/mir/input/NetcdfFileInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/NetcdfFileInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/ValueMap.h" -namespace mir { -namespace input { +namespace mir::input { NetcdfFileInput::NetcdfFileInput(const eckit::PathName& path) : @@ -207,5 +206,4 @@ static const MIRInputBuilder netcdf32(0x43444602); // "CDF." -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/NetcdfFileInput.h metview-5.19.2/mir/src/mir/input/NetcdfFileInput.h --- metview-5.17.4/mir/src/mir/input/NetcdfFileInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/NetcdfFileInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/param/FieldParametrisation.h" -namespace mir { -namespace input { +namespace mir::input { class NetcdfFileInput : public MIRInput, public param::FieldParametrisation, public netcdf::NCFileCache { @@ -134,8 +133,7 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input #endif diff -Nru metview-5.17.4/mir/src/mir/input/RawInput.cc metview-5.19.2/mir/src/mir/input/RawInput.cc --- metview-5.17.4/mir/src/mir/input/RawInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/RawInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,239 +12,76 @@ #include "mir/input/RawInput.h" -#include #include #include "mir/data/MIRField.h" -#include "mir/input/RawMetadata.h" -#include "mir/util/BoundingBox.h" +#include "mir/repres/Representation.h" #include "mir/util/Exceptions.h" -#include "mir/util/Log.h" -namespace mir { -namespace input { +namespace mir::input { -RawInput::RawInput(const RawMetadata& metadata, const double* values, size_t count) : - metadata_(metadata), values_(values), count_(count) {} +RawInput::RawInput(const double* const values, size_t count, const param::SimpleParametrisation& metadata) : + values_(values), count_(count), metadata_(metadata), dimensions_(1), calls_(0) { + ASSERT_MSG(values != nullptr, "RawInput: values != nullptr"); + ASSERT_MSG(count > 0, "RawInput: count > 0"); + long dimensions = 1; + metadata_.get("dimensions", dimensions); + ASSERT(dimensions >= 1); -bool RawInput::sameAs(const MIRInput& other) const { - return this == &other; + dimensions_ = static_cast(dimensions); } bool RawInput::next() { - NOTIMP; -} - - -const param::MIRParametrisation& RawInput::parametrisation(size_t which) const { - ASSERT(which == 0); - return *this; -} - - -data::MIRField RawInput::field() const { - - data::MIRField field(*this, metadata_.hasMissing(), metadata_.missingValue()); - - MIRValuesVector values(count_); - std::memcpy(&values[0], values_, sizeof(double) * count_); - field.update(values, 0); - - // Log::debug() << "RawInput::field: " << field << std::endl; - - return field; -} - - -void RawInput::print(std::ostream& out) const { - out << "RawInput[count=" << count_ << "]"; -} - - -size_t RawInput::copy(double* values, size_t size) const { - ASSERT(count_ <= size); - std::memcpy(values, values_, sizeof(double) * count_); - return count_; -} - - -bool RawInput::has(const std::string& name) const { - Log::debug() << ">>>>>>>>>>>>> RawInput::has (" << name << ")" << std::endl; - - if (name == "gridded") { - return metadata_.gridded(); - } - - if (name == "spectral") { - return metadata_.spectral(); - } - - return false; -} - - -bool RawInput::get(const std::string& name, std::string& value) const { - Log::debug() << ">>>>>>>>>>>>> RawInput::get string (" << name << ")" << std::endl; - - if (name == "gridType") { - value = metadata_.gridType(); - return true; - } - - return false; -} - - -bool RawInput::get(const std::string& name, bool& /*value*/) const { - Log::debug() << ">>>>>>>>>>>>> RawInput::get bool (" << name << ")" << std::endl; - return false; -} - - -bool RawInput::get(const std::string& name, int& value) const { - long v; - if (get(name, v)) { - ASSERT(long(int(v)) == v); - value = int(v); - return true; - } - return false; + return calls_++ == 0; } -bool RawInput::get(const std::string& name, long& value) const { - Log::debug() << ">>>>>>>>>>>>> RawInput::get long (" << name << ")" << std::endl; - - if (name == "N") { - value = long(metadata_.N()); - return true; - } - - if (name == "Nj") { - value = long(metadata_.nj()); - return true; - } - - if (name == "truncation") { - value = long(metadata_.truncation()); - return true; - } - - if (name == "paramId") { - value = long(metadata_.paramId()); - return true; - } - - return false; +size_t RawInput::dimensions() const { + return dimensions_; } -bool RawInput::get(const std::string& name, float& value) const { - double v; - if (get(name, v)) { - value = float(v); - return true; - } - return false; -} - - -bool RawInput::get(const std::string& name, double& value) const { - Log::debug() << ">>>>>>>>>>>>> RawInput::get double (" << name << ")" << std::endl; - - if (name == "north") { - value = metadata_.bbox().north().value(); - return true; - } - - if (name == "south") { - value = metadata_.bbox().south().value(); - return true; - } - - if (name == "west") { - value = metadata_.bbox().west().value(); - return true; - } - - if (name == "east") { - value = metadata_.bbox().east().value(); - return true; - } +const param::MIRParametrisation& RawInput::parametrisation(size_t which) const { + ASSERT(which == 0); - return false; + return metadata_; } -bool RawInput::get(const std::string& name, std::vector& value) const { - std::vector v; - if (get(name, v)) { - value.clear(); - value.reserve(v.size()); - for (const long& l : v) { - ASSERT(long(int(l)) == l); - value.push_back(int(l)); - } - return true; - } - return false; -} - +data::MIRField RawInput::field() const { + double missingValue = 9999.; + bool hasMissing = metadata_.get("missing_value", missingValue); -bool RawInput::get(const std::string& name, std::vector& value) const { - Log::debug() << ">>>>>>>>>>>>> RawInput::get vector (" << name << ")" << std::endl; + // TODO support parametrisation for dimensions > 1 + data::MIRField field(parametrisation(0), hasMissing, missingValue); - if (name == "pl") { - value = metadata_.pl(); - return true; + repres::RepresentationHandle repres(field.representation()); + auto n = repres->numberOfValues(); + ASSERT_VALUES_SIZE_EQ_ITERATOR_COUNT("RawInput", count_, n); + + const auto* here = values_; + for (size_t which = 0; which < dimensions(); ++which, here += count_) { + MIRValuesVector values(here, here + count_); + field.update(values, which); } - return false; -} - - -bool RawInput::get(const std::string& name, std::vector& value) const { - std::vector v; - if (get(name, v)) { - value.clear(); - value.reserve(v.size()); - for (const double& l : v) { - value.push_back(float(l)); - } - return true; - } - return false; + return field; } -bool RawInput::get(const std::string& name, std::vector& value) const { - - if (name == "area") { - value.resize(4); - value[0] = metadata_.bbox().north().value(); // North - value[1] = metadata_.bbox().west().value(); // West - value[2] = metadata_.bbox().south().value(); // South - value[3] = metadata_.bbox().east().value(); // East - return true; - } - - if (name == "grid") { - return false; - } - - Log::debug() << ">>>>>>>>>>>>> RawInput::get vector (" << name << ")" << std::endl; - return false; +bool RawInput::sameAs(const MIRInput& other) const { + const auto* o = dynamic_cast(&other); + return (o != nullptr) && metadata_.matchAll(o->metadata_); } -bool RawInput::get(const std::string& /*name*/, std::vector& /*value*/) const { - NOTIMP; +void RawInput::print(std::ostream& out) const { + out << "RawInput[&values=" << values_ << ",count=" << count_ << ",metadata=" << metadata_ << "]"; } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/RawInput.h metview-5.19.2/mir/src/mir/input/RawInput.h --- metview-5.17.4/mir/src/mir/input/RawInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/RawInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,27 +13,20 @@ #pragma once #include "mir/input/MIRInput.h" -#include "mir/param/MIRParametrisation.h" +#include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace input { -class RawMetadata; -} -} // namespace mir +namespace mir::input { -namespace mir { -namespace input { - - -class RawInput : public MIRInput, public param::MIRParametrisation { +class RawInput final : public MIRInput { public: // -- Exceptions // None // -- Constructors - RawInput(const RawMetadata& metadata, const double* values, size_t count); + + RawInput(const double* const values, size_t count, const param::SimpleParametrisation& metadata); // -- Destructor // None @@ -56,57 +49,28 @@ // -- Class methods // None -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - private: // -- Members - const RawMetadata& metadata_; - const double* values_; - size_t count_; + const double* const values_; + const size_t count_; + const param::SimpleParametrisation& metadata_; + size_t dimensions_; + size_t calls_; // -- Methods + // None // -- Overridden methods // From MIRInput - void print(std::ostream&) const override; - const param::MIRParametrisation& parametrisation(size_t which) const override; - data::MIRField field() const override; bool next() override; - size_t copy(double* values, size_t size) const override; + size_t dimensions() const override; + const param::MIRParametrisation& parametrisation(size_t which = 0) const override; + data::MIRField field() const override; + void print(std::ostream&) const override; bool sameAs(const MIRInput&) const override; - // From MIRParametrisation - bool has(const std::string& name) const override; - - bool get(const std::string& name, std::string& value) const override; - bool get(const std::string& name, bool& value) const override; - bool get(const std::string& name, int& value) const override; - bool get(const std::string& name, long& value) const override; - bool get(const std::string& name, float& value) const override; - bool get(const std::string& name, double& value) const override; - - bool get(const std::string& name, std::vector& value) const override; - bool get(const std::string& name, std::vector& value) const override; - bool get(const std::string& name, std::vector& value) const override; - bool get(const std::string& name, std::vector& value) const override; - bool get(const std::string& name, std::vector& value) const override; - // -- Class members // None @@ -114,9 +78,12 @@ // None // -- Friends - // None + + friend std::ostream& operator<<(std::ostream& s, const RawInput& p) { + p.print(s); + return s; + } }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/RawMetadata.cc metview-5.19.2/mir/src/mir/input/RawMetadata.cc --- metview-5.17.4/mir/src/mir/input/RawMetadata.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/RawMetadata.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/input/RawMetadata.h" - - -namespace mir { -namespace input { - - -RawMetadata::RawMetadata() = default; - - -RawMetadata::~RawMetadata() = default; - - -} // namespace input -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/input/RawMetadata.h metview-5.19.2/mir/src/mir/input/RawMetadata.h --- metview-5.17.4/mir/src/mir/input/RawMetadata.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/RawMetadata.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include -#include - - -namespace mir { -namespace util { -class BoundingBox; -} -} // namespace mir - - -namespace mir { -namespace input { - - -class RawMetadata { -public: - // -- Exceptions - // None - - // -- Constructors - - RawMetadata(); - RawMetadata(const RawMetadata&) = delete; - - // -- Destructor - - virtual ~RawMetadata(); - - // -- Convertors - // None - - // -- Operators - - RawMetadata& operator=(const RawMetadata&) = delete; - - // -- Methods - - virtual const std::vector& pl() const = 0; - - virtual size_t N() const = 0; - virtual size_t truncation() const = 0; - - virtual const util::BoundingBox& bbox() const = 0; - virtual const std::string& gridType() const = 0; - - virtual bool gridded() const = 0; - virtual bool spectral() const = 0; - - virtual size_t nj() const = 0; - virtual size_t paramId() const = 0; - - virtual bool hasMissing() const = 0; - virtual double missingValue() const = 0; - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - // None -}; - - -} // namespace input -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/input/VectorInput.cc metview-5.19.2/mir/src/mir/input/VectorInput.cc --- metview-5.17.4/mir/src/mir/input/VectorInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/VectorInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace input { +namespace mir::input { VectorInput::VectorInput(MIRInput& component1, MIRInput& component2) : @@ -81,5 +80,4 @@ return 2; } -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/input/VectorInput.h metview-5.19.2/mir/src/mir/input/VectorInput.h --- metview-5.17.4/mir/src/mir/input/VectorInput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/input/VectorInput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/input/MIRInput.h" -namespace mir { -namespace output { +namespace mir::output { class VectorOutput; -} -} // namespace mir +} // namespace mir::output -namespace mir { -namespace input { +namespace mir::input { class VectorInput : public MIRInput { @@ -105,5 +102,4 @@ }; -} // namespace input -} // namespace mir +} // namespace mir::input diff -Nru metview-5.17.4/mir/src/mir/iterator/detail/RegularIterator.cc metview-5.19.2/mir/src/mir/iterator/detail/RegularIterator.cc --- metview-5.17.4/mir/src/mir/iterator/detail/RegularIterator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/iterator/detail/RegularIterator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace iterator { -namespace detail { +namespace mir::iterator::detail { RegularIterator::RegularIterator(const eckit::Fraction& a, const eckit::Fraction& b, const eckit::Fraction& inc, @@ -81,6 +79,4 @@ } -} // namespace detail -} // namespace iterator -} // namespace mir +} // namespace mir::iterator::detail diff -Nru metview-5.17.4/mir/src/mir/iterator/detail/RegularIterator.h metview-5.19.2/mir/src/mir/iterator/detail/RegularIterator.h --- metview-5.17.4/mir/src/mir/iterator/detail/RegularIterator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/iterator/detail/RegularIterator.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "eckit/types/Fraction.h" -namespace mir { -namespace iterator { -namespace detail { +namespace mir::iterator::detail { class RegularIterator { @@ -108,6 +106,4 @@ }; -} // namespace detail -} // namespace iterator -} // namespace mir +} // namespace mir::iterator::detail diff -Nru metview-5.17.4/mir/src/mir/iterator/UnstructuredIterator.h metview-5.19.2/mir/src/mir/iterator/UnstructuredIterator.h --- metview-5.17.4/mir/src/mir/iterator/UnstructuredIterator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/iterator/UnstructuredIterator.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace iterator { +namespace mir::iterator { class UnstructuredIterator : public repres::Iterator { @@ -101,5 +100,4 @@ }; -} // namespace iterator -} // namespace mir +} // namespace mir::iterator diff -Nru metview-5.17.4/mir/src/mir/key/Area.cc metview-5.19.2/mir/src/mir/key/Area.cc --- metview-5.17.4/mir/src/mir/key/Area.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/Area.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,22 +22,19 @@ #include "eckit/utils/Tokenizer.h" #include "eckit/utils/Translator.h" +#include "mir/config/LibMir.h" #include "mir/param/MIRParametrisation.h" #include "mir/util/BoundingBox.h" #include "mir/util/Exceptions.h" #include "mir/util/Mutex.h" -namespace mir { -namespace key { +namespace mir::key { -static const std::string key = "area"; -static const std::string path = "~mir/etc/mir/area.yaml"; - struct map_t : std::map> { - map_t(const std::string& p) { - const eckit::PathName path(p); + map_t() { + const auto path = LibMir::configFile(LibMir::config_file::AREA); if (!path.exists()) { return; } @@ -59,7 +56,7 @@ static void init() { mtx = new util::recursive_mutex(); - m = new map_t(path); + m = new map_t; } @@ -67,13 +64,11 @@ util::call_once(once, init); util::lock_guard lock(*mtx); - if (!param.has(key)) { + std::string value; + if (!param.get("area", value)) { return false; } - std::string value; - ASSERT(param.get(key, value)); - if (match(value, bbox)) { return true; } @@ -118,5 +113,4 @@ } -} // namespace key -} // namespace mir +} // namespace mir::key diff -Nru metview-5.17.4/mir/src/mir/key/Area.h metview-5.19.2/mir/src/mir/key/Area.h --- metview-5.17.4/mir/src/mir/key/Area.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/Area.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ } // namespace mir -namespace mir { -namespace key { +namespace mir::key { class Area { @@ -103,5 +102,4 @@ }; -} // namespace key -} // namespace mir +} // namespace mir::key diff -Nru metview-5.17.4/mir/src/mir/key/grid/ClassicPattern.cc metview-5.19.2/mir/src/mir/key/grid/ClassicPattern.cc --- metview-5.17.4/mir/src/mir/key/grid/ClassicPattern.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/ClassicPattern.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { ClassicPattern::ClassicPattern(const std::string& name) : GridPattern(name) {} @@ -50,6 +48,4 @@ static const ClassicPattern __pattern("^[nN][1-9][0-9]*$"); -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/ClassicPattern.h metview-5.19.2/mir/src/mir/key/grid/ClassicPattern.h --- metview-5.17.4/mir/src/mir/key/grid/ClassicPattern.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/ClassicPattern.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/GridPattern.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class ClassicPattern : public GridPattern { @@ -77,6 +75,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/Grid.cc metview-5.19.2/mir/src/mir/key/grid/Grid.cc --- metview-5.17.4/mir/src/mir/key/grid/Grid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/Grid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,6 +18,7 @@ #include "eckit/filesystem/PathName.h" #include "eckit/parser/YAMLParser.h" +#include "mir/config/LibMir.h" #include "mir/key/grid/GridPattern.h" #include "mir/key/grid/NamedFromFile.h" #include "mir/util/Exceptions.h" @@ -25,9 +26,7 @@ #include "mir/util/ValueMap.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { static util::once_flag once; @@ -47,7 +46,7 @@ files_read = true; // Read config file, attaching new Grid's grids to parametrisations - eckit::PathName path("~mir/etc/mir/grids.yaml"); + const auto path = LibMir::configFile(LibMir::config_file::GRIDS); if (path.exists()) { Log::debug() << "Grid: reading from '" << path << "'" << std::endl; @@ -184,6 +183,4 @@ } -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/Grid.h metview-5.19.2/mir/src/mir/key/grid/Grid.h --- metview-5.17.4/mir/src/mir/key/grid/Grid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/Grid.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,9 +29,7 @@ } // namespace mir -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class Grid { @@ -144,6 +142,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/GridPattern.cc metview-5.19.2/mir/src/mir/key/grid/GridPattern.cc --- metview-5.17.4/mir/src/mir/key/grid/GridPattern.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/GridPattern.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { static util::recursive_mutex* local_mutex = nullptr; @@ -122,6 +120,4 @@ } -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/GridPattern.h metview-5.19.2/mir/src/mir/key/grid/GridPattern.h --- metview-5.17.4/mir/src/mir/key/grid/GridPattern.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/GridPattern.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,18 +19,12 @@ #include "mir/util/Regex.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class Grid; -} -} // namespace key -} // namespace mir +} // namespace mir::key::grid -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class GridPattern { @@ -116,6 +110,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedClassic.cc metview-5.19.2/mir/src/mir/key/grid/NamedClassic.cc --- metview-5.17.4/mir/src/mir/key/grid/NamedClassic.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedClassic.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/repres/gauss/reduced/RotatedClassic.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { NamedClassic::NamedClassic(const std::string& name, size_t N) : NamedGrid(name), N_(N) {} @@ -46,6 +44,4 @@ } -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedClassic.h metview-5.19.2/mir/src/mir/key/grid/NamedClassic.h --- metview-5.17.4/mir/src/mir/key/grid/NamedClassic.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedClassic.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/NamedGrid.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class NamedClassic : public NamedGrid { @@ -94,6 +92,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedFromFile.cc metview-5.19.2/mir/src/mir/key/grid/NamedFromFile.cc --- metview-5.17.4/mir/src/mir/key/grid/NamedFromFile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedFromFile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { NamedFromFile::NamedFromFile(const std::string& name) : NamedGrid(name) {} @@ -50,6 +48,4 @@ } -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedFromFile.h metview-5.19.2/mir/src/mir/key/grid/NamedFromFile.h --- metview-5.17.4/mir/src/mir/key/grid/NamedFromFile.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedFromFile.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class NamedFromFile : public NamedGrid, public param::SimpleParametrisation { @@ -94,6 +92,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedGrid.h metview-5.19.2/mir/src/mir/key/grid/NamedGrid.h --- metview-5.17.4/mir/src/mir/key/grid/NamedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/Grid.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class NamedGrid : public Grid { @@ -57,6 +55,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedOctahedral.cc metview-5.19.2/mir/src/mir/key/grid/NamedOctahedral.cc --- metview-5.17.4/mir/src/mir/key/grid/NamedOctahedral.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedOctahedral.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/repres/gauss/reduced/RotatedOctahedral.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { NamedOctahedral::NamedOctahedral(const std::string& name, size_t N) : NamedGrid(name), N_(N) {} @@ -46,6 +44,4 @@ } -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedOctahedral.h metview-5.19.2/mir/src/mir/key/grid/NamedOctahedral.h --- metview-5.17.4/mir/src/mir/key/grid/NamedOctahedral.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedOctahedral.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/NamedGrid.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class NamedOctahedral : public NamedGrid { @@ -94,6 +92,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedORCA.cc metview-5.19.2/mir/src/mir/key/grid/NamedORCA.cc --- metview-5.17.4/mir/src/mir/key/grid/NamedORCA.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedORCA.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { NamedORCA::NamedORCA(const std::string& name) : NamedGrid(name) {} @@ -46,6 +44,4 @@ } -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedORCA.h metview-5.19.2/mir/src/mir/key/grid/NamedORCA.h --- metview-5.17.4/mir/src/mir/key/grid/NamedORCA.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedORCA.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/NamedGrid.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class NamedORCA : public NamedGrid { @@ -93,6 +91,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedRegular.cc metview-5.19.2/mir/src/mir/key/grid/NamedRegular.cc --- metview-5.17.4/mir/src/mir/key/grid/NamedRegular.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedRegular.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/repres/gauss/regular/RotatedGG.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { NamedRegular::NamedRegular(const std::string& name, size_t N) : NamedGrid(name), N_(N) {} @@ -46,6 +44,4 @@ } -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/NamedRegular.h metview-5.19.2/mir/src/mir/key/grid/NamedRegular.h --- metview-5.17.4/mir/src/mir/key/grid/NamedRegular.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/NamedRegular.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/NamedGrid.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class NamedRegular : public NamedGrid { @@ -94,6 +92,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/OctahedralPattern.cc metview-5.19.2/mir/src/mir/key/grid/OctahedralPattern.cc --- metview-5.17.4/mir/src/mir/key/grid/OctahedralPattern.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/OctahedralPattern.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { OctahedralPattern::OctahedralPattern(const std::string& name) : GridPattern(name) {} @@ -49,6 +47,4 @@ static const OctahedralPattern __pattern("^[oO][1-9][0-9]*$"); -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/OctahedralPattern.h metview-5.19.2/mir/src/mir/key/grid/OctahedralPattern.h --- metview-5.17.4/mir/src/mir/key/grid/OctahedralPattern.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/OctahedralPattern.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/GridPattern.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class OctahedralPattern : public GridPattern { @@ -77,6 +75,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/ORCAPattern.cc metview-5.19.2/mir/src/mir/key/grid/ORCAPattern.cc --- metview-5.17.4/mir/src/mir/key/grid/ORCAPattern.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/ORCAPattern.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/key/grid/NamedORCA.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { ORCAPattern::ORCAPattern(const std::string& name) : GridPattern(name) {} @@ -61,6 +59,4 @@ static const ORCAPattern __pattern2("^[eE]?[oO][rR][cC][aA][0-9]+_[tTuUvVwWfF]$"); -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/ORCAPattern.h metview-5.19.2/mir/src/mir/key/grid/ORCAPattern.h --- metview-5.17.4/mir/src/mir/key/grid/ORCAPattern.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/ORCAPattern.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/GridPattern.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class ORCAPattern : public GridPattern { @@ -77,6 +75,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/RegularLL.cc metview-5.19.2/mir/src/mir/key/grid/RegularLL.cc --- metview-5.17.4/mir/src/mir/key/grid/RegularLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/RegularLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { RegularLL::RegularLL(const std::string& key) : Grid(key, regular_ll_t) {} @@ -61,6 +59,4 @@ } -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/RegularLL.h metview-5.19.2/mir/src/mir/key/grid/RegularLL.h --- metview-5.17.4/mir/src/mir/key/grid/RegularLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/RegularLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,16 +14,12 @@ #include "mir/key/grid/Grid.h" -namespace mir { -namespace util { +namespace mir::util { class Increments; -} -} // namespace mir +} // namespace mir::util -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class RegularLL final : public Grid { @@ -84,6 +80,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/RegularLLPattern.cc metview-5.19.2/mir/src/mir/key/grid/RegularLLPattern.cc --- metview-5.17.4/mir/src/mir/key/grid/RegularLLPattern.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/RegularLLPattern.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { RegularLLPattern::RegularLLPattern(const std::string& name) : GridPattern(name) {} @@ -59,6 +57,4 @@ #undef fp -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/RegularLLPattern.h metview-5.19.2/mir/src/mir/key/grid/RegularLLPattern.h --- metview-5.17.4/mir/src/mir/key/grid/RegularLLPattern.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/RegularLLPattern.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/GridPattern.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class RegularLLPattern : public GridPattern { @@ -77,6 +75,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/RegularPattern.cc metview-5.19.2/mir/src/mir/key/grid/RegularPattern.cc --- metview-5.17.4/mir/src/mir/key/grid/RegularPattern.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/RegularPattern.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { RegularPattern::RegularPattern(const std::string& name) : GridPattern(name) {} @@ -50,6 +48,4 @@ static const RegularPattern __pattern("^[fF][1-9][0-9]*$"); -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/RegularPattern.h metview-5.19.2/mir/src/mir/key/grid/RegularPattern.h --- metview-5.17.4/mir/src/mir/key/grid/RegularPattern.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/RegularPattern.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/grid/GridPattern.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class RegularPattern : public GridPattern { @@ -77,6 +75,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/TypedGrid.cc metview-5.19.2/mir/src/mir/key/grid/TypedGrid.cc --- metview-5.17.4/mir/src/mir/key/grid/TypedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/TypedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,9 +26,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { TypedGrid::TypedGrid(const std::string& key, const std::set& requiredKeys, @@ -131,10 +129,10 @@ ~TypedGenericPattern() override = default; - TypedGenericPattern(const TypedGenericPattern&) = delete; - TypedGenericPattern(TypedGenericPattern&&) = delete; + TypedGenericPattern(const TypedGenericPattern&) = delete; + TypedGenericPattern(TypedGenericPattern&&) = delete; TypedGenericPattern& operator=(const TypedGenericPattern&) = delete; - TypedGenericPattern& operator=(TypedGenericPattern&&) = delete; + TypedGenericPattern& operator=(TypedGenericPattern&&) = delete; const Grid* make(const std::string& name) const override { return new TYPE(name, requiredKeys_, optionalKeys_); } @@ -181,6 +179,4 @@ {"gaussianNumber", "shapeOfTheEarth", "radius", "earthMajorAxis", "earthMinorAxis"}); -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/grid/TypedGrid.h metview-5.19.2/mir/src/mir/key/grid/TypedGrid.h --- metview-5.17.4/mir/src/mir/key/grid/TypedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/grid/TypedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/key/grid/Grid.h" -namespace mir { -namespace key { -namespace grid { +namespace mir::key::grid { class TypedGrid : public Grid { @@ -95,6 +93,4 @@ }; -} // namespace grid -} // namespace key -} // namespace mir +} // namespace mir::key::grid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/Automatic.cc metview-5.19.2/mir/src/mir/key/intgrid/Automatic.cc --- metview-5.17.4/mir/src/mir/key/intgrid/Automatic.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/Automatic.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/key/intgrid/Automatic.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { static const IntgridBuilder __intgrid1("automatic"); @@ -36,6 +34,4 @@ } -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/Automatic.h metview-5.19.2/mir/src/mir/key/intgrid/Automatic.h --- metview-5.17.4/mir/src/mir/key/intgrid/Automatic.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/Automatic.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/intgrid/Intgrid.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { class Automatic : public Intgrid { @@ -73,6 +71,4 @@ }; -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/Intgrid.cc metview-5.19.2/mir/src/mir/key/intgrid/Intgrid.cc --- metview-5.17.4/mir/src/mir/key/intgrid/Intgrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/Intgrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { static util::once_flag once; @@ -98,6 +96,4 @@ } -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/Intgrid.h metview-5.19.2/mir/src/mir/key/intgrid/Intgrid.h --- metview-5.17.4/mir/src/mir/key/intgrid/Intgrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/Intgrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,16 +16,12 @@ #include -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { class Intgrid { @@ -105,7 +101,7 @@ std::string name_; virtual Intgrid* make(const param::MIRParametrisation&, long targetGaussianN) = 0; - IntgridFactory(const IntgridFactory&) = delete; + IntgridFactory(const IntgridFactory&) = delete; IntgridFactory& operator=(const IntgridFactory&) = delete; protected: @@ -129,6 +125,4 @@ }; -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/NamedGrid.cc metview-5.19.2/mir/src/mir/key/intgrid/NamedGrid.cc --- metview-5.17.4/mir/src/mir/key/intgrid/NamedGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/NamedGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { NamedGrid::NamedGrid(const std::string& gridname, const param::MIRParametrisation& parametrisation) : @@ -31,6 +29,4 @@ } -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/NamedGrid.h metview-5.19.2/mir/src/mir/key/intgrid/NamedGrid.h --- metview-5.17.4/mir/src/mir/key/intgrid/NamedGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/NamedGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/intgrid/Intgrid.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { class NamedGrid : public Intgrid { @@ -73,6 +71,4 @@ }; -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/None.cc metview-5.19.2/mir/src/mir/key/intgrid/None.cc --- metview-5.17.4/mir/src/mir/key/intgrid/None.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/None.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/key/intgrid/None.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { static const IntgridBuilder __intgrid1("none"); @@ -31,6 +29,4 @@ } -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/None.h metview-5.19.2/mir/src/mir/key/intgrid/None.h --- metview-5.17.4/mir/src/mir/key/intgrid/None.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/None.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/intgrid/Intgrid.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { class None : public Intgrid { @@ -72,6 +70,4 @@ }; -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/Source.cc metview-5.19.2/mir/src/mir/key/intgrid/Source.cc --- metview-5.17.4/mir/src/mir/key/intgrid/Source.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/Source.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/SpectralOrder.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { static const IntgridBuilder __intgrid1("source"); @@ -51,6 +49,4 @@ } -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/intgrid/Source.h metview-5.19.2/mir/src/mir/key/intgrid/Source.h --- metview-5.17.4/mir/src/mir/key/intgrid/Source.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/intgrid/Source.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/intgrid/Intgrid.h" -namespace mir { -namespace key { -namespace intgrid { +namespace mir::key::intgrid { class Source : public Intgrid { @@ -73,6 +71,4 @@ }; -} // namespace intgrid -} // namespace key -} // namespace mir +} // namespace mir::key::intgrid diff -Nru metview-5.17.4/mir/src/mir/key/Key.cc metview-5.19.2/mir/src/mir/key/Key.cc --- metview-5.17.4/mir/src/mir/key/Key.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/Key.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/param/MIRParametrisation.h" -namespace mir { -namespace key { +namespace mir::key { bool Key::postProcess(const param::MIRParametrisation& param) { @@ -37,5 +36,4 @@ } -} // namespace key -} // namespace mir +} // namespace mir::key diff -Nru metview-5.17.4/mir/src/mir/key/Key.h metview-5.19.2/mir/src/mir/key/Key.h --- metview-5.17.4/mir/src/mir/key/Key.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/Key.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,15 +13,12 @@ #pragma once -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace key { +namespace mir::key { class Key { @@ -94,5 +91,4 @@ }; -} // namespace key -} // namespace mir +} // namespace mir::key diff -Nru metview-5.17.4/mir/src/mir/key/packing/ArchivedValue.cc metview-5.19.2/mir/src/mir/key/packing/ArchivedValue.cc --- metview-5.17.4/mir/src/mir/key/packing/ArchivedValue.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/ArchivedValue.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/key/packing/ArchivedValue.h" - -#include "mir/util/Exceptions.h" - - -namespace mir { -namespace key { -namespace packing { - - -static const PackingBuilder __packing("archived-value", "av", true, true); - - -ArchivedValue::ArchivedValue(const std::string& name, const param::MIRParametrisation& param) : Packing(name, param) { - ASSERT(!definePacking_); -} - - -void ArchivedValue::fill(const repres::Representation* /*unused*/, grib_info& info) const { - Packing::fill(info, 0 /* dummy, protected by ASSERT */); -} - - -void ArchivedValue::set(const repres::Representation* /*unused*/, grib_handle* handle) const { - Packing::set(handle, "" /* dummy, protected by ASSERT */); -} - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/ArchivedValue.h metview-5.19.2/mir/src/mir/key/packing/ArchivedValue.h --- metview-5.17.4/mir/src/mir/key/packing/ArchivedValue.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/ArchivedValue.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include "mir/key/packing/Packing.h" - - -namespace mir { -namespace key { -namespace packing { - - -class ArchivedValue : public Packing { -public: - // -- Types - // None - - // -- Exceptions - // None - - // -- Constructors - - ArchivedValue(const std::string&, const param::MIRParametrisation&); - - // -- Destructor - // None - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - // None - - // -- Methods - - void fill(const repres::Representation*, grib_info&) const override; - void set(const repres::Representation*, grib_handle*) const override; - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - // None -}; - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/CCSDS.cc metview-5.19.2/mir/src/mir/key/packing/CCSDS.cc --- metview-5.17.4/mir/src/mir/key/packing/CCSDS.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/CCSDS.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/key/packing/CCSDS.h" - -#include "mir/util/Exceptions.h" -#include "mir/util/Grib.h" -#include "mir/util/Log.h" - - -namespace mir { -namespace key { -namespace packing { - - -static const PackingBuilder __packing("ccsds", false, true); - - -CCSDS::CCSDS(const std::string& name, const param::MIRParametrisation& param) : Packing(name, param) { - if (!gridded()) { - std::string msg = "packing=ccsds: only supports gridded fields"; - Log::error() << msg << std::endl; - throw exception::UserError(msg); - } - requireEdition(param, 2); -} - - -void CCSDS::fill(const repres::Representation* /*unused*/, grib_info& info) const { - Packing::fill(info, CODES_UTIL_PACKING_TYPE_CCSDS); -} - - -void CCSDS::set(const repres::Representation* /*unused*/, grib_handle* handle) const { - Packing::set(handle, "grid_ccsds"); -} - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/CCSDS.h metview-5.19.2/mir/src/mir/key/packing/CCSDS.h --- metview-5.17.4/mir/src/mir/key/packing/CCSDS.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/CCSDS.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include "mir/key/packing/Packing.h" - - -namespace mir { -namespace key { -namespace packing { - - -class CCSDS : public Packing { -public: - // -- Types - // None - - // -- Exceptions - // None - - // -- Constructors - - CCSDS(const std::string&, const param::MIRParametrisation&); - - // -- Destructor - // None - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - - void fill(const repres::Representation*, grib_info&) const override; - void set(const repres::Representation*, grib_handle*) const override; - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - // None -}; - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/Complex.cc metview-5.19.2/mir/src/mir/key/packing/Complex.cc --- metview-5.17.4/mir/src/mir/key/packing/Complex.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/Complex.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/key/packing/Complex.h" - -#include "mir/util/Grib.h" - - -namespace mir { -namespace key { -namespace packing { - - -static const PackingBuilder __packing("complex", "co", true, true); - - -Complex::Complex(const std::string& name, const param::MIRParametrisation& param) : Packing(name, param) { - if (gridded()) { - requireEdition(param, 2); - } -} - - -void Complex::fill(const repres::Representation* /*unused*/, grib_info& info) const { - Packing::fill(info, gridded() ? CODES_UTIL_PACKING_TYPE_GRID_COMPLEX : CODES_UTIL_PACKING_TYPE_SPECTRAL_COMPLEX); -} - - -void Complex::set(const repres::Representation* /*unused*/, grib_handle* handle) const { - Packing::set(handle, gridded() ? "grid_complex" : "spectral_complex"); -} - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/Complex.h metview-5.19.2/mir/src/mir/key/packing/Complex.h --- metview-5.17.4/mir/src/mir/key/packing/Complex.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/Complex.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include "mir/key/packing/Packing.h" - - -namespace mir { -namespace key { -namespace packing { - - -class Complex : public Packing { -public: - // -- Types - // None - - // -- Exceptions - // None - - // -- Constructors - - Complex(const std::string&, const param::MIRParametrisation&); - - // -- Destructor - // None - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - - void fill(const repres::Representation*, grib_info&) const override; - void set(const repres::Representation*, grib_handle*) const override; - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - // None -}; - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/IEEE.cc metview-5.19.2/mir/src/mir/key/packing/IEEE.cc --- metview-5.17.4/mir/src/mir/key/packing/IEEE.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/IEEE.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/key/packing/IEEE.h" - -#include "mir/param/MIRParametrisation.h" -#include "mir/util/Exceptions.h" -#include "mir/util/Grib.h" -#include "mir/util/Log.h" - - -namespace mir { -namespace key { -namespace packing { - - -static const PackingBuilder __packing("ieee", true, true); - - -IEEE::IEEE(const std::string& name, const param::MIRParametrisation& param) : Packing(name, param) { - const auto& user = param.userParametrisation(); - const auto& field = param.fieldParametrisation(); - - constexpr long L32 = 32; - constexpr long L64 = 64; - constexpr long L128 = 128; - - // Accuracy set by user, otherwise by field (rounded up to a supported precision) - long bits = L32; - field.get("accuracy", bits); - - if (!user.get("accuracy", accuracy_)) { - accuracy_ = bits <= L32 ? L32 : bits <= L64 ? L64 : L128; - } - - definePrecision_ = accuracy_ != bits || definePacking_ || !field.has("accuracy"); - precision_ = accuracy_ == L32 ? 1 : accuracy_ == L64 ? 2 : accuracy_ == L128 ? 3 : 0; - - if (precision_ == 0) { - std::string msg = "packing=ieee: only supports accuracy=32, 64 and 128"; - Log::error() << msg << std::endl; - throw exception::UserError(msg); - } - - if (gridded()) { - requireEdition(param, 2); - } -} - - -void IEEE::fill(const repres::Representation* /*unused*/, grib_info& info) const { - info.packing.packing = CODES_UTIL_PACKING_SAME_AS_INPUT; - // (Representation can set edition, so it isn't reset) - - if (definePacking_) { - info.packing.packing = CODES_UTIL_PACKING_USE_PROVIDED; - info.packing.packing_type = CODES_UTIL_PACKING_TYPE_IEEE; - } - - if (defineEdition_) { - info.packing.editionNumber = edition_; - } - - if (definePrecision_) { - info.extra_set("precision", precision_); - } -} - - -void IEEE::set(const repres::Representation* /*unused*/, grib_handle* handle) const { - Packing::set(handle, gridded() ? "grid_ieee" : "spectral_ieee"); - - if (definePrecision_) { - GRIB_CALL(codes_set_long(handle, "precision", precision_)); - } -} - - -bool IEEE::printParametrisation(std::ostream& out) const { - const auto* sep = Packing::printParametrisation(out) ? "," : ""; - if (definePrecision_) { - out << sep << "precision=" << precision_; - } - return true; -} - - -bool IEEE::empty() const { - return Packing::empty() && !definePrecision_; -} - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/IEEE.h metview-5.19.2/mir/src/mir/key/packing/IEEE.h --- metview-5.17.4/mir/src/mir/key/packing/IEEE.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/IEEE.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include "mir/key/packing/Packing.h" - - -namespace mir { -namespace key { -namespace packing { - - -class IEEE : public Packing { -public: - // -- Types - // None - - // -- Exceptions - // None - - // -- Constructors - - IEEE(const std::string&, const param::MIRParametrisation&); - - // -- Destructor - // None - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - - long precision_; - bool definePrecision_; - - // -- Methods - // None - - // -- Overridden methods - - void fill(const repres::Representation*, grib_info&) const override; - void set(const repres::Representation*, grib_handle*) const override; - bool printParametrisation(std::ostream&) const override; - bool empty() const override; - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - // None -}; - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/JPEG2000.cc metview-5.19.2/mir/src/mir/key/packing/JPEG2000.cc --- metview-5.17.4/mir/src/mir/key/packing/JPEG2000.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/JPEG2000.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/key/packing/JPEG2000.h" - -#include "mir/util/Grib.h" - - -namespace mir { -namespace key { -namespace packing { - - -static const PackingBuilder __packing("jpeg", false, true); - - -void JPEG2000::fill(const repres::Representation* /*unused*/, grib_info& info) const { - Packing::fill(info, CODES_UTIL_PACKING_TYPE_JPEG); -} - - -void JPEG2000::set(const repres::Representation* /*unused*/, grib_handle* handle) const { - Packing::set(handle, "grid_jpeg"); -} - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/JPEG2000.h metview-5.19.2/mir/src/mir/key/packing/JPEG2000.h --- metview-5.17.4/mir/src/mir/key/packing/JPEG2000.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/JPEG2000.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include "mir/key/packing/Packing.h" - - -namespace mir { -namespace key { -namespace packing { - - -class JPEG2000 : public Packing { -public: - // -- Types - // None - - // -- Exceptions - // None - - // -- Constructors - - using Packing::Packing; - - // -- Destructor - // None - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - - void fill(const repres::Representation*, grib_info&) const override; - void set(const repres::Representation*, grib_handle*) const override; - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - // None -}; - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/Packing.cc metview-5.19.2/mir/src/mir/key/packing/Packing.cc --- metview-5.17.4/mir/src/mir/key/packing/Packing.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/Packing.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,273 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/key/packing/Packing.h" - -#include -#include -#include - -#include "mir/param/MIRParametrisation.h" -#include "mir/util/Exceptions.h" -#include "mir/util/Grib.h" -#include "mir/util/Log.h" -#include "mir/util/Mutex.h" - - -namespace mir { -namespace key { -namespace packing { - - -static util::once_flag once; -static util::recursive_mutex* local_mutex = nullptr; -static std::map* ms = nullptr; -static std::map* mg = nullptr; -static void init() { - local_mutex = new util::recursive_mutex(); - ms = new std::map(); - mg = new std::map(); -} - - -Packing::Packing(const std::string& name, const param::MIRParametrisation& param) : - gridded_(param.userParametrisation().has("grid") || param.fieldParametrisation().has("gridded")) { - const auto& user = param.userParametrisation(); - const auto& field = param.fieldParametrisation(); - - ASSERT(!name.empty()); - packing_ = name; - std::string packing; - - bool gridded = false; - field.get("gridded", gridded); - - definePacking_ = !field.get("packing", packing) || packing_ != packing || gridded_ != gridded; - defineAccuracyBeforePacking_ = definePacking_ && packing == "ieee"; - - defineAccuracy_ = false; - if (defineAccuracyBeforePacking_) { - ASSERT(param.get("accuracy", accuracy_)); - defineAccuracy_ = true; - } - else if (user.get("accuracy", accuracy_)) { - long accuracy; - defineAccuracy_ = !field.get("accuracy", accuracy) || accuracy_ != accuracy; - } - - defineEdition_ = false; - if (user.get("edition", edition_)) { - long edition; - defineEdition_ = !field.get("edition", edition) || edition_ != edition; - } -} - - -Packing::~Packing() = default; - - -bool Packing::sameAs(const Packing* other) const { - if (definePacking_ != other->definePacking_ || defineAccuracy_ != other->defineAccuracy_ || - defineEdition_ != other->defineEdition_) { - return false; - } - bool samePacking = !definePacking_ || packing_ == other->packing_; - bool sameAccuracy = !defineAccuracy_ || accuracy_ == other->accuracy_; - bool sameEdition = !defineEdition_ || edition_ == other->edition_; - return samePacking && sameAccuracy && sameEdition; -} - - -bool Packing::printParametrisation(std::ostream& out) const { - std::string sep; - - if (definePacking_) { - out << sep << "packing=" << packing_; - sep = ","; - } - - if (defineEdition_) { - out << sep << "edition=" << edition_; - sep = ","; - } - - if (defineAccuracy_) { - out << sep << "accuracy=" << accuracy_; - sep = ","; - } - - return !sep.empty(); -} - - -bool Packing::empty() const { - return !definePacking_ && !defineAccuracy_ && !defineEdition_; -} - - -void Packing::requireEdition(const param::MIRParametrisation& param, long edition) { - // Define edition if not specified - if (defineEdition_) { - ASSERT(edition_ == edition); - return; - } - - if (!param.fieldParametrisation().get("edition", edition_) || edition_ != edition) { - edition_ = edition; - defineEdition_ = true; - } -} - - -void Packing::fill(grib_info& info, long pack) const { - info.packing.packing = CODES_UTIL_PACKING_SAME_AS_INPUT; - info.packing.accuracy = CODES_UTIL_ACCURACY_SAME_BITS_PER_VALUES_AS_INPUT; - // (Representation can set edition, so it isn't reset) - - if (definePacking_) { - info.packing.packing = CODES_UTIL_PACKING_USE_PROVIDED; - info.packing.packing_type = pack; - } - - if (defineAccuracy_) { - info.packing.accuracy = CODES_UTIL_ACCURACY_USE_PROVIDED_BITS_PER_VALUES; - info.packing.bitsPerValue = accuracy_; - } - - if (defineEdition_) { - info.packing.editionNumber = edition_; - } -} - - -void Packing::set(grib_handle* h, const std::string& type) const { - // Note: order is important, it is not applicable to all packing's. - - if (defineEdition_) { - GRIB_CALL(codes_set_long(h, "edition", edition_)); - } - - if (defineAccuracyBeforePacking_) { - GRIB_CALL(codes_set_long(h, "bitsPerValue", accuracy_)); - } - - if (definePacking_) { - auto len = type.length(); - GRIB_CALL(codes_set_string(h, "packingType", type.c_str(), &len)); - } - - if (defineAccuracy_) { - GRIB_CALL(codes_set_long(h, "bitsPerValue", accuracy_)); - } -} - - -PackingFactory::PackingFactory(const std::string& name, const std::string& alias, bool spectral, bool gridded) : - name_(name) { - util::call_once(once, init); - util::lock_guard lock(*local_mutex); - - ASSERT(gridded || spectral); - - if (gridded) { - ASSERT_MSG(mg->insert({name, this}).second, "PackingFactory: duplicate gridded packing"); - if (!alias.empty()) { - ASSERT_MSG(mg->insert({alias, this}).second, "PackingFactory: duplicate gridded packing"); - } - } - - if (spectral) { - ASSERT_MSG(ms->insert({name, this}).second, "PackingFactory: duplicate spectral packing"); - if (!alias.empty()) { - ASSERT_MSG(ms->insert({alias, this}).second, "PackingFactory: duplicate spectral packing"); - } - } -} - - -PackingFactory::~PackingFactory() { - util::lock_guard lock(*local_mutex); - - mg->erase(name_); - ms->erase(name_); -} - - -Packing* PackingFactory::build(const param::MIRParametrisation& param) { - util::call_once(once, init); - util::lock_guard lock(*local_mutex); - - const auto& user = param.userParametrisation(); - const auto& field = param.fieldParametrisation(); - - - // When converting from spectral to gridded, default to simple packing - std::string name = user.has("grid") && field.has("spectral") ? "simple" : "av"; - user.get("packing", name); - - - // When converting formats, field packing needs a sensible default - std::string packing = field.has("spectral") ? "complex" : "simple"; - field.get("packing", packing); - - - bool av = name == "av" || name == "archived-value"; - bool gridded = user.has("grid") || field.has("gridded"); - std::string t = gridded ? "gridded" : "spectral"; - const auto& m = gridded ? *mg : *ms; - - - // In case of packing=av, try instantiating specific packing - if (av) { - auto j = m.find(packing); - if (j != m.end()) { - return j->second->make(packing, param); - } - } - - auto j = m.find(name); - if (j != m.end()) { - return j->second->make(av ? packing : j->second->name_, param); - } - - Log::error() << "PackingFactory: unknown " << t << " packing '" << name << "', choices are: "; - for (const auto& j : m) { - Log::error() << ", " << j.first; - } - - throw exception::SeriousBug("PackingFactory: unknown " + t + " packing '" + name + "'"); -} - - -void PackingFactory::list(std::ostream& out) { - util::call_once(once, init); - util::lock_guard lock(*local_mutex); - - std::set p; - for (const auto& j : *ms) { - p.insert(j.first); - } - for (const auto& j : *mg) { - p.insert(j.first); - } - - const char* sep = ""; - for (const auto& j : p) { - out << sep << j; - sep = ", "; - } -} - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/Packing.h metview-5.19.2/mir/src/mir/key/packing/Packing.h --- metview-5.17.4/mir/src/mir/key/packing/Packing.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/Packing.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include -#include - - -struct grib_handle; -struct grib_info; - -namespace mir { -namespace param { -class MIRParametrisation; -} -namespace repres { -class Representation; -} -} // namespace mir - - -namespace mir { -namespace key { -namespace packing { - - -class Packing { -public: - // -- Exceptions - // None - - // -- Constructors - - Packing(const std::string& name, const param::MIRParametrisation&); - - // -- Destructor - - virtual ~Packing(); - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - - virtual void fill(const repres::Representation*, grib_info&) const = 0; - virtual void set(const repres::Representation*, grib_handle*) const = 0; - - virtual bool sameAs(const Packing*) const; - virtual bool printParametrisation(std::ostream&) const; - - virtual bool empty() const; - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Constructors - - Packing(const Packing&) = delete; - - // -- Operators - - void operator=(const Packing&) = delete; - - // -- Members - - long accuracy_; - long edition_; - std::string packing_; - - bool defineAccuracy_; - bool defineAccuracyBeforePacking_; - bool defineEdition_; - bool definePacking_; - - // -- Methods - - bool gridded() const { return gridded_; } - void requireEdition(const param::MIRParametrisation&, long); - - void fill(grib_info&, long) const; - void set(grib_handle*, const std::string&) const; - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - - const bool gridded_; - - // -- Methods - // None - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - // None -}; - - -class PackingFactory { - std::string name_; - - virtual Packing* make(const std::string& name, const param::MIRParametrisation&) = 0; - - PackingFactory(const PackingFactory&) = delete; - PackingFactory& operator=(const PackingFactory&) = delete; - -protected: - PackingFactory(const std::string&, const std::string&, bool spectral, bool gridded); - virtual ~PackingFactory(); - -public: - static Packing* build(const param::MIRParametrisation&); - static void list(std::ostream&); -}; - - -template -class PackingBuilder : public PackingFactory { - Packing* make(const std::string& name, const param::MIRParametrisation& param) override { - return new T(name, param); - } - -public: - PackingBuilder(const std::string& name, bool spectral, bool gridded) : - PackingFactory(name, "", spectral, gridded) {} - PackingBuilder(const std::string& name, const std::string& alias, bool spectral, bool gridded) : - PackingFactory(name, alias, spectral, gridded) {} -}; - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/SecondOrder.cc metview-5.19.2/mir/src/mir/key/packing/SecondOrder.cc --- metview-5.17.4/mir/src/mir/key/packing/SecondOrder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/SecondOrder.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/key/packing/SecondOrder.h" - -#include "mir/repres/Representation.h" -#include "mir/util/Exceptions.h" -#include "mir/util/Grib.h" -#include "mir/util/Log.h" - - -namespace mir { -namespace key { -namespace packing { - - -static const PackingBuilder __packing("second-order", "so", false, true); - - -static bool check(const repres::Representation* repres) { - ASSERT(repres != nullptr); - - auto n = repres->numberOfPoints(); - if (n < 4) { - Log::warning() << "packing=second-order: does not support less than 4 values, using packing=simple" - << std::endl; - return false; - } - return true; -} - - -SecondOrder::SecondOrder(const std::string& name, const param::MIRParametrisation& param) : - Packing(name, param), simple_(name, param) {} - - -void SecondOrder::fill(const repres::Representation* repres, grib_info& info) const { - if (!check(repres)) { - simple_.fill(repres, info); - return; - } - - Packing::fill(info, CODES_UTIL_PACKING_TYPE_GRID_SECOND_ORDER); -} - - -void SecondOrder::set(const repres::Representation* repres, grib_handle* handle) const { - if (!check(repres)) { - simple_.set(repres, handle); - return; - } - - Packing::set(handle, "grid_second_order"); -} - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/SecondOrder.h metview-5.19.2/mir/src/mir/key/packing/SecondOrder.h --- metview-5.17.4/mir/src/mir/key/packing/SecondOrder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/SecondOrder.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include "mir/key/packing/Packing.h" -#include "mir/key/packing/Simple.h" - - -namespace mir { -namespace key { -namespace packing { - - -class SecondOrder : public Packing { -public: - // -- Types - // None - - // -- Exceptions - // None - - // -- Constructors - - SecondOrder(const std::string& name, const param::MIRParametrisation&); - - // -- Destructor - // None - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - - Simple simple_; - - // -- Methods - // None - - // -- Overridden methods - - void fill(const repres::Representation*, grib_info&) const override; - void set(const repres::Representation*, grib_handle*) const override; - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - // None -}; - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/Simple.cc metview-5.19.2/mir/src/mir/key/packing/Simple.cc --- metview-5.17.4/mir/src/mir/key/packing/Simple.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/Simple.cc 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#include "mir/key/packing/Simple.h" - -#include "mir/util/Grib.h" - - -namespace mir { -namespace key { -namespace packing { - - -static const PackingBuilder __packing("simple", true, true); - - -void Simple::fill(const repres::Representation* /*unused*/, grib_info& info) const { - Packing::fill(info, gridded() ? CODES_UTIL_PACKING_TYPE_GRID_SIMPLE : CODES_UTIL_PACKING_TYPE_SPECTRAL_SIMPLE); -} - - -void Simple::set(const repres::Representation* /*unused*/, grib_handle* handle) const { - Packing::set(handle, gridded() ? "grid_simple" : "spectral_simple"); -} - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/packing/Simple.h metview-5.19.2/mir/src/mir/key/packing/Simple.h --- metview-5.17.4/mir/src/mir/key/packing/Simple.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/packing/Simple.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -/* - * (C) Copyright 1996- 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. - */ - - -#pragma once - -#include "mir/key/packing/Packing.h" - - -namespace mir { -namespace key { -namespace packing { -class SecondOrder; -} -} // namespace key -} // namespace mir - - -namespace mir { -namespace key { -namespace packing { - - -class Simple : public Packing { -public: - // -- Types - // None - - // -- Exceptions - // None - - // -- Constructors - - using Packing::Packing; - - // -- Destructor - // None - - // -- Convertors - // None - - // -- Operators - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - -private: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - - void fill(const repres::Representation*, grib_info&) const override; - void set(const repres::Representation*, grib_handle*) const override; - - // -- Class members - // None - - // -- Class methods - // None - - // -- Friends - - friend class SecondOrder; -}; - - -} // namespace packing -} // namespace key -} // namespace mir diff -Nru metview-5.17.4/mir/src/mir/key/resol/Resol.cc metview-5.19.2/mir/src/mir/key/resol/Resol.cc --- metview-5.17.4/mir/src/mir/key/resol/Resol.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/resol/Resol.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,17 +27,17 @@ #include "mir/util/SpectralOrder.h" -namespace mir { -namespace key { -namespace resol { +namespace mir::key::resol { Resol::Resol(const param::MIRParametrisation& parametrisation, bool forceNoIntermediateGrid) : parametrisation_(parametrisation) { + bool spectral = false; + ASSERT(parametrisation_.fieldParametrisation().get("spectral", spectral) && spectral); // Get input truncation and a Gaussian grid number based on input (truncation) and output (grid) inputTruncation_ = 0; - ASSERT(parametrisation_.fieldParametrisation().get("spectral", inputTruncation_)); + ASSERT(parametrisation_.fieldParametrisation().get("truncation", inputTruncation_)); ASSERT(inputTruncation_ > 0); long N = std::min(getTargetGaussianNumber(), getSourceGaussianNumber()); @@ -46,7 +46,7 @@ // Setup intermediate grid (before truncation) // NOTE: truncation can depend on the intermediate grid Gaussian number if (forceNoIntermediateGrid) { - intgrid_.reset(new intgrid::None(parametrisation_, N)); + intgrid_ = std::make_unique(parametrisation_, N); } else { std::string intgrid = "automatic"; @@ -65,7 +65,7 @@ // NOTE: number takes priority over possible names long T = 0; if (parametrisation_.userParametrisation().get("truncation", T) && T > 0) { - truncation_.reset(new truncation::Ordinal(T, parametrisation_)); + truncation_ = std::make_unique(T, parametrisation_); } else { std::string name = "automatic"; @@ -85,12 +85,15 @@ plan.add("filter.sh-truncate", "truncation", T); } - // filter - bool cesaro; - if (parametrisation_.get("cesaro", cesaro)) { + // filter(s) + if (parametrisation_.userParametrisation().has("cesaro")) { plan.add("filter.sh-cesaro-summation-filter"); } + if (parametrisation_.userParametrisation().has("bandpass")) { + plan.add("filter.sh-bandpass"); + } + // transform, if specified const std::string grid = intgrid_->gridname(); if (!grid.empty()) { @@ -174,6 +177,4 @@ } -} // namespace resol -} // namespace key -} // namespace mir +} // namespace mir::key::resol diff -Nru metview-5.17.4/mir/src/mir/key/resol/Resol.h metview-5.19.2/mir/src/mir/key/resol/Resol.h --- metview-5.17.4/mir/src/mir/key/resol/Resol.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/resol/Resol.h 2023-07-15 08:28:47.000000000 +0000 @@ -30,9 +30,7 @@ } // namespace mir -namespace mir { -namespace key { -namespace resol { +namespace mir::key::resol { class Resol { @@ -119,6 +117,4 @@ }; -} // namespace resol -} // namespace key -} // namespace mir +} // namespace mir::key::resol diff -Nru metview-5.17.4/mir/src/mir/key/style/CustomParametrisation.cc metview-5.19.2/mir/src/mir/key/style/CustomParametrisation.cc --- metview-5.17.4/mir/src/mir/key/style/CustomParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/style/CustomParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace key { -namespace style { +namespace mir::key::style { CustomParametrisation::CustomParametrisation(const std::string& name, @@ -168,6 +166,4 @@ } -} // namespace style -} // namespace key -} // namespace mir +} // namespace mir::key::style diff -Nru metview-5.17.4/mir/src/mir/key/style/CustomParametrisation.h metview-5.19.2/mir/src/mir/key/style/CustomParametrisation.h --- metview-5.17.4/mir/src/mir/key/style/CustomParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/style/CustomParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/param/MIRParametrisation.h" -namespace mir { -namespace key { -namespace style { +namespace mir::key::style { class CustomParametrisation : public param::MIRParametrisation { @@ -117,6 +115,4 @@ }; -} // namespace style -} // namespace key -} // namespace mir +} // namespace mir::key::style diff -Nru metview-5.17.4/mir/src/mir/key/style/CustomStyle.cc metview-5.19.2/mir/src/mir/key/style/CustomStyle.cc --- metview-5.17.4/mir/src/mir/key/style/CustomStyle.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/style/CustomStyle.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/PlanParser.h" -namespace mir { -namespace key { -namespace style { +namespace mir::key::style { void parse(std::istream& str, action::ActionPlan& plan, const param::MIRParametrisation& parametrisation, @@ -76,6 +74,4 @@ static const MIRStyleBuilder __style("custom"); -} // namespace style -} // namespace key -} // namespace mir +} // namespace mir::key::style diff -Nru metview-5.17.4/mir/src/mir/key/style/CustomStyle.h metview-5.19.2/mir/src/mir/key/style/CustomStyle.h --- metview-5.17.4/mir/src/mir/key/style/CustomStyle.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/style/CustomStyle.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/style/MIRStyle.h" -namespace mir { -namespace key { -namespace style { +namespace mir::key::style { class CustomStyle : public MIRStyle { @@ -90,6 +88,4 @@ }; -} // namespace style -} // namespace key -} // namespace mir +} // namespace mir::key::style diff -Nru metview-5.17.4/mir/src/mir/key/style/ECMWFStyle.cc metview-5.19.2/mir/src/mir/key/style/ECMWFStyle.cc --- metview-5.17.4/mir/src/mir/key/style/ECMWFStyle.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/style/ECMWFStyle.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,31 +20,32 @@ #include "eckit/utils/StringTools.h" #include "mir/action/plan/ActionPlan.h" +#include "mir/key/Area.h" #include "mir/key/grid/Grid.h" #include "mir/key/resol/Resol.h" #include "mir/output/MIROutput.h" #include "mir/param/MIRParametrisation.h" #include "mir/param/SameParametrisation.h" #include "mir/repres/latlon/LatLon.h" +#include "mir/util/BoundingBox.h" #include "mir/util/DeprecatedFunctionality.h" #include "mir/util/Exceptions.h" #include "mir/util/Types.h" -namespace mir { -namespace key { -namespace style { - - -namespace { +namespace mir::key::style { struct DeprecatedStyle : ECMWFStyle, util::DeprecatedFunctionality { - DeprecatedStyle(const param::MIRParametrisation& p) : + explicit DeprecatedStyle(const param::MIRParametrisation& p) : ECMWFStyle(p), util::DeprecatedFunctionality("style 'dissemination' now known as 'ecmwf'") {} }; +static const MIRStyleBuilder __style("ecmwf"); +static const MIRStyleBuilder __deprecated_style("dissemination"); + + bool option(const param::MIRParametrisation& param, const std::string& key, bool dfault) { bool value = dfault; param.get(key, value); @@ -52,12 +53,43 @@ }; -} // namespace +bool same_points(const param::MIRParametrisation& user, const param::MIRParametrisation& field) { + std::unique_ptr same(new param::SameParametrisation(user, field, true)); + std::vector rotation; + if (user.has("rotation") && !same->get("rotation", rotation)) { + return false; + } -static const MIRStyleBuilder __style("ecmwf"); + std::vector grid; + if (user.has("grid") && !same->get("grid", grid)) { + return false; + } -static const MIRStyleBuilder __deprecated_style("dissemination"); + util::BoundingBox bboxUser; + if (Area::get(user, bboxUser)) { + util::Increments inc(field); + size_t ni = 0; + size_t nj = 0; + + repres::latlon::LatLon::correctBoundingBox(bboxUser, ni, nj, inc, {bboxUser.south(), bboxUser.west()}); + + util::BoundingBox bboxField(field); + repres::latlon::LatLon::correctBoundingBox(bboxField, ni, nj, inc, {bboxField.south(), bboxField.west()}); + + PointLatLon ref{bboxField.south(), bboxField.west()}; + + for (const auto& lat : {bboxUser.south(), bboxUser.north()}) { + for (const auto& lon : {bboxUser.east(), bboxUser.west()}) { + if (inc.isShifted({ref.lat() - lat, ref.lon() - lon})) { + return false; + } + } + } + } + + return true; +} static std::string target_gridded_from_parametrisation(const param::MIRParametrisation& param, bool checkRotation) { @@ -65,6 +97,12 @@ const auto& field = param.fieldParametrisation(); std::unique_ptr same(new param::SameParametrisation(user, field, true)); + std::string interpolation; + user.get("interpolation", interpolation); + if (interpolation == "none") { + return ""; + } + std::vector rotation; const bool rotated = checkRotation && user.has("rotation") && !same->get("rotation", rotation); @@ -80,9 +118,7 @@ if (g.isRegularLL()) { std::vector grid_v; forced = forced || !field.has("gridded_regular_ll"); - return forced || !same->get("grid", grid_v) || !repres::latlon::LatLon::samePoints(user, field) - ? prefix + "regular-ll" - : ""; + return forced || !same->get("grid", grid_v) || !same_points(user, field) ? prefix + "regular-ll" : ""; } if (g.isNamed()) { @@ -96,17 +132,17 @@ } if (user.has("reduced")) { - long N; + long N = 0; return forced || !same->get("reduced", N) ? prefix + "reduced-gg" : ""; } if (user.has("regular")) { - long N; + long N = 0; return forced || !same->get("regular", N) ? prefix + "regular-gg" : ""; } if (user.has("octahedral")) { - long N; + long N = 0; return forced || !same->get("octahedral", N) ? prefix + "octahedral-gg" : ""; } @@ -134,7 +170,7 @@ } if (user.has("area") || user.has("rotation")) { - if (field.has("gridded_regular_ll") && !repres::latlon::LatLon::samePoints(user, field)) { + if (field.has("gridded_regular_ll") && !same_points(user, field)) { return prefix + "regular-ll"; } } @@ -145,7 +181,7 @@ static void add_formula(action::ActionPlan& plan, const param::MIRParametrisation& param, - const std::vector&& whens) { + const std::vector& whens) { std::string formula; for (const auto& when : whens) { if (param.get("formula." + when, formula)) { @@ -314,12 +350,12 @@ if (u_only) { ASSERT(!v_only); - plan.add("select.field", "which", long(0)); + plan.add("select.field", "which", 0L); } if (v_only) { ASSERT(!u_only); - plan.add("select.field", "which", long(1)); + plan.add("select.field", "which", 1L); } } @@ -461,6 +497,4 @@ } -} // namespace style -} // namespace key -} // namespace mir +} // namespace mir::key::style diff -Nru metview-5.17.4/mir/src/mir/key/style/ECMWFStyle.h metview-5.19.2/mir/src/mir/key/style/ECMWFStyle.h --- metview-5.17.4/mir/src/mir/key/style/ECMWFStyle.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/style/ECMWFStyle.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/style/MIRStyle.h" -namespace mir { -namespace key { -namespace style { +namespace mir::key::style { class ECMWFStyle : public MIRStyle { @@ -95,6 +93,4 @@ }; -} // namespace style -} // namespace key -} // namespace mir +} // namespace mir::key::style diff -Nru metview-5.17.4/mir/src/mir/key/style/MIRStyle.cc metview-5.19.2/mir/src/mir/key/style/MIRStyle.cc --- metview-5.17.4/mir/src/mir/key/style/MIRStyle.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/style/MIRStyle.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace key { -namespace style { +namespace mir::key::style { MIRStyle::MIRStyle(const param::MIRParametrisation& parametrisation) : parametrisation_(parametrisation) {} @@ -93,6 +91,4 @@ } -} // namespace style -} // namespace key -} // namespace mir +} // namespace mir::key::style diff -Nru metview-5.17.4/mir/src/mir/key/style/MIRStyle.h metview-5.19.2/mir/src/mir/key/style/MIRStyle.h --- metview-5.17.4/mir/src/mir/key/style/MIRStyle.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/style/MIRStyle.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,9 +29,7 @@ } // namespace mir -namespace mir { -namespace key { -namespace style { +namespace mir::key::style { class MIRStyle { @@ -115,7 +113,7 @@ std::string name_; virtual MIRStyle* make(const param::MIRParametrisation&) = 0; - MIRStyleFactory(const MIRStyleFactory&) = delete; + MIRStyleFactory(const MIRStyleFactory&) = delete; MIRStyleFactory& operator=(const MIRStyleFactory&) = delete; protected: @@ -137,6 +135,4 @@ }; -} // namespace style -} // namespace key -} // namespace mir +} // namespace mir::key::style diff -Nru metview-5.17.4/mir/src/mir/key/truncation/Automatic.cc metview-5.19.2/mir/src/mir/key/truncation/Automatic.cc --- metview-5.17.4/mir/src/mir/key/truncation/Automatic.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/truncation/Automatic.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/SpectralOrder.h" -namespace mir { -namespace key { -namespace truncation { +namespace mir::key::truncation { static const TruncationBuilder __truncation1("automatic"); @@ -60,6 +58,4 @@ } -} // namespace truncation -} // namespace key -} // namespace mir +} // namespace mir::key::truncation diff -Nru metview-5.17.4/mir/src/mir/key/truncation/Automatic.h metview-5.19.2/mir/src/mir/key/truncation/Automatic.h --- metview-5.17.4/mir/src/mir/key/truncation/Automatic.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/truncation/Automatic.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/truncation/Truncation.h" -namespace mir { -namespace key { -namespace truncation { +namespace mir::key::truncation { class Automatic : public Truncation { @@ -73,6 +71,4 @@ }; -} // namespace truncation -} // namespace key -} // namespace mir +} // namespace mir::key::truncation diff -Nru metview-5.17.4/mir/src/mir/key/truncation/None.cc metview-5.19.2/mir/src/mir/key/truncation/None.cc --- metview-5.17.4/mir/src/mir/key/truncation/None.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/truncation/None.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/key/truncation/None.h" -namespace mir { -namespace key { -namespace truncation { +namespace mir::key::truncation { static const TruncationBuilder __truncation1("none"); @@ -30,6 +28,4 @@ } -} // namespace truncation -} // namespace key -} // namespace mir +} // namespace mir::key::truncation diff -Nru metview-5.17.4/mir/src/mir/key/truncation/None.h metview-5.19.2/mir/src/mir/key/truncation/None.h --- metview-5.17.4/mir/src/mir/key/truncation/None.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/truncation/None.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/truncation/Truncation.h" -namespace mir { -namespace key { -namespace truncation { +namespace mir::key::truncation { class None : public Truncation { @@ -72,6 +70,4 @@ }; -} // namespace truncation -} // namespace key -} // namespace mir +} // namespace mir::key::truncation diff -Nru metview-5.17.4/mir/src/mir/key/truncation/Ordinal.cc metview-5.19.2/mir/src/mir/key/truncation/Ordinal.cc --- metview-5.17.4/mir/src/mir/key/truncation/Ordinal.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/truncation/Ordinal.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace key { -namespace truncation { +namespace mir::key::truncation { Ordinal::Ordinal(long truncation, const param::MIRParametrisation& parametrisation) : @@ -32,6 +30,4 @@ } -} // namespace truncation -} // namespace key -} // namespace mir +} // namespace mir::key::truncation diff -Nru metview-5.17.4/mir/src/mir/key/truncation/Ordinal.h metview-5.19.2/mir/src/mir/key/truncation/Ordinal.h --- metview-5.17.4/mir/src/mir/key/truncation/Ordinal.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/truncation/Ordinal.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/key/truncation/Truncation.h" -namespace mir { -namespace key { -namespace truncation { +namespace mir::key::truncation { class Ordinal : public Truncation { @@ -73,6 +71,4 @@ }; -} // namespace truncation -} // namespace key -} // namespace mir +} // namespace mir::key::truncation diff -Nru metview-5.17.4/mir/src/mir/key/truncation/Truncation.cc metview-5.19.2/mir/src/mir/key/truncation/Truncation.cc --- metview-5.17.4/mir/src/mir/key/truncation/Truncation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/truncation/Truncation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace key { -namespace truncation { +namespace mir::key::truncation { static util::once_flag once; @@ -100,6 +98,4 @@ } -} // namespace truncation -} // namespace key -} // namespace mir +} // namespace mir::key::truncation diff -Nru metview-5.17.4/mir/src/mir/key/truncation/Truncation.h metview-5.19.2/mir/src/mir/key/truncation/Truncation.h --- metview-5.17.4/mir/src/mir/key/truncation/Truncation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/key/truncation/Truncation.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,16 +16,12 @@ #include -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace key { -namespace truncation { +namespace mir::key::truncation { class Truncation { @@ -104,7 +100,7 @@ std::string name_; virtual Truncation* make(const param::MIRParametrisation&, long targetGaussianN) = 0; - TruncationFactory(const TruncationFactory&) = delete; + TruncationFactory(const TruncationFactory&) = delete; TruncationFactory& operator=(const TruncationFactory&) = delete; protected: @@ -128,6 +124,4 @@ }; -} // namespace truncation -} // namespace key -} // namespace mir +} // namespace mir::key::truncation diff -Nru metview-5.17.4/mir/src/mir/lsm/FileLSM.cc metview-5.19.2/mir/src/mir/lsm/FileLSM.cc --- metview-5.17.4/mir/src/mir/lsm/FileLSM.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/FileLSM.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace lsm { +namespace mir::lsm { static const FileLSM __lsm_selection("file"); @@ -66,5 +65,4 @@ } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/FileLSM.h metview-5.19.2/mir/src/mir/lsm/FileLSM.h --- metview-5.17.4/mir/src/mir/lsm/FileLSM.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/FileLSM.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/lsm/LSMSelection.h" -namespace mir { -namespace lsm { +namespace mir::lsm { class FileLSM : public LSMSelection { @@ -93,5 +92,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/GribFileMask.cc metview-5.19.2/mir/src/mir/lsm/GribFileMask.cc --- metview-5.17.4/mir/src/mir/lsm/GribFileMask.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/GribFileMask.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,8 +29,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace lsm { +namespace mir::lsm { GribFileMask::GribFileMask(const eckit::PathName& path, const param::MIRParametrisation& parametrisation, @@ -110,5 +109,4 @@ } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/GribFileMaskFromMIR.cc metview-5.19.2/mir/src/mir/lsm/GribFileMaskFromMIR.cc --- metview-5.17.4/mir/src/mir/lsm/GribFileMaskFromMIR.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/GribFileMaskFromMIR.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,22 +13,23 @@ #include "mir/lsm/GribFileMaskFromMIR.h" -namespace mir { -namespace lsm { +namespace mir::lsm { + GribFileMaskFromMIR::GribFileMaskFromMIR(const std::string& name, const eckit::PathName& path, const param::MIRParametrisation& parametrisation, const repres::Representation& representation, const std::string& which) : GribFileMask(path, parametrisation, representation, which), name_(name) {} + bool GribFileMaskFromMIR::cacheable() const { return true; } + std::string GribFileMaskFromMIR::cacheName() const { return name_; } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/GribFileMaskFromMIR.h metview-5.19.2/mir/src/mir/lsm/GribFileMaskFromMIR.h --- metview-5.17.4/mir/src/mir/lsm/GribFileMaskFromMIR.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/GribFileMaskFromMIR.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,13 @@ #include "mir/lsm/GribFileMask.h" -namespace mir { -namespace lsm { +namespace mir::lsm { class GribFileMaskFromMIR : public GribFileMask { public: - GribFileMaskFromMIR(const std::string& name, const eckit::PathName& path, - const param::MIRParametrisation& parametrisation, const repres::Representation& representation, - const std::string& which); + GribFileMaskFromMIR(const std::string& name, const eckit::PathName&, const param::MIRParametrisation&, + const repres::Representation&, const std::string& which); private: std::string name_; @@ -33,5 +31,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/GribFileMaskFromUser.cc metview-5.19.2/mir/src/mir/lsm/GribFileMaskFromUser.cc --- metview-5.17.4/mir/src/mir/lsm/GribFileMaskFromUser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/GribFileMaskFromUser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,17 +13,17 @@ #include "mir/lsm/GribFileMaskFromUser.h" -namespace mir { -namespace lsm { +namespace mir::lsm { bool GribFileMaskFromUser::cacheable() const { return false; } + std::string GribFileMaskFromUser::cacheName() const { return path_; } -} // namespace lsm -} // namespace mir + +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/GribFileMaskFromUser.h metview-5.19.2/mir/src/mir/lsm/GribFileMaskFromUser.h --- metview-5.17.4/mir/src/mir/lsm/GribFileMaskFromUser.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/GribFileMaskFromUser.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/lsm/GribFileMask.h" -namespace mir { -namespace lsm { +namespace mir::lsm { class GribFileMaskFromUser : public GribFileMask { @@ -29,5 +28,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/GribFileMask.h metview-5.19.2/mir/src/mir/lsm/GribFileMask.h --- metview-5.17.4/mir/src/mir/lsm/GribFileMask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/GribFileMask.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,18 +19,7 @@ #include "mir/lsm/Mask.h" -namespace mir { -namespace param { -class MIRParametrisation; -} -namespace repres { -class Representation; -} -} // namespace mir - - -namespace mir { -namespace lsm { +namespace mir::lsm { class GribFileMask : public Mask { @@ -111,5 +100,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/LandSeaMasks.cc metview-5.19.2/mir/src/mir/lsm/LandSeaMasks.cc --- metview-5.17.4/mir/src/mir/lsm/LandSeaMasks.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/LandSeaMasks.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace lsm { +namespace mir::lsm { LandSeaMasks::LandSeaMasks(const Mask& input, const Mask& output) : input_(input), output_(output) { @@ -80,5 +79,4 @@ } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/LandSeaMasks.h metview-5.19.2/mir/src/mir/lsm/LandSeaMasks.h --- metview-5.17.4/mir/src/mir/lsm/LandSeaMasks.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/LandSeaMasks.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,11 +19,9 @@ namespace eckit { class MD5; } -namespace mir { -namespace lsm { +namespace mir::lsm { class Mask; -} -} // namespace mir +} // namespace mir::lsm namespace mir { namespace param { class MIRParametrisation; @@ -34,8 +32,7 @@ } // namespace mir -namespace mir { -namespace lsm { +namespace mir::lsm { class LandSeaMasks { @@ -139,5 +136,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/LSMSelection.cc metview-5.19.2/mir/src/mir/lsm/LSMSelection.cc --- metview-5.17.4/mir/src/mir/lsm/LSMSelection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/LSMSelection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace lsm { +namespace mir::lsm { static util::once_flag once; @@ -67,15 +66,13 @@ Log::debug() << "LSMSelection: looking for '" << name << "'" << std::endl; - auto j = m->find(name); - if (j == m->end()) { - list(Log::error() << "LSMSelection: unknown '" << name << "', choices are: "); - throw exception::SeriousBug("LSMSelection: unknown '" + name + "'"); + if (auto j = m->find(name); j != m->end()) { + return *(j->second); } - return *(j->second); + list(Log::error() << "LSMSelection: unknown '" << name << "', choices are: "); + throw exception::SeriousBug("LSMSelection: unknown '" + name + "'"); } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/LSMSelection.h metview-5.19.2/mir/src/mir/lsm/LSMSelection.h --- metview-5.17.4/mir/src/mir/lsm/LSMSelection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/LSMSelection.h 2023-07-15 08:28:47.000000000 +0000 @@ -29,8 +29,7 @@ } // namespace mir -namespace mir { -namespace lsm { +namespace mir::lsm { class LSMSelection { @@ -120,5 +119,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/MappedMask.cc metview-5.19.2/mir/src/mir/lsm/MappedMask.cc --- metview-5.17.4/mir/src/mir/lsm/MappedMask.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/MappedMask.cc 2023-07-15 08:28:47.000000000 +0000 @@ -44,10 +44,10 @@ public: FDClose(int fd) : fd_(fd) {} - FDClose(const FDClose&) = delete; - FDClose(FDClose&&) = delete; + FDClose(const FDClose&) = delete; + FDClose(FDClose&&) = delete; FDClose& operator=(const FDClose&) = delete; - FDClose& operator=(FDClose&&) = delete; + FDClose& operator=(FDClose&&) = delete; ~FDClose() { SYSCALL(::close(fd_)); } }; @@ -57,10 +57,10 @@ public: Unmapper(void* address, size_t size) : address_(address), size_(size) {} - Unmapper(const Unmapper&) = delete; - Unmapper(Unmapper&&) = delete; + Unmapper(const Unmapper&) = delete; + Unmapper(Unmapper&&) = delete; Unmapper& operator=(const Unmapper&) = delete; - Unmapper& operator=(Unmapper&&) = delete; + Unmapper& operator=(Unmapper&&) = delete; ~Unmapper() { SYSCALL(MMap::munmap(address_, size_)); } }; @@ -71,8 +71,7 @@ static const unsigned int MASKS[] = {1 << 7, 1 << 6, 1 << 5, 1 << 4, 1 << 3, 1 << 2, 1 << 1, 1 << 0}; -namespace mir { -namespace lsm { +namespace mir::lsm { MappedMask::MappedMask(const std::string& name, const eckit::PathName& path, @@ -188,5 +187,4 @@ } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/MappedMask.h metview-5.19.2/mir/src/mir/lsm/MappedMask.h --- metview-5.17.4/mir/src/mir/lsm/MappedMask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/MappedMask.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,18 +19,7 @@ #include "mir/lsm/Mask.h" -namespace mir { -namespace param { -class MIRParametrisation; -} -namespace repres { -class Representation; -} -} // namespace mir - - -namespace mir { -namespace lsm { +namespace mir::lsm { class MappedMask : public Mask { @@ -40,8 +29,8 @@ // -- Constructors - MappedMask(const std::string& name, const eckit::PathName&, const param::MIRParametrisation& parametrisation, - const repres::Representation& representation, const std::string& which); + MappedMask(const std::string& name, const eckit::PathName&, const param::MIRParametrisation&, + const repres::Representation&, const std::string& which); // -- Destructor @@ -111,5 +100,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/Mask.cc metview-5.19.2/mir/src/mir/lsm/Mask.cc --- metview-5.17.4/mir/src/mir/lsm/Mask.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/Mask.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,15 +18,14 @@ #include "mir/lsm/NoneLSM.h" #include "mir/param/MIRParametrisation.h" #include "mir/util/Mutex.h" -//#include "mir/param/RuntimeParametrisation.h" -//#include "mir/repres/latlon/RegularLL.h" +// #include "mir/param/RuntimeParametrisation.h" +// #include "mir/repres/latlon/RegularLL.h" #include "mir/repres/Representation.h" #include "mir/util/Exceptions.h" #include "mir/util/Log.h" -namespace mir { -namespace lsm { +namespace mir::lsm { static util::recursive_mutex* local_mutex = nullptr; @@ -177,5 +176,4 @@ } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/Mask.h metview-5.19.2/mir/src/mir/lsm/Mask.h --- metview-5.17.4/mir/src/mir/lsm/Mask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/Mask.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,8 +32,7 @@ } // namespace mir -namespace mir { -namespace lsm { +namespace mir::lsm { class Mask { @@ -125,5 +124,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/NamedLSM.cc metview-5.19.2/mir/src/mir/lsm/NamedLSM.cc --- metview-5.17.4/mir/src/mir/lsm/NamedLSM.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/NamedLSM.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,14 +28,13 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace lsm { +namespace mir::lsm { static NamedLSM const __lsm_selection("named"); -static const NamedMaskBuilder __NamedMappedMask_1("1km", "~mir/share/mir/masks/lsm.1km.climate.v013.mask"); +static const NamedMaskBuilder __NamedMappedMask_1("1km", "~mir/share/mir/masks/lsm.1km.climate.v020.mask"); static const NamedMaskBuilder __NamedMappedMask_2("1km.climate.v020", "~mir/share/mir/masks/lsm.1km.climate.v020.mask"); static const NamedMaskBuilder __NamedMappedMask_3("1km.climate.v013", @@ -120,13 +119,12 @@ name = sane(name); Log::debug() << "NamedMaskFactory: looking for '" << name << "'" << std::endl; - auto j = m->find(name); - if (j == m->end()) { - list(Log::error() << "NamedMaskFactory: unknown '" << name << "', choices are: "); - throw exception::SeriousBug("NamedMaskFactory: unknown '" + name + "'"); + if (auto j = m->find(name); j != m->end()) { + return j->second->make(param, representation, which); } - return j->second->make(param, representation, which); + list(Log::error() << "NamedMaskFactory: unknown '" << name << "', choices are: "); + throw exception::SeriousBug("NamedMaskFactory: unknown '" + name + "'"); } @@ -140,15 +138,14 @@ name = sane(name); Log::debug() << "NamedMaskFactory: looking for '" << name << "'" << std::endl; - auto j = m->find(name); - if (j == m->end()) { - list(Log::error() << "NamedMaskFactory: unknown '" << name << "', choices are: "); - throw exception::SeriousBug("NamedMaskFactory: unknown '" + name + "'"); + if (auto j = m->find(name); j != m->end()) { + eckit::MD5 md5; + j->second->hashCacheKey(md5, param, representation, which); + return "named." + name + "." + md5.digest(); } - eckit::MD5 md5; - j->second->hashCacheKey(md5, param, representation, which); - return "named." + name + "." + md5.digest(); + list(Log::error() << "NamedMaskFactory: unknown '" << name << "', choices are: "); + throw exception::SeriousBug("NamedMaskFactory: unknown '" + name + "'"); } @@ -164,5 +161,4 @@ } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/NamedLSM.h metview-5.19.2/mir/src/mir/lsm/NamedLSM.h --- metview-5.17.4/mir/src/mir/lsm/NamedLSM.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/NamedLSM.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ } -namespace mir { -namespace lsm { +namespace mir::lsm { class NamedLSM : public LSMSelection { @@ -86,7 +85,7 @@ virtual void hashCacheKey(eckit::MD5&, const param::MIRParametrisation&, const repres::Representation&, const std::string& which) = 0; - NamedMaskFactory(const NamedMaskFactory&) = delete; + NamedMaskFactory(const NamedMaskFactory&) = delete; NamedMaskFactory& operator=(const NamedMaskFactory&) = delete; protected: @@ -120,5 +119,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/NoMask.cc metview-5.19.2/mir/src/mir/lsm/NoMask.cc --- metview-5.17.4/mir/src/mir/lsm/NoMask.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/NoMask.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace lsm { +namespace mir::lsm { bool NoMask::active() const { @@ -45,9 +44,10 @@ out << "NoMask[]"; } + std::string NoMask::cacheName() const { NOTIMP; } -} // namespace lsm -} // namespace mir + +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/NoMask.h metview-5.19.2/mir/src/mir/lsm/NoMask.h --- metview-5.17.4/mir/src/mir/lsm/NoMask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/NoMask.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/lsm/Mask.h" -namespace mir { -namespace lsm { +namespace mir::lsm { class NoMask : public Mask { @@ -35,5 +34,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/NoneLSM.cc metview-5.19.2/mir/src/mir/lsm/NoneLSM.cc --- metview-5.17.4/mir/src/mir/lsm/NoneLSM.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/NoneLSM.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace lsm { +namespace mir::lsm { static const NoneLSM __lsm_selection("none"); @@ -50,10 +49,10 @@ return "none"; } + std::string NoneLSM::cacheName() const { NOTIMP; } -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/NoneLSM.h metview-5.19.2/mir/src/mir/lsm/NoneLSM.h --- metview-5.17.4/mir/src/mir/lsm/NoneLSM.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/NoneLSM.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/lsm/LSMSelection.h" -namespace mir { -namespace lsm { +namespace mir::lsm { class NoneLSM : public LSMSelection { @@ -95,5 +94,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/TenMinutesMask.cc metview-5.19.2/mir/src/mir/lsm/TenMinutesMask.cc --- metview-5.17.4/mir/src/mir/lsm/TenMinutesMask.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/TenMinutesMask.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace lsm { +namespace mir::lsm { /* @@ -129,9 +128,10 @@ return mask_; } + std::string TenMinutesMask::cacheName() const { return name_; } -} // namespace lsm -} // namespace mir + +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/lsm/TenMinutesMask.h metview-5.19.2/mir/src/mir/lsm/TenMinutesMask.h --- metview-5.17.4/mir/src/mir/lsm/TenMinutesMask.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/lsm/TenMinutesMask.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,16 +19,9 @@ #include "mir/lsm/Mask.h" -namespace mir { -namespace param { -class MIRParametrisation; -} -} // namespace mir +namespace mir::lsm { -namespace mir { -namespace lsm { - class TenMinutesMask : public Mask { public: // -- Exceptions @@ -91,5 +84,4 @@ }; -} // namespace lsm -} // namespace mir +} // namespace mir::lsm diff -Nru metview-5.17.4/mir/src/mir/method/Cropping.cc metview-5.19.2/mir/src/mir/method/Cropping.cc --- metview-5.17.4/mir/src/mir/method/Cropping.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/Cropping.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { +namespace mir::method { Cropping::Cropping() : active_(false) {} @@ -60,5 +59,4 @@ } -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/Cropping.h metview-5.19.2/mir/src/mir/method/Cropping.h --- metview-5.17.4/mir/src/mir/method/Cropping.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/Cropping.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace method { +namespace mir::method { class Cropping { @@ -47,5 +46,4 @@ }; -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/FailMethod.cc metview-5.19.2/mir/src/mir/method/FailMethod.cc --- metview-5.17.4/mir/src/mir/method/FailMethod.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/FailMethod.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,11 +18,11 @@ #include "mir/util/Log.h" -namespace mir { -namespace method { +namespace mir::method { -static const MethodBuilder __method("fail"); +static const MethodBuilder __method_1("fail"); +static const MethodBuilder __method_2("none"); bool FailMethod::canCrop() const { @@ -72,5 +72,4 @@ } -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/FailMethod.h metview-5.19.2/mir/src/mir/method/FailMethod.h --- metview-5.17.4/mir/src/mir/method/FailMethod.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/FailMethod.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/method/Method.h" -namespace mir { -namespace method { +namespace mir::method { class FailMethod final : public Method { @@ -83,5 +82,4 @@ }; -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/fe/BuildNodeLumpedMassMatrix.cc metview-5.19.2/mir/src/mir/method/fe/BuildNodeLumpedMassMatrix.cc --- metview-5.17.4/mir/src/mir/method/fe/BuildNodeLumpedMassMatrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/BuildNodeLumpedMassMatrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { BuildNodeLumpedMassMatrix::BuildNodeLumpedMassMatrix(std::string name, bool force_recompute) : @@ -135,6 +133,4 @@ } -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/BuildNodeLumpedMassMatrix.h metview-5.19.2/mir/src/mir/method/fe/BuildNodeLumpedMassMatrix.h --- metview-5.17.4/mir/src/mir/method/fe/BuildNodeLumpedMassMatrix.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/BuildNodeLumpedMassMatrix.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ } // namespace atlas -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { class BuildNodeLumpedMassMatrix { @@ -99,6 +97,4 @@ }; -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/CalculateCellLongestDiagonal.cc metview-5.19.2/mir/src/mir/method/fe/CalculateCellLongestDiagonal.cc --- metview-5.17.4/mir/src/mir/method/fe/CalculateCellLongestDiagonal.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/CalculateCellLongestDiagonal.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { CalculateCellLongestDiagonal::CalculateCellLongestDiagonal(std::string name, bool force_recompute) : @@ -103,6 +101,4 @@ } -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/CalculateCellLongestDiagonal.h metview-5.19.2/mir/src/mir/method/fe/CalculateCellLongestDiagonal.h --- metview-5.17.4/mir/src/mir/method/fe/CalculateCellLongestDiagonal.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/CalculateCellLongestDiagonal.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ } // namespace atlas -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { class CalculateCellLongestDiagonal { @@ -98,6 +96,4 @@ }; -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/FEBilinear.cc metview-5.19.2/mir/src/mir/method/fe/FEBilinear.cc --- metview-5.17.4/mir/src/mir/method/fe/FEBilinear.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/FEBilinear.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/method/fe/FEBilinear.h" -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { FEBilinear::FEBilinear(const param::MIRParametrisation& param, const std::string& label) : FiniteElement(param, label) { @@ -34,6 +32,4 @@ static const FiniteElementBuilder __builder("bilinear"); -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/FEBilinear.h metview-5.19.2/mir/src/mir/method/fe/FEBilinear.h --- metview-5.17.4/mir/src/mir/method/fe/FEBilinear.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/FEBilinear.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/fe/FiniteElement.h" -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { class FEBilinear : public FiniteElement { @@ -92,6 +90,4 @@ }; -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/FELinear.cc metview-5.19.2/mir/src/mir/method/fe/FELinear.cc --- metview-5.17.4/mir/src/mir/method/fe/FELinear.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/FELinear.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/method/fe/FELinear.h" -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { FELinear::FELinear(const param::MIRParametrisation& param, const std::string& label) : FiniteElement(param, label) { @@ -33,6 +31,4 @@ static const FiniteElementBuilder __builder("linear"); -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/FELinear.h metview-5.19.2/mir/src/mir/method/fe/FELinear.h --- metview-5.17.4/mir/src/mir/method/fe/FELinear.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/FELinear.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/fe/FiniteElement.h" -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { class FELinear : public FiniteElement { @@ -92,6 +90,4 @@ }; -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/FiniteElement.cc metview-5.19.2/mir/src/mir/method/fe/FiniteElement.cc --- metview-5.17.4/mir/src/mir/method/fe/FiniteElement.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/FiniteElement.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,10 +40,7 @@ namespace fe { -// epsilon used to scale edge tolerance when projecting ray to intersect element -static constexpr double parametricEpsilon = 1e-15; - -static constexpr size_t nbFailuresLogged = 10; +static constexpr size_t nbMaxFailures = 10; static util::once_flag once; static util::recursive_mutex* mtx = nullptr; @@ -68,7 +65,7 @@ virtual ~element_t() = default; - virtual bool intersects(const atlas::interpolation::method::Ray&) = 0; + virtual bool intersects(const atlas::interpolation::method::Ray&, double eps) = 0; void append_triplets(size_t i, size_t nbRealPoints, triplet_vector_t& t) const { ASSERT(size() == weights.size()); @@ -117,8 +114,8 @@ atlas::PointXYZ{coords(i2, XYZCOORDS::XX), coords(i2, XYZCOORDS::YY), coords(i2, XYZCOORDS::ZZ)}, atlas::PointXYZ{coords(i3, XYZCOORDS::XX), coords(i3, XYZCOORDS::YY), coords(i3, XYZCOORDS::ZZ)}) {} - bool intersects(const atlas::interpolation::method::Ray& r) override { - auto is = Triag3D::intersects(r, parametricEpsilon * std::sqrt(area())); + bool intersects(const atlas::interpolation::method::Ray& r, double eps) override { + auto is = Triag3D::intersects(r, eps * std::sqrt(area())); if (is) { weights.assign({1. - is.u - is.v, is.u, is.v}); return true; @@ -136,8 +133,8 @@ atlas::PointXYZ{coords(i3, XYZCOORDS::XX), coords(i3, XYZCOORDS::YY), coords(i3, XYZCOORDS::ZZ)}, atlas::PointXYZ{coords(i4, XYZCOORDS::XX), coords(i4, XYZCOORDS::YY), coords(i4, XYZCOORDS::ZZ)}) {} - bool intersects(const atlas::interpolation::method::Ray& r) override { - auto is = Quad3D::intersects(r, parametricEpsilon * std::sqrt(area())); + bool intersects(const atlas::interpolation::method::Ray& r, double eps) override { + auto is = Quad3D::intersects(r, eps * std::sqrt(area())); if (is) { weights.assign({(1. - is.u) * (1. - is.v), is.u * (1. - is.v), is.u * is.v, (1. - is.u) * is.v}); return true; @@ -150,10 +147,17 @@ FiniteElement::FiniteElement(const param::MIRParametrisation& param, const std::string& label) : MethodWeighted(param), meshGeneratorParams_(param, label) { param.get("finite-element-validate-mesh", validateMesh_ = false); - param.get("finite-element-missing-value-on-projection-fail", missingValueOnProjectionFail_ = true); // mesh requirements meshGeneratorParams_.meshCellCentres_ = true; + + // projection fail + std::string projectionFail = "missing-value"; + param.get("finite-element-projection-fail", projectionFail); + projectionFail_ = projectionFail == "failure" ? ProjectionFail::failure + : projectionFail == "increase-epsilon" ? ProjectionFail::increaseEpsilon + : projectionFail == "missing-value" ? ProjectionFail::missingValue + : NOTIMP; } @@ -216,7 +220,11 @@ void FiniteElement::print(std::ostream& out) const { out << "FiniteElement[name=" << name() << ","; MethodWeighted::print(out); - out << ",validateMesh=" << validateMesh_ << ",missingValueOnProjectionFail=" << missingValueOnProjectionFail_ + out << ",validateMesh=" << validateMesh_ << ",projectionFail=" + << (projectionFail_ == ProjectionFail::failure ? "fail" + : projectionFail_ == ProjectionFail::increaseEpsilon ? "increase-epsilon" + : projectionFail_ == ProjectionFail::missingValue ? "missing-value" + : NOTIMP) << "]"; } @@ -224,8 +232,7 @@ bool FiniteElement::sameAs(const Method& other) const { const auto* o = dynamic_cast(&other); return (o != nullptr) && meshGeneratorParams_.sameAs(o->meshGeneratorParams_) && - validateMesh_ == o->validateMesh_ && missingValueOnProjectionFail_ == o->missingValueOnProjectionFail_ && - MethodWeighted::sameAs(other); + validateMesh_ == o->validateMesh_ && projectionFail_ == o->projectionFail_ && MethodWeighted::sameAs(other); } @@ -235,7 +242,7 @@ // FIXME uncomment on cache version increase // md5 << validateMesh_; - // md5 << missingValueOnProjectionFail_; + // md5 << static_cast(projectionFail_); } @@ -294,7 +301,7 @@ for (const std::unique_ptr it(out.iterator()); it->next(); ++progress) { if (inDomain.contains(it->pointRotated())) { - // 3D projection, trying elements closest to p (if this fails, consider lowering parametricEpsilon) + // 3D projection, trying elements closest to p Point3 p(it->point3D()); size_t nbProjectionAttempts = 0; @@ -305,36 +312,44 @@ atlas::interpolation::method::Ray ray(p.data()); - bool success = false; - for (const auto& close : closest) { - ++nbProjectionAttempts; + // epsilon used to scale edge tolerance when projecting ray to intersect elements + // (if it fails consider increasing eps, or use ProjectionFail::increaseEpsilon) + double eps = 1e-15; - /* - * Assumes: - * - nb_cols == 3 implies triangle - * - nb_cols == 4 implies quadrilateral - * - no other element is supported at the time - */ - const auto e = atlas::idx_t(close.value().payload()); - ASSERT(e < connectivity.rows()); - - auto idx = [e, nbInputPoints, &connectivity](atlas::idx_t j) { - auto x = size_t(connectivity(e, j)); - ASSERT(x < nbInputPoints); - return x; - }; - - const auto nb_cols = connectivity.cols(e); - - std::unique_ptr elem( - nb_cols == 3 ? static_cast(new triag_t(inCoords, idx(0), idx(1), idx(2))) - : nb_cols == 4 ? new quad_t(inCoords, idx(0), idx(1), idx(2), idx(3)) - : NOTIMP); - - if (elem->intersects(ray)) { - elem->append_triplets(ip, nbRealPts, weights_triplets); - success = true; - break; + bool success = false; + for (size_t a = 0; + a == 0 || (!success && a < nbMaxFailures && projectionFail_ == ProjectionFail::increaseEpsilon); + eps *= 2., ++a) { + for (const auto& close : closest) { + ++nbProjectionAttempts; + + /* + * Assumes: + * - nb_cols == 3 implies triangle + * - nb_cols == 4 implies quadrilateral + * - no other element is supported at the time + */ + const auto e = atlas::idx_t(close.value().payload()); + ASSERT(e < connectivity.rows()); + + auto idx = [e, nbInputPoints, &connectivity](atlas::idx_t j) { + auto x = size_t(connectivity(e, j)); + ASSERT(x < nbInputPoints); + return x; + }; + + const auto nb_cols = connectivity.cols(e); + + std::unique_ptr elem( + nb_cols == 3 ? static_cast(new triag_t(inCoords, idx(0), idx(1), idx(2))) + : nb_cols == 4 ? new quad_t(inCoords, idx(0), idx(1), idx(2), idx(3)) + : NOTIMP); + + if (elem->intersects(ray, eps)) { + elem->append_triplets(ip, nbRealPts, weights_triplets); + success = true; + break; + } } } @@ -345,7 +360,7 @@ if (success) { ++nbProjections; } - else if (!missingValueOnProjectionFail_) { + else if (projectionFail_ != ProjectionFail::missingValue) { failures.emplace_front(ip, it->pointUnrotated()); ++nbFailures; } @@ -365,7 +380,7 @@ size_t count = 0; for (const auto& f : failures) { log << "\n\tpoint " << f.first << " " << f.second; - if (++count > nbFailuresLogged) { + if (++count > nbMaxFailures) { log << "\n\t..."; break; } @@ -433,6 +448,11 @@ } +void FiniteElement::ProjectionFail::list(std::ostream& out) { + out << "failure, increase-epsilon, missing-value"; +} + + } // namespace fe } // namespace method } // namespace mir diff -Nru metview-5.17.4/mir/src/mir/method/fe/FiniteElement.h metview-5.19.2/mir/src/mir/method/fe/FiniteElement.h --- metview-5.17.4/mir/src/mir/method/fe/FiniteElement.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/FiniteElement.h 2023-07-15 08:28:47.000000000 +0000 @@ -25,7 +25,16 @@ class FiniteElement : public MethodWeighted { public: // -- Types - // None + + struct ProjectionFail { + static void list(std::ostream& out); + enum type : unsigned int + { + failure = 0, + missingValue, + increaseEpsilon + }; + }; // -- Exceptions // None @@ -80,8 +89,8 @@ // -- Members util::MeshGeneratorParameters meshGeneratorParams_; + ProjectionFail::type projectionFail_; bool validateMesh_; - bool missingValueOnProjectionFail_; // -- Methods // None @@ -115,7 +124,7 @@ virtual FiniteElement* make(const param::MIRParametrisation&, const std::string& label) = 0; FiniteElement* make(const param::MIRParametrisation&) override = 0; - FiniteElementFactory(const FiniteElementFactory&) = delete; + FiniteElementFactory(const FiniteElementFactory&) = delete; FiniteElementFactory& operator=(const FiniteElementFactory&) = delete; protected: diff -Nru metview-5.17.4/mir/src/mir/method/fe/L2Projection.cc metview-5.19.2/mir/src/mir/method/fe/L2Projection.cc --- metview-5.17.4/mir/src/mir/method/fe/L2Projection.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/L2Projection.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { L2Projection::L2Projection(const param::MIRParametrisation& param) : MethodWeighted(param) { @@ -149,6 +147,4 @@ static const MethodBuilder __builder("l2-projection"); -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/fe/L2Projection.h metview-5.19.2/mir/src/mir/method/fe/L2Projection.h --- metview-5.17.4/mir/src/mir/method/fe/L2Projection.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/fe/L2Projection.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,18 +17,12 @@ #include "mir/method/MethodWeighted.h" -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { class FiniteElement; -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe -namespace mir { -namespace method { -namespace fe { +namespace mir::method::fe { /** @@ -118,6 +112,4 @@ }; -} // namespace fe -} // namespace method -} // namespace mir +} // namespace mir::method::fe diff -Nru metview-5.17.4/mir/src/mir/method/gridbox/GridBoxAverage.cc metview-5.19.2/mir/src/mir/method/gridbox/GridBoxAverage.cc --- metview-5.17.4/mir/src/mir/method/gridbox/GridBoxAverage.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/gridbox/GridBoxAverage.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,14 +13,10 @@ #include "mir/method/gridbox/GridBoxAverage.h" -namespace mir { -namespace method { -namespace gridbox { +namespace mir::method::gridbox { static const MethodBuilder __builder("grid-box-average"); -} // namespace gridbox -} // namespace method -} // namespace mir +} // namespace mir::method::gridbox diff -Nru metview-5.17.4/mir/src/mir/method/gridbox/GridBoxAverage.h metview-5.19.2/mir/src/mir/method/gridbox/GridBoxAverage.h --- metview-5.17.4/mir/src/mir/method/gridbox/GridBoxAverage.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/gridbox/GridBoxAverage.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/gridbox/GridBoxMethod.h" -namespace mir { -namespace method { -namespace gridbox { +namespace mir::method::gridbox { class GridBoxAverage : public GridBoxMethod { @@ -90,6 +88,4 @@ }; -} // namespace gridbox -} // namespace method -} // namespace mir +} // namespace mir::method::gridbox diff -Nru metview-5.17.4/mir/src/mir/method/gridbox/GridBoxMethod.cc metview-5.19.2/mir/src/mir/method/gridbox/GridBoxMethod.cc --- metview-5.17.4/mir/src/mir/method/gridbox/GridBoxMethod.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/gridbox/GridBoxMethod.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,9 +32,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace gridbox { +namespace mir::method::gridbox { GridBoxMethod::GridBoxMethod(const param::MIRParametrisation& parametrisation) : MethodWeighted(parametrisation) { @@ -106,7 +104,7 @@ std::unique_ptr tree; { trace::ResourceUsage usage("GridBoxMethod::assemble create k-d tree"); - tree.reset(new search::PointSearch(parametrisation_, in)); + tree = std::make_unique(parametrisation_, in); } { @@ -208,6 +206,9 @@ } -} // namespace gridbox -} // namespace method -} // namespace mir +int GridBoxMethod::version() const { + return 1; +} + + +} // namespace mir::method::gridbox diff -Nru metview-5.17.4/mir/src/mir/method/gridbox/GridBoxMethod.h metview-5.19.2/mir/src/mir/method/gridbox/GridBoxMethod.h --- metview-5.17.4/mir/src/mir/method/gridbox/GridBoxMethod.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/gridbox/GridBoxMethod.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/MethodWeighted.h" -namespace mir { -namespace method { -namespace gridbox { +namespace mir::method::gridbox { class GridBoxMethod : public MethodWeighted { @@ -87,6 +85,7 @@ void print(std::ostream&) const override; bool validateMatrixWeights() const override; const char* name() const override; + int version() const override; // -- Class members // None @@ -99,6 +98,4 @@ }; -} // namespace gridbox -} // namespace method -} // namespace mir +} // namespace mir::method::gridbox diff -Nru metview-5.17.4/mir/src/mir/method/gridbox/GridBoxStatistics.cc metview-5.19.2/mir/src/mir/method/gridbox/GridBoxStatistics.cc --- metview-5.17.4/mir/src/mir/method/gridbox/GridBoxStatistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/gridbox/GridBoxStatistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/stats/Field.h" -namespace mir { -namespace method { -namespace gridbox { +namespace mir::method::gridbox { GridBoxStatistics::GridBoxStatistics(const param::MIRParametrisation& param) : GridBoxMethod(param) { @@ -33,6 +31,4 @@ static const MethodBuilder __builder("grid-box-statistics"); -} // namespace gridbox -} // namespace method -} // namespace mir +} // namespace mir::method::gridbox diff -Nru metview-5.17.4/mir/src/mir/method/gridbox/GridBoxStatistics.h metview-5.19.2/mir/src/mir/method/gridbox/GridBoxStatistics.h --- metview-5.17.4/mir/src/mir/method/gridbox/GridBoxStatistics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/gridbox/GridBoxStatistics.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,18 +15,14 @@ #include "mir/method/gridbox/GridBoxMethod.h" -namespace mir { -namespace method { -namespace gridbox { +namespace mir::method::gridbox { struct GridBoxStatistics final : GridBoxMethod { explicit GridBoxStatistics(const param::MIRParametrisation&); GridBoxStatistics(const GridBoxStatistics&) = delete; - void operator=(const GridBoxStatistics&) = delete; + void operator=(const GridBoxStatistics&) = delete; }; -} // namespace gridbox -} // namespace method -} // namespace mir +} // namespace mir::method::gridbox diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/ClimateFilter.cc metview-5.19.2/mir/src/mir/method/knn/distance/ClimateFilter.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/ClimateFilter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/ClimateFilter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,10 +23,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { ClimateFilter::ClimateFilter(const param::MIRParametrisation& param) { @@ -109,7 +106,4 @@ static const DistanceWeightingBuilder __distance("climate-filter"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/ClimateFilter.h metview-5.19.2/mir/src/mir/method/knn/distance/ClimateFilter.h --- metview-5.17.4/mir/src/mir/method/knn/distance/ClimateFilter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/ClimateFilter.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/distance/DistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct ClimateFilter : DistanceWeighting { @@ -35,7 +32,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/Cressman.cc metview-5.19.2/mir/src/mir/method/knn/distance/Cressman.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/Cressman.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/Cressman.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,10 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { Cressman::Cressman(const param::MIRParametrisation& parametrisation) { @@ -87,7 +84,4 @@ static const DistanceWeightingBuilder __distance("cressman"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/Cressman.h metview-5.19.2/mir/src/mir/method/knn/distance/Cressman.h --- metview-5.17.4/mir/src/mir/method/knn/distance/Cressman.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/Cressman.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/distance/DistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { /** @@ -40,7 +37,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/DistanceWeighting.cc metview-5.19.2/mir/src/mir/method/knn/distance/DistanceWeighting.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/DistanceWeighting.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/DistanceWeighting.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { static util::recursive_mutex* local_mutex = nullptr; @@ -88,7 +85,4 @@ } -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/DistanceWeighting.h metview-5.19.2/mir/src/mir/method/knn/distance/DistanceWeighting.h --- metview-5.17.4/mir/src/mir/method/knn/distance/DistanceWeighting.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/DistanceWeighting.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,10 +23,7 @@ } -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { class DistanceWeighting { @@ -44,7 +41,7 @@ virtual void hash(eckit::MD5&) const = 0; private: - DistanceWeighting(const DistanceWeighting&) = delete; + DistanceWeighting(const DistanceWeighting&) = delete; DistanceWeighting& operator=(const DistanceWeighting&) = delete; virtual void print(std::ostream&) const = 0; @@ -61,7 +58,7 @@ std::string name_; virtual DistanceWeighting* make(const param::MIRParametrisation&) = 0; - DistanceWeightingFactory(const DistanceWeightingFactory&) = delete; + DistanceWeightingFactory(const DistanceWeightingFactory&) = delete; DistanceWeightingFactory& operator=(const DistanceWeightingFactory&) = delete; protected: @@ -83,7 +80,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/DistanceWeightingWithLSM.cc metview-5.19.2/mir/src/mir/method/knn/distance/DistanceWeightingWithLSM.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/DistanceWeightingWithLSM.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/DistanceWeightingWithLSM.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,10 +22,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { static util::recursive_mutex* local_mutex = nullptr; @@ -133,7 +130,4 @@ } -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/DistanceWeightingWithLSM.h metview-5.19.2/mir/src/mir/method/knn/distance/DistanceWeightingWithLSM.h --- metview-5.17.4/mir/src/mir/method/knn/distance/DistanceWeightingWithLSM.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/DistanceWeightingWithLSM.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,17 +17,12 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace lsm { +namespace mir::lsm { class LandSeaMasks; -} -} // namespace mir +} // namespace mir::lsm -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct DistanceWeightingWithLSM : DistanceWeighting { @@ -54,7 +49,7 @@ std::string name_; virtual DistanceWeighting* make(const param::MIRParametrisation&, const lsm::LandSeaMasks&) = 0; - DistanceWeightingWithLSMFactory(const DistanceWeightingWithLSMFactory&) = delete; + DistanceWeightingWithLSMFactory(const DistanceWeightingWithLSMFactory&) = delete; DistanceWeightingWithLSMFactory& operator=(const DistanceWeightingWithLSMFactory&) = delete; protected: @@ -80,7 +75,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/GaussianDistanceWeighting.cc metview-5.19.2/mir/src/mir/method/knn/distance/GaussianDistanceWeighting.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/GaussianDistanceWeighting.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/GaussianDistanceWeighting.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,10 +24,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { GaussianDistanceWeighting::GaussianDistanceWeighting(const param::MIRParametrisation& parametrisation) { @@ -90,7 +87,4 @@ static const DistanceWeightingBuilder __distance("gaussian"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/GaussianDistanceWeighting.h metview-5.19.2/mir/src/mir/method/knn/distance/GaussianDistanceWeighting.h --- metview-5.17.4/mir/src/mir/method/knn/distance/GaussianDistanceWeighting.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/GaussianDistanceWeighting.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/distance/DistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct GaussianDistanceWeighting : DistanceWeighting { @@ -35,7 +32,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/InverseDistanceWeighting.cc metview-5.19.2/mir/src/mir/method/knn/distance/InverseDistanceWeighting.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/InverseDistanceWeighting.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/InverseDistanceWeighting.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,10 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { namespace { @@ -117,7 +114,4 @@ static const DistanceWeightingBuilder __weighting3("shepard"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/InverseDistanceWeighting.h metview-5.19.2/mir/src/mir/method/knn/distance/InverseDistanceWeighting.h --- metview-5.17.4/mir/src/mir/method/knn/distance/InverseDistanceWeighting.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/InverseDistanceWeighting.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/distance/DistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct InverseDistanceWeighting : DistanceWeighting { @@ -36,7 +33,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/InverseDistanceWeightingSquared.cc metview-5.19.2/mir/src/mir/method/knn/distance/InverseDistanceWeightingSquared.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/InverseDistanceWeightingSquared.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/InverseDistanceWeightingSquared.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { InverseDistanceWeightingSquared::InverseDistanceWeightingSquared(const param::MIRParametrisation& /*unused*/) {} @@ -79,7 +76,4 @@ static const DistanceWeightingBuilder __distance("inverse-distance-weighting-squared"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/InverseDistanceWeightingSquared.h metview-5.19.2/mir/src/mir/method/knn/distance/InverseDistanceWeightingSquared.h --- metview-5.17.4/mir/src/mir/method/knn/distance/InverseDistanceWeightingSquared.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/InverseDistanceWeightingSquared.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/distance/DistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct InverseDistanceWeightingSquared : DistanceWeighting { @@ -33,7 +30,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/NearestLSM.cc metview-5.19.2/mir/src/mir/method/knn/distance/NearestLSM.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/NearestLSM.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/NearestLSM.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,10 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { NearestLSM::NearestLSM(const param::MIRParametrisation& parametrisation, const lsm::LandSeaMasks& landSeaMasks) : @@ -84,7 +81,4 @@ static const DistanceWeightingWithLSMBuilder __distance("nearest-lsm"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/NearestLSM.h metview-5.19.2/mir/src/mir/method/knn/distance/NearestLSM.h --- metview-5.17.4/mir/src/mir/method/knn/distance/NearestLSM.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/NearestLSM.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,17 +15,12 @@ #include "mir/method/knn/distance/DistanceWeightingWithLSM.h" -namespace mir { -namespace lsm { +namespace mir::lsm { class LandSeaMasks; -} -} // namespace mir +} // namespace mir::lsm -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { // Note: DistanceWeightingFactory cannot instantiate this because it @@ -44,7 +39,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/NearestLSMWithLowestIndex.cc metview-5.19.2/mir/src/mir/method/knn/distance/NearestLSMWithLowestIndex.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/NearestLSMWithLowestIndex.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/NearestLSMWithLowestIndex.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,10 +23,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct Choice { @@ -102,7 +99,4 @@ static const DistanceWeightingWithLSMBuilder __distance("nearest-lsm-with-lowest-index"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/NearestLSMWithLowestIndex.h metview-5.19.2/mir/src/mir/method/knn/distance/NearestLSMWithLowestIndex.h --- metview-5.17.4/mir/src/mir/method/knn/distance/NearestLSMWithLowestIndex.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/NearestLSMWithLowestIndex.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,17 +15,12 @@ #include "mir/method/knn/distance/DistanceWeightingWithLSM.h" -namespace mir { -namespace lsm { +namespace mir::lsm { class LandSeaMasks; -} -} // namespace mir +} // namespace mir::lsm -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { // Note: DistanceWeightingFactory cannot instantiate this because it @@ -44,7 +39,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/NearestNeighbour.cc metview-5.19.2/mir/src/mir/method/knn/distance/NearestNeighbour.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/NearestNeighbour.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/NearestNeighbour.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { NearestNeighbour::NearestNeighbour(const param::MIRParametrisation& /*unused*/) {} @@ -58,7 +55,4 @@ static const DistanceWeightingBuilder __distance("nearest-neighbour"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/NearestNeighbour.h metview-5.19.2/mir/src/mir/method/knn/distance/NearestNeighbour.h --- metview-5.17.4/mir/src/mir/method/knn/distance/NearestNeighbour.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/NearestNeighbour.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/distance/DistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct NearestNeighbour : DistanceWeighting { @@ -33,7 +30,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/NoDistanceWeighting.cc metview-5.19.2/mir/src/mir/method/knn/distance/NoDistanceWeighting.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/NoDistanceWeighting.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/NoDistanceWeighting.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { NoDistanceWeighting::NoDistanceWeighting(const param::MIRParametrisation& /*unused*/) {} @@ -66,7 +63,4 @@ static const DistanceWeightingBuilder __distance2("no"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/NoDistanceWeighting.h metview-5.19.2/mir/src/mir/method/knn/distance/NoDistanceWeighting.h --- metview-5.17.4/mir/src/mir/method/knn/distance/NoDistanceWeighting.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/NoDistanceWeighting.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/distance/DistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct NoDistanceWeighting : DistanceWeighting { @@ -33,7 +30,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/PseudoLaplace.cc metview-5.19.2/mir/src/mir/method/knn/distance/PseudoLaplace.cc --- metview-5.17.4/mir/src/mir/method/knn/distance/PseudoLaplace.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/PseudoLaplace.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,10 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { PseudoLaplace::PseudoLaplace(const param::MIRParametrisation& /*unused*/) {} @@ -123,7 +120,4 @@ static const DistanceWeightingBuilder __distance("pseudo-laplace"); -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/distance/PseudoLaplace.h metview-5.19.2/mir/src/mir/method/knn/distance/PseudoLaplace.h --- metview-5.17.4/mir/src/mir/method/knn/distance/PseudoLaplace.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/distance/PseudoLaplace.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/distance/DistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { -namespace distance { +namespace mir::method::knn::distance { struct PseudoLaplace : DistanceWeighting { @@ -33,7 +30,4 @@ }; -} // namespace distance -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::distance diff -Nru metview-5.17.4/mir/src/mir/method/knn/KNearest.cc metview-5.19.2/mir/src/mir/method/knn/KNearest.cc --- metview-5.17.4/mir/src/mir/method/knn/KNearest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/KNearest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { KNearest::KNearest(const param::MIRParametrisation& param) : KNearestNeighbours(param) { @@ -68,6 +66,4 @@ static const MethodBuilder __method3("k-nearest-neighbors"); -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/KNearest.h metview-5.19.2/mir/src/mir/method/knn/KNearest.h --- metview-5.17.4/mir/src/mir/method/knn/KNearest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/KNearest.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { class KNearest : public KNearestNeighbours { @@ -39,6 +37,4 @@ }; -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/KNearestNeighbours.cc metview-5.19.2/mir/src/mir/method/knn/KNearestNeighbours.cc --- metview-5.17.4/mir/src/mir/method/knn/KNearestNeighbours.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/KNearestNeighbours.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,9 +29,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { KNearestNeighbours::KNearestNeighbours(const param::MIRParametrisation& param) : MethodWeighted(param) {} @@ -151,6 +149,4 @@ } -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/KNearestNeighbours.h metview-5.19.2/mir/src/mir/method/knn/KNearestNeighbours.h --- metview-5.17.4/mir/src/mir/method/knn/KNearestNeighbours.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/KNearestNeighbours.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,23 +17,17 @@ #include "mir/method/MethodWeighted.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { namespace distance { class DistanceWeighting; } namespace pick { class Pick; } -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { class KNearestNeighbours : public MethodWeighted { @@ -63,6 +57,4 @@ }; -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/KNearestStatistics.cc metview-5.19.2/mir/src/mir/method/knn/KNearestStatistics.cc --- metview-5.17.4/mir/src/mir/method/knn/KNearestStatistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/KNearestStatistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { KNearestStatistics::KNearestStatistics(const param::MIRParametrisation& param) : @@ -68,6 +66,4 @@ static const MethodBuilder __method3("k-nearest-neighbors-statistics"); -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/KNearestStatistics.h metview-5.19.2/mir/src/mir/method/knn/KNearestStatistics.h --- metview-5.17.4/mir/src/mir/method/knn/KNearestStatistics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/KNearestStatistics.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/method/knn/distance/NoDistanceWeighting.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { class KNearestStatistics : public KNearestNeighbours { @@ -40,6 +38,4 @@ }; -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/NearestLSM.cc metview-5.19.2/mir/src/mir/method/knn/NearestLSM.cc --- metview-5.17.4/mir/src/mir/method/knn/NearestLSM.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/NearestLSM.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/param/RuntimeParametrisation.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { NearestLSM::NearestLSM(const param::MIRParametrisation& param) : KNearestNeighbours(param), distanceWeighting_(param) { @@ -106,6 +104,4 @@ static const MethodBuilder __method("nearest-lsm"); -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/NearestLSM.h metview-5.19.2/mir/src/mir/method/knn/NearestLSM.h --- metview-5.17.4/mir/src/mir/method/knn/NearestLSM.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/NearestLSM.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/method/knn/distance/DistanceWeightingWithLSM.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { class NearestLSM : public KNearestNeighbours { @@ -48,6 +46,4 @@ }; -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/NearestNeighbour.cc metview-5.19.2/mir/src/mir/method/knn/NearestNeighbour.cc --- metview-5.17.4/mir/src/mir/method/knn/NearestNeighbour.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/NearestNeighbour.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { NearestNeighbour::NearestNeighbour(const param::MIRParametrisation& param) : @@ -61,6 +59,4 @@ static const MethodBuilder __method3("nn"); // For the lazy -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/NearestNeighbour.h metview-5.19.2/mir/src/mir/method/knn/NearestNeighbour.h --- metview-5.17.4/mir/src/mir/method/knn/NearestNeighbour.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/NearestNeighbour.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/method/knn/distance/InverseDistanceWeightingSquared.h" -namespace mir { -namespace method { -namespace knn { +namespace mir::method::knn { class NearestNeighbour : public KNearestNeighbours { @@ -39,6 +37,4 @@ }; -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/DistanceAndNClosest.cc metview-5.19.2/mir/src/mir/method/knn/pick/DistanceAndNClosest.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/DistanceAndNClosest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/DistanceAndNClosest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { DistanceAndNClosest::DistanceAndNClosest(const param::MIRParametrisation& param) : nClosest_(param) { @@ -68,7 +65,4 @@ static const PickBuilder __pick("distance-and-nclosest"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/DistanceAndNClosest.h metview-5.19.2/mir/src/mir/method/knn/pick/DistanceAndNClosest.h --- metview-5.17.4/mir/src/mir/method/knn/pick/DistanceAndNClosest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/DistanceAndNClosest.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/method/knn/pick/Pick.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct DistanceAndNClosest : Pick { @@ -36,7 +33,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/Distance.cc metview-5.19.2/mir/src/mir/method/knn/pick/Distance.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/Distance.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/Distance.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { Distance::Distance(const param::MIRParametrisation& param) { @@ -62,7 +59,4 @@ static const PickBuilder __pick("distance"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/Distance.h metview-5.19.2/mir/src/mir/method/knn/pick/Distance.h --- metview-5.17.4/mir/src/mir/method/knn/pick/Distance.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/Distance.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/pick/Pick.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct Distance : Pick { @@ -34,7 +31,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/DistanceOrNClosest.cc metview-5.19.2/mir/src/mir/method/knn/pick/DistanceOrNClosest.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/DistanceOrNClosest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/DistanceOrNClosest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { DistanceOrNClosest::DistanceOrNClosest(const param::MIRParametrisation& param) : nClosest_(param) { @@ -68,7 +65,4 @@ static const PickBuilder __pick("distance-or-nclosest"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/DistanceOrNClosest.h metview-5.19.2/mir/src/mir/method/knn/pick/DistanceOrNClosest.h --- metview-5.17.4/mir/src/mir/method/knn/pick/DistanceOrNClosest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/DistanceOrNClosest.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/method/knn/pick/Pick.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct DistanceOrNClosest : Pick { @@ -36,7 +33,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/LongestElementDiagonalAndNClosest.cc metview-5.19.2/mir/src/mir/method/knn/pick/LongestElementDiagonalAndNClosest.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/LongestElementDiagonalAndNClosest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/LongestElementDiagonalAndNClosest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,10 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { LongestElementDiagonalAndNClosest::LongestElementDiagonalAndNClosest(const param::MIRParametrisation& param) : @@ -96,7 +93,4 @@ static const PickBuilder __pick("longest-element-diagonal-and-nclosest"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/LongestElementDiagonalAndNClosest.h metview-5.19.2/mir/src/mir/method/knn/pick/LongestElementDiagonalAndNClosest.h --- metview-5.17.4/mir/src/mir/method/knn/pick/LongestElementDiagonalAndNClosest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/LongestElementDiagonalAndNClosest.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/pick/Pick.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct LongestElementDiagonalAndNClosest : Pick { @@ -38,7 +35,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/NClosest.cc metview-5.19.2/mir/src/mir/method/knn/pick/NClosest.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/NClosest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/NClosest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,10 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { NClosest::NClosest(const param::MIRParametrisation& param) { @@ -61,7 +58,4 @@ static const PickBuilder __pick("nclosest"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/NClosest.h metview-5.19.2/mir/src/mir/method/knn/pick/NClosest.h --- metview-5.17.4/mir/src/mir/method/knn/pick/NClosest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/NClosest.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/pick/Pick.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct NClosest : Pick { @@ -34,7 +31,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/NClosestOrNearest.cc metview-5.19.2/mir/src/mir/method/knn/pick/NClosestOrNearest.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/NClosestOrNearest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/NClosestOrNearest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,10 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { NClosestOrNearest::NClosestOrNearest(size_t nClosest, double distanceTolerance) : @@ -98,7 +95,4 @@ static const PickBuilder __pick2("k"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/NClosestOrNearest.h metview-5.19.2/mir/src/mir/method/knn/pick/NClosestOrNearest.h --- metview-5.17.4/mir/src/mir/method/knn/pick/NClosestOrNearest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/NClosestOrNearest.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/pick/Pick.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct NClosestOrNearest : Pick { @@ -37,7 +34,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/NearestNeighbourWithLowestIndex.cc metview-5.19.2/mir/src/mir/method/knn/pick/NearestNeighbourWithLowestIndex.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/NearestNeighbourWithLowestIndex.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/NearestNeighbourWithLowestIndex.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,10 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { NearestNeighbourWithLowestIndex::NearestNeighbourWithLowestIndex(const param::MIRParametrisation& param) { @@ -91,7 +88,4 @@ static const PickBuilder __pick("nearest-neighbour-with-lowest-index"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/NearestNeighbourWithLowestIndex.h metview-5.19.2/mir/src/mir/method/knn/pick/NearestNeighbourWithLowestIndex.h --- metview-5.17.4/mir/src/mir/method/knn/pick/NearestNeighbourWithLowestIndex.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/NearestNeighbourWithLowestIndex.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,16 +15,13 @@ #include "mir/method/knn/pick/Pick.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct NearestNeighbourWithLowestIndex : Pick { NearestNeighbourWithLowestIndex(const param::MIRParametrisation&); - NearestNeighbourWithLowestIndex(const NearestNeighbourWithLowestIndex&) = delete; + NearestNeighbourWithLowestIndex(const NearestNeighbourWithLowestIndex&) = delete; NearestNeighbourWithLowestIndex& operator=(const NearestNeighbourWithLowestIndex&) = delete; void pick(const search::PointSearch&, const Point3&, neighbours_t&) const override; @@ -39,7 +36,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/Pick.cc metview-5.19.2/mir/src/mir/method/knn/pick/Pick.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/Pick.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/Pick.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { static util::recursive_mutex* local_mutex = nullptr; @@ -92,7 +89,4 @@ } -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/Pick.h metview-5.19.2/mir/src/mir/method/knn/pick/Pick.h --- metview-5.17.4/mir/src/mir/method/knn/pick/Pick.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/Pick.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,17 +21,12 @@ class MD5; } -namespace mir { -namespace repres { +namespace mir::repres { class Representation; -} -} // namespace mir +} // namespace mir::repres -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { class Pick { @@ -41,7 +36,7 @@ Pick(); virtual ~Pick(); - Pick(const Pick&) = delete; + Pick(const Pick&) = delete; Pick& operator=(const Pick&) = delete; virtual void pick(const search::PointSearch&, const Point3&, neighbours_t&) const = 0; @@ -66,7 +61,7 @@ std::string name_; virtual Pick* make(const param::MIRParametrisation&) = 0; - PickFactory(const PickFactory&) = default; + PickFactory(const PickFactory&) = default; PickFactory& operator=(const PickFactory&) = default; protected: @@ -88,7 +83,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/Sample.cc metview-5.19.2/mir/src/mir/method/knn/pick/Sample.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/Sample.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/Sample.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,10 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { Sample::Sample(const param::MIRParametrisation& param) { @@ -83,7 +80,4 @@ static const PickBuilder __pick("sample"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/Sample.h metview-5.19.2/mir/src/mir/method/knn/pick/Sample.h --- metview-5.17.4/mir/src/mir/method/knn/pick/Sample.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/Sample.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/method/knn/pick/Pick.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct Sample : Pick { @@ -35,7 +32,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/SortedSample.cc metview-5.19.2/mir/src/mir/method/knn/pick/SortedSample.cc --- metview-5.17.4/mir/src/mir/method/knn/pick/SortedSample.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/SortedSample.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,10 +17,7 @@ #include "eckit/utils/MD5.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { SortedSample::SortedSample(const param::MIRParametrisation& param) : sample_(param) {} @@ -60,7 +57,4 @@ static const PickBuilder __pick("sorted-sample"); -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/knn/pick/SortedSample.h metview-5.19.2/mir/src/mir/method/knn/pick/SortedSample.h --- metview-5.17.4/mir/src/mir/method/knn/pick/SortedSample.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/knn/pick/SortedSample.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/method/knn/pick/Sample.h" -namespace mir { -namespace method { -namespace knn { -namespace pick { +namespace mir::method::knn::pick { struct SortedSample : Pick { @@ -35,7 +32,4 @@ }; -} // namespace pick -} // namespace knn -} // namespace method -} // namespace mir +} // namespace mir::method::knn::pick diff -Nru metview-5.17.4/mir/src/mir/method/MatrixCacheCreator.cc metview-5.19.2/mir/src/mir/method/MatrixCacheCreator.cc --- metview-5.17.4/mir/src/mir/method/MatrixCacheCreator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/MatrixCacheCreator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace method { +namespace mir::method { MatrixCacheCreator::MatrixCacheCreator(const MethodWeighted& owner, context::Context& ctx, @@ -79,5 +78,4 @@ ASSERT(code == 0); } -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/MatrixCacheCreator.h metview-5.19.2/mir/src/mir/method/MatrixCacheCreator.h --- metview-5.17.4/mir/src/mir/method/MatrixCacheCreator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/MatrixCacheCreator.h 2023-07-15 08:28:47.000000000 +0000 @@ -36,8 +36,7 @@ } // namespace mir -namespace mir { -namespace method { +namespace mir::method { class MatrixCacheCreator : public caching::WeightCache::CacheContentCreator { @@ -49,10 +48,10 @@ const repres::Representation& out, const lsm::LandSeaMasks&, const Cropping&); ~MatrixCacheCreator() = default; - MatrixCacheCreator(const MatrixCacheCreator&) = delete; - MatrixCacheCreator(MatrixCacheCreator&&) = delete; + MatrixCacheCreator(const MatrixCacheCreator&) = delete; + MatrixCacheCreator(MatrixCacheCreator&&) = delete; MatrixCacheCreator& operator=(const MatrixCacheCreator&) = delete; - MatrixCacheCreator& operator=(MatrixCacheCreator&&) = delete; + MatrixCacheCreator& operator=(MatrixCacheCreator&&) = delete; private: const MethodWeighted& owner_; @@ -64,5 +63,4 @@ }; -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/Method.cc metview-5.19.2/mir/src/mir/method/Method.cc --- metview-5.17.4/mir/src/mir/method/Method.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/Method.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,8 +29,7 @@ #endif -namespace mir { -namespace method { +namespace mir::method { Method::Method(const param::MIRParametrisation& params) : parametrisation_(params) { @@ -105,5 +104,4 @@ } -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/Method.h metview-5.19.2/mir/src/mir/method/Method.h --- metview-5.17.4/mir/src/mir/method/Method.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/Method.h 2023-07-15 08:28:47.000000000 +0000 @@ -36,8 +36,7 @@ } // namespace mir -namespace mir { -namespace method { +namespace mir::method { class Method { @@ -81,7 +80,7 @@ std::string name_; virtual Method* make(const param::MIRParametrisation&) = 0; - MethodFactory(const MethodFactory&) = delete; + MethodFactory(const MethodFactory&) = delete; MethodFactory& operator=(const MethodFactory&) = delete; protected: @@ -103,5 +102,4 @@ }; -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/MethodWeighted.cc metview-5.19.2/mir/src/mir/method/MethodWeighted.cc --- metview-5.17.4/mir/src/mir/method/MethodWeighted.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/MethodWeighted.cc 2023-07-15 08:28:47.000000000 +0000 @@ -40,8 +40,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { +namespace mir::method { static util::recursive_mutex local_mutex; @@ -533,5 +532,4 @@ } -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/MethodWeighted.h metview-5.19.2/mir/src/mir/method/MethodWeighted.h --- metview-5.17.4/mir/src/mir/method/MethodWeighted.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/MethodWeighted.h 2023-07-15 08:28:47.000000000 +0000 @@ -44,8 +44,7 @@ } // namespace mir -namespace mir { -namespace method { +namespace mir::method { class MethodWeighted : public Method { @@ -168,5 +167,4 @@ }; -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/Heaviest.cc metview-5.19.2/mir/src/mir/method/nonlinear/Heaviest.cc --- metview-5.17.4/mir/src/mir/method/nonlinear/Heaviest.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/Heaviest.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "eckit/utils/MD5.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { Heaviest::Heaviest(const param::MIRParametrisation& param) : NonLinear(param) {} @@ -79,6 +77,4 @@ static const NonLinearBuilder __nonlinear("heaviest"); -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/Heaviest.h metview-5.19.2/mir/src/mir/method/nonlinear/Heaviest.h --- metview-5.17.4/mir/src/mir/method/nonlinear/Heaviest.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/Heaviest.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/nonlinear/NonLinear.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { struct Heaviest : NonLinear { @@ -34,6 +32,4 @@ }; -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfAllMissing.cc metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfAllMissing.cc --- metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfAllMissing.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfAllMissing.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { MissingIfAllMissing::MissingIfAllMissing(const param::MIRParametrisation& param) : NonLinear(param) {} @@ -113,6 +111,4 @@ static const NonLinearBuilder __nonlinear("missing-if-all-missing"); -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfAllMissing.h metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfAllMissing.h --- metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfAllMissing.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfAllMissing.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/nonlinear/NonLinear.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { struct MissingIfAllMissing : NonLinear { @@ -34,6 +32,4 @@ }; -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfAnyMissing.cc metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfAnyMissing.cc --- metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfAnyMissing.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfAnyMissing.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { MissingIfAnyMissing::MissingIfAnyMissing(const param::MIRParametrisation& param) : NonLinear(param) {} @@ -95,6 +93,4 @@ static const NonLinearBuilder __nonlinear("missing-if-any-missing"); -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfAnyMissing.h metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfAnyMissing.h --- metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfAnyMissing.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfAnyMissing.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/nonlinear/NonLinear.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { struct MissingIfAnyMissing : NonLinear { @@ -34,6 +32,4 @@ }; -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfHeaviestMissing.cc metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfHeaviestMissing.cc --- metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfHeaviestMissing.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfHeaviestMissing.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { MissingIfHeaviestMissing::MissingIfHeaviestMissing(const param::MIRParametrisation& param) : NonLinear(param) {} @@ -118,6 +116,4 @@ static const NonLinearBuilder __nonlinear("missing-if-heaviest-missing"); -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfHeaviestMissing.h metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfHeaviestMissing.h --- metview-5.17.4/mir/src/mir/method/nonlinear/MissingIfHeaviestMissing.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/MissingIfHeaviestMissing.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/nonlinear/NonLinear.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { struct MissingIfHeaviestMissing : NonLinear { @@ -34,6 +32,4 @@ }; -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/NonLinear.cc metview-5.19.2/mir/src/mir/method/nonlinear/NonLinear.cc --- metview-5.17.4/mir/src/mir/method/nonlinear/NonLinear.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/NonLinear.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { static util::recursive_mutex* local_mutex = nullptr; @@ -86,6 +84,4 @@ } -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/NonLinear.h metview-5.19.2/mir/src/mir/method/nonlinear/NonLinear.h --- metview-5.17.4/mir/src/mir/method/nonlinear/NonLinear.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/NonLinear.h 2023-07-15 08:28:47.000000000 +0000 @@ -35,16 +35,14 @@ } // namespace mir -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { class NonLinear { public: NonLinear(const param::MIRParametrisation&); - NonLinear(const NonLinear&) = delete; + NonLinear(const NonLinear&) = delete; void operator=(const NonLinear&) = delete; virtual ~NonLinear(); @@ -74,7 +72,7 @@ std::string name_; virtual NonLinear* make(const param::MIRParametrisation&) = 0; - NonLinearFactory(const NonLinearFactory&) = delete; + NonLinearFactory(const NonLinearFactory&) = delete; NonLinearFactory& operator=(const NonLinearFactory&) = delete; protected: @@ -96,6 +94,4 @@ }; -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/NoNonLinear.cc metview-5.19.2/mir/src/mir/method/nonlinear/NoNonLinear.cc --- metview-5.17.4/mir/src/mir/method/nonlinear/NoNonLinear.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/NoNonLinear.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "eckit/utils/MD5.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { NoNonLinear::NoNonLinear(const param::MIRParametrisation& param) : NonLinear(param) {} @@ -55,6 +53,4 @@ static const NonLinearBuilder __nonlinear("no"); -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/NoNonLinear.h metview-5.19.2/mir/src/mir/method/nonlinear/NoNonLinear.h --- metview-5.17.4/mir/src/mir/method/nonlinear/NoNonLinear.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/NoNonLinear.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/nonlinear/NonLinear.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { struct NoNonLinear : NonLinear { @@ -34,6 +32,4 @@ }; -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/SimulateMissingValue.cc metview-5.19.2/mir/src/mir/method/nonlinear/SimulateMissingValue.cc --- metview-5.17.4/mir/src/mir/method/nonlinear/SimulateMissingValue.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/SimulateMissingValue.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { SimulateMissingValue::SimulateMissingValue(const param::MIRParametrisation& param) : NonLinear(param) { @@ -128,6 +126,4 @@ static const NonLinearBuilder __nonlinear("simulated-missing-value"); -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/nonlinear/SimulateMissingValue.h metview-5.19.2/mir/src/mir/method/nonlinear/SimulateMissingValue.h --- metview-5.17.4/mir/src/mir/method/nonlinear/SimulateMissingValue.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/nonlinear/SimulateMissingValue.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/nonlinear/NonLinear.h" -namespace mir { -namespace method { -namespace nonlinear { +namespace mir::method::nonlinear { struct SimulateMissingValue : NonLinear { @@ -37,6 +35,4 @@ }; -} // namespace nonlinear -} // namespace method -} // namespace mir +} // namespace mir::method::nonlinear diff -Nru metview-5.17.4/mir/src/mir/method/ProxyMethod.cc metview-5.19.2/mir/src/mir/method/ProxyMethod.cc --- metview-5.17.4/mir/src/mir/method/ProxyMethod.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/ProxyMethod.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace method { +namespace mir::method { struct StructuredBicubic final : public ProxyMethod { @@ -193,5 +192,4 @@ } -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/ProxyMethod.h metview-5.19.2/mir/src/mir/method/ProxyMethod.h --- metview-5.17.4/mir/src/mir/method/ProxyMethod.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/ProxyMethod.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { +namespace mir::method { class ProxyMethod : public Method { @@ -114,5 +113,4 @@ }; -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/solver/Multiply.cc metview-5.19.2/mir/src/mir/method/solver/Multiply.cc --- metview-5.17.4/mir/src/mir/method/solver/Multiply.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/solver/Multiply.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace solver { +namespace mir::method::solver { Multiply::Multiply(const param::MIRParametrisation& param) : @@ -68,6 +66,4 @@ } -} // namespace solver -} // namespace method -} // namespace mir +} // namespace mir::method::solver diff -Nru metview-5.17.4/mir/src/mir/method/solver/Multiply.h metview-5.19.2/mir/src/mir/method/solver/Multiply.h --- metview-5.17.4/mir/src/mir/method/solver/Multiply.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/solver/Multiply.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,16 +15,12 @@ #include "mir/method/solver/Solver.h" -namespace eckit { -namespace linalg { +namespace eckit::linalg { class LinearAlgebraSparse; -} -} // namespace eckit +} // namespace eckit::linalg -namespace mir { -namespace method { -namespace solver { +namespace mir::method::solver { /// Linear system solving by matrix multiplication @@ -43,6 +39,4 @@ }; -} // namespace solver -} // namespace method -} // namespace mir +} // namespace mir::method::solver diff -Nru metview-5.17.4/mir/src/mir/method/solver/Solver.h metview-5.19.2/mir/src/mir/method/solver/Solver.h --- metview-5.17.4/mir/src/mir/method/solver/Solver.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/solver/Solver.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,16 +22,12 @@ class MD5; } -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace method { -namespace solver { +namespace mir::method::solver { /// Solve linear system (B = W A) @@ -39,7 +35,7 @@ public: Solver(const param::MIRParametrisation&) {} - Solver(const Solver&) = delete; + Solver(const Solver&) = delete; void operator=(const Solver&) = delete; virtual ~Solver() = default; @@ -61,6 +57,4 @@ }; -} // namespace solver -} // namespace method -} // namespace mir +} // namespace mir::method::solver diff -Nru metview-5.17.4/mir/src/mir/method/solver/Statistics.cc metview-5.19.2/mir/src/mir/method/solver/Statistics.cc --- metview-5.17.4/mir/src/mir/method/solver/Statistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/solver/Statistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace method { -namespace solver { +namespace mir::method::solver { Statistics::Statistics(const param::MIRParametrisation& param, stats::Field* fieldStats) : @@ -45,7 +43,7 @@ WeightMatrix::const_iterator it(W); for (WeightMatrix::Size r = 0; r < W.rows(); ++r) { - stats_->reset(missingValue, std::isnan(missingValue) != 0); + stats_->reset(missingValue, std::isnan(missingValue)); for (; it != W.end(r); ++it) { ASSERT(it.col() < N); @@ -53,7 +51,7 @@ } auto value = stats_->value(); - B(r, 0) = static_cast(std::isnan(value) != 0 ? missingValue : value); + B(r, 0) = static_cast(std::isnan(value) ? missingValue : value); } } @@ -74,6 +72,4 @@ } -} // namespace solver -} // namespace method -} // namespace mir +} // namespace mir::method::solver diff -Nru metview-5.17.4/mir/src/mir/method/solver/Statistics.h metview-5.19.2/mir/src/mir/method/solver/Statistics.h --- metview-5.17.4/mir/src/mir/method/solver/Statistics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/solver/Statistics.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,23 +17,19 @@ #include "mir/method/solver/Solver.h" -namespace mir { -namespace stats { +namespace mir::stats { class Field; -} -} // namespace mir +} // namespace mir::stats -namespace mir { -namespace method { -namespace solver { +namespace mir::method::solver { /// Non-linear system solving by calculating statistics on sets of input points (substitutes matrix multiply) struct Statistics final : solver::Solver { Statistics(const param::MIRParametrisation&, stats::Field*); - Statistics(const Statistics&) = delete; + Statistics(const Statistics&) = delete; void operator=(const Statistics&) = delete; void solve(const MethodWeighted::Matrix& A, const MethodWeighted::WeightMatrix& W, MethodWeighted::Matrix& B, @@ -50,6 +46,4 @@ }; -} // namespace solver -} // namespace method -} // namespace mir +} // namespace mir::method::solver diff -Nru metview-5.17.4/mir/src/mir/method/structured/StructuredBilinearLatLon.cc metview-5.19.2/mir/src/mir/method/structured/StructuredBilinearLatLon.cc --- metview-5.17.4/mir/src/mir/method/structured/StructuredBilinearLatLon.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/structured/StructuredBilinearLatLon.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace structured { +namespace mir::method::structured { static const MethodBuilder __method("structured-bilinear-latlon"); @@ -294,6 +292,4 @@ } -} // namespace structured -} // namespace method -} // namespace mir +} // namespace mir::method::structured diff -Nru metview-5.17.4/mir/src/mir/method/structured/StructuredBilinearLatLon.h metview-5.19.2/mir/src/mir/method/structured/StructuredBilinearLatLon.h --- metview-5.17.4/mir/src/mir/method/structured/StructuredBilinearLatLon.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/structured/StructuredBilinearLatLon.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/structured/StructuredMethod.h" -namespace mir { -namespace method { -namespace structured { +namespace mir::method::structured { class StructuredBilinearLatLon : public StructuredMethod { @@ -39,6 +37,4 @@ }; -} // namespace structured -} // namespace method -} // namespace mir +} // namespace mir::method::structured diff -Nru metview-5.17.4/mir/src/mir/method/structured/StructuredLinear3D.cc metview-5.19.2/mir/src/mir/method/structured/StructuredLinear3D.cc --- metview-5.17.4/mir/src/mir/method/structured/StructuredLinear3D.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/structured/StructuredLinear3D.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,9 +31,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace structured { +namespace mir::method::structured { static const MethodBuilder __method("structured-linear-3d"); @@ -117,7 +115,7 @@ const Longitude& l0 = icoords[l[0]].lon(); const Longitude& l1 = icoords[l[1]].lon(); trip = {WeightMatrix::Triplet(i, l[0], (l1 - p.lon()).value()), - WeightMatrix::Triplet(i, l[1], (p.lon() - l0).value())}; + WeightMatrix::Triplet(i, l[1], (p.lon() - l0).value())}; } else { @@ -228,6 +226,4 @@ } -} // namespace structured -} // namespace method -} // namespace mir +} // namespace mir::method::structured diff -Nru metview-5.17.4/mir/src/mir/method/structured/StructuredLinear3D.h metview-5.19.2/mir/src/mir/method/structured/StructuredLinear3D.h --- metview-5.17.4/mir/src/mir/method/structured/StructuredLinear3D.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/structured/StructuredLinear3D.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/method/structured/StructuredMethod.h" -namespace mir { -namespace method { -namespace structured { +namespace mir::method::structured { class StructuredLinear3D : public StructuredMethod { @@ -39,6 +37,4 @@ }; -} // namespace structured -} // namespace method -} // namespace mir +} // namespace mir::method::structured diff -Nru metview-5.17.4/mir/src/mir/method/structured/StructuredMethod.cc metview-5.19.2/mir/src/mir/method/structured/StructuredMethod.cc --- metview-5.17.4/mir/src/mir/method/structured/StructuredMethod.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/structured/StructuredMethod.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { -namespace structured { +namespace mir::method::structured { StructuredMethod::StructuredMethod(const param::MIRParametrisation& param) : MethodWeighted(param) {} @@ -182,6 +180,4 @@ out << "]"; } -} // namespace structured -} // namespace method -} // namespace mir +} // namespace mir::method::structured diff -Nru metview-5.17.4/mir/src/mir/method/structured/StructuredMethod.h metview-5.19.2/mir/src/mir/method/structured/StructuredMethod.h --- metview-5.17.4/mir/src/mir/method/structured/StructuredMethod.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/structured/StructuredMethod.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,7 @@ } // namespace mir -namespace mir { -namespace method { -namespace structured { +namespace mir::method::structured { class StructuredMethod : public MethodWeighted { @@ -75,6 +73,4 @@ }; -} // namespace structured -} // namespace method -} // namespace mir +} // namespace mir::method::structured diff -Nru metview-5.17.4/mir/src/mir/method/voronoi/VoronoiMethod.cc metview-5.19.2/mir/src/mir/method/voronoi/VoronoiMethod.cc --- metview-5.17.4/mir/src/mir/method/voronoi/VoronoiMethod.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/voronoi/VoronoiMethod.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,9 +28,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace method { -namespace voronoi { +namespace mir::method::voronoi { namespace { @@ -66,7 +64,7 @@ std::unique_ptr tree; { trace::ResourceUsage usage("assemble: create output k-d tree"); - tree.reset(new search::PointSearch(parametrisation_, out)); + tree = std::make_unique(parametrisation_, out); } @@ -106,7 +104,7 @@ { trace::ResourceUsage usage("assemble: create input k-d tree"); - tree.reset(new search::PointSearch(parametrisation_, in)); + tree = std::make_unique(parametrisation_, in); } { @@ -167,6 +165,4 @@ } -} // namespace voronoi -} // namespace method -} // namespace mir +} // namespace mir::method::voronoi diff -Nru metview-5.17.4/mir/src/mir/method/voronoi/VoronoiMethod.h metview-5.19.2/mir/src/mir/method/voronoi/VoronoiMethod.h --- metview-5.17.4/mir/src/mir/method/voronoi/VoronoiMethod.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/voronoi/VoronoiMethod.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/method/knn/pick/NClosestOrNearest.h" -namespace mir { -namespace method { -namespace voronoi { +namespace mir::method::voronoi { class VoronoiMethod : public MethodWeighted { @@ -101,6 +99,4 @@ }; -} // namespace voronoi -} // namespace method -} // namespace mir +} // namespace mir::method::voronoi diff -Nru metview-5.17.4/mir/src/mir/method/voronoi/VoronoiStatistics.cc metview-5.19.2/mir/src/mir/method/voronoi/VoronoiStatistics.cc --- metview-5.17.4/mir/src/mir/method/voronoi/VoronoiStatistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/voronoi/VoronoiStatistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/stats/Field.h" -namespace mir { -namespace method { -namespace voronoi { +namespace mir::method::voronoi { VoronoiStatistics::VoronoiStatistics(const param::MIRParametrisation& param) : VoronoiMethod(param) { @@ -33,6 +31,4 @@ static const MethodBuilder __builder("voronoi-statistics"); -} // namespace voronoi -} // namespace method -} // namespace mir +} // namespace mir::method::voronoi diff -Nru metview-5.17.4/mir/src/mir/method/voronoi/VoronoiStatistics.h metview-5.19.2/mir/src/mir/method/voronoi/VoronoiStatistics.h --- metview-5.17.4/mir/src/mir/method/voronoi/VoronoiStatistics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/voronoi/VoronoiStatistics.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,18 +15,14 @@ #include "mir/method/voronoi/VoronoiMethod.h" -namespace mir { -namespace method { -namespace voronoi { +namespace mir::method::voronoi { struct VoronoiStatistics final : VoronoiMethod { explicit VoronoiStatistics(const param::MIRParametrisation&); VoronoiStatistics(const VoronoiStatistics&) = delete; - void operator=(const VoronoiStatistics&) = delete; + void operator=(const VoronoiStatistics&) = delete; }; -} // namespace voronoi -} // namespace method -} // namespace mir +} // namespace mir::method::voronoi diff -Nru metview-5.17.4/mir/src/mir/method/WeightMatrix.cc metview-5.19.2/mir/src/mir/method/WeightMatrix.cc --- metview-5.17.4/mir/src/mir/method/WeightMatrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/WeightMatrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace method { +namespace mir::method { WeightMatrix::WeightMatrix(SparseMatrix::Allocator* alloc) : SparseMatrix(alloc) {} @@ -153,5 +152,4 @@ } -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/method/WeightMatrix.h metview-5.19.2/mir/src/mir/method/WeightMatrix.h --- metview-5.17.4/mir/src/mir/method/WeightMatrix.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/method/WeightMatrix.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "eckit/linalg/SparseMatrix.h" -namespace mir { -namespace method { +namespace mir::method { class WeightMatrix : public eckit::linalg::SparseMatrix { @@ -69,5 +68,4 @@ }; -} // namespace method -} // namespace mir +} // namespace mir::method diff -Nru metview-5.17.4/mir/src/mir/netcdf/AllLeapCalendar.cc metview-5.19.2/mir/src/mir/netcdf/AllLeapCalendar.cc --- metview-5.17.4/mir/src/mir/netcdf/AllLeapCalendar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/AllLeapCalendar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { AllLeapCalendar::AllLeapCalendar(const Variable& /*variable*/) {} @@ -34,5 +33,4 @@ static const CodecBuilder builder3("366_day"); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/AllLeapCalendar.h metview-5.19.2/mir/src/mir/netcdf/AllLeapCalendar.h --- metview-5.17.4/mir/src/mir/netcdf/AllLeapCalendar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/AllLeapCalendar.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Calendar.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class AllLeapCalendar : public Calendar { @@ -29,5 +28,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Attribute.cc metview-5.19.2/mir/src/mir/netcdf/Attribute.cc --- metview-5.17.4/mir/src/mir/netcdf/Attribute.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Attribute.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Attribute::Attribute(Endowed& owner, const std::string& name, Value* value) : owner_(owner), name_(name), value_(value) {} @@ -77,5 +76,4 @@ NOTIMP; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Attribute.h metview-5.19.2/mir/src/mir/netcdf/Attribute.h --- metview-5.17.4/mir/src/mir/netcdf/Attribute.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Attribute.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,16 +16,13 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Endowed; class Value; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Attribute { @@ -71,5 +68,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Calendar.cc metview-5.19.2/mir/src/mir/netcdf/Calendar.cc --- metview-5.17.4/mir/src/mir/netcdf/Calendar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Calendar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,8 +13,7 @@ #include "mir/netcdf/Calendar.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { bool Calendar::timeAxis() const { @@ -22,5 +21,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Calendar.h metview-5.19.2/mir/src/mir/netcdf/Calendar.h --- metview-5.17.4/mir/src/mir/netcdf/Calendar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Calendar.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/netcdf/Codec.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Calendar : public Codec { @@ -35,5 +32,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/CellMethodInputVariable.cc metview-5.19.2/mir/src/mir/netcdf/CellMethodInputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/CellMethodInputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/CellMethodInputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/netcdf/CellMethodOutputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { CellMethodInputVariable::CellMethodInputVariable(Dataset& owner, const std::string& name, int id, const std::vector& dimensions) : @@ -44,5 +43,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/CellMethodInputVariable.h metview-5.19.2/mir/src/mir/netcdf/CellMethodInputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/CellMethodInputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/CellMethodInputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/InputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class CellMethodInputVariable : public InputVariable { @@ -37,5 +36,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/CellMethodOutputVariable.cc metview-5.19.2/mir/src/mir/netcdf/CellMethodOutputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/CellMethodOutputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/CellMethodOutputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/MergePlan.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { CellMethodOutputVariable::CellMethodOutputVariable(Dataset& owner, const std::string& name, const std::vector& dimensions) : @@ -40,5 +39,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/CellMethodOutputVariable.h metview-5.19.2/mir/src/mir/netcdf/CellMethodOutputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/CellMethodOutputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/CellMethodOutputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/OutputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class CellMethodOutputVariable : public OutputVariable { @@ -30,5 +29,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Codec.cc metview-5.19.2/mir/src/mir/netcdf/Codec.cc --- metview-5.17.4/mir/src/mir/netcdf/Codec.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Codec.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Codec::Codec() = default; @@ -191,5 +190,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Codec.h metview-5.19.2/mir/src/mir/netcdf/Codec.h --- metview-5.17.4/mir/src/mir/netcdf/Codec.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Codec.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,15 +19,12 @@ #include "eckit/memory/Counted.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Codec : public eckit::Counted { @@ -35,7 +32,7 @@ Codec(); ~Codec() override; - Codec(const Codec&) = delete; + Codec(const Codec&) = delete; void operator=(const Codec&) = delete; virtual void decode(std::vector&) const; @@ -74,7 +71,7 @@ std::string name_; virtual Codec* make(const Variable&) = 0; - CodecFactory(const CodecFactory&) = delete; + CodecFactory(const CodecFactory&) = delete; CodecFactory& operator=(const CodecFactory&) = delete; protected: @@ -98,5 +95,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/CoordinateInputVariable.cc metview-5.19.2/mir/src/mir/netcdf/CoordinateInputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/CoordinateInputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/CoordinateInputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/ScalarCoordinateInputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { CoordinateInputVariable::CoordinateInputVariable(Dataset& owner, const std::string& name, int id, @@ -59,5 +58,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/CoordinateInputVariable.h metview-5.19.2/mir/src/mir/netcdf/CoordinateInputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/CoordinateInputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/CoordinateInputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/InputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class CoordinateInputVariable : public InputVariable { @@ -36,5 +35,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/CoordinateOutputVariable.cc metview-5.19.2/mir/src/mir/netcdf/CoordinateOutputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/CoordinateOutputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/CoordinateOutputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "mir/netcdf/Type.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { CoordinateOutputVariable::CoordinateOutputVariable(Dataset& owner, const std::string& name, @@ -56,5 +55,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/CoordinateOutputVariable.h metview-5.19.2/mir/src/mir/netcdf/CoordinateOutputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/CoordinateOutputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/CoordinateOutputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/OutputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class CoordinateOutputVariable : public OutputVariable { @@ -31,5 +30,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Curvilinear.cc metview-5.19.2/mir/src/mir/netcdf/Curvilinear.cc --- metview-5.17.4/mir/src/mir/netcdf/Curvilinear.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Curvilinear.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Curvilinear::Curvilinear(const Variable& variable, const std::vector& latitudes, @@ -273,5 +272,4 @@ static const GridSpecGuesserBuilder builder(3); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Curvilinear.h metview-5.19.2/mir/src/mir/netcdf/Curvilinear.h --- metview-5.17.4/mir/src/mir/netcdf/Curvilinear.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Curvilinear.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/GridSpec.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Curvilinear : public GridSpec { @@ -59,5 +58,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DataInputVariable.cc metview-5.19.2/mir/src/mir/netcdf/DataInputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/DataInputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DataInputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { DataInputVariable::DataInputVariable(Dataset& owner, const std::string& name, int id, @@ -172,5 +171,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DataInputVariable.h metview-5.19.2/mir/src/mir/netcdf/DataInputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/DataInputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DataInputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/InputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class DataInputVariable : public InputVariable { @@ -47,5 +46,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DataOutputVariable.cc metview-5.19.2/mir/src/mir/netcdf/DataOutputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/DataOutputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DataOutputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/netcdf/MergeDataStep.h" #include "mir/netcdf/MergePlan.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { DataOutputVariable::DataOutputVariable(Dataset& owner, const std::string& name, const std::vector& dimensions) : @@ -49,5 +48,4 @@ NOTIMP; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DataOutputVariable.h metview-5.19.2/mir/src/mir/netcdf/DataOutputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/DataOutputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DataOutputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/OutputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class DataOutputVariable : public OutputVariable { @@ -35,5 +34,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Dataset.cc metview-5.19.2/mir/src/mir/netcdf/Dataset.cc --- metview-5.17.4/mir/src/mir/netcdf/Dataset.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Dataset.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { Dataset::Dataset(const std::string& path) : path_(path) {} @@ -161,5 +160,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Dataset.h metview-5.19.2/mir/src/mir/netcdf/Dataset.h --- metview-5.17.4/mir/src/mir/netcdf/Dataset.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Dataset.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,16 +18,13 @@ #include "mir/netcdf/Endowed.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Dimension; class Variable; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Dataset : public Endowed { @@ -85,5 +82,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Dimension.cc metview-5.19.2/mir/src/mir/netcdf/Dimension.cc --- metview-5.17.4/mir/src/mir/netcdf/Dimension.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Dimension.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/netcdf/Remapping.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Dimension::Dimension(Dataset& owner, const std::string& name, size_t len) : owner_(owner), name_(name), len_(len) {} @@ -91,5 +90,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Dimension.h metview-5.19.2/mir/src/mir/netcdf/Dimension.h --- metview-5.17.4/mir/src/mir/netcdf/Dimension.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Dimension.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,15 +17,12 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Dataset; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Dimension { @@ -33,7 +30,7 @@ Dimension(Dataset& owner, const std::string& name, size_t len); virtual ~Dimension(); - Dimension(const Dimension&) = delete; + Dimension(const Dimension&) = delete; Dimension& operator=(const Dimension&) = delete; const std::string& name() const; @@ -68,5 +65,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DummyInputVariable.cc metview-5.19.2/mir/src/mir/netcdf/DummyInputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/DummyInputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DummyInputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { DummyInputVariable::DummyInputVariable(Dataset& owner, const Variable& parent) : @@ -69,5 +68,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DummyInputVariable.h metview-5.19.2/mir/src/mir/netcdf/DummyInputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/DummyInputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DummyInputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class DummyInputVariable : public Variable { @@ -45,5 +44,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DummyMatrix.cc metview-5.19.2/mir/src/mir/netcdf/DummyMatrix.cc --- metview-5.17.4/mir/src/mir/netcdf/DummyMatrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DummyMatrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { DummyMatrix::DummyMatrix(const Variable& v) : Matrix(v.matrix()->type(), v.name(), v.matrix()->size()), other_(v.matrix()) { @@ -33,5 +32,4 @@ out << "DummyMatrix[type=" << *type_ << ",name=" << name_ << ",other=" << *other_ << "]"; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DummyMatrix.h metview-5.19.2/mir/src/mir/netcdf/DummyMatrix.h --- metview-5.17.4/mir/src/mir/netcdf/DummyMatrix.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DummyMatrix.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/netcdf/Matrix.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class DummyMatrix : public Matrix { @@ -40,5 +37,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/DummyVariable.h metview-5.19.2/mir/src/mir/netcdf/DummyVariable.h --- metview-5.17.4/mir/src/mir/netcdf/DummyVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/DummyVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class DummyVariable : public Variable { @@ -44,5 +43,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Endowed.cc metview-5.19.2/mir/src/mir/netcdf/Endowed.cc --- metview-5.17.4/mir/src/mir/netcdf/Endowed.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Endowed.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/netcdf/Type.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Endowed::Endowed() = default; @@ -106,5 +105,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Endowed.h metview-5.19.2/mir/src/mir/netcdf/Endowed.h --- metview-5.17.4/mir/src/mir/netcdf/Endowed.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Endowed.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Attribute; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Endowed { @@ -58,5 +55,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Exceptions.cc metview-5.19.2/mir/src/mir/netcdf/Exceptions.cc --- metview-5.17.4/mir/src/mir/netcdf/Exceptions.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Exceptions.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,11 @@ #include -namespace mir { -namespace netcdf { -namespace exception { +namespace mir::netcdf::exception { NCError::NCError(int e, const std::string& call, const std::string& path) : eckit::Exception(std::string("NCError: ") + nc_strerror(e) + +" " + call + " (" + path + ")") {} -} // namespace exception -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf::exception diff -Nru metview-5.17.4/mir/src/mir/netcdf/Exceptions.h metview-5.19.2/mir/src/mir/netcdf/Exceptions.h --- metview-5.17.4/mir/src/mir/netcdf/Exceptions.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Exceptions.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace netcdf { -namespace exception { +namespace mir::netcdf::exception { using mir::exception::SeriousBug; @@ -37,7 +35,7 @@ inline int _nc_call(int e, const char* call, const std::string& path) { - if (e) { + if (e != 0) { throw NCError(e, call, path); } return e; @@ -47,6 +45,4 @@ #define NC_CALL(a, path) ::mir::netcdf::exception::_nc_call(a, #a, path) -} // namespace exception -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf::exception diff -Nru metview-5.17.4/mir/src/mir/netcdf/Field.cc metview-5.19.2/mir/src/mir/netcdf/Field.cc --- metview-5.17.4/mir/src/mir/netcdf/Field.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Field.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,6 +16,7 @@ #include "eckit/parser/YAMLParser.h" +#include "mir/config/LibMir.h" #include "mir/data/MIRField.h" #include "mir/netcdf/GridSpec.h" #include "mir/netcdf/Variable.h" @@ -23,8 +24,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Field::Field(const Variable& variable) : @@ -108,7 +108,7 @@ static void init() { - standard_names = eckit::YAMLParser::decodeFile("~mir/etc/mir/netcdf.yaml"); + standard_names = eckit::YAMLParser::decodeFile(LibMir::configFile(LibMir::config_file::NETCDF)); standard_names.dump(Log::info()) << std::endl; } @@ -131,5 +131,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Field.h metview-5.19.2/mir/src/mir/netcdf/Field.h --- metview-5.17.4/mir/src/mir/netcdf/Field.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Field.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,7 @@ } // namespace mir -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Field { @@ -88,5 +87,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/GregorianCalendar.cc metview-5.19.2/mir/src/mir/netcdf/GregorianCalendar.cc --- metview-5.17.4/mir/src/mir/netcdf/GregorianCalendar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/GregorianCalendar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { static long long offset = 0; @@ -166,5 +165,4 @@ static const CodecBuilder builder2("standard"); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/GregorianCalendar.h metview-5.19.2/mir/src/mir/netcdf/GregorianCalendar.h --- metview-5.17.4/mir/src/mir/netcdf/GregorianCalendar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/GregorianCalendar.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/netcdf/Calendar.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class GregorianCalendar : public Calendar { @@ -62,5 +61,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/GridSpec.cc metview-5.19.2/mir/src/mir/netcdf/GridSpec.cc --- metview-5.17.4/mir/src/mir/netcdf/GridSpec.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/GridSpec.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { static util::recursive_mutex* local_mutex = nullptr; @@ -89,5 +88,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/GridSpec.h metview-5.19.2/mir/src/mir/netcdf/GridSpec.h --- metview-5.17.4/mir/src/mir/netcdf/GridSpec.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/GridSpec.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,15 +18,12 @@ #include "mir/util/Types.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class GridSpec { @@ -34,7 +31,7 @@ GridSpec(const Variable&); virtual ~GridSpec(); - GridSpec(const GridSpec&) = delete; + GridSpec(const GridSpec&) = delete; void operator=(const GridSpec&) = delete; // -- Methods @@ -71,7 +68,7 @@ class GridSpecGuesser { - GridSpecGuesser(const GridSpecGuesser&) = delete; + GridSpecGuesser(const GridSpecGuesser&) = delete; GridSpecGuesser& operator=(const GridSpecGuesser&) = delete; public: @@ -99,5 +96,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/HyperCube.cc metview-5.19.2/mir/src/mir/netcdf/HyperCube.cc --- metview-5.17.4/mir/src/mir/netcdf/HyperCube.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/HyperCube.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,8 +13,7 @@ #include "mir/netcdf/HyperCube.h" #include "mir/netcdf/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { static void addLoop2(int d, size_t which, size_t where, size_t count, size_t depth, const HyperCube::Dimensions& dims, @@ -93,5 +92,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/HyperCube.h metview-5.19.2/mir/src/mir/netcdf/HyperCube.h --- metview-5.17.4/mir/src/mir/netcdf/HyperCube.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/HyperCube.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { // Helper class to handle multi-dimension objects @@ -97,13 +96,13 @@ inline // For speed void HyperCube::combine(Remapping& map1, Remapping& map2) { - if (map1.size() == 0) { + if (map1.empty()) { std::swap(map1, map2); } else { - for (Remapping::iterator i = map1.begin(); i != map1.end(); ++i) { + for (auto& i : map1) { // ASSERT(*i < map2.size()); - *i = map2[*i]; + i = map2[i]; } } } @@ -112,5 +111,4 @@ std::ostream& operator<<(std::ostream&, const HyperCube&); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputAttribute.cc metview-5.19.2/mir/src/mir/netcdf/InputAttribute.cc --- metview-5.17.4/mir/src/mir/netcdf/InputAttribute.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputAttribute.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/netcdf/Value.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { InputAttribute::InputAttribute(Endowed& owner, const std::string& name, Value* value) : Attribute(owner, name, value) {} @@ -39,5 +38,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputAttribute.h metview-5.19.2/mir/src/mir/netcdf/InputAttribute.h --- metview-5.17.4/mir/src/mir/netcdf/InputAttribute.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputAttribute.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Attribute.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class InputAttribute : public Attribute { @@ -31,5 +30,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputDataset.cc metview-5.19.2/mir/src/mir/netcdf/InputDataset.cc --- metview-5.17.4/mir/src/mir/netcdf/InputDataset.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputDataset.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { InputDataset::InputDataset(const std::string& path, NCFileCache& cache) : Dataset(path), cache_(cache) { @@ -207,5 +206,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputDataset.h metview-5.19.2/mir/src/mir/netcdf/InputDataset.h --- metview-5.17.4/mir/src/mir/netcdf/InputDataset.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputDataset.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,16 +15,13 @@ #include "mir/netcdf/Dataset.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Field; class NCFileCache; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class InputDataset : public Dataset { @@ -54,5 +51,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputDimension.cc metview-5.19.2/mir/src/mir/netcdf/InputDimension.cc --- metview-5.17.4/mir/src/mir/netcdf/InputDimension.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputDimension.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/OutputDimension.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { InputDimension::InputDimension(Dataset& owner, const std::string& name, int id, size_t len) : @@ -49,5 +48,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputDimension.h metview-5.19.2/mir/src/mir/netcdf/InputDimension.h --- metview-5.17.4/mir/src/mir/netcdf/InputDimension.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputDimension.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,12 +15,11 @@ #include "mir/netcdf/Dimension.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class InputDimension : public Dimension { - InputDimension(const InputDimension&) = delete; + InputDimension(const InputDimension&) = delete; InputDimension& operator=(const InputDimension&) = delete; public: @@ -42,5 +41,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputMatrix.cc metview-5.19.2/mir/src/mir/netcdf/InputMatrix.cc --- metview-5.17.4/mir/src/mir/netcdf/InputMatrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputMatrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ #include "mir/netcdf/Value.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { InputMatrix::InputMatrix(Type& type, int varid, const std::string& name, size_t size, NCFile& file) : @@ -161,5 +160,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputMatrix.h metview-5.19.2/mir/src/mir/netcdf/InputMatrix.h --- metview-5.17.4/mir/src/mir/netcdf/InputMatrix.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputMatrix.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/netcdf/Matrix.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class NCFile; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class InputMatrix : public Matrix { @@ -56,5 +53,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputVariable.cc metview-5.19.2/mir/src/mir/netcdf/InputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/InputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { InputVariable::InputVariable(Dataset& owner, const std::string& name, int id, @@ -63,5 +62,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/InputVariable.h metview-5.19.2/mir/src/mir/netcdf/InputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/InputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/InputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class InputVariable : public Variable { @@ -43,5 +42,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/JulianCalendar.cc metview-5.19.2/mir/src/mir/netcdf/JulianCalendar.cc --- metview-5.17.4/mir/src/mir/netcdf/JulianCalendar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/JulianCalendar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { JulianCalendar::JulianCalendar(const Variable& /*variable*/) {} @@ -33,5 +32,4 @@ static const CodecBuilder builder("julian"); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/JulianCalendar.h metview-5.19.2/mir/src/mir/netcdf/JulianCalendar.h --- metview-5.17.4/mir/src/mir/netcdf/JulianCalendar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/JulianCalendar.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Calendar.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class JulianCalendar : public Calendar { @@ -29,5 +28,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Mapper.h metview-5.19.2/mir/src/mir/netcdf/Mapper.h --- metview-5.17.4/mir/src/mir/netcdf/Mapper.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Mapper.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/Reshape.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { template @@ -34,7 +33,7 @@ void set(size_t i, T value); private: - Mapper(const Mapper&) = delete; + Mapper(const Mapper&) = delete; Mapper& operator=(const Mapper&) = delete; private: @@ -51,23 +50,23 @@ Mapper::Mapper(Mapper& parent, const std::vector& reshapes) : v_(parent.v_), set_(parent.set_), overlap_(parent.overlap_) { Reshape* r = nullptr; - for (std::vector::const_iterator j = reshapes.begin(); j != reshapes.end(); ++j) { - if (r && r->merge(*(*j))) { + for (auto* reshape : reshapes) { + if (r != nullptr && r->merge(*reshape)) { // Pass } else { - r = (*j); + r = reshape; r->attach(); reshapes_.push_back(r); } } - for (std::vector::iterator j = parent.reshapes_.begin(); j != parent.reshapes_.end(); ++j) { - if (r && r->merge(*(*j))) { + for (auto* reshape : parent.reshapes_) { + if (r != nullptr && r->merge(*reshape)) { // Pass } else { - r = (*j); + r = reshape; r->attach(); reshapes_.push_back(r); } @@ -77,8 +76,8 @@ template Mapper::~Mapper() { - for (std::vector::iterator j = reshapes_.begin(); j != reshapes_.end(); ++j) { - (*j)->detach(); + for (auto* reshape : reshapes_) { + reshape->detach(); } } @@ -86,9 +85,8 @@ template void Mapper::set(size_t i, T v) { - for (std::vector::iterator j = reshapes_.begin(); j != reshapes_.end(); ++j) { - Reshape* m = (*j); - size_t k = (*m)(i); + for (auto* reshape : reshapes_) { + size_t k = (*reshape)(i); ASSERT(k >= i); i = k; } @@ -106,5 +104,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Matrix.cc metview-5.19.2/mir/src/mir/netcdf/Matrix.cc --- metview-5.17.4/mir/src/mir/netcdf/Matrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Matrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/netcdf/Value.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Matrix::Matrix(Type& type, const std::string& name, size_t size) : @@ -207,5 +206,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Matrix.h metview-5.19.2/mir/src/mir/netcdf/Matrix.h --- metview-5.17.4/mir/src/mir/netcdf/Matrix.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Matrix.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,17 +18,14 @@ #include "eckit/memory/Counted.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Type; class Value; class Codec; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Matrix : public eckit::Counted { @@ -104,5 +101,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergeCoordinateMatrix.cc metview-5.19.2/mir/src/mir/netcdf/MergeCoordinateMatrix.cc --- metview-5.17.4/mir/src/mir/netcdf/MergeCoordinateMatrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergeCoordinateMatrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/Type.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { MergeCoordinateMatrix::MergeCoordinateMatrix(Matrix* out, Matrix* in, size_t size) : @@ -47,5 +46,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergeCoordinateMatrix.h metview-5.19.2/mir/src/mir/netcdf/MergeCoordinateMatrix.h --- metview-5.17.4/mir/src/mir/netcdf/MergeCoordinateMatrix.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergeCoordinateMatrix.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Matrix.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class MergeCoordinateMatrix : public Matrix { @@ -34,5 +33,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergeCoordinateStep.cc metview-5.19.2/mir/src/mir/netcdf/MergeCoordinateStep.cc --- metview-5.17.4/mir/src/mir/netcdf/MergeCoordinateStep.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergeCoordinateStep.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { MergeCoordinateStep::MergeCoordinateStep(Variable& out, const Variable& in) : out_(out), in_(in) {} @@ -68,5 +67,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergeCoordinateStep.h metview-5.19.2/mir/src/mir/netcdf/MergeCoordinateStep.h --- metview-5.17.4/mir/src/mir/netcdf/MergeCoordinateStep.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergeCoordinateStep.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/netcdf/Step.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class MergeCoordinateStep : public Step { @@ -43,5 +40,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergeDataMatrix.cc metview-5.19.2/mir/src/mir/netcdf/MergeDataMatrix.cc --- metview-5.17.4/mir/src/mir/netcdf/MergeDataMatrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergeDataMatrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/Type.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { MergeDataMatrix::MergeDataMatrix(Matrix* out, Matrix* in, size_t size) : @@ -47,5 +46,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergeDataMatrix.h metview-5.19.2/mir/src/mir/netcdf/MergeDataMatrix.h --- metview-5.17.4/mir/src/mir/netcdf/MergeDataMatrix.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergeDataMatrix.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Matrix.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class MergeDataMatrix : public Matrix { @@ -34,5 +33,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergeDataStep.cc metview-5.19.2/mir/src/mir/netcdf/MergeDataStep.cc --- metview-5.17.4/mir/src/mir/netcdf/MergeDataStep.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergeDataStep.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { MergeDataStep::MergeDataStep(Variable& out, const Variable& in) : out_(out), in_(in) {} @@ -66,5 +65,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergeDataStep.h metview-5.19.2/mir/src/mir/netcdf/MergeDataStep.h --- metview-5.17.4/mir/src/mir/netcdf/MergeDataStep.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergeDataStep.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/netcdf/Step.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class MergeDataStep : public Step { @@ -43,5 +40,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergePlan.cc metview-5.19.2/mir/src/mir/netcdf/MergePlan.cc --- metview-5.17.4/mir/src/mir/netcdf/MergePlan.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergePlan.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { MergePlan::MergePlan(Dataset& field) : field_(field) {} @@ -74,5 +73,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/MergePlan.h metview-5.19.2/mir/src/mir/netcdf/MergePlan.h --- metview-5.17.4/mir/src/mir/netcdf/MergePlan.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/MergePlan.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,16 +18,13 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; class Dataset; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class MergePlan { @@ -57,5 +54,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/NCFileCache.cc metview-5.19.2/mir/src/mir/netcdf/NCFileCache.cc --- metview-5.17.4/mir/src/mir/netcdf/NCFileCache.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/NCFileCache.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/NCFile.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { NCFileCache::NCFileCache() = default; @@ -38,5 +37,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/NCFileCache.h metview-5.19.2/mir/src/mir/netcdf/NCFileCache.h --- metview-5.17.4/mir/src/mir/netcdf/NCFileCache.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/NCFileCache.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class NCFile; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class NCFileCache { @@ -42,5 +39,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/NCFile.cc metview-5.19.2/mir/src/mir/netcdf/NCFile.cc --- metview-5.17.4/mir/src/mir/netcdf/NCFile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/NCFile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { NCFile::NCFile(const std::string& path) : path_(path), nc_(-1), open_(false) {} @@ -49,5 +48,4 @@ return path_; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/NCFile.h metview-5.19.2/mir/src/mir/netcdf/NCFile.h --- metview-5.17.4/mir/src/mir/netcdf/NCFile.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/NCFile.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class NCFile { @@ -51,5 +50,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/NoLeapCalendar.cc metview-5.19.2/mir/src/mir/netcdf/NoLeapCalendar.cc --- metview-5.17.4/mir/src/mir/netcdf/NoLeapCalendar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/NoLeapCalendar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { NoLeapCalendar::NoLeapCalendar(const Variable& /*variable*/) {} @@ -34,5 +33,4 @@ static const CodecBuilder builder2("365_day"); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/NoLeapCalendar.h metview-5.19.2/mir/src/mir/netcdf/NoLeapCalendar.h --- metview-5.17.4/mir/src/mir/netcdf/NoLeapCalendar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/NoLeapCalendar.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Calendar.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class NoLeapCalendar : public Calendar { @@ -29,5 +28,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/NoneCalendar.cc metview-5.19.2/mir/src/mir/netcdf/NoneCalendar.cc --- metview-5.17.4/mir/src/mir/netcdf/NoneCalendar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/NoneCalendar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { NoneCalendar::NoneCalendar(const Variable& /*variable*/) {} @@ -33,5 +32,4 @@ static const CodecBuilder builder("none"); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/NoneCalendar.h metview-5.19.2/mir/src/mir/netcdf/NoneCalendar.h --- metview-5.17.4/mir/src/mir/netcdf/NoneCalendar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/NoneCalendar.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Calendar.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class NoneCalendar : public Calendar { @@ -29,5 +28,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/OutputAttribute.cc metview-5.19.2/mir/src/mir/netcdf/OutputAttribute.cc --- metview-5.17.4/mir/src/mir/netcdf/OutputAttribute.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/OutputAttribute.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { /* See http://www.unidata.ucar.edu/software/netcdf/docs/netcdf/Attribute-Conventions.html */ @@ -74,5 +73,4 @@ out << "OutputAttribute[name=" << name_ << "]"; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/OutputAttribute.h metview-5.19.2/mir/src/mir/netcdf/OutputAttribute.h --- metview-5.17.4/mir/src/mir/netcdf/OutputAttribute.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/OutputAttribute.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Attribute.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class OutputAttribute : public Attribute { @@ -38,5 +37,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/OutputDataset.cc metview-5.19.2/mir/src/mir/netcdf/OutputDataset.cc --- metview-5.17.4/mir/src/mir/netcdf/OutputDataset.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/OutputDataset.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { OutputDataset::OutputDataset(const std::string& path, NCFileCache& cache, int format) : @@ -180,5 +179,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/OutputDataset.h metview-5.19.2/mir/src/mir/netcdf/OutputDataset.h --- metview-5.17.4/mir/src/mir/netcdf/OutputDataset.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/OutputDataset.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/netcdf/Dataset.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class NCFileCache; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class OutputDataset : public Dataset { @@ -53,5 +50,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/OutputDimension.cc metview-5.19.2/mir/src/mir/netcdf/OutputDimension.cc --- metview-5.17.4/mir/src/mir/netcdf/OutputDimension.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/OutputDimension.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { OutputDimension::OutputDimension(Dataset& owner, const std::string& name, size_t len) : @@ -55,5 +54,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/OutputDimension.h metview-5.19.2/mir/src/mir/netcdf/OutputDimension.h --- metview-5.17.4/mir/src/mir/netcdf/OutputDimension.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/OutputDimension.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Dimension.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class OutputDimension : public Dimension { @@ -39,5 +38,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/OutputVariable.cc metview-5.19.2/mir/src/mir/netcdf/OutputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/OutputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/OutputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/netcdf/Type.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { OutputVariable::OutputVariable(Dataset& owner, const std::string& name, const std::vector& dimensions) : @@ -88,5 +87,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/OutputVariable.h metview-5.19.2/mir/src/mir/netcdf/OutputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/OutputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/OutputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class OutputVariable : public Variable { @@ -42,5 +41,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/PackingCodec.cc metview-5.19.2/mir/src/mir/netcdf/PackingCodec.cc --- metview-5.17.4/mir/src/mir/netcdf/PackingCodec.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/PackingCodec.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { PackingCodec::PackingCodec(const Variable& variable) : @@ -51,5 +50,4 @@ static const CodecBuilder builder("packing"); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/PackingCodec.h metview-5.19.2/mir/src/mir/netcdf/PackingCodec.h --- metview-5.17.4/mir/src/mir/netcdf/PackingCodec.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/PackingCodec.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Codec.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class PackingCodec : public Codec { @@ -34,5 +33,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ProlepticCalendar.cc metview-5.19.2/mir/src/mir/netcdf/ProlepticCalendar.cc --- metview-5.17.4/mir/src/mir/netcdf/ProlepticCalendar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ProlepticCalendar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { ProlepticCalendar::ProlepticCalendar(const Variable& /*variable*/) {} @@ -33,5 +32,4 @@ static const CodecBuilder builder("proleptic_gregorian"); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ProlepticCalendar.h metview-5.19.2/mir/src/mir/netcdf/ProlepticCalendar.h --- metview-5.17.4/mir/src/mir/netcdf/ProlepticCalendar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ProlepticCalendar.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Calendar.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class ProlepticCalendar : public Calendar { @@ -29,5 +28,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Rectilinear.cc metview-5.19.2/mir/src/mir/netcdf/Rectilinear.cc --- metview-5.17.4/mir/src/mir/netcdf/Rectilinear.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Rectilinear.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Rectilinear::Rectilinear(const Variable& variable, double north, double south, const std::vector& latitudes, @@ -186,5 +185,4 @@ static const GridSpecGuesserBuilder builder(1); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Rectilinear.h metview-5.19.2/mir/src/mir/netcdf/Rectilinear.h --- metview-5.17.4/mir/src/mir/netcdf/Rectilinear.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Rectilinear.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/GridSpec.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Rectilinear : public GridSpec { @@ -62,5 +61,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/RegularLL.cc metview-5.19.2/mir/src/mir/netcdf/RegularLL.cc --- metview-5.17.4/mir/src/mir/netcdf/RegularLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/RegularLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { RegularLL::RegularLL(const Variable& variable, double north, double south, double south_north_increment, double west, @@ -214,5 +213,4 @@ static const GridSpecGuesserBuilder builder(0); // First choice -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/RegularLL.h metview-5.19.2/mir/src/mir/netcdf/RegularLL.h --- metview-5.17.4/mir/src/mir/netcdf/RegularLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/RegularLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/GridSpec.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class RegularLL : public GridSpec { @@ -65,5 +64,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Remapping.cc metview-5.19.2/mir/src/mir/netcdf/Remapping.cc --- metview-5.17.4/mir/src/mir/netcdf/Remapping.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Remapping.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/netcdf/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Remapping::Remapping(size_t s) { @@ -51,5 +50,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Remapping.h metview-5.19.2/mir/src/mir/netcdf/Remapping.h --- metview-5.17.4/mir/src/mir/netcdf/Remapping.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Remapping.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/netcdf/HyperCube.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Remapping : public HyperCube::Remapping, public eckit::Counted { @@ -43,5 +42,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Reshape.cc metview-5.19.2/mir/src/mir/netcdf/Reshape.cc --- metview-5.17.4/mir/src/mir/netcdf/Reshape.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Reshape.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,8 +14,7 @@ #include "mir/netcdf/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Reshape::Reshape(const HyperCube& cube, size_t which, size_t where, size_t count, char tag) : cube_(cube.dimensions()), @@ -94,5 +93,4 @@ return a; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Reshape.h metview-5.19.2/mir/src/mir/netcdf/Reshape.h --- metview-5.17.4/mir/src/mir/netcdf/Reshape.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Reshape.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/netcdf/HyperCube.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Reshape : public eckit::Counted { @@ -55,5 +54,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ReshapeVariableStep.cc metview-5.19.2/mir/src/mir/netcdf/ReshapeVariableStep.cc --- metview-5.17.4/mir/src/mir/netcdf/ReshapeVariableStep.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ReshapeVariableStep.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { ReshapeVariableStep::ReshapeVariableStep(Variable& out, const Dimension& dimension, size_t growth) : @@ -154,5 +153,4 @@ return false; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ReshapeVariableStep.h metview-5.19.2/mir/src/mir/netcdf/ReshapeVariableStep.h --- metview-5.17.4/mir/src/mir/netcdf/ReshapeVariableStep.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ReshapeVariableStep.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,16 +15,13 @@ #include "mir/netcdf/Step.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; class Dimension; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class ReshapeVariableStep : public Step { @@ -48,5 +45,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ScalarCoordinateInputVariable.cc metview-5.19.2/mir/src/mir/netcdf/ScalarCoordinateInputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/ScalarCoordinateInputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ScalarCoordinateInputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/netcdf/VirtualInputDimension.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { ScalarCoordinateInputVariable::ScalarCoordinateInputVariable(Dataset& owner, const std::string& name, int id, @@ -61,5 +60,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ScalarCoordinateInputVariable.h metview-5.19.2/mir/src/mir/netcdf/ScalarCoordinateInputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/ScalarCoordinateInputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ScalarCoordinateInputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/InputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class ScalarCoordinateInputVariable : public InputVariable { @@ -35,5 +34,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ScalarCoordinateOutputVariable.cc metview-5.19.2/mir/src/mir/netcdf/ScalarCoordinateOutputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/ScalarCoordinateOutputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ScalarCoordinateOutputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Matrix.h" #include "mir/netcdf/Type.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { ScalarCoordinateOutputVariable::ScalarCoordinateOutputVariable(Dataset& owner, const std::string& name, const std::vector& dimensions) : @@ -50,5 +49,4 @@ } } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ScalarCoordinateOutputVariable.h metview-5.19.2/mir/src/mir/netcdf/ScalarCoordinateOutputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/ScalarCoordinateOutputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ScalarCoordinateOutputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/OutputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class ScalarCoordinateOutputVariable : public OutputVariable { @@ -30,5 +29,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/SimpleInputVariable.cc metview-5.19.2/mir/src/mir/netcdf/SimpleInputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/SimpleInputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/SimpleInputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { SimpleInputVariable::SimpleInputVariable(Dataset& owner, const std::string& name, int id, const std::vector& dimensions) : @@ -116,5 +115,4 @@ return result; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/SimpleInputVariable.h metview-5.19.2/mir/src/mir/netcdf/SimpleInputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/SimpleInputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/SimpleInputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/InputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class SimpleInputVariable : public InputVariable { @@ -43,5 +42,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/SimpleOutputVariable.cc metview-5.19.2/mir/src/mir/netcdf/SimpleOutputVariable.cc --- metview-5.17.4/mir/src/mir/netcdf/SimpleOutputVariable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/SimpleOutputVariable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,8 +14,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { SimpleOutputVariable::SimpleOutputVariable(Dataset& owner, const std::string& name, @@ -28,5 +27,4 @@ out << "SimpleOutputVariable[name=" << name_ << "]"; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/SimpleOutputVariable.h metview-5.19.2/mir/src/mir/netcdf/SimpleOutputVariable.h --- metview-5.17.4/mir/src/mir/netcdf/SimpleOutputVariable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/SimpleOutputVariable.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/OutputVariable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class SimpleOutputVariable : public OutputVariable { @@ -29,5 +28,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Step.cc metview-5.19.2/mir/src/mir/netcdf/Step.cc --- metview-5.17.4/mir/src/mir/netcdf/Step.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Step.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,8 +13,7 @@ #include "mir/netcdf/Step.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { bool Step::merge(Step* /*other*/) { @@ -22,5 +21,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Step.h metview-5.19.2/mir/src/mir/netcdf/Step.h --- metview-5.17.4/mir/src/mir/netcdf/Step.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Step.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,18 +15,15 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class MergePlan; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Step { - Step(const Step&) = delete; + Step(const Step&) = delete; Step& operator=(const Step&) = delete; public: @@ -51,5 +48,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ThreeSixtyCalendar.cc metview-5.19.2/mir/src/mir/netcdf/ThreeSixtyCalendar.cc --- metview-5.17.4/mir/src/mir/netcdf/ThreeSixtyCalendar.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ThreeSixtyCalendar.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { ThreeSixtyCalendar::ThreeSixtyCalendar(const Variable& /*variable*/) {} @@ -33,5 +32,4 @@ static const CodecBuilder builder("360_day"); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ThreeSixtyCalendar.h metview-5.19.2/mir/src/mir/netcdf/ThreeSixtyCalendar.h --- metview-5.17.4/mir/src/mir/netcdf/ThreeSixtyCalendar.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ThreeSixtyCalendar.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Calendar.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class ThreeSixtyCalendar : public Calendar { @@ -29,5 +28,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Type.cc metview-5.19.2/mir/src/mir/netcdf/Type.cc --- metview-5.17.4/mir/src/mir/netcdf/Type.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Type.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,8 +33,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { static Type* types_[NC_MAX_ATOMIC_TYPE + 1] = { @@ -254,13 +253,13 @@ codec->encode(values); ASSERT(varid >= 0); ASSERT(values.size()); - NC_CALL(put(nc, varid, &values[0]), path); + NC_CALL(put(nc, varid, values.data()), path); } else { const std::vector& values = matrix.values(); ASSERT(varid >= 0); ASSERT(values.size()); - NC_CALL(put(nc, varid, &values[0]), path); + NC_CALL(put(nc, varid, values.data()), path); } } @@ -446,5 +445,4 @@ T(std::string, NC_STRING, -1); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Type.h metview-5.19.2/mir/src/mir/netcdf/Type.h --- metview-5.17.4/mir/src/mir/netcdf/Type.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Type.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,18 +15,15 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Value; class Matrix; class Variable; class MergePlan; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Type { @@ -81,5 +78,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/UnstructuredGrid.cc metview-5.19.2/mir/src/mir/netcdf/UnstructuredGrid.cc --- metview-5.17.4/mir/src/mir/netcdf/UnstructuredGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/UnstructuredGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { UnstructuredGrid::UnstructuredGrid(const Variable& variable, const std::vector& latitudes, @@ -192,5 +191,4 @@ static const GridSpecGuesserBuilder builder(99); -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/UnstructuredGrid.h metview-5.19.2/mir/src/mir/netcdf/UnstructuredGrid.h --- metview-5.17.4/mir/src/mir/netcdf/UnstructuredGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/UnstructuredGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/GridSpec.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class UnstructuredGrid : public GridSpec { @@ -59,5 +58,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/UpdateCoordinateStep.cc metview-5.19.2/mir/src/mir/netcdf/UpdateCoordinateStep.cc --- metview-5.17.4/mir/src/mir/netcdf/UpdateCoordinateStep.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/UpdateCoordinateStep.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/netcdf/Variable.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { UpdateCoordinateStep::UpdateCoordinateStep(Variable& out, const Variable& in) : out_(out), in_(in) {} @@ -55,5 +54,4 @@ #endif } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/UpdateCoordinateStep.h metview-5.19.2/mir/src/mir/netcdf/UpdateCoordinateStep.h --- metview-5.17.4/mir/src/mir/netcdf/UpdateCoordinateStep.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/UpdateCoordinateStep.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/netcdf/Step.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class UpdateCoordinateStep : public Step { @@ -43,5 +40,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Value.cc metview-5.19.2/mir/src/mir/netcdf/Value.cc --- metview-5.17.4/mir/src/mir/netcdf/Value.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Value.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { Value::Value(Type& type) : type_(type) {} @@ -29,5 +28,4 @@ return new ValueT(Type::lookup(NC_CHAR), s); } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Value.h metview-5.19.2/mir/src/mir/netcdf/Value.h --- metview-5.17.4/mir/src/mir/netcdf/Value.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Value.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Type; -} -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Value { @@ -92,5 +89,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ValueT.cc metview-5.19.2/mir/src/mir/netcdf/ValueT.cc --- metview-5.17.4/mir/src/mir/netcdf/ValueT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ValueT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/netcdf/Exceptions.h" #include "mir/netcdf/Type.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { template <> void ValueT::createAttribute(int nc, int varid, const std::string& name, const std::string& path) { @@ -93,5 +92,4 @@ out << value_; } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/ValueT.h metview-5.19.2/mir/src/mir/netcdf/ValueT.h --- metview-5.17.4/mir/src/mir/netcdf/ValueT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/ValueT.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ #include "mir/netcdf/Value.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { template @@ -119,5 +118,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Variable.cc metview-5.19.2/mir/src/mir/netcdf/Variable.cc --- metview-5.17.4/mir/src/mir/netcdf/Variable.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Variable.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { Variable::Variable(Dataset& owner, const std::string& name, const std::vector& dimensions) : @@ -466,5 +465,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/Variable.h metview-5.19.2/mir/src/mir/netcdf/Variable.h --- metview-5.17.4/mir/src/mir/netcdf/Variable.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/Variable.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,19 +20,16 @@ #include "mir/util/Types.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Dataset; class Dimension; class Matrix; class MergePlan; class Field; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf -namespace mir { -namespace netcdf { +namespace mir::netcdf { class Variable : public Endowed { @@ -151,5 +148,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/VirtualInputDimension.cc metview-5.19.2/mir/src/mir/netcdf/VirtualInputDimension.cc --- metview-5.17.4/mir/src/mir/netcdf/VirtualInputDimension.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/VirtualInputDimension.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/VirtualOutputDimension.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { VirtualInputDimension::VirtualInputDimension(Dataset& owner, const std::string& name) : Dimension(owner, name, 1) {} @@ -48,5 +47,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/VirtualInputDimension.h metview-5.19.2/mir/src/mir/netcdf/VirtualInputDimension.h --- metview-5.17.4/mir/src/mir/netcdf/VirtualInputDimension.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/VirtualInputDimension.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Dimension.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class VirtualInputDimension : public Dimension { @@ -37,5 +36,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/VirtualOutputDimension.cc metview-5.19.2/mir/src/mir/netcdf/VirtualOutputDimension.cc --- metview-5.17.4/mir/src/mir/netcdf/VirtualOutputDimension.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/VirtualOutputDimension.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/netcdf/Exceptions.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { VirtualOutputDimension::VirtualOutputDimension(Dataset& owner, const std::string& name) : @@ -63,5 +62,4 @@ } -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/netcdf/VirtualOutputDimension.h metview-5.19.2/mir/src/mir/netcdf/VirtualOutputDimension.h --- metview-5.17.4/mir/src/mir/netcdf/VirtualOutputDimension.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/netcdf/VirtualOutputDimension.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/netcdf/Dimension.h" -namespace mir { -namespace netcdf { +namespace mir::netcdf { class VirtualOutputDimension : public Dimension { @@ -40,5 +39,4 @@ }; -} // namespace netcdf -} // namespace mir +} // namespace mir::netcdf diff -Nru metview-5.17.4/mir/src/mir/output/EmptyOutput.cc metview-5.19.2/mir/src/mir/output/EmptyOutput.cc --- metview-5.17.4/mir/src/mir/output/EmptyOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/EmptyOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/param/MIRParametrisation.h" -namespace mir { -namespace output { +namespace mir::output { EmptyOutput::EmptyOutput() = default; @@ -83,5 +82,4 @@ static const MIROutputBuilder output("empty"); -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/EmptyOutput.h metview-5.19.2/mir/src/mir/output/EmptyOutput.h --- metview-5.17.4/mir/src/mir/output/EmptyOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/EmptyOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/output/MIROutput.h" -namespace mir { -namespace output { +namespace mir::output { class EmptyOutput : public MIROutput { @@ -93,5 +92,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GeoPointsFileOutput.cc metview-5.19.2/mir/src/mir/output/GeoPointsFileOutput.cc --- metview-5.17.4/mir/src/mir/output/GeoPointsFileOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GeoPointsFileOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "eckit/io/DataHandle.h" -namespace mir { -namespace output { +namespace mir::output { GeoPointsFileOutput::GeoPointsFileOutput(const std::string& path, bool binary) : path_(path), binary_(binary) {} @@ -47,5 +46,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GeoPointsFileOutput.h metview-5.19.2/mir/src/mir/output/GeoPointsFileOutput.h --- metview-5.17.4/mir/src/mir/output/GeoPointsFileOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GeoPointsFileOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/output/GeoPointsOutput.h" -namespace mir { -namespace output { +namespace mir::output { class GeoPointsFileOutput : public GeoPointsOutput { @@ -97,5 +96,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GeoPointsFileOutputXYV.cc metview-5.19.2/mir/src/mir/output/GeoPointsFileOutputXYV.cc --- metview-5.17.4/mir/src/mir/output/GeoPointsFileOutputXYV.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GeoPointsFileOutputXYV.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace output { +namespace mir::output { // See https://software.ecmwf.int/wiki/display/METV/Geopoints @@ -195,5 +194,4 @@ static const MIROutputBuilder output2("geopoints"); -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GeoPointsFileOutputXYVector.cc metview-5.19.2/mir/src/mir/output/GeoPointsFileOutputXYVector.cc --- metview-5.17.4/mir/src/mir/output/GeoPointsFileOutputXYVector.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GeoPointsFileOutputXYVector.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace output { +namespace mir::output { // See https://software.ecmwf.int/wiki/display/METV/Geopoints @@ -90,5 +89,4 @@ static const MIROutputBuilder output("geopoints-xy-vector"); -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GeoPointsFileOutputXYVector.h metview-5.19.2/mir/src/mir/output/GeoPointsFileOutputXYVector.h --- metview-5.17.4/mir/src/mir/output/GeoPointsFileOutputXYVector.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GeoPointsFileOutputXYVector.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/output/GeoPointsFileOutput.h" -namespace mir { -namespace output { +namespace mir::output { class GeoPointsFileOutputXYVector : public GeoPointsFileOutput { @@ -88,5 +87,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GeoPointsFileOutputXYV.h metview-5.19.2/mir/src/mir/output/GeoPointsFileOutputXYV.h --- metview-5.17.4/mir/src/mir/output/GeoPointsFileOutputXYV.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GeoPointsFileOutputXYV.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/output/GeoPointsFileOutput.h" -namespace mir { -namespace output { +namespace mir::output { class GeoPointsFileOutputXYV : public GeoPointsFileOutput { @@ -89,5 +88,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GeoPointsOutput.cc metview-5.19.2/mir/src/mir/output/GeoPointsOutput.cc --- metview-5.17.4/mir/src/mir/output/GeoPointsOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GeoPointsOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace output { +namespace mir::output { // See https://software.ecmwf.int/wiki/display/METV/Geopoints @@ -53,5 +52,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GeoPointsOutput.h metview-5.19.2/mir/src/mir/output/GeoPointsOutput.h --- metview-5.17.4/mir/src/mir/output/GeoPointsOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GeoPointsOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ } -namespace mir { -namespace output { +namespace mir::output { class GeoPointsOutput : public MIROutput { @@ -99,5 +98,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GmshOutput.cc metview-5.19.2/mir/src/mir/output/GmshOutput.cc --- metview-5.17.4/mir/src/mir/output/GmshOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GmshOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,7 @@ #include "mir/util/ValueMap.h" -namespace mir { -namespace output { +namespace mir::output { GmshOutput::GmshOutput(std::string path) : path_(std::move(path)) {} @@ -151,5 +150,4 @@ static const MIROutputBuilder _output("gmsh", {".msh"}); -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GmshOutput.h metview-5.19.2/mir/src/mir/output/GmshOutput.h --- metview-5.17.4/mir/src/mir/output/GmshOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GmshOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include "mir/output/MIROutput.h" -namespace mir { -namespace data { +namespace mir::data { class MIRField; -} -} // namespace mir +} // namespace mir::data -namespace mir { -namespace output { +namespace mir::output { class GmshOutput : public MIROutput { @@ -104,5 +101,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GribFileOutput.cc metview-5.19.2/mir/src/mir/output/GribFileOutput.cc --- metview-5.17.4/mir/src/mir/output/GribFileOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GribFileOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -14,8 +14,7 @@ #include "eckit/io/DataHandle.h" -namespace mir { -namespace output { +namespace mir::output { GribFileOutput::GribFileOutput(const eckit::PathName& path, bool append) : @@ -58,5 +57,4 @@ static const MIROutputBuilder output("grib"); -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GribFileOutput.h metview-5.19.2/mir/src/mir/output/GribFileOutput.h --- metview-5.17.4/mir/src/mir/output/GribFileOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GribFileOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/output/GribStreamOutput.h" -namespace mir { -namespace output { +namespace mir::output { class GribFileOutput : public GribStreamOutput { @@ -98,5 +97,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GribMemoryOutput.cc metview-5.19.2/mir/src/mir/output/GribMemoryOutput.cc --- metview-5.17.4/mir/src/mir/output/GribMemoryOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GribMemoryOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace output { +namespace mir::output { GribMemoryOutput::GribMemoryOutput(void* message, size_t size) : message_(message), size_(size), length_(0) {} @@ -43,5 +42,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GribMemoryOutput.h metview-5.19.2/mir/src/mir/output/GribMemoryOutput.h --- metview-5.17.4/mir/src/mir/output/GribMemoryOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GribMemoryOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/output/GribOutput.h" -namespace mir { -namespace output { +namespace mir::output { class GribMemoryOutput : public GribOutput { @@ -95,5 +94,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GribOutput.cc metview-5.19.2/mir/src/mir/output/GribOutput.cc --- metview-5.17.4/mir/src/mir/output/GribOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GribOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,10 @@ #include "mir/api/MIREstimation.h" #include "mir/compat/GribCompatibility.h" #include "mir/data/MIRField.h" +#include "mir/grib/BasicAngle.h" +#include "mir/grib/Packing.h" #include "mir/input/MIRInput.h" #include "mir/key/Area.h" -#include "mir/key/packing/Packing.h" #include "mir/param/MIRParametrisation.h" #include "mir/repres/Gridded.h" #include "mir/repres/Representation.h" @@ -40,8 +41,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace output { +namespace mir::output { static util::recursive_mutex local_mutex; @@ -111,7 +111,7 @@ std::string packing; if (param.get(packing, packing)) { estimator.packing(packing); - // const key::packing::Packing &packer = key::packing::Packing::lookup(packing); + // const grib::Packing &packer = grib::Packing::lookup(packing); // packer.estimate(estimator, *field.representation()); } @@ -123,7 +123,7 @@ bool GribOutput::printParametrisation(std::ostream& out, const param::MIRParametrisation& param) const { - std::unique_ptr pack(key::packing::PackingFactory::build(param)); + std::unique_ptr pack(grib::Packing::build(param)); ASSERT(pack); bool ok = pack->printParametrisation(out); @@ -153,7 +153,7 @@ }; auto packing_empty = [¶m]() { - std::unique_ptr pack(key::packing::PackingFactory::build(param)); + std::unique_ptr pack(grib::Packing::build(param)); ASSERT(pack); return pack->empty(); }; @@ -167,8 +167,8 @@ bool GribOutput::sameParametrisation(const param::MIRParametrisation& param1, const param::MIRParametrisation& param2) const { - std::unique_ptr packing1(key::packing::PackingFactory::build(param1)); - std::unique_ptr packing2(key::packing::PackingFactory::build(param2)); + std::unique_ptr packing1(grib::Packing::build(param1)); + std::unique_ptr packing2(grib::Packing::build(param2)); if (!packing1->sameAs(packing2.get())) { return false; @@ -210,7 +210,7 @@ util::MIRStatistics::Timing saveTimer; auto timer(ctx.statistics().gribEncodingTimer()); - std::unique_ptr pack(key::packing::PackingFactory::build(param)); + std::unique_ptr pack(grib::Packing::build(param)); ASSERT(pack); for (size_t i = 0; i < field.dimensions(); i++) { @@ -270,6 +270,31 @@ // Packing, accuracy, edition pack->fill(repres, info); + // Basic angle (after representation), support only for gridType=regular_ll + std::string basicAngle = "decimal"; + param.get("basic-angle", basicAngle); + + if (basicAngle == "as-input") { + ASSERT(info.grid.grid_type == CODES_UTIL_GRID_SPEC_REGULAR_LL); + + std::vector fraction(2); + GRIB_CALL(codes_get_long(h, "basicAngleOfTheInitialProductionDomain", &fraction[0])); + GRIB_CALL(codes_get_long(h, "subdivisionsOfBasicAngle", &fraction[1])); + + grib::BasicAngle basic(fraction[0], fraction[1]); + basic.fillGrib(info); + } + else if (basicAngle == "fraction") { + ASSERT(info.grid.grid_type == CODES_UTIL_GRID_SPEC_REGULAR_LL); + + grib::BasicAngle basic(info); + basic.fillGrib(info); + } + else { + // codes_grib_util_set_spec does not need anything here (GRIB standard) + ASSERT(basicAngle == "decimal"); + } + // Extra settings (paramId comes from here) for (const auto& k : field.metadata(i)) { info.extra_set(k.first.c_str(), k.second); @@ -352,7 +377,8 @@ int flags = 0; int err = 0; - auto* result = codes_grib_util_set_spec(h, &info.grid, &info.packing, flags, &values[0], values.size(), &err); + auto* result = + codes_grib_util_set_spec(h, &info.grid, &info.packing, flags, values.data(), values.size(), &err); HandleDeleter hf(result); // Make sure handle deleted even in case of exception @@ -435,7 +461,7 @@ util::MIRStatistics::Timing saveTimer; auto timer(ctx.statistics().gribEncodingTimer()); - std::unique_ptr pack(key::packing::PackingFactory::build(param)); + std::unique_ptr pack(grib::Packing::build(param)); ASSERT(pack); ASSERT(field.dimensions() == 1); @@ -489,5 +515,4 @@ #undef X -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GribOutput.h metview-5.19.2/mir/src/mir/output/GribOutput.h --- metview-5.17.4/mir/src/mir/output/GribOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GribOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,8 +21,7 @@ struct grib_handle; -namespace mir { -namespace output { +namespace mir::output { class GribOutput : public MIROutput { @@ -105,5 +104,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GribStreamOutput.cc metview-5.19.2/mir/src/mir/output/GribStreamOutput.cc --- metview-5.17.4/mir/src/mir/output/GribStreamOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GribStreamOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/output/GribStreamOutput.h" -namespace mir { -namespace output { +namespace mir::output { GribStreamOutput::GribStreamOutput() = default; @@ -30,5 +29,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/GribStreamOutput.h metview-5.19.2/mir/src/mir/output/GribStreamOutput.h --- metview-5.17.4/mir/src/mir/output/GribStreamOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/GribStreamOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ } -namespace mir { -namespace output { +namespace mir::output { class GribStreamOutput : public GribOutput { @@ -94,5 +93,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/MIROutput.cc metview-5.19.2/mir/src/mir/output/MIROutput.cc --- metview-5.17.4/mir/src/mir/output/MIROutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/MIROutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace output { +namespace mir::output { MIROutput::MIROutput() = default; @@ -79,10 +78,10 @@ OutputFromExtension() : MIROutputFactory("extension") {} - OutputFromExtension(const OutputFromExtension&) = delete; - OutputFromExtension(OutputFromExtension&&) = delete; + OutputFromExtension(const OutputFromExtension&) = delete; + OutputFromExtension(OutputFromExtension&&) = delete; OutputFromExtension& operator=(const OutputFromExtension&) = delete; - OutputFromExtension& operator=(OutputFromExtension&&) = delete; + OutputFromExtension& operator=(OutputFromExtension&&) = delete; ~OutputFromExtension() override { util::lock_guard lock(*ext_mutex); @@ -185,5 +184,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/MIROutput.h metview-5.19.2/mir/src/mir/output/MIROutput.h --- metview-5.17.4/mir/src/mir/output/MIROutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/MIROutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -33,8 +33,7 @@ } // namespace mir -namespace mir { -namespace output { +namespace mir::output { class MIROutput { @@ -123,7 +122,7 @@ class MIROutputFactory { const std::string name_; - MIROutputFactory(const MIROutputFactory&) = delete; + MIROutputFactory(const MIROutputFactory&) = delete; MIROutputFactory& operator=(const MIROutputFactory&) = delete; protected: @@ -149,5 +148,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/MultiDimensionalOutput.cc metview-5.19.2/mir/src/mir/output/MultiDimensionalOutput.cc --- metview-5.17.4/mir/src/mir/output/MultiDimensionalOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/MultiDimensionalOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace output { +namespace mir::output { MultiDimensionalOutput::MultiDimensionalOutput() = default; @@ -188,5 +187,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/MultiDimensionalOutput.h metview-5.19.2/mir/src/mir/output/MultiDimensionalOutput.h --- metview-5.17.4/mir/src/mir/output/MultiDimensionalOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/MultiDimensionalOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/output/MIROutput.h" -namespace mir { -namespace output { +namespace mir::output { class MultiDimensionalOutput : public MIROutput { @@ -99,5 +98,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/PNGOutput.cc metview-5.19.2/mir/src/mir/output/PNGOutput.cc --- metview-5.17.4/mir/src/mir/output/PNGOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/PNGOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -41,8 +41,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace output { +namespace mir::output { constexpr int N_BITS_PER_BYTE = 8; @@ -61,7 +60,7 @@ PNGEncoder() = default; virtual ~PNGEncoder() = default; - PNGEncoder(const PNGEncoder&) = delete; + PNGEncoder(const PNGEncoder&) = delete; PNGEncoder& operator=(const PNGEncoder&) = delete; virtual void encode(png_bytep&, const double&) const = 0; @@ -337,5 +336,4 @@ static const PNGEncoderBuilder> encoder7("16-bit/rgb"); static const PNGEncoderBuilder> encoder8("16-bit/rgba"); -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/PNGOutput.h metview-5.19.2/mir/src/mir/output/PNGOutput.h --- metview-5.17.4/mir/src/mir/output/PNGOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/PNGOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include "mir/util/Types.h" -namespace mir { -namespace data { +namespace mir::data { class MIRField; -} -} // namespace mir +} // namespace mir::data -namespace mir { -namespace output { +namespace mir::output { class PNGOutput : public MIROutput { @@ -110,7 +107,7 @@ std::string name_; virtual PNGOutput::PNGEncoder* make(const param::MIRParametrisation&, const data::MIRField&) = 0; - PNGEncoderFactory(const PNGEncoderFactory&) = delete; + PNGEncoderFactory(const PNGEncoderFactory&) = delete; PNGEncoderFactory& operator=(const PNGEncoderFactory&) = delete; protected: @@ -136,5 +133,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/RawOutput.cc metview-5.19.2/mir/src/mir/output/RawOutput.cc --- metview-5.17.4/mir/src/mir/output/RawOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/RawOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,55 +16,71 @@ #include #include "mir/action/context/Context.h" +#include "mir/api/MIRJob.h" #include "mir/data/MIRField.h" +#include "mir/repres/Representation.h" #include "mir/util/Exceptions.h" #include "mir/util/Log.h" -namespace mir { -namespace output { +namespace mir::output { -RawOutput::RawOutput(double* values, size_t count) : values_(values), count_(count), size_(0) {} - - -bool RawOutput::sameAs(const MIROutput& other) const { - return this == &other; -} - - -bool RawOutput::sameParametrisation(const param::MIRParametrisation& /*unused*/, - const param::MIRParametrisation& /*unused*/) const { - NOTIMP; -} - - -bool RawOutput::printParametrisation(std::ostream& /*out*/, const param::MIRParametrisation& /*param*/) const { - NOTIMP; -} +RawOutput::RawOutput(double* values, size_t count, param::SimpleParametrisation& metadata) : + values_(values), count_(count), metadata_(metadata), size_(0) {} size_t RawOutput::save(const param::MIRParametrisation& /*param*/, context::Context& ctx) { - const data::MIRField& field = ctx.field(); - + const auto& field = ctx.field(); field.validate(); - // field.hasMissing(); - // field.missingValue(); + // save metadata + { + Log::debug() << "RawOutput::save metadata" << std::endl; + repres::RepresentationHandle repres(field.representation()); + + // (a hack) + api::MIRJob job; + repres->fillJob(job); + job.copyValuesTo(metadata_); + + if (field.hasMissing()) { + metadata_.set("missing_value", field.missingValue()); + } + } + + + // save data ASSERT(field.dimensions() == 1); - const MIRValuesVector& values = field.values(0); + const auto& values = field.values(0); Log::debug() << "RawOutput::save values: " << values.size() << ", user: " << count_ << std::endl; size_ = values.size(); ASSERT(size_ <= count_); - std::memcpy(values_, &values[0], size_ * sizeof(double)); + std::memcpy(values_, values.data(), size_ * sizeof(double)); return size_ * sizeof(double); } +bool RawOutput::sameAs(const MIROutput& other) const { + return this == &other; +} + + +bool RawOutput::sameParametrisation(const param::MIRParametrisation& /*unused*/, + const param::MIRParametrisation& /*unused*/) const { + return true; +} + + +bool RawOutput::printParametrisation(std::ostream& /*out*/, const param::MIRParametrisation& /*param*/) const { + return false; +} + + void RawOutput::print(std::ostream& out) const { out << "RawOutput[count=" << count_ << ", size=" << size_ << "]"; } @@ -75,5 +91,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/RawOutput.h metview-5.19.2/mir/src/mir/output/RawOutput.h --- metview-5.17.4/mir/src/mir/output/RawOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/RawOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -13,20 +13,20 @@ #pragma once #include "mir/output/MIROutput.h" +#include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace output { +namespace mir::output { -class RawOutput : public MIROutput { +class RawOutput final : public MIROutput { public: // -- Exceptions // None // -- Constructors - RawOutput(double* values, size_t count); + RawOutput(double* const values, size_t count, param::SimpleParametrisation& metadata); // -- Destructor // None @@ -50,27 +50,12 @@ // -- Class methods // None -protected: - // -- Members - // None - - // -- Methods - // None - - // -- Overridden methods - // None - - // -- Class members - // None - - // -- Class methods - // None - private: // -- Members - double* values_; + double* const values_; size_t count_; + param::SimpleParametrisation& metadata_; size_t size_; // -- Methods @@ -96,5 +81,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/ResizableOutput.cc metview-5.19.2/mir/src/mir/output/ResizableOutput.cc --- metview-5.17.4/mir/src/mir/output/ResizableOutput.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/ResizableOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,87 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include "mir/output/ResizableOutput.h" + +#include + +#include "mir/action/context/Context.h" +#include "mir/api/MIRJob.h" +#include "mir/data/MIRField.h" +#include "mir/repres/Representation.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Log.h" + + +namespace mir::output { + + +ResizableOutput::ResizableOutput(std::vector& values, param::SimpleParametrisation& metadata) : + values_(values), metadata_(metadata) {} + + +size_t ResizableOutput::save(const param::MIRParametrisation& /*param*/, context::Context& ctx) { + const auto& field = ctx.field(); + field.validate(); + + + // save metadata + { + Log::debug() << "ResizableOutput::save metadata" << std::endl; + repres::RepresentationHandle repres(field.representation()); + + // (a hack) + api::MIRJob job; + repres->fillJob(job); + job.copyValuesTo(metadata_); + + if (field.hasMissing()) { + metadata_.set("missing_value", field.missingValue()); + } + } + + + // save data + ASSERT(field.dimensions() == 1); + values_ = field.values(0); + + return values_.size() * sizeof(double); +} + + +bool ResizableOutput::sameAs(const MIROutput& other) const { + return dynamic_cast(this) == &other; +} + + +bool ResizableOutput::sameParametrisation(const param::MIRParametrisation& /*unused*/, + const param::MIRParametrisation& /*unused*/) const { + return true; +} + + +bool ResizableOutput::printParametrisation(std::ostream& /*out*/, const param::MIRParametrisation& /*param*/) const { + return false; +} + + +void ResizableOutput::print(std::ostream& out) const { + out << "ResizableOutput[size=" << size() << "]"; +} + + +size_t ResizableOutput::size() const { + return values_.size(); +} + + +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/ResizableOutput.h metview-5.19.2/mir/src/mir/output/ResizableOutput.h --- metview-5.17.4/mir/src/mir/output/ResizableOutput.h 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/ResizableOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,84 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#pragma once + +#include + +#include "mir/output/MIROutput.h" +#include "mir/param/SimpleParametrisation.h" + + +namespace mir::output { + + +class ResizableOutput final : public MIROutput { +public: + // -- Exceptions + // None + + // -- Constructors + + ResizableOutput(std::vector&, param::SimpleParametrisation& metadata); + + // -- Destructor + // None + + // -- Convertors + // None + + // -- Operators + // None + + // -- Methods + + size_t size() const; + + // -- Overridden methods + // None + + // -- Class members + // None + + // -- Class methods + // None + +private: + // -- Members + + std::vector& values_; + param::SimpleParametrisation& metadata_; + + // -- Methods + // None + + // -- Overridden methods + + // From MIROutput + size_t save(const param::MIRParametrisation&, context::Context&) override; + bool sameAs(const MIROutput&) const override; + bool sameParametrisation(const param::MIRParametrisation&, const param::MIRParametrisation&) const override; + bool printParametrisation(std::ostream&, const param::MIRParametrisation&) const override; + void print(std::ostream&) const override; + + // -- Class members + // None + + // -- Class methods + // None + + // -- Friends + // None +}; + + +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/ValuesOutput.cc metview-5.19.2/mir/src/mir/output/ValuesOutput.cc --- metview-5.17.4/mir/src/mir/output/ValuesOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/ValuesOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace output { +namespace mir::output { ValuesOutput::ValuesOutput() : missingValue_(9999), hasMissing_(false) {} @@ -85,5 +84,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/ValuesOutput.h metview-5.19.2/mir/src/mir/output/ValuesOutput.h --- metview-5.17.4/mir/src/mir/output/ValuesOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/ValuesOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace output { +namespace mir::output { class ValuesOutput : public MIROutput { @@ -103,5 +102,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/VectorOutput.cc metview-5.19.2/mir/src/mir/output/VectorOutput.cc --- metview-5.17.4/mir/src/mir/output/VectorOutput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/VectorOutput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace output { +namespace mir::output { VectorOutput::VectorOutput(MIROutput& component1, MIROutput& component2) : @@ -144,5 +143,4 @@ } -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/output/VectorOutput.h metview-5.19.2/mir/src/mir/output/VectorOutput.h --- metview-5.17.4/mir/src/mir/output/VectorOutput.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/output/VectorOutput.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/output/MIROutput.h" -namespace mir { -namespace output { +namespace mir::output { class VectorOutput : public MIROutput { @@ -99,5 +98,4 @@ }; -} // namespace output -} // namespace mir +} // namespace mir::output diff -Nru metview-5.17.4/mir/src/mir/param/CachedParametrisation.cc metview-5.19.2/mir/src/mir/param/CachedParametrisation.cc --- metview-5.17.4/mir/src/mir/param/CachedParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/CachedParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace param { +namespace mir::param { CachedParametrisation::CachedParametrisation(MIRParametrisation& parametrisation) : parametrisation_(parametrisation) {} @@ -149,5 +148,4 @@ } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/CachedParametrisation.h metview-5.19.2/mir/src/mir/param/CachedParametrisation.h --- metview-5.17.4/mir/src/mir/param/CachedParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/CachedParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,15 +18,12 @@ #include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace input { +namespace mir::input { class GribInput; -} -} // namespace mir +} // namespace mir::input -namespace mir { -namespace param { +namespace mir::param { class CachedParametrisation : public MIRParametrisation { @@ -130,5 +127,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/CombinedParametrisation.cc metview-5.19.2/mir/src/mir/param/CombinedParametrisation.cc --- metview-5.17.4/mir/src/mir/param/CombinedParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/CombinedParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace param { +namespace mir::param { CombinedParametrisation::CombinedParametrisation(const MIRParametrisation& user, const MIRParametrisation& metadata, @@ -114,5 +113,4 @@ } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/CombinedParametrisation.h metview-5.19.2/mir/src/mir/param/CombinedParametrisation.h --- metview-5.17.4/mir/src/mir/param/CombinedParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/CombinedParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/param/MIRParametrisation.h" -namespace mir { -namespace param { +namespace mir::param { class CombinedParametrisation : public MIRParametrisation { @@ -114,5 +113,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/ConfigurationWrapper.cc metview-5.19.2/mir/src/mir/param/ConfigurationWrapper.cc --- metview-5.17.4/mir/src/mir/param/ConfigurationWrapper.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/ConfigurationWrapper.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "eckit/config/Configuration.h" -namespace mir { -namespace param { +namespace mir::param { ConfigurationWrapper::ConfigurationWrapper(const eckit::Configuration& config) : configuration_(config) {} @@ -96,5 +95,4 @@ } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/ConfigurationWrapper.h metview-5.19.2/mir/src/mir/param/ConfigurationWrapper.h --- metview-5.17.4/mir/src/mir/param/ConfigurationWrapper.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/ConfigurationWrapper.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ } -namespace mir { -namespace param { +namespace mir::param { class ConfigurationWrapper : public MIRParametrisation { @@ -57,5 +56,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/DefaultParametrisation.cc metview-5.19.2/mir/src/mir/param/DefaultParametrisation.cc --- metview-5.17.4/mir/src/mir/param/DefaultParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/DefaultParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/config/LibMir.h" -namespace mir { -namespace param { +namespace mir::param { DefaultParametrisation::DefaultParametrisation() { @@ -26,15 +25,14 @@ set("interpolation", "linear/k-nearest-neighbours"); set("vector-space", "1d-linear"); - bool caching = LibMir::caching(); - set("caching", caching); + set("caching", LibMir::caching()); set("prune-epsilon", 1e-10); set("nclosest", 4L); set("lsm", false); set("lsm-selection", "named"); - set("lsm-named", "1km"); + set("lsm-named", LibMir::lsmNamed()); set("lsm-interpolation", "nearest-neighbour"); set("lsm-weight-adjustment", 0.2); set("lsm-value-threshold", 0.5); @@ -48,5 +46,4 @@ DefaultParametrisation::~DefaultParametrisation() = default; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/DefaultParametrisation.h metview-5.19.2/mir/src/mir/param/DefaultParametrisation.h --- metview-5.17.4/mir/src/mir/param/DefaultParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/DefaultParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace param { +namespace mir::param { class DefaultParametrisation : public SimpleParametrisation { @@ -87,5 +86,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/FieldParametrisation.cc metview-5.19.2/mir/src/mir/param/FieldParametrisation.cc --- metview-5.17.4/mir/src/mir/param/FieldParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/FieldParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace param { +namespace mir::param { static const MIRParametrisation* find_param_rules(const param::MIRParametrisation& param) { @@ -167,5 +166,4 @@ } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/FieldParametrisation.h metview-5.19.2/mir/src/mir/param/FieldParametrisation.h --- metview-5.17.4/mir/src/mir/param/FieldParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/FieldParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/param/MIRParametrisation.h" -namespace mir { -namespace param { +namespace mir::param { class FieldParametrisation : public MIRParametrisation { @@ -109,5 +108,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/MIRParametrisation.cc metview-5.19.2/mir/src/mir/param/MIRParametrisation.cc --- metview-5.17.4/mir/src/mir/param/MIRParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/MIRParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace param { +namespace mir::param { MIRParametrisation::MIRParametrisation() = default; @@ -90,5 +89,4 @@ return false; } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/MIRParametrisation.h metview-5.19.2/mir/src/mir/param/MIRParametrisation.h --- metview-5.17.4/mir/src/mir/param/MIRParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/MIRParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "eckit/config/Parametrisation.h" -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation : public eckit::Parametrisation { @@ -118,5 +117,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/Rules.cc metview-5.19.2/mir/src/mir/param/Rules.cc --- metview-5.17.4/mir/src/mir/param/Rules.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/Rules.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,13 +18,13 @@ #include "eckit/parser/YAMLParser.h" #include "eckit/utils/Translator.h" +#include "mir/config/LibMir.h" #include "mir/param/SimpleParametrisation.h" #include "mir/util/Exceptions.h" #include "mir/util/Log.h" -namespace mir { -namespace param { +namespace mir::param { static const std::string PARAM_ID("paramId"); @@ -125,24 +125,11 @@ using PathName::PathName; }; - ConfigFile classes("~mir/etc/mir/classes.yaml"); - ConfigFile parameterClass("~mir/etc/mir/parameter-class.yaml"); - ConfigFile parameters("~mir/etc/mir/parameters.yaml"); + ConfigFile classes(LibMir::configFile(LibMir::config_file::CLASSES)); + ConfigFile parameterClass(LibMir::configFile(LibMir::config_file::PARAMETER_CLASS)); + ConfigFile parameters(LibMir::configFile(LibMir::config_file::PARAMETERS)); if (!classes.exists() || !parameterClass.exists() || !parameters.exists()) { - - const std::string msg = - "Configuration files not found," - " post-processing defaults might not be appropriate"; - - static bool abortIfConfigurationFilesNotFound = - eckit::Resource("$MIR_ABORT_IF_CONFIGURATION_NOT_FOUND", false); - if (abortIfConfigurationFilesNotFound) { - Log::error() << msg << std::endl; - throw exception::UserError(msg); - } - - Log::warning() << msg << std::endl; return; } @@ -230,5 +217,4 @@ } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/Rules.h metview-5.19.2/mir/src/mir/param/Rules.h --- metview-5.17.4/mir/src/mir/param/Rules.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/Rules.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,16 +19,13 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; class SimpleParametrisation; -} // namespace param -} // namespace mir +} // namespace mir::param -namespace mir { -namespace param { +namespace mir::param { class Rules { @@ -116,5 +113,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/RuntimeParametrisation.cc metview-5.19.2/mir/src/mir/param/RuntimeParametrisation.cc --- metview-5.17.4/mir/src/mir/param/RuntimeParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/RuntimeParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace param { +namespace mir::param { RuntimeParametrisation::RuntimeParametrisation(const MIRParametrisation& owner) : owner_(owner) {} @@ -236,5 +235,4 @@ } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/RuntimeParametrisation.h metview-5.19.2/mir/src/mir/param/RuntimeParametrisation.h --- metview-5.17.4/mir/src/mir/param/RuntimeParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/RuntimeParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace param { +namespace mir::param { class RuntimeParametrisation : public SimpleParametrisation { @@ -139,5 +138,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/SameParametrisation.cc metview-5.19.2/mir/src/mir/param/SameParametrisation.cc --- metview-5.17.4/mir/src/mir/param/SameParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/SameParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace param { +namespace mir::param { SameParametrisation::SameParametrisation(const MIRParametrisation& parametrisation1, @@ -111,5 +110,4 @@ } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/SameParametrisation.h metview-5.19.2/mir/src/mir/param/SameParametrisation.h --- metview-5.17.4/mir/src/mir/param/SameParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/SameParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/param/MIRParametrisation.h" -namespace mir { -namespace param { +namespace mir::param { class SameParametrisation : public MIRParametrisation { @@ -108,5 +107,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/SimpleParametrisation.cc metview-5.19.2/mir/src/mir/param/SimpleParametrisation.cc --- metview-5.17.4/mir/src/mir/param/SimpleParametrisation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/SimpleParametrisation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace param { +namespace mir::param { class Setting { @@ -36,10 +35,10 @@ Setting() = default; virtual ~Setting() = default; - Setting(const Setting&) = delete; - Setting(Setting&&) = delete; + Setting(const Setting&) = delete; + Setting(Setting&&) = delete; Setting& operator=(const Setting&) = delete; - Setting& operator=(Setting&&) = delete; + Setting& operator=(Setting&&) = delete; virtual void get(const std::string& name, std::string& value) const = 0; virtual void get(const std::string& name, bool& value) const = 0; @@ -372,8 +371,8 @@ template <> void TSettings::get(const std::string& name, bool& value) const { conversion_warning("string", "bool", name, value_); - eckit::Translator translate; - value = translate(value_) != 0; + eckit::Translator translate; + value = translate(value_); } @@ -832,5 +831,4 @@ } -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/param/SimpleParametrisation.h metview-5.19.2/mir/src/mir/param/SimpleParametrisation.h --- metview-5.17.4/mir/src/mir/param/SimpleParametrisation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/param/SimpleParametrisation.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,15 +21,12 @@ namespace eckit { class JSON; } -namespace mir { -namespace param { +namespace mir::param { class Setting; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace param { +namespace mir::param { class SimpleParametrisation : public MIRParametrisation { @@ -81,7 +78,7 @@ // Used by Job bool matchAll(const MIRParametrisation&) const; - // Used by GribFixes + // Used by grib::Config bool matchAny(const MIRParametrisation&) const; // -- Overridden methods @@ -161,5 +158,4 @@ }; -} // namespace param -} // namespace mir +} // namespace mir::param diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/Gaussian.cc metview-5.19.2/mir/src/mir/repres/gauss/Gaussian.cc --- metview-5.17.4/mir/src/mir/repres/gauss/Gaussian.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/Gaussian.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,8 +29,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace repres { +namespace mir::repres { static util::once_flag once; @@ -190,6 +189,8 @@ *f = -(*b); } + edges[N_] = 0.; // exact value + return edges; } @@ -283,5 +284,4 @@ } -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/Gaussian.h metview-5.19.2/mir/src/mir/repres/gauss/Gaussian.h --- metview-5.17.4/mir/src/mir/repres/gauss/Gaussian.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/Gaussian.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace repres { +namespace mir::repres { class Gaussian : public Gridded { @@ -116,5 +115,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/GaussianIterator.cc metview-5.19.2/mir/src/mir/repres/gauss/GaussianIterator.cc --- metview-5.17.4/mir/src/mir/repres/gauss/GaussianIterator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/GaussianIterator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace repres { -namespace gauss { +namespace mir::repres::gauss { GaussianIterator::GaussianIterator(const std::vector& latitudes, std::vector&& pl, @@ -116,6 +114,4 @@ } -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/GaussianIterator.h metview-5.19.2/mir/src/mir/repres/gauss/GaussianIterator.h --- metview-5.17.4/mir/src/mir/repres/gauss/GaussianIterator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/GaussianIterator.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace repres { -namespace gauss { +namespace mir::repres::gauss { class GaussianIterator : public Iterator { @@ -55,6 +53,4 @@ }; -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/Classic.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/Classic.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/Classic.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/Classic.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,10 +18,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { Classic::Classic(size_t N, const util::BoundingBox& bbox, double angularPrecision) : @@ -73,7 +70,4 @@ } -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/Classic.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/Classic.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/Classic.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/Classic.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class Classic : public Reduced { @@ -94,7 +91,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/FromPL.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/FromPL.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/FromPL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/FromPL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,10 +17,7 @@ #include "mir/util/Domain.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { FromPL::FromPL(const param::MIRParametrisation& parametrisation) : Reduced(parametrisation) {} @@ -64,7 +61,4 @@ } -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/FromPL.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/FromPL.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/FromPL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/FromPL.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class FromPL : public Reduced { @@ -96,7 +93,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/Octahedral.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/Octahedral.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/Octahedral.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/Octahedral.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { Octahedral::Octahedral(size_t N, const util::BoundingBox& bbox, double angularPrecision) : @@ -80,7 +77,4 @@ } -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/Octahedral.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/Octahedral.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/Octahedral.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/Octahedral.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class Octahedral : public Reduced { @@ -95,7 +92,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/Reduced.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/Reduced.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/Reduced.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/Reduced.cc 2023-07-15 08:28:47.000000000 +0000 @@ -33,10 +33,7 @@ #include "mir/util/GridBox.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { template @@ -290,7 +287,7 @@ std::vector Reduced::gridBoxes() const { - ASSERT(1 < Nj_); + ASSERT(1 <= Nj_); // latitude edges @@ -306,26 +303,49 @@ for (size_t j = k_; j < k_ + Nj_; ++j) { ASSERT(pl[j] > 0); - eckit::Fraction inc(360, pl[j]); + const auto inc = eckit::Fraction(360, pl[j]); - auto Ni = size_t(pl[j]); + // latitude edges + const auto n = includesNorthPole() ? latEdges[j] : std::min(bbox_.north().value(), latEdges[j]); + const auto s = includesSouthPole() ? latEdges[j + 1] : std::max(bbox_.south().value(), latEdges[j + 1]); + ASSERT(n >= s); // longitude edges - auto west = bbox_.west().fraction(); - auto Nw = (west / inc).integralPart(); + const auto west = bbox_.west().fraction(); + auto Nw = (west / inc).integralPart(); if (Nw * inc < west) { Nw += 1; } + + const auto east = bbox_.east().fraction(); + auto Ne = (east / inc).integralPart(); + if (Ne * inc > east) { + Ne -= 1; + } + + const auto N = std::min(static_cast(pl[j]), static_cast(Ne - Nw + 1)); + Longitude lon0 = (Nw * inc) - (inc / 2); Longitude lon1 = lon0; - for (size_t i = 0; i < Ni; ++i) { - auto l = lon1; - lon1 += inc; - r.emplace_back(util::GridBox(latEdges[j], l.value(), latEdges[j + 1], lon1.value())); + if (periodic) { + for (size_t i = 0; i < N; ++i) { + auto w = lon1.value(); + lon1 += inc; + r.emplace_back(n, w, s, lon1.value()); + } + + ASSERT(lon0 == lon1.normalise(lon0)); } + else { + for (size_t i = 0; i < N; ++i) { + auto w = std::max(bbox_.west().value(), lon1.value()); + lon1 += inc; + r.emplace_back(n, w, s, std::min(bbox_.east().value(), lon1.value())); + } - ASSERT(periodic ? lon0 == lon1.normalise(lon0) : lon0 < lon1.normalise(lon0)); + ASSERT(lon0 < lon1.normalise(lon0)); + } } ASSERT(r.size() == numberOfPoints()); @@ -520,7 +540,4 @@ } -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedClassic.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedClassic.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedClassic.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedClassic.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { ReducedClassic::ReducedClassic(size_t N, const util::BoundingBox& bbox, double angularPrecision) : @@ -51,7 +48,4 @@ } -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedClassic.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedClassic.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedClassic.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedClassic.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/repres/gauss/reduced/Classic.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class ReducedClassic : public Classic { @@ -93,7 +90,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedFromPL.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedFromPL.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedFromPL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedFromPL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { ReducedFromPL::ReducedFromPL(const param::MIRParametrisation& parametrisation) : FromPL(parametrisation) {} @@ -58,7 +55,4 @@ static const RepresentationBuilder reducedFromPL("reduced_gg"); -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedFromPL.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedFromPL.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedFromPL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedFromPL.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/repres/gauss/reduced/FromPL.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class ReducedFromPL : public FromPL { @@ -95,7 +92,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/Reduced.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/Reduced.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/Reduced.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/Reduced.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,17 +15,12 @@ #include "mir/repres/gauss/Gaussian.h" -namespace mir { -namespace util { +namespace mir::util { class Rotation; -} -} // namespace mir +} // namespace mir::util -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class Reduced : public Gaussian { @@ -50,7 +45,8 @@ // None // -- Methods - // None + + static std::vector pls(const std::string&); // -- Overridden methods // None @@ -77,7 +73,6 @@ Iterator* rotatedIterator(const util::Rotation&) const; const std::vector& pls() const; - static std::vector pls(const std::string&); void setNj(std::vector, const Latitude& s, const Latitude& n); void correctWestEast(Longitude& w, Longitude& e) const; @@ -126,7 +121,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedOctahedral.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedOctahedral.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedOctahedral.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedOctahedral.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { ReducedOctahedral::ReducedOctahedral(size_t N, const util::BoundingBox& bbox, double angularPrecision) : @@ -51,7 +48,4 @@ } -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedOctahedral.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedOctahedral.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/ReducedOctahedral.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/ReducedOctahedral.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/repres/gauss/reduced/Octahedral.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class ReducedOctahedral : public Octahedral { @@ -93,7 +90,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedClassic.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedClassic.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedClassic.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedClassic.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,10 +18,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { RotatedClassic::RotatedClassic(size_t N, const util::Rotation& rotation, const util::BoundingBox& bbox, @@ -75,7 +72,4 @@ } -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedClassic.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedClassic.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedClassic.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedClassic.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class RotatedClassic : public Classic { @@ -99,7 +96,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedFromPL.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedFromPL.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedFromPL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedFromPL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,10 +18,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { RotatedFromPL::RotatedFromPL(const param::MIRParametrisation& parametrisation) : @@ -83,7 +80,4 @@ static const RepresentationBuilder rotatedFromPL("reduced_rotated_gg"); -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedFromPL.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedFromPL.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedFromPL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedFromPL.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class RotatedFromPL : public FromPL { @@ -100,7 +97,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedOctahedral.cc metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedOctahedral.cc --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedOctahedral.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedOctahedral.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,10 +18,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { RotatedOctahedral::RotatedOctahedral(size_t N, const util::Rotation& rotation, const util::BoundingBox& bbox, @@ -75,7 +72,4 @@ } -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedOctahedral.h metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedOctahedral.h --- metview-5.17.4/mir/src/mir/repres/gauss/reduced/RotatedOctahedral.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/reduced/RotatedOctahedral.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace repres { -namespace gauss { -namespace reduced { +namespace mir::repres::gauss::reduced { class RotatedOctahedral : public Octahedral { @@ -99,7 +96,4 @@ }; -} // namespace reduced -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::reduced diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/regular/Regular.cc metview-5.19.2/mir/src/mir/repres/gauss/regular/Regular.cc --- metview-5.17.4/mir/src/mir/repres/gauss/regular/Regular.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/regular/Regular.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,10 +22,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace repres { -namespace gauss { -namespace regular { +namespace mir::repres::gauss::regular { Regular::Regular(const param::MIRParametrisation& parametrisation) : Gaussian(parametrisation), k_(0), Ni_(0), Nj_(0) { // adjust latitudes, longitudes and re-set bounding box @@ -280,7 +277,4 @@ } -} // namespace regular -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::regular diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/regular/RegularGG.cc metview-5.19.2/mir/src/mir/repres/gauss/regular/RegularGG.cc --- metview-5.17.4/mir/src/mir/repres/gauss/regular/RegularGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/regular/RegularGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,6 +12,7 @@ #include "mir/repres/gauss/regular/RegularGG.h" +#include #include #include @@ -20,10 +21,7 @@ #include "mir/util/GridBox.h" -namespace mir { -namespace repres { -namespace gauss { -namespace regular { +namespace mir::repres::gauss::regular { RegularGG::RegularGG(const param::MIRParametrisation& parametrisation) : Regular(parametrisation) {} @@ -63,8 +61,8 @@ std::vector RegularGG::gridBoxes() const { - ASSERT(1 < Ni_); - ASSERT(1 < Nj_); + ASSERT(1 <= Ni_); + ASSERT(1 <= Nj_); // latitude edges @@ -83,6 +81,11 @@ lonEdges[i + 1] = (lon0 + (i + half) * inc).value(); } + if (!periodic) { + lonEdges.front() = std::max(bbox_.west().value(), lonEdges.front()); + lonEdges.back() = std::min(bbox_.east().value(), lonEdges.back()); + } + // grid boxes std::vector r; @@ -108,7 +111,4 @@ static const RepresentationBuilder reducedGG("regular_gg"); -} // namespace regular -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::regular diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/regular/RegularGG.h metview-5.19.2/mir/src/mir/repres/gauss/regular/RegularGG.h --- metview-5.17.4/mir/src/mir/repres/gauss/regular/RegularGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/regular/RegularGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/repres/gauss/regular/Regular.h" -namespace mir { -namespace repres { -namespace gauss { -namespace regular { +namespace mir::repres::gauss::regular { class RegularGG : public Regular { @@ -96,7 +93,4 @@ }; -} // namespace regular -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::regular diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/regular/Regular.h metview-5.19.2/mir/src/mir/repres/gauss/regular/Regular.h --- metview-5.17.4/mir/src/mir/repres/gauss/regular/Regular.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/regular/Regular.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,10 +15,7 @@ #include "mir/repres/gauss/Gaussian.h" -namespace mir { -namespace repres { -namespace gauss { -namespace regular { +namespace mir::repres::gauss::regular { class Regular : public Gaussian { @@ -113,7 +110,4 @@ }; -} // namespace regular -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::regular diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/regular/RotatedGG.cc metview-5.19.2/mir/src/mir/repres/gauss/regular/RotatedGG.cc --- metview-5.17.4/mir/src/mir/repres/gauss/regular/RotatedGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/regular/RotatedGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,10 +19,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace repres { -namespace gauss { -namespace regular { +namespace mir::repres::gauss::regular { RotatedGG::RotatedGG(const param::MIRParametrisation& parametrisation) : @@ -84,7 +81,4 @@ static const RepresentationBuilder rotatedGG("rotated_gg"); -} // namespace regular -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::regular diff -Nru metview-5.17.4/mir/src/mir/repres/gauss/regular/RotatedGG.h metview-5.19.2/mir/src/mir/repres/gauss/regular/RotatedGG.h --- metview-5.17.4/mir/src/mir/repres/gauss/regular/RotatedGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/gauss/regular/RotatedGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,10 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace repres { -namespace gauss { -namespace regular { +namespace mir::repres::gauss::regular { class RotatedGG : public Regular { @@ -101,7 +98,4 @@ }; -} // namespace regular -} // namespace gauss -} // namespace repres -} // namespace mir +} // namespace mir::repres::gauss::regular diff -Nru metview-5.17.4/mir/src/mir/repres/Gridded.cc metview-5.19.2/mir/src/mir/repres/Gridded.cc --- metview-5.17.4/mir/src/mir/repres/Gridded.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/Gridded.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace repres { +namespace mir::repres { Gridded::Gridded(const param::MIRParametrisation& parametrisation) : bbox_(parametrisation) {} @@ -64,5 +63,9 @@ } -} // namespace repres -} // namespace mir +size_t Gridded::numberOfValues() const { + return numberOfPoints(); +} + + +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/Gridded.h metview-5.19.2/mir/src/mir/repres/Gridded.h --- metview-5.17.4/mir/src/mir/repres/Gridded.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/Gridded.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace repres { +namespace mir::repres { class Gridded : public Representation { @@ -86,7 +85,8 @@ // None // -- Overridden methods - // None + + size_t numberOfValues() const override; // -- Class members // None @@ -99,5 +99,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/latlon/LatLon.cc metview-5.19.2/mir/src/mir/repres/latlon/LatLon.cc --- metview-5.17.4/mir/src/mir/repres/latlon/LatLon.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/latlon/LatLon.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/data/MIRField.h" #include "mir/iterator/detail/RegularIterator.h" -#include "mir/key/Area.h" #include "mir/param/MIRParametrisation.h" -#include "mir/param/SameParametrisation.h" #include "mir/util/Domain.h" #include "mir/util/Exceptions.h" #include "mir/util/Grib.h" @@ -32,9 +30,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace repres { -namespace latlon { +namespace mir::repres::latlon { LatLon::LatLon(const param::MIRParametrisation& parametrisation) : @@ -408,45 +404,4 @@ } -bool LatLon::samePoints(const param::MIRParametrisation& user, const param::MIRParametrisation& field) { - std::unique_ptr same(new param::SameParametrisation(user, field, true)); - - std::vector rotation; - if (user.has("rotation") && !same->get("rotation", rotation)) { - return false; - } - - std::vector grid; - if (user.has("grid") && !same->get("grid", grid)) { - return false; - } - - util::BoundingBox bboxUser; - if (key::Area::get(user, bboxUser)) { - util::Increments inc(field); - size_t ni = 0; - size_t nj = 0; - - correctBoundingBox(bboxUser, ni, nj, inc, {bboxUser.south(), bboxUser.west()}); - - util::BoundingBox bboxField(field); - correctBoundingBox(bboxField, ni, nj, inc, {bboxField.south(), bboxField.west()}); - - PointLatLon ref{bboxField.south(), bboxField.west()}; - - for (const auto& lat : {bboxUser.south(), bboxUser.north()}) { - for (const auto& lon : {bboxUser.east(), bboxUser.west()}) { - if (inc.isShifted({ref.lat() - lat, ref.lon() - lon})) { - return false; - } - } - } - } - - return true; -} - - -} // namespace latlon -} // namespace repres -} // namespace mir +} // namespace mir::repres::latlon diff -Nru metview-5.17.4/mir/src/mir/repres/latlon/LatLon.h metview-5.19.2/mir/src/mir/repres/latlon/LatLon.h --- metview-5.17.4/mir/src/mir/repres/latlon/LatLon.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/latlon/LatLon.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/util/Increments.h" -namespace mir { -namespace repres { -namespace latlon { +namespace mir::repres::latlon { class LatLon : public Gridded { @@ -53,8 +51,6 @@ static void correctBoundingBox(util::BoundingBox&, size_t& ni, size_t& nj, const util::Increments&, const PointLatLon& reference = {0, 0}); - static bool samePoints(const param::MIRParametrisation& user, const param::MIRParametrisation& field); - // -- Overridden methods // None @@ -159,6 +155,4 @@ }; -} // namespace latlon -} // namespace repres -} // namespace mir +} // namespace mir::repres::latlon diff -Nru metview-5.17.4/mir/src/mir/repres/latlon/ReducedLL.cc metview-5.19.2/mir/src/mir/repres/latlon/ReducedLL.cc --- metview-5.17.4/mir/src/mir/repres/latlon/ReducedLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/latlon/ReducedLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,6 +15,7 @@ #include #include #include +#include #include "eckit/types/FloatCompare.h" #include "eckit/types/Fraction.h" @@ -30,9 +31,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace repres { -namespace latlon { +namespace mir::repres::latlon { static bool checkPl(const std::vector& pl) { ASSERT(!pl.empty()); @@ -155,14 +154,14 @@ } bool ReducedLL::isPeriodicWestEast() const { - ASSERT(pl_.size()); + ASSERT(!pl_.empty()); - auto we = bbox_.east() - bbox_.west(); - auto inc = (Longitude::GLOBE - we).value(); - auto maxpl = double(*std::max_element(pl_.begin(), pl_.end())); + auto maxpl = *std::max_element(pl_.begin(), pl_.end()); + ASSERT(maxpl >= 2); - constexpr double GRIB1_EPSILON = 0.001; - return eckit::types::is_approximately_equal(inc * maxpl, Longitude::GLOBE.value(), GRIB1_EPSILON); + // if range West-East is within one increment (or greater than) 360 degree + const eckit::Fraction inc(360, maxpl); + return bbox_.east() - bbox_.west() + inc >= Longitude::GLOBE; } bool ReducedLL::includesNorthPole() const { @@ -273,7 +272,6 @@ } std::vector ReducedLL::gridBoxes() const { - auto dom = domain(); bool periodic = isPeriodicWestEast(); @@ -296,8 +294,8 @@ latEdges[j + 1] = (lat0 - (j + half) * sn).value(); } - latEdges.front() = std::min(dom.north().value(), std::max(dom.south().value(), latEdges.front())); - latEdges.back() = std::min(dom.north().value(), std::max(dom.south().value(), latEdges.back())); + latEdges.front() = std::min(dom.north().value(), latEdges.front()); + latEdges.back() = std::max(dom.south().value(), latEdges.back()); for (size_t j = 0; j < Nj; ++j) { @@ -307,16 +305,28 @@ ASSERT(Ni > 1); const eckit::Fraction we = (dom.east() - dom.west()).fraction() / (Ni - (periodic ? 0 : 1)); - auto lon0 = bbox_.west(); + auto lon0 = bbox_.west() - we / 2; auto lon1 = lon0; - for (long i = 0; i < Ni; ++i) { - auto l = lon1; - lon1 += we; - r.emplace_back(util::GridBox(latEdges[j], l.value(), latEdges[j + 1], lon1.value())); + if (periodic) { + for (long i = 0; i < Ni; ++i) { + auto w = lon1.value(); + lon1 += we; + r.emplace_back(util::GridBox(latEdges[j], w, latEdges[j + 1], lon1.value())); + } + + ASSERT(lon0 == lon1.normalise(lon0)); } + else { + for (long i = 0; i < Ni; ++i) { + auto w = std::max(bbox_.west().value(), lon1.value()); + lon1 += we; + auto e = std::min(bbox_.east().value(), lon1.value()); + r.emplace_back(util::GridBox(latEdges[j], w, latEdges[j + 1], e)); + } - ASSERT(periodic ? lon0 == lon1.normalise(lon0) : lon0 < lon1.normalise(lon0)); + ASSERT(lon0 < lon1.normalise(lon0)); + } } ASSERT(r.size() == numberOfPoints()); @@ -324,9 +334,14 @@ } +const Representation* mir::repres::latlon::ReducedLL::croppedRepresentation(const util::BoundingBox&) const { + std::ostringstream os; + os << "ReducedLL::croppedRepresentation() not supported for " << *this; + throw exception::FunctionalityNotSupported(os.str()); +} + + static const RepresentationBuilder reducedLL("reduced_ll"); -} // namespace latlon -} // namespace repres -} // namespace mir +} // namespace mir::repres::latlon diff -Nru metview-5.17.4/mir/src/mir/repres/latlon/ReducedLL.h metview-5.19.2/mir/src/mir/repres/latlon/ReducedLL.h --- metview-5.17.4/mir/src/mir/repres/latlon/ReducedLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/latlon/ReducedLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { -namespace latlon { +namespace mir::repres::latlon { class ReducedLL : public Gridded { @@ -100,6 +98,7 @@ // From Representation std::vector gridBoxes() const override; + const Representation* croppedRepresentation(const util::BoundingBox&) const override; // -- Class members // None @@ -112,6 +111,4 @@ }; -} // namespace latlon -} // namespace repres -} // namespace mir +} // namespace mir::repres::latlon diff -Nru metview-5.17.4/mir/src/mir/repres/latlon/RegularLL.cc metview-5.19.2/mir/src/mir/repres/latlon/RegularLL.cc --- metview-5.17.4/mir/src/mir/repres/latlon/RegularLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/latlon/RegularLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/GridBox.h" -namespace mir { -namespace repres { -namespace latlon { +namespace mir::repres::latlon { RegularLL::RegularLL(const param::MIRParametrisation& parametrisation) : LatLon(parametrisation) {} @@ -204,6 +202,4 @@ static const RepresentationBuilder regularLL("regular_ll"); -} // namespace latlon -} // namespace repres -} // namespace mir +} // namespace mir::repres::latlon diff -Nru metview-5.17.4/mir/src/mir/repres/latlon/RegularLL.h metview-5.19.2/mir/src/mir/repres/latlon/RegularLL.h --- metview-5.17.4/mir/src/mir/repres/latlon/RegularLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/latlon/RegularLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/repres/latlon/LatLon.h" -namespace mir { -namespace repres { -namespace latlon { +namespace mir::repres::latlon { class RegularLL : public LatLon { @@ -90,6 +88,4 @@ }; -} // namespace latlon -} // namespace repres -} // namespace mir +} // namespace mir::repres::latlon diff -Nru metview-5.17.4/mir/src/mir/repres/latlon/RotatedLL.cc metview-5.19.2/mir/src/mir/repres/latlon/RotatedLL.cc --- metview-5.17.4/mir/src/mir/repres/latlon/RotatedLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/latlon/RotatedLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace repres { -namespace latlon { +namespace mir::repres::latlon { RotatedLL::RotatedLL(const param::MIRParametrisation& parametrisation) : LatLon(parametrisation), rotation_(parametrisation) {} @@ -112,6 +110,4 @@ static const RepresentationBuilder rotatedLL("rotated_ll"); -} // namespace latlon -} // namespace repres -} // namespace mir +} // namespace mir::repres::latlon diff -Nru metview-5.17.4/mir/src/mir/repres/latlon/RotatedLL.h metview-5.19.2/mir/src/mir/repres/latlon/RotatedLL.h --- metview-5.17.4/mir/src/mir/repres/latlon/RotatedLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/latlon/RotatedLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/util/Rotation.h" -namespace mir { -namespace repres { -namespace latlon { +namespace mir::repres::latlon { class RotatedLL : public LatLon { @@ -89,6 +87,4 @@ }; -} // namespace latlon -} // namespace repres -} // namespace mir +} // namespace mir::repres::latlon diff -Nru metview-5.17.4/mir/src/mir/repres/other/None.cc metview-5.19.2/mir/src/mir/repres/other/None.cc --- metview-5.17.4/mir/src/mir/repres/other/None.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/other/None.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include -namespace mir { -namespace repres { -namespace other { +namespace mir::repres::other { None::None() = default; @@ -37,6 +35,4 @@ static const RepresentationBuilder builder("none"); -} // namespace other -} // namespace repres -} // namespace mir +} // namespace mir::repres::other diff -Nru metview-5.17.4/mir/src/mir/repres/other/None.h metview-5.19.2/mir/src/mir/repres/other/None.h --- metview-5.17.4/mir/src/mir/repres/other/None.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/other/None.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/repres/Representation.h" -namespace mir { -namespace repres { -namespace other { +namespace mir::repres::other { class None : public Representation { @@ -93,6 +91,4 @@ }; -} // namespace other -} // namespace repres -} // namespace mir +} // namespace mir::repres::other diff -Nru metview-5.17.4/mir/src/mir/repres/other/ORCA.cc metview-5.19.2/mir/src/mir/repres/other/ORCA.cc --- metview-5.17.4/mir/src/mir/repres/other/ORCA.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/other/ORCA.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,9 +26,7 @@ #include "mir/util/MeshGeneratorParameters.h" -namespace mir { -namespace repres { -namespace other { +namespace mir::repres::other { // order is important for makeName() @@ -175,6 +173,4 @@ } -} // namespace other -} // namespace repres -} // namespace mir +} // namespace mir::repres::other diff -Nru metview-5.17.4/mir/src/mir/repres/other/ORCA.h metview-5.19.2/mir/src/mir/repres/other/ORCA.h --- metview-5.17.4/mir/src/mir/repres/other/ORCA.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/other/ORCA.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/util/Atlas.h" -namespace mir { -namespace repres { -namespace other { +namespace mir::repres::other { class ORCA : public Gridded { @@ -114,6 +112,4 @@ }; -} // namespace other -} // namespace repres -} // namespace mir +} // namespace mir::repres::other diff -Nru metview-5.17.4/mir/src/mir/repres/other/UnstructuredGrid.cc metview-5.19.2/mir/src/mir/repres/other/UnstructuredGrid.cc --- metview-5.17.4/mir/src/mir/repres/other/UnstructuredGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/other/UnstructuredGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -45,8 +45,25 @@ #endif -namespace mir { -namespace repres { +namespace mir::repres { + + +template <> +Representation* RepresentationBuilder::make(const param::MIRParametrisation& param) { +#if mir_HAVE_ATLAS + // specially-named unstructured grids + std::string grid; + if (param.get("grid", grid)) { + if (!key::grid::ORCAPattern::match(grid, param).empty()) { + return new other::ORCA(param); + } + } +#endif + + return new other::UnstructuredGrid(param); +} + + namespace other { @@ -277,21 +294,4 @@ } // namespace other -template <> -Representation* RepresentationBuilder::make(const param::MIRParametrisation& param) { -#if mir_HAVE_ATLAS - // specially-named unstructured grids - std::string grid; - if (param.get("grid", grid)) { - if (!key::grid::ORCAPattern::match(grid, param).empty()) { - return new other::ORCA(param); - } - } -#endif - - return new other::UnstructuredGrid(param); -} - - -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/other/UnstructuredGrid.h metview-5.19.2/mir/src/mir/repres/other/UnstructuredGrid.h --- metview-5.17.4/mir/src/mir/repres/other/UnstructuredGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/other/UnstructuredGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ } -namespace mir { -namespace repres { -namespace other { +namespace mir::repres::other { class UnstructuredGrid : public Gridded { @@ -129,6 +127,4 @@ }; -} // namespace other -} // namespace repres -} // namespace mir +} // namespace mir::repres::other diff -Nru metview-5.17.4/mir/src/mir/repres/regular/LambertAzimuthalEqualArea.cc metview-5.19.2/mir/src/mir/repres/regular/LambertAzimuthalEqualArea.cc --- metview-5.17.4/mir/src/mir/repres/regular/LambertAzimuthalEqualArea.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/LambertAzimuthalEqualArea.cc 2023-07-15 08:28:47.000000000 +0000 @@ -12,15 +12,15 @@ #include "mir/repres/regular/LambertAzimuthalEqualArea.h" +#include + #include "mir/param/MIRParametrisation.h" #include "mir/repres/Iterator.h" #include "mir/util/Exceptions.h" #include "mir/util/Grib.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { static const RepresentationBuilder __builder("lambert_azimuthal_equal_area"); @@ -102,13 +102,11 @@ throw exception::UserError("LambertAzimuthalEqualArea::croppedRepresentation: cannot find first point"); }(mm.first.i, mm.first.j); - auto x = linspace(first.x(), x_.step(), long(mm.second.i - mm.first.i + 1), xPlus_); - auto y = linspace(first.y(), y_.step(), long(mm.second.j - mm.first.j + 1), yPlus_); + auto x = linspace(first.x(), std::abs(x_.step()), long(mm.second.i - mm.first.i + 1), xPlus_); + auto y = linspace(first.y(), std::abs(y_.step()), long(mm.second.j - mm.first.j + 1), yPlus_); return new LambertAzimuthalEqualArea(projection, bbox, x, y, shape_); } -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/LambertAzimuthalEqualArea.h metview-5.19.2/mir/src/mir/repres/regular/LambertAzimuthalEqualArea.h --- metview-5.17.4/mir/src/mir/repres/regular/LambertAzimuthalEqualArea.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/LambertAzimuthalEqualArea.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/repres/regular/RegularGrid.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { class LambertAzimuthalEqualArea : public RegularGrid { @@ -78,6 +76,4 @@ }; -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/Lambert.cc metview-5.19.2/mir/src/mir/repres/regular/Lambert.cc --- metview-5.17.4/mir/src/mir/repres/regular/Lambert.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/Lambert.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { static const RepresentationBuilder __builder("lambert"); @@ -98,6 +96,4 @@ } -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/Lambert.h metview-5.19.2/mir/src/mir/repres/regular/Lambert.h --- metview-5.17.4/mir/src/mir/repres/regular/Lambert.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/Lambert.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/repres/regular/RegularGrid.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { class Lambert : public RegularGrid { @@ -77,6 +75,4 @@ }; -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/Mercator.cc metview-5.19.2/mir/src/mir/repres/regular/Mercator.cc --- metview-5.17.4/mir/src/mir/repres/regular/Mercator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/Mercator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { static const RepresentationBuilder __builder("mercator"); @@ -31,6 +29,4 @@ } -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/Mercator.h metview-5.19.2/mir/src/mir/repres/regular/Mercator.h --- metview-5.17.4/mir/src/mir/repres/regular/Mercator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/Mercator.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/repres/regular/RegularGrid.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { class Mercator : public RegularGrid { @@ -74,6 +72,4 @@ }; -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/PolarStereographic.cc metview-5.19.2/mir/src/mir/repres/regular/PolarStereographic.cc --- metview-5.17.4/mir/src/mir/repres/regular/PolarStereographic.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/PolarStereographic.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { static const RepresentationBuilder __builder("polar_stereographic"); @@ -32,6 +30,4 @@ } -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/PolarStereographic.h metview-5.19.2/mir/src/mir/repres/regular/PolarStereographic.h --- metview-5.17.4/mir/src/mir/repres/regular/PolarStereographic.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/PolarStereographic.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/repres/regular/RegularGrid.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { class PolarStereographic : public RegularGrid { @@ -74,6 +72,4 @@ }; -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/RegularGrid.cc metview-5.19.2/mir/src/mir/repres/regular/RegularGrid.cc --- metview-5.17.4/mir/src/mir/repres/regular/RegularGrid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/RegularGrid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,9 +31,7 @@ #include "mir/util/MeshGeneratorParameters.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { RegularGrid::RegularGrid(const param::MIRParametrisation& param, const RegularGrid::Projection& projection) : @@ -82,7 +80,13 @@ RegularGrid::RegularGrid(const Projection& projection, const util::BoundingBox& bbox, const LinearSpacing& x, const LinearSpacing& y, const util::Shape& shape) : - Gridded(bbox), x_(x), y_(y), shape_(shape), xPlus_(true), yPlus_(false), firstPointBottomLeft_(false) { + Gridded(bbox), + x_(x), + y_(y), + shape_(shape), + xPlus_(x.front() <= x.back()), + yPlus_(y.front() < y.back()), + firstPointBottomLeft_(false) { grid_ = {x_, y_, projection}; if (!shape_.provided) { @@ -122,6 +126,7 @@ RegularGrid::LinearSpacing RegularGrid::linspace(double start, double step, long num, bool plus) { + ASSERT(step >= 0.); return {start, start + step * double(plus ? num - 1 : 1 - num), num}; } @@ -331,6 +336,4 @@ } -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/RegularGrid.h metview-5.19.2/mir/src/mir/repres/regular/RegularGrid.h --- metview-5.17.4/mir/src/mir/repres/regular/RegularGrid.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/RegularGrid.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { class RegularGrid : public Gridded { @@ -122,6 +120,4 @@ }; -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/SpaceView.cc metview-5.19.2/mir/src/mir/repres/regular/SpaceView.cc --- metview-5.17.4/mir/src/mir/repres/regular/SpaceView.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/SpaceView.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,9 +29,7 @@ #include "mir/util/Trace.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { static const RepresentationBuilder __builder("space_view"); @@ -251,6 +249,4 @@ } -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/regular/SpaceView.h metview-5.19.2/mir/src/mir/repres/regular/SpaceView.h --- metview-5.17.4/mir/src/mir/repres/regular/SpaceView.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/regular/SpaceView.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/repres/regular/RegularGrid.h" -namespace mir { -namespace repres { -namespace regular { +namespace mir::repres::regular { namespace detail { @@ -113,6 +111,4 @@ }; -} // namespace regular -} // namespace repres -} // namespace mir +} // namespace mir::repres::regular diff -Nru metview-5.17.4/mir/src/mir/repres/Representation.cc metview-5.19.2/mir/src/mir/repres/Representation.cc --- metview-5.17.4/mir/src/mir/repres/Representation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/Representation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace repres { +namespace mir::repres { Representation::Representation() = default; @@ -222,6 +221,13 @@ } +size_t Representation::numberOfValues() const { + std::ostringstream os; + os << "Representation::numberOfValues() not implemented for " << *this; + throw exception::SeriousBug(os.str()); +} + + bool Representation::getLongestElementDiagonal(double& /*unused*/) const { std::ostringstream os; os << "Representation::getLongestElementDiagonal() not implemented for " << *this; @@ -383,5 +389,4 @@ } -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/Representation.h metview-5.19.2/mir/src/mir/repres/Representation.h --- metview-5.17.4/mir/src/mir/repres/Representation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/Representation.h 2023-07-15 08:28:47.000000000 +0000 @@ -60,8 +60,7 @@ } // namespace mir -namespace mir { -namespace repres { +namespace mir::repres { class Representation : public eckit::Counted { @@ -104,6 +103,7 @@ virtual const Representation* globalise(data::MIRField&) const; virtual size_t numberOfPoints() const; + virtual size_t numberOfValues() const; virtual bool getLongestElementDiagonal(double&) const; virtual const Representation* truncate(size_t truncation, const MIRValuesVector&, MIRValuesVector&) const; @@ -230,5 +230,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/sh/SphericalHarmonics.cc metview-5.19.2/mir/src/mir/repres/sh/SphericalHarmonics.cc --- metview-5.17.4/mir/src/mir/repres/sh/SphericalHarmonics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/sh/SphericalHarmonics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace repres { -namespace sh { +namespace mir::repres::sh { SphericalHarmonics::SphericalHarmonics(const param::MIRParametrisation& parametrisation) { @@ -109,12 +107,12 @@ size_t outsize = number_of_complex_coefficients(truncation_to) * 2; out.resize(outsize); - auto delta = int(truncation_from - truncation_to); + auto delta = static_cast(truncation_from) - static_cast(truncation_to); size_t i = 0; size_t j = 0; if (delta > 0) { - auto delta2 = size_t(delta * 2); + auto delta2 = static_cast(delta * 2); size_t t1 = truncation_to + 1; for (size_t m = 0; m < t1; m++) { @@ -183,8 +181,12 @@ void SphericalHarmonics::validate(const MIRValuesVector& values) const { - ASSERT_VALUES_SIZE_EQ_NUMBER_OF_COEFFS("SphericalHarmonics", values.size(), - number_of_complex_coefficients(truncation_) * 2); + ASSERT_VALUES_SIZE_EQ_NUMBER_OF_COEFFS("SphericalHarmonics", values.size(), numberOfValues()); +} + + +size_t SphericalHarmonics::numberOfValues() const { + return number_of_complex_coefficients(truncation_) * 2; } @@ -202,6 +204,4 @@ static const RepresentationBuilder sphericalHarmonics("sh"); -} // namespace sh -} // namespace repres -} // namespace mir +} // namespace mir::repres::sh diff -Nru metview-5.17.4/mir/src/mir/repres/sh/SphericalHarmonics.h metview-5.19.2/mir/src/mir/repres/sh/SphericalHarmonics.h --- metview-5.17.4/mir/src/mir/repres/sh/SphericalHarmonics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/sh/SphericalHarmonics.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/util/Domain.h" -namespace mir { -namespace repres { -namespace sh { +namespace mir::repres::sh { class SphericalHarmonics : public Representation { @@ -100,6 +98,7 @@ void comparison(std::string&) const override; void validate(const MIRValuesVector&) const override; + size_t numberOfValues() const override; void makeName(std::ostream&) const override; bool sameAs(const Representation&) const override; @@ -119,6 +118,4 @@ }; -} // namespace sh -} // namespace repres -} // namespace mir +} // namespace mir::repres::sh diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/Albers.cc metview-5.19.2/mir/src/mir/repres/unsupported/Albers.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/Albers.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/Albers.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { Albers::Albers(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("albers"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/Albers.h metview-5.19.2/mir/src/mir/repres/unsupported/Albers.h --- metview-5.17.4/mir/src/mir/repres/unsupported/Albers.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/Albers.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class Albers : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/AzimuthRange.cc metview-5.19.2/mir/src/mir/repres/unsupported/AzimuthRange.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/AzimuthRange.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/AzimuthRange.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { AzimuthRange::AzimuthRange(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("azimuth_range"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/AzimuthRange.h metview-5.19.2/mir/src/mir/repres/unsupported/AzimuthRange.h --- metview-5.17.4/mir/src/mir/repres/unsupported/AzimuthRange.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/AzimuthRange.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class AzimuthRange : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/EquatorialAzimuthalEquidistant.cc metview-5.19.2/mir/src/mir/repres/unsupported/EquatorialAzimuthalEquidistant.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/EquatorialAzimuthalEquidistant.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/EquatorialAzimuthalEquidistant.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { EquatorialAzimuthalEquidistant::EquatorialAzimuthalEquidistant(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("equatorial_azimuthal_equidistant"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/EquatorialAzimuthalEquidistant.h metview-5.19.2/mir/src/mir/repres/unsupported/EquatorialAzimuthalEquidistant.h --- metview-5.17.4/mir/src/mir/repres/unsupported/EquatorialAzimuthalEquidistant.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/EquatorialAzimuthalEquidistant.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class EquatorialAzimuthalEquidistant : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/IrregularLatlon.cc metview-5.19.2/mir/src/mir/repres/unsupported/IrregularLatlon.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/IrregularLatlon.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/IrregularLatlon.cc 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace repres { +namespace mir::repres { static void range(const std::vector& v, double& mn, double& mx, double& dmax) { @@ -260,5 +259,4 @@ static const RepresentationBuilder irregularLatlon("irregular_latlon"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/IrregularLatlon.h metview-5.19.2/mir/src/mir/repres/unsupported/IrregularLatlon.h --- metview-5.17.4/mir/src/mir/repres/unsupported/IrregularLatlon.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/IrregularLatlon.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class IrregularLatlon : public Gridded { @@ -114,5 +113,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/RotatedSH.cc metview-5.19.2/mir/src/mir/repres/unsupported/RotatedSH.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/RotatedSH.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/RotatedSH.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { RotatedSH::RotatedSH(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("rotated_sh"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/RotatedSH.h metview-5.19.2/mir/src/mir/repres/unsupported/RotatedSH.h --- metview-5.17.4/mir/src/mir/repres/unsupported/RotatedSH.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/RotatedSH.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class RotatedSH : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedGG.cc metview-5.19.2/mir/src/mir/repres/unsupported/StretchedGG.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { StretchedGG::StretchedGG(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("stretched_gg"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedGG.h metview-5.19.2/mir/src/mir/repres/unsupported/StretchedGG.h --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class StretchedGG : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedLL.cc metview-5.19.2/mir/src/mir/repres/unsupported/StretchedLL.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { StretchedLL::StretchedLL(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("stretched_ll"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedLL.h metview-5.19.2/mir/src/mir/repres/unsupported/StretchedLL.h --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class StretchedLL : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedGG.cc metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedGG.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedGG.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedGG.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { StretchedRotatedGG::StretchedRotatedGG(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("stretched_rotated_gg"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedGG.h metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedGG.h --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedGG.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedGG.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class StretchedRotatedGG : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedLL.cc metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedLL.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedLL.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedLL.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { StretchedRotatedLL::StretchedRotatedLL(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("stretched_rotated_ll"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedLL.h metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedLL.h --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedLL.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedLL.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class StretchedRotatedLL : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedSH.cc metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedSH.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedSH.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedSH.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { StretchedRotatedSH::StretchedRotatedSH(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("stretched_rotated_sh"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedSH.h metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedSH.h --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedRotatedSH.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedRotatedSH.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class StretchedRotatedSH : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedSH.cc metview-5.19.2/mir/src/mir/repres/unsupported/StretchedSH.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedSH.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedSH.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { StretchedSH::StretchedSH(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("stretched_sh"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/StretchedSH.h metview-5.19.2/mir/src/mir/repres/unsupported/StretchedSH.h --- metview-5.17.4/mir/src/mir/repres/unsupported/StretchedSH.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/StretchedSH.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class StretchedSH : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/TransverseMercator.cc metview-5.19.2/mir/src/mir/repres/unsupported/TransverseMercator.cc --- metview-5.17.4/mir/src/mir/repres/unsupported/TransverseMercator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/TransverseMercator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace repres { +namespace mir::repres { TransverseMercator::TransverseMercator(const param::MIRParametrisation& /*parametrisation*/) {} @@ -31,5 +30,4 @@ static const RepresentationBuilder __repres("transverse_mercator"); -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/repres/unsupported/TransverseMercator.h metview-5.19.2/mir/src/mir/repres/unsupported/TransverseMercator.h --- metview-5.17.4/mir/src/mir/repres/unsupported/TransverseMercator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/repres/unsupported/TransverseMercator.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/repres/Gridded.h" -namespace mir { -namespace repres { +namespace mir::repres { class TransverseMercator : public Gridded { @@ -89,5 +88,4 @@ }; -} // namespace repres -} // namespace mir +} // namespace mir::repres diff -Nru metview-5.17.4/mir/src/mir/search/PointSearch.cc metview-5.19.2/mir/src/mir/search/PointSearch.cc --- metview-5.17.4/mir/src/mir/search/PointSearch.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/PointSearch.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,18 +24,21 @@ #include "mir/util/Types.h" -namespace mir { -namespace search { +namespace mir::search { -PointSearch::PointSearch(const param::MIRParametrisation& parametrisation, const repres::Representation& r) { + +static std::string extract_loader(const param::MIRParametrisation& param) { bool caching = LibMir::caching(); - parametrisation.get("caching", caching); + param.get("caching", caching); - std::string name = caching ? "mapped-cache-file" : "memory"; - parametrisation.get("point-search-trees", name); + std::string name = caching ? LibMir::cacheLoader(LibMir::cache_loader::POINT_SEARCH) : "memory"; + param.get("point-search-trees", name); + return name; +} - tree_.reset(TreeFactory::build(name, r)); +PointSearch::PointSearch(const param::MIRParametrisation& param, const repres::Representation& r) { + tree_.reset(TreeFactory::build(extract_loader(param), r)); eckit::AutoLock lock(*tree_); Log::debug() << "Search using " << *tree_ << std::endl; @@ -46,10 +49,12 @@ } } + PointSearch::PointValueType PointSearch::closestPoint(const PointSearch::PointType& pt) const { return tree_->nearestNeighbour(pt); } + void PointSearch::closestNPoints(const PointType& pt, size_t n, std::vector& closest) const { // Small optimisation @@ -62,10 +67,12 @@ closest = tree_->kNearestNeighbours(pt, n); } + void PointSearch::closestWithinRadius(const PointType& pt, double radius, std::vector& closest) const { closest = tree_->findInSphere(pt, radius); } + void PointSearch::build(const repres::Representation& r) { const size_t npts = tree_->itemCount(); ASSERT(npts > 0); @@ -98,10 +105,11 @@ } } + void PointSearch::print(std::ostream& out) const { tree_->statsPrint(out, false); tree_->statsReset(); } -} // namespace search -} // namespace mir + +} // namespace mir::search diff -Nru metview-5.17.4/mir/src/mir/search/PointSearch.h metview-5.19.2/mir/src/mir/search/PointSearch.h --- metview-5.17.4/mir/src/mir/search/PointSearch.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/PointSearch.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,15 +17,12 @@ #include "mir/search/Tree.h" -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace search { +namespace mir::search { /// Class for fast searches in point clouds following k-d tree algorithms @@ -121,5 +118,4 @@ }; -} // namespace search -} // namespace mir +} // namespace mir::search diff -Nru metview-5.17.4/mir/src/mir/search/tree/TreeMappedAnonymousMemory.cc metview-5.19.2/mir/src/mir/search/tree/TreeMappedAnonymousMemory.cc --- metview-5.17.4/mir/src/mir/search/tree/TreeMappedAnonymousMemory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/tree/TreeMappedAnonymousMemory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/search/tree/TreeMappedAnonymousMemory.h" -namespace mir { -namespace search { -namespace tree { +namespace mir::search::tree { TreeMappedAnonymousMemory::TreeMappedAnonymousMemory(const repres::Representation& r) : TreeMapped(r, "/dev/zero") {} @@ -24,6 +22,4 @@ static const TreeBuilder builder("mapped-anonymous-memory"); -} // namespace tree -} // namespace search -} // namespace mir +} // namespace mir::search::tree diff -Nru metview-5.17.4/mir/src/mir/search/tree/TreeMappedAnonymousMemory.h metview-5.19.2/mir/src/mir/search/tree/TreeMappedAnonymousMemory.h --- metview-5.17.4/mir/src/mir/search/tree/TreeMappedAnonymousMemory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/tree/TreeMappedAnonymousMemory.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/search/tree/TreeMapped.h" -namespace mir { -namespace search { -namespace tree { +namespace mir::search::tree { class TreeMappedAnonymousMemory : public TreeMapped { @@ -33,6 +31,4 @@ }; -} // namespace tree -} // namespace search -} // namespace mir +} // namespace mir::search::tree diff -Nru metview-5.17.4/mir/src/mir/search/tree/TreeMapped.cc metview-5.19.2/mir/src/mir/search/tree/TreeMapped.cc --- metview-5.17.4/mir/src/mir/search/tree/TreeMapped.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/tree/TreeMapped.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/search/tree/TreeMapped.h" -namespace mir { -namespace search { -namespace tree { +namespace mir::search::tree { void TreeMapped::build(std::vector& v) { @@ -66,6 +64,4 @@ Tree(r), umask_(0), path_(path), tree_(path, path.exists() ? 0 : itemCount(), 0) {} -} // namespace tree -} // namespace search -} // namespace mir +} // namespace mir::search::tree diff -Nru metview-5.17.4/mir/src/mir/search/tree/TreeMappedFile.cc metview-5.19.2/mir/src/mir/search/tree/TreeMappedFile.cc --- metview-5.17.4/mir/src/mir/search/tree/TreeMappedFile.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/tree/TreeMappedFile.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace search { -namespace tree { +namespace mir::search::tree { template @@ -128,6 +126,4 @@ static const TreeBuilder builder2("mapped-temporary-file"); -} // namespace tree -} // namespace search -} // namespace mir +} // namespace mir::search::tree diff -Nru metview-5.17.4/mir/src/mir/search/tree/TreeMappedFile.h metview-5.19.2/mir/src/mir/search/tree/TreeMappedFile.h --- metview-5.17.4/mir/src/mir/search/tree/TreeMappedFile.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/tree/TreeMappedFile.h 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace search { -namespace tree { +namespace mir::search::tree { template @@ -88,6 +86,4 @@ }; -} // namespace tree -} // namespace search -} // namespace mir +} // namespace mir::search::tree diff -Nru metview-5.17.4/mir/src/mir/search/tree/TreeMapped.h metview-5.19.2/mir/src/mir/search/tree/TreeMapped.h --- metview-5.17.4/mir/src/mir/search/tree/TreeMapped.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/tree/TreeMapped.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/search/Tree.h" -namespace mir { -namespace search { -namespace tree { +namespace mir::search::tree { class TreeMapped : public Tree { @@ -55,6 +53,4 @@ }; -} // namespace tree -} // namespace search -} // namespace mir +} // namespace mir::search::tree diff -Nru metview-5.17.4/mir/src/mir/search/tree/TreeMemory.cc metview-5.19.2/mir/src/mir/search/tree/TreeMemory.cc --- metview-5.17.4/mir/src/mir/search/tree/TreeMemory.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/tree/TreeMemory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/search/tree/TreeMemory.h" -namespace mir { -namespace search { -namespace tree { +namespace mir::search::tree { void TreeMemory::build(std::vector& v) { @@ -78,6 +76,4 @@ static const TreeBuilder builder("memory"); -} // namespace tree -} // namespace search -} // namespace mir +} // namespace mir::search::tree diff -Nru metview-5.17.4/mir/src/mir/search/tree/TreeMemory.h metview-5.19.2/mir/src/mir/search/tree/TreeMemory.h --- metview-5.17.4/mir/src/mir/search/tree/TreeMemory.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/tree/TreeMemory.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/search/Tree.h" -namespace mir { -namespace search { -namespace tree { +namespace mir::search::tree { class TreeMemory : public Tree { @@ -52,6 +50,4 @@ }; -} // namespace tree -} // namespace search -} // namespace mir +} // namespace mir::search::tree diff -Nru metview-5.17.4/mir/src/mir/search/Tree.cc metview-5.19.2/mir/src/mir/search/Tree.cc --- metview-5.17.4/mir/src/mir/search/Tree.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/Tree.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace search { +namespace mir::search { Tree::~Tree() = default; @@ -170,5 +169,4 @@ } -} // namespace search -} // namespace mir +} // namespace mir::search diff -Nru metview-5.17.4/mir/src/mir/search/Tree.h metview-5.19.2/mir/src/mir/search/Tree.h --- metview-5.17.4/mir/src/mir/search/Tree.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/search/Tree.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,19 +21,16 @@ #include "mir/util/Types.h" -namespace mir { -namespace repres { +namespace mir::repres { class Representation; -} -} // namespace mir +} // namespace mir::repres -namespace mir { -namespace search { +namespace mir::search { class Tree { - Tree(const Tree&) = delete; + Tree(const Tree&) = delete; Tree& operator=(const Tree&) = delete; public: @@ -74,7 +71,7 @@ }; class TreeFactory { - TreeFactory(const TreeFactory&) = delete; + TreeFactory(const TreeFactory&) = delete; TreeFactory& operator=(const TreeFactory&) = delete; protected: @@ -97,5 +94,4 @@ }; -} // namespace search -} // namespace mir +} // namespace mir::search diff -Nru metview-5.17.4/mir/src/mir/stats/comparator/ComparatorT.cc metview-5.19.2/mir/src/mir/stats/comparator/ComparatorT.cc --- metview-5.17.4/mir/src/mir/stats/comparator/ComparatorT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/comparator/ComparatorT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace comparator { +namespace mir::stats::comparator { template @@ -42,7 +40,7 @@ const auto& values2 = field2.values(0); ASSERT(values1.size() == values2.size()); - if (std::isnan(ignoreAboveLatitude_) == 0 || std::isnan(ignoreBelowLatitude_) == 0) { + if (!std::isnan(ignoreAboveLatitude_) || !std::isnan(ignoreBelowLatitude_)) { repres::RepresentationHandle rep1(field1.representation()); repres::RepresentationHandle rep2(field2.representation()); @@ -131,6 +129,4 @@ static const ComparatorBuilder> __comp6("min-max"); -} // namespace comparator -} // namespace stats -} // namespace mir +} // namespace mir::stats::comparator diff -Nru metview-5.17.4/mir/src/mir/stats/comparator/ComparatorT.h metview-5.19.2/mir/src/mir/stats/comparator/ComparatorT.h --- metview-5.17.4/mir/src/mir/stats/comparator/ComparatorT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/comparator/ComparatorT.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,16 +22,12 @@ #include "mir/stats/detail/CounterBinary.h" -namespace mir { -namespace data { +namespace mir::data { class MIRField; -} -} // namespace mir +} // namespace mir::data -namespace mir { -namespace stats { -namespace comparator { +namespace mir::stats::comparator { /// Generic comparison on two MIRFields @@ -101,6 +97,4 @@ }; -} // namespace comparator -} // namespace stats -} // namespace mir +} // namespace mir::stats::comparator diff -Nru metview-5.17.4/mir/src/mir/stats/comparator/MissingValues.cc metview-5.19.2/mir/src/mir/stats/comparator/MissingValues.cc --- metview-5.17.4/mir/src/mir/stats/comparator/MissingValues.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/comparator/MissingValues.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace comparator { +namespace mir::stats::comparator { std::string MissingValues::execute(const data::MIRField& field1, const data::MIRField& field2) { @@ -82,6 +80,4 @@ static const ComparatorBuilder __stats("missing-values"); -} // namespace comparator -} // namespace stats -} // namespace mir +} // namespace mir::stats::comparator diff -Nru metview-5.17.4/mir/src/mir/stats/comparator/MissingValues.h metview-5.19.2/mir/src/mir/stats/comparator/MissingValues.h --- metview-5.17.4/mir/src/mir/stats/comparator/MissingValues.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/comparator/MissingValues.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/stats/Comparator.h" -namespace mir { -namespace stats { -namespace comparator { +namespace mir::stats::comparator { /** @@ -75,6 +73,4 @@ }; -} // namespace comparator -} // namespace stats -} // namespace mir +} // namespace mir::stats::comparator diff -Nru metview-5.17.4/mir/src/mir/stats/comparator/Spectral.cc metview-5.19.2/mir/src/mir/stats/comparator/Spectral.cc --- metview-5.17.4/mir/src/mir/stats/comparator/Spectral.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/comparator/Spectral.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ #include "mir/stats/statistics/Spectral.h" -namespace mir { -namespace stats { -namespace comparator { +namespace mir::stats::comparator { Spectral::Spectral(const param::MIRParametrisation& param1, const param::MIRParametrisation& param2) : @@ -101,6 +99,4 @@ static const ComparatorBuilder __stats("spectral"); -} // namespace comparator -} // namespace stats -} // namespace mir +} // namespace mir::stats::comparator diff -Nru metview-5.17.4/mir/src/mir/stats/comparator/Spectral.h metview-5.19.2/mir/src/mir/stats/comparator/Spectral.h --- metview-5.17.4/mir/src/mir/stats/comparator/Spectral.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/comparator/Spectral.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/stats/Comparator.h" -namespace mir { -namespace stats { -namespace comparator { +namespace mir::stats::comparator { /** @@ -86,6 +84,4 @@ }; -} // namespace comparator -} // namespace stats -} // namespace mir +} // namespace mir::stats::comparator diff -Nru metview-5.17.4/mir/src/mir/stats/Comparator.cc metview-5.19.2/mir/src/mir/stats/Comparator.cc --- metview-5.17.4/mir/src/mir/stats/Comparator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Comparator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace stats { +namespace mir::stats { static util::recursive_mutex* local_mutex = nullptr; @@ -90,5 +89,4 @@ } -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/Comparator.h metview-5.19.2/mir/src/mir/stats/Comparator.h --- metview-5.17.4/mir/src/mir/stats/Comparator.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Comparator.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ } // namespace mir -namespace mir { -namespace stats { +namespace mir::stats { class Comparator { @@ -112,7 +111,7 @@ std::string name_; virtual Comparator* make(const param::MIRParametrisation&, const param::MIRParametrisation&) = 0; - ComparatorFactory(const ComparatorFactory&) = delete; + ComparatorFactory(const ComparatorFactory&) = delete; ComparatorFactory& operator=(const ComparatorFactory&) = delete; protected: @@ -136,5 +135,4 @@ }; -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/detail/AngleT.cc metview-5.19.2/mir/src/mir/stats/detail/AngleT.cc --- metview-5.17.4/mir/src/mir/stats/detail/AngleT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/AngleT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,9 +13,7 @@ #include "mir/stats/detail/AngleT.h" -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { constexpr double D360 = 360; @@ -47,6 +45,4 @@ rescale_(1.), descale_(1.), globe_(TWO * M_PI), min_(-M_PI) {} -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/AngleT.h metview-5.19.2/mir/src/mir/stats/detail/AngleT.h --- metview-5.17.4/mir/src/mir/stats/detail/AngleT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/AngleT.h 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { enum AngleScale @@ -110,6 +108,4 @@ AngleT::AngleT::AngleT(); -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/CentralMomentsT.cc metview-5.19.2/mir/src/mir/stats/detail/CentralMomentsT.cc --- metview-5.17.4/mir/src/mir/stats/detail/CentralMomentsT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/CentralMomentsT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { template <> @@ -37,6 +35,4 @@ } -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/CentralMomentsT.h metview-5.19.2/mir/src/mir/stats/detail/CentralMomentsT.h --- metview-5.17.4/mir/src/mir/stats/detail/CentralMomentsT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/CentralMomentsT.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { /** @@ -110,6 +108,4 @@ }; -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/CounterBinary.cc metview-5.19.2/mir/src/mir/stats/detail/CounterBinary.cc --- metview-5.17.4/mir/src/mir/stats/detail/CounterBinary.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/CounterBinary.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { CounterBinary::CounterBinary(const param::MIRParametrisation& param1, const param::MIRParametrisation& param2) : @@ -290,6 +288,4 @@ } -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/CounterBinary.h metview-5.19.2/mir/src/mir/stats/detail/CounterBinary.h --- metview-5.17.4/mir/src/mir/stats/detail/CounterBinary.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/CounterBinary.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/stats/detail/Counter.h" -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { /// Counter accounting for missing values, for differences of two MIRFIelds @@ -84,6 +82,4 @@ }; -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/Counter.cc metview-5.19.2/mir/src/mir/stats/detail/Counter.cc --- metview-5.17.4/mir/src/mir/stats/detail/Counter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/Counter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { static double get_param(const param::MIRParametrisation& param, const std::string& key, double def) { @@ -165,6 +163,4 @@ } -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/Counter.h metview-5.19.2/mir/src/mir/stats/detail/Counter.h --- metview-5.17.4/mir/src/mir/stats/detail/Counter.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/Counter.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,7 @@ } // namespace mir -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { /// Counter accounting for missing values @@ -87,6 +85,4 @@ }; -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/ModeT.cc metview-5.19.2/mir/src/mir/stats/detail/ModeT.cc --- metview-5.17.4/mir/src/mir/stats/detail/ModeT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/ModeT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/param/MIRParametrisation.h" -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { namespace { @@ -110,6 +108,7 @@ ModeBoolean::ModeBoolean(const param::MIRParametrisation& param) { + reset(); param.get("mode-disambiguate-max", disambiguateMax_); param.get("mode-boolean-min", min_); } @@ -166,6 +165,4 @@ } -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/ModeT.h metview-5.19.2/mir/src/mir/stats/detail/ModeT.h --- metview-5.17.4/mir/src/mir/stats/detail/ModeT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/ModeT.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,16 +20,12 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { /** @@ -169,6 +165,4 @@ }; -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/PNormsT.h metview-5.19.2/mir/src/mir/stats/detail/PNormsT.h --- metview-5.17.4/mir/src/mir/stats/detail/PNormsT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/PNormsT.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { /** @@ -69,6 +67,4 @@ }; -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/detail/ScalarT.h metview-5.19.2/mir/src/mir/stats/detail/ScalarT.h --- metview-5.17.4/mir/src/mir/stats/detail/ScalarT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/detail/ScalarT.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/stats/detail/CentralMomentsT.h" -namespace mir { -namespace stats { -namespace detail { +namespace mir::stats::detail { /// Scalar statistics (composition) @@ -35,6 +33,4 @@ }; -} // namespace detail -} // namespace stats -} // namespace mir +} // namespace mir::stats::detail diff -Nru metview-5.17.4/mir/src/mir/stats/distribution/DistributionT.cc metview-5.19.2/mir/src/mir/stats/distribution/DistributionT.cc --- metview-5.17.4/mir/src/mir/stats/distribution/DistributionT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/distribution/DistributionT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,9 +19,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace distribution { +namespace mir::stats::distribution { static const DistributionBuilder> __random1("bernoulli-distribution"); @@ -425,6 +423,4 @@ } -} // namespace distribution -} // namespace stats -} // namespace mir +} // namespace mir::stats::distribution diff -Nru metview-5.17.4/mir/src/mir/stats/distribution/DistributionT.h metview-5.19.2/mir/src/mir/stats/distribution/DistributionT.h --- metview-5.17.4/mir/src/mir/stats/distribution/DistributionT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/distribution/DistributionT.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,16 +15,12 @@ #include "mir/stats/Distribution.h" -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace stats { -namespace distribution { +namespace mir::stats::distribution { template @@ -102,6 +98,4 @@ }; -} // namespace distribution -} // namespace stats -} // namespace mir +} // namespace mir::stats::distribution diff -Nru metview-5.17.4/mir/src/mir/stats/Distribution.cc metview-5.19.2/mir/src/mir/stats/Distribution.cc --- metview-5.17.4/mir/src/mir/stats/Distribution.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Distribution.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/ValueMap.h" -namespace mir { -namespace stats { +namespace mir::stats { static util::once_flag once; @@ -104,5 +103,4 @@ } -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/Distribution.h metview-5.19.2/mir/src/mir/stats/Distribution.h --- metview-5.17.4/mir/src/mir/stats/Distribution.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Distribution.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,15 +17,12 @@ #include -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace stats { +namespace mir::stats { class Distribution { @@ -102,7 +99,7 @@ class DistributionFactory { - DistributionFactory(const DistributionFactory&) = delete; + DistributionFactory(const DistributionFactory&) = delete; void operator=(const DistributionFactory&) = delete; virtual Distribution* make(const param::MIRParametrisation&) = 0; const std::string name_; @@ -126,5 +123,4 @@ }; -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/field/CentralMomentStats.cc metview-5.19.2/mir/src/mir/stats/field/CentralMomentStats.cc --- metview-5.17.4/mir/src/mir/stats/field/CentralMomentStats.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/field/CentralMomentStats.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/stats/detail/CentralMomentsT.h" -namespace mir { -namespace stats { -namespace field { +namespace mir::stats::field { struct Mean final : CentralMomentStatsT> { @@ -72,6 +70,4 @@ static const FieldBuilder __builder_6("sum"); -} // namespace field -} // namespace stats -} // namespace mir +} // namespace mir::stats::field diff -Nru metview-5.17.4/mir/src/mir/stats/field/CentralMomentStats.h metview-5.19.2/mir/src/mir/stats/field/CentralMomentStats.h --- metview-5.17.4/mir/src/mir/stats/field/CentralMomentStats.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/field/CentralMomentStats.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/stats/detail/Counter.h" -namespace mir { -namespace stats { -namespace field { +namespace mir::stats::field { /// Central moment statistics on values (mean, stddev, etc.) @@ -42,6 +40,4 @@ }; -} // namespace field -} // namespace stats -} // namespace mir +} // namespace mir::stats::field diff -Nru metview-5.17.4/mir/src/mir/stats/field/CounterStats.cc metview-5.19.2/mir/src/mir/stats/field/CounterStats.cc --- metview-5.17.4/mir/src/mir/stats/field/CounterStats.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/field/CounterStats.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include -namespace mir { -namespace stats { -namespace field { +namespace mir::stats::field { struct Count final : CounterStats { @@ -62,6 +60,4 @@ static const FieldBuilder __builder_5("minimum"); -} // namespace field -} // namespace stats -} // namespace mir +} // namespace mir::stats::field diff -Nru metview-5.17.4/mir/src/mir/stats/field/CounterStats.h metview-5.19.2/mir/src/mir/stats/field/CounterStats.h --- metview-5.17.4/mir/src/mir/stats/field/CounterStats.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/field/CounterStats.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/stats/detail/Counter.h" -namespace mir { -namespace stats { -namespace field { +namespace mir::stats::field { /// Counting statistics on values (min, max, etc.) @@ -33,6 +31,4 @@ }; -} // namespace field -} // namespace stats -} // namespace mir +} // namespace mir::stats::field diff -Nru metview-5.17.4/mir/src/mir/stats/field/ModeStats.cc metview-5.19.2/mir/src/mir/stats/field/ModeStats.cc --- metview-5.17.4/mir/src/mir/stats/field/ModeStats.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/field/ModeStats.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/stats/detail/ModeT.h" -namespace mir { -namespace stats { -namespace field { +namespace mir::stats::field { struct ModeReal final : ModeStatsT { @@ -58,6 +56,4 @@ static const FieldBuilder __builder_5("median-boolean"); // (alias) -} // namespace field -} // namespace stats -} // namespace mir +} // namespace mir::stats::field diff -Nru metview-5.17.4/mir/src/mir/stats/field/ModeStats.h metview-5.19.2/mir/src/mir/stats/field/ModeStats.h --- metview-5.17.4/mir/src/mir/stats/field/ModeStats.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/field/ModeStats.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/stats/detail/Counter.h" -namespace mir { -namespace stats { -namespace field { +namespace mir::stats::field { /// Mode statistics on values @@ -42,6 +40,4 @@ }; -} // namespace field -} // namespace stats -} // namespace mir +} // namespace mir::stats::field diff -Nru metview-5.17.4/mir/src/mir/stats/Field.cc metview-5.19.2/mir/src/mir/stats/Field.cc --- metview-5.17.4/mir/src/mir/stats/Field.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Field.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace stats { +namespace mir::stats { static util::recursive_mutex* local_mutex = nullptr; @@ -88,5 +87,4 @@ } -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/Field.h metview-5.19.2/mir/src/mir/stats/Field.h --- metview-5.17.4/mir/src/mir/stats/Field.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Field.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace stats { +namespace mir::stats { class Field { @@ -109,7 +106,7 @@ std::string name_; virtual Field* make(const param::MIRParametrisation&) = 0; - FieldFactory(const FieldFactory&) = delete; + FieldFactory(const FieldFactory&) = delete; FieldFactory& operator=(const FieldFactory&) = delete; protected: @@ -131,5 +128,4 @@ }; -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/method/MethodT.cc metview-5.19.2/mir/src/mir/stats/method/MethodT.cc --- metview-5.17.4/mir/src/mir/stats/method/MethodT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/method/MethodT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/stats/detail/ScalarT.h" -namespace mir { -namespace stats { -namespace method { +namespace mir::stats::method { template @@ -121,6 +119,4 @@ static const MethodBuilder>> __stats6("scalar"); -} // namespace method -} // namespace stats -} // namespace mir +} // namespace mir::stats::method diff -Nru metview-5.17.4/mir/src/mir/stats/method/MethodT.h metview-5.19.2/mir/src/mir/stats/method/MethodT.h --- metview-5.17.4/mir/src/mir/stats/method/MethodT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/method/MethodT.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,16 +19,12 @@ #include "mir/stats/detail/Counter.h" -namespace mir { -namespace data { +namespace mir::data { class MIRField; -} -} // namespace mir +} // namespace mir::data -namespace mir { -namespace stats { -namespace method { +namespace mir::stats::method { /// Generic statistics on a MIRField @@ -101,6 +97,4 @@ }; -} // namespace method -} // namespace stats -} // namespace mir +} // namespace mir::stats::method diff -Nru metview-5.17.4/mir/src/mir/stats/Method.cc metview-5.19.2/mir/src/mir/stats/Method.cc --- metview-5.17.4/mir/src/mir/stats/Method.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Method.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace stats { +namespace mir::stats { static util::recursive_mutex* local_mutex = nullptr; @@ -88,5 +87,4 @@ } -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/Method.h metview-5.19.2/mir/src/mir/stats/Method.h --- metview-5.17.4/mir/src/mir/stats/Method.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Method.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ } // namespace mir -namespace mir { -namespace stats { +namespace mir::stats { class Method { @@ -118,7 +117,7 @@ std::string name_; virtual Method* make(const param::MIRParametrisation&) = 0; - MethodFactory(const MethodFactory&) = delete; + MethodFactory(const MethodFactory&) = delete; MethodFactory& operator=(const MethodFactory&) = delete; protected: @@ -141,5 +140,4 @@ }; -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/GridBoxIntegral.cc metview-5.19.2/mir/src/mir/stats/statistics/GridBoxIntegral.cc --- metview-5.17.4/mir/src/mir/stats/statistics/GridBoxIntegral.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/GridBoxIntegral.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/GridBox.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { GridBoxIntegral::GridBoxIntegral(const param::MIRParametrisation& parametrisation) : @@ -65,6 +63,4 @@ static const StatisticsBuilder __stats("grid-box-integral"); -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/GridBoxIntegral.h metview-5.19.2/mir/src/mir/stats/statistics/GridBoxIntegral.h --- metview-5.17.4/mir/src/mir/stats/statistics/GridBoxIntegral.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/GridBoxIntegral.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/stats/detail/Counter.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { class GridBoxIntegral : public Statistics, detail::Counter { @@ -78,6 +76,4 @@ }; -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/Integral.cc metview-5.19.2/mir/src/mir/stats/statistics/Integral.cc --- metview-5.17.4/mir/src/mir/stats/statistics/Integral.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/Integral.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { Integral::Integral(const param::MIRParametrisation& parametrisation) : @@ -88,6 +86,4 @@ static const StatisticsBuilder __stats("integral"); -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/Integral.h metview-5.19.2/mir/src/mir/stats/statistics/Integral.h --- metview-5.17.4/mir/src/mir/stats/statistics/Integral.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/Integral.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,9 +17,7 @@ #include "mir/stats/detail/Counter.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { class Integral : public Statistics, detail::Counter { @@ -79,6 +77,4 @@ }; -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/SimplePackingEntropy.cc metview-5.19.2/mir/src/mir/stats/statistics/SimplePackingEntropy.cc --- metview-5.17.4/mir/src/mir/stats/statistics/SimplePackingEntropy.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/SimplePackingEntropy.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { SimplePackingEntropy::SimplePackingEntropy(const param::MIRParametrisation& parametrisation) : @@ -120,6 +118,4 @@ static const StatisticsBuilder __stats("simple-packing-entropy"); -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/SimplePackingEntropy.h metview-5.19.2/mir/src/mir/stats/statistics/SimplePackingEntropy.h --- metview-5.17.4/mir/src/mir/stats/statistics/SimplePackingEntropy.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/SimplePackingEntropy.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/stats/detail/Counter.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { /** @@ -84,6 +82,4 @@ }; -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/Spectral.cc metview-5.19.2/mir/src/mir/stats/statistics/Spectral.cc --- metview-5.17.4/mir/src/mir/stats/statistics/Spectral.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/Spectral.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { Spectral::Spectral(const param::MIRParametrisation& parametrisation) : Statistics(parametrisation) { @@ -68,7 +66,7 @@ ASSERT(!field.hasMissing()); const MIRValuesVector& values = field.values(0); - ASSERT(values.size()); + ASSERT(!values.empty()); // set truncation // Note: assumes triangular truncation (from GribInput.cc) @@ -109,6 +107,4 @@ static const StatisticsBuilder __stats("spectral"); -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/Spectral.h metview-5.19.2/mir/src/mir/stats/statistics/Spectral.h --- metview-5.17.4/mir/src/mir/stats/statistics/Spectral.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/Spectral.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,9 +15,7 @@ #include "mir/stats/Statistics.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { /** @@ -86,6 +84,4 @@ }; -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/StatisticsT.cc metview-5.19.2/mir/src/mir/stats/statistics/StatisticsT.cc --- metview-5.17.4/mir/src/mir/stats/statistics/StatisticsT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/StatisticsT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/stats/detail/ScalarT.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { struct MinMax {}; @@ -63,6 +61,4 @@ static const StatisticsBuilder> __stats8("min-max"); -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/statistics/StatisticsT.h metview-5.19.2/mir/src/mir/stats/statistics/StatisticsT.h --- metview-5.17.4/mir/src/mir/stats/statistics/StatisticsT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/statistics/StatisticsT.h 2023-07-15 08:28:47.000000000 +0000 @@ -20,9 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace stats { -namespace statistics { +namespace mir::stats::statistics { /// Generic statistics on a MIRField @@ -97,6 +95,4 @@ }; -} // namespace statistics -} // namespace stats -} // namespace mir +} // namespace mir::stats::statistics diff -Nru metview-5.17.4/mir/src/mir/stats/Statistics.cc metview-5.19.2/mir/src/mir/stats/Statistics.cc --- metview-5.17.4/mir/src/mir/stats/Statistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Statistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace stats { +namespace mir::stats { static util::recursive_mutex* local_mutex = nullptr; @@ -88,5 +87,4 @@ } -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/stats/Statistics.h metview-5.19.2/mir/src/mir/stats/Statistics.h --- metview-5.17.4/mir/src/mir/stats/Statistics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/stats/Statistics.h 2023-07-15 08:28:47.000000000 +0000 @@ -26,8 +26,7 @@ } // namespace mir -namespace mir { -namespace stats { +namespace mir::stats { class Statistics { @@ -113,7 +112,7 @@ std::string name_; virtual Statistics* make(const param::MIRParametrisation&) = 0; - StatisticsFactory(const StatisticsFactory&) = delete; + StatisticsFactory(const StatisticsFactory&) = delete; StatisticsFactory& operator=(const StatisticsFactory&) = delete; protected: @@ -136,5 +135,4 @@ }; -} // namespace stats -} // namespace mir +} // namespace mir::stats diff -Nru metview-5.17.4/mir/src/mir/tools/Count.cc metview-5.19.2/mir/src/mir/tools/Count.cc --- metview-5.17.4/mir/src/mir/tools/Count.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/tools/Count.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { template @@ -209,5 +208,4 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools diff -Nru metview-5.17.4/mir/src/mir/tools/Count.h metview-5.19.2/mir/src/mir/tools/Count.h --- metview-5.17.4/mir/src/mir/tools/Count.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/tools/Count.h 2023-07-15 08:28:47.000000000 +0000 @@ -24,15 +24,12 @@ class JSON; } -namespace mir { -namespace repres { +namespace mir::repres { class Representation; -} -} // namespace mir +} // namespace mir::repres -namespace mir { -namespace tools { +namespace mir::tools { class Count { @@ -119,5 +116,4 @@ }; -} // namespace tools -} // namespace mir +} // namespace mir::tools diff -Nru metview-5.17.4/mir/src/mir/tools/MIRTool.cc metview-5.19.2/mir/src/mir/tools/MIRTool.cc --- metview-5.17.4/mir/src/mir/tools/MIRTool.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/tools/MIRTool.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,8 +24,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tools { +namespace mir::tools { static MIRTool* instance_ = nullptr; @@ -76,5 +75,4 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools diff -Nru metview-5.17.4/mir/src/mir/tools/MIRTool.h metview-5.19.2/mir/src/mir/tools/MIRTool.h --- metview-5.17.4/mir/src/mir/tools/MIRTool.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/tools/MIRTool.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,16 +17,13 @@ #include "eckit/runtime/Tool.h" -namespace eckit { -namespace option { +namespace eckit::option { class CmdArgs; class Option; -} // namespace option -} // namespace eckit +} // namespace eckit::option -namespace mir { -namespace tools { +namespace mir::tools { class MIRTool : public eckit::Tool { @@ -54,5 +51,4 @@ }; -} // namespace tools -} // namespace mir +} // namespace mir::tools diff -Nru metview-5.17.4/mir/src/mir/util/Angles.h metview-5.19.2/mir/src/mir/util/Angles.h --- metview-5.17.4/mir/src/mir/util/Angles.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Angles.h 2023-07-15 08:28:47.000000000 +0000 @@ -14,11 +14,10 @@ #include -#include "mir/util/Types.h" +#include "mir/util/LongitudeDouble.h" -namespace mir { -namespace util { +namespace mir::util { /// @return degree to radian (no range check) @@ -35,9 +34,8 @@ /// @return longitude in degree within range [minimum, minimum + 360[ inline double normalise_longitude(const double& lon, const double& minimum) { - return Longitude(lon).normalise(minimum).value(); + return LongitudeDouble(lon).normalise(minimum).value(); } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/AreaCropperMapping.h metview-5.19.2/mir/src/mir/util/AreaCropperMapping.h --- metview-5.17.4/mir/src/mir/util/AreaCropperMapping.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/AreaCropperMapping.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,12 +15,10 @@ #include -namespace mir { -namespace util { +namespace mir::util { using AreaCropperMapping = std::vector; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Atlas.h metview-5.19.2/mir/src/mir/util/Atlas.h --- metview-5.17.4/mir/src/mir/util/Atlas.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Atlas.h 2023-07-15 08:28:47.000000000 +0000 @@ -285,12 +285,10 @@ #endif -namespace mir { -namespace util { +namespace mir::util { using atlas::util::Earth; -} -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Bitmap.cc metview-5.19.2/mir/src/mir/util/Bitmap.cc --- metview-5.17.4/mir/src/mir/util/Bitmap.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Bitmap.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ // TODO: Cache bitmaps -namespace mir { -namespace util { +namespace mir::util { static void out(std::vector >& bitmap, long row, const std::string& line, bool on, long& prev) { @@ -270,5 +269,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Bitmap.h metview-5.19.2/mir/src/mir/util/Bitmap.h --- metview-5.17.4/mir/src/mir/util/Bitmap.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Bitmap.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include -namespace mir { -namespace util { +namespace mir::util { class Bitmap { @@ -108,5 +107,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/BoundingBox.cc metview-5.19.2/mir/src/mir/util/BoundingBox.cc --- metview-5.17.4/mir/src/mir/util/BoundingBox.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/BoundingBox.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,7 +16,6 @@ #include #include "eckit/types/FloatCompare.h" -#include "eckit/types/Fraction.h" #include "eckit/utils/MD5.h" #include "mir/api/MIRJob.h" @@ -25,17 +24,13 @@ #include "mir/util/Grib.h" -namespace mir { -namespace util { +namespace mir::util { -static void check(const BoundingBox& bbox) { - ASSERT(bbox.north() >= bbox.south()); - ASSERT(bbox.north() <= Latitude::NORTH_POLE); - ASSERT(bbox.south() >= Latitude::SOUTH_POLE); - - ASSERT(bbox.east() - bbox.west() >= 0); - ASSERT(bbox.east() - bbox.west() <= Longitude::GLOBE); +static double get(const param::MIRParametrisation& param, const char* key) { + double value = 0.; + ASSERT(param.get(key, value)); + return value; } @@ -45,46 +40,24 @@ BoundingBox::BoundingBox(const Latitude& north, const Longitude& west, const Latitude& south, const Longitude& east) : north_(north), west_(west), south_(south), east_(east) { - normalise(); - check(*this); -} - - -BoundingBox::BoundingBox(const param::MIRParametrisation& param) { - - double box[4]; - ASSERT(param.get("north", box[0])); - ASSERT(param.get("west", box[1])); - ASSERT(param.get("south", box[2])); - ASSERT(param.get("east", box[3])); - - double angularPrecision = 0.; - param.get("angular_precision", angularPrecision); - - if (angularPrecision > 0.) { - - const eckit::Fraction precision(angularPrecision); - north_ = eckit::Fraction(box[0], precision); - west_ = eckit::Fraction(box[1], precision); - south_ = eckit::Fraction(box[2], precision); - east_ = eckit::Fraction(box[3], precision); - } - else { - - north_ = box[0]; - west_ = box[1]; - south_ = box[2]; - east_ = box[3]; + if (west_ != east_) { + auto eastNormalised = east_.normalise(west_); + if (eastNormalised == west_) { + eastNormalised += Longitude::GLOBE; + } + east_ = eastNormalised; } - normalise(); - check(*this); + ASSERT(west_ <= east_ && east_ <= west_ + Longitude::GLOBE); + ASSERT(Latitude::SOUTH_POLE <= south_ && south_ <= north_ && north_ <= Latitude::NORTH_POLE); } -BoundingBox::BoundingBox(const BoundingBox& other) { - operator=(other); -} +BoundingBox::BoundingBox(const param::MIRParametrisation& param) : + BoundingBox(get(param, "north"), get(param, "west"), get(param, "south"), get(param, "east")) {} + + +BoundingBox::BoundingBox(const BoundingBox&) = default; bool BoundingBox::operator==(const BoundingBox& other) const { @@ -111,10 +84,7 @@ info.grid.latitudeOfLastGridPointInDegrees = south_.value(); info.grid.longitudeOfLastGridPointInDegrees = east_.value(); - const long c = info.packing.extra_settings_count++; - info.packing.extra_settings[c].type = CODES_TYPE_LONG; - info.packing.extra_settings[c].name = "expandBoundingBox"; - info.packing.extra_settings[c].long_value = 1; + info.extra_set("expandBoundingBox", 1L); } @@ -136,20 +106,6 @@ } -void BoundingBox::normalise() { - if (west_ != east_) { - Longitude eastNormalised = east_.normalise(west_); - if (eastNormalised == west_) { - eastNormalised += Longitude::GLOBE; - } - east_ = eastNormalised; - } - - ASSERT(west_ <= east_); - ASSERT(east_ <= west_ + Longitude::GLOBE); -} - - bool BoundingBox::contains(const PointLatLon& p) const { return contains(p.lat(), p.lon()); } @@ -241,5 +197,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/BoundingBox.h metview-5.19.2/mir/src/mir/util/BoundingBox.h --- metview-5.17.4/mir/src/mir/util/BoundingBox.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/BoundingBox.h 2023-07-15 08:28:47.000000000 +0000 @@ -31,8 +31,7 @@ } // namespace mir -namespace mir { -namespace util { +namespace mir::util { class BoundingBox { @@ -134,8 +133,7 @@ Longitude east_; // -- Methods - - void normalise(); + // None // -- Overridden methods // None @@ -155,5 +153,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/CheckDuplicatePoints.cc metview-5.19.2/mir/src/mir/util/CheckDuplicatePoints.cc --- metview-5.17.4/mir/src/mir/util/CheckDuplicatePoints.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/CheckDuplicatePoints.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace util { +namespace mir::util { void check_duplicate_points(const std::string& title, const std::vector& latitudes, @@ -63,5 +62,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/CheckDuplicatePoints.h metview-5.19.2/mir/src/mir/util/CheckDuplicatePoints.h --- metview-5.17.4/mir/src/mir/util/CheckDuplicatePoints.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/CheckDuplicatePoints.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace util { +namespace mir::util { void check_duplicate_points(const std::string& title, const std::vector& latitudes, @@ -35,5 +32,4 @@ const std::vector& longitudes, const param::MIRParametrisation&); -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/DeprecatedFunctionality.cc metview-5.19.2/mir/src/mir/util/DeprecatedFunctionality.cc --- metview-5.17.4/mir/src/mir/util/DeprecatedFunctionality.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/DeprecatedFunctionality.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "eckit/utils/MD5.h" -namespace mir { -namespace util { +namespace mir::util { static std::set known_messages; @@ -39,5 +38,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/DeprecatedFunctionality.h metview-5.19.2/mir/src/mir/util/DeprecatedFunctionality.h --- metview-5.17.4/mir/src/mir/util/DeprecatedFunctionality.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/DeprecatedFunctionality.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace util { +namespace mir::util { struct DeprecatedFunctionality { @@ -29,5 +28,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Domain.cc metview-5.19.2/mir/src/mir/util/Domain.cc --- metview-5.17.4/mir/src/mir/util/Domain.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Domain.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace util { +namespace mir::util { bool Domain::includesPoleNorth() const { @@ -41,5 +40,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Domain.h metview-5.19.2/mir/src/mir/util/Domain.h --- metview-5.17.4/mir/src/mir/util/Domain.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Domain.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace util { +namespace mir::util { class Domain : public BoundingBox { @@ -102,5 +101,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Error.cc metview-5.19.2/mir/src/mir/util/Error.cc --- metview-5.17.4/mir/src/mir/util/Error.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Error.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include -namespace mir { -namespace util { +namespace mir::util { void Error::print(std::ostream& s) const { @@ -29,5 +28,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Error.h metview-5.19.2/mir/src/mir/util/Error.h --- metview-5.17.4/mir/src/mir/util/Error.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Error.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace util { +namespace mir::util { class Error { @@ -28,5 +27,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Exceptions.h metview-5.19.2/mir/src/mir/util/Exceptions.h --- metview-5.17.4/mir/src/mir/util/Exceptions.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Exceptions.h 2023-07-15 08:28:47.000000000 +0000 @@ -32,13 +32,13 @@ #define ASSERT_NONEMPTY_AREA_CROP(m, nonempty) ASSERT_MSG((nonempty), m ": non-empty area crop (to at least one point)") -namespace mir { -namespace exception { +namespace mir::exception { using eckit::BadValue; using eckit::CantOpenFile; using eckit::FailedSystemCall; +using eckit::FunctionalityNotSupported; using eckit::SeriousBug; using eckit::UserError; using eckit::WriteError; @@ -55,5 +55,4 @@ }; -} // namespace exception -} // namespace mir +} // namespace mir::exception diff -Nru metview-5.17.4/mir/src/mir/util/FormulaBinop.cc metview-5.19.2/mir/src/mir/util/FormulaBinop.cc --- metview-5.17.4/mir/src/mir/util/FormulaBinop.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaBinop.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/MIRStatistics.h" -namespace mir { -namespace util { +namespace mir::util { FormulaBinop::FormulaBinop(const param::MIRParametrisation& parametrisation, const std::string& name, Formula* arg1, @@ -409,5 +408,4 @@ static const Binop _pow_2("pow"); -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaBinop.h metview-5.19.2/mir/src/mir/util/FormulaBinop.h --- metview-5.17.4/mir/src/mir/util/FormulaBinop.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaBinop.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/FormulaFunction.h" -namespace mir { -namespace util { +namespace mir::util { class FormulaBinop : public FormulaFunction { @@ -33,5 +32,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Formula.cc metview-5.19.2/mir/src/mir/util/Formula.cc --- metview-5.17.4/mir/src/mir/util/Formula.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Formula.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,12 +13,10 @@ #include "mir/util/Formula.h" -namespace mir { -namespace util { +namespace mir::util { Formula::~Formula() = default; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaFunction.cc metview-5.19.2/mir/src/mir/util/FormulaFunction.cc --- metview-5.17.4/mir/src/mir/util/FormulaFunction.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaFunction.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/Function.h" -namespace mir { -namespace util { +namespace mir::util { FormulaFunction::FormulaFunction(const param::MIRParametrisation& parametrisation, const std::string& name, @@ -89,5 +88,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaFunction.h metview-5.19.2/mir/src/mir/util/FormulaFunction.h --- metview-5.17.4/mir/src/mir/util/FormulaFunction.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaFunction.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,15 +18,12 @@ #include "mir/util/Formula.h" -namespace mir { -namespace util { +namespace mir::util { class Function; -} -} // namespace mir +} // namespace mir::util -namespace mir { -namespace util { +namespace mir::util { class FormulaFunction : public Formula { public: @@ -52,5 +49,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Formula.h metview-5.19.2/mir/src/mir/util/Formula.h --- metview-5.17.4/mir/src/mir/util/Formula.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Formula.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/action/plan/Action.h" -namespace mir { -namespace util { +namespace mir::util { class Formula : public action::Action { @@ -36,5 +35,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaIdent.cc metview-5.19.2/mir/src/mir/util/FormulaIdent.cc --- metview-5.17.4/mir/src/mir/util/FormulaIdent.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaIdent.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,10 +17,10 @@ #include "mir/action/context/Context.h" #include "mir/util/Exceptions.h" +#include "mir/util/Regex.h" -namespace mir { -namespace util { +namespace mir::util { FormulaIdent::FormulaIdent(const param::MIRParametrisation& parametrisation, const std::string& name) : @@ -36,22 +36,24 @@ void FormulaIdent::execute(context::Context& ctx) const { - // TODO: something better... - if (name_ == "f1") { - ctx.select(0); - return; - } + const auto match = Regex::match("f([0-9]+)", name_); + if (match) { + ASSERT(match.size() == 2); + + size_t which = 0; + std::istringstream iss(match[1]); + iss >> which; + ASSERT(which > 0); - if (name_ == "f2") { - ctx.select(1); + ctx.select(which - 1); return; } if (name_ != "f") { std::ostringstream oss; - oss << "Only variable 'f' is supported (" << name_ << ")"; + oss << "Only variables 'f', 'f1' (same as 'f'), 'f2', 'f3'... are supported (" << name_ << ")"; throw exception::UserError(oss.str()); } @@ -71,5 +73,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaIdent.h metview-5.19.2/mir/src/mir/util/FormulaIdent.h --- metview-5.17.4/mir/src/mir/util/FormulaIdent.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaIdent.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Formula.h" -namespace mir { -namespace util { +namespace mir::util { class FormulaIdent : public Formula { @@ -37,5 +36,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaNumber.cc metview-5.19.2/mir/src/mir/util/FormulaNumber.cc --- metview-5.17.4/mir/src/mir/util/FormulaNumber.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaNumber.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/action/context/Context.h" -namespace mir { -namespace util { +namespace mir::util { FormulaNumber::FormulaNumber(const param::MIRParametrisation& parametrisation, double value) : @@ -46,5 +45,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaNumber.h metview-5.19.2/mir/src/mir/util/FormulaNumber.h --- metview-5.17.4/mir/src/mir/util/FormulaNumber.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaNumber.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/util/Formula.h" -namespace mir { -namespace util { +namespace mir::util { class FormulaNumber : public Formula { @@ -35,5 +34,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaParser.cc metview-5.19.2/mir/src/mir/util/FormulaParser.cc --- metview-5.17.4/mir/src/mir/util/FormulaParser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaParser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #include "mir/util/FormulaString.h" -namespace mir { -namespace util { +namespace mir::util { FormulaParser::FormulaParser(std::istream& in) : StreamParser(in, true) {} @@ -246,5 +245,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaParser.h metview-5.19.2/mir/src/mir/util/FormulaParser.h --- metview-5.17.4/mir/src/mir/util/FormulaParser.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaParser.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ } // namespace mir -namespace mir { -namespace util { +namespace mir::util { class FormulaParser : public eckit::StreamParser { public: // methods @@ -49,5 +48,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaString.cc metview-5.19.2/mir/src/mir/util/FormulaString.cc --- metview-5.17.4/mir/src/mir/util/FormulaString.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaString.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace util { +namespace mir::util { FormulaString::FormulaString(const param::MIRParametrisation& parametrisation, const std::string& value) : @@ -49,5 +48,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/FormulaString.h metview-5.19.2/mir/src/mir/util/FormulaString.h --- metview-5.17.4/mir/src/mir/util/FormulaString.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/FormulaString.h 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Formula.h" -namespace mir { -namespace util { +namespace mir::util { class FormulaString : public Formula { @@ -37,5 +36,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Function.cc metview-5.19.2/mir/src/mir/util/Function.cc --- metview-5.17.4/mir/src/mir/util/Function.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Function.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace util { +namespace mir::util { static recursive_mutex* local_mutex = nullptr; @@ -75,5 +74,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Function.h metview-5.19.2/mir/src/mir/util/Function.h --- metview-5.17.4/mir/src/mir/util/Function.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Function.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,22 +16,19 @@ #include -namespace mir { -namespace context { +namespace mir::context { class Context; -} -} // namespace mir +} // namespace mir::context -namespace mir { -namespace util { +namespace mir::util { class Function { public: Function(const std::string&); - Function(const Function&) = delete; + Function(const Function&) = delete; void operator=(const Function&) = delete; virtual ~Function(); @@ -56,5 +53,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/GlobaliseUnstructured.cc metview-5.19.2/mir/src/mir/util/GlobaliseUnstructured.cc --- metview-5.17.4/mir/src/mir/util/GlobaliseUnstructured.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/GlobaliseUnstructured.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace util { +namespace mir::util { GlobaliseUnstructured::GlobaliseUnstructured(const param::MIRParametrisation& parametrisation) : @@ -78,5 +77,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/GlobaliseUnstructured.h metview-5.19.2/mir/src/mir/util/GlobaliseUnstructured.h --- metview-5.17.4/mir/src/mir/util/GlobaliseUnstructured.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/GlobaliseUnstructured.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace util { +namespace mir::util { class GlobaliseUnstructured { @@ -50,5 +47,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Grib.cc metview-5.19.2/mir/src/mir/util/Grib.cc --- metview-5.17.4/mir/src/mir/util/Grib.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Grib.cc 2023-07-15 08:28:47.000000000 +0000 @@ -10,11 +10,13 @@ */ +#include "mir/util/Grib.h" + #include #include -#include +#include +#include -#include "mir/util/Grib.h" #include "mir/util/Log.h" diff -Nru metview-5.17.4/mir/src/mir/util/Grib.h metview-5.19.2/mir/src/mir/util/Grib.h --- metview-5.17.4/mir/src/mir/util/Grib.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Grib.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,7 +22,7 @@ inline bool grib_call(int e, const char* call, bool missingOK = false) { - if (e) { + if (static_cast(e)) { if (missingOK && (e == CODES_NOT_FOUND)) { return false; } @@ -51,7 +51,7 @@ codes_util_packing_spec packing; private: - grib_info(const grib_info&) = delete; + grib_info(const grib_info&) = delete; void operator=(const grib_info&) = delete; std::vector strings_; @@ -64,7 +64,7 @@ public: HandleDeleter(grib_handle* h) : h_(h) { ASSERT(h); } - HandleDeleter(const HandleDeleter&) = delete; + HandleDeleter(const HandleDeleter&) = delete; void operator=(const HandleDeleter&) = delete; ~HandleDeleter() { codes_handle_delete(h_); } }; @@ -76,7 +76,7 @@ public: GKeyIteratorDeleter(codes_keys_iterator* h) : h_(h) {} GKeyIteratorDeleter(const GKeyIteratorDeleter&) = delete; - void operator=(const GKeyIteratorDeleter&) = delete; + void operator=(const GKeyIteratorDeleter&) = delete; ~GKeyIteratorDeleter() { codes_keys_iterator_delete(h_); } }; @@ -87,7 +87,7 @@ public: BKeyIteratorDeleter(codes_bufr_keys_iterator* h) : h_(h) {} BKeyIteratorDeleter(const BKeyIteratorDeleter&) = delete; - void operator=(const BKeyIteratorDeleter&) = delete; + void operator=(const BKeyIteratorDeleter&) = delete; ~BKeyIteratorDeleter() { codes_bufr_keys_iterator_delete(h_); } }; diff -Nru metview-5.17.4/mir/src/mir/util/GridBox.cc metview-5.19.2/mir/src/mir/util/GridBox.cc --- metview-5.17.4/mir/src/mir/util/GridBox.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/GridBox.cc 2023-07-15 08:28:47.000000000 +0000 @@ -37,8 +37,7 @@ } -namespace mir { -namespace util { +namespace mir::util { GridBox::GridBox(double north, double west, double south, double east) : @@ -97,5 +96,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/GridBox.h metview-5.19.2/mir/src/mir/util/GridBox.h --- metview-5.17.4/mir/src/mir/util/GridBox.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/GridBox.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace util { +namespace mir::util { class GridBox { @@ -43,6 +42,11 @@ double diagonal() const; bool intersects(GridBox&) const; + double north() const { return north_; } + double west() const { return west_; } + double south() const { return south_; } + double east() const { return east_; } + // -- Overridden methods // None @@ -101,5 +105,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Increments.cc metview-5.19.2/mir/src/mir/util/Increments.cc --- metview-5.17.4/mir/src/mir/util/Increments.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Increments.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,8 +23,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace util { +namespace mir::util { static void check(const Increments& inc) { @@ -144,5 +143,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Increments.h metview-5.19.2/mir/src/mir/util/Increments.h --- metview-5.17.4/mir/src/mir/util/Increments.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Increments.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,15 +27,12 @@ class MIRJob; } } // namespace mir -namespace mir { -namespace util { +namespace mir::util { class BoundingBox; -} -} // namespace mir +} // namespace mir::util -namespace mir { -namespace util { +namespace mir::util { class Increments { @@ -141,5 +138,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/MeshGeneratorParameters.cc metview-5.19.2/mir/src/mir/util/MeshGeneratorParameters.cc --- metview-5.17.4/mir/src/mir/util/MeshGeneratorParameters.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/MeshGeneratorParameters.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Exceptions.h" -namespace mir { -namespace util { +namespace mir::util { MeshGeneratorParameters::MeshGeneratorParameters() { meshCellCentres_ = false; @@ -97,5 +96,4 @@ s << "]"; } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/MeshGeneratorParameters.h metview-5.19.2/mir/src/mir/util/MeshGeneratorParameters.h --- metview-5.17.4/mir/src/mir/util/MeshGeneratorParameters.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/MeshGeneratorParameters.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,15 +18,12 @@ #include "mir/util/Atlas.h" -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} // namespace param -} // namespace mir +} // namespace mir::param -namespace mir { -namespace util { +namespace mir::util { class MeshGeneratorParameters : public atlas::MeshGenerator::Parameters { @@ -121,5 +118,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/MIRStatistics.cc metview-5.19.2/mir/src/mir/util/MIRStatistics.cc --- metview-5.17.4/mir/src/mir/util/MIRStatistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/MIRStatistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "eckit/serialisation/Stream.h" -namespace mir { -namespace util { +namespace mir::util { static const std::vector all_caches{"mirBitmap", "mirArea", "mirCoefficient", "mirMatrix", "mirMesh"}; @@ -155,5 +154,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/MIRStatistics.h metview-5.19.2/mir/src/mir/util/MIRStatistics.h --- metview-5.17.4/mir/src/mir/util/MIRStatistics.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/MIRStatistics.h 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ } // namespace eckit -namespace mir { -namespace util { +namespace mir::util { class MIRStatistics : public eckit::Statistics { @@ -150,5 +149,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Mutex.h metview-5.19.2/mir/src/mir/util/Mutex.h --- metview-5.17.4/mir/src/mir/util/Mutex.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Mutex.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ #endif -namespace mir { -namespace util { +namespace mir::util { #if defined(mir_ECKIT_THREADS) @@ -56,5 +55,4 @@ #endif -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/PlanParser.cc metview-5.19.2/mir/src/mir/util/PlanParser.cc --- metview-5.17.4/mir/src/mir/util/PlanParser.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/PlanParser.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include "mir/key/style/CustomParametrisation.h" -namespace mir { -namespace util { +namespace mir::util { PlanParser::PlanParser(std::istream& in) : StreamParser(in, true) {} @@ -119,5 +118,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/PlanParser.h metview-5.19.2/mir/src/mir/util/PlanParser.h --- metview-5.17.4/mir/src/mir/util/PlanParser.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/PlanParser.h 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,7 @@ } // namespace mir -namespace mir { -namespace util { +namespace mir::util { class PlanParser : public eckit::StreamParser { @@ -48,5 +47,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/PointLatLonT.h metview-5.19.2/mir/src/mir/util/PointLatLonT.h --- metview-5.17.4/mir/src/mir/util/PointLatLonT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/PointLatLonT.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include -namespace mir { -namespace util { +namespace mir::util { template @@ -50,5 +49,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Regex.cc metview-5.19.2/mir/src/mir/util/Regex.cc --- metview-5.17.4/mir/src/mir/util/Regex.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Regex.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace util { +namespace mir::util { static const std::map regex_code{ @@ -61,5 +60,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Regex.h metview-5.19.2/mir/src/mir/util/Regex.h --- metview-5.17.4/mir/src/mir/util/Regex.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Regex.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include -namespace mir { -namespace util { +namespace mir::util { class Regex { @@ -110,5 +109,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Rotation.cc metview-5.19.2/mir/src/mir/util/Rotation.cc --- metview-5.17.4/mir/src/mir/util/Rotation.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Rotation.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/Grib.h" -namespace mir { -namespace util { +namespace mir::util { Rotation::Rotation(const Latitude& south_pole_latitude, const Longitude& south_pole_longitude, @@ -79,10 +78,7 @@ // This is missing from the grib_spec // Remove that when supported if (!eckit::types::is_approximately_equal(south_pole_rotation_angle_, 0.)) { - long j = info.packing.extra_settings_count++; - info.packing.extra_settings[j].name = "angleOfRotationInDegrees"; - info.packing.extra_settings[j].type = CODES_TYPE_DOUBLE; - info.packing.extra_settings[j].double_value = south_pole_rotation_angle_; + info.extra_set("angleOfRotationInDegrees", south_pole_rotation_angle_); } } @@ -144,5 +140,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Rotation.h metview-5.19.2/mir/src/mir/util/Rotation.h --- metview-5.17.4/mir/src/mir/util/Rotation.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Rotation.h 2023-07-15 08:28:47.000000000 +0000 @@ -36,8 +36,7 @@ } // namespace mir -namespace mir { -namespace util { +namespace mir::util { /** @@ -158,5 +157,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Shape.cc metview-5.19.2/mir/src/mir/util/Shape.cc --- metview-5.17.4/mir/src/mir/util/Shape.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Shape.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/param/MIRParametrisation.h" -namespace mir { -namespace util { +namespace mir::util { Shape::Shape(const param::MIRParametrisation& param) { @@ -87,5 +86,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Shape.h metview-5.19.2/mir/src/mir/util/Shape.h --- metview-5.17.4/mir/src/mir/util/Shape.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Shape.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,15 +16,12 @@ #include "mir/util/Grib.h" -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace util { +namespace mir::util { struct Shape { @@ -46,5 +43,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/SpectralOrder.cc metview-5.19.2/mir/src/mir/util/SpectralOrder.cc --- metview-5.17.4/mir/src/mir/util/SpectralOrder.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/SpectralOrder.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace util { +namespace mir::util { long SpectralOrder::getTruncationFromGaussianNumber(long /*unused*/) const { @@ -95,5 +94,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/SpectralOrder.h metview-5.19.2/mir/src/mir/util/SpectralOrder.h --- metview-5.17.4/mir/src/mir/util/SpectralOrder.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/SpectralOrder.h 2023-07-15 08:28:47.000000000 +0000 @@ -16,8 +16,7 @@ #include -namespace mir { -namespace util { +namespace mir::util { class SpectralOrder { @@ -101,7 +100,7 @@ std::string name_; virtual SpectralOrder* make() = 0; - SpectralOrderFactory(const SpectralOrderFactory&) = delete; + SpectralOrderFactory(const SpectralOrderFactory&) = delete; SpectralOrderFactory& operator=(const SpectralOrderFactory&) = delete; protected: @@ -123,5 +122,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/SpectralOrderT.cc metview-5.19.2/mir/src/mir/util/SpectralOrderT.cc --- metview-5.17.4/mir/src/mir/util/SpectralOrderT.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/SpectralOrderT.cc 2023-07-15 08:28:47.000000000 +0000 @@ -13,8 +13,7 @@ #include "mir/util/SpectralOrderT.h" -namespace mir { -namespace util { +namespace mir::util { static const SpectralOrderBuilder > __order1("linear"); @@ -41,5 +40,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/SpectralOrderT.h metview-5.19.2/mir/src/mir/util/SpectralOrderT.h --- metview-5.17.4/mir/src/mir/util/SpectralOrderT.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/SpectralOrderT.h 2023-07-15 08:28:47.000000000 +0000 @@ -18,8 +18,7 @@ #include "mir/util/SpectralOrder.h" -namespace mir { -namespace util { +namespace mir::util { template @@ -107,5 +106,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Trace.cc metview-5.19.2/mir/src/mir/util/Trace.cc --- metview-5.17.4/mir/src/mir/util/Trace.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Trace.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/config/LibMir.h" -namespace mir { -namespace trace { +namespace mir::trace { Timer::Timer(const std::string& name) : eckit::Timer(name, Log::debug()) {} @@ -63,5 +62,4 @@ } -} // namespace trace -} // namespace mir +} // namespace mir::trace diff -Nru metview-5.17.4/mir/src/mir/util/Trace.h metview-5.19.2/mir/src/mir/util/Trace.h --- metview-5.17.4/mir/src/mir/util/Trace.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Trace.h 2023-07-15 08:28:47.000000000 +0000 @@ -22,8 +22,7 @@ } -namespace mir { -namespace trace { +namespace mir::trace { class Timer : public eckit::Timer { @@ -41,7 +40,7 @@ ~ResourceUsage(); private: - ResourceUsage(const ResourceUsage&) = delete; + ResourceUsage(const ResourceUsage&) = delete; ResourceUsage& operator=(const ResourceUsage&) = delete; eckit::ResourceUsage* info_; @@ -69,5 +68,4 @@ }; -} // namespace trace -} // namespace mir +} // namespace mir::trace diff -Nru metview-5.17.4/mir/src/mir/util/ValueMap.cc metview-5.19.2/mir/src/mir/util/ValueMap.cc --- metview-5.17.4/mir/src/mir/util/ValueMap.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/ValueMap.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/param/SimpleParametrisation.h" -namespace mir { -namespace util { +namespace mir::util { ValueMap::ValueMap(const eckit::Value& value) : eckit::ValueMap(value) {} @@ -44,5 +43,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/ValueMap.h metview-5.19.2/mir/src/mir/util/ValueMap.h --- metview-5.17.4/mir/src/mir/util/ValueMap.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/ValueMap.h 2023-07-15 08:28:47.000000000 +0000 @@ -19,15 +19,12 @@ class Configured; } // namespace eckit -namespace mir { -namespace param { +namespace mir::param { class SimpleParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace util { +namespace mir::util { class ValueMap : public eckit::ValueMap { @@ -42,5 +39,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Wind.cc metview-5.19.2/mir/src/mir/util/Wind.cc --- metview-5.17.4/mir/src/mir/util/Wind.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Wind.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace util { +namespace mir::util { constexpr long PARAMETER_ID_U = 131; @@ -74,5 +73,4 @@ } -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/mir/util/Wind.h metview-5.19.2/mir/src/mir/util/Wind.h --- metview-5.17.4/mir/src/mir/util/Wind.h 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/mir/util/Wind.h 2023-07-15 08:28:47.000000000 +0000 @@ -15,15 +15,12 @@ #include -namespace mir { -namespace param { +namespace mir::param { class MIRParametrisation; -} -} // namespace mir +} // namespace mir::param -namespace mir { -namespace util { +namespace mir::util { class Wind { @@ -100,5 +97,4 @@ }; -} // namespace util -} // namespace mir +} // namespace mir::util diff -Nru metview-5.17.4/mir/src/sandbox/grids.cc metview-5.19.2/mir/src/sandbox/grids.cc --- metview-5.17.4/mir/src/sandbox/grids.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/sandbox/grids.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tools { +namespace mir::tools { struct Grids : eckit::Tool { @@ -33,7 +32,7 @@ void Grids::grid(const atlas::StructuredGrid& grid) { const auto& pl = grid.nx(); - ASSERT(pl.size()); + ASSERT(!pl.empty()); std::vector points_per_latitudes(pl.size()); ASSERT(pl.size() == points_per_latitudes.size()); @@ -72,8 +71,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/sandbox/lsm.cc metview-5.19.2/mir/src/sandbox/lsm.cc --- metview-5.17.4/mir/src/sandbox/lsm.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/sandbox/lsm.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace sandbox { +namespace mir::sandbox { struct LSM : eckit::Tool { @@ -94,8 +93,7 @@ } -} // namespace sandbox -} // namespace mir +} // namespace mir::sandbox int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/CMakeLists.txt metview-5.19.2/mir/src/tools/CMakeLists.txt --- metview-5.17.4/mir/src/tools/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -4,7 +4,9 @@ foreach(tool IN ITEMS mir-climate-filter mir-compare # NOTE: set in the testing scripts, however not used + mir-compute mir-config + mir-config-grib mir-count mir-formula mir-gaussian-fractions diff -Nru metview-5.17.4/mir/src/tools/mir.cc metview-5.19.2/mir/src/tools/mir.cc --- metview-5.17.4/mir/src/tools/mir.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,11 +27,12 @@ #include "mir/api/MIRJob.h" #include "mir/caching/matrix/MatrixLoader.h" #include "mir/data/Space.h" -#include "mir/input/MultiDimensionalGribFileInput.h" +#include "mir/grib/BasicAngle.h" +#include "mir/grib/Packing.h" +#include "mir/input/MIRInput.h" #include "mir/key/Area.h" #include "mir/key/grid/GridPattern.h" #include "mir/key/intgrid/Intgrid.h" -#include "mir/key/packing/Packing.h" #include "mir/key/style/MIRStyle.h" #include "mir/key/truncation/Truncation.h" #include "mir/lsm/LSMSelection.h" @@ -126,9 +127,8 @@ "L2 Projection FE method for output")); options_.push_back(new SimpleOption("finite-element-validate-mesh", "FE method check mesh quadrilaterals validity (default false)")); - options_.push_back( - new SimpleOption("finite-element-missing-value-on-projection-fail", - "FE method sets missing value when interpolation isn't possible (default true)")); + options_.push_back(new FactoryOption( + "finite-element-projection-fail", "FE method failed projection handling (default missing-value)")); #endif options_.push_back(new FactoryOption( @@ -256,10 +256,16 @@ options_.push_back(new SimpleOption("cesaro-k", "Cesàro summation k (default 2.)")); options_.push_back(new SimpleOption( "cesaro-truncation", "Cesàro summation filtering minimum truncation (1 <= Tmin < T, default 1)")); + options_.push_back(new VectorOption( + "bandpass", + "spectral bandpass filter on zonal/meridional minimum/maximum wave numbers (M min/M max/N min/N max)", 4)); //============================================== options_.push_back(new Separator("Compute")); - options_.push_back(new SimpleOption("formula", "Formula to apply on field")); + for (const std::string& when : {"prologue", "raw", "spectral", "gridded", "epilogue"}) { + options_.push_back(new SimpleOption("formula." + when, "Formula")); + options_.push_back(new SimpleOption("formula." + when + ".metadata", "Formula metadata")); + } //============================================== options_.push_back(new Separator("Land-sea mask handling")); @@ -296,12 +302,24 @@ //============================================== options_.push_back(new Separator("GRIB Output")); options_.push_back(new SimpleOption("accuracy", "Number of bits per value")); - options_.push_back(new FactoryOption("packing", "GRIB packing method")); + options_.push_back(new FactoryOption("packing", "GRIB packing method")); options_.push_back(new SimpleOption("edition", "GRIB edition number")); + options_.push_back(new SimpleOption( + "grib-packing-gridded", "GRIB default gridded packing, on gridded/spectral conversions")); + options_.push_back(new SimpleOption( + "grib-packing-spectral", "GRIB default spectral packing, on gridded/spectral conversions")); + options_.push_back( + new SimpleOption("grib-packing-always-set", "GRIB packing setting to default, unless overriden")); + options_.push_back( + new SimpleOption("grib-edition-conversion", "GRIB edition conversion on packing changes")); + options_.push_back(new SimpleOption("delete-local-definition", "Remove GRIB local extension")); + + options_.push_back(new FactoryOption( + "basic-angle", "GRIB basic angle and subdivisions (bounding box and grid increments, default false)")); options_.push_back( - new SimpleOption("metadata", "Set eccodes keys to integer values (a=b,c=d,..)")); + new SimpleOption("metadata", "GRIB extra metadata key/integer pairs (a=b,c=d,..)")); //============================================== options_.push_back(new Separator("Statistics")); @@ -367,9 +385,7 @@ } } - int minimumPositionalArguments() const override { - return 2; - } + int minimumPositionalArguments() const override { return 2; } void usage(const std::string& tool) const override { Log::info() << "\n" diff -Nru metview-5.17.4/mir/src/tools/mir-climate-filter.cc metview-5.19.2/mir/src/tools/mir-climate-filter.cc --- metview-5.17.4/mir/src/tools/mir-climate-filter.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-climate-filter.cc 2023-07-15 08:28:47.000000000 +0000 @@ -43,8 +43,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRClimateFilter : MIRTool { @@ -328,8 +327,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-compare.cc metview-5.19.2/mir/src/tools/mir-compare.cc --- metview-5.17.4/mir/src/tools/mir-compare.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-compare.cc 2023-07-15 08:28:47.000000000 +0000 @@ -17,8 +17,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRCompare : MIRTool { @@ -44,8 +43,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-compute.cc metview-5.19.2/mir/src/tools/mir-compute.cc --- metview-5.17.4/mir/src/tools/mir-compute.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-compute.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,122 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include +#include +#include + +#include "eckit/option/CmdArgs.h" +#include "eckit/option/SimpleOption.h" +#include "eckit/option/VectorOption.h" + +#include "mir/action/calc/FormulaAction.h" +#include "mir/action/context/Context.h" +#include "mir/action/io/Save.h" +#include "mir/input/MIRInput.h" +#include "mir/output/MIROutput.h" +#include "mir/param/CombinedParametrisation.h" +#include "mir/param/ConfigurationWrapper.h" +#include "mir/param/DefaultParametrisation.h" +#include "mir/param/SimpleParametrisation.h" +#include "mir/tools/MIRTool.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Log.h" +#include "mir/util/MIRStatistics.h" + + +namespace mir::tools { + + +struct MIRCompute : MIRTool { + MIRCompute(int argc, char** argv) : MIRTool(argc, argv) { + options_.push_back(new eckit::option::SimpleOption("input", "Input options (YAML)")); + options_.push_back(new eckit::option::VectorOption( + "formula", "Formula(s) on variables f/f1/f2/... (formula;formula;...)", 0, ";")); + options_.push_back(new eckit::option::VectorOption("param-id", "GRIB paramId(s) (1;2;...)", 0, ";")); + } + + int numberOfPositionalArguments() const override { return 2; } + + void usage(const std::string& tool) const override { + Log::info() << "\n" + "Usage: " + << tool + << " --formula=f(f,f1,f2,...)[;g(f,f1,f2,...)[;...]] [--param-id=1[;2[;...]]] [--input={}] " + "input.grib output.grib" + "\n" + "Examples: " + "\n % " + << tool + << " --formula=2+3*f input.grib output.grib" + "\n % " + << tool + << " --formula=\"sqrt(f1*f1+f2^2);f1-f2;f1+f2\" --input=\"{multiDimensional: 2}\" " + "--param-id=1;2;3 input.grib output.grib" + << std::endl; + } + + void execute(const eckit::option::CmdArgs&) override; +}; + + +void MIRCompute::execute(const eckit::option::CmdArgs& args) { + const param::ConfigurationWrapper param(args); + + + // arguments + std::vector formulas; + args.get("formula", formulas); + ASSERT(!formulas.empty()); + + std::vector paramids; + args.get("param-id", paramids); + ASSERT(paramids.empty() || paramids.size() == formulas.size()); + + + // create input/output + std::unique_ptr input(input::MIRInputFactory::build(args(0), param)); + std::unique_ptr output(output::MIROutputFactory::build(args(1), param)); + + + // for each input (possibly more than one field at a time), process each formula/metadata + while (input->next()) { + for (size_t i = 0; i < formulas.size(); ++i) { + util::MIRStatistics statistics; + context::Context ctx(*input, statistics); + + // run-time parametrisation + param::SimpleParametrisation user; + user.set("formula", formulas[i]); + user.set("formula.metadata", paramids.empty() ? "" : "paramId=" + std::to_string(paramids[i])); + + const param::DefaultParametrisation defaults; + std::unique_ptr param( + new param::CombinedParametrisation(user, input->parametrisation(), defaults)); + + std::unique_ptr formula(new action::FormulaAction(*param)); + formula->perform(ctx); + Log::info() << ctx << std::endl; + + std::unique_ptr save(new action::io::Save(*param, *output)); + save->perform(ctx); + } + } +} + + +} // namespace mir::tools + + +int main(int argc, char** argv) { + mir::tools::MIRCompute tool(argc, argv); + return tool.start(); +} diff -Nru metview-5.17.4/mir/src/tools/mir-config.cc metview-5.19.2/mir/src/tools/mir-config.cc --- metview-5.17.4/mir/src/tools/mir-config.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-config.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,6 +22,7 @@ #include "eckit/option/SimpleOption.h" #include "eckit/utils/StringTools.h" +#include "mir/config/LibMir.h" #include "mir/input/GribFileInput.h" #include "mir/param/CombinedParametrisation.h" #include "mir/param/DefaultParametrisation.h" @@ -31,12 +32,11 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct Param { - Param(const std::vector& classes_v) : classes(classes_v.begin(), classes_v.end()) {} + Param(const std::vector& classes_v) : id(0), classes(classes_v.begin(), classes_v.end()) {} long id; std::string name; std::set classes; @@ -97,9 +97,6 @@ options_.push_back(new SimpleOption("param-id", "Display configuration with paramId")); options_.push_back(new SimpleOption("key", "Display configuration with specific key")); - - options_.push_back(new SimpleOption( - "param-file", "Set classification file (default '~mir/etc/mir/parameter-class.yaml')")); options_.push_back(new SimpleOption("param-class", "Set class(es) for paramId, /-separated")); options_.push_back(new SimpleOption("param-name", "Set name for paramId")); } @@ -143,17 +140,15 @@ Map map; - std::string paramFile = "~mir/etc/mir/parameter-class.yaml"; - args.get("param-file", paramFile); + const eckit::LocalPathName file = LibMir::configFile(LibMir::config_file::PARAMETER_CLASS).asString(); + Log::info() << "File '" << file.fullName() << "' (read)" << std::endl; - eckit::LocalPathName file(paramFile); - auto tmp = file + ".tmp"; - Log::info() << "File '" << file.fullName() << "' (read),\nFile '" << tmp.fullName() << "' (temporary)" - << std::endl; + eckit::LocalPathName tmp = file + ".tmp"; + Log::info() << "File '" << tmp.fullName() << "' (temporary)" << std::endl; { - std::ifstream i(file.c_str()); - std::ofstream o(tmp.c_str()); + std::ifstream i(file); + std::ofstream o(tmp); if (!o) { throw exception::WriteError("Cannot write to '" + tmp + "'"); } @@ -171,8 +166,8 @@ } if (!line.empty() && line.substr(0, 2) == "- ") { - auto c = line.find_first_of('#'); - long id; + auto c = line.find_first_of('#'); + long id = 0; std::istringstream(line.substr(2, c)) >> id; std::string name(c != std::string::npos ? eckit::StringTools::trim(line.substr(c + 1)) : ""); @@ -212,7 +207,7 @@ } public: - DummyField(long paramId) : paramId_(paramId) {} + explicit DummyField(long paramId) : paramId_(paramId) {} }; display(DummyField(paramId), key); @@ -232,8 +227,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-config-grib.cc metview-5.19.2/mir/src/tools/mir-config-grib.cc --- metview-5.17.4/mir/src/tools/mir-config-grib.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-config-grib.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,98 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include + +#include "eckit/option/CmdArgs.h" +#include "eckit/option/FactoryOption.h" +#include "eckit/option/SimpleOption.h" + +#include "mir/config/LibMir.h" +#include "mir/grib/Config.h" +#include "mir/grib/Packing.h" +#include "mir/input/MIRInput.h" +#include "mir/param/CombinedParametrisation.h" +#include "mir/param/ConfigurationWrapper.h" +#include "mir/param/DefaultParametrisation.h" +#include "mir/tools/MIRTool.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Log.h" + + +namespace mir::tools { + + +struct MIRConfigGrib : MIRTool { + MIRConfigGrib(int argc, char** argv) : MIRTool(argc, argv) { + using eckit::option::FactoryOption; + using eckit::option::SimpleOption; + + options_.push_back(new SimpleOption("accuracy", "Number of bits per value")); + options_.push_back(new FactoryOption("packing", "GRIB packing method")); + options_.push_back(new SimpleOption("edition", "GRIB edition number")); + + options_.push_back(new SimpleOption( + "grib-packing-gridded", "GRIB default gridded packing, on gridded/spectral conversions")); + options_.push_back(new SimpleOption( + "grib-packing-spectral", "GRIB default spectral packing, on gridded/spectral conversions")); + options_.push_back( + new SimpleOption("grib-packing-always-set", "GRIB packing setting to default, unless overriden")); + options_.push_back( + new SimpleOption("grib-edition-conversion", "GRIB edition conversion on packing changes")); + } + + int minimumPositionalArguments() const override { return 1; } + + void usage(const std::string& tool) const override { + Log::info() << "\nDisplay GRIB-related configuration." + "\n" + "\nUsage: " + << tool << " [file1 [file2 [...]]]" << std::endl; + } + + void execute(const eckit::option::CmdArgs& /*args*/) override; +}; + + +template +T get(const param::MIRParametrisation& param, const std::string& name, T value) { + param.get(name, value); + return value; +} + + +void MIRConfigGrib::execute(const eckit::option::CmdArgs& args) { + static const param::DefaultParametrisation defaults; + const param::ConfigurationWrapper args_wrap(args); + + static const grib::Config config(LibMir::configFile(LibMir::config_file::GRIB_OUTPUT), false); + + for (const auto& arg : args) { + Log::info() << arg << std::endl; + std::unique_ptr input(input::MIRInputFactory::build(arg, args_wrap)); + + while (input->next()) { + std::unique_ptr param( + new param::CombinedParametrisation(args_wrap, input->parametrisation(), defaults)); + config.find(*param); + } + } +} + + +} // namespace mir::tools + + +int main(int argc, char** argv) { + mir::tools::MIRConfigGrib tool(argc, argv); + return tool.start(); +} diff -Nru metview-5.17.4/mir/src/tools/mir-count.cc metview-5.19.2/mir/src/tools/mir-count.cc --- metview-5.17.4/mir/src/tools/mir-count.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-count.cc 2023-07-15 08:28:47.000000000 +0000 @@ -32,8 +32,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { using prec_t = decltype(Log::info().precision()); @@ -151,8 +150,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-formula.cc metview-5.19.2/mir/src/tools/mir-formula.cc --- metview-5.17.4/mir/src/tools/mir-formula.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-formula.cc 2023-07-15 08:28:47.000000000 +0000 @@ -20,8 +20,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRFormula : MIRTool { @@ -54,8 +53,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-gaussian-fractions.cc metview-5.19.2/mir/src/tools/mir-gaussian-fractions.cc --- metview-5.17.4/mir/src/tools/mir-gaussian-fractions.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-gaussian-fractions.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,8 +25,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tools { +namespace mir::tools { using statistics_t = stats::detail::PNormsT; @@ -117,8 +116,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-get-data.cc metview-5.19.2/mir/src/tools/mir-get-data.cc --- metview-5.17.4/mir/src/tools/mir-get-data.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-get-data.cc 2023-07-15 08:28:47.000000000 +0000 @@ -36,8 +36,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { using coord_t = std::vector; @@ -175,12 +174,8 @@ NOTIMP; #endif } - const coord_t& latitudes() const override { - return lats_; - } - const coord_t& longitudes() const override { - return lons_; - } + const coord_t& latitudes() const override { return lats_; } + const coord_t& longitudes() const override { return lons_; } private: coord_t lats_; @@ -374,8 +369,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-grid-info.cc metview-5.19.2/mir/src/tools/mir-grid-info.cc --- metview-5.17.4/mir/src/tools/mir-grid-info.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-grid-info.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,8 +27,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRGridInfo : MIRTool { @@ -148,8 +147,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-inspect.cc metview-5.19.2/mir/src/tools/mir-inspect.cc --- metview-5.17.4/mir/src/tools/mir-inspect.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-inspect.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,8 +15,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { class MIRInspect : public tools::MIRTool { @@ -83,8 +82,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-list.cc metview-5.19.2/mir/src/tools/mir-list.cc --- metview-5.17.4/mir/src/tools/mir-list.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-list.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRList : MIRTool { @@ -64,8 +63,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-load-legendre.cc metview-5.19.2/mir/src/tools/mir-load-legendre.cc --- metview-5.17.4/mir/src/tools/mir-load-legendre.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-load-legendre.cc 2023-07-15 08:28:47.000000000 +0000 @@ -28,8 +28,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRLoadLegendre : MIRTool { @@ -128,8 +127,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-load-matrix.cc metview-5.19.2/mir/src/tools/mir-load-matrix.cc --- metview-5.17.4/mir/src/tools/mir-load-matrix.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-load-matrix.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,6 +24,7 @@ #include "mir/caching/matrix/MatrixLoader.h" #include "mir/caching/matrix/SharedMemoryLoader.h" +#include "mir/config/LibMir.h" #include "mir/method/WeightMatrix.h" #include "mir/param/ConfigurationWrapper.h" #include "mir/tools/MIRTool.h" @@ -31,8 +32,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRLoadMatrix : MIRTool { @@ -97,7 +97,7 @@ param.get("unload", unload); param.get("wait", wait); - std::string matrixLoader = "file-io"; + std::string matrixLoader = LibMir::cacheLoader(LibMir::cache_loader::MATRIX); param.get("matrix-loader", matrixLoader); @@ -272,8 +272,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-make-lsm.cc metview-5.19.2/mir/src/tools/mir-make-lsm.cc --- metview-5.17.4/mir/src/tools/mir-make-lsm.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-make-lsm.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRMakeLSM : MIRTool { @@ -86,8 +85,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-plot-lsm.cc metview-5.19.2/mir/src/tools/mir-plot-lsm.cc --- metview-5.17.4/mir/src/tools/mir-plot-lsm.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-plot-lsm.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,8 +30,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRPlotLSM : MIRTool { @@ -98,8 +97,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-points.cc metview-5.19.2/mir/src/tools/mir-points.cc --- metview-5.17.4/mir/src/tools/mir-points.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-points.cc 2023-07-15 08:28:47.000000000 +0000 @@ -19,8 +19,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRPoints : MIRTool { @@ -65,8 +64,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-spectral-transform-points.cc metview-5.19.2/mir/src/tools/mir-spectral-transform-points.cc --- metview-5.17.4/mir/src/tools/mir-spectral-transform-points.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-spectral-transform-points.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,8 +29,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRSpectralTransformPoints : MIRTool { @@ -107,8 +106,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-statistics.cc metview-5.19.2/mir/src/tools/mir-statistics.cc --- metview-5.17.4/mir/src/tools/mir-statistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-statistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,8 +35,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tools { +namespace mir::tools { using prec_t = decltype(Log::info().precision()); @@ -211,8 +210,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-triangulate.cc metview-5.19.2/mir/src/tools/mir-triangulate.cc --- metview-5.17.4/mir/src/tools/mir-triangulate.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-triangulate.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,8 +34,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRTriangulate : MIRTool { @@ -420,8 +419,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/src/tools/mir-weight-matrix-diff.cc metview-5.19.2/mir/src/tools/mir-weight-matrix-diff.cc --- metview-5.17.4/mir/src/tools/mir-weight-matrix-diff.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/src/tools/mir-weight-matrix-diff.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,6 +21,7 @@ #include "eckit/types/FloatCompare.h" #include "mir/caching/matrix/MatrixLoader.h" +#include "mir/config/LibMir.h" #include "mir/method/WeightMatrix.h" #include "mir/param/ConfigurationWrapper.h" #include "mir/stats/detail/CounterBinary.h" @@ -29,8 +30,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tools { +namespace mir::tools { struct MIRWeightMatrixDiff : MIRTool { @@ -63,10 +63,10 @@ virtual ~diff_t() = default; virtual bool operator()(double a, double b) const = 0; - diff_t(const diff_t&) = delete; - diff_t(diff_t&&) = delete; + diff_t(const diff_t&) = delete; + diff_t(diff_t&&) = delete; diff_t& operator=(const diff_t&) = delete; - diff_t& operator=(diff_t&&) = delete; + diff_t& operator=(diff_t&&) = delete; }; @@ -86,20 +86,16 @@ using caching::matrix::MatrixLoaderFactory; using method::WeightMatrix; - struct shape_t : std::vector { - shape_t(const WeightMatrix& m) : std::vector{m.nonZeros(), m.rows(), m.cols()} {} - }; - const param::ConfigurationWrapper param(args); auto& log = Log::info(); - std::string matrixLoader = "file-io"; + std::string matrixLoader = LibMir::cacheLoader(LibMir::cache_loader::MATRIX); param.get("matrix-loader", matrixLoader); - bool matrixValidate; + bool matrixValidate = false; param.get("matrix-validate", matrixValidate); - bool counter; + bool counter = false; param.get("counter", counter); WeightMatrix a(MatrixLoaderFactory::build(matrixLoader, args(0))); @@ -112,8 +108,8 @@ b.validate(("load '" + args(1) + "'").c_str()); } - shape_t aShape(a); - shape_t bShape(b); + auto aShape = std::vector{a.nonZeros(), a.rows(), a.cols()}; + auto bShape = std::vector{b.nonZeros(), b.rows(), b.cols()}; if (aShape != bShape) { log << "!= geometry: " << aShape << " != " << bShape << std::endl; } @@ -168,8 +164,7 @@ } -} // namespace tools -} // namespace mir +} // namespace mir::tools int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/assertions/CMakeLists.txt metview-5.19.2/mir/tests/assertions/CMakeLists.txt --- metview-5.17.4/mir/tests/assertions/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -2,6 +2,16 @@ ecbuild_configure_file(mir-test.sh.in mir-test.sh @ONLY) +file(CREATE_LINK + "${CMAKE_BINARY_DIR}/etc/mir/grib-output-ii.yaml" + "${CMAKE_CURRENT_BINARY_DIR}/grib-output-ii.yaml" + COPY_ON_ERROR SYMBOLIC) + +file(CREATE_LINK + "${CMAKE_BINARY_DIR}/etc/mir/grib-output-iii.yaml" + "${CMAKE_CURRENT_BINARY_DIR}/grib-output-iii.yaml" + COPY_ON_ERROR SYMBOLIC) + if(MARS_SCRIPT) file(GLOB_RECURSE test_files LIST_DIRECTORIES false *.test) diff -Nru metview-5.17.4/mir/tests/assertions/grib-output-iii.yaml metview-5.19.2/mir/tests/assertions/grib-output-iii.yaml --- metview-5.17.4/mir/tests/assertions/grib-output-iii.yaml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/grib-output-iii.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,17 @@ +--- + +edition=0: +- grib-packing-gridded: ccsds +- grib-packing-spectral: complex +- grib-packing-always-set: true + +edition=1: +- grib-packing-gridded: simple +- grib-packing-spectral: complex +- grib-packing-always-set: true + +edition=2: +- grib-packing-gridded: ccsds +- grib-packing-spectral: complex +- grib-packing-always-set: true + diff -Nru metview-5.17.4/mir/tests/assertions/grib-output-ii.yaml metview-5.19.2/mir/tests/assertions/grib-output-ii.yaml --- metview-5.17.4/mir/tests/assertions/grib-output-ii.yaml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/grib-output-ii.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,15 @@ +--- + +edition=0: +- grib-packing-gridded: ccsds +- grib-packing-spectral: complex +- grib-packing-always-set: true + +edition=1: +- grib-packing-gridded: simple +- grib-packing-spectral: complex + +edition=2: +- grib-packing-gridded: ccsds +- grib-packing-spectral: complex + diff -Nru metview-5.17.4/mir/tests/assertions/griddef-from-spectral.test metview-5.19.2/mir/tests/assertions/griddef-from-spectral.test --- metview-5.17.4/mir/tests/assertions/griddef-from-spectral.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/griddef-from-spectral.test 2023-07-15 08:28:47.000000000 +0000 @@ -1,6 +1,6 @@ -# Mars request -param=t,level=1000 -# Mir tool options +# mars +param=t,level=1000,resol=20 +# mir --griddef=$tests_assertions_dir/weather-params.pts -# grib_get assertions +# grib_get # none: output file is GEOPOINTS diff -Nru metview-5.17.4/mir/tests/assertions/MIR-280.001.core.test metview-5.19.2/mir/tests/assertions/MIR-280.001.core.test --- metview-5.17.4/mir/tests/assertions/MIR-280.001.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-280.001.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -1,6 +1,6 @@ # MARS request stream=wave,param=swh,special # mir (do nothing) ---truncation=none +--intgrid=none # grib_get assertions missingValuesPresent = 1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.001.test metview-5.19.2/mir/tests/assertions/MIR-513.001.test --- metview-5.17.4/mir/tests/assertions/MIR-513.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.001.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -param=vo_d,level=1000,resol=20.SPECIAL -# mir ---grid=1/1 --intgrid=none --vod2uv --packing=av -# grib_get assertions -packingType=grid_complex -edition=2 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.002.core.test metview-5.19.2/mir/tests/assertions/MIR-513.002.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.002.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib2 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--grid=1/1 --intgrid=none --edition=1 +# grib_get +packingType=grid_simple +edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.003.core.test metview-5.19.2/mir/tests/assertions/MIR-513.003.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.003.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.003.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib1 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--grid=1/1 --intgrid=none --edition=2 +# grib_get +packingType=grid_ccsds +edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.004.core.test metview-5.19.2/mir/tests/assertions/MIR-513.004.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.004.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.004.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +param=t,level=1000,resol=20 +# mir +--grid=9/9 --grib-packing-gridded=ccsds --grib-edition-conversion=true +# grib_get +packingType=grid_ccsds +edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.005.core.test metview-5.19.2/mir/tests/assertions/MIR-513.005.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.005.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.005.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +param=t,level=1000,resol=20 +# mir +--grid=9/9 +# grib_get +packingType=grid_simple +edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.006.core.test metview-5.19.2/mir/tests/assertions/MIR-513.006.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.006.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.006.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +param=z,level=1,levtype=ml,resol=20 +# mir +--grid=9/9 +# grib_get +packingType=grid_simple +edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.001.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.001.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.001.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.001.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ccsds.grib2 # mir --packing=simple -# grib_get assertions +# grib_get packingType=grid_simple edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.002.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.002.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.002.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ccsds.grib2 # mir --packing=so -# grib_get assertions +# grib_get packingType=grid_second_order edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.003.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.003.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.003.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.003.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ccsds.grib2 # mir --packing=ccsds -# grib_get assertions +# grib_get packingType=grid_ccsds edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.004.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.004.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.004.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.004.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ccsds.grib2 # mir --packing=ieee -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.005.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.005.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.005.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.005.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ccsds.grib2 # mir --packing=ieee --accuracy=32 -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.006.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.006.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.006.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.006.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ccsds.grib2 # mir --packing=av -# grib_get assertions +# grib_get packingType=grid_ccsds edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.007.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.007.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ccsds.007.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ccsds.007.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=grid_ccsds.grib2 +# mir +--grid=0.5/0.5 +# grib_get +packingType=grid_ccsds +edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.001.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.001.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.001.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.001.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ieee.grib2 # mir --packing=simple -# grib_get assertions +# grib_get packingType=grid_simple edition=2 bitsPerValue=32 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.002.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.002.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.002.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ieee.grib2 # mir --packing=so -# grib_get assertions +# grib_get packingType=grid_second_order edition=2 bitsPerValue=32 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.003.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.003.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.003.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.003.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ieee.grib2 # mir --packing=ccsds -# grib_get assertions +# grib_get packingType=grid_ccsds edition=2 bitsPerValue=32 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.004.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.004.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.004.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.004.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ieee.grib2 # mir --packing=ieee -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.005.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.005.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.005.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.005.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ieee.grib2 # mir --packing=ieee --accuracy=64 -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.006.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.006.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.006.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.006.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_ieee.grib2 # mir --packing=av -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.007.core.fail.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.007.core.fail.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.007.core.fail.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.007.core.fail.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=grid_ieee.grib2 +# mir +--packing=av --accuracy=128 +# grib_get +packingType=grid_ieee +edition=2 +precision=3 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.007.fail.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.007.fail.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.007.fail.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.007.fail.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=grid_ieee.grib2 -# mir ---packing=av --accuracy=128 -# grib_get assertions -packingType=grid_ieee -edition=2 -precision=3 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.008.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.008.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_ieee.008.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_ieee.008.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=grid_ieee.grib2 +# mir +--grid=0.5/0.5 +# grib_get +packingType=grid_ieee +edition=2 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.001.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.001.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.001.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.001.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_second_order.grib2 # mir --packing=simple -# grib_get assertions +# grib_get packingType=grid_simple edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.002.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.002.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.002.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_second_order.grib2 # mir --packing=so -# grib_get assertions +# grib_get packingType=grid_second_order edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.003.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.003.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.003.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.003.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_second_order.grib2 # mir --packing=ccsds -# grib_get assertions +# grib_get packingType=grid_ccsds edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.004.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.004.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.004.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.004.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_second_order.grib2 # mir --packing=ieee -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.005.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.005.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.005.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.005.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_second_order.grib2 # mir --packing=ieee --accuracy=32 -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.006.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.006.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.006.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.006.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_second_order.grib2 # mir --packing=av -# grib_get assertions +# grib_get packingType=grid_second_order edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.007.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.007.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_second_order.007.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_second_order.007.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=grid_second_order.grib2 +# mir +--grid=0.5/0.5 +# grib_get +packingType=grid_second_order +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.001.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.001.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.001.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.001.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_simple.grib2 # mir --packing=simple -# grib_get assertions +# grib_get packingType=grid_simple edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.002.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.002.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.002.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_simple.grib2 # mir --packing=so -# grib_get assertions +# grib_get packingType=grid_second_order edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.003.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.003.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.003.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.003.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_simple.grib2 # mir --packing=ccsds -# grib_get assertions +# grib_get packingType=grid_ccsds edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.004.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.004.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.004.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.004.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_simple.grib2 # mir --packing=ieee -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.005.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.005.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.005.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.005.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_simple.grib2 # mir --packing=ieee --accuracy=32 -# grib_get assertions +# grib_get packingType=grid_ieee edition=2 precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.006.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.006.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.006.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.006.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,7 +2,7 @@ packingType=grid_simple.grib2 # mir --packing=av -# grib_get assertions +# grib_get packingType=grid_simple edition=2 bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.007.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.007.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.007.core.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.007.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -2,6 +2,6 @@ tiny.grib # mir --area=0/0/0/1 --packing=so -# grib_get assertions (output (#points = 2) is in packingType=grid_simple because grid_second_order is not supported for #points < 4) +# grib_get (output (#points = 2) is in packingType=grid_simple because grid_second_order is not supported for #points < 4) packingType=grid_simple numberOfDataPoints=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.008.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.008.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.008.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.008.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=grid_simple.grib2 +# mir +--grid=0.5/0.5 +# grib_get +packingType=grid_simple +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.009.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.009.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.009.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.009.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=grid_simple.grib1 +# mir +--packing=simple +# grib_get +packingType=grid_simple +edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.010.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.010.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.010.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.010.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=grid_simple.grib1 +# mir +--packing=so +# grib_get +packingType=grid_second_order +edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.011.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.011.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.011.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.011.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=grid_simple.grib1 +# mir +--packing=ccsds --grib-edition-conversion=true +# grib_get +packingType=grid_ccsds +edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.012.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.012.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.012.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.012.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=grid_simple.grib1 +# mir +--packing=ieee +# grib_get +packingType=grid_ieee +edition=1 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.013.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.013.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.013.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.013.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=grid_simple.grib1 +# mir +--packing=ieee --accuracy=32 +# grib_get +packingType=grid_ieee +edition=1 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.014.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.014.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.014.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.014.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=grid_simple.grib1 +# mir +--packing=av +# grib_get +packingType=grid_simple +edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.015.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.015.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.015.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.015.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=grid_simple.grib2 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--packing=simple +# grib_get +packingType=grid_simple +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.016.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.016.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.016.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.016.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=grid_simple.grib2 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--packing=ccsds +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.017.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.017.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.017.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.017.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=grid_simple.grib2 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--grid=0.5/0.5 +# grib_get +packingType=grid_simple +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.018.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.018.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.018.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.018.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=grid_simple.grib1 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--packing=simple +# grib_get +packingType=grid_simple +edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.019.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.019.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=grid_simple.019.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=grid_simple.019.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=grid_simple.grib1 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--packing=ccsds --grib-edition-conversion=true +# grib_get +packingType=grid_ccsds +edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.002.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.002.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.002.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib1 +# mir +--grid=1/1 --intgrid=none --packing=so +# grib_get +packingType=grid_second_order +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.002.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.002.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.002.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.002.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none --packing=so -# grib_get assertions -packingType=grid_second_order -edition=1 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.003.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.003.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.003.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.003.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib1 +# mir +--grid=1/1 --intgrid=none --packing=ccsds --grib-edition-conversion=true +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.004.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.004.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.004.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.004.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib1 +# mir +--grid=1/1 --intgrid=none --packing=ieee +# grib_get +packingType=grid_ieee +edition=1 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.004.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.004.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.004.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.004.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none --packing=ieee -# grib_get assertions -packingType=grid_ieee -edition=2 -precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.005.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.005.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.005.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.005.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib1 +# mir +--grid=1/1 --intgrid=none --packing=ieee --accuracy=32 +# grib_get +packingType=grid_ieee +edition=1 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.005.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.005.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.005.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.005.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none --packing=ieee --accuracy=32 -# grib_get assertions -packingType=grid_ieee -edition=2 -precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.006.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.006.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.006.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.006.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib1 +# mir +--grid=1/1 --intgrid=none +# grib_get +packingType=grid_simple +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.006.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.006.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.006.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.006.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none -# grib_get assertions -packingType=grid_simple -edition=1 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.008.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.008.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.008.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.008.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib2 +# mir +--grid=1/1 --intgrid=none --packing=ieee +# grib_get +packingType=grid_ieee +edition=2 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.008.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.008.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.008.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.008.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_complex.grib2 -# mir ---grid=1/1 --intgrid=none --packing=ieee -# grib_get assertions -packingType=grid_ieee -edition=2 -precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.009.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.009.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.009.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.009.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=spectral_complex.grib1 +# mir +--packing=simple +# grib_get +packingType=spectral_simple +edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.009.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.009.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.009.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.009.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---packing=simple -# grib_get assertions -packingType=spectral_simple -edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.010.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.010.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.010.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.010.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex.grib1 +# mir +--truncation=21 --packing=simple +# grib_get +packingType=spectral_simple +edition=1 +numberOfDataPoints=506 +numberOfValues=506 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.010.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.010.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.010.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.010.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---truncation=21 --packing=simple -# grib_get assertions -packingType=spectral_simple -edition=1 -numberOfDataPoints=506 -numberOfValues=506 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.011.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.011.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.011.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.011.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=spectral_complex.grib2 +# mir +--packing=simple +# grib_get +packingType=spectral_simple +edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.011.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.011.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.011.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.011.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -# mars -packingType=spectral_complex.grib2 -# mir ---packing=simple -# grib_get assertions -packingType=spectral_simple -edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.012.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.012.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.012.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.012.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex.grib2 +# mir +--truncation=21 --packing=simple +# grib_get +packingType=spectral_simple +edition=2 +numberOfDataPoints=506 +numberOfValues=506 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.012.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.012.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.012.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.012.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -# mars -packingType=spectral_complex.grib2 -# mir ---truncation=21 --packing=simple -# grib_get assertions -packingType=spectral_simple -edition=2 -numberOfDataPoints=506 -numberOfValues=506 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.014.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.014.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.014.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.014.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex.grib2 +# mir +--grid=0.5/0.5 +# grib_get +packingType=grid_simple +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.016.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.016.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.016.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.016.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +--vod2uv --intgrid=none --grid=1/1 --packing=so +# grib_get +packingType=grid_second_order +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.017.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.017.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.017.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.017.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +--vod2uv --intgrid=none --grid=1/1 --packing=ccsds --grib-edition-conversion=true +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.018.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.018.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.018.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.018.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +--vod2uv --intgrid=none --grid=1/1 --packing=ieee +# grib_get +packingType=grid_ieee +edition=1 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.019.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.019.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.019.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.019.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +--vod2uv --intgrid=none --grid=1/1 --packing=ieee --accuracy=32 +# grib_get +packingType=grid_ieee +edition=1 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.020.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.020.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.020.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.020.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +--vod2uv --intgrid=none --grid=1/1 +# grib_get +packingType=grid_simple +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.022.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.022.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.022.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.022.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +--vod2uv --packing=simple +# grib_get +packingType=spectral_simple +edition=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.023.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.023.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.023.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.023.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +--vod2uv --truncation=21 --packing=simple +# grib_get +packingType=spectral_simple +edition=1 +numberOfDataPoints=506 +numberOfValues=506 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.025.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.025.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.025.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.025.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +--vod2uv --intgrid=none --grid=1/1 --packing=so +# grib_get +packingType=grid_second_order +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.026.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.026.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.026.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.026.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +--vod2uv --intgrid=none --grid=1/1 --packing=ccsds +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.027.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.027.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.027.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.027.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +--vod2uv --intgrid=none --grid=1/1 --packing=ieee +# grib_get +packingType=grid_ieee +edition=2 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.028.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.028.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.028.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.028.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +--vod2uv --intgrid=none --grid=1/1 --packing=ieee --accuracy=32 +# grib_get +packingType=grid_ieee +edition=2 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.029.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.029.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.029.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.029.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +--vod2uv --intgrid=none --grid=1/1 +# grib_get +packingType=grid_simple +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.032.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.032.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.032.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.032.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex.grib1 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--grid=1/1 --intgrid=none --packing=ccsds --grib-edition-conversion=true +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.033.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.033.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.033.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.033.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex.grib1 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--grid=1/1 --intgrid=none +# grib_get +packingType=grid_simple +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.033.core.test.disabled metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.033.core.test.disabled --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.033.core.test.disabled 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.033.core.test.disabled 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +--vod2uv --packing=simple +# grib_get +packingType=spectral_simple +edition=2 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.034.core.test.disabled metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.034.core.test.disabled --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.034.core.test.disabled 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.034.core.test.disabled 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +--vod2uv --truncation=21 --packing=simple +# grib_get +packingType=spectral_simple +edition=2 +numberOfDataPoints=506 +numberOfValues=506 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.035.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.035.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.035.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.035.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex.grib2 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--grid=0.5/0.5 +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.037.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.037.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.037.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.037.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--vod2uv --intgrid=none --grid=1/1 --packing=ccsds --grib-edition-conversion=true +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.038.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.038.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.038.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.038.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex,param=vo_d.grib1 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--vod2uv --intgrid=none --grid=1/1 +# grib_get +packingType=grid_simple +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.040.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.040.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.040.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.040.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--vod2uv --intgrid=none --grid=1/1 --packing=ccsds +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.041.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.041.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_complex.041.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_complex.041.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,9 @@ +# mars +packingType=spectral_complex,param=vo_d.grib2 +# mir +$MIR_CONFIG_GRIB_OUTPUT=grib-output-ii.yaml +--vod2uv --intgrid=none --grid=1/1 +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.001.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.001.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.001.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.001.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_simple.grib1 +# mir +--grid=1/1 --intgrid=none --packing=simple +# grib_get +packingType=grid_simple +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.001.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.001.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.001.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_simple.grib1 -# mir ---grid=1/1 --intgrid=none --packing=simple -# grib_get assertions -packingType=grid_simple -edition=1 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.002.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.002.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.002.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_simple.grib1 +# mir +--grid=1/1 --intgrid=none --packing=so +# grib_get +packingType=grid_second_order +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.002.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.002.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.002.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.002.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_simple.grib1 -# mir ---grid=1/1 --intgrid=none --packing=so -# grib_get assertions -packingType=grid_second_order -edition=1 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.003.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.003.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.003.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.003.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_simple.grib1 +# mir +--grid=1/1 --intgrid=none --packing=ccsds --grib-edition-conversion=true +# grib_get +packingType=grid_ccsds +edition=2 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.004.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.004.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.004.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.004.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_simple.grib1 +# mir +--grid=1/1 --intgrid=none --packing=ieee +# grib_get +packingType=grid_ieee +edition=1 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.004.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.004.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.004.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.004.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_simple.grib1 -# mir ---grid=1/1 --intgrid=none --packing=ieee -# grib_get assertions -packingType=grid_ieee -edition=2 -precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.005.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.005.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.005.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.005.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_simple.grib1 +# mir +--grid=1/1 --intgrid=none --packing=ieee --accuracy=32 +# grib_get +packingType=grid_ieee +edition=1 +precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.005.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.005.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.005.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.005.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_simple.grib1 -# mir ---grid=1/1 --intgrid=none --packing=ieee --accuracy=32 -# grib_get assertions -packingType=grid_ieee -edition=2 -precision=1 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.006.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.006.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.006.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.006.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_simple.grib1 +# mir +--grid=1/1 --intgrid=none +# grib_get +packingType=grid_simple +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.006.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.006.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.006.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.006.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_simple.grib1 -# mir ---grid=1/1 --intgrid=none -# grib_get assertions -packingType=grid_simple -edition=1 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.007.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.007.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.007.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.007.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_simple.grib1 +# mir +--grid=1/1 --intgrid=none --packing=av +# grib_get +packingType=grid_simple +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.007.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.007.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.007.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.007.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -# mars -packingType=spectral_simple.grib1 -# mir ---grid=1/1 --intgrid=none --packing=av -# grib_get assertions -packingType=grid_simple -edition=1 -bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.008.core.test metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.008.core.test --- metview-5.17.4/mir/tests/assertions/MIR-513.packingType=spectral_simple.008.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-513.packingType=spectral_simple.008.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,8 @@ +# mars +packingType=spectral_simple.grib1 +# mir +--grid=0.5/0.5 +# grib_get +packingType=grid_simple +edition=1 +bitsPerValue=16 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-553.002.test metview-5.19.2/mir/tests/assertions/MIR-553.002.test --- metview-5.17.4/mir/tests/assertions/MIR-553.002.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-553.002.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,13 @@ +# GRIB +MIR-553.grib2 +# mir +--area=66.6/-24.4/63.4/-13.6 +# grib_get assertions +#Ni=122 # prone to compiler/platform dependant results +#Nj=105 # ... +#latitudeOfFirstGridPointInDegrees=65.7618 # ... +#longitudeOfFirstGridPointInDegrees=-27.7661 # ... +scanningMode=0 +iScansPositively=1 +jScansPositively=0 + diff -Nru metview-5.17.4/mir/tests/assertions/MIR-555.test metview-5.19.2/mir/tests/assertions/MIR-555.test --- metview-5.17.4/mir/tests/assertions/MIR-555.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-555.test 2023-07-15 08:28:47.000000000 +0000 @@ -1,5 +1,5 @@ # mars -param=t,level=1000 +param=t,level=1000,resol=20 # mir --truncation=none --intgrid=none --grid=F640 --area=54/-16.5/50.5/-3 # grib_get diff -Nru metview-5.17.4/mir/tests/assertions/MIR-586.core.test metview-5.19.2/mir/tests/assertions/MIR-586.core.test --- metview-5.17.4/mir/tests/assertions/MIR-586.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-586.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,14 @@ +# mars +regular_ll.2-2.grib1 +# mir +--area=11/-1/-1/11 --interpolation=none +# grib_get assertions +gridType=regular_ll +Ni=6 +Nj=6 +iDirectionIncrementInDegrees=2 +jDirectionIncrementInDegrees=2 +latitudeOfFirstGridPointInDegrees=10 +longitudeOfFirstGridPointInDegrees=0 +latitudeOfLastGridPointInDegrees=0 +longitudeOfLastGridPointInDegrees=10 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-587.core.test metview-5.19.2/mir/tests/assertions/MIR-587.core.test --- metview-5.17.4/mir/tests/assertions/MIR-587.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-587.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,11 @@ +# input +MIR-587.grib2 +# mir tool options +--interpolation=grid-box-average --grid=0.5/0.5 +# grib_get assertions (not checking results) +Ni=25 +Nj=15 +latitudeOfFirstGridPointInDegrees=30.5 +longitudeOfFirstGridPointInDegrees=337 +latitudeOfLastGridPointInDegrees=23.5 +longitudeOfLastGridPointInDegrees=349 Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/assertions/MIR-587.grib2 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/assertions/MIR-587.grib2 differ diff -Nru metview-5.17.4/mir/tests/assertions/MIR-595.001.core.test metview-5.19.2/mir/tests/assertions/MIR-595.001.core.test --- metview-5.17.4/mir/tests/assertions/MIR-595.001.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-595.001.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,22 @@ +# mars +ukmo-tigge.count=4.grib +# mir +--area=43/-1/-10/3 --interpolation=none --basic-angle=decimal +# grib_get assertions +gridType=regular_ll +Ni=3 +Nj=64 +basicAngleOfTheInitialProductionDomain=0 +subdivisionsOfBasicAngle=MISSING +iDirectionIncrement=1250000 +jDirectionIncrement=833333 +latitudeOfFirstGridPoint=42916667 +longitudeOfFirstGridPoint=359375000 +latitudeOfLastGridPoint=-9583334 +longitudeOfLastGridPoint=1875000 +iDirectionIncrementInDegrees=1.25 +jDirectionIncrementInDegrees=0.833333 +latitudeOfFirstGridPointInDegrees=42.9167 +longitudeOfFirstGridPointInDegrees=359.375 +latitudeOfLastGridPointInDegrees=-9.58333 +longitudeOfLastGridPointInDegrees=1.875 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-595.002.core.test metview-5.19.2/mir/tests/assertions/MIR-595.002.core.test --- metview-5.17.4/mir/tests/assertions/MIR-595.002.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-595.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,22 @@ +# mars +ukmo-tigge.count=4.grib +# mir +--area=43/-2/-10/1 --interpolation=none --basic-angle=as-input +# grib_get assertions +gridType=regular_ll +Ni=3 +Nj=64 +basicAngleOfTheInitialProductionDomain=360 +subdivisionsOfBasicAngle=1728 +iDirectionIncrement=6 +jDirectionIncrement=4 +latitudeOfFirstGridPoint=206 +longitudeOfFirstGridPoint=1719 +latitudeOfLastGridPoint=-46 +longitudeOfLastGridPoint=3 +iDirectionIncrementInDegrees=1.25 +jDirectionIncrementInDegrees=0.833333 +latitudeOfFirstGridPointInDegrees=42.9167 +longitudeOfFirstGridPointInDegrees=358.125 +latitudeOfLastGridPointInDegrees=-9.58333 +longitudeOfLastGridPointInDegrees=0.625 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-595.003.core.test metview-5.19.2/mir/tests/assertions/MIR-595.003.core.test --- metview-5.17.4/mir/tests/assertions/MIR-595.003.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-595.003.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,22 @@ +# mars +ukmo-tigge.count=4.grib +# mir +--area=43/-2/-10/1 --interpolation=none --basic-angle=fraction +# grib_get assertions +gridType=regular_ll +Ni=3 +Nj=64 +basicAngleOfTheInitialProductionDomain=5 +subdivisionsOfBasicAngle=24 +iDirectionIncrement=6 +jDirectionIncrement=4 +latitudeOfFirstGridPoint=206 +longitudeOfFirstGridPoint=1719 +latitudeOfLastGridPoint=-46 +longitudeOfLastGridPoint=3 +iDirectionIncrementInDegrees=1.25 +jDirectionIncrementInDegrees=0.833333 +latitudeOfFirstGridPointInDegrees=42.9167 +longitudeOfFirstGridPointInDegrees=358.125 +latitudeOfLastGridPointInDegrees=-9.58333 +longitudeOfLastGridPointInDegrees=0.625 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-595.004.core.test metview-5.19.2/mir/tests/assertions/MIR-595.004.core.test --- metview-5.17.4/mir/tests/assertions/MIR-595.004.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-595.004.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,22 @@ +# mars +ukmo-tigge.count=4.grib +# mir +--area=1/-1/-1/1 --interpolation=none --basic-angle=decimal +# grib_get assertions +gridType=regular_ll +Ni=2 +Nj=2 +basicAngleOfTheInitialProductionDomain=0 +subdivisionsOfBasicAngle=MISSING +iDirectionIncrement=1250000 +jDirectionIncrement=833333 +latitudeOfFirstGridPoint=416667 +longitudeOfFirstGridPoint=359375000 +latitudeOfLastGridPoint=-416667 +longitudeOfLastGridPoint=625000 +iDirectionIncrementInDegrees=1.25 +jDirectionIncrementInDegrees=0.833333 +latitudeOfFirstGridPointInDegrees=0.416667 +longitudeOfFirstGridPointInDegrees=359.375 +latitudeOfLastGridPointInDegrees=-0.416667 +longitudeOfLastGridPointInDegrees=0.625 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-595.005.core.test metview-5.19.2/mir/tests/assertions/MIR-595.005.core.test --- metview-5.17.4/mir/tests/assertions/MIR-595.005.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-595.005.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,22 @@ +# mars +ukmo-tigge.count=4.grib +# mir +--area=1/-1/-1/1 --interpolation=none --basic-angle=as-input +# grib_get assertions +gridType=regular_ll +Ni=2 +Nj=2 +basicAngleOfTheInitialProductionDomain=360 +subdivisionsOfBasicAngle=1728 +iDirectionIncrement=6 +jDirectionIncrement=4 +latitudeOfFirstGridPoint=2 +longitudeOfFirstGridPoint=1725 +latitudeOfLastGridPoint=-2 +longitudeOfLastGridPoint=3 +iDirectionIncrementInDegrees=1.25 +jDirectionIncrementInDegrees=0.833333 +latitudeOfFirstGridPointInDegrees=0.416667 +longitudeOfFirstGridPointInDegrees=359.375 +latitudeOfLastGridPointInDegrees=-0.416667 +longitudeOfLastGridPointInDegrees=0.625 diff -Nru metview-5.17.4/mir/tests/assertions/MIR-595.006.core.test metview-5.19.2/mir/tests/assertions/MIR-595.006.core.test --- metview-5.17.4/mir/tests/assertions/MIR-595.006.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/MIR-595.006.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,22 @@ +# mars +ukmo-tigge.count=4.grib +# mir +--area=1/-1/-1/1 --interpolation=none --basic-angle=fraction +# grib_get assertions +gridType=regular_ll +Ni=2 +Nj=2 +basicAngleOfTheInitialProductionDomain=5 +subdivisionsOfBasicAngle=24 +iDirectionIncrement=6 +jDirectionIncrement=4 +latitudeOfFirstGridPoint=2 +longitudeOfFirstGridPoint=1725 +latitudeOfLastGridPoint=-2 +longitudeOfLastGridPoint=3 +iDirectionIncrementInDegrees=1.25 +jDirectionIncrementInDegrees=0.833333 +latitudeOfFirstGridPointInDegrees=0.416667 +longitudeOfFirstGridPointInDegrees=359.375 +latitudeOfLastGridPointInDegrees=-0.416667 +longitudeOfLastGridPointInDegrees=0.625 Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/assertions/packingType=grid_simple.grib1 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/assertions/packingType=grid_simple.grib1 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/assertions/packingType=spectral_complex,param=vo_d.grib1 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/assertions/packingType=spectral_complex,param=vo_d.grib1 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/assertions/packingType=spectral_complex,param=vo_d.grib2 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/assertions/packingType=spectral_complex,param=vo_d.grib2 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/assertions/param=z,level=1,levtype=ml,resol=20 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/assertions/param=z,level=1,levtype=ml,resol=20 differ diff -Nru metview-5.17.4/mir/tests/assertions/PGEN-496.core.test metview-5.19.2/mir/tests/assertions/PGEN-496.core.test --- metview-5.17.4/mir/tests/assertions/PGEN-496.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/assertions/PGEN-496.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,7 @@ +# PGEN-496 ensure handling of (gridded input) + RESOL=AV (--intgrid=source --truncation=none) +# mars +regular_ll.2-2.grib1 +# mir +--grid=2/2 --truncation=none +# grib_get + Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/assertions/ukmo-tigge.count=4.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/assertions/ukmo-tigge.count=4.grib differ diff -Nru metview-5.17.4/mir/tests/CMakeLists.txt metview-5.19.2/mir/tests/CMakeLists.txt --- metview-5.17.4/mir/tests/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -18,13 +18,10 @@ # ecCodes really doesn't build tools, so disabling testing is required if(eccodes_HAVE_BUILD_TOOLS) - if (HAVE_TEST_ASSERTIONS) - add_subdirectory(assertions) - endif() + add_subdirectory(assertions) add_subdirectory(tool) else() - message(WARNING "${PROJECT_NAME}: assertion tests (option TEST_ASSERTIONS) requires ecCodes option BUILD_TOOLS, tests disabled") - message(WARNING "${PROJECT_NAME}: tool tests requires ecCodes option BUILD_TOOLS, tests disabled") + message(WARNING "${PROJECT_NAME}: assertions/ and tool/ tests require ecCodes option BUILD_TOOLS, tests disabled") endif() Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/data/orog_1km.grib2 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/data/orog_1km.grib2 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/data/packingType=grid_simple.grib1 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/data/packingType=grid_simple.grib1 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/data/packingType=spectral_complex,param=vo_d.grib1 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/data/packingType=spectral_complex,param=vo_d.grib1 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/data/packingType=spectral_complex,param=vo_d.grib2 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/data/packingType=spectral_complex,param=vo_d.grib2 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/data/param=z,level=1,levtype=ml,resol=20 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/data/param=z,level=1,levtype=ml,resol=20 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/data/ukmo-tigge.count=4.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/data/ukmo-tigge.count=4.grib differ diff -Nru metview-5.17.4/mir/tests/plans/0000.test metview-5.19.2/mir/tests/plans/0000.test --- metview-5.17.4/mir/tests/plans/0000.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/0000.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --dont-compress-plan --area=80/-10/10/100 --grid=1/1 # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|AreaCropper[bbox=BoundingBox[north=80,west=-10,south=10,east=100]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|AreaCropper[bbox=BoundingBox[north=80,west=-10,south=10,east=100]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/0001.test metview-5.19.2/mir/tests/plans/0001.test --- metview-5.17.4/mir/tests/plans/0001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/0001.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --dont-compress-plan --grid=1/1 # plan -ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/0002.test metview-5.19.2/mir/tests/plans/0002.test --- metview-5.17.4/mir/tests/plans/0002.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/0002.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --dont-compress-plan --area=80/-10/10/100 --grid=1/1 --accuracy=8 --packing=so # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|AreaCropper[bbox=BoundingBox[north=80,west=-10,south=10,east=100]]|Save[packing=second-order,accuracy=8,output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|AreaCropper[bbox=BoundingBox[north=80,west=-10,south=10,east=100]]|Save[packing=second-order,accuracy=8,output=...] diff -Nru metview-5.17.4/mir/tests/plans/CMakeLists.txt metview-5.19.2/mir/tests/plans/CMakeLists.txt --- metview-5.17.4/mir/tests/plans/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -24,3 +24,14 @@ ENVIRONMENT ${_testEnvironment}) endforeach() endif() + +set(_t ${CMAKE_CURRENT_SOURCE_DIR}/config) +ecbuild_add_test( + TARGET ${_t} + CONDITION MARS_SCRIPT + COMMAND mir-test.sh + ARGS ${_t}.x + ENVIRONMENT ${_testEnvironment} + MIR_CONFIG_AREA=${_t}/area.yaml + MIR_CONFIG_PARAMETERS=${_t}/parameters.yaml) + diff -Nru metview-5.17.4/mir/tests/plans/config/area.yaml metview-5.19.2/mir/tests/plans/config/area.yaml --- metview-5.17.4/mir/tests/plans/config/area.yaml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/config/area.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,2 @@ +--- +custom: [46., 12., 41.5, 19.] diff -Nru metview-5.17.4/mir/tests/plans/config/parameters.yaml metview-5.19.2/mir/tests/plans/config/parameters.yaml --- metview-5.17.4/mir/tests/plans/config/parameters.yaml 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/config/parameters.yaml 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,3 @@ +--- +133: + interpolation: fail diff -Nru metview-5.17.4/mir/tests/plans/config.x metview-5.19.2/mir/tests/plans/config.x --- metview-5.17.4/mir/tests/plans/config.x 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/config.x 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,6 @@ +# mars +regular_ll.2-2.grib2 +# mir (env. set by cmake) +--grid=3/3 --area=custom +# plan +Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=89.5,west=0,south=-87.5,east=357],interpolation=fail,method=FailMethod[]]|AreaCropper[bbox=BoundingBox[north=46,west=12,south=41.5,east=19]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/different-interpolation-methods.0000.test metview-5.19.2/mir/tests/plans/different-interpolation-methods.0000.test --- metview-5.17.4/mir/tests/plans/different-interpolation-methods.0000.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/different-interpolation-methods.0000.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,6 +4,6 @@ --grid=3/3 --area=3/0/0/3 # plan Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=nearest-neighbour,method=KNearestNeighbours[nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=3,west=0,south=0,east=3],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,nearestMethod=NearestNeighbourWithLowestIndex[nclosest=4],distanceWeighting=InverseDistanceWeightingSquared[]]]|Save[output=...] -Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=3,west=0,south=0,east=3],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=3,west=0,south=0,east=3],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=nearest-neighbour,method=KNearestNeighbours[nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=3,west=0,south=0,east=3],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,nearestMethod=NearestNeighbourWithLowestIndex[nclosest=4],distanceWeighting=InverseDistanceWeightingSquared[]]]|Save[output=...] -Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=3,west=0,south=0,east=3],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=3,west=0,south=0,east=3],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/different-interpolation-methods.0001.test metview-5.19.2/mir/tests/plans/different-interpolation-methods.0001.test --- metview-5.17.4/mir/tests/plans/different-interpolation-methods.0001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/different-interpolation-methods.0001.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,6 +4,6 @@ --grid=3/3 --area=3/0/0/3 --dont-compress-plan # plan Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=nearest-neighbour,method=KNearestNeighbours[nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,nearestMethod=NearestNeighbourWithLowestIndex[nclosest=4],distanceWeighting=InverseDistanceWeightingSquared[]]]|AreaCropper[bbox=BoundingBox[north=3,west=0,south=0,east=3]]|Save[output=...] -Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|AreaCropper[bbox=BoundingBox[north=3,west=0,south=0,east=3]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|AreaCropper[bbox=BoundingBox[north=3,west=0,south=0,east=3]]|Save[output=...] Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=nearest-neighbour,method=KNearestNeighbours[nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,nearestMethod=NearestNeighbourWithLowestIndex[nclosest=4],distanceWeighting=InverseDistanceWeightingSquared[]]]|AreaCropper[bbox=BoundingBox[north=3,west=0,south=0,east=3]]|Save[output=...] -Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|AreaCropper[bbox=BoundingBox[north=3,west=0,south=0,east=3]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|AreaCropper[bbox=BoundingBox[north=3,west=0,south=0,east=3]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-grid=veryfine-1.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-grid=veryfine-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-grid=veryfine-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-grid=veryfine-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,4 +4,4 @@ # mir --grid=0.1/0.1 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F900]|Gridded2RegularLL[increments=Increments[west_east=0.1,south_north=0.1],bbox=BoundingBox[north=90,west=0,south=-90,east=359.9],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F900]|Gridded2RegularLL[increments=Increments[west_east=0.1,south_north=0.1],bbox=BoundingBox[north=90,west=0,south=-90,east=359.9],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-grid=veryfine-2.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-grid=veryfine-2.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-grid=veryfine-2.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-grid=veryfine-2.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,4 +4,4 @@ # mir --grid=0.01/0.01 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F1280]|Gridded2RegularLL[increments=Increments[west_east=0.01,south_north=0.01],bbox=BoundingBox[north=90,west=0,south=-90,east=359.99],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F1280]|Gridded2RegularLL[increments=Increments[west_east=0.01,south_north=0.01],bbox=BoundingBox[north=90,west=0,south=-90,east=359.99],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar.test metview-5.19.2/mir/tests/plans/MIR-219-scalar.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=255-intgrid=auto-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=255-intgrid=auto-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=255-intgrid=auto-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=255-intgrid=auto-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --truncation=255 --intgrid=auto --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=255]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=255]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=255-intgrid=O320-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=255-intgrid=O320-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=255-intgrid=O320-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=255-intgrid=O320-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --truncation=255 --intgrid=O320 --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=255]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O320]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=255]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O320]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=399-intgrid=auto-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=399-intgrid=auto-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=399-intgrid=auto-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=399-intgrid=auto-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,4 +4,4 @@ # mir --truncation=399 --intgrid=auto --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=399]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=399]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=auto-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=auto-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=auto-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=auto-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --truncation=auto --intgrid=auto --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=auto-grid=N80.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=auto-grid=N80.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=auto-grid=N80.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=auto-grid=N80.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --truncation=auto --intgrid=auto --grid=N80 --dont-compress-plan # plan -ShTruncate[truncation=159]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F80]|Gridded2NamedGrid[grid=N80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=159]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F80]|Gridded2NamedGrid[grid=N80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=O320-grid=2-2.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=O320-grid=2-2.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=O320-grid=2-2.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=auto-intgrid=O320-grid=2-2.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --truncation=auto --intgrid=O320 --grid=2/2 --dont-compress-plan # plan -ShTruncate[truncation=639]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O320]|Gridded2RegularLL[increments=Increments[west_east=2,south_north=2],bbox=BoundingBox[north=90,west=0,south=-90,east=358],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=639]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O320]|Gridded2RegularLL[increments=Increments[west_east=2,south_north=2],bbox=BoundingBox[north=90,west=0,south=-90,east=358],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=none-intgrid=auto-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=none-intgrid=auto-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=none-intgrid=auto-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=none-intgrid=auto-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --truncation=none --intgrid=auto --grid=1/1 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=none-intgrid=O400-grid=O200.test metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=none-intgrid=O400-grid=O200.test --- metview-5.17.4/mir/tests/plans/MIR-219-scalar-truncation=none-intgrid=O400-grid=O200.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-scalar-truncation=none-intgrid=O400-grid=O200.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --truncation=none --intgrid=O400 --grid=O200 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O400]|Gridded2NamedGrid[grid=O200,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O400]|Gridded2NamedGrid[grid=O200,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --vod2uv --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=255-intgrid=auto-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=255-intgrid=auto-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=255-intgrid=auto-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=255-intgrid=auto-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --vod2uv --truncation=255 --intgrid=auto --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=255]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=255]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=255-intgrid=O320-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=255-intgrid=O320-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=255-intgrid=O320-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=255-intgrid=O320-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --vod2uv --truncation=255 --intgrid=O320 --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=255]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O320]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=255]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O320]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=auto-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=auto-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=auto-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=auto-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --vod2uv --truncation=auto --intgrid=auto --grid=1/1 --dont-compress-plan # plan -ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=179]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=auto-grid=N80.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=auto-grid=N80.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=auto-grid=N80.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=auto-grid=N80.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --vod2uv --truncation=auto --intgrid=auto --grid=N80 --dont-compress-plan # plan -ShTruncate[truncation=159]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F80]|Gridded2NamedGrid[grid=N80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=159]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F80]|Gridded2NamedGrid[grid=N80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=O320-grid=2-2.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=O320-grid=2-2.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=O320-grid=2-2.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=auto-intgrid=O320-grid=2-2.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --vod2uv --truncation=auto --intgrid=O320 --grid=2/2 --dont-compress-plan # plan -ShTruncate[truncation=639]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O320]|Gridded2RegularLL[increments=Increments[west_east=2,south_north=2],bbox=BoundingBox[north=90,west=0,south=-90,east=358],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=639]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O320]|Gridded2RegularLL[increments=Increments[west_east=2,south_north=2],bbox=BoundingBox[north=90,west=0,south=-90,east=358],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=none-intgrid=auto-grid=1-1.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=none-intgrid=auto-grid=1-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=none-intgrid=auto-grid=1-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=none-intgrid=auto-grid=1-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --vod2uv --truncation=none --intgrid=auto --grid=1/1 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F90]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=none-intgrid=O400-grid=O200.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=none-intgrid=O400-grid=O200.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-truncation=none-intgrid=O400-grid=O200.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-truncation=none-intgrid=O400-grid=O200.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --vod2uv --truncation=none --intgrid=O400 --grid=O200 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O400]|Gridded2NamedGrid[grid=O200,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O400]|Gridded2NamedGrid[grid=O200,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-veryfine-1.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-veryfine-1.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-veryfine-1.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-veryfine-1.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,4 +4,4 @@ # mir --vod2uv --grid=0.1/0.1 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F900]|Gridded2RegularLL[increments=Increments[west_east=0.1,south_north=0.1],bbox=BoundingBox[north=90,west=0,south=-90,east=359.9],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F900]|Gridded2RegularLL[increments=Increments[west_east=0.1,south_north=0.1],bbox=BoundingBox[north=90,west=0,south=-90,east=359.9],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-veryfine-2.test metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-veryfine-2.test --- metview-5.17.4/mir/tests/plans/MIR-219-vod2uv-veryfine-2.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-219-vod2uv-veryfine-2.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,4 +4,4 @@ # mir --vod2uv --grid=0.01/0.01 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F1280]|Gridded2RegularLL[increments=Increments[west_east=0.01,south_north=0.01],bbox=BoundingBox[north=90,west=0,south=-90,east=359.99],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F1280]|Gridded2RegularLL[increments=Increments[west_east=0.01,south_north=0.01],bbox=BoundingBox[north=90,west=0,south=-90,east=359.99],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-239-gridname=O640.test metview-5.19.2/mir/tests/plans/MIR-239-gridname=O640.test --- metview-5.17.4/mir/tests/plans/MIR-239-gridname=O640.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-239-gridname=O640.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,4 +4,4 @@ # mir --intgrid=auto --grid=O640 --dont-compress-plan # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F640]|Gridded2NamedGrid[grid=O640,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F640]|Gridded2NamedGrid[grid=O640,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-239-gridname=O64.test metview-5.19.2/mir/tests/plans/MIR-239-gridname=O64.test --- metview-5.17.4/mir/tests/plans/MIR-239-gridname=O64.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-239-gridname=O64.test 2023-07-15 08:28:47.000000000 +0000 @@ -4,4 +4,4 @@ # mir --intgrid=auto --grid=O64 --dont-compress-plan # plan -ShTruncate[truncation=127]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F64]|Gridded2NamedGrid[grid=O64,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=127]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F64]|Gridded2NamedGrid[grid=O64,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-294.uv2uv=false.test metview-5.19.2/mir/tests/plans/MIR-294.uv2uv=false.test --- metview-5.17.4/mir/tests/plans/MIR-294.uv2uv=false.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-294.uv2uv=false.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,5 +3,5 @@ # mir --grid=1/1 --rotation=-89/1 --uv2uv=false # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|AdjustWindsScaleCosLatitude[]|AdjustWindsDirections[rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0]]|Save[packing=simple,output=...] -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|AdjustWindsScaleCosLatitude[]|AdjustWindsDirections[rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|AdjustWindsScaleCosLatitude[]|AdjustWindsDirections[rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|AdjustWindsScaleCosLatitude[]|AdjustWindsDirections[rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-294.uv2uv=true.test metview-5.19.2/mir/tests/plans/MIR-294.uv2uv=true.test --- metview-5.17.4/mir/tests/plans/MIR-294.uv2uv=true.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-294.uv2uv=true.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/1 --rotation=-89/1 --uv2uv=true # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|AdjustWindsScaleCosLatitude[]|AdjustWindsDirections[rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|AdjustWindsScaleCosLatitude[]|AdjustWindsDirections[rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-294.vod2uv=false.test metview-5.19.2/mir/tests/plans/MIR-294.vod2uv=false.test --- metview-5.17.4/mir/tests/plans/MIR-294.vod2uv=false.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-294.vod2uv=false.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,5 +3,5 @@ # mir --grid=1/1 --rotation=-89/1 --vod2uv=false # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-294.vod2uv=true.test metview-5.19.2/mir/tests/plans/MIR-294.vod2uv=true.test --- metview-5.17.4/mir/tests/plans/MIR-294.vod2uv=true.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-294.vod2uv=true.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/1 --rotation=-89/1 --vod2uv=true # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|AdjustWindsDirections[rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RotatedLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|AdjustWindsDirections[rotation=Rotation[south_pole_latitude=-89,south_pole_longitude=1,south_pole_rotation_angle=0]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-309.001.test metview-5.19.2/mir/tests/plans/MIR-309.001.test --- metview-5.17.4/mir/tests/plans/MIR-309.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-309.001.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --area=28/-77/3/-43 --globalise --grid=1/1 # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=28,west=-77,south=3,east=-43],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=28,west=-77,south=3,east=-43],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-309.002.test metview-5.19.2/mir/tests/plans/MIR-309.002.test --- metview-5.17.4/mir/tests/plans/MIR-309.002.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-309.002.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --area=28/-77/3/-43 --globalise --grid=1/1 --dont-compress-plan # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|GlobaliseFilter[]|AreaCropper[bbox=BoundingBox[north=28,west=-77,south=3,east=-43]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|GlobaliseFilter[]|AreaCropper[bbox=BoundingBox[north=28,west=-77,south=3,east=-43]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-323.002.test metview-5.19.2/mir/tests/plans/MIR-323.002.test --- metview-5.17.4/mir/tests/plans/MIR-323.002.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-323.002.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/0.25 # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=0.25],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=0.25],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-361.001.test metview-5.19.2/mir/tests/plans/MIR-361.001.test --- metview-5.17.4/mir/tests/plans/MIR-361.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-361.001.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --area=50/-21/25/6 # plan -Gridded2RegularLL[increments=Increments[west_east=0.35,south_north=0.35],bbox=BoundingBox[north=89.75,west=-21,south=-89.8,east=338.8],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=50,west=-21,south=25,east=6],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=0.35,south_north=0.35],bbox=BoundingBox[north=89.75,west=-21,south=-89.8,east=338.8],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=50,west=-21,south=25,east=6],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-361.003.test metview-5.19.2/mir/tests/plans/MIR-361.003.test --- metview-5.17.4/mir/tests/plans/MIR-361.003.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-361.003.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --area=85/-80/25/40 # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=85,west=-80,south=25,east=40],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=85,west=-80,south=25,east=40],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-361.007.test metview-5.19.2/mir/tests/plans/MIR-361.007.test --- metview-5.17.4/mir/tests/plans/MIR-361.007.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-361.007.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --rotation=30/30 # plan -Gridded2RotatedLL[increments=Increments[west_east=2,south_north=2],bbox=BoundingBox[north=90,west=0,south=-90,east=358],rotation=Rotation[south_pole_latitude=30,south_pole_longitude=30,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RotatedLL[increments=Increments[west_east=2,south_north=2],bbox=BoundingBox[north=90,west=0,south=-90,east=358],rotation=Rotation[south_pole_latitude=30,south_pole_longitude=30,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-361.010.test metview-5.19.2/mir/tests/plans/MIR-361.010.test --- metview-5.17.4/mir/tests/plans/MIR-361.010.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-361.010.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --rotation=10/10 # plan -Gridded2RotatedLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],rotation=Rotation[south_pole_latitude=10,south_pole_longitude=10,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RotatedLL[increments=Increments[west_east=3,south_north=3],bbox=BoundingBox[north=90,west=0,south=-90,east=357],rotation=Rotation[south_pole_latitude=10,south_pole_longitude=10,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-361.011.test metview-5.19.2/mir/tests/plans/MIR-361.011.test --- metview-5.17.4/mir/tests/plans/MIR-361.011.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-361.011.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --area=89.5/-179.5/-89.5/179.5 # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=89.5,west=0.5,south=-89.5,east=359.5],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=89.5,west=-179.5,south=-89.5,east=179.5],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=89.5,west=0.5,south=-89.5,east=359.5],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=89.5,west=-179.5,south=-89.5,east=179.5],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-361.012.test metview-5.19.2/mir/tests/plans/MIR-361.012.test --- metview-5.17.4/mir/tests/plans/MIR-361.012.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-361.012.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/1 --area=89.5/-179.5/-89.5/179.5 # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=89.5,west=0.5,south=-89.5,east=359.5],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=89.5,west=-179.5,south=-89.5,east=179.5],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=89.5,west=0.5,south=-89.5,east=359.5],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=89.5,west=-179.5,south=-89.5,east=179.5],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-361.013.test metview-5.19.2/mir/tests/plans/MIR-361.013.test --- metview-5.17.4/mir/tests/plans/MIR-361.013.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-361.013.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=2/2 # plan -Gridded2RegularLL[increments=Increments[west_east=2,south_north=2],bbox=BoundingBox[north=90,west=0,south=-90,east=358],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=2,south_north=2],bbox=BoundingBox[north=90,west=0,south=-90,east=358],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-361.015.test metview-5.19.2/mir/tests/plans/MIR-361.015.test --- metview-5.17.4/mir/tests/plans/MIR-361.015.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-361.015.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=4/4 # plan -Gridded2RegularLL[increments=Increments[west_east=4,south_north=4],bbox=BoundingBox[north=88,west=0,south=-88,east=356],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2RegularLL[increments=Increments[west_east=4,south_north=4],bbox=BoundingBox[north=88,west=0,south=-88,east=356],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-380.O16-to-laea.test metview-5.19.2/mir/tests/plans/MIR-380.O16-to-laea.test --- metview-5.17.4/mir/tests/plans/MIR-380.O16-to-laea.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-380.O16-to-laea.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=gridType=lambert_azimuthal_equal_area\;grid=5000./5000.\;standardParallelInDegrees=52.\;centralLongitudeInDegrees=10.\;latitudeOfFirstGridPointInDegrees=66.982143\;longitudeOfFirstGridPointInDegrees=-35.034024\;Ni=1000\;Nj=950\;gaussianNumber=1280 # plan -Gridded2TypedGrid[grid={"Ni":"1000","Nj":"950","centralLongitudeInDegrees":"10.","gaussianNumber":"1280","grid":"5000./5000.","gridType":"lambert_azimuthal_equal_area","latitudeOfFirstGridPointInDegrees":"66.982143","longitudeOfFirstGridPointInDegrees":"-35.034024","standardParallelInDegrees":"52."},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2TypedGrid[grid={"Ni":"1000","Nj":"950","centralLongitudeInDegrees":"10.","gaussianNumber":"1280","grid":"5000./5000.","gridType":"lambert_azimuthal_equal_area","latitudeOfFirstGridPointInDegrees":"66.982143","longitudeOfFirstGridPointInDegrees":"-35.034024","standardParallelInDegrees":"52."},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-380.regular_ll-to-laea.test metview-5.19.2/mir/tests/plans/MIR-380.regular_ll-to-laea.test --- metview-5.17.4/mir/tests/plans/MIR-380.regular_ll-to-laea.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-380.regular_ll-to-laea.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=gridType=lambert_azimuthal_equal_area\;grid=5000./5000.\;standardParallelInDegrees=52.\;centralLongitudeInDegrees=10.\;latitudeOfFirstGridPointInDegrees=66.982143\;longitudeOfFirstGridPointInDegrees=-35.034024\;Ni=1000\;Nj=950\;gaussianNumber=1280 # plan -Gridded2TypedGrid[grid={"Ni":"1000","Nj":"950","centralLongitudeInDegrees":"10.","gaussianNumber":"1280","grid":"5000./5000.","gridType":"lambert_azimuthal_equal_area","latitudeOfFirstGridPointInDegrees":"66.982143","longitudeOfFirstGridPointInDegrees":"-35.034024","standardParallelInDegrees":"52."},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2TypedGrid[grid={"Ni":"1000","Nj":"950","centralLongitudeInDegrees":"10.","gaussianNumber":"1280","grid":"5000./5000.","gridType":"lambert_azimuthal_equal_area","latitudeOfFirstGridPointInDegrees":"66.982143","longitudeOfFirstGridPointInDegrees":"-35.034024","standardParallelInDegrees":"52."},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-380.sh-to-laea.test metview-5.19.2/mir/tests/plans/MIR-380.sh-to-laea.test --- metview-5.17.4/mir/tests/plans/MIR-380.sh-to-laea.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-380.sh-to-laea.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=gridType=lambert_azimuthal_equal_area\;grid=5000./5000.\;standardParallelInDegrees=52.\;centralLongitudeInDegrees=10.\;latitudeOfFirstGridPointInDegrees=66.982143\;longitudeOfFirstGridPointInDegrees=-35.034024\;Ni=1000\;Nj=950\;gaussianNumber=1280 # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2TypedGrid[grid={"Ni":"1000","Nj":"950","centralLongitudeInDegrees":"10.","gaussianNumber":"1280","grid":"5000./5000.","gridType":"lambert_azimuthal_equal_area","latitudeOfFirstGridPointInDegrees":"66.982143","longitudeOfFirstGridPointInDegrees":"-35.034024","standardParallelInDegrees":"52."},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2TypedGrid[grid={"Ni":"1000","Nj":"950","centralLongitudeInDegrees":"10.","gaussianNumber":"1280","grid":"5000./5000.","gridType":"lambert_azimuthal_equal_area","latitudeOfFirstGridPointInDegrees":"66.982143","longitudeOfFirstGridPointInDegrees":"-35.034024","standardParallelInDegrees":"52."},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-403.test metview-5.19.2/mir/tests/plans/MIR-403.test --- metview-5.17.4/mir/tests/plans/MIR-403.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-403.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --truncation=none --grid=0.25/0.25 --rotation=-40/22 --area=73.5/-27/33/45 # plan -ShToNamedGrid[type=local,cropping=BoundingBox[north=90,west=0,south=50.34,east=360],options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F360]|Gridded2RotatedLL[increments=Increments[west_east=0.25,south_north=0.25],bbox=BoundingBox[north=90,west=0,south=-90,east=359.75],rotation=Rotation[south_pole_latitude=-40,south_pole_longitude=22,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=73.5,west=-27,south=33,east=45],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=BoundingBox[north=90,west=0,south=50.34,east=360],options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F360]|Gridded2RotatedLL[increments=Increments[west_east=0.25,south_north=0.25],bbox=BoundingBox[north=90,west=0,south=-90,east=359.75],rotation=Rotation[south_pole_latitude=-40,south_pole_longitude=22,south_pole_rotation_angle=0],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=BoundingBox[north=73.5,west=-27,south=33,east=45],lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-454.001.test.atlas-orca metview-5.19.2/mir/tests/plans/MIR-454.001.test.atlas-orca --- metview-5.17.4/mir/tests/plans/MIR-454.001.test.atlas-orca 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-454.001.test.atlas-orca 2023-07-15 08:28:47.000000000 +0000 @@ -3,6 +3,6 @@ # mir --grid=eorca1_u # plan -Gridded2NamedGrid[grid=eORCA1_U,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2NamedGrid[grid=eORCA1_U,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] Copy[] -Gridded2NamedGrid[grid=eORCA1_U,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2NamedGrid[grid=eORCA1_U,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-454.003.test.atlas-orca metview-5.19.2/mir/tests/plans/MIR-454.003.test.atlas-orca --- metview-5.17.4/mir/tests/plans/MIR-454.003.test.atlas-orca 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-454.003.test.atlas-orca 2023-07-15 08:28:47.000000000 +0000 @@ -3,6 +3,6 @@ # mir --grid=eorca2 # plan -Gridded2NamedGrid[grid=eORCA2_T,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] -Gridded2NamedGrid[grid=eORCA2_U,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] -Gridded2NamedGrid[grid=eORCA2_V,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2NamedGrid[grid=eORCA2_T,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] +Gridded2NamedGrid[grid=eORCA2_U,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] +Gridded2NamedGrid[grid=eORCA2_V,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-459.nabla=scalar-gradient.param=z.sh.test metview-5.19.2/mir/tests/plans/MIR-459.nabla=scalar-gradient.param=z.sh.test --- metview-5.17.4/mir/tests/plans/MIR-459.nabla=scalar-gradient.param=z.sh.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-459.nabla=scalar-gradient.param=z.sh.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,5 +3,5 @@ # mir --grid=1/1 --nabla=scalar-gradient # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|ScalarGradient[meshGeneratorParameters=...]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|ScalarGradient[meshGeneratorParameters=...]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-459.nabla=scalar-laplacian.param=z.sh.test metview-5.19.2/mir/tests/plans/MIR-459.nabla=scalar-laplacian.param=z.sh.test --- metview-5.17.4/mir/tests/plans/MIR-459.nabla=scalar-laplacian.param=z.sh.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-459.nabla=scalar-laplacian.param=z.sh.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,5 +3,5 @@ # mir --grid=1/1 --nabla=scalar-laplacian # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|ScalarLaplacian[meshGeneratorParameters=...]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|ScalarLaplacian[meshGeneratorParameters=...]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-459.nabla=uv-divergence.param=vo_d.test metview-5.19.2/mir/tests/plans/MIR-459.nabla=uv-divergence.param=vo_d.test --- metview-5.17.4/mir/tests/plans/MIR-459.nabla=uv-divergence.param=vo_d.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-459.nabla=uv-divergence.param=vo_d.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,5 +3,5 @@ # mir --vod2uv --grid=1/1 --nabla=uv-divergence # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|UVDivergence[meshGeneratorParameters=...]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|UVDivergence[meshGeneratorParameters=...]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-459.nabla=uv-gradient.param=vo_d.test metview-5.19.2/mir/tests/plans/MIR-459.nabla=uv-gradient.param=vo_d.test --- metview-5.17.4/mir/tests/plans/MIR-459.nabla=uv-gradient.param=vo_d.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-459.nabla=uv-gradient.param=vo_d.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,5 +3,5 @@ # mir --vod2uv --grid=1/1 --nabla=uv-gradient # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|UVGradient[meshGeneratorParameters=...]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|UVGradient[meshGeneratorParameters=...]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-459.nabla=uv-vorticity.param=vo_d.test metview-5.19.2/mir/tests/plans/MIR-459.nabla=uv-vorticity.param=vo_d.test --- metview-5.17.4/mir/tests/plans/MIR-459.nabla=uv-vorticity.param=vo_d.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-459.nabla=uv-vorticity.param=vo_d.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,5 +3,5 @@ # mir --vod2uv --grid=1/1 --nabla=uv-vorticity # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|UVVorticity[meshGeneratorParameters=...]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|UVVorticity[meshGeneratorParameters=...]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-474.O16-to-lambert.test metview-5.19.2/mir/tests/plans/MIR-474.O16-to-lambert.test --- metview-5.17.4/mir/tests/plans/MIR-474.O16-to-lambert.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-474.O16-to-lambert.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=gridType=lambert\;grid=2500./2500.\;writeLaDInDegrees=0\;LaDInDegrees=45.8\;LoVInDegrees=2.\;latitudeOfFirstGridPointInDegrees=37.333\;longitudeOfFirstGridPointInDegrees=-8.354\;Ni=1000\;Nj=950\;gaussianNumber=1280 # plan -Gridded2TypedGrid[grid={"LaDInDegrees":"45.8","LoVInDegrees":"2.","Ni":"1000","Nj":"950","gaussianNumber":"1280","grid":"2500./2500.","gridType":"lambert","latitudeOfFirstGridPointInDegrees":"37.333","longitudeOfFirstGridPointInDegrees":"-8.354","writeLaDInDegrees":"0"},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2TypedGrid[grid={"LaDInDegrees":"45.8","LoVInDegrees":"2.","Ni":"1000","Nj":"950","gaussianNumber":"1280","grid":"2500./2500.","gridType":"lambert","latitudeOfFirstGridPointInDegrees":"37.333","longitudeOfFirstGridPointInDegrees":"-8.354","writeLaDInDegrees":"0"},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-474.regular_ll-to-lambert.test metview-5.19.2/mir/tests/plans/MIR-474.regular_ll-to-lambert.test --- metview-5.17.4/mir/tests/plans/MIR-474.regular_ll-to-lambert.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-474.regular_ll-to-lambert.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=gridType=lambert\;grid=2500./2500.\;writeLaDInDegrees=1\;LaDInDegrees=45.8\;LoVInDegrees=2.\;latitudeOfFirstGridPointInDegrees=37.333\;longitudeOfFirstGridPointInDegrees=-8.354\;Ni=1000\;Nj=950\;gaussianNumber=1280 # plan -Gridded2TypedGrid[grid={"LaDInDegrees":"45.8","LoVInDegrees":"2.","Ni":"1000","Nj":"950","gaussianNumber":"1280","grid":"2500./2500.","gridType":"lambert","latitudeOfFirstGridPointInDegrees":"37.333","longitudeOfFirstGridPointInDegrees":"-8.354","writeLaDInDegrees":"1"},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2TypedGrid[grid={"LaDInDegrees":"45.8","LoVInDegrees":"2.","Ni":"1000","Nj":"950","gaussianNumber":"1280","grid":"2500./2500.","gridType":"lambert","latitudeOfFirstGridPointInDegrees":"37.333","longitudeOfFirstGridPointInDegrees":"-8.354","writeLaDInDegrees":"1"},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-474.sh-to-lambert.test metview-5.19.2/mir/tests/plans/MIR-474.sh-to-lambert.test --- metview-5.17.4/mir/tests/plans/MIR-474.sh-to-lambert.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-474.sh-to-lambert.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=gridType=lambert\;grid=2500./2500.\;writeLaDInDegrees=0\;LaDInDegrees=45.8\;LoVInDegrees=2.\;latitudeOfFirstGridPointInDegrees=37.333\;longitudeOfFirstGridPointInDegrees=-8.354\;Ni=1000\;Nj=950\;gaussianNumber=1280 # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2TypedGrid[grid={"LaDInDegrees":"45.8","LoVInDegrees":"2.","Ni":"1000","Nj":"950","gaussianNumber":"1280","grid":"2500./2500.","gridType":"lambert","latitudeOfFirstGridPointInDegrees":"37.333","longitudeOfFirstGridPointInDegrees":"-8.354","writeLaDInDegrees":"0"},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=F21]|Gridded2TypedGrid[grid={"LaDInDegrees":"45.8","LoVInDegrees":"2.","Ni":"1000","Nj":"950","gaussianNumber":"1280","grid":"2500./2500.","gridType":"lambert","latitudeOfFirstGridPointInDegrees":"37.333","longitudeOfFirstGridPointInDegrees":"-8.354","writeLaDInDegrees":"0"},interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-487.006.test metview-5.19.2/mir/tests/plans/MIR-487.006.test --- metview-5.17.4/mir/tests/plans/MIR-487.006.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-487.006.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --packing=ieee --grid=1/1 # plan -Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=nearest-neighbour,method=KNearestNeighbours[nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,nearestMethod=NearestNeighbourWithLowestIndex[nclosest=4],distanceWeighting=InverseDistanceWeightingSquared[]]]|Save[packing=ieee,edition=2,precision=1,output=...] +Gridded2RegularLL[increments=Increments[west_east=1,south_north=1],bbox=BoundingBox[north=90,west=0,south=-90,east=359],interpolation=nearest-neighbour,method=KNearestNeighbours[nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,nearestMethod=NearestNeighbourWithLowestIndex[nclosest=4],distanceWeighting=InverseDistanceWeightingSquared[]]]|Save[packing=ieee,precision=1,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-497.001.test metview-5.19.2/mir/tests/plans/MIR-497.001.test --- metview-5.17.4/mir/tests/plans/MIR-497.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-497.001.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --intgrid=source --grid=O80 # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O1280]|Gridded2NamedGrid[grid=O80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O1280]|Gridded2NamedGrid[grid=O80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-497.002.test metview-5.19.2/mir/tests/plans/MIR-497.002.test --- metview-5.17.4/mir/tests/plans/MIR-497.002.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-497.002.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --intgrid=source --truncation=159 --grid=O80 # plan -ShTruncate[truncation=159]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O160]|Gridded2NamedGrid[grid=O80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShTruncate[truncation=159]|ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O160]|Gridded2NamedGrid[grid=O80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-497.003.test metview-5.19.2/mir/tests/plans/MIR-497.003.test --- metview-5.17.4/mir/tests/plans/MIR-497.003.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-497.003.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --intgrid=source --truncation=auto --grid=O80 # plan -ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O1280]|Gridded2NamedGrid[grid=O80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[packing=simple,output=...] +ShToNamedGrid[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,grid=O1280]|Gridded2NamedGrid[grid=O80,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-510.001.test metview-5.19.2/mir/tests/plans/MIR-510.001.test --- metview-5.17.4/mir/tests/plans/MIR-510.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-510.001.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=O64 # plan -Gridded2NamedGrid[grid=O64,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2NamedGrid[grid=O64,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-510.002.test metview-5.19.2/mir/tests/plans/MIR-510.002.test --- metview-5.17.4/mir/tests/plans/MIR-510.002.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-510.002.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=o64 # plan -Gridded2NamedGrid[grid=O64,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,missingValueOnProjectionFail=1]]|Save[output=...] +Gridded2NamedGrid[grid=O64,interpolation=linear,method=FiniteElement[name=linear,nonLinear[MissingIfHeaviestMissing[]],Solver=Multiply[],cropping=none,lsmWeightAdjustment=0.2,pruneEpsilon=1e-10,validateMesh=0,projectionFail=missing-value]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.001.test metview-5.19.2/mir/tests/plans/MIR-513.001.test --- metview-5.17.4/mir/tests/plans/MIR-513.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.001.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -# mars -param=vo_d,level=1000,resol=20.SPECIAL -# mir ---grid=1/1 --intgrid=none --vod2uv --packing=av -# plan -ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=complex,edition=2,output=...] -ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=simple,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.001.test metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.001.test --- metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.001.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.001.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none --packing=complex -# plan -ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=complex,edition=2,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.003.test metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.003.test --- metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.003.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.003.test 2023-07-15 08:28:47.000000000 +0000 @@ -1,6 +1,6 @@ # mars packingType=spectral_complex.grib1 # mir ---grid=1/1 --intgrid=none --packing=ccsds +--grid=1/1 --intgrid=none --packing=ccsds --grib-edition-conversion=true # plan ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ccsds,edition=2,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.004.test metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.004.test --- metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.004.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.004.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/1 --intgrid=none --packing=ieee # plan -ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ieee,edition=2,precision=1,output=...] +ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ieee,precision=1,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.005.test metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.005.test --- metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.005.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.005.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/1 --intgrid=none --packing=ieee --accuracy=32 # plan -ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ieee,edition=2,accuracy=32,precision=1,output=...] +ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ieee,accuracy=32,precision=1,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.007.test metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.007.test --- metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_complex.007.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_complex.007.test 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -# mars -packingType=spectral_complex.grib1 -# mir ---grid=1/1 --intgrid=none --packing=av -# plan -ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=complex,edition=2,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_simple.003.test metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_simple.003.test --- metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_simple.003.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_simple.003.test 2023-07-15 08:28:47.000000000 +0000 @@ -1,6 +1,6 @@ # mars packingType=spectral_simple.grib1 # mir ---grid=1/1 --intgrid=none --packing=ccsds +--grid=1/1 --intgrid=none --packing=ccsds --grib-edition-conversion=true # plan ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ccsds,edition=2,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_simple.004.test metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_simple.004.test --- metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_simple.004.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_simple.004.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/1 --intgrid=none --packing=ieee # plan -ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ieee,edition=2,precision=1,output=...] +ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ieee,precision=1,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_simple.005.test metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_simple.005.test --- metview-5.17.4/mir/tests/plans/MIR-513.packingType=spectral_simple.005.test 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-513.packingType=spectral_simple.005.test 2023-07-15 08:28:47.000000000 +0000 @@ -3,4 +3,4 @@ # mir --grid=1/1 --intgrid=none --packing=ieee --accuracy=32 # plan -ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ieee,edition=2,accuracy=32,precision=1,output=...] +ShToRegularLL[type=local,cropping=none,options=[4886829aa871a5c38f41fff09ed0970e],invtrans=,bbox=BoundingBox[north=90,west=0,south=-90,east=360],increments=Increments[west_east=1,south_north=1]]|Save[packing=ieee,accuracy=32,precision=1,output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-527.test metview-5.19.2/mir/tests/plans/MIR-527.test --- metview-5.17.4/mir/tests/plans/MIR-527.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-527.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,6 @@ +# mars +param=t,level=1000,resol=20 +# mir +--cesaro --cesaro-k=2 --cesaro-truncation=10 +# plan +CesaroSummationFilter[k=2,truncation=10]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-586.test metview-5.19.2/mir/tests/plans/MIR-586.test --- metview-5.17.4/mir/tests/plans/MIR-586.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-586.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,6 @@ +# mars +regular_ll.2-2.grib1 +# mir +--area=11/-1/-1/11 --interpolation=none +# plan +AreaCropper[bbox=BoundingBox[north=11,west=-1,south=-1,east=11]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-595.001.core.test metview-5.19.2/mir/tests/plans/MIR-595.001.core.test --- metview-5.17.4/mir/tests/plans/MIR-595.001.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-595.001.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,6 @@ +# mars +ukmo-tigge.count=4.grib +# mir +--area=43/-1/-10/3 --interpolation=none +# grib_get assertions +AreaCropper[bbox=BoundingBox[north=43,west=-1,south=-10,east=3]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-595.002.core.test metview-5.19.2/mir/tests/plans/MIR-595.002.core.test --- metview-5.17.4/mir/tests/plans/MIR-595.002.core.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-595.002.core.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,6 @@ +# mars +ukmo-tigge.count=4.grib +# mir +--area=1/-1/-1/1 --interpolation=none +# grib_get assertions +AreaCropper[bbox=BoundingBox[north=1,west=-1,south=-1,east=1]]|Save[output=...] diff -Nru metview-5.17.4/mir/tests/plans/MIR-597.test metview-5.19.2/mir/tests/plans/MIR-597.test --- metview-5.17.4/mir/tests/plans/MIR-597.test 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/plans/MIR-597.test 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,6 @@ +# mars +param=t,level=1000,resol=20 +# mir +--bandpass=1/5/2/6 +# plan +Bandpass[M=1/5,N=2/6]|Save[output=...] Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/plans/ukmo-tigge.count=4.grib and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/plans/ukmo-tigge.count=4.grib differ diff -Nru metview-5.17.4/mir/tests/unit/action_graph.cc metview-5.19.2/mir/tests/unit/action_graph.cc --- metview-5.17.4/mir/tests/unit/action_graph.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/action_graph.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,7 @@ // define EXPECTV(a) log << "\tEXPECT(" << #a <<")" << std::endl; EXPECT(a) -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { struct TestWatcher : api::MIRWatcher { @@ -108,9 +106,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/area.cc metview-5.19.2/mir/tests/unit/area.cc --- metview-5.17.4/mir/tests/unit/area.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/area.cc 2023-07-15 08:28:47.000000000 +0000 @@ -16,9 +16,7 @@ #include "mir/util/BoundingBox.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("Area") { @@ -48,9 +46,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/atlas.cc metview-5.19.2/mir/tests/unit/atlas.cc --- metview-5.17.4/mir/tests/unit/atlas.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/atlas.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { using Handle = repres::RepresentationHandle; @@ -137,9 +135,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/bounding_box.cc metview-5.19.2/mir/tests/unit/bounding_box.cc --- metview-5.17.4/mir/tests/unit/bounding_box.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/bounding_box.cc 2023-07-15 08:28:47.000000000 +0000 @@ -11,11 +11,13 @@ #include +#include #include #include "eckit/testing/Test.h" #include "mir/api/mir_config.h" +#include "mir/input/GribFileInput.h" #include "mir/key/grid/Grid.h" #include "mir/repres/Representation.h" #include "mir/util/BoundingBox.h" @@ -25,13 +27,10 @@ // define EXPECTV(a) log << "\tEXPECT(" << #a <<")" << std::endl; EXPECT(a) -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("BoundingBox") { - using util::BoundingBox; auto& log = Log::info(); @@ -97,7 +96,6 @@ }; SECTION("operator==") { - std::vector _delta{Longitude::GLOBE * -2, Longitude::GLOBE * -1, Longitude::GREENWICH, Longitude::GLOBE, Longitude::GLOBE * 2}; @@ -214,7 +212,6 @@ } SECTION("intersects (point)") { - std::vector _lat{-90, -89, -88, 2, 1, 0, 1, 2, 88, 89, 90}; std::vector _lon{ -360, -358, -182, -180, -178, -2, 0, 2, 178, 180, 182, 358, 360, 362, 718, 720, 722, @@ -295,7 +292,6 @@ CASE("Representation::extendBoundingBox") { - using key::grid::Grid; using util::BoundingBox; @@ -331,9 +327,25 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +CASE("IFS climate files") { + std::unique_ptr in(new input::GribFileInput("orog_1km.grib2")); + ASSERT(in->next()); + + util::BoundingBox bbox(in->parametrisation()); + + for (const auto& test : { + std::make_pair(bbox.north().fraction(), eckit::Fraction(21599, 240)), + std::make_pair(bbox.west().fraction(), eckit::Fraction(1, 240)), + std::make_pair(bbox.south().fraction(), eckit::Fraction(-21599, 240)), + std::make_pair(bbox.east().fraction(), eckit::Fraction(86399, 240)), + }) { + Log::info() << test.first << " == " << test.second << std::endl; + EXPECT_EQUAL(test.first, test.second); + } +} + + +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/CMakeLists.txt metview-5.19.2/mir/tests/unit/CMakeLists.txt --- metview-5.17.4/mir/tests/unit/CMakeLists.txt 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/CMakeLists.txt 2023-07-15 08:28:47.000000000 +0000 @@ -9,16 +9,22 @@ MIR-425 MIR-536 PGEN-412 - area + PGEN-492 action_graph + area bounding_box + formula gaussian_grid + grib_basic_angle grib_encoding + grid_box_method increments input_MultiDimensionalInput interpolations iterator knn_weighting + packing + raw_memory spectral_order statistics style diff -Nru metview-5.17.4/mir/tests/unit/formula.cc metview-5.19.2/mir/tests/unit/formula.cc --- metview-5.17.4/mir/tests/unit/formula.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/formula.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,253 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include "eckit/testing/Test.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "eckit/types/FloatCompare.h" + +#include "mir/action/context/Context.h" +#include "mir/action/plan/Action.h" +#include "mir/api/MIRJob.h" +#include "mir/input/MIRInput.h" +#include "mir/output/RawOutput.h" +#include "mir/param/SimpleParametrisation.h" +#include "mir/util/Formula.h" +#include "mir/util/FormulaParser.h" +#include "mir/util/Log.h" + +#define EXPECT_APPROX(a, b) \ + EXPECT_MSG(eckit::types::is_approximately_equal(a, b, 1e-12), [=]() { \ + std::cerr << eckit::Colour::red << "FAILED " << #a " == " << #b << " evaluated as [" << a << "] == [" << b \ + << "]" << eckit::Colour::reset << std::endl; \ + };) + + +namespace mir::tests::unit { + + +CASE("Formula") { + auto eval = [](const std::string& formula) { + context::Context ctx; + ctx.scalar(0.); + + std::istringstream iss(formula); + iss >> std::setprecision(16); + util::FormulaParser parser(iss); + + static const param::SimpleParametrisation empty; + std::unique_ptr action(parser.parse(empty)); + action->perform(ctx); + + return ctx.scalar(); + }; + + auto s = [](double d) { + std::ostringstream str; + str << std::setprecision(32) << d; + return str.str(); + }; + + using t = std::pair; + + SECTION("f(scalar)") { + for (const auto& test : { + // clang-format off + t("abs(1)", 1), + t("abs(-1)", 1), + t("neg(1)", -1), + t("neg(-1)", 1), + t("not(1)", 0), + t("not(-1)", 0), + t("not(0)", 1), + t("sin(0)", 0), + t("sin(" + s(M_PI_2 / 3.) + ")", 1. / 2.), + t("sin(" + s(M_PI_4) + ")", std::sqrt(2.) / 2.), + t("sin(" + s(M_PI / 3.) + ")", std::sqrt(3.) / 2.), + t("sin(" + s(M_PI_2) + ")", 1.), + t("cos(0)", 1.), + t("cos(" + s(M_PI_2 / 3.) + ")", std::sqrt(3.) / 2.), + t("cos(" + s(M_PI_4) + ")", std::sqrt(2.) / 2.), + t("cos(" + s(M_PI / 3.) + ")", 1. / 2.), + t("cos(" + s(M_PI_2) + ")", 0.), + t("tan(0)", 0.), + t("tan(" + s(M_PI_2 / 3.) + ")", std::sqrt(3.) / 3.), + t("tan(" + s(M_PI_4) + ")", 1.), + t("tan(" + s(M_PI / 3.) + ")", std::sqrt(3.)), + t("asin(0)", 0.), + t("asin(" + s(1. / 2.) + ")", M_PI_2 / 3.), + t("asin(" + s(std::sqrt(2.) / 2.) + ")", M_PI_4), + t("asin(" + s(std::sqrt(3.) / 2.) + ")", M_PI / 3.), + t("asin(1)", M_PI_2), + t("acos(1)", 0.), + t("acos(" + s(std::sqrt(3.) / 2.) + ")", M_PI_2 / 3.), + t("acos(" + s(std::sqrt(2.) / 2.) + ")", M_PI_4), + t("acos(" + s(1. / 2.) + ")", M_PI / 3.), + t("acos(0)", M_PI_2), + t("atan(0)", 0.), + t("atan(" + s(std::sqrt(3.) / 3.) + ")", M_PI_2 / 3.), + t("atan(1)", M_PI_4), + t("atan(" + s(std::sqrt(3.)) + ")", M_PI / 3.), + t("exp(0)", 1.), + t("exp(1)", std::exp(1.)), + t("log(1)", 0.), + t("log(" + s(std::exp(1.)) + ")", 1.), + t("log(" + s(std::exp(2.)) + ")", 2.), + t("log10(1)", 0), + t("log10(10)", 1), + t("log10(100)", 2), + t("log2(1)", 0), + t("log2(2)", 1), + t("log2(4)", 2), + t("round(1.1)", 1), + t("round(1.9)", 2), + t("round(-1.1)", -1), + t("round(-1.9)", -2), + t("sqrt(1)", 1), + t("sqrt(4)", 2), + // clang-format on + }) { + break; + + Log::info() << test.first << " -> " << eval(test.first) << " ~= " << test.second << std::endl; + EXPECT_APPROX(eval(test.first), test.second); + } + } + + + SECTION("f(scalar, scalar)") { + for (const auto& test : { + // clang-format off + t("atan2(0, 1)", 0), + t("atan2(1,1)", M_PI_4), + t("atan2(-1,1)", -M_PI_4), + t("atan2(1,-1)", 3. * M_PI_4), + t("atan2(-1,-1)", -3. * M_PI_4), + t("max(1,-1)", 1), + t("max(-1,1)", 1), + t("min(1,-1)", -1), + t("min(-1,1)", -1), + t("pow(1,1)", 1), + t("pow(1,2)", 1), + t("pow(2,1)", 2), + t("pow(2,2)", 4), + t("pow(2,-1)", 1. / 2.), + t("pow(2,-2)", 1. / 4.), + t("1 * 2", 2), + t("1 + 2", 3), + t("1 - 2", -1), + t("1 / 2", 0.5), + t("1 < 2", 1), + t("2 < 1", 0), + t("1 < 1", 0), + t("1 > 2", 0), + t("2 > 1", 1), + t("1 > 1", 0), + t("1 <= 2", 1), + t("2 <= 1", 0), + t("1 <= 1", 1), + t("1 >= 2", 0), + t("2 >= 1", 1), + t("1 >= 1", 1), + t("1 = 1", 1), + t("1 = 2", 0), + t("and(1,0)", 0), + t("and(1,1)", 1), + t("and(1,-1)", 1), + t("and(0,0)", 0), + t("and(0,1)", 0), + t("and(0,-1)", 0), + t("or(1,0)", 1), + t("or(1,1)", 1), + t("or(1,-1)", 1), + t("or(0,0)", 0), + t("or(0,1)", 1), + t("or(0,-1)", 1), +#if 0 + t("x != y", 1), + t("x && y", 0), + t("x ^ y", 0), + t("1 || y", 0), +#endif + // clang-format on + }) { + Log::info() << test.first << " -> " << eval(test.first) << " ~= " << test.second << std::endl; + EXPECT_APPROX(eval(test.first), test.second); + } + } +} + + +CASE("Formula (pgen integration)") { + // pgen in production uses (integration test, however this list is not extensive): + // - use options like a=b=c (CmdArgs cannot use this, a CmdArgs::init parsing problem) + // - use options like a.b=c (CmdArgs cannot use this, because of LocalConfiguration default separator '.') + // - use formula with/without associated metadata + + // setup input/output/job + param::SimpleParametrisation in; + in.set("input", + "{" + "artificialInput:constant," + "constant:1.," + "gridded:true," + "gridType:regular_ll," + "west_east_increment:1.," + "south_north_increment:1.," + "Ni:360," + "Nj:181," + "north:90.," + "west:0.," + "south:-90.," + "east:360." + "}"); + + std::unique_ptr input(input::MIRInputFactory::build("constant", in)); + + param::SimpleParametrisation out; + std::vector values(7320, 0.); + std::unique_ptr output(new output::RawOutput(values.data(), values.size(), out)); + + api::MIRJob job; + job.set("grid", std::vector{3, 3}); + job.set("formula.prologue", "3-f"); + job.set("formula.epilogue", "f1*3"); + job.set("formula.epilogue.metadata", "paramId=255"); + + job.execute(*input, *output); + + auto is_approximately_equal = [](const std::vector& values) -> bool { + return values.end() == std::adjacent_find(values.begin(), values.end(), [](double a, double b) { + return !eckit::types::is_approximately_equal(a, b); + }); + }; + + // (3 - 1) * 3 = 6 + EXPECT(is_approximately_equal(values)); + EXPECT_APPROX(6., values[0]); +} + + +} // namespace mir::tests::unit + + +int main(int argc, char** argv) { + return eckit::testing::run_tests(argc, argv); +} diff -Nru metview-5.17.4/mir/tests/unit/gaussian_grid.cc metview-5.19.2/mir/tests/unit/gaussian_grid.cc --- metview-5.17.4/mir/tests/unit/gaussian_grid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/gaussian_grid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ // define EXPECTV(a) log << "\tEXPECT(" << #a <<")" << std::endl; EXPECT(a) -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("NamedGrid") { @@ -110,9 +108,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/grib_basic_angle.cc metview-5.19.2/mir/tests/unit/grib_basic_angle.cc --- metview-5.17.4/mir/tests/unit/grib_basic_angle.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/grib_basic_angle.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,123 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include +#include + +#include "eckit/testing/Test.h" +#include "eckit/types/Fraction.h" + +#include "mir/grib/BasicAngle.h" +#include "mir/util/BoundingBox.h" +#include "mir/util/Increments.h" + + +namespace mir::tests::unit { + + +CASE("lcm") { + using grib::lcm; + + EXPECT_EQUAL(2 * 2 * 3 * 3, lcm(2 * 2 * 3, 2 * 3 * 3)); + EXPECT_EQUAL(3 * 3 * 5 * 5, lcm(3 * 3 * 5, 3 * 5 * 5)); + + EXPECT_EQUAL(60, lcm(2 * 3, 3 * 4, 4 * 5)); + EXPECT_EQUAL(120, lcm(2 * 3 * 4, 3 * 4 * 5, 4 * 5 * 6)); + EXPECT_EQUAL(840, lcm(2 * 3 * 4, 3 * 4 * 5, 4 * 5 * 6, 5 * 6 * 7)); + + EXPECT_EQUAL(0, lcm(1, 0)); + EXPECT_EQUAL(0, lcm(0, 1)); + EXPECT_EQUAL(0, lcm(0, 0)); +} + + +CASE("gcd") { + using grib::gcd; + + EXPECT_EQUAL(2 * 3, gcd(2 * 2 * 3, 2 * 3 * 3)); + EXPECT_EQUAL(3 * 5, gcd(3 * 3 * 5, 3 * 5 * 5)); + + EXPECT_EQUAL(2, gcd(2 * 3, 3 * 4, 4 * 5)); + EXPECT_EQUAL(12, gcd(2 * 3 * 4, 3 * 4 * 5, 4 * 5 * 6)); + EXPECT_EQUAL(6, gcd(2 * 3 * 4, 3 * 4 * 5, 4 * 5 * 6, 5 * 6 * 7)); + + EXPECT_EQUAL(1, gcd(1, 0)); + EXPECT_EQUAL(2, gcd(0, 2)); + EXPECT_EQUAL(0, gcd(0, 0)); +} + + +CASE("Climate files <= v020 (1km)") { + using grib::Fraction; + + auto fraction_via_double = [](const Fraction& f) { + return eckit::Fraction(static_cast(f.num) / static_cast(f.den)); + }; + + auto fraction_via_fraction = [](const Fraction& f) { + return eckit::Fraction(static_cast(f.num), + static_cast(f.den)); + }; + + + // GRIB to value + const Fraction fractions[] = {{2, 240}, // iDirectionIncrementInDegrees + {2, 240}, // jDirectionIncrementInDegrees + {21599, 240}, // latitudeOfFirstGridPointInDegrees + {1, 240}, // longitudeOfFirstGridPointInDegrees + {-21599, 240}, // latitudeOfLastGridPointInDegrees + {86399, 240}}; // longitudeOfLastGridPointInDegrees + + for (const auto& f : fractions) { + EXPECT_EQUAL(fraction_via_double(f), fraction_via_fraction(f)); + } + + + // basic angle + grib::BasicAngle basic(fractions[0], fractions[1], fractions[2], fractions[3], fractions[4], fractions[5]); + + EXPECT_EQUAL(basic.num, 1L); + EXPECT_EQUAL(basic.den, 240L); + + + // bounding box/increments normalised numerators + const util::Increments inc(fraction_via_fraction(fractions[0]), fraction_via_fraction(fractions[1])); + + const util::BoundingBox bbox(fraction_via_fraction(fractions[2]), fraction_via_fraction(fractions[3]), + fraction_via_fraction(fractions[4]), fraction_via_fraction(fractions[5])); + + struct test_t { + explicit test_t(const Longitude& lon, const long _num) : fraction(lon.fraction()), num(_num) {} + explicit test_t(const Latitude& lat, const long _num) : fraction(lat.fraction()), num(_num) {} + const Fraction fraction; + const long num; + }; + + for (const auto& test : { + test_t{inc.west_east().longitude(), 2}, + test_t{inc.south_north().latitude(), 2}, + test_t{bbox.north(), 21599}, + test_t{bbox.west(), 1}, + test_t{bbox.south(), -21599}, + test_t{bbox.east(), 86399}, + }) { + EXPECT_EQUAL(basic.numerator(test.fraction), test.num); + } +} + + +} // namespace mir::tests::unit + + +int main(int argc, char** argv) { + return eckit::testing::run_tests(argc, argv); +} diff -Nru metview-5.17.4/mir/tests/unit/grib_encoding.cc metview-5.19.2/mir/tests/unit/grib_encoding.cc --- metview-5.17.4/mir/tests/unit/grib_encoding.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/grib_encoding.cc 2023-07-15 08:28:47.000000000 +0000 @@ -30,9 +30,7 @@ #include "mir/util/Mutex.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { using input::MIRInput; using repres::RepresentationHandle; @@ -625,9 +623,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { return eckit::testing::run_tests(argc, argv); diff -Nru metview-5.17.4/mir/tests/unit/grid_box_method.cc metview-5.19.2/mir/tests/unit/grid_box_method.cc --- metview-5.17.4/mir/tests/unit/grid_box_method.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/grid_box_method.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,164 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include "eckit/testing/Test.h" + +#include "mir/param/SimpleParametrisation.h" +#include "mir/repres/gauss/reduced/ReducedFromPL.h" +#include "mir/repres/gauss/regular/RegularGG.h" +#include "mir/repres/latlon/ReducedLL.h" +#include "mir/repres/latlon/RegularLL.h" +#include "mir/util/BoundingBox.h" +#include "mir/util/Domain.h" +#include "mir/util/GridBox.h" +#include "mir/util/Increments.h" +#include "mir/util/Types.h" + +// define EXPECTV(a) log << "\tEXPECT(" << #a <<")" << std::endl; EXPECT(a) + + +namespace mir::tests::unit { + + +CASE("grid boxes: West-East periodicity") { + using Longitude = LongitudeDouble; + + + SECTION("reduced Gaussian grid (periodic)") { + const std::vector pl{20, 20}; + + repres::RepresentationHandle r(new repres::gauss::reduced::ReducedFromPL(pl.size() / 2, pl)); + ASSERT(r->domain().isPeriodicWestEast()); + + auto boxes = r->gridBoxes(); + auto a = boxes.front(); + auto b = boxes.back(); + auto inc = 360. / static_cast(pl[0]); + + EXPECT_EQUAL(Longitude(a.west()), Longitude(-inc / 2.)); + EXPECT_EQUAL(Longitude(b.east()), Longitude(-inc / 2. + 360.)); + } + + + SECTION("reduced Gaussian grid (non-periodic)") { + const std::vector pl{20, 20}; + util::BoundingBox bbox{90., 0., 0., 180.}; + + repres::RepresentationHandle r(new repres::gauss::reduced::ReducedFromPL(pl.size() / 2, pl, bbox)); + ASSERT(!r->domain().isPeriodicWestEast()); + + for (const auto& box : r->gridBoxes()) { + EXPECT(bbox.contains({box.north(), box.west(), box.south(), box.east()})); + } + } + + + SECTION("regular Gaussian grid (periodic)") { + repres::RepresentationHandle r(new repres::gauss::regular::RegularGG(1)); + ASSERT(r->domain().isPeriodicWestEast()); + + auto boxes = r->gridBoxes(); + auto a = boxes.front(); + auto b = boxes.back(); + auto inc = 360. / 4.; // assumes Ni == 4 * N + + EXPECT_EQUAL(Longitude(a.west()), Longitude(-inc / 2.)); + EXPECT_EQUAL(Longitude(b.east()), Longitude(-inc / 2. + 360.)); + } + + + SECTION("regular Gaussian grid (non-periodic)") { + util::BoundingBox bbox{90., 0., 0., 180.}; + + repres::RepresentationHandle r(new repres::gauss::regular::RegularGG(1, bbox)); + ASSERT(!r->domain().isPeriodicWestEast()); + + for (const auto& box : r->gridBoxes()) { + EXPECT(bbox.contains({box.north(), box.west(), box.south(), box.east()})); + } + } + + + SECTION("regular lat/lon grid (periodic)") { + double inc = 18.; + + repres::RepresentationHandle r(new repres::latlon::RegularLL(util::Increments{inc, 90.})); + ASSERT(r->domain().isPeriodicWestEast()); + + auto boxes = r->gridBoxes(); + auto a = boxes.front(); + auto b = boxes.back(); + + EXPECT_EQUAL(Longitude(a.west()), Longitude(-inc / 2.)); + EXPECT_EQUAL(Longitude(b.east()), Longitude(-inc / 2. + 360.)); + } + + + SECTION("regular lat/lon grid (non-periodic)") { + util::BoundingBox bbox{90., 0., 0., 180.}; + double inc = 18.; + + repres::RepresentationHandle r(new repres::latlon::RegularLL(util::Increments{inc, 90.}, bbox)); + ASSERT(!r->domain().isPeriodicWestEast()); + + for (const auto& box : r->gridBoxes()) { + EXPECT(bbox.contains({box.north(), box.west(), box.south(), box.east()})); + } + } + + + { + const std::vector pl{20, 20}; + + param::SimpleParametrisation param; + param.set("pl", pl); + param.set("Nj", pl.size()); + param.set("north", 90.); + param.set("west", 0.); + param.set("south", 0.); + param.set("east", 360.); + + + SECTION("reduced lat/lon grid (periodic)") { + repres::RepresentationHandle r(new repres::latlon::ReducedLL(param)); + ASSERT(r->domain().isPeriodicWestEast()); + + auto boxes = r->gridBoxes(); + auto a = boxes.front(); + auto b = boxes.back(); + auto inc = 360. / static_cast(pl[0]); + + EXPECT_EQUAL(Longitude(a.west()), Longitude(-inc / 2.)); + EXPECT_EQUAL(Longitude(b.east()), Longitude(-inc / 2. + 360.)); + } + + + SECTION("reduced lat/lon grid (non-periodic)") { + util::BoundingBox bbox{90., 0., 0., 180.}; + param.set("east", bbox.east().value()); + + repres::RepresentationHandle r(new repres::latlon::ReducedLL(param)); + ASSERT(!r->domain().isPeriodicWestEast()); + for (const auto& box : r->gridBoxes()) { + EXPECT(bbox.contains({box.north(), box.west(), box.south(), box.east()})); + } + } + } +} + + +} // namespace mir::tests::unit + + +int main(int argc, char** argv) { + return eckit::testing::run_tests(argc, argv); +} diff -Nru metview-5.17.4/mir/tests/unit/increments.cc metview-5.19.2/mir/tests/unit/increments.cc --- metview-5.17.4/mir/tests/unit/increments.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/increments.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,9 +31,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { using eckit::Fraction; @@ -664,9 +662,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/input_MultiDimensionalInput.cc metview-5.19.2/mir/tests/unit/input_MultiDimensionalInput.cc --- metview-5.17.4/mir/tests/unit/input_MultiDimensionalInput.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/input_MultiDimensionalInput.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,6 +15,7 @@ #include "eckit/testing/Test.h" +#include "mir/data/MIRField.h" #include "mir/input/DummyInput.h" #include "mir/input/MultiDimensionalInput.h" #include "mir/param/DefaultParametrisation.h" @@ -22,9 +23,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { struct TestingInput : input::MIRInput { @@ -172,9 +171,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/interpolations.cc metview-5.19.2/mir/tests/unit/interpolations.cc --- metview-5.17.4/mir/tests/unit/interpolations.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/interpolations.cc 2023-07-15 08:28:47.000000000 +0000 @@ -23,9 +23,7 @@ #include "mir/util/Atlas.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("interpolations") { @@ -132,9 +130,29 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +#if mir_HAVE_ATLAS +CASE("MIR-583") { + // interpolation=linear failure on low parametricEpsilon + + api::MIRJob job; + job.set("caching", false); + job.set("grid", "0.04/0.04"); + job.set("interpolation", "linear"); + job.set("finite-element-missing-value-on-projection-fail", false); + + param::SimpleParametrisation args; + std::unique_ptr input(input::MIRInputFactory::build("MIR-583.grib1", args)); + + output::EmptyOutput output; + + while (input->next()) { + job.execute(*input, output); + } +} +#endif + + +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/iterator.cc metview-5.19.2/mir/tests/unit/iterator.cc --- metview-5.17.4/mir/tests/unit/iterator.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/iterator.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { using eckit::Fraction; @@ -345,9 +343,7 @@ log.precision(old); } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/knn_weighting.cc metview-5.19.2/mir/tests/unit/knn_weighting.cc --- metview-5.17.4/mir/tests/unit/knn_weighting.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/knn_weighting.cc 2023-07-15 08:28:47.000000000 +0000 @@ -22,9 +22,7 @@ // define EXPECTV(a) log << "\tEXPECT(" << #a <<")" << std::endl; EXPECT(a) -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("distance-weighting") { @@ -77,9 +75,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/MIR-333.cc metview-5.19.2/mir/tests/unit/MIR-333.cc --- metview-5.17.4/mir/tests/unit/MIR-333.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/MIR-333.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("MIR-333") { @@ -78,9 +76,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/MIR-356.cc metview-5.19.2/mir/tests/unit/MIR-356.cc --- metview-5.17.4/mir/tests/unit/MIR-356.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/MIR-356.cc 2023-07-15 08:28:47.000000000 +0000 @@ -21,9 +21,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("MIR-356") { @@ -54,9 +52,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/MIR-425.cc metview-5.19.2/mir/tests/unit/MIR-425.cc --- metview-5.17.4/mir/tests/unit/MIR-425.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/MIR-425.cc 2023-07-15 08:28:47.000000000 +0000 @@ -29,9 +29,7 @@ // define EXPECTV(a) log << "\tEXPECT(" << #a <<")" << std::endl; EXPECT(a) -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("MIR-425") { @@ -106,9 +104,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/MIR-536.cc metview-5.19.2/mir/tests/unit/MIR-536.cc --- metview-5.17.4/mir/tests/unit/MIR-536.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/MIR-536.cc 2023-07-15 08:28:47.000000000 +0000 @@ -15,21 +15,23 @@ #include "eckit/testing/Test.h" #include "mir/action/io/Save.h" -#include "mir/output/GribFileOutput.h" +#include "mir/grib/Packing.h" +#include "mir/output/GribMemoryOutput.h" #include "mir/param/SimpleParametrisation.h" +#include "mir/util/Exceptions.h" #include "mir/util/Log.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("MIR-536") { - std::unique_ptr out(new output::GribFileOutput("")); + std::unique_ptr out(new output::GribMemoryOutput(nullptr, 0)); struct Param : param::SimpleParametrisation { - Param() { field_.set("edition", 0L).set("accuracy", 0L).set("packing", "not_simple"); } + explicit Param(long edition = 0) { + field_.set("edition", edition).set("accuracy", 0L).set("packing", "not_simple").set("gridded", true); + } const MIRParametrisation& userParametrisation() const override { return *this; } const MIRParametrisation& fieldParametrisation() const override { return field_; } @@ -68,12 +70,24 @@ } } } + + + SECTION("Control grib-edition-conversion") { + std::unique_ptr ptr; + + Param param(1L); + param.set("packing", "ccsds"); // edition=2 only + + param.set("grib-edition-conversion", false); + EXPECT_THROWS_AS(ptr.reset(grib::Packing::build(param)), exception::UserError); + + param.set("grib-edition-conversion", true); + EXPECT_NO_THROW(ptr.reset(grib::Packing::build(param))); + } } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/unit/MIR-583.grib1 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/unit/MIR-583.grib1 differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/unit/orog_1km.grib2 and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/unit/orog_1km.grib2 differ diff -Nru metview-5.17.4/mir/tests/unit/packing.cc metview-5.19.2/mir/tests/unit/packing.cc --- metview-5.17.4/mir/tests/unit/packing.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/packing.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,205 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include +#include +#include + +#include "eckit/testing/Test.h" + +#include "mir/api/MIRJob.h" +#include "mir/grib/Packing.h" +#include "mir/input/MIRInput.h" +#include "mir/param/CombinedParametrisation.h" +#include "mir/param/DefaultParametrisation.h" +#include "mir/param/SimpleParametrisation.h" +#include "mir/util/Exceptions.h" +#include "mir/util/Log.h" + + +namespace mir::tests::unit { + + +CASE("Packing") { + // setup input/output + std::map fields; + +#define COMMON "artificialInput:constant,constant:0.,accuracy:16,truncation:1279" + fields["spectral_complex, edition=1"].set("input", "{" COMMON ",edition:1,packing:complex,spectral:true}"); + fields["spectral_complex, edition=2"].set("input", "{" COMMON ",edition:2,packing:complex,spectral:true}"); + fields["grid_simple, edition=1"].set("input", "{" COMMON ",edition:1,packing:simple,gridded:true}"); + fields["grid_simple, edition=2"].set("input", "{" COMMON ",edition:2,packing:simple,gridded:true}"); + fields["grid_ccsds, edition=2"].set("input", "{" COMMON ",edition:2,packing:ccsds,gridded:true}"); +#undef COMMON + + static const param::DefaultParametrisation defaults; + + struct Combine { + Combine(const api::MIRJob& job, const param::MIRParametrisation& field) : + input(input::MIRInputFactory::build("constant", field)), + param(new param::CombinedParametrisation(job, input->parametrisation(), defaults)) {} + std::unique_ptr input; + std::unique_ptr param; + }; + + + auto check_packing_edition_bits = [](const grib::Packing& pack, const std::string& packing = "", long edition = 0, + long bits = 0, long precision = 0) { + std::ostringstream str; + pack.printParametrisation(str); + const auto calculated = "Packing[" + str.str() + "]"; + + auto app = [](const std::string& str, const std::string& key, long value) { + return value == 0 ? "" : ((str.empty() ? "" : ",") + key + "=" + std::to_string(value)); + }; + + std::string expected(packing.empty() ? "" : ("packing=" + packing)); + expected += app(expected, "edition", edition); + expected += app(expected, "accuracy", bits); + expected += app(expected, "precision", precision); + expected = "Packing[" + expected + "]"; + + Log::info() << expected << " (expected)\n" << calculated << " (calculated)" << std::endl; + EXPECT_EQUAL(expected, calculated); + }; + + + SECTION("grid=off, packing=off, edition=off, accuracy=off") { + api::MIRJob job; + + for (const auto& field : fields) { + std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + check_packing_edition_bits(*pack); + } + } + + + SECTION("grid=1/1: modify only spectral->gridded packing, no edition, accuracy") { + api::MIRJob job; + job.set("grid", "1/1"); + + for (const auto& field : fields) { + std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + field.first == "spectral_complex, edition=1" ? check_packing_edition_bits(*pack, "simple") + : field.first == "spectral_complex, edition=2" ? check_packing_edition_bits(*pack, "simple") + : check_packing_edition_bits(*pack); + } + } + + + SECTION("packing=ccsds") { + api::MIRJob job; + job.set("packing", "ccsds"); + EXPECT_THROWS_AS(grib::Packing::build(*Combine(job, fields["grid_simple, edition=1"]).param), + exception::UserError); + + job.set("grid", "1/1"); + EXPECT_THROWS_AS(grib::Packing::build(*Combine(job, fields["spectral_complex, edition=1"]).param), + exception::UserError); + + // (edition conversion) + job.set("edition", 2); + for (const auto& field : fields) { + std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + bool same_packing = field.first == "grid_ccsds, edition=2"; + bool same_edition = field.first.back() == '2'; + check_packing_edition_bits(*pack, same_packing ? "" : "ccsds", same_edition ? 0 : 2); + } + } + + + SECTION("packing=ieee") { + api::MIRJob job; + job.set("packing", "ieee"); + + for (const auto& field : fields) { + // std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + // check_packing_edition_bits(*pack, "ieee", 0, 32, 1); + + for (long accuracy : {31, 32, 33, 63, 64, 65}) { + job.set("accuracy", accuracy); + + if (accuracy == 32) { + std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + check_packing_edition_bits(*pack, "ieee", 0, 32, 1); + continue; + } + + if (accuracy == 64) { + std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + check_packing_edition_bits(*pack, "ieee", 0, 64, 2); + continue; + } + + EXPECT_THROWS_AS(grib::Packing::build(*Combine(job, field.second).param), exception::UserError); + } + } + } + + + SECTION("grib-packing-always-set=true") { + api::MIRJob job; + job.set("grid", "1/1"); + job.set("grib-packing-always-set", true); + + for (const auto& field : fields) { + Log::info() << "'" << field.first << "'" << std::endl; + std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + + bool same_packing = field.first == "grid_simple, edition=1" || field.first == "grid_simple, edition=2"; + check_packing_edition_bits(*pack, same_packing ? "" : "simple"); + } + } + + + SECTION("grib-packing-always-set=true, grib-packing-gridded=ccsds") { + api::MIRJob job; + job.set("grid", "1/1"); + job.set("grib-edition-conversion", true); + job.set("grib-packing-always-set", true); + job.set("grib-packing-gridded", "ccsds"); + + for (const auto& field : fields) { + Log::info() << "'" << field.first << "'" << std::endl; + std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + bool same_packing = field.first == "grid_ccsds, edition=2"; + bool same_edition = field.first.back() == '2'; + check_packing_edition_bits(*pack, same_packing ? "" : "ccsds", same_edition ? 0 : 2); + } + } + + + // PGEN-496 + SECTION("grid=?, packing=off, edition=off, accuracy=off, truncation=?") { + api::MIRJob job; + job.set("truncation", "none"); // (from RESOL=AV) + + for (const std::string& grid : {"N80", "N160"}) { + job.set("grid", grid); + + for (const auto& field : fields) { + std::unique_ptr pack(grib::Packing::build(*Combine(job, field.second).param)); + + bool field_spectral = field.first.substr(0, 8) == "spectral"; + check_packing_edition_bits(*pack, field_spectral ? "simple" : ""); + } + } + } +} + + +} // namespace mir::tests::unit + + +int main(int argc, char** argv) { + return eckit::testing::run_tests(argc, argv); +} diff -Nru metview-5.17.4/mir/tests/unit/PGEN-412.cc metview-5.19.2/mir/tests/unit/PGEN-412.cc --- metview-5.17.4/mir/tests/unit/PGEN-412.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/PGEN-412.cc 2023-07-15 08:28:47.000000000 +0000 @@ -24,9 +24,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("PGEN-412") { @@ -36,7 +34,8 @@ "{" "artificialInput:constant," "constant:0.," - "spectral:1279," + "spectral:true," + "truncation:1279," "gridType:sh," "packing:spectral_complex," "edition:2," @@ -101,9 +100,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/PGEN-492.cc metview-5.19.2/mir/tests/unit/PGEN-492.cc --- metview-5.17.4/mir/tests/unit/PGEN-492.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/PGEN-492.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,49 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include +#include + +#include "eckit/testing/Test.h" + +#include "mir/data/MIRField.h" +#include "mir/input/GribFileInput.h" +#include "mir/repres/Representation.h" +#include "mir/util/Domain.h" + + +namespace mir::tests::unit { + + +CASE("PGEN-492") { + for (const std::string& file : {"stream=wave,param=swh", "stream=wave,param=swh,domain=m"}) { + std::unique_ptr input(new input::GribFileInput(file)); + ASSERT(input->next()); + + std::string gridType; + input->parametrisation().get("gridType", gridType); + ASSERT(gridType == "reduced_ll"); + + repres::RepresentationHandle repres(input->field().representation()); + auto domain = repres->domain(); + + EXPECT(domain.isPeriodicWestEast()); + } +} + + +} // namespace mir::tests::unit + + +int main(int argc, char** argv) { + return eckit::testing::run_tests(argc, argv); +} diff -Nru metview-5.17.4/mir/tests/unit/raw_memory.cc metview-5.19.2/mir/tests/unit/raw_memory.cc --- metview-5.17.4/mir/tests/unit/raw_memory.cc 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/raw_memory.cc 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1,285 @@ +/* + * (C) Copyright 1996- 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. + */ + + +#include +#include +#include +#include + +#include "eckit/testing/Test.h" + +#include "mir/api/MIRJob.h" +#include "mir/data/MIRField.h" +#include "mir/input/RawInput.h" +#include "mir/output/RawOutput.h" +#include "mir/output/ResizableOutput.h" +#include "mir/param/SimpleParametrisation.h" +#include "mir/util/Log.h" + + +namespace mir::tests::unit { + + +CASE("RawInput") { + auto& log = Log::info(); + + + SECTION("grid=1/1") { + // metadata + param::SimpleParametrisation meta; + + meta.set("gridded", true); + meta.set("gridType", "regular_ll"); + meta.set("north", 10.); + meta.set("west", 0.); + meta.set("south", 0.); + meta.set("east", 10.); + meta.set("south_north_increment", 5.); + meta.set("west_east_increment", 5.); + meta.set("Ni", 3); + meta.set("Nj", 3); + + + // data + std::vector values(9, 0.); + std::unique_ptr input(new input::RawInput(values.data(), values.size(), meta)); + + + // access a field (in the post-processing context) + log << *input << std::endl; + + auto field = input->field(); + log << field << std::endl; + } + + + SECTION("grid=o4") { + // metadata + param::SimpleParametrisation meta; + + meta.set("gridded", true); + meta.set("gridType", "reduced_gg"); + meta.set("north", 90.); + meta.set("west", 0.); + meta.set("south", -90.); + meta.set("east", 360.); + meta.set("N", 4); + meta.set("pl", std::vector{20, 24, 28, 32, 32, 28, 24, 20}); + + + // data + std::vector values(208 /*sum(pl)*/, 0.); + std::unique_ptr input(new input::RawInput(values.data(), values.size(), meta)); + + + // access a field (in the post-processing context) + log << *input << std::endl; + + auto field = input->field(); + log << field << std::endl; + } + + + SECTION("sh truncation=21") { + // metadata + param::SimpleParametrisation meta; + + meta.set("spectral", true); + meta.set("gridType", "sh"); + meta.set("truncation", 21); + + + // data + std::vector values(506, 0.); + std::unique_ptr input(new input::RawInput(values.data(), values.size(), meta)); + + + // access a field (in the post-processing context) + log << *input << std::endl; + + auto field = input->field(); + log << field << std::endl; + } +} + + +CASE("Example 1") { + auto& log = Log::info(); + + + // input, with a values vector representing: + // - North Pole + // - 20 x 0. + // - 24 x 0. + // - 28 x 0. + // - 32 x 42. + // - Equator + // - 32 x -42. + // - 28 x 0. + // - 24 x 0. + // - 20 x 0. + // - South Pole + + param::SimpleParametrisation meta1; + meta1.set("gridded", true); + meta1.set("gridType", "reduced_gg"); + meta1.set("north", 90.); + meta1.set("west", 0.); + meta1.set("south", -90.); + meta1.set("east", 360.); + meta1.set("N", 4); + meta1.set("pl", std::vector{20, 24, 28, 32, 32, 28, 24, 20}); + + std::vector values1(208 /*sum(pl)*/, 0.); + std::fill_n(values1.begin() + 20 + 24 + 28, 32, 42.); + std::fill_n(values1.begin() + 20 + 24 + 28 + 32, 32, -42.); + + std::unique_ptr input(new input::RawInput(values1.data(), values1.size(), meta1)); + + + // job + api::MIRJob job; + job.set("grid", std::vector{2., 2.}); + job.set("area", std::vector{1., -1., -1., 1.}); + job.set("interpolation", "nn"); + job.set("caching", false); + + log << job << std::endl; + + + SECTION("process with output of static size") { + // output + param::SimpleParametrisation meta2; + std::vector values2(4, 0); + std::unique_ptr output(new output::RawOutput(values2.data(), values2.size(), meta2)); + + + // process + job.execute(*input, *output); + + EXPECT_EQUAL(values2[0], 42.); + EXPECT_EQUAL(values2[1], 42.); + EXPECT_EQUAL(values2[2], -42.); + EXPECT_EQUAL(values2[3], -42.); + + log << "output metadata: " << meta2 << std::endl; + + std::ostringstream ss; + ss << meta2; + EXPECT(ss.str() == "{\"area\":[1,-1,-1,1],\"grid\":[2,2]}"); + } + + + SECTION("process with output of dynamic size") { + // output (RawOutput instead of MIROutput to access specific methods) + param::SimpleParametrisation meta2; + std::vector values2; + std::unique_ptr output(new output::ResizableOutput(values2, meta2)); + + + // process + job.execute(*input, *output); + + EXPECT(values2.size() == 4); + + EXPECT_EQUAL(values2[0], 42.); + EXPECT_EQUAL(values2[1], 42.); + EXPECT_EQUAL(values2[2], -42.); + EXPECT_EQUAL(values2[3], -42.); + + log << "output metadata: " << meta2 << std::endl; + + std::ostringstream ss; + ss << meta2; + EXPECT(ss.str() == "{\"area\":[1,-1,-1,1],\"grid\":[2,2]}"); + } +} + + +CASE("Example 2") { + auto& log = Log::info(); + + + // input, with a values vector representing spherical harmonics scalar field + param::SimpleParametrisation meta1; + meta1.set("spectral", true); + meta1.set("gridType", "sh"); + meta1.set("truncation", 21); + + std::vector values1(506, 0.); + std::unique_ptr input(new input::RawInput(values1.data(), values1.size(), meta1)); + + + // job + api::MIRJob job; + job.set("grid", std::vector{2., 2.}); + job.set("area", std::vector{1., -1., -1., 1.}); + job.set("caching", false); + + + SECTION("process with output of static size") { + // output + param::SimpleParametrisation meta2; + std::vector values2(4, 0); + std::unique_ptr output(new output::RawOutput(values2.data(), values2.size(), meta2)); + + log << job << std::endl; + + + // process + job.execute(*input, *output); + + EXPECT_EQUAL(values2[0], 0.); // TODO: improve results check + EXPECT_EQUAL(values2[1], 0.); + EXPECT_EQUAL(values2[2], 0.); + EXPECT_EQUAL(values2[3], 0.); + + log << "output metadata: " << meta2 << std::endl; + + std::ostringstream ss; + ss << meta2; + EXPECT(ss.str() == "{\"area\":[1,-1,-1,1],\"grid\":[2,2]}"); + } + + + SECTION("process with output of dynamic size") { + // output (RawOutput instead of MIROutput to access specific methods) + param::SimpleParametrisation meta2; + std::vector values2; + std::unique_ptr output(new output::ResizableOutput(values2, meta2)); + + + // process + job.execute(*input, *output); + + EXPECT(values2.size() == 4); + + EXPECT_EQUAL(values2[0], 0.); + EXPECT_EQUAL(values2[1], 0.); + EXPECT_EQUAL(values2[2], 0.); + EXPECT_EQUAL(values2[3], 0.); + + log << "output metadata: " << meta2 << std::endl; + + std::ostringstream ss; + ss << meta2; + EXPECT(ss.str() == "{\"area\":[1,-1,-1,1],\"grid\":[2,2]}"); + } +} + + +} // namespace mir::tests::unit + + +int main(int argc, char** argv) { + return eckit::testing::run_tests(argc, argv); +} diff -Nru metview-5.17.4/mir/tests/unit/regular_ll_grid.cc metview-5.19.2/mir/tests/unit/regular_ll_grid.cc --- metview-5.17.4/mir/tests/unit/regular_ll_grid.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/regular_ll_grid.cc 2023-07-15 08:28:47.000000000 +0000 @@ -31,9 +31,7 @@ #include "mir/util/Types.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { using eckit::Fraction; @@ -678,9 +676,7 @@ #endif -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/spectral_order.cc metview-5.19.2/mir/tests/unit/spectral_order.cc --- metview-5.17.4/mir/tests/unit/spectral_order.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/spectral_order.cc 2023-07-15 08:28:47.000000000 +0000 @@ -18,9 +18,7 @@ #include "mir/util/SpectralOrder.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("test_spectral_order") { @@ -160,9 +158,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/statistics.cc metview-5.19.2/mir/tests/unit/statistics.cc --- metview-5.17.4/mir/tests/unit/statistics.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/statistics.cc 2023-07-15 08:28:47.000000000 +0000 @@ -35,9 +35,7 @@ EXPECT(eckit::types::is_approximately_equal(static_cast(a), static_cast(b), EPS)) -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { struct case_t { @@ -160,9 +158,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/unit/stream=wave,param=swh and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/unit/stream=wave,param=swh differ Binary files /tmp/tmplxcw1n2q/GROA0F58JF/metview-5.17.4/mir/tests/unit/stream=wave,param=swh,domain=m and /tmp/tmplxcw1n2q/jgDzR3O64f/metview-5.19.2/mir/tests/unit/stream=wave,param=swh,domain=m differ diff -Nru metview-5.17.4/mir/tests/unit/style.cc metview-5.19.2/mir/tests/unit/style.cc --- metview-5.17.4/mir/tests/unit/style.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/style.cc 2023-07-15 08:28:47.000000000 +0000 @@ -34,9 +34,7 @@ // define EXPECTV(a) log << "\tEXPECT(" << #a <<")" << std::endl; EXPECT(a) -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { bool plan_has_action(const action::ActionPlan& plan, const action::Action& action) { @@ -51,7 +49,9 @@ const std::vector grid{1, 1}; protected: - InputOutput(bool gridded) { gridded ? set("grid", grid).set("gridded", true) : set("spectral", 1); } + InputOutput(bool gridded) { + gridded ? set("grid", grid).set("gridded", true) : set("truncation", 1).set("spectral", true); + } }; @@ -190,9 +190,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/vector-space.cc metview-5.19.2/mir/tests/unit/vector-space.cc --- metview-5.17.4/mir/tests/unit/vector-space.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/vector-space.cc 2023-07-15 08:28:47.000000000 +0000 @@ -25,9 +25,7 @@ #include "mir/util/Log.h" -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { CASE("vector-space") { @@ -120,9 +118,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/tests/unit/wind.cc metview-5.19.2/mir/tests/unit/wind.cc --- metview-5.17.4/mir/tests/unit/wind.cc 2022-12-05 10:14:29.000000000 +0000 +++ metview-5.19.2/mir/tests/unit/wind.cc 2023-07-15 08:28:47.000000000 +0000 @@ -27,9 +27,7 @@ EXPECT(a) -namespace mir { -namespace tests { -namespace unit { +namespace mir::tests::unit { struct FakeInput : public param::RuntimeParametrisation { @@ -93,9 +91,7 @@ } -} // namespace unit -} // namespace tests -} // namespace mir +} // namespace mir::tests::unit int main(int argc, char** argv) { diff -Nru metview-5.17.4/mir/VERSION metview-5.19.2/mir/VERSION --- metview-5.17.4/mir/VERSION 1970-01-01 00:00:00.000000000 +0000 +++ metview-5.19.2/mir/VERSION 2023-07-15 08:28:47.000000000 +0000 @@ -0,0 +1 @@ +1.17.2
" + label + "
" + label + "
" + label + "
" + label + "
" + s + "" + headers[i] + "" + headers[headers.count() - 1] + "
" + label + "" + label + "