NIImporter_OpenStreetMap.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef NIImporter_OpenStreetMap_h
00020 #define NIImporter_OpenStreetMap_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <string>
00033 #include <map>
00034 #include <utils/xml/SUMOSAXHandler.h>
00035 #include <utils/common/UtilExceptions.h>
00036
00037
00038
00039
00040
00041 class NBEdge;
00042 class NBEdgeCont;
00043 class NBNetBuilder;
00044 class NBNode;
00045 class NBNodeCont;
00046 class NBTrafficLightLogicCont;
00047 class NBTypeCont;
00048 class OptionsCont;
00049
00050
00051
00052
00053
00059 class NIImporter_OpenStreetMap {
00060 public:
00072 static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb);
00073
00074
00075 protected:
00078 struct NIOSMNode {
00080 int id;
00082 double lon;
00084 double lat;
00086 bool tlsControlled;
00087 };
00088
00089
00092 struct Edge {
00094 std::string id;
00096 int myNoLanes;
00098 double myMaxSpeed;
00100 std::string myHighWayType;
00102 std::string myIsOneWay;
00104 std::vector<int> myCurrentNodes;
00106 bool myCurrentIsRoad;
00107 };
00108
00109
00110 private:
00111 class CompareNodesInPairs;
00112 class SubstituteNode;
00113 class SimilarEdge;
00114
00129 static NBNode *insertNodeChecking(int id, const std::map<int, NIOSMNode*> &osmNodes,
00130 NBNodeCont &nc, NBTrafficLightLogicCont &tlsc) throw(ProcessError);
00131
00132
00146 static void insertEdge(Edge *e, int index, NBNode *from, NBNode *to,
00147 const std::vector<int> &passed, const std::map<int, NIOSMNode*> &osmNodes,
00148 NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc) throw(ProcessError);
00149
00150
00151
00156 class NodesHandler : public SUMOSAXHandler {
00157 public:
00162 NodesHandler(std::map<int, NIOSMNode*> &toFill) throw();
00163
00164
00166 ~NodesHandler() throw();
00167
00168
00169 protected:
00171
00172
00180 void myStartElement(SumoXMLTag element, const SUMOSAXAttributes &attrs) throw(ProcessError);
00181
00182
00189 void myEndElement(SumoXMLTag element) throw(ProcessError);
00191
00192
00193 private:
00195 std::map<int, NIOSMNode*> &myToFill;
00196
00197 int myLastNodeID;
00198 bool myIsInValidNodeTag;
00199 int myHierarchyLevel;
00200
00201 private:
00203 NodesHandler(const NodesHandler &s);
00204
00206 NodesHandler &operator=(const NodesHandler &s);
00207
00208 };
00209
00210
00211
00216 class EdgesHandler : public SUMOSAXHandler {
00217 public:
00223 EdgesHandler(const std::map<int, NIOSMNode*> &osmNodes,
00224 std::map<std::string, Edge*> &toFill) throw();
00225
00226
00228 ~EdgesHandler() throw();
00229
00230
00231 protected:
00233
00234
00242 void myStartElement(SumoXMLTag element, const SUMOSAXAttributes &attrs) throw(ProcessError);
00243
00244
00251 void myEndElement(SumoXMLTag element) throw(ProcessError);
00253
00254
00255 private:
00257 const std::map<int, NIOSMNode*> &myOSMNodes;
00258
00260 std::map<std::string, Edge*> &myEdgeMap;
00261
00263 Edge *myCurrentEdge;
00264
00266 std::vector<SumoXMLTag> myParentElements;
00267
00268
00269 private:
00271 EdgesHandler(const EdgesHandler &s);
00272
00274 EdgesHandler &operator=(const EdgesHandler &s);
00275
00276 };
00277
00278
00279 };
00280
00281
00282 #endif
00283
00284
00285