LCOV - code coverage report
Current view: top level - src/netimport - NIXMLShapeHandler.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 16.7 % 18 3
Test Date: 2024-11-20 15:55:46 Functions: 50.0 % 2 1

            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              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    NIXMLShapeHandler.cpp
      15              : /// @author  Jakob Erdmann
      16              : /// @date    Sat, 28 Jul 2018
      17              : ///
      18              : // Importer for static public transport information
      19              : /****************************************************************************/
      20              : #include <config.h>
      21              : 
      22              : #include <utils/geom/Position.h>
      23              : #include <utils/common/MsgHandler.h>
      24              : #include <utils/geom/GeoConvHelper.h>
      25              : #include <netbuild/NBEdgeCont.h>
      26              : #include <netbuild/NBEdge.h>
      27              : 
      28              : #include "NIXMLShapeHandler.h"
      29              : 
      30              : // ===========================================================================
      31              : // method definitions
      32              : // ===========================================================================
      33              : 
      34         1824 : NIXMLShapeHandler::NIXMLShapeHandler(ShapeContainer& sc, const NBEdgeCont& ec) :
      35              :     ShapeHandler("polgyon - file", sc, GeoConvHelper::getNumLoaded() == 0 ? nullptr : & GeoConvHelper::getLoaded()),
      36         2507 :     myEdgeCont(ec)
      37         1824 : {}
      38              : 
      39              : Position
      40            0 : NIXMLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, bool friendlyPos, double lanePosLat) {
      41              :     std::string edgeID;
      42              :     int laneIndex;
      43            0 :     NBHelpers::interpretLaneID(laneID, edgeID, laneIndex);
      44            0 :     NBEdge* edge = myEdgeCont.retrieve(edgeID);
      45            0 :     if (edge == 0 || laneIndex < 0 || edge->getNumLanes() <= laneIndex) {
      46            0 :         WRITE_ERRORF(TL("Lane '%' to place poi '%' on is not known."), laneID, poiID);
      47            0 :         return Position::INVALID;
      48              :     }
      49            0 :     if (lanePos < 0) {
      50            0 :         lanePos = edge->getLength() + lanePos;
      51              :     }
      52            0 :     if ((lanePos < 0) && friendlyPos) {
      53            0 :         lanePos = 0;
      54              :     }
      55            0 :     if ((lanePos > edge->getLength()) && friendlyPos) {
      56            0 :         lanePos = edge->getLength();
      57              :     }
      58            0 :     if (lanePos < 0 || lanePos > edge->getLength()) {
      59            0 :         WRITE_WARNINGF(TL("lane position % for poi '%' is not valid."), toString(lanePos), poiID);
      60              :     }
      61            0 :     return edge->getLanes()[laneIndex].shape.positionAtOffset(lanePos, -lanePosLat);
      62              : }
      63              : 
      64              : 
      65              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1