SUMO - Simulation of Urban MObility
AGPosition.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 // activitygen module
5 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6 /****************************************************************************/
7 //
8 // This program and the accompanying materials
9 // are made available under the terms of the Eclipse Public License v2.0
10 // which accompanies this distribution, and is available at
11 // http://www.eclipse.org/legal/epl-v20.html
12 //
13 /****************************************************************************/
22 // References a street of the city and defines a position in this street
23 /****************************************************************************/
24 #ifndef AGPOSITION_H
25 #define AGPOSITION_H
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include "../../utils/geom/Position.h"
38 #include <list>
39 #include <map>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class AGStreet;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
62 class AGPosition {
63 public:
73  AGPosition(const AGStreet& str, double pos);
81  AGPosition(const AGStreet& str);
82 
87  const AGStreet& getStreet() const;
88 
96  double getPosition() const;
97 
106  bool operator==(const AGPosition& pos) const;
107 
113  double distanceTo(const AGPosition& otherPos) const;
114 
123  double minDistanceTo(const std::list<AGPosition>& positions) const;
124 
133  double minDistanceTo(const std::map<int, AGPosition>& positions) const;
134 
138  void print() const;
139 
140 private:
141  const AGStreet* street;
142  double position;
144 
149  static double randomPositionInStreet(const AGStreet& street);
150 
158  Position compute2dPosition() const;
159 };
160 
161 #endif /* AGPOSITION_H */
162 
163 /****************************************************************************/
Position compute2dPosition() const
Definition: AGPosition.cpp:125
static double randomPositionInStreet(const AGStreet &street)
Determines a random relative position on a street.
Definition: AGPosition.cpp:119
A location in the 2D plane freely positioned on a street.
Definition: AGPosition.h:62
A model of the street in the city.
Definition: AGStreet.h:59
bool operator==(const AGPosition &pos) const
Tests whether two positions are at the same place.
Definition: AGPosition.cpp:63
AGPosition(const AGStreet &str, double pos)
Constructs an AGPosition at a certain point on a street.
Definition: AGPosition.cpp:46
double minDistanceTo(const std::list< AGPosition > &positions) const
Computes the distance to the closest position in a list.
Definition: AGPosition.cpp:75
const AGStreet & getStreet() const
Provides the street this AGPosition is located on.
Definition: AGPosition.cpp:107
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
double distanceTo(const AGPosition &otherPos) const
Computes the distance between two AGPosition objects.
Definition: AGPosition.cpp:69
Position pos2d
Definition: AGPosition.h:143
void print() const
Prints out a summary of the properties of this class on standard output.
Definition: AGPosition.cpp:57
double getPosition() const
Provides the relative position of this AGPosition on the street.
Definition: AGPosition.cpp:113
double position
Definition: AGPosition.h:142
const AGStreet * street
Definition: AGPosition.h:141