SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GeoConvHelper.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // static methods for processing the coordinates conversion for the current net
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GeoConvHelper_h
23 #define GeoConvHelper_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <map>
36 #include <string>
37 #include <utils/geom/Position.h>
38 #include <utils/geom/Boundary.h>
39 
40 #ifdef HAVE_PROJ
41 #include <proj_api.h>
42 #endif
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class OptionsCont;
49 class PositionVector;
50 class OutputDevice;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
61 public:
62 
67 
70  GeoConvHelper(const std::string& proj, const Position& offset,
71  const Boundary& orig, const Boundary& conv, int shift = 0, bool inverse = false);
72 
73 
76 
77 
83  static void addProjectionOptions(OptionsCont& oc);
84 
86  static bool init(OptionsCont& oc);
87 
89  static void init(const std::string& proj,
90  const Position& offset,
91  const Boundary& orig,
92  const Boundary& conv,
93  int shift = 0);
94 
99  return myProcessing;
100  }
101 
105  return myLoaded;
106  }
107 
111  static void computeFinal(bool lefthand = false);
112 
113 
117  static const GeoConvHelper& getFinal() {
118  return myFinal;
119  }
120 
121 
124  static void setLoaded(const GeoConvHelper& loaded);
125 
126 
129  static void resetLoaded();
130 
132  void cartesian2geo(Position& cartesian) const;
133 
138  bool x2cartesian(Position& from, bool includeInBoundary = true);
139 
141  bool x2cartesian_const(Position& from) const;
142 
144  bool usingGeoProjection() const;
145 
147  bool usingInverseGeoProjection() const;
148 
150  void moveConvertedBy(SUMOReal x, SUMOReal y);
151 
153  const Boundary& getOrigBoundary() const;
154 
156  const Boundary& getConvBoundary() const;
157 
159  void setConvBoundary(const Boundary& boundary) {
160  myConvBoundary = boundary;
161  }
162 
164  const Position getOffset() const;
165 
167  const Position getOffsetBase() const;
168 
170  const std::string& getProjString() const;
171 
173  static void writeLocation(OutputDevice& into);
174 
175 private:
183  };
184 
186  std::string myProjString;
187 
188 #ifdef HAVE_PROJ
189  projPJ myProjection;
191 
193  projPJ myInverseProjection;
194 
196  projPJ myGeoProjection;
197 #endif
198 
201 
203  double myGeoScale;
204 
207 
210 
213 
216 
219 
222 
225 
227  static int myNumLoaded;
228 
231 
234 
235 };
236 
237 
238 #endif
239 
240 /****************************************************************************/
241 
static void writeLocation(OutputDevice &into)
writes the location element
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
void setConvBoundary(const Boundary &boundary)
sets the converted boundary
static GeoConvHelper myProcessing
coordinate transformation to use for input conversion and processing
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
~GeoConvHelper()
Destructor.
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:98
bool x2cartesian(Position &from, bool includeInBoundary=true)
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
static GeoConvHelper myLoaded
coordinate transformation loaded from a location element
static void resetLoaded()
resets loaded location elements
bool myUseInverseProjection
Information whether inverse projection shall be used.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
double myGeoScale
The scaling to apply to geo-coordinates.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:60
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:46
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.
const std::string & getProjString() const
Returns the network offset.
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
const Position getOffsetBase() const
Returns the network base.
const Boundary & getConvBoundary() const
Returns the converted boundary.
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:99
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const Position getOffset() const
Returns the network offset.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
const Boundary & getOrigBoundary() const
Returns the original boundary.
bool usingInverseGeoProjection() const
Returns the information whether an inverse transformation will happen.
void moveConvertedBy(SUMOReal x, SUMOReal y)
Shifts the converted boundary by the given amounts.
GeoConvHelper & operator=(const GeoConvHelper &)
assignment operator.