Line data Source code
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 : /****************************************************************************/
12 : /// @file TraCI_Junction.cpp
13 : /// @author Daniel Krajzewicz
14 : /// @author Mario Krumnow
15 : /// @author Jakob Erdmann
16 : /// @author Michael Behrisch
17 : /// @author Robert Hilbrich
18 : /// @date 30.05.2012
19 : /// @version $Id$
20 : ///
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 :
34 : #include <utils/shapes/PointOfInterest.h>
35 : #include <utils/shapes/ShapeContainer.h>
36 : #include <microsim/MSNet.h>
37 : #include <microsim/MSJunctionControl.h>
38 : #include "TraCI_Junction.h"
39 : #include "TraCI.h"
40 :
41 :
42 : // ===========================================================================
43 : // member definitions
44 : // ===========================================================================
45 : std::vector<std::string>
46 22 : TraCI_Junction::getIDList() {
47 22 : std::vector<std::string> ids;
48 22 : MSNet::getInstance()->getJunctionControl().insertIDs(ids);
49 22 : return ids;
50 : }
51 :
52 : int
53 5 : TraCI_Junction::getIDCount() {
54 5 : return (int) getIDList().size();
55 : }
56 :
57 : TraCIPosition
58 6013 : TraCI_Junction::getPosition(const std::string& junctionID) {
59 6013 : return TraCI::makeTraCIPosition(getJunction(junctionID)->getPosition());
60 : }
61 :
62 : TraCIPositionVector
63 2 : TraCI_Junction::getShape(const std::string& junctionID) {
64 2 : return TraCI::makeTraCIPositionVector(getJunction(junctionID)->getShape());
65 : }
66 :
67 : MSJunction*
68 18027 : TraCI_Junction::getJunction(const std::string& id) {
69 18027 : MSJunction* j = MSNet::getInstance()->getJunctionControl().get(id);
70 18027 : if (j == 0) {
71 2 : throw TraCIException("Junction '" + id + "' is not known");
72 : }
73 18025 : return j;
74 43554 : }
75 :
76 :
77 : /****************************************************************************/
|