SUMO - Simulation of Urban MObility
Junction.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2017-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 /****************************************************************************/
21 // C++ TraCI client API implementation
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
36 #include <microsim/MSNet.h>
38 #include "Helper.h"
39 #include "Junction.h"
40 
41 
42 // ===========================================================================
43 // member definitions
44 // ===========================================================================
45 namespace libsumo {
46 std::vector<std::string>
48  std::vector<std::string> ids;
50  return ids;
51 }
52 
53 int
55  return (int)getIDList().size();
56 }
57 
59 Junction::getPosition(const std::string& junctionID) {
60  return Helper::makeTraCIPosition(getJunction(junctionID)->getPosition());
61 }
62 
64 Junction::getShape(const std::string& junctionID) {
66 }
67 
69 Junction::getJunction(const std::string& id) {
71  if (j == 0) {
72  throw TraCIException("Junction '" + id + "' is not known");
73  }
74  return j;
75 }
76 
79  NamedRTree* t = new NamedRTree();
80  for (const auto& i : MSNet::getInstance()->getJunctionControl()) {
81  Boundary b = i.second->getShape().getBoxBoundary();
82  const float cmin[2] = {(float) b.xmin(), (float) b.ymin()};
83  const float cmax[2] = {(float) b.xmax(), (float) b.ymax()};
84  t->Insert(cmin, cmax, i.second);
85  }
86  return t;
87 }
88 
89 }
90 
91 
92 /****************************************************************************/
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
Definition: NamedRTree.h:89
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:137
static int getIDCount()
Definition: Junction.cpp:54
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:131
The base class for an intersection.
Definition: MSJunction.h:64
T get(const std::string &id) const
Retrieves an item.
static TraCIPosition makeTraCIPosition(const Position &position)
Definition: Helper.cpp:147
A RT-tree for efficient storing of SUMO&#39;s Named objects.
Definition: NamedRTree.h:71
static NamedRTree * getTree()
Returns a tree filled with junction instances.
Definition: Junction.cpp:78
static TraCIPosition getPosition(const std::string &junctionID)
Definition: Junction.cpp:59
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
Definition: Helper.cpp:110
void insertIDs(std::vector< std::string > &into) const
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
static MSJunction * getJunction(const std::string &id)
Definition: Junction.cpp:69
static TraCIPositionVector getShape(const std::string &junctionID)
Definition: Junction.cpp:64
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:125
Definition: Edge.cpp:31
MSJunctionControl & getJunctionControl()
Returns the junctions control.
Definition: MSNet.h:389
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:143
A 3D-position.
Definition: TraCIDefs.h:71
static std::vector< std::string > getIDList()
Definition: Junction.cpp:47
A list of positions.