LCOV - code coverage report
Current view: top level - src/netimport/vissim/typeloader - NIVissimSingleTypeParser_Verbindungsdefinition.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 67 68 98.5 %
Date: 2024-05-01 15:34:42 Functions: 4 4 100.0 %

          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    NIVissimSingleTypeParser_Verbindungsdefinition.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Michael Behrisch
      17             : /// @date    Wed, 18 Dec 2002
      18             : ///
      19             : //
      20             : /****************************************************************************/
      21             : #include <config.h>
      22             : 
      23             : #include <iostream>
      24             : #include <utils/geom/PositionVector.h>
      25             : #include <utils/common/StringUtils.h>
      26             : #include <netimport/vissim/NIImporter_Vissim.h>
      27             : #include <netimport/vissim/tempstructs/NIVissimConnection.h>
      28             : #include "NIVissimSingleTypeParser_Verbindungsdefinition.h"
      29             : 
      30             : 
      31             : // ===========================================================================
      32             : // method definitions
      33             : // ===========================================================================
      34           9 : NIVissimSingleTypeParser_Verbindungsdefinition::NIVissimSingleTypeParser_Verbindungsdefinition(NIImporter_Vissim& parent)
      35           9 :     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
      36             : 
      37             : 
      38          18 : NIVissimSingleTypeParser_Verbindungsdefinition::~NIVissimSingleTypeParser_Verbindungsdefinition() {}
      39             : 
      40             : 
      41             : bool
      42         913 : NIVissimSingleTypeParser_Verbindungsdefinition::parse(std::istream& from) {
      43             :     int id;
      44         913 :     from >> id; // type-checking is missing!
      45             :     std::string tag;
      46             :     // Read optional value "Name", skip optional value "Beschriftung"
      47             :     std::string name;
      48        2700 :     while (tag != "von") {
      49        3574 :         tag = overrideOptionalLabel(from);
      50        1787 :         if (tag == "name") {
      51        1748 :             name = readName(from);
      52             :         }
      53             :     }
      54             :     // Read the geometry information
      55         913 :     NIVissimExtendedEdgePoint from_def = readExtEdgePointDef(from);
      56         913 :     PositionVector geom;
      57         913 :     tag = myRead(from); // "ueber"
      58        6728 :     while (tag != "nach") {
      59        4902 :         std::string x = myRead(from);
      60        4902 :         std::string y = myRead(from);
      61        4902 :         if (y != "nach") {
      62        4691 :             geom.push_back_noDoublePos(
      63        4691 :                 Position(
      64             :                     StringUtils::toDouble(x),
      65             :                     StringUtils::toDouble(y)
      66             :                 ));
      67        4691 :             tag = myRead(from);
      68             :             try {
      69        4691 :                 StringUtils::toDouble(tag);
      70        8840 :                 tag = myRead(from);
      71         271 :             } catch (NumberFormatException&) {}
      72             :         } else {
      73             :             tag = y;
      74             :         }
      75             :     }
      76         913 :     NIVissimExtendedEdgePoint to_def = readExtEdgePointDef(from);
      77             :     // read some optional values until mandatory "Fahrzeugklassen" occurs
      78         913 :     double dxnothalt = 0;
      79         913 :     double dxeinordnen = 0;
      80             :     double zuschlag1, zuschlag2;
      81         913 :     zuschlag1 = zuschlag2 = 0;
      82         913 :     double seglength = 0;
      83         913 :     tag = myRead(from);
      84             : //    NIVissimConnection::Direction direction = NIVissimConnection::NIVC_DIR_ALL;
      85       32573 :     while (tag != "fahrzeugklassen" && tag != "sperrung" && tag != "auswertung" && tag != "DATAEND") {
      86        7036 :         if (tag == "rechts") {
      87             : //            direction = NIVissimConnection::NIVC_DIR_RIGHT;
      88        6599 :         } else if (tag == "links") {
      89             : //            direction = NIVissimConnection::NIVC_DIR_LEFT;
      90        6536 :         } else if (tag == "alle") {
      91             : //            direction = NIVissimConnection::NIVC_DIR_ALL;
      92        6123 :         } else if (tag == "dxnothalt") {
      93             :             from >> dxnothalt; // type-checking is missing!
      94        5446 :         } else if (tag == "dxeinordnen") {
      95             :             from >> dxeinordnen; // type-checking is missing!
      96        4769 :         } else if (tag == "segment") {
      97         677 :             from >> tag;
      98             :             from >> seglength;
      99             :         }
     100        7036 :         if (tag == "zuschlag") {
     101             :             from >> zuschlag1; // type-checking is missing!
     102        1354 :             tag = readEndSecure(from);
     103         677 :             if (tag == "zuschlag") {
     104             :                 from >> zuschlag2; // type-checking is missing!
     105        1354 :                 tag = readEndSecure(from, "auswertung");
     106             :             }
     107             :         } else {
     108       12718 :             tag = readEndSecure(from, "auswertung");
     109             :         }
     110             :     }
     111             :     // read in allowed vehicle classes
     112             :     std::vector<int> assignedVehicles;
     113         913 :     if (tag == "fahrzeugklassen") {
     114          60 :         tag = readEndSecure(from);
     115         600 :         while (tag != "DATAEND" && tag != "sperrung" && tag != "auswertung") {
     116         180 :             int classes = StringUtils::toInt(tag);
     117         180 :             assignedVehicles.push_back(classes);
     118         360 :             tag = readEndSecure(from, "auswertung");
     119             :         }
     120             :     }
     121             :     // Read definitions of closed lanes
     122             :     NIVissimClosedLanesVector clv;
     123         913 :     if (tag != "DATAEND") {
     124             :         do {
     125             :             // check whether a next close lane definition can be found
     126         188 :             tag = readEndSecure(from);
     127          94 :             if (tag == "keinspurwechsel") {
     128          32 :                 while (tag != "DATAEND") {
     129          60 :                     tag = readEndSecure(from);
     130             :                 }
     131          92 :             } else if (tag == "spur") {
     132             :                 // get the lane number
     133             : //                from >> tag;
     134             :                 int laneNo;
     135          23 :                 from >> laneNo; // unused and type-checking is missing!
     136             :                 // get the list of assigned car classes
     137             :                 std::vector<int> assigned;
     138          46 :                 tag = myRead(from);
     139          23 :                 if (tag == "fahrzeugklassen") {
     140          46 :                     tag = myRead(from);
     141             :                 }
     142         250 :                 while (tag != "DATAEND" && tag != "spur" && tag != "keinspurwechsel") {
     143          74 :                     int classes = StringUtils::toInt(tag);
     144          74 :                     assigned.push_back(classes);
     145         148 :                     tag = readEndSecure(from);
     146             :                 }
     147             :                 // build and add the definition
     148          23 :                 NIVissimClosedLaneDef* cld = new NIVissimClosedLaneDef(assigned);
     149          23 :                 clv.push_back(cld);
     150             :             }
     151          94 :         } while (tag != "DATAEND");
     152             :     }
     153             :     NIVissimConnection* c = new NIVissimConnection(id, name, from_def, to_def, geom,
     154         913 :             assignedVehicles, clv);
     155             : 
     156         913 :     if (!NIVissimConnection::dictionary(id, c)) {
     157           0 :         return false;
     158             :     }
     159             :     return true;
     160             :     //return NIVissimAbstractEdge::dictionary(id, c);
     161         913 : }
     162             : 
     163             : 
     164             : /****************************************************************************/

Generated by: LCOV version 1.14