SUMO - Simulation of Urban MObility
NIVissimEdgePosMap.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // -------------------
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 
32 #include <map>
33 #include "NIVissimEdgePosMap.h"
34 
35 
37 
38 
40 
41 
42 void
43 NIVissimEdgePosMap::add(int edgeid, double pos) {
44  add(edgeid, pos, pos);
45 }
46 
47 
48 void
49 NIVissimEdgePosMap::add(int edgeid, double from, double to) {
50  if (from > to) {
51  double tmp = from;
52  from = to;
53  to = tmp;
54  }
55  ContType::iterator i = myCont.find(edgeid);
56  if (i == myCont.end()) {
57  myCont[edgeid] = Range(from, to);
58  } else {
59  double pfrom = (*i).second.first;
60  double pto = (*i).second.second;
61  if (pfrom < from) {
62  from = pfrom;
63  }
64  if (pto > to) {
65  to = pto;
66  }
67  myCont[edgeid] = Range(from, to);
68  }
69 }
70 
71 
72 void
74  for (ContType::iterator i = with.myCont.begin(); i != with.myCont.end(); i++) {
75  add((*i).first, (*i).second.first, (*i).second.second);
76  }
77 }
78 
79 
80 
81 /****************************************************************************/
82 
std::pair< double, double > Range
void add(int edgeid, double pos)
void join(NIVissimEdgePosMap &with)