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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // static methods for processing the coordinates conversion for the current net
20 /****************************************************************************/
21 #ifndef GeoConvHelper_h
22 #define GeoConvHelper_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <map>
35 #include <string>
36 #include <utils/geom/Position.h>
37 #include <utils/geom/Boundary.h>
38 
39 #ifdef HAVE_PROJ
40 #include <proj_api.h>
41 #endif
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 
48 class OptionsCont;
49 class PositionVector;
50 class OutputDevice;
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
60 public:
61 
66 
68  GeoConvHelper(const std::string& proj, const Position& offset,
69  const Boundary& orig, const Boundary& conv, double scale = 1.0, bool inverse = false);
70 
73 
78  static void addProjectionOptions(OptionsCont& oc);
79 
81  static bool init(OptionsCont& oc);
82 
84  static void init(const std::string& proj, const Position& offset, const Boundary& orig,
85  const Boundary& conv, double scale = 1.0);
86 
91  return myProcessing;
92  }
93 
96  return myLoaded;
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 private:
167  };
168 
170  std::string myProjString;
171 
172 #ifdef HAVE_PROJ
173  projPJ myProjection;
175 
177  projPJ myInverseProjection;
178 
180  projPJ myGeoProjection;
181 #endif
182 
185 
187  double myGeoScale;
188 
191 
194 
197 
200 
203 
206 
209 
211  static int myNumLoaded;
212 
215 
217  GeoConvHelper(const GeoConvHelper&) = delete;
218 };
219 
220 
221 #endif
222 
223 /****************************************************************************/
224 
static void writeLocation(OutputDevice &into)
writes the location element
void setConvBoundary(const Boundary &boundary)
sets the converted boundary
static GeoConvHelper myProcessing
coordinate transformation to use for input conversion and processing
~GeoConvHelper()
Destructor.
const Boundary & getConvBoundary() const
Returns the converted boundary.
Position myOffset
The offset to apply.
static void computeFinal(bool lefthand=false)
compute the location attributes which will be used for output based on the loaded location data...
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:90
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
ProjectionMethod
projection method
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
Boundary myOrigBoundary
The boundary before conversion (x2cartesian)
static void setLoaded(const GeoConvHelper &loaded)
sets the coordinate transformation loaded from a location element
static GeoConvHelper & getLoaded()
the coordinate transformation that was loaded fron an input file
Definition: GeoConvHelper.h:95
const Boundary & getOrigBoundary() const
Returns the original boundary.
static GeoConvHelper myLoaded
coordinate transformation loaded from a location element
const std::string & getProjString() const
Returns the network offset.
static void resetLoaded()
resets loaded location elements
bool myUseInverseProjection
Information whether inverse projection shall be used.
void moveConvertedBy(double x, double y)
Shifts the converted boundary by the given amounts.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
double myGeoScale
The scaling to apply to geo-coordinates.
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:59
static GeoConvHelper myFinal
coordinate transformation to use for writing the location element and for tracking the original coord...
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
ProjectionMethod myProjectionMethod
Information whether no projection shall be done.
std::string myProjString
A proj options string describing the proj.4-projection to use.
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
static void addProjectionOptions(OptionsCont &oc)
Adds projection options to the given container.
GeoConvHelper(OptionsCont &oc)
Constructor based on the stored options.
Boundary myConvBoundary
The boundary after conversion (x2cartesian)
static int myNumLoaded
the numer of coordinate transformations loaded from location elements
A storage for options typed value containers)
Definition: OptionsCont.h:98
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
bool usingInverseGeoProjection() const
Returns the information whether an inverse transformation will happen.
const Position getOffsetBase() const
Returns the network base.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
const Position getOffset() const
Returns the network offset.
GeoConvHelper & operator=(const GeoConvHelper &)
make assignment operator private