53 myLastParameterised(nullptr),
54 myGeoConvHelper(geoConvHelper) {
73 addPOI(attrs,
false,
false);
85 WRITE_WARNING(
TL(
"Error parsing key from shape generic parameter. Key cannot be empty"));
87 WRITE_WARNING(
TL(
"Error parsing key from shape generic parameter. Key contains invalid characters"));
89 WRITE_DEBUG(
"Inserting generic parameter '" + key +
"|" + val +
"' into shape.");
155 }
else if (useProcessing) {
173 pos =
getLanePos(
id, laneID, lanePos, friendlyPos, lanePosLat);
177 WRITE_ERRORF(
TL(
"Either (x, y), (lon, lat) or (lane, pos) must be specified for PoI '%'."),
id);
180 WRITE_ERRORF(
TL(
"(lon, lat) is specified for PoI '%' but no geo-conversion is specified for the network."),
id);
192 WRITE_ERRORF(
TL(
"Unable to project coordinates for POI '%'."),
id);
200 if (!
myShapeContainer.
addPOI(
id, type, color, pos, useGeo, laneID, lanePos, friendlyPos, lanePosLat, icon,
201 layer, angle, imgFile, relativePath, width, height, ignorePruning)) {
241 if (geo || useProcessing) {
243 for (
int i = 0; i < (int)shape.size(); i++) {
247 success &= gch->x2cartesian_const(shape[i]);
262 if (shape.size() == 0) {
267 if (lineWidth <= 0) {
268 WRITE_ERROR(
TL(
"Polygon's lineWidth must be greater than 0."));
272 if (!
myShapeContainer.
addPolygon(
id, type, color, layer, angle, imgFile, relativePath, shape, geo, fill, lineWidth, ignorePruning)) {
288 for (
const auto& fileIt : files) {
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGEF(...)
#define WRITE_ERRORF(...)
#define WRITE_WARNING(msg)
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
@ SUMO_TAG_POLY
begin/end of the description of a polygon
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_FILL
Fill the polygon.
@ SUMO_ATTR_LAYER
A layer number.
@ SUMO_ATTR_COLOR
A color information.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
const std::string & getFileName() const
returns the current file name
static methods for processing the coordinates conversion for the current net
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
T get(const std::string &id) const
Retrieves an item.
An upper class for objects with additional parameters.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A point in 2D or 3D with translation and scaling methods.
void set(double x, double y)
set positions x and y
void setz(double z)
set position z
static const RGBColor WHITE
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SAX-handler base for SUMO-files.
class for maintaining associations between enums and xml-strings
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
static StringBijection< POIIcon > POIIcons
POI icon values.
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter
Storage for geometrical objects.
const Polygons & getPolygons() const
Returns all polygons.
virtual bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, const PositionVector &shape, bool geo, bool fill, double lineWidth, bool ignorePruning=false, const std::string &name=Shape::DEFAULT_NAME)
Builds a polygon using the given values and adds it to the container.
virtual bool addPOI(const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, bool geo, const std::string &lane, double posOverLane, bool friendlyPos, double posLat, const std::string &icon, double layer, double angle, const std::string &imgFile, bool relativePath, double width, double height, bool ignorePruning=false)
Builds a POI using the given values and adds it to the container.
const POIs & getPOIs() const
Returns all pois.
The XML-Handler for network loading.
virtual bool addLanePosParams()
Whether some input attributes shall be automatically added as params (Can be implemented in all child...
std::string myPrefix
The prefix to use.
virtual void myEndElement(int element)
Called when a closing tag occurs.
void addPOI(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a POI
void addPoly(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a polygon
RGBColor myDefaultColor
The default color to use.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
ShapeContainer & myShapeContainer
reference to shape container in which all Shares are being added
Parameterised * myLastParameterised
element to receive parameters
static bool loadFiles(const std::vector< std::string > &files, ShapeHandler &sh)
loads all of the given files
virtual Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, bool friendlyPos, double lanePosLat)=0
get position for a given laneID (Has to be implemented in all child)
void setDefaults(const std::string &prefix, const RGBColor &color, const std::string &icon, const double layer, const bool fill=false)
set default values
bool myDefaultFill
Information whether polygons should be filled.
virtual ~ShapeHandler()
Destructor.
ShapeHandler(const std::string &file, ShapeContainer &sc, const GeoConvHelper *=nullptr)
Constructor.
Parameterised * getLastParameterised() const
get last parameterised object
std::string myDefaultIcon
The default icon to use.
const GeoConvHelper * myGeoConvHelper
geo-conversion to use during loading
double myDefaultLayer
The default layer to use.
static const bool DEFAULT_RELATIVEPATH
static const double DEFAULT_LAYER
static const double DEFAULT_LAYER_POI
static const double DEFAULT_IMG_WIDTH
static const std::string DEFAULT_IMG_FILE
static const double DEFAULT_LINEWIDTH
static const double DEFAULT_ANGLE
static const double DEFAULT_IMG_HEIGHT
static const std::string DEFAULT_TYPE
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false, const bool isExternal=false, const bool catchExceptions=true)
Runs the given handler on the given file; returns if everything's ok.