"Fossies" - the Fresh Open Source Software Archive 
Member "fimex-1.4.1/include/fimex/SpatialAxisSpec.h" (30 Oct 2019, 3966 Bytes) of package /linux/privat/fimex-1.4.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "SpatialAxisSpec.h" see the
Fossies "Dox" file reference documentation.
1 /*
2 * Fimex, SpatialAxisSpec.h
3 *
4 * (C) Copyright 2009, met.no
5 *
6 * Project Info: https://wiki.met.no/fimex/start
7 *
8 * This library is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 * License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 * USA.
22 *
23 * Created on: Mar 18, 2009
24 * Author: Heiko Klein
25 */
26
27 #ifndef TIMESPEC_H_
28 #define TIMESPEC_H_
29
30 #include <vector>
31 #include <string>
32
33 namespace MetNoFimex
34 {
35
36 /**
37 * @headerfile fimex/SpatialAxisSpec.h
38 */
39 /**
40 * This class can be used to describe a list of spatial units in an efficient textual way.
41 *
42 *
43 * - UNIT: see <a href="http://www.unidata.ucar.edu/software/udunits/">udunit</a>, compatible with degree or m: default: m
44 * - RELVALUE: float-number
45 * - RELVALUES: comma-separated list of values with possible ... extension, ... meaning continuation of the difference of the previous two values
46 * 0 is the first time in the original time-axis, x is the last time-value in the original time-axis
47 *
48 * A SpatialAxisSpec consists of at least of values:
49 *
50 * - axisspec := VALUES[;unit=UNIT] |
51 * RELVALUES;relativeStart=VALUE[;unit=UNIT]
52 *
53 * relativeStart will reset the relative value 0 to the first value larger
54 * than x0 (original start time)
55 * with x0 = i * (v1-v0)* unit with i being a integer.
56 *
57 * @subsubsection secSpatialAxisSpecEx1 Example: absolute axis values, every 50km
58 *
59 * @code
60 * axisspec = -450000,-400000,...,50000
61 * @endcode
62 *
63 * @subsubsection secSpatialAxisSpecEx2 Example: relative axis, each 50km starting at 17km from the northpole
64 *
65 * @code
66 * timespec = -50,0,...,x,x+50;relativeStart=17;unit=km
67 * @endcode
68 *
69 * @warning The 'unit' parameter is currently not supported, please enter values as m or degree
70 * @warning the RELVALUES currently must be in m, degree not supported (yet?)
71 */
72 class SpatialAxisSpec
73 {
74 private:
75 void init();
76 public:
77 /**
78 * Define a spatialAxisSpec. Depending on the axisSpec (relativeStart?), start and end must be given later
79 * @param axisSpec string representation as explained above
80 */
81 SpatialAxisSpec(const std::string& axisSpec) :
82 axisSpec(axisSpec), startEndInitialized(false), axisInitialized(false) {}
83 /**
84 * Define a spatialAxisSpec
85 * @param axisSpec string representation as explained above
86 * @param start place of data start, in degree or m
87 * @param end place to end, in degree or m
88 */
89 SpatialAxisSpec(const std::string& axisSpec, double start, double end) :
90 axisSpec(axisSpec), start(start), end(end), startEndInitialized(true), axisInitialized(false) {}
91 virtual ~SpatialAxisSpec() {};
92 /**
93 * Check if axisSpec still requires start and end place. This returns false if
94 * a) start and end have been given already
95 * b) the axisSpec is independant of start and end
96 */
97 bool requireStartEnd();
98 void setStartEnd(double start, double end) {this->start = start; this->end = end; this->startEndInitialized = true;}
99 /**
100 * @return steps on the axis in degree or m
101 */
102 const std::vector<double>& getAxisSteps() {if (!axisInitialized) init(); return axisSteps;}
103
104 private:
105 std::string axisSpec;
106 double start;
107 double end;
108 bool startEndInitialized;
109 bool axisInitialized;
110 std::vector<double> axisSteps;
111 };
112
113 } /* MetNoFimex */
114
115 #endif /* TIMESPEC_H_ */