srs/WKTActions.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file WKTActions.cpp
22 
23  \brief A class that implements the semanthic actions to grammar rules for well known text (WKT) format for Spatial Reference Systems.
24  Basically, the class is responsible to generate a SRS element.
25 */
26 
27 // TerraLib
28 #include "Datum.h"
29 #include "Ellipsoid.h"
32 #include "WKTActions.h"
33 
34 // STL
35 #include <cstdlib>
36 
38  : m_srs(nullptr),
39  m_projCS(nullptr),
40  m_geoCS(nullptr),
41  m_datum(nullptr),
42  m_ellps(nullptr),
43  m_authorityName(""),
44  m_authorityCode("")
45 {
46  m_sevenParams.resize(7);
47 }
48 
50 
52 {
53  m_srs = nullptr;
54 
55  delete m_projCS;
56  m_projCS = nullptr;
57 
58  delete m_geoCS;
59  m_geoCS = nullptr;
60 
61  delete m_datum;
62  m_datum = nullptr;
63 
64  delete m_ellps;
65  m_ellps = nullptr;
66 }
67 
69 {
71  m_srs = m_projCS;
72 }
73 
75 {
77  m_srs = m_geoCS;
78 }
79 
81 {
82  m_datum = new te::srs::Datum();
83 }
84 
86 {
88 }
89 
90 void te::srs::WKTActions::setName(const std::string& name)
91 {
92  m_srs->setName(name);
93 }
94 
95 void te::srs::WKTActions::setPrimeMeridian(const double& primem)
96 {
97  m_geoCS->setPrimem(primem);
98 }
99 
100 void te::srs::WKTActions::setUnitName(const std::string& name)
101 {
102  m_srs->setUnitName(name);
103 }
104 
106 {}
107 
108 void te::srs::WKTActions::setDatumName(const std::string& name)
109 {
110  m_datum->setName(name);
111 }
112 
113 void te::srs::WKTActions::setDx(const double& dx)
114 {
115  m_sevenParams[0] = dx;
116 }
117 
118 void te::srs::WKTActions::setDy(const double& dy)
119 {
120  m_sevenParams[1] = dy;
121 }
122 
123 void te::srs::WKTActions::setDz(const double& dz)
124 {
125  m_sevenParams[2] = dz;
126 }
127 
128 void te::srs::WKTActions::setEx(const double& ex)
129 {
130  m_sevenParams[3] = ex;
131 }
132 
133 void te::srs::WKTActions::setEy(const double& ey)
134 {
135  m_sevenParams[4] = ey;
136 }
137 
138 void te::srs::WKTActions::setEz(const double& ez)
139 {
140  m_sevenParams[5] = ez;
141 }
142 
143 void te::srs::WKTActions::setPPM(const double& ppm)
144 {
145  m_sevenParams[6] = ppm;
146 }
147 
149 {
151 }
152 
153 void te::srs::WKTActions::setAuthorityName(const std::string& name)
154 {
155  m_authorityName = name;
156 }
157 
158 void te::srs::WKTActions::setAuthorityCode(const std::string& code)
159 {
160  m_authorityCode = code;
161 }
162 
163 void te::srs::WKTActions::setSpheroidName(const std::string& name)
164 {
165  m_ellps->setName(name);
166 }
167 
169 {
170  m_ellps->setRadium(rad);
171 }
172 
173 void te::srs::WKTActions::setInverseFlattening(const double& invflat)
174 {
175  m_ellps->setInverseFlattening(invflat);
176 }
177 
178 void te::srs::WKTActions::setProjectionName(const std::string& name)
179 {
180  m_projCS->setProjection(name);
181 }
182 
183 void te::srs::WKTActions::setParameter(const std::string& name)
184 {
185  m_parameter.first = name;
186 }
187 
188 void te::srs::WKTActions::setParameterValue(const double& value)
189 {
190  m_parameter.second = value;
191  m_params.insert(m_parameter);
192 }
193 
194 void te::srs::WKTActions::setAxisName(const std::string& name)
195 {
196  m_axis.first = name;
197 }
198 
199 void te::srs::WKTActions::setAxisValue(const std::string& value)
200 {
201  m_axis.second = value;
202  m_axes.insert(m_axis);
203 }
204 
206 {
208  m_ellps = nullptr;
209 }
210 
212 {
214  m_datum = nullptr;
215 }
216 
218 {
219  if(!m_authorityName.empty() && !m_authorityCode.empty()) // The parser read AUTHORITY[name, code]?
220  {
222 
223 // clears authority to the next element use it
224  m_authorityName.clear();
225  m_authorityCode.clear();
226  }
227 
228  if(m_projCS == nullptr)
229  {
230  m_geoCS = nullptr; // The reference is now only in m_srs
231  return;
232  }
233 
235  m_srs = m_projCS;
236 }
237 
239 {
240  if(!m_authorityName.empty() && !m_authorityCode.empty()) // The parser read AUTHORITY[name, code]?
241  {
243  // Clears authority to the next element use it
244  m_authorityName.clear();
245  m_authorityCode.clear();
246  }
247 
249  m_projCS = nullptr; // The reference is now only in m_srs
250 }
251 
253 {
254  return m_srs;
255 }
256 
void reset()
This method resets the Action class to original state.
A geodetic datum defines a reference to measure Earth&#39;s surface.
Definition: Datum.h:35
void setSpheroidName(const std::string &name)
void setProjection(const std::string &projname)
Sets the map projection name.
void setRadium(const double &rad)
Sets the Ellipsoid radium.
Definition: Ellipsoid.cpp:52
void setName(const std::string &name)
Sets the Ellipsoid name.
Definition: Ellipsoid.cpp:42
GeographicCoordinateSystem * m_geoCS
This file contains the support to represent a geodetic datum.
std::map< std::string, double > m_params
void setUnitName(const std::string &name)
Sets the SRS unit name.
std::pair< std::string, std::string > m_axis
A Geographic Coordinate System (GEOGCS).
void setPrimeMeridian(const double &primem)
static te::dt::Date dx(2010, 12, 31)
void setAuthorityName(const std::string &name)
~WKTActions()
Destructor.
void setToWGS84Params(const std::vector< double > &params)
Sets the Datum shifting parameters relative to WGS84.
Definition: Datum.cpp:65
void setAxisValue(const std::string &value)
void setConversionFactor(const double &f)
void setName(const std::string &name)
Sets the SRS name.
void setEx(const double &ex)
void createGeographicCoordinateSystem()
A Spatial Reference System, also known as a Coordinate System.
void setDatum(Datum *datum)
Sets the associated Datum.
std::vector< double > m_sevenParams
void setUnitName(const std::string &name)
This file contains the structs necessary to represent a ProjectedCoordinateSystem.
void setPPM(const double &ppm)
void setEz(const double &ez)
void setDx(const double &dx)
void setProjectionName(const std::string &name)
void setDy(const double &dy)
void setPrimem(double primen)
Sets the meridian used to take longitude measurements from.
void setEllipsoid(Ellipsoid *ellps)
Sets the Ellipsoid associated to the Datum.
Definition: Datum.cpp:57
void setInverseFlattening(const double &invflat)
Sets the Ellipsoid inverse flattening.
Definition: Ellipsoid.cpp:62
void setDatumName(const std::string &name)
WKTActions()
Default constructor.
void setAxisName(const std::string &name)
std::map< std::string, std::string > m_axes
void setSemiMajorAxis(const double &rad)
ProjectedCoordinateSystem * m_projCS
This file contains the structs necessary to represent a GeographicCoordinateSystem.
A Projected Coordinate System (PROJCS).
std::string m_authorityCode
void setName(const std::string &name)
Sets the Datum name.
Definition: Datum.cpp:47
A reference ellipsoid is an approximation of the Earth&#39;s surface as a squashed sphere.
Definition: Ellipsoid.h:50
void setParameters(const std::map< std::string, double > &params)
Sets the projection parameters.
void setSRID(int id, const std::string &authName="EPSG")
Sets the SRS integer identification.
SpatialReferenceSystem * getSRS()
It returns the SRS generated by the parser process.
SpatialReferenceSystem * m_srs
void setParameter(const std::string &name)
void endGeographicCoordinateSystem()
void setName(const std::string &name)
void setGeographicCoordinateSystem(GeographicCoordinateSystem *geogcs)
Sets the underlying Geographic Coordinate Reference System.
void setParameterValue(const double &value)
std::string m_authorityName
void setEy(const double &ey)
This file contains the structs necessary to model an Ellipsoid.
void setDz(const double &dz)
void createProjectedCoordinateSystem()
void setAuthorityCode(const std::string &code)
void setInverseFlattening(const double &invflat)
std::pair< std::string, double > m_parameter