LCOV - code coverage report
Current view: top level - src/activitygen/city - AGPosition.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 1 100.0 %
Date: 2024-05-05 15:31:14 Functions: 0 0 -

          Line data    Source code
       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             : /****************************************************************************/
      16             : /// @file    AGPosition.h
      17             : /// @author  Piotr Woznica
      18             : /// @author  Walter Bamberger
      19             : /// @author  Daniel Krajzewicz
      20             : /// @author  Michael Behrisch
      21             : /// @date    July 2010
      22             : ///
      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             : // ===========================================================================
      42             : /**
      43             :  * @class AGPosition
      44             :  * @brief A location in the 2D plane freely positioned on a street.
      45             :  *
      46             :  * This class restricts the Position class in the way that it must be
      47             :  * a position on a street. As a consequence, this position can be described
      48             :  * either by x and y coordinates or by a street and its distance to the
      49             :  * beginning of the street (the relative position).
      50             :  *
      51             :  * @TODO Should this class be derived from Position?
      52             :  */
      53       63051 : class AGPosition {
      54             : public:
      55             :     /** @brief Constructs an AGPosition at a certain point on a street.
      56             :      *
      57             :      * An AGPosition is determined by a street and the relative position
      58             :      * on the street. This relative position is the distance from the
      59             :      * from node of the street.
      60             :      *
      61             :      * param[in] str the street on which the AGPosition is located
      62             :      * param[in] pos the distance from the from node of the street
      63             :      */
      64             :     AGPosition(const AGStreet& str, double pos);
      65             :     /** @brief Constructs an AGPosition at a random point on a street.
      66             :      *
      67             :      * This constructor determines the distance from the from node with
      68             :      * a random number based on a uniform density.
      69             :      *
      70             :      * param[in] str the street on which the AGPosition is located
      71             :      */
      72             :     AGPosition(const AGStreet& str);
      73             : 
      74             :     /** @brief Provides the street this AGPosition is located on.
      75             :      *
      76             :      * @return the street
      77             :      */
      78             :     const AGStreet& getStreet() const;
      79             : 
      80             :     /** @brief Provides the relative position of this AGPosition on the street.
      81             :      *
      82             :      * This relative position is the distance from the from node
      83             :      * of the associated street.
      84             :      *
      85             :      * @return the relative position
      86             :      */
      87             :     double getPosition() const;
      88             : 
      89             :     /** @brief Tests whether two positions are at the same place.
      90             :      *
      91             :      * Compares the x and y coordinates with a threshold
      92             :      * (see Position::almostSame)
      93             :      *
      94             :      * @param[in] pos the position with which the comparison is done
      95             :      * @return true if both AGPositions are (almost) at the same place
      96             :      */
      97             :     bool operator==(const AGPosition& pos) const;
      98             : 
      99             :     /** @brief Computes the distance between two AGPosition objects.
     100             :      *
     101             :      * @param[in] the other position the distance in computed to
     102             :      * @return the distance
     103             :      */
     104             :     double distanceTo(const AGPosition& otherPos) const;
     105             : 
     106             :     /** @brief Computes the distance to the closest position in a list.
     107             :      *
     108             :      * minDistanceTo computes the distance to all positions in the given list
     109             :      * and returns the minimal distance.
     110             :      *
     111             :      * @param[in] positions the list of positions the distances are computed to
     112             :      * @return the minimal distance
     113             :      */
     114             :     double minDistanceTo(const std::list<AGPosition>& positions) const;
     115             : 
     116             :     /** @brief Computes the distance to the closest position in a map.
     117             :      *
     118             :      * minDistanceTo computes the distance to all positions given as the second
     119             :      * elements of a map and returns the minimal distance.
     120             :      *
     121             :      * @param[in] positions the map of positions the distances are computed to
     122             :      * @return the minimal distance
     123             :      */
     124             :     double minDistanceTo(const std::map<int, AGPosition>& positions) const;
     125             : 
     126             :     /** @brief Prints out a summary of the properties of this class
     127             :      * on standard output.
     128             :      */
     129             :     void print() const;
     130             : 
     131             : private:
     132             :     const AGStreet* street;
     133             :     double position;
     134             :     Position pos2d;
     135             : 
     136             :     /** @brief Determines a random relative position on a street.
     137             :      *
     138             :      * @return the random relative position
     139             :      */
     140             :     static double randomPositionInStreet(const AGStreet& street);
     141             : 
     142             :     /** Creates a Position object to the street and position attribute of
     143             :      * this class.
     144             :      *
     145             :      * This method may only be called when street and position are initialised!
     146             :      *
     147             :      * @return the Position object
     148             :      */
     149             :     Position compute2dPosition() const;
     150             : };

Generated by: LCOV version 1.14