NIVissimEdge.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A temporary storage for edges imported from Vissim
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 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 NIVissimEdge_h
00020 #define NIVissimEdge_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 "NIVissimConnectionCluster.h"
00033 #include <vector>
00034 #include <string>
00035 #include <map>
00036 #include <netbuild/NBEdge.h>
00037 #include <utils/geom/Position2DVector.h>
00038 #include <utils/common/VectorHelper.h>
00039 #include <utils/common/UtilExceptions.h>
00040 #include "NIVissimAbstractEdge.h"
00041 #include "NIVissimClosedLanesVector.h"
00042 
00043 
00044 // ===========================================================================
00045 // class declarations
00046 // ===========================================================================
00047 class NBNode;
00048 class NIVissimDistrictConnection;
00049 class NBDistribution;
00050 class NBDistrictCont;
00051 
00052 
00053 // ===========================================================================
00054 // class definitions
00055 // ===========================================================================
00060 class NIVissimEdge
00061             : public NIVissimAbstractEdge {
00062 public:
00064     NIVissimEdge(int id, const std::string &name,
00065                  const std::string &type, int noLanes, SUMOReal zuschlag1,
00066                  SUMOReal zuschlag2, SUMOReal length,
00067                  const Position2DVector &geom,
00068                  const NIVissimClosedLanesVector &clv);
00069 
00071     ~NIVissimEdge();
00072 
00073     void setNodeCluster(int nodeid);
00074     void buildGeom();
00075 
00077     void addIncomingConnection(int id);
00078 
00080     void addOutgoingConnection(int id);
00081 
00084     NBNode *getNodeAt(const Position2D &p, NBNode *other=0);
00085 
00087     Position2D getBegin2D() const;
00088 
00090     Position2D getEnd2D() const;
00091 
00093     SUMOReal getLength() const;
00094 
00095     void checkDistrictConnectionExistanceAt(SUMOReal pos);
00096 
00097     void mergedInto(NIVissimConnectionCluster *old,
00098                     NIVissimConnectionCluster *act);
00099 
00100     void removeFromConnectionCluster(NIVissimConnectionCluster *c);
00101     void addToConnectionCluster(NIVissimConnectionCluster *c);
00102     void setSpeed(size_t lane, int speedDist);
00103     bool addToTreatAsSame(NIVissimEdge *e);
00104 
00105     NIVissimConnection* getConnectionTo(NIVissimEdge *e);
00106     const std::vector<NIVissimEdge*> &getToTreatAsSame() const;
00107 
00108 
00112     bool wasWithinAJunction() const throw() {
00113         return myAmWithinJunction;
00114     }
00115 
00116     NIVissimEdge *getBestIncoming() const throw();
00117     NIVissimEdge *getBestOutgoing() const throw();
00118 
00119     friend class NIVissimNodeDef_Edges;
00120     friend class NIVissimNodeDef_Poly;
00121 
00122 public:
00125     static bool dictionary(int id, const std::string &name,
00126                            const std::string &type, int noLanes, SUMOReal zuschlag1,
00127                            SUMOReal zuschlag2, SUMOReal length,
00128                            const Position2DVector &geom,
00129                            const NIVissimClosedLanesVector &clv);
00130 
00132     static bool dictionary(int id, NIVissimEdge *o);
00133 
00135     static NIVissimEdge *dictionary(int id);
00136 
00145     static void buildConnectionClusters() throw();
00146 
00148     static void dict_buildNBEdges(NBDistrictCont &dc, NBNodeCont &nc,
00149                                   NBEdgeCont &ec, SUMOReal offset);
00150 
00151     static void dict_propagateSpeeds(/* NBDistribution &dc */);
00152 
00153     static void dict_checkEdges2Join();
00154 
00155 
00164     static void reportUnsetSpeeds() throw();
00165 
00166 
00167 private:
00169     typedef std::vector<NIVissimConnectionCluster*> ConnectionClusters;
00170 
00171 private:
00180     void buildNBEdge(NBDistrictCont &dc, NBNodeCont &nc,
00181                      NBEdgeCont &ec, SUMOReal sameNodesOffset) throw(ProcessError);
00182 
00184     std::pair<NIVissimConnectionCluster*, NBNode*>
00185     getFromNode(NBNodeCont &nc, ConnectionClusters &clusters);
00186 
00188     std::pair<NIVissimConnectionCluster*, NBNode*>
00189     getToNode(NBNodeCont &nc, ConnectionClusters &clusters);
00190 
00192     std::pair<NBNode*, NBNode*> resolveSameNode(NBNodeCont &nc,
00193             SUMOReal offset, NBNode *prevFrom, NBNode *prevTo);
00194 
00195 //    SUMOReal recheckSpeedPatches();
00196 
00197     std::vector<NIVissimConnection*> getOutgoingConnected(int lane) const;
00198 
00199     void propagateSpeed(/* NBDistribution &dc */SUMOReal speed, IntVector forLanes);
00200 
00201 
00202     void setDistrictSpeed(/* NBDistribution &dc */);
00203     SUMOReal getRealSpeed(/* NBDistribution &dc */int distNo);
00204     void checkUnconnectedLaneSpeeds(/* NBDistribution &dc */);
00205     void propagateOwn(/* NBDistribution &dc */);
00206 
00207 
00208 
00209 private:
00210     static NBNode *getNodeSecure(int nodeid, const Position2D &pos,
00211                                  const std::string &possibleName);
00212 
00213     std::pair<NBNode*, NBNode*>
00214     remapOneOfNodes(NBNodeCont &nc,
00215                     NIVissimDistrictConnection *d,
00216                     NBNode *fromNode, NBNode *toNode);
00217 
00218 private:
00223     class connection_position_sorter {
00224     public:
00226         explicit connection_position_sorter(int edgeid);
00227 
00229         int operator()(int c1id, int c2id) const;
00230 
00231     private:
00233         int myEdgeID;
00234 
00235     };
00236 
00237 
00242     class connection_cluster_position_sorter {
00243     public:
00245         explicit connection_cluster_position_sorter(int edgeid);
00246 
00248         int operator()(NIVissimConnectionCluster *cc1,
00249                        NIVissimConnectionCluster *cc2) const;
00250 
00251     private:
00253         int myEdgeID;
00254 
00255     };
00256 
00257 private:
00259     std::string myName;
00260 
00262     std::string myType;
00263 
00265     unsigned int myNoLanes;
00266 
00268     SUMOReal myZuschlag1, myZuschlag2;
00269 
00271     NIVissimClosedLanesVector myClosedLanes;
00272 
00274     ConnectionClusters myConnectionClusters;
00275 
00277     IntVector myIncomingConnections;
00278 
00280     IntVector myOutgoingConnections;
00281 
00282     DoubleVector myDistrictConnections;
00283 
00284     IntVector myPatchedSpeeds;
00285 
00286     std::vector<SUMOReal> myLaneSpeeds;
00287 
00288     std::vector<NIVissimEdge*> myToTreatAsSame;
00289 
00291     bool myAmWithinJunction;
00292 
00293 private:
00295     typedef std::map<int, NIVissimEdge*> DictType;
00296 
00298     static DictType myDict;
00299 
00301     static int myMaxID;
00302 
00303     static std::vector<std::string> myLanesWithMissingSpeeds;
00304 
00305 };
00306 
00307 
00308 #endif
00309 
00310 /****************************************************************************/
00311 

Generated on Wed May 5 00:06:34 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6