LCOV - code coverage report
Current view: top level - src/netimport/vissim/typeloader - NIVissimSingleTypeParser_Knotendefinition.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 22 29 75.9 %
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_Knotendefinition.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/common/StringUtils.h>
      25             : #include <utils/geom/Position.h>
      26             : #include <utils/geom/PositionVector.h>
      27             : #include <netimport/vissim/NIImporter_Vissim.h>
      28             : #include <netimport/vissim/tempstructs/NIVissimNodeParticipatingEdge.h>
      29             : #include <netimport/vissim/tempstructs/NIVissimNodeParticipatingEdgeVector.h>
      30             : #include <netimport/vissim/tempstructs/NIVissimNodeDef_Edges.h>
      31             : #include <netimport/vissim/tempstructs/NIVissimNodeDef_Poly.h>
      32             : #include <netimport/vissim/tempstructs/NIVissimNodeDef.h>
      33             : #include "NIVissimSingleTypeParser_Knotendefinition.h"
      34             : 
      35             : 
      36             : // ===========================================================================
      37             : // method definitions
      38             : // ===========================================================================
      39           9 : NIVissimSingleTypeParser_Knotendefinition::NIVissimSingleTypeParser_Knotendefinition(NIImporter_Vissim& parent)
      40           9 :     : NIImporter_Vissim::VissimSingleTypeParser(parent) {}
      41             : 
      42             : 
      43          18 : NIVissimSingleTypeParser_Knotendefinition::~NIVissimSingleTypeParser_Knotendefinition() {}
      44             : 
      45             : 
      46             : bool
      47         105 : NIVissimSingleTypeParser_Knotendefinition::parse(std::istream& from) {
      48             :     //
      49             :     int id;
      50         105 :     from >> id;
      51             :     //
      52             :     std::string tag;
      53         105 :     from >> tag;
      54         105 :     std::string name = readName(from);
      55             :     //
      56         210 :     tag = overrideOptionalLabel(from);
      57             :     //
      58         322 :     while (tag != "netzausschnitt") {
      59         224 :         tag = myRead(from);
      60             :     }
      61             :     //
      62         210 :     tag = myRead(from);
      63         105 :     if (tag == "strecke") {
      64             :         NIVissimNodeParticipatingEdgeVector edges;
      65        1065 :         while (tag == "strecke") {
      66             :             int edgeid;
      67             :             double from_pos, to_pos;
      68         960 :             from_pos = to_pos = -1.0;
      69         960 :             from >> edgeid;
      70        1920 :             tag = readEndSecure(from, "strecke");
      71         960 :             if (tag == "von") {
      72             :                 from >> from_pos; // type-checking is missing!
      73         432 :                 from >> tag;
      74             :                 from >> to_pos; // type-checking is missing!
      75         864 :                 tag = readEndSecure(from, "strecke");
      76             :             }
      77         960 :             edges.push_back(new NIVissimNodeParticipatingEdge(edgeid, from_pos, to_pos));
      78             :         }
      79         105 :         NIVissimNodeDef_Edges::dictionary(id, name, edges);
      80             :     } else {
      81           0 :         int no = StringUtils::toInt(tag);
      82           0 :         PositionVector poly;
      83           0 :         for (int i = 0; i < no; i++) {
      84           0 :             poly.push_back(getPosition(from));
      85             :         }
      86           0 :         poly.closePolygon();
      87           0 :         NIVissimNodeDef_Poly::dictionary(id, name, poly);
      88           0 :     }
      89         105 :     return true;
      90             : }
      91             : 
      92             : 
      93             : /****************************************************************************/

Generated by: LCOV version 1.14