SUMO - Simulation of Urban MObility

GeoConvHelper.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // static methods for processing the coordinates conversion for the current net
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef GeoConvHelper_h
00020 #define GeoConvHelper_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <map>
00033 #include <string>
00034 #include <utils/geom/Position.h>
00035 #include <utils/geom/Boundary.h>
00036 
00037 #ifdef HAVE_PROJ
00038 #include <proj_api.h>
00039 #endif
00040 
00041 
00042 // ===========================================================================
00043 // class declarations
00044 // ===========================================================================
00045 class OptionsCont;
00046 
00047 
00048 // ===========================================================================
00049 // class definitions
00050 // ===========================================================================
00055 class GeoConvHelper {
00056 public:
00057 
00061     GeoConvHelper(OptionsCont& oc);
00062 
00065     GeoConvHelper(const std::string& proj, const Position& offset,
00066                   const Boundary& orig, const Boundary& conv, int shift=0, bool inverse=false, bool baseFound=false);
00067 
00068 
00070     ~GeoConvHelper();
00071 
00072 
00078     static void addProjectionOptions(OptionsCont& oc);
00079 
00081     static bool init(OptionsCont& oc);
00082 
00084     static void init(const std::string& proj,
00085                      const Position& offset,
00086                      const Boundary& orig,
00087                      const Boundary& conv);
00088 
00092     static GeoConvHelper& getDefaultInstance() {
00093         return myDefault;
00094     }
00095 
00096 
00099     static const GeoConvHelper& getOutputInstance();
00100 
00103     static void setLoaded(const GeoConvHelper& loaded) {
00104         myLoaded = loaded;
00105         myNumLoaded++;
00106     }
00107 
00109     void cartesian2geo(Position& cartesian);
00110 
00112     bool x2cartesian(Position& from, bool includeInBoundary=true);
00113 
00115     bool usingGeoProjection() const;
00116 
00118     bool usingInverseGeoProjection() const;
00119 
00121     void moveConvertedBy(SUMOReal x, SUMOReal y);
00122 
00124     const Boundary& getOrigBoundary() const;
00125 
00127     const Boundary& getConvBoundary() const;
00128 
00130     const Position getOffset() const;
00131 
00133     const Position getOffsetBase() const;
00134 
00136     const std::string& getProjString() const;
00137 
00138 private:
00139     enum ProjectionMethod {
00140         NONE,
00141         SIMPLE,
00142         UTM,
00143         DHDN,
00144         PROJ
00145     };
00146 
00148     std::string myProjString;
00149 
00150 #ifdef HAVE_PROJ
00151 
00152     projPJ myProjection;
00153 #endif
00154 
00156     Position myOffset;
00157 
00159     double myGeoScale;
00160 
00162     ProjectionMethod myProjectionMethod;
00163 
00165     bool myUseInverseProjection;
00166 
00168     bool myBaseFound;
00169 
00171     double myBaseX, myBaseY;
00172 
00174     Boundary myOrigBoundary;
00175 
00177     Boundary myConvBoundary;
00178 
00179 #ifdef HAVE_PROJ
00180 
00181     void initProjection(double x, double y);
00182 #endif
00183 
00185     static GeoConvHelper myDefault;
00186 
00188     static GeoConvHelper myLoaded;
00189 
00191     static GeoConvHelper myOutput;
00192 
00194     static int myNumLoaded;
00195 
00197     GeoConvHelper& operator=(const GeoConvHelper&);
00198 
00200     GeoConvHelper(const GeoConvHelper&);
00201 
00202 };
00203 
00204 
00205 #endif
00206 
00207 /****************************************************************************/
00208 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines