 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
51 myLastParameterised(nullptr),
52 myGeoConvHelper(geoConvHelper) {
71 addPOI(attrs,
false,
false);
83 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key cannot be empty");
85 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key contains invalid characters");
87 WRITE_WARNING(
"Error parsing value from shape generic parameter. Value contains invalid characters");
89 WRITE_DEBUG(
"Inserting generic parameter '" + key +
"|" + val +
"' into shape.");
145 }
else if (useProcessing) {
163 pos =
getLanePos(
id, laneID, lanePos, lanePosLat);
167 WRITE_ERROR(
"Either (x, y), (lon, lat) or (lane, pos) must be specified for PoI '" +
id +
"'.");
170 WRITE_ERROR(
"(lon, lat) is specified for PoI '" +
id +
"' but no geo-conversion is specified for the network.");
182 WRITE_ERROR(
"Unable to project coordinates for PoI '" +
id +
"'.");
187 if (!
myShapeContainer.
addPOI(
id, type, color, pos, useGeo, laneID, lanePos, lanePosLat, layer, angle, imgFile, relativePath, width, height, ignorePruning)) {
227 if (geo || useProcessing) {
229 for (
int i = 0; i < (int)shape.size(); i++) {
233 success &= gch->x2cartesian_const(shape[i]);
237 WRITE_WARNING(
"Unable to project coordinates for polygon '" +
id +
"'.");
248 if (shape.size() == 0) {
253 if (lineWidth <= 0) {
254 WRITE_ERROR(
"Polygon's lineWidth must be greather than 0.");
258 if (!
myShapeContainer.
addPolygon(
id, type, color, layer, angle, imgFile, relativePath, shape, geo, fill, lineWidth, ignorePruning)) {
259 WRITE_ERROR(
"Polygon '" +
id +
"' already exists.");
274 for (
const auto& fileIt : files) {
276 WRITE_MESSAGE(
"Loading of shapes from " + fileIt +
" failed.");
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false)
Runs the given handler on the given file; returns if everything's ok.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
#define WRITE_WARNING(msg)
virtual ~ShapeHandler()
Destructor.
An upper class for objects with additional parameters.
Parameterised * myLastParameterised
element to receive parameters
@ SUMO_TAG_POLY
begin/end of the description of a polygon
Parameterised * getLastParameterised() const
get last parameterised object
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SAX-handler base for SUMO-files.
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation.
virtual Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)=0
get position for a given laneID (Has to be implemented in all child)
@ SUMO_TAG_PARAM
parameter associated to a certain key
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
static const double DEFAULT_LAYER
void addPoly(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a polygon
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
bool myDefaultFill
Information whether polygons should be filled.
Storage for geometrical objects.
@ SUMO_ATTR_COLOR
A color information.
@ SUMO_TAG_POI
begin/end of the description of a Point of interest
static bool loadFiles(const std::vector< std::string > &files, ShapeHandler &sh)
loads all of the given files
virtual bool addLanePosParams()
Whether some input attributes shall be automatically added as params (Can be implemented in all child...
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
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.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
const GeoConvHelper * myGeoConvHelper
geo-conversion to use during loading
void addPOI(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a POI
static const double DEFAULT_IMG_HEIGHT
static const bool DEFAULT_RELATIVEPATH
static bool isValidParameterKey(const std::string &value)
whether the given string is a valid key for a parameter
static const double DEFAULT_LINEWIDTH
void setDefaults(const std::string &prefix, const RGBColor &color, const double layer, const bool fill=false)
set default values
RGBColor myDefaultColor
The default color to use.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
virtual void myEndElement(int element)
Called when a closing tag occurs.
void set(double x, double y)
set positions x and y
double myDefaultLayer
The default layer to use.
ShapeHandler(const std::string &file, ShapeContainer &sc, const GeoConvHelper *=nullptr)
Constructor.
@ SUMO_ATTR_LAYER
A layer number.
static bool isValidParameterValue(const std::string &value)
whether the given string is a valid value for a parameter
static const std::string DEFAULT_TYPE
A point in 2D or 3D with translation and scaling methods.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue, bool report=true) const
Tries to read given attribute assuming it is an int.
@ SUMO_ATTR_FILL
Fill the polygon.
const POIs & getPOIs() const
Returns all pois.
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)
Builds a polygon using the given values and adds it to the container.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static bool isValidTypeID(const std::string &value)
whether the given string is a valid id for an edge or vehicle type
ShapeContainer & myShapeContainer
reference to shape container in which all Shares are being added
const std::string & getFileName() const
returns the current file name
T get(const std::string &id) const
Retrieves an item.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
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, double posLat, 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.
static const double DEFAULT_ANGLE
The XML-Handler for network loading.
const Polygons & getPolygons() const
Returns all polygons.
static const std::string DEFAULT_IMG_FILE
Encapsulated SAX-Attributes.
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
std::string myPrefix
The prefix to use.
#define WRITE_MESSAGE(msg)
static const double DEFAULT_LAYER_POI
static const double DEFAULT_IMG_WIDTH