Eclipse 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.dev/sumo
3 // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4 // activitygen module
5 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6 // This program and the accompanying materials are made available under the
7 // terms of the Eclipse Public License 2.0 which is available at
8 // https://www.eclipse.org/legal/epl-2.0/
9 // This Source Code may also be made available under the following Secondary
10 // Licenses when the conditions for such availability set forth in the Eclipse
11 // Public License 2.0 are satisfied: GNU General Public License, version 2
12 // or later which is available at
13 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
15 /****************************************************************************/
23 // References a street of the city and defines a position in this street
24 /****************************************************************************/
25 #pragma once
26 #include <config.h>
27 
28 #include <list>
29 #include <map>
30 #include <utils/geom/Position.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class AGStreet;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
53 class AGPosition {
54 public:
64  AGPosition(const AGStreet& str, double pos);
72  AGPosition(const AGStreet& str);
73 
78  const AGStreet& getStreet() const;
79 
87  double getPosition() const;
88 
97  bool operator==(const AGPosition& pos) const;
98 
104  double distanceTo(const AGPosition& otherPos) const;
105 
114  double minDistanceTo(const std::list<AGPosition>& positions) const;
115 
124  double minDistanceTo(const std::map<int, AGPosition>& positions) const;
125 
129  void print() const;
130 
131 private:
132  const AGStreet* street;
133  double position;
135 
140  static double randomPositionInStreet(const AGStreet& street);
141 
149  Position compute2dPosition() const;
150 };
A location in the 2D plane freely positioned on a street.
Definition: AGPosition.h:53
double getPosition() const
Provides the relative position of this AGPosition on the street.
Definition: AGPosition.cpp:105
double distanceTo(const AGPosition &otherPos) const
Computes the distance between two AGPosition objects.
Definition: AGPosition.cpp:61
const AGStreet & getStreet() const
Provides the street this AGPosition is located on.
Definition: AGPosition.cpp:99
void print() const
Prints out a summary of the properties of this class on standard output.
Definition: AGPosition.cpp:49
Position pos2d
Definition: AGPosition.h:134
bool operator==(const AGPosition &pos) const
Tests whether two positions are at the same place.
Definition: AGPosition.cpp:55
double position
Definition: AGPosition.h:133
double minDistanceTo(const std::list< AGPosition > &positions) const
Computes the distance to the closest position in a list.
Definition: AGPosition.cpp:67
static double randomPositionInStreet(const AGStreet &street)
Determines a random relative position on a street.
Definition: AGPosition.cpp:111
const AGStreet * street
Definition: AGPosition.h:132
AGPosition(const AGStreet &str, double pos)
Constructs an AGPosition at a certain point on a street.
Definition: AGPosition.cpp:38
Position compute2dPosition() const
Definition: AGPosition.cpp:117
A model of the street in the city.
Definition: AGStreet.h:50
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37