/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2014-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 TrajectoriesHandler.h14/// @author Michael Behrisch15/// @date 14.03.201416///17// An XML-Handler for amitran and netstate trajectories18/****************************************************************************/19#pragma once20#include <config.h>2122#include <string>23#include <utility>24#include <utils/xml/SUMOSAXHandler.h>2526class EnergyParams;2728// ===========================================================================29// class definitions30// ===========================================================================31/**32* @class TrajectoriesHandler33* @brief An XML-Handler for amitran and netstate trajectories34*35* This SUMOSAXHandler parses vehicles and their speeds.36*/37class TrajectoriesHandler : public SUMOSAXHandler {38public:39static const int INVALID_VALUE = -999999;4041public:42/** @brief Constructor43*44* @param[in] file The file that will be processed45*/46TrajectoriesHandler(const bool computeA, const bool computeAForward, const bool accelZeroCorrection,47const SUMOEmissionClass defaultClass,48EnergyParams* params, long long int attributes,49const double defaultSlope, std::ostream* stdOut, OutputDevice* xmlOut);505152/// @brief Destructor53~TrajectoriesHandler();5455const PollutantsInterface::Emissions computeEmissions(const std::string id,56const SUMOEmissionClass c, EnergyParams* params, double& v,57double& a, double& s);5859bool writeEmissions(std::ostream& o, const std::string id,60const SUMOEmissionClass c,61EnergyParams* params, long long int attributes,62double t, double& v,63double& a, double& s);6465bool writeXMLEmissions(const std::string id,66const SUMOEmissionClass c,67EnergyParams* params,68SUMOTime t, double& v,69double a = INVALID_VALUE, double s = INVALID_VALUE);7071void writeSums(std::ostream& o, const std::string id);7273void writeNormedSums(std::ostream& o, const std::string id, const double factor);747576protected:77/// @name inherited from GenericSAXHandler78//@{7980/** @brief Called when an opening-tag occurs81*82* Processes vehicle and motionState elements.83*84* @param[in] element The enum of the currently opened element85* @param[in] attrs Attributes of the currently opened element86* @exception ProcessError If an error within the parsed file occurs87* @see GenericSAXHandler::myStartElement88*/89void myStartElement(int element,90const SUMOSAXAttributes& attrs);91//@}9293private:94void writeOptional(std::ostream& o, long long int attributes, const SumoXMLAttr attr, double v);9596private:97const bool myComputeA;98const bool myComputeAForward;99const bool myAccelZeroCorrection;100const SUMOEmissionClass myDefaultClass;101EnergyParams* myParams;102long long int myAttributes;103const double myDefaultSlope;104std::ostream* myStdOut;105OutputDevice* myXMLOut;106std::map<std::string, double> myLastV;107std::map<std::string, double> myLastSlope;108SUMOTime myCurrentTime;109double myStepSize;110std::map<std::string, PollutantsInterface::Emissions> mySums;111std::map<std::string, SUMOEmissionClass> myEmissionClassByType;112std::map<std::string, SUMOEmissionClass> myEmissionClassByVehicle;113114115private:116/// @brief invalidated copy constructor117TrajectoriesHandler(const TrajectoriesHandler& s);118119/// @brief invalidated assignment operator120TrajectoriesHandler& operator=(const TrajectoriesHandler& s);121122123};124125126