00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef NIImporter_VISUM_h
00020 #define NIImporter_VISUM_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 <vector>
00035 #include <netbuild/NBCapacity2Lanes.h>
00036 #include <utils/importio/LineHandler.h>
00037 #include <utils/importio/LineReader.h>
00038 #include <utils/importio/NamedColumnsParser.h>
00039 #include "NIVisumTL.h"
00040
00041
00042
00043
00044
00045 class OptionsCont;
00046 class NBNetBuilder;
00047 class NBNodeCont;
00048 class NBEdgeCont;
00049 class NBNode;
00050 class NBEdge;
00051
00052
00053
00054
00055
00074 class NIImporter_VISUM {
00075 public:
00087 static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb);
00088
00089
00090 protected:
00101 NIImporter_VISUM(NBNetBuilder &nb, const std::string &file,
00102 NBCapacity2Lanes capacity2Lanes, bool useVisumPrio) throw();
00103
00104
00106 ~NIImporter_VISUM() throw();
00107
00108
00119 void load() throw(ProcessError);
00120
00121 private:
00130 SUMOReal getNamedFloat(const std::string &fieldName) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00131
00141 SUMOReal getNamedFloat(const std::string &fieldName1, const std::string &fieldName2) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00142
00143
00150 SUMOReal getNamedFloat(const std::string &fieldName, SUMOReal defaultValue) throw();
00151
00159 SUMOReal getNamedFloat(const std::string &fieldName1, const std::string &fieldName2,
00160 SUMOReal defaultValue) throw();
00161
00162
00173 std::string getNamedString(const std::string &fieldName) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00174
00184 std::string getNamedString(const std::string &fieldName1, const std::string &fieldName2) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00185
00186
00196 SUMOReal getWeightedFloat(const std::string &name) throw();
00197
00198
00208 bool getWeightedBool(const std::string &name) throw();
00209
00210
00223 NBNode *getNamedNode(const std::string &fieldName) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00224
00234 NBNode *getNamedNode(const std::string &fieldName1, const std::string &fieldName2) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00235
00236
00249 NBEdge *getNamedEdge(const std::string &fieldName) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00250
00260 NBEdge *getNamedEdge(const std::string &fieldName1, const std::string &fieldName2) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00261
00262
00277 NBEdge *getNamedEdgeContinuating(const std::string &fieldName, NBNode *node) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00278
00289 NBEdge *getNamedEdgeContinuating(const std::string &fieldName1, const std::string &fieldName2,
00290 NBNode *node) throw(OutOfBoundsException, NumberFormatException, UnknownElement);
00291
00298 NBEdge *getNamedEdgeContinuating(NBEdge *begin, NBNode *node) throw();
00299
00300
00307 NBEdge *getEdge(NBNode *FromNode, NBNode *ToNode) throw();
00308
00309
00320 NBEdge *getReversedContinuating(NBEdge *edge, NBNode *node) throw();
00321
00322
00335 NBNode *buildDistrictNode(const std::string &id, NBNode *dest, bool isSource) throw();
00336
00337
00346 bool checkNodes(NBNode *from, NBNode *to) throw();
00347
00348
00349 private:
00356 typedef void (NIImporter_VISUM::*ParsingFunction)();
00357
00362 struct TypeParser {
00366 std::string name;
00367
00371 ParsingFunction function;
00372
00377 long position;
00378
00382 std::string pattern;
00383
00384 };
00385
00387 void parse_VSysTypes();
00388
00390 void parse_Types();
00391
00393 void parse_Nodes();
00394
00396 void parse_Districts();
00397
00399 void parse_Point();
00400
00401
00403 void parse_Edges();
00404
00406 void parse_PartOfArea();
00407
00409 void parse_Kante();
00410
00411
00413 void parse_Connectors();
00414
00416 void parse_Turns();
00417
00419 void parse_EdgePolys();
00420
00422 void parse_Lanes();
00423
00425 void parse_TrafficLights();
00426
00428 void parse_NodesToTrafficLights();
00429
00431 void parse_SignalGroups();
00432
00434 void parse_TurnsToSignalGroups();
00435
00437 void parse_AreaSubPartElement();
00438
00440 void parse_Phases();
00441
00443 void parse_SignalGroupsToPhases();
00444
00446 void parse_LanesConnections();
00447
00448
00455 void addParser(const std::string &name, ParsingFunction function) throw();
00456
00457
00458 private:
00460 NBNetBuilder &myNetBuilder;
00461
00463 std::string myFileName;
00464
00466 LineReader myLineReader;
00467
00471 NamedColumnsParser myLineParser;
00472
00474 NBCapacity2Lanes myCapacity2Lanes;
00475
00477 typedef std::map<std::string, std::string> VSysTypeNames;
00479 VSysTypeNames myVSysTypes;
00480
00482 typedef std::vector<TypeParser> ParserVector;
00484 ParserVector mySingleDataParsers;
00485
00487 typedef std::map<std::string, NIVisumTL*> NIVisumTL_Map;
00488
00489 NIVisumTL_Map myNIVisumTLs;
00490
00492 std::vector<std::string > myTouchedEdges;
00493
00495 bool myUseVisumPrio;
00496
00498 std::string myCurrentID;
00499
00500
00502 std::map<long, Position2D> myPoints;
00503
00505 std::map<long, std::pair<long, long> > myEdges;
00506
00508 std::map<long, NBDistrict*> myShapeDistrictMap;
00509
00511 std::map<long, std::vector<long> > mySubPartsAreas;
00512
00514 std::map<NBDistrict*, Position2DVector> myDistrictShapes;
00515
00516
00517 };
00518
00519
00520 #endif
00521
00522
00523