SUMO - Simulation of Urban MObility
GeoConvHelper.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // static methods for processing the coordinates conversion for the current net
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef GeoConvHelper_h
00023 #define GeoConvHelper_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <map>
00036 #include <string>
00037 #include <utils/geom/Position.h>
00038 #include <utils/geom/Boundary.h>
00039 
00040 #ifdef HAVE_PROJ
00041 #include <proj_api.h>
00042 #endif
00043 
00044 
00045 // ===========================================================================
00046 // class declarations
00047 // ===========================================================================
00048 class OptionsCont;
00049 
00050 
00051 // ===========================================================================
00052 // class definitions
00053 // ===========================================================================
00058 class GeoConvHelper {
00059 public:
00060 
00064     GeoConvHelper(OptionsCont& oc);
00065 
00068     GeoConvHelper(const std::string& proj, const Position& offset,
00069                   const Boundary& orig, const Boundary& conv, int shift = 0, bool inverse = false, bool baseFound = false);
00070 
00071 
00073     ~GeoConvHelper();
00074 
00075 
00081     static void addProjectionOptions(OptionsCont& oc);
00082 
00084     static bool init(OptionsCont& oc);
00085 
00087     static void init(const std::string& proj,
00088                      const Position& offset,
00089                      const Boundary& orig,
00090                      const Boundary& conv);
00091 
00095     static GeoConvHelper& getProcessing() {
00096         return myProcessing;
00097     }
00098 
00099 
00103     static void computeFinal();
00104 
00105 
00109     static const GeoConvHelper& getFinal() {
00110         return myFinal;
00111     }
00112 
00113 
00116     static void setLoaded(const GeoConvHelper& loaded);
00117 
00118 
00121     static void resetLoaded();
00122 
00124     void cartesian2geo(Position& cartesian) const;
00125 
00130     bool x2cartesian(Position& from, bool includeInBoundary = true);
00131 
00133     bool x2cartesian_const(Position& from) const;
00134 
00136     bool usingGeoProjection() const;
00137 
00139     bool usingInverseGeoProjection() const;
00140 
00142     void moveConvertedBy(SUMOReal x, SUMOReal y);
00143 
00145     const Boundary& getOrigBoundary() const;
00146 
00148     const Boundary& getConvBoundary() const;
00149 
00151     const Position getOffset() const;
00152 
00154     const Position getOffsetBase() const;
00155 
00157     const std::string& getProjString() const;
00158 
00159 private:
00160     enum ProjectionMethod {
00161         NONE,
00162         SIMPLE,
00163         UTM,
00164         DHDN,
00165         PROJ
00166     };
00167 
00169     std::string myProjString;
00170 
00171 #ifdef HAVE_PROJ
00172 
00173     projPJ myProjection;
00174 #endif
00175 
00177     Position myOffset;
00178 
00180     double myGeoScale;
00181 
00183     ProjectionMethod myProjectionMethod;
00184 
00186     bool myUseInverseProjection;
00187 
00189     bool myBaseFound;
00190 
00192     double myBaseX, myBaseY;
00193 
00195     Boundary myOrigBoundary;
00196 
00198     Boundary myConvBoundary;
00199 
00201     static GeoConvHelper myProcessing;
00202 
00204     static GeoConvHelper myLoaded;
00205 
00207     static GeoConvHelper myFinal;
00208 
00210     static int myNumLoaded;
00211 
00213     GeoConvHelper& operator=(const GeoConvHelper&);
00214 
00216     GeoConvHelper(const GeoConvHelper&);
00217 
00218 };
00219 
00220 
00221 #endif
00222 
00223 /****************************************************************************/
00224 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines