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 /****************************************************************************/
14 // -------------------
15 /****************************************************************************/
16 
17 
18 // ===========================================================================
19 // included modules
20 // ===========================================================================
21 #include <config.h>
22 
23 
24 #include <map>
25 #include "NIVissimEdgePosMap.h"
26 
27 
29 
30 
32 
33 
34 void
35 NIVissimEdgePosMap::add(int edgeid, double pos) {
36  add(edgeid, pos, pos);
37 }
38 
39 
40 void
41 NIVissimEdgePosMap::add(int edgeid, double from, double to) {
42  if (from > to) {
43  double tmp = from;
44  from = to;
45  to = tmp;
46  }
47  ContType::iterator i = myCont.find(edgeid);
48  if (i == myCont.end()) {
49  myCont[edgeid] = Range(from, to);
50  } else {
51  double pfrom = (*i).second.first;
52  double pto = (*i).second.second;
53  if (pfrom < from) {
54  from = pfrom;
55  }
56  if (pto > to) {
57  to = pto;
58  }
59  myCont[edgeid] = Range(from, to);
60  }
61 }
62 
63 
64 void
66  for (ContType::iterator i = with.myCont.begin(); i != with.myCont.end(); i++) {
67  add((*i).first, (*i).second.first, (*i).second.second);
68  }
69 }
70 
71 
72 
73 /****************************************************************************/
74 
NIVissimEdgePosMap::Range
std::pair< double, double > Range
Definition: NIVissimEdgePosMap.h:42
NIVissimEdgePosMap::myCont
ContType myCont
Definition: NIVissimEdgePosMap.h:44
NIVissimEdgePosMap::join
void join(NIVissimEdgePosMap &with)
Definition: NIVissimEdgePosMap.cpp:65
NIVissimEdgePosMap::~NIVissimEdgePosMap
~NIVissimEdgePosMap()
Definition: NIVissimEdgePosMap.cpp:31
NIVissimEdgePosMap::add
void add(int edgeid, double pos)
Definition: NIVissimEdgePosMap.cpp:35
NIVissimEdgePosMap::NIVissimEdgePosMap
NIVissimEdgePosMap()
Definition: NIVissimEdgePosMap.cpp:28
config.h
NIVissimEdgePosMap
Definition: NIVissimEdgePosMap.h:34
NIVissimEdgePosMap.h