Eclipse SUMO - Simulation of Urban MObility
GeoConvHelper.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // static methods for processing the coordinates conversion for the current net
17 /****************************************************************************/
18 #ifndef GeoConvHelper_h
19 #define GeoConvHelper_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <map>
28 #include <string>
29 #include <utils/geom/Position.h>
30 #include <utils/geom/Boundary.h>
31 
32 #ifdef PROJ_API_FILE
33 #include PROJ_API_FILE
34 #ifdef PROJ_VERSION_MAJOR
35 typedef PJ* projPJ;
36 #endif
37 #endif
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 
44 class OptionsCont;
45 class PositionVector;
46 class OutputDevice;
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
56 public:
57 
62 
64  GeoConvHelper(const std::string& proj, const Position& offset,
65  const Boundary& orig, const Boundary& conv, double scale = 1.0, double rot = 0.0, bool inverse = false, bool flatten = false);
66 
69 
74  static void addProjectionOptions(OptionsCont& oc);
75 
77  static bool init(OptionsCont& oc);
78 
80  static void init(const std::string& proj, const Position& offset, const Boundary& orig,
81  const Boundary& conv, double scale = 1.0);
82 
87  return myProcessing;
88  }
89 
92  return myLoaded;
93  }
94 
95  static int getNumLoaded() {
96  return myNumLoaded;
97  }
98 
102  static void computeFinal(bool lefthand = false);
103 
105  static const GeoConvHelper& getFinal() {
106  return myFinal;
107  }
108 
110  static void setLoaded(const GeoConvHelper& loaded);
111 
113  static void resetLoaded();
114 
116  void cartesian2geo(Position& cartesian) const;
117 
121  bool x2cartesian(Position& from, bool includeInBoundary = true);
122 
124  bool x2cartesian_const(Position& from) const;
125 
127  bool usingGeoProjection() const;
128 
130  bool usingInverseGeoProjection() const;
131 
133  void moveConvertedBy(double x, double y);
134 
136  const Boundary& getOrigBoundary() const;
137 
139  const Boundary& getConvBoundary() const;
140 
142  void setConvBoundary(const Boundary& boundary) {
143  myConvBoundary = boundary;
144  }
145 
147  const Position getOffset() const;
148 
150  const Position getOffsetBase() const;
151 
153  const std::string& getProjString() const;
154 
156  static void writeLocation(OutputDevice& into);
157 
158  bool operator==(const GeoConvHelper& o) const;
159 
160  bool operator!=(const GeoConvHelper& o) const {
161  return !(*this == o);
162  }
163 
164 private:
172  PROJ
173  };
174 
176  std::string myProjString;
177 
178 #ifdef PROJ_API_FILE
179  projPJ myProjection;
181 
183  projPJ myInverseProjection;
184 
186  projPJ myGeoProjection;
187 #endif
188 
191 
193  double myGeoScale;
194 
196  double mySin;
197  double myCos;
198 
201 
204 
206  bool myFlatten;
207 
210 
213 
216 
219 
222 
224  static int myNumLoaded;
225 
228 
230  GeoConvHelper(const GeoConvHelper&) = delete;
231 };
232 
233 
234 #endif
235 
236 /****************************************************************************/
237 
GeoConvHelper::writeLocation
static void writeLocation(OutputDevice &into)
writes the location element
Definition: GeoConvHelper.cpp:556
Boundary.h
GeoConvHelper::NONE
@ NONE
Definition: GeoConvHelper.h:167
GeoConvHelper::operator!=
bool operator!=(const GeoConvHelper &o) const
Definition: GeoConvHelper.h:160
GeoConvHelper::getConvBoundary
const Boundary & getConvBoundary() const
Returns the converted boundary.
Definition: GeoConvHelper.cpp:489
GeoConvHelper::operator=
GeoConvHelper & operator=(const GeoConvHelper &)
make assignment operator private
Definition: GeoConvHelper.cpp:137
GeoConvHelper::x2cartesian_const
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
Definition: GeoConvHelper.cpp:417
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GeoConvHelper::ProjectionMethod
ProjectionMethod
projection method
Definition: GeoConvHelper.h:166
GeoConvHelper::myCos
double myCos
Definition: GeoConvHelper.h:197
GeoConvHelper::setConvBoundary
void setConvBoundary(const Boundary &boundary)
sets the converted boundary
Definition: GeoConvHelper.h:142
GeoConvHelper::setLoaded
static void setLoaded(const GeoConvHelper &loaded)
sets the coordinate transformation loaded from a location element
Definition: GeoConvHelper.cpp:539
GeoConvHelper::PROJ
@ PROJ
Definition: GeoConvHelper.h:172
GeoConvHelper::getProcessing
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:86
GeoConvHelper::myLoaded
static GeoConvHelper myLoaded
coordinate transformation loaded from a location element
Definition: GeoConvHelper.h:218
GeoConvHelper::getOffset
const Position getOffset() const
Returns the network offset.
Definition: GeoConvHelper.cpp:495
GeoConvHelper::getLoaded
static GeoConvHelper & getLoaded()
the coordinate transformation that was loaded fron an input file
Definition: GeoConvHelper.h:91
PositionVector
A list of positions.
Definition: PositionVector.h:45
GeoConvHelper
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:55
GeoConvHelper::init
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
Definition: GeoConvHelper.cpp:200
GeoConvHelper::x2cartesian
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
Definition: GeoConvHelper.cpp:326
GeoConvHelper::usingGeoProjection
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
Definition: GeoConvHelper.cpp:281
GeoConvHelper::getProjString
const std::string & getProjString() const
Returns the original projection definition.
Definition: GeoConvHelper.cpp:507
GeoConvHelper::myOrigBoundary
Boundary myOrigBoundary
The boundary before conversion (x2cartesian)
Definition: GeoConvHelper.h:209
GeoConvHelper::moveConvertedBy
void moveConvertedBy(double x, double y)
Shifts the converted boundary by the given amounts.
Definition: GeoConvHelper.cpp:476
GeoConvHelper::~GeoConvHelper
~GeoConvHelper()
Destructor.
Definition: GeoConvHelper.cpp:94
GeoConvHelper::myConvBoundary
Boundary myConvBoundary
The boundary after conversion (x2cartesian)
Definition: GeoConvHelper.h:212
GeoConvHelper::myUseInverseProjection
bool myUseInverseProjection
Information whether inverse projection shall be used.
Definition: GeoConvHelper.h:203
GeoConvHelper::getFinal
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
Definition: GeoConvHelper.h:105
GeoConvHelper::GeoConvHelper
GeoConvHelper(OptionsCont &oc)
Constructor based on the stored options.
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GeoConvHelper::addProjectionOptions
static void addProjectionOptions(OptionsCont &oc)
Adds projection options to the given container.
Definition: GeoConvHelper.cpp:248
GeoConvHelper::myProjString
std::string myProjString
A proj options string describing the proj.4-projection to use.
Definition: GeoConvHelper.h:176
GeoConvHelper::getOrigBoundary
const Boundary & getOrigBoundary() const
Returns the original boundary.
Definition: GeoConvHelper.cpp:483
GeoConvHelper::cartesian2geo
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
Definition: GeoConvHelper.cpp:293
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GeoConvHelper::getOffsetBase
const Position getOffsetBase() const
Returns the network base.
Definition: GeoConvHelper.cpp:501
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:89
GeoConvHelper::DHDN
@ DHDN
Definition: GeoConvHelper.h:170
GeoConvHelper::SIMPLE
@ SIMPLE
Definition: GeoConvHelper.h:168
GeoConvHelper::myFlatten
bool myFlatten
whether to discard z-data
Definition: GeoConvHelper.h:206
GeoConvHelper::operator==
bool operator==(const GeoConvHelper &o) const
Definition: GeoConvHelper.cpp:121
Position.h
GeoConvHelper::GeoConvHelper
GeoConvHelper(const GeoConvHelper &)=delete
invalidated copy constructor.
GeoConvHelper::myNumLoaded
static int myNumLoaded
the numer of coordinate transformations loaded from location elements
Definition: GeoConvHelper.h:224
GeoConvHelper::DHDN_UTM
@ DHDN_UTM
Definition: GeoConvHelper.h:171
GeoConvHelper::UTM
@ UTM
Definition: GeoConvHelper.h:169
GeoConvHelper::myGeoScale
double myGeoScale
The scaling to apply to geo-coordinates.
Definition: GeoConvHelper.h:193
GeoConvHelper::myOffset
Position myOffset
The offset to apply.
Definition: GeoConvHelper.h:190
GeoConvHelper::computeFinal
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data,...
Definition: GeoConvHelper.cpp:513
GeoConvHelper::usingInverseGeoProjection
bool usingInverseGeoProjection() const
Returns the information whether an inverse transformation will happen.
Definition: GeoConvHelper.cpp:287
config.h
GeoConvHelper::myFinal
static GeoConvHelper myFinal
coordinate transformation to use for writing the location element and for tracking the original coord...
Definition: GeoConvHelper.h:221
GeoConvHelper::myProjectionMethod
ProjectionMethod myProjectionMethod
Information whether no projection shall be done.
Definition: GeoConvHelper.h:200
GeoConvHelper::resetLoaded
static void resetLoaded()
resets loaded location elements
Definition: GeoConvHelper.cpp:550
GeoConvHelper::mySin
double mySin
The rotation to apply to geo-coordinates.
Definition: GeoConvHelper.h:196
GeoConvHelper::myProcessing
static GeoConvHelper myProcessing
coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:215
GeoConvHelper::getNumLoaded
static int getNumLoaded()
Definition: GeoConvHelper.h:95