LCOV - code coverage report
Current view: top level - src/netbuild - NBParking.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 93.1 % 29 27
Test Date: 2024-11-21 15:56:26 Functions: 100.0 % 3 3

            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    NBParking.cpp
      15              : /// @author  Jakob Erdmann
      16              : /// @date    Tue, 14 Nov 2017
      17              : ///
      18              : // The representation of an imported parking area
      19              : /****************************************************************************/
      20              : #include <config.h>
      21              : 
      22              : #include <utils/iodevices/OutputDevice.h>
      23              : #include <utils/options/OptionsCont.h>
      24              : #include <utils/common/MsgHandler.h>
      25              : #include "NBParking.h"
      26              : #include "NBEdge.h"
      27              : #include "NBEdgeCont.h"
      28              : 
      29              : 
      30              : // ===========================================================================
      31              : // method definitions
      32              : // ===========================================================================
      33          274 : NBParking::NBParking(const std::string& id, const std::string& edgeID, const std::string& name) :
      34              :     Named(id),
      35          274 :     myEdgeID(edgeID),
      36          548 :     myName(name) {
      37          274 : }
      38              : 
      39              : void
      40          274 : NBParking::write(OutputDevice& device, NBEdgeCont& ec) const {
      41          274 :     const NBEdge* e = ec.retrieve(myEdgeID);
      42          274 :     if (e != nullptr) {
      43          238 :         if ((e->getPermissions() & SVC_PASSENGER) == 0) {
      44            0 :             WRITE_WARNINGF(TL("Ignoring parking area on edge '%' due to invalid permissions."), e->getID());
      45           24 :             return;
      46              :         }
      47              :         // keep minimum distance of 5m to junction corners
      48          238 :         const int cornerDistance = 5;
      49          238 :         int capacity = (int)((e->getFinalLength() - 2 * cornerDistance) / 7.5);
      50          238 :         if (capacity <= 0) {
      51           72 :             WRITE_WARNINGF(TL("Ignoring parking area on edge '%' due to insufficient space."), e->getID());
      52           24 :             return;
      53              :         }
      54              :         int lane = 0;
      55          422 :         for (; lane < e->getNumLanes(); ++lane) {
      56          422 :             if ((e->getPermissions(lane) & SVC_PASSENGER) != 0) {
      57              :                 break;
      58              :             }
      59              :         }
      60          214 :         device.openTag(SUMO_TAG_PARKING_AREA);
      61              :         device.writeAttr(SUMO_ATTR_ID, getID());
      62          428 :         device.writeAttr(SUMO_ATTR_LANE, e->getLaneID(lane));
      63              :         device.writeAttr(SUMO_ATTR_STARTPOS, cornerDistance);
      64          428 :         device.writeAttr(SUMO_ATTR_ENDPOS, -cornerDistance);
      65              :         device.writeAttr(SUMO_ATTR_ROADSIDE_CAPACITY, capacity);
      66          214 :         if (!myName.empty()) {
      67            0 :             device.writeAttr(SUMO_ATTR_NAME, myName);
      68              :         }
      69          428 :         device.closeTag();
      70              :     } else {
      71          108 :         WRITE_WARNINGF(TL("Could not find edge for parkingArea '%'."), getID());
      72              :     }
      73              :     // XXX else: prevent edge merging via --geometry.remove
      74              : }
      75              : 
      76              : 
      77              : void
      78         1708 : NBParkingCont::addEdges2Keep(const OptionsCont& oc, std::set<std::string>& into) {
      79         3415 :     if (oc.exists("parking-output") && oc.isSet("parking-output")) {
      80          552 :         for (NBParking& p : *this) {
      81          548 :             into.insert(p.getEdgeID());
      82              :         }
      83              :     }
      84         1708 : }
        

Generated by: LCOV version 2.0-1