/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file ROLane.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @date Sept 200217///18// A single lane the router may use19/****************************************************************************/20#pragma once21#include <config.h>2223#include <vector>24#include <utils/geom/PositionVector.h>25#include <utils/common/Named.h>26#include <utils/common/SUMOVehicleClass.h>272829// ===========================================================================30// class declarations31// ===========================================================================32class ROEdge;333435// ===========================================================================36// class definitions37// ===========================================================================38/**39* @class ROLane40* @brief A single lane the router may use41*42* Currently, the lane has no other purpose then storing the allowed vehicle43* classes. They are even only stored herein and used by computing the vehicle44* classes allowed on the according edge.45* @see ROEdge46*/47class ROLane : public Named {48public:49/** @brief Constructor50*51* @param[in] id The id of the lane52* @param[in] length The length of the lane53* @param[in] maxSpeed The maximum speed allowed on the lane54* @param[in] permissions Vehicle classes that may pass this lane55*/56ROLane(const std::string& id, ROEdge* edge, double length, double maxSpeed, SVCPermissions permissions, const PositionVector& shape) :57Named(id), myEdge(edge), myLength(length), myMaxSpeed(maxSpeed), myPermissions(permissions), myShape(shape),58myLengthGeometryFactor(MAX2(NUMERICAL_EPS, myShape.length() / myLength)) // factor should not be 059{ }606162/// @brief Destructor63~ROLane() { }646566/** @brief Returns the length of the lane67* @return The length of this lane68*/69double getLength() const {70return myLength;71}727374/** @brief Returns the maximum speed allowed on this lane75* @return The maximum speed allowed on this lane76*/77double getSpeed() const {78return myMaxSpeed;79}808182/** @brief Returns the list of allowed vehicle classes83* @return The list of vehicle classes allowed on this lane84*/85inline SVCPermissions getPermissions() const {86return myPermissions;87}8889void setPermissions(SVCPermissions permissions) {90myPermissions = permissions;91}9293/** @brief Returns the lane's edge94* @return This lane's edge95*/96ROEdge& getEdge() const {97return *myEdge;98}99100/// @brief get the map of outgoing lanes to via edges101const std::vector<std::pair<const ROLane*, const ROEdge*> >& getOutgoingViaLanes() const {102return myOutgoingLanes;103}104105void addOutgoingLane(ROLane* lane, ROEdge* via = nullptr) {106myOutgoingLanes.push_back(std::make_pair(lane, via));107}108109/// @brief get the state of the link from the logical predecessor to this lane (ignored for routing)110inline LinkState getIncomingLinkState() const {111return LINKSTATE_MAJOR;112}113114inline bool allowsVehicleClass(SUMOVehicleClass vclass) const {115return (myPermissions & vclass) == vclass;116}117118const PositionVector& getShape() const {119return myShape;120}121122/* @brief fit the given lane position to a visibly suitable geometry position123* (lane length might differ from geometry length) */124inline double interpolateLanePosToGeometryPos(double lanePos) const {125return lanePos * myLengthGeometryFactor;126}127128/* @brief fit the given lane position to a visibly suitable geometry position129* and return the coordinates */130inline const Position geometryPositionAtOffset(double offset, double lateralOffset = 0) const {131return myShape.positionAtOffset(interpolateLanePosToGeometryPos(offset), lateralOffset);132}133134private:135/// @brief The parent edge of this lane136ROEdge* myEdge;137138/// @brief The length of the lane139double myLength;140141/// @brief The maximum speed allowed on the lane142double myMaxSpeed;143144/// @brief The encoding of allowed vehicle classes145SVCPermissions myPermissions;146147std::vector<std::pair<const ROLane*, const ROEdge*> > myOutgoingLanes;148149/// @brief shape for this lane150const PositionVector myShape;151152/// @brief precomputed myShape.length / myLength153const double myLengthGeometryFactor;154155156private:157/// @brief Invalidated copy constructor158ROLane(const ROLane& src);159160/// @brief Invalidated assignment operator161ROLane& operator=(const ROLane& src);162163};164165166