Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netimport/NIXMLShapeHandler.cpp
169665 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
NIXMLShapeHandler::NIXMLShapeHandler(ShapeContainer& sc, const NBEdgeCont& ec) :
35
ShapeHandler("polgyon - file", sc, GeoConvHelper::getNumLoaded() == 0 ? nullptr : & GeoConvHelper::getLoaded()),
36
myEdgeCont(ec)
37
{}
38
39
Position
40
NIXMLShapeHandler::getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, bool friendlyPos, double lanePosLat) {
41
std::string edgeID;
42
int laneIndex;
43
NBHelpers::interpretLaneID(laneID, edgeID, laneIndex);
44
NBEdge* edge = myEdgeCont.retrieve(edgeID);
45
if (edge == 0 || laneIndex < 0 || edge->getNumLanes() <= laneIndex) {
46
WRITE_ERRORF(TL("Lane '%' to place poi '%' on is not known."), laneID, poiID);
47
return Position::INVALID;
48
}
49
if (lanePos < 0) {
50
lanePos = edge->getLength() + lanePos;
51
}
52
if ((lanePos < 0) && friendlyPos) {
53
lanePos = 0;
54
}
55
if ((lanePos > edge->getLength()) && friendlyPos) {
56
lanePos = edge->getLength();
57
}
58
if (lanePos < 0 || lanePos > edge->getLength()) {
59
WRITE_WARNINGF(TL("lane position % for poi '%' is not valid."), toString(lanePos), poiID);
60
}
61
return edge->getLanes()[laneIndex].shape.positionAtOffset(lanePos, -lanePosLat);
62
}
63
64
65
/****************************************************************************/
66
67