 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
52 myLastParameterised(nullptr),
53 myGeoConvHelper(geoConvHelper) {
72 addPOI(attrs,
false,
false);
84 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key cannot be empty");
86 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key contains invalid characters");
88 WRITE_WARNING(
"Error parsing value from shape generic parameter. Value contains invalid characters");
90 WRITE_DEBUG(
"Inserting generic parameter '" + key +
"|" + val +
"' into shape.");
155 pos =
getLanePos(
id, laneID, lanePos, lanePosLat);
159 WRITE_ERROR(
"Either (x, y), (lon, lat) or (lane, pos) must be specified for PoI '" +
id +
"'.");
162 WRITE_ERROR(
"(lon, lat) is specified for PoI '" +
id +
"' but no geo-conversion is specified for the network.");
174 WRITE_ERROR(
"Unable to project coordinates for PoI '" +
id +
"'.");
179 if (!
myShapeContainer.
addPOI(
id, type, color, pos, useGeo, laneID, lanePos, lanePosLat, layer, angle, imgFile, relativePath, width, height, ignorePruning)) {
210 for (
int i = 0; i < (int)shape.size(); i++) {
218 WRITE_WARNING(
"Unable to project coordinates for polygon '" +
id +
"'.");
229 if (shape.size() == 0) {
234 if (lineWidth <= 0) {
235 WRITE_ERROR(
"Polygon's lineWidth must be greather than 0.");
239 if (!
myShapeContainer.
addPolygon(
id, type, color, layer, angle, imgFile, relativePath, shape, geo, fill, lineWidth, ignorePruning)) {
240 WRITE_ERROR(
"Polygon '" +
id +
"' already exists.");
254 for (
auto fileIt : files) {
256 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
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)
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.
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 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.
static const std::string DEFAULT_TYPE
A point in 2D or 3D with translation and scaling methods.
static bool isValidGenericParameterKey(const std::string &value)
whether the given string is a valid key for a generic parameter
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.
static bool isValidGenericParameterValue(const std::string &value)
whether the given string is a valid value for a generic parameter
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)
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.
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