Line data Source code
1 : /****************************************************************************/ 2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo 3 : // Copyright (C) 2014-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 MSPModel.cpp 15 : /// @author Jakob Erdmann 16 : /// @date Mon, 13 Jan 2014 17 : /// 18 : // The pedestrian following model (prototype) 19 : /****************************************************************************/ 20 : #include <config.h> 21 : 22 : #include <cmath> 23 : #include <algorithm> 24 : #include <utils/options/OptionsCont.h> 25 : #include <microsim/MSNet.h> 26 : #include <microsim/MSEdge.h> 27 : #include <microsim/MSJunction.h> 28 : #include <microsim/MSLane.h> 29 : #include <microsim/MSGlobals.h> 30 : #include "MSPModel_Striping.h" 31 : #include "MSPModel_NonInteracting.h" 32 : #include "MSPModel.h" 33 : 34 : 35 : // =========================================================================== 36 : // static members 37 : // =========================================================================== 38 : // named constants 39 : const int MSPModel::FORWARD(1); 40 : const int MSPModel::BACKWARD(-1); 41 : const int MSPModel::UNDEFINED_DIRECTION(0); 42 : 43 : // parameters shared by all models 44 : const double MSPModel::SAFETY_GAP(1.0); 45 : const double MSPModel::SIDEWALK_OFFSET(3); 46 : const double MSPModel::UNSPECIFIED_POS_LAT(std::numeric_limits<double>::max()); 47 : const double MSPModel::RANDOM_POS_LAT(-std::numeric_limits<double>::max()); 48 : 49 : 50 : // =========================================================================== 51 : // MSPModel method definitions 52 : // =========================================================================== 53 : int 54 997032 : MSPModel::canTraverse(int dir, const ConstMSEdgeVector& route, int& passedEdges) { 55 : const MSJunction* junction = nullptr; 56 2695650 : for (ConstMSEdgeVector::const_iterator it = route.begin(); it != route.end(); ++it) { 57 2054055 : const MSEdge* edge = *it; 58 2054055 : if (junction != nullptr) { 59 : //std::cout << " junction=" << junction->getID() << " edge=" << edge->getID() << "\n"; 60 1057023 : if (junction == edge->getFromJunction()) { 61 : dir = FORWARD; 62 562346 : } else if (junction == edge->getToJunction()) { 63 : dir = BACKWARD; 64 : } else { 65 : return UNDEFINED_DIRECTION; 66 : } 67 : } 68 997032 : junction = dir == FORWARD ? edge->getToJunction() : edge->getFromJunction(); 69 1698618 : passedEdges++; 70 : } 71 : return dir; 72 : } 73 : 74 : 75 : /****************************************************************************/