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_POI.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 "TraCI_POI.h"
38 : #include "TraCI.h"
39 :
40 :
41 :
42 :
43 : // ===========================================================================
44 : // member definitions
45 : // ===========================================================================
46 : std::vector<std::string>
47 39 : TraCI_POI::getIDList() {
48 39 : std::vector<std::string> ids;
49 39 : ShapeContainer& shapeCont = MSNet::getInstance()->getShapeContainer();
50 39 : shapeCont.getPOIs().insertIDs(ids);
51 39 : return ids;
52 : }
53 :
54 : int
55 14 : TraCI_POI::getIDCount() {
56 14 : return (int)getIDList().size();
57 : }
58 :
59 : std::string
60 18 : TraCI_POI::getType(const std::string& poiID) {
61 18 : return getPoI(poiID)->getType();
62 : }
63 :
64 : TraCIColor
65 74 : TraCI_POI::getColor(const std::string& poiID) {
66 74 : PointOfInterest* sumoPoi = getPoI(poiID);
67 72 : RGBColor col = sumoPoi->getColor();
68 72 : return TraCI::makeTraCIColor(col);
69 : }
70 :
71 : TraCIPosition
72 12054 : TraCI_POI::getPosition(const std::string& poiID) {
73 : TraCIPosition pos;
74 12054 : PointOfInterest* p = getPoI(poiID);
75 12054 : pos.x = p->x();
76 12054 : pos.y = p->y();
77 12054 : pos.z = p->z();
78 12054 : return pos;
79 : }
80 :
81 : std::string
82 14 : TraCI_POI::getParameter(const std::string& poiID, const std::string& param) {
83 14 : PointOfInterest* p = getPoI(poiID);
84 14 : return p->getParameter(param, "");
85 : }
86 :
87 : void
88 5 : TraCI_POI::setType(const std::string& poiID, const std::string& type) {
89 5 : PointOfInterest* p = getPoI(poiID);
90 4 : p->setType(type);
91 4 : }
92 :
93 : void
94 5 : TraCI_POI::setPosition(const std::string& poiID, const TraCIPosition& pos) {
95 5 : PointOfInterest* p = getPoI(poiID);
96 4 : p->set(TraCI::makePosition(pos));
97 4 : }
98 :
99 : void
100 5 : TraCI_POI::setColor(const std::string& poiID, const TraCIColor& c) {
101 5 : PointOfInterest* p = getPoI(poiID);
102 4 : p->setColor(TraCI::makeRGBColor(c));
103 4 : }
104 :
105 : bool
106 49 : TraCI_POI::add(const std::string& poiID, const TraCIPosition& pos, const TraCIColor& c, const std::string& type, int layer) {
107 49 : ShapeContainer& shapeCont = MSNet::getInstance()->getShapeContainer();
108 : return shapeCont.addPOI(poiID, type, TraCI::makeRGBColor(c), TraCI::makePosition(pos), false, "", 0, 0, (double) layer,
109 : Shape::DEFAULT_ANGLE,
110 : Shape::DEFAULT_IMG_FILE,
111 : Shape::DEFAULT_IMG_WIDTH,
112 49 : Shape::DEFAULT_IMG_HEIGHT);
113 : }
114 :
115 : bool
116 5 : TraCI_POI::remove(const std::string& poiID, int /* layer */) {
117 5 : ShapeContainer& shapeCont = MSNet::getInstance()->getShapeContainer();
118 5 : return shapeCont.removePOI(poiID);
119 : }
120 :
121 : void
122 1 : TraCI_POI::setParameter(const std::string& poiID, const std::string& param, const std::string& value) {
123 1 : PointOfInterest* p = getPoI(poiID);
124 1 : p->setParameter(param, value);
125 1 : }
126 :
127 :
128 : PointOfInterest*
129 12176 : TraCI_POI::getPoI(const std::string& id) {
130 12176 : PointOfInterest* sumoPoi = MSNet::getInstance()->getShapeContainer().getPOIs().get(id);
131 12176 : if (sumoPoi == 0) {
132 5 : throw TraCIException("POI '" + id + "' is not known");
133 : }
134 12171 : return sumoPoi;
135 43554 : }
136 :
137 :
138 : /****************************************************************************/
|