45 myPrefix(
""), myDefaultColor(
RGBColor::RED), myDefaultLayer(), myDefaultFill(false),
46 myLastParameterised(nullptr) {
63 addPOI(attrs,
false,
false);
75 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key cannot be empty");
77 WRITE_WARNING(
"Error parsing key from shape generic parameter. Key contains invalid characters");
79 WRITE_WARNING(
"Error parsing value from shape generic parameter. Value contains invalid characters");
81 WRITE_DEBUG(
"Inserting generic parameter '" + key +
"|" + val +
"' into shape.");
130 if (lat == INVALID_POSITION || lon == INVALID_POSITION) {
138 if (x == INVALID_POSITION || y == INVALID_POSITION) {
141 pos =
getLanePos(
id, laneID, lanePos, lanePosLat);
144 if (lat == INVALID_POSITION || lon == INVALID_POSITION) {
145 WRITE_ERROR(
"Either (x, y), (lon, lat) or (lane, pos) must be specified for PoI '" +
id +
"'.");
148 WRITE_ERROR(
"(lon, lat) is specified for PoI '" +
id +
"' but no geo-conversion is specified for the network.");
160 WRITE_ERROR(
"Unable to project coordinates for PoI '" +
id +
"'.");
165 if (!
myShapeContainer.
addPOI(
id, type, color, pos, useGeo, laneID, lanePos, lanePosLat, layer, angle, imgFile, relativePath, width, height, ignorePruning)) {
195 for (
int i = 0; i < (int)shape.size(); i++) {
203 WRITE_WARNING(
"Unable to project coordinates for polygon '" +
id +
"'.");
214 if (shape.size() == 0) {
219 if (lineWidth <= 0) {
220 WRITE_ERROR(
"Polygon's lineWidth must be greather than 0.");
224 if (!
myShapeContainer.
addPolygon(
id, type, color, layer, angle, imgFile, relativePath, shape, geo, fill, lineWidth, ignorePruning)) {
225 WRITE_ERROR(
"Polygon '" +
id +
"' already exists.");
234 for (
auto fileIt : files) {
236 WRITE_MESSAGE(
"Loading of shapes from " + fileIt +
" failed.");
double myDefaultLayer
The default layer to use.
static std::string getConfigurationRelative(const std::string &configPath, const std::string &path)
Returns the second path as a relative path to the first file.
ShapeHandler(const std::string &file, ShapeContainer &sc)
Constructor.
static const std::string DEFAULT_IMG_FILE
void setDefaults(const std::string &prefix, const RGBColor &color, const double layer, const bool fill=false)
set default values
virtual void myEndElement(int element)
Called when a closing tag occurs.
const Polygons & getPolygons() const
Returns all polygons.
virtual Position getLanePos(const std::string &poiID, const std::string &laneID, double lanePos, double lanePosLat)=0
get position for a given laneID
static const double DEFAULT_LAYER_POI
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
static bool loadFiles(const std::vector< std::string > &files, ShapeHandler &sh)
loads all of the given files
const std::string & getFileName() const
returns the current file name
bool x2cartesian(Position &from, bool includeInBoundary=true)
Converts the given coordinate into a cartesian and optionally update myConvBoundary.
T get(const std::string &id) const
Retrieves an item.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
static const double DEFAULT_IMG_HEIGHT
Storage for geometrical objects.
begin/end of the description of a Point of interest
RGBColor myDefaultColor
The default color to use.
Parameterised * myLastParameterised
element to receive parameters
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.
void set(double x, double y)
set positions x and y
SAX-handler base for SUMO-files.
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.
static const std::string DEFAULT_TYPE
std::string myPrefix
The prefix to use.
static bool isValidGenericParameterKey(const std::string &value)
whether the given string is a valid key for a generic parameter
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 std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
The XML-Handler for network loading.
static bool isValidGenericParameterValue(const std::string &value)
whether the given string is a valid value for a generic parameter
static methods for processing the coordinates conversion for the current net
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Encapsulated SAX-Attributes.
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 addLanePosParams()
Whether some input attributes shall be automatically added as params.
static bool isAbsolute(const std::string &path)
Returns the information whether the given path is absolute.
A point in 2D or 3D with translation and scaling methods.
parameter associated to a certain key
void addPOI(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a POI
static const bool DEFAULT_RELATIVEPATH
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_LINEWIDTH
bool myDefaultFill
Information whether polygons should be filled.
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
edge: the shape in xml-definition
void addPoly(const SUMOSAXAttributes &attrs, const bool ignorePruning, const bool useProcessing)
adds a polygon
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.
virtual ~ShapeHandler()
Destructor.
ShapeContainer & myShapeContainer
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
static const double DEFAULT_IMG_WIDTH
bool x2cartesian_const(Position &from) const
Converts the given coordinate into a cartesian using the previous initialisation. ...
#define WRITE_MESSAGE(msg)
static const double DEFAULT_ANGLE
begin/end of the description of a polygon
static const double DEFAULT_LAYER
const POIs & getPOIs() const
Returns all pois.