LCOV - code coverage report
Current view: top level - src/netimport/vissim/typeloader - NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 74.6 % 71 53
Test Date: 2025-03-19 16:11:11 Functions: 87.5 % 8 7

            Line data    Source code
       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    NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @date    Wed, 18 Dec 2002
      19              : ///
      20              : //
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : 
      24              : #include <iostream>
      25              : #include <utils/common/StringUtils.h>
      26              : #include <utils/common/MsgHandler.h>
      27              : #include <netimport/vissim/NIImporter_Vissim.h>
      28              : #include <netimport/vissim/tempstructs/NIVissimExtendedEdgePoint.h>
      29              : #include <netimport/vissim/tempstructs/NIVissimDisturbance.h>
      30              : #include "NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition.h"
      31              : 
      32              : 
      33              : // ===========================================================================
      34              : // method definitions
      35              : // ===========================================================================
      36            9 : NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition(NIImporter_Vissim& parent)
      37            9 :     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
      38              : 
      39              : 
      40           18 : NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::~NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition() {}
      41              : 
      42              : 
      43              : bool
      44          296 : NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parse(std::istream& from) {
      45              :     std::string tag;
      46          296 :     tag = myRead(from);
      47          296 :     if (tag == "nureigenestrecke") {
      48            6 :         return parseOnlyMe(from);
      49          290 :     } else if (tag == "ort") {
      50            0 :         return parsePositionDescribed(from);
      51          290 :     } else if (tag == "nummer") {
      52          290 :         return parseNumbered(from);
      53              :     }
      54            0 :     WRITE_ERROR(
      55              :         "NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition: format problem");
      56            0 :     throw 1;
      57              : }
      58              : 
      59              : bool
      60            6 : NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseOnlyMe(std::istream& from) {
      61              :     std::string tag;
      62            6 :     from >> tag;
      63            6 :     return true;
      64              : }
      65              : 
      66              : 
      67              : bool
      68            0 : NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePositionDescribed(std::istream& from) {
      69            0 :     std::string tag = myRead(from);
      70            0 :     NIVissimExtendedEdgePoint edge = parsePos(from);
      71              : //    from >> tag; // "Durch"
      72              :     bool ok = true;
      73              :     do {
      74            0 :         from >> tag; // "Strecke"
      75            0 :         NIVissimExtendedEdgePoint by = parsePos(from);
      76              :         //
      77              :         double timegap;
      78              :         from >> timegap;
      79              : 
      80            0 :         from >> tag;
      81              :         double waygap;
      82              :         from >> waygap;
      83              : 
      84            0 :         double vmax = -1;
      85            0 :         tag = readEndSecure(from);
      86            0 :         if (tag == "vmax") {
      87              :             from >> vmax;
      88              :         }
      89            0 :         ok = NIVissimDisturbance::dictionary("", edge, by);
      90            0 :         if (tag != "DATAEND") {
      91            0 :             tag = readEndSecure(from);
      92              :         }
      93            0 :     } while (tag != "DATAEND" && ok);
      94            0 :     return ok;
      95            0 : }
      96              : 
      97              : 
      98              : 
      99              : bool
     100          290 : NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parseNumbered(std::istream& from) {
     101              :     //
     102              :     int id;
     103          290 :     from >> id;
     104              :     //
     105              :     std::string tag;
     106          290 :     from >> tag;
     107          290 :     std::string name = readName(from);
     108              :     // skip optional "Beschriftung"
     109         1450 :     while (tag != "ort") {
     110         2320 :         tag = myRead(from);
     111              :     }
     112              :     //
     113          290 :     from >> tag; // "Strecke"
     114          290 :     NIVissimExtendedEdgePoint edge = parsePos(from);
     115              :     bool ok = true;
     116              :     do {
     117          415 :         from >> tag; // "Ort"
     118          415 :         from >> tag; // "Strecke"
     119          415 :         NIVissimExtendedEdgePoint by = parsePos(from);
     120              :         //
     121              :         double timegap;
     122              :         from >> timegap;
     123              : 
     124              :         double waygap;
     125          415 :         from >> tag;
     126              :         from >> waygap;
     127              : 
     128          415 :         double vmax = -1;
     129          415 :         tag = readEndSecure(from);
     130          415 :         if (tag == "vmax") {
     131              :             from >> vmax;
     132              :         }
     133              : 
     134          415 :         ok = NIVissimDisturbance::dictionary(name, edge, by);
     135          415 :         if (tag != "DATAEND") {
     136          830 :             tag = readEndSecure(from);
     137              :         }
     138          705 :     } while (tag != "DATAEND" && ok);
     139          290 :     return ok;
     140          290 : }
     141              : 
     142              : 
     143              : 
     144              : NIVissimExtendedEdgePoint
     145          705 : NIVissimSingleTypeParser_Querverkehrsstoerungsdefinition::parsePos(std::istream& from) {
     146              :     int edgeid;
     147          705 :     from >> edgeid; // type-checking is missing!
     148              :     //
     149              :     std::string tag;
     150          705 :     from >> tag;
     151          705 :     from >> tag;
     152              :     std::vector<int> lanes;
     153          705 :     if (tag == "ALLE") {
     154              :         //lanes.push_back(1); // !!!
     155              :     } else {
     156          705 :         lanes.push_back(StringUtils::toInt(tag));
     157              :     }
     158              :     //
     159              :     double position;
     160          705 :     from >> tag;
     161              :     from >> position;
     162              :     // assigned vehicle types
     163              :     std::vector<int> types;
     164          705 :     from >> tag;
     165         1443 :     while (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND" && tag != "alle") {
     166         1476 :         tag = readEndSecure(from);
     167          738 :         if (tag != "DATAEND") {
     168          738 :             if (tag == "alle") {
     169          672 :                 types.push_back(-1);
     170          672 :                 from >> tag;
     171              :                 tag = "alle";
     172           66 :             } else if (tag != "zeitluecke" && tag != "durch" && tag != "DATAEND") {
     173           33 :                 int tmp = StringUtils::toInt(tag);
     174           33 :                 types.push_back(tmp);
     175              :             }
     176              :         }
     177              :     }
     178         1410 :     return NIVissimExtendedEdgePoint(edgeid, lanes, position, types);
     179          705 : }
     180              : 
     181              : 
     182              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1