SUMO - Simulation of Urban MObility
NIVissimEdgePosMap.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // -------------------
18 /****************************************************************************/
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 
31 #include <map>
32 #include "NIVissimEdgePosMap.h"
33 
34 
36 
37 
39 
40 
41 void
42 NIVissimEdgePosMap::add(int edgeid, double pos) {
43  add(edgeid, pos, pos);
44 }
45 
46 
47 void
48 NIVissimEdgePosMap::add(int edgeid, double from, double to) {
49  if (from > to) {
50  double tmp = from;
51  from = to;
52  to = tmp;
53  }
54  ContType::iterator i = myCont.find(edgeid);
55  if (i == myCont.end()) {
56  myCont[edgeid] = Range(from, to);
57  } else {
58  double pfrom = (*i).second.first;
59  double pto = (*i).second.second;
60  if (pfrom < from) {
61  from = pfrom;
62  }
63  if (pto > to) {
64  to = pto;
65  }
66  myCont[edgeid] = Range(from, to);
67  }
68 }
69 
70 
71 void
73  for (ContType::iterator i = with.myCont.begin(); i != with.myCont.end(); i++) {
74  add((*i).first, (*i).second.first, (*i).second.second);
75  }
76 }
77 
78 
79 
80 /****************************************************************************/
81 
std::pair< double, double > Range
void add(int edgeid, double pos)
void join(NIVissimEdgePosMap &with)