SUMO - Simulation of Urban MObility
NBPTStop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // The representation of a single pt stop
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
32 #include "NBPTStop.h"
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
38 NBPTStop::NBPTStop(std::string ptStopId, Position position, std::string edgeId, std::string origEdgeId, double length, std::string name) :
39  myPTStopId(ptStopId),
40  myPosition(position),
41  myEdgeId(edgeId),
42  myOrigEdgeId(origEdgeId),
43  myPTStopLength(length),
44  myName(name),
45  myFriendlyPos(false) {
46 
47 }
48 
49 std::string
50 NBPTStop::getID() const {
51  return myPTStopId;
52 }
53 
54 const std::string
56  return myOrigEdgeId;
57 }
58 
59 const std::string
61  return myEdgeId;
62 }
63 
64 const std::string
66  return myName;
67 }
69  return myPosition;
70 }
71 void NBPTStop::computExtent(double center, double edgeLength) {
72  myFrom = center - myPTStopLength / 2.;
73  myTo = center + myPTStopLength / 2.;
74  if (myFrom < 0 || myTo > edgeLength) {
75  myFriendlyPos = true;
76  }
77 }
78 void NBPTStop::setLaneID(const std::string& laneId) {
79  myLaneId = laneId;
80 }
82  device.openTag(SUMO_TAG_BUS_STOP);
84  if (myName != "") {
86  }
90  if (myFriendlyPos) {
91  device.writeAttr(SUMO_ATTR_FRIENDLY_POS, "true");
92  }
93  device.closeTag();
94 
95 }
96 void NBPTStop::reshiftPostion(const double offsetX, const double offsetY) {
97  myPosition.add(offsetX, offsetY, 0);
98 
99 }
const std::string getName()
Definition: NBPTStop.cpp:65
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
void write(OutputDevice &device)
Definition: NBPTStop.cpp:81
double myFrom
Definition: NBPTStop.h:80
const std::string myOrigEdgeId
Definition: NBPTStop.h:75
void add(const Position &pos)
Adds the given position to this one.
Definition: Position.h:133
const std::string getEdgeId()
Definition: NBPTStop.cpp:60
double myTo
Definition: NBPTStop.h:81
bool myFriendlyPos
Definition: NBPTStop.h:82
std::string getID() const
Definition: NBPTStop.cpp:50
const std::string myName
Definition: NBPTStop.h:77
const double myPTStopLength
Definition: NBPTStop.h:76
const std::string myEdgeId
Definition: NBPTStop.h:74
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
void computExtent(double center, double d)
Definition: NBPTStop.cpp:71
void reshiftPostion(const double offsetX, const double offsetY)
Definition: NBPTStop.cpp:96
void setLaneID(const std::string &laneId)
Definition: NBPTStop.cpp:78
Position myPosition
Definition: NBPTStop.h:73
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
const Position & getPosition()
Definition: NBPTStop.cpp:68
bool closeTag()
Closes the most recently opened tag.
std::string myLaneId
Definition: NBPTStop.h:78
const std::string getOrigEdgeId()
Definition: NBPTStop.cpp:55
NBPTStop(std::string ptStopId, Position position, std::string edgeId, std::string origEdgeId, double length, std::string name)
Constructor.
Definition: NBPTStop.cpp:38
const std::string myPTStopId
Definition: NBPTStop.h:72
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.