KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GridAxisIrregular.h
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
29 
30 /********************************************************************
31  class: GridAxisIrregular
32  created: 05/11/2009
33  author: Karl Jones
34 
35  purpose: Implementation of the grid axis data type for Irregular (variable spacing) axis data.
36 
37  size: 320 bits / 40 octets - min size
38 *********************************************************************/
39 
40 #pragma once
41 
42 #include "./GridAxisRegular.h"
43 
44 namespace KDIS {
45 namespace DATA_TYPE {
46 
48 {
49 protected:
50 
52 
54 
55  std::vector<KUINT16> m_vXiValues;
56 
57  std::vector<KUINT16> m_vui16Padding; // To 64 bit boundary
58 
59  //************************************
60  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::GetAsString
61  //!Description: Calculates and adds padding so that the data type is on a 64 bit boundary.
62  //************************************
63  void calculatePadding();
64 
65 public:
66 
67 #define GRID_AXIS_IRREGULAR 40 // Min size
68 
69  GridAxisIrregular();
70 
71  GridAxisIrregular( KDataStream & stream ) throw( KException );
72 
73  // This constructor is used by the Gridded_Data_PDU. In order to know if a grid axis is regular or irregular
74  // we must first decode 4 other values before we can get to the AxisType value. So this constructor is here to aid in this process.
75  GridAxisIrregular( KFLOAT64 InitialXi, KFLOAT64 FinalXi, KUINT16 PointsXi, KUINT8 InterleafFactor,
76  KUINT8 AxisType, KDataStream & stream );
77 
78  GridAxisIrregular( KFLOAT64 InitialXi, KFLOAT64 FinalXi, KUINT16 PointsXi, KUINT8 InterleafFactor,
79  KUINT8 AxisType, KUINT16 InitialIndexXi, KFLOAT64 CoordinateScaleXi,
80  KFLOAT64 CoordinateOffsetXi, const std::vector<KUINT16> & XiValues );
81 
82  virtual ~GridAxisIrregular();
83 
84  //************************************
85  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::SetCoordinateScaleXi
86  // KDIS::DATA_TYPE::GridAxisIrregular::GetCoordinateScaleXi
87  //!Description: Specifies the value that linearly scales the coordinates of the
88  //! grid locations for the Xi axis.
89  // Parameter: KFLOAT64 Xi, void
90  //************************************
91  void SetCoordinateScaleXi( KFLOAT64 Xi );
92  KFLOAT64 GetCoordinateScaleXi() const;
93 
94  //************************************
95  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::SetCoordinateOffsetXi
96  // KDIS::DATA_TYPE::GridAxisIrregular::GetCoordinateOffsetXi
97  //!Description: Specifies the constant offset value that shall be applied to the grid locations
98  //! for the Xi axis (for example, the Earth radius is the z-axis offset).
99  // Parameter: KFLOAT64 Xi, void
100  //************************************
101  void SetCoordinateOffsetXi( KFLOAT64 Xi );
102  KFLOAT64 GetCoordinateOffsetXi() const;
103 
104  //************************************
105  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::AddXiValue
106  // KDIS::DATA_TYPE::GridAxisIrregular::SetXiValues
107  // KDIS::DATA_TYPE::GridAxisIrregular::GetXiValues
108  // KDIS::DATA_TYPE::ClearXiValues
109  //!Description: Specifies the coordinate values for the Ni grid locations along the
110  //! irregular (variable spacing) Xi axis for environmental data values
111  //! contained within the PDU.
112  //! Note: The Add and Set functions will automatically set NumberOfPointsOnXiAxis to the
113  //! correct value.
114  // Parameter: KUINT16 Xi, const vector<KUINT16> & Xi, void
115  //************************************
116  void AddXiValue( KUINT16 Xi );
117  void SetXiValues( const std::vector<KUINT16> & Xi );
118  const std::vector<KUINT16> & GetXiValues() const;
119  void ClearXiValues();
120 
121  //************************************
122  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::GetAsString
123  //!Description: If false then this is in fact a derived GridAxisIrregular instance and can be safely
124  //! up cast for access to the additional fields.
125  //************************************
126  virtual KBOOL IsGridRegular() const;
127 
128  //************************************
129  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::GetAsString
130  //!Description: Returns length in octets, used for determining the PDU length.
131  //************************************
132  virtual KUINT16 GetLength();
133 
134  //************************************
135  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::GetAsString
136  //!Description: Returns a string representation
137  //************************************
138  virtual KString GetAsString() const;
139 
140  //************************************
141  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::Decode
142  //!Description: Convert From Network Data.
143  // Parameter: KDataStream & stream
144  //************************************
145  virtual void Decode( KDataStream & stream ) throw( KException );
146 
147  //************************************
148  // FullName: KDIS::DATA_TYPE::GridAxisIrregular::Encode
149  //!Description: Convert To Network Data.
150  // Parameter: KDataStream & stream
151  //************************************
152  virtual KDataStream Encode() const;
153  virtual void Encode( KDataStream & stream ) const;
154 
155  KBOOL operator == ( const GridAxisIrregular & Value ) const;
156  KBOOL operator != ( const GridAxisIrregular & Value ) const;
157 };
158 
159 } // END namespace DATA_TYPES
160 } // END namespace KDIS
161 
std::vector< KUINT16 > m_vui16Padding
Definition: GridAxisIrregular.h:57
unsigned short int KUINT16
Definition: KDefines.h:101
Definition: GridAxisRegular.h:61
bool KBOOL
Definition: KDefines.h:119
KFLOAT64 m_f64CoordOffsetXi
Definition: GridAxisIrregular.h:53
std::string KString
Definition: KDefines.h:116
std::vector< KUINT16 > m_vXiValues
Definition: GridAxisIrregular.h:55
double KFLOAT64
Definition: KDefines.h:114
unsigned char KUINT8
Definition: KDefines.h:99
KFLOAT64 m_f64CoordScaleXi
Definition: GridAxisIrregular.h:51
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: GridAxisIrregular.h:47