NIXMLEdgesHandler.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef NIXMLEdgesHandler_h
00020 #define NIXMLEdgesHandler_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 <utils/geom/Position2DVector.h>
00033 #include <utils/xml/SUMOSAXHandler.h>
00034 #include <netbuild/NBEdge.h>
00035
00036
00037
00038
00039
00040 class OptionsCont;
00041 class NBNode;
00042 class NBEdge;
00043 class NBNodeCont;
00044 class NBEdgeCont;
00045 class NBTypeCont;
00046 class NBDistrictCont;
00047
00048
00049
00050
00051
00060 class NIXMLEdgesHandler : public SUMOSAXHandler {
00061 public:
00069 NIXMLEdgesHandler(NBNodeCont &nc, NBEdgeCont &ec,
00070 NBTypeCont &tc, NBDistrictCont &dc, OptionsCont &options) throw();
00071
00072
00074 ~NIXMLEdgesHandler() throw();
00075
00076
00077 protected:
00079
00080
00088 void myStartElement(SumoXMLTag element,
00089 const SUMOSAXAttributes &attrs) throw(ProcessError);
00090
00091
00098 void myEndElement(SumoXMLTag element) throw(ProcessError);
00100
00101
00102 private:
00110 Position2DVector tryGetShape(const SUMOSAXAttributes &attrs) throw();
00111
00112
00120 bool setNodes(const SUMOSAXAttributes &attrs) throw();
00121
00122
00125 SUMOReal tryGetPosition(const SUMOSAXAttributes &attrs, SumoXMLAttr attrID,
00126 const std::string &attrName);
00127
00128
00129 NBNode * insertNodeChecking(const Position2D &pos,
00130 const std::string &name, const std::string &dir);
00131
00132
00137 void parseSplitLanes(const std::string &val) throw(ProcessError);
00138
00139
00140 private:
00142 OptionsCont &myOptions;
00143
00145 std::string myCurrentID;
00146
00148 SUMOReal myCurrentSpeed;
00149
00151 int myCurrentPriority;
00152
00154 int myCurrentLaneNo;
00155
00157 std::string myCurrentType;
00158
00160 NBNode *myFromNode, *myToNode;
00161
00163 SUMOReal myLength;
00164
00166 Position2DVector myShape;
00167
00169 NBEdge::LaneSpreadFunction myLanesSpread;
00170
00172 NBNodeCont &myNodeCont;
00173
00175 NBEdgeCont &myEdgeCont;
00176
00178 NBTypeCont &myTypeCont;
00179
00181 NBDistrictCont &myDistrictCont;
00182
00184 bool myIsUpdate;
00185
00187 NBEdge *myCurrentEdge;
00188
00189
00193 struct Split {
00195 std::vector<int> lanes;
00197 SUMOReal pos;
00199 int nameid;
00201 Position2D gpos;
00202 };
00203
00205 std::vector<Split> mySplits;
00206
00207
00211 class split_sorter {
00212 public:
00214 explicit split_sorter() { }
00215
00217 int operator()(const Split &e1, const Split &e2) const {
00218 return e1.pos < e2.pos;
00219 }
00220 };
00221
00222
00226 class split_by_pos_finder {
00227 public:
00229 explicit split_by_pos_finder(SUMOReal pos)
00230 : myPosition(pos) { }
00231
00233 bool operator()(const Split &e) {
00234 return e.pos==myPosition;
00235 }
00236
00237 private:
00239 SUMOReal myPosition;
00240
00241 };
00242
00243
00245 bool myHaveReportedAboutFunctionDeprecation;
00246
00248 bool myHaveReportedAboutOverwriting;
00249
00250
00251 private:
00253 NIXMLEdgesHandler(const NIXMLEdgesHandler &s);
00254
00256 NIXMLEdgesHandler &operator=(const NIXMLEdgesHandler &s);
00257
00258 };
00259
00260
00261 #endif
00262
00263
00264