/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file ODAmitranHandler.cpp14/// @author Michael Behrisch15/// @date 27.03.201416///17// An XML-Handler for Amitran OD matrices18/****************************************************************************/19#include <config.h>2021#include <utils/common/MsgHandler.h>22#include "ODMatrix.h"23#include "ODAmitranHandler.h"242526// ===========================================================================27// method definitions28// ===========================================================================29ODAmitranHandler::ODAmitranHandler(ODMatrix& matrix, const std::string& file)30: SUMOSAXHandler(file), myMatrix(matrix) {}313233ODAmitranHandler::~ODAmitranHandler() {}343536void37ODAmitranHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) {38bool ok = true;39switch (element) {40case SUMO_TAG_ACTORCONFIG:41myVehicleType = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);42break;43case SUMO_TAG_TIMESLICE:44myBegin = attrs.get<int>(SUMO_ATTR_STARTTIME, myVehicleType.c_str(), ok);45myEnd = myBegin + attrs.get<int>(SUMO_ATTR_DURATION, myVehicleType.c_str(), ok);46if (myBegin >= myEnd) {47WRITE_ERRORF(TL("Invalid duration for timeSlice starting %."), toString(myBegin));48}49break;50case SUMO_TAG_OD_PAIR:51myMatrix.add(attrs.get<double>(SUMO_ATTR_AMOUNT, myVehicleType.c_str(), ok),52std::make_pair(myBegin, myEnd), attrs.get<std::string>(SUMO_ATTR_ORIGIN, myVehicleType.c_str(), ok),53attrs.get<std::string>(SUMO_ATTR_DESTINATION, myVehicleType.c_str(), ok), myVehicleType);54break;55default:56break;57}58}596061/****************************************************************************/626364