Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // -------------------
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 
25 #include <map>
26 #include "NIVissimEdgePosMap.h"
27 
28 
30 
31 
33 
34 
35 void
36 NIVissimEdgePosMap::add(int edgeid, double pos) {
37  add(edgeid, pos, pos);
38 }
39 
40 
41 void
42 NIVissimEdgePosMap::add(int edgeid, double from, double to) {
43  if (from > to) {
44  double tmp = from;
45  from = to;
46  to = tmp;
47  }
48  ContType::iterator i = myCont.find(edgeid);
49  if (i == myCont.end()) {
50  myCont[edgeid] = Range(from, to);
51  } else {
52  double pfrom = (*i).second.first;
53  double pto = (*i).second.second;
54  if (pfrom < from) {
55  from = pfrom;
56  }
57  if (pto > to) {
58  to = pto;
59  }
60  myCont[edgeid] = Range(from, to);
61  }
62 }
63 
64 
65 void
67  for (ContType::iterator i = with.myCont.begin(); i != with.myCont.end(); i++) {
68  add((*i).first, (*i).second.first, (*i).second.second);
69  }
70 }
71 
72 
73 
74 /****************************************************************************/
75 
std::pair< double, double > Range
void add(int edgeid, double pos)
void join(NIVissimEdgePosMap &with)