/****************************************************************************/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 NIXMLShapeHandler.cpp14/// @author Jakob Erdmann15/// @date Sat, 28 Jul 201816///17// Importer for static public transport information18/****************************************************************************/19#include <config.h>2021#include <utils/geom/Position.h>22#include <utils/common/MsgHandler.h>23#include <utils/geom/GeoConvHelper.h>24#include <netbuild/NBEdgeCont.h>25#include <netbuild/NBEdge.h>2627#include "NIXMLShapeHandler.h"2829// ===========================================================================30// method definitions31// ===========================================================================3233NIXMLShapeHandler::NIXMLShapeHandler(ShapeContainer& sc, const NBEdgeCont& ec) :34ShapeHandler("polgyon - file", sc, GeoConvHelper::getNumLoaded() == 0 ? nullptr : & GeoConvHelper::getLoaded()),35myEdgeCont(ec)36{}3738Position39NIXMLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, bool friendlyPos, double lanePosLat) {40std::string edgeID;41int laneIndex;42NBHelpers::interpretLaneID(laneID, edgeID, laneIndex);43NBEdge* edge = myEdgeCont.retrieve(edgeID);44if (edge == 0 || laneIndex < 0 || edge->getNumLanes() <= laneIndex) {45WRITE_ERRORF(TL("Lane '%' to place poi '%' on is not known."), laneID, poiID);46return Position::INVALID;47}48if (lanePos < 0) {49lanePos = edge->getLength() + lanePos;50}51if ((lanePos < 0) && friendlyPos) {52lanePos = 0;53}54if ((lanePos > edge->getLength()) && friendlyPos) {55lanePos = edge->getLength();56}57if (lanePos < 0 || lanePos > edge->getLength()) {58WRITE_WARNINGF(TL("lane position % for poi '%' is not valid."), toString(lanePos), poiID);59}60return edge->getLanes()[laneIndex].shape.positionAtOffset(lanePos, -lanePosLat);61}626364/****************************************************************************/656667