/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 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 NGNode.h14/// @author Markus Hartinger15/// @author Daniel Krajzewicz16/// @author Michael Behrisch17/// @date Mar, 200318///19// A netgen-representation of a node20/****************************************************************************/21#pragma once22#include <config.h>2324#include <list>25#include <utils/common/Named.h>26#include <utils/geom/Position.h>27#include <utils/geom/GeomHelper.h>28#include <utils/common/UtilExceptions.h>29#include "NGEdge.h"303132// ===========================================================================33// class declarations34// ===========================================================================35class NBNode;36class NBEdge;37class NBNetBuilder;383940// ===========================================================================41// class definitions42// ===========================================================================43/**44* @class NGNode45* @brief A netgen-representation of a node46*/47class NGNode : public Named {48public:49/** @brief Constructor50*51* @param[in] id The id of the node52*/53NGNode(const std::string& id);545556/** @brief Constructor57*58* @param[in] id The id of the node59* @param[in] xPos The x-position of the node60* @param[in] yPos The y-position of the node61*/62NGNode(const std::string& id, int xPos, int yPos);636465/** @brief Constructor66*67* @param[in] id The id of the node68* @param[in] xPos The x-position of the node69* @param[in] yPos The y-position of the node70* @param[in] amCenter Information whether this is the center-node of a spider-net71*/72NGNode(const std::string& id, int xID, int yID, bool amCenter);737475/// @brief Destructor76~NGNode();777879/** @brief Returns this node's position80*81* @return The position of the node82*/83const Position& getPosition() const {84return myPosition;85}868788/** @brief Returns this node's maximum neighbour number89*90* @return The maximum neighbour number of the node91*/92int getMaxNeighbours() {93return myMaxNeighbours;94}959697/** @brief Sets this node's maximum neighbour number98*99* @param[in] value The new maximum neighbour number of the node100*/101void setMaxNeighbours(int value) {102myMaxNeighbours = value;103}104105106/** @brief Sets a new value for x-position107*108* @param[in] value The new x-position of this node109*/110void setX(double x) {111myPosition.set(x, myPosition.y());112}113114115/** @brief Sets a new value for y-position116*117* @param[in] value The new y-position of this node118*/119void setY(double y) {120myPosition.set(myPosition.x(), y);121}122123/// @brief mark node as fringe124void setFringe() {125myAmFringe = true;126}127128/** @brief Builds and returns this node's netbuild-representation129*130* The position of the node is transformed to cartesian using GeoConvHelper::x2cartesian,131* first. If this node is the center node of a spider net, a node of the type132* NBNode::SumoXMLNodeType::NOJUNCTION is returned.133* Otherwise, a plain node is built and it is checked whether the options134* indicate building one of the tls node-types. In this case, a logic is built and135* stored. A ProcessError is thrown if this fails (should never happen, in fact).136*137* @param[in] nb The netbuilder to retrieve the tls-container from138* @return The built node139* @exception ProcessError If the built tls logic could not be added (should never happen)140* @todo There is no interaction with explicit node setting options? Where is this done?141* @todo Check whether throwing an exception is really necessary, here142*/143NBNode* buildNBNode(NBNetBuilder& nb, const Position& perturb) const;144145146/** @brief Adds the given link to the internal list147*148* @param[in] link The link to add149*/150void addLink(NGEdge* link);151152153/** @brief Removes the given link154*155* The given pointer is compared to those in the list. A matching156* pointer is removed, not other same connections.157*158* @param[in] link The link to remove159*/160void removeLink(NGEdge* link);161162163const NGEdgeList& getLinks() const {164return myLinkList;165}166167/** @brief Returns whether the other node is connected168*169* @param[in] node The link to check whether it is connected170* @return Whether the given node is connected171*/172bool connected(const NGNode* const node, const bool withDir = false) const;173174175/** @brief Returns whether the node has the given position176*177* @param[in] node The link to check whether it is connected178* @return Whether the given node is connected179*/180bool samePos(int xPos, int yPos) const {181return myXID == xPos && myYID == yPos;182}183184private:185/// @brief Integer x-position (x-id)186int myXID;187188/// @brief Integer y-position (y-id)189int myYID;190191/// @brief List of connected links192NGEdgeList myLinkList;193194/// @brief The position of the node195Position myPosition;196197/// @brief The maximum number of neighbours198int myMaxNeighbours;199200/// @brief Information whether this is the center of a cpider-net201bool myAmCenter;202203/// @brief Information whether this is the center of a cpider-net204bool myAmFringe;205206};207208/**209* @typedef NGNodeList210* @brief A list of nodes (node pointers)211*/212typedef std::list<NGNode*> NGNodeList;213214215