/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2005-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 PCPolyContainer.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @author Jakob Erdmann17/// @date Mon, 05 Dec 200518///19// A storage for loaded polygons and pois20/****************************************************************************/21#pragma once22#include <config.h>2324#include <string>25#include <map>26#include <vector>27#include <utils/shapes/ShapeContainer.h>282930// ===========================================================================31// class declarations32// ===========================================================================33class Boundary;34class SUMOPolygon;35class PointOfInterest;36class OptionsCont;37class OutputDevice;383940// ===========================================================================41// class definitions42// ===========================================================================43/**44* @class PCPolyContainer45* @brief A storage for loaded polygons and pois46*/47class PCPolyContainer : public ShapeContainer {48public:49/** @brief Constructor50* @param[in] prune Whether added polygons/pois shall be pruned51* @param[in] pruningBoundary The pruning boundary (only valid if prune==true)52* @param[in] removeByNames Names of objects that shall not be added53*/54PCPolyContainer(bool prune, const Boundary& pruningBoundary,55const std::vector<std::string>& removeByNames);565758/// @brief Destructor59~PCPolyContainer();606162/** @brief Adds a polygon to the storage63*64* If pruning is enabled, "ignorePruning" is false and the polygon lies outside65* the pruning boundary, or if the polygon's name is within the names of66* objects to discard, the polygon is deleted and false is returned.67*68* Afterwards it is tested whether a polygon with the same name is already stored.69* If so, an error message is printed, the polygon is deleted and false is returned, otherwise true.70*71* @param[in] poly The polygon to add72* @param[in] ignorePruning Whether the polygon shall be kept, even though it would be pruned73* @return Whether the polygon could be added74*/75bool add(SUMOPolygon* poly, bool ignorePruning = false);767778/** @brief Adds a poi to the storage79*80* If pruning is enabled, "ignorePruning" is false and the poi lies outside81* the pruning boundary, or if the poi's name is within the names of82* objects to discard, the poi is deleted and false is returned.83*84* Afterwards it is tested whether a poi with the same name is already stored.85* If so, an error message is printed, the poi is deleted and false is returned, otherwise true.86*87* @param[in] poly The poi to add88* @param[in] ignorePruning Whether the poi shall be kept, even though it would be pruned89* @return Whether the poi could be added90*/91bool add(PointOfInterest* poi, bool ignorePruning = false);9293/// @brief add lane pos94void addLanePos(const std::string& poiID, const std::string& laneID, const double lanePos, const bool friendlyPos, const double lanePosLat);9596/** @brief Saves the stored polygons and pois into the given file97* @param[in] file The name of the file to write stored objects' definitions into98* @param[in] useGeo Whether to write output in geo-coordinates99* @exception IOError If the file could not be opened100*/101void save(const std::string& file, bool useGeo);102103/** @brief Saves the stored polygons and pois into the given file in dlrTDP format104* @param[in] prefix The prefix of the file to write stored objects' definitions into105*/106void saveDlrTDP(const std::string& prefix);107108109/** @brief Retuns a unique id for a given name110*111* The unique id is generated by having an internal map of ids to running numbers.112* The first call to this method will return 0, all subsequent with the same113* key will return numbers increased by one at each call.114* @param[in] key The key to get a running number for115* @return Unique id (running number of calls that used this key)116*/117int getEnumIDFor(const std::string& key);118119private:120/// @brief LanePos121struct LanePos {122/// @brief default constructor123LanePos();124125/// @brief parameter constructor126LanePos(const std::string& laneID, double pos, bool friendlyPos, double posLat);127128/// @brief laneID129std::string laneID;130131/// @brief pos over lane132double pos;133134/// @brief friendly position135bool friendlyPos;136137/// @brief pos lateral over lane138double posLat;139};140141/// @brief An id to pos map for lane pos specs142std::map<std::string, LanePos> myLanePosPois;143144/// @brief An id to int map for proper enumeration145std::map<std::string, int> myIDEnums;146147/// @brief The boundary that described the rectangle within which an object must be in order to be kept148Boundary myPruningBoundary;149150/// @brief Information whether the pruning boundary shall be used151bool myDoPrune;152153/// @brief List of names of polygons/pois that shall be removed154std::vector<std::string> myRemoveByNames;155156/// @brief write DLR TDP Header157static void writeDlrTDPHeader(OutputDevice& device, const OptionsCont& oc);158159/// @brief Invalidated copy constructor160PCPolyContainer(const PCPolyContainer& s);161162/// @brief Invalidated assignment operator163PCPolyContainer& operator=(const PCPolyContainer& s) = delete;164};165166167