NIImporter_OpenStreetMap.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Importer for networks stored in OpenStreetMap format
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 NIImporter_OpenStreetMap_h
00020 #define NIImporter_OpenStreetMap_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 <string>
00033 #include <map>
00034 #include <utils/xml/SUMOSAXHandler.h>
00035 #include <utils/common/UtilExceptions.h>
00036 
00037 
00038 // ===========================================================================
00039 // class declarations
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 // class definitions
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 

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