65 std::set<std::string> result;
66 result.insert(
"highway");
67 result.insert(
"waterway");
68 result.insert(
"aeroway");
69 result.insert(
"aerialway");
70 result.insert(
"power");
71 result.insert(
"man_made");
72 result.insert(
"building");
73 result.insert(
"leisure");
74 result.insert(
"amenity");
75 result.insert(
"shop");
76 result.insert(
"tourism");
77 result.insert(
"historic");
78 result.insert(
"landuse");
79 result.insert(
"natural");
80 result.insert(
"military");
81 result.insert(
"boundary");
82 result.insert(
"admin_level");
83 result.insert(
"sport");
84 result.insert(
"polygon");
85 result.insert(
"place");
86 result.insert(
"population");
87 result.insert(
"openGeoDB:population");
88 result.insert(
"openGeoDB:name");
95 if (!oc.
isSet(
"osm-files")) {
101 std::map<long long int, PCOSMNode*> nodes;
102 bool withAttributes = oc.
getBool(
"all-attributes");
105 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
108 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
113 for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
123 RelationsHandler relationsHandler(additionalWays, relations, withAttributes, *m);
124 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
133 EdgesHandler edgesHandler(nodes, edges, additionalWays, withAttributes, *m);
134 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
142 const bool useName = oc.
getBool(
"osm.use-name");
144 for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
167 std::string unknownPolyType =
"";
168 for (std::map<std::string, std::string>::iterator it = e->
myAttributes.begin(); it != e->
myAttributes.end(); ++it) {
169 const std::string& key = it->first;
170 const std::string& value = it->second;
171 const std::string fullType = key +
"." + value;
172 if (tm.
has(key +
"." + value)) {
173 index =
addPolygon(e, vec, tm.
get(fullType), fullType, index, useName, toFill, ignorePruning, withAttributes);
174 }
else if (tm.
has(key)) {
175 index =
addPolygon(e, vec, tm.
get(key), fullType, index, useName, toFill, ignorePruning, withAttributes);
177 unknownPolyType = fullType;
181 if (index == 0 && !def.
discard && unknownPolyType !=
"") {
182 addPolygon(e, vec, def, unknownPolyType, index, useName, toFill, ignorePruning, withAttributes);
188 for (std::map<long long int, PCOSMNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i) {
201 std::string unKnownPOIType =
"";
202 for (std::map<std::string, std::string>::iterator it = n->
myAttributes.begin(); it != n->
myAttributes.end(); ++it) {
203 const std::string& key = it->first;
204 const std::string& value = it->second;
205 const std::string fullType = key +
"." + value;
206 if (tm.
has(key +
"." + value)) {
207 index =
addPOI(n, pos, tm.
get(fullType), fullType, index, toFill, ignorePruning, withAttributes);
208 }
else if (tm.
has(key)) {
209 index =
addPOI(n, pos, tm.
get(key), fullType, index, toFill, ignorePruning, withAttributes);
211 unKnownPOIType = fullType;
215 if (index == 0 && !def.
discard && unKnownPOIType !=
"") {
216 addPOI(n, pos, def, unKnownPOIType, index, toFill, ignorePruning, withAttributes);
220 for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
224 for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
228 for (Relations::iterator i = relations.begin(); i != relations.end(); ++i) {
239 const bool closedShape = vec.front() == vec.back();
240 const std::string idSuffix = (index == 0 ?
"" :
"#" +
toString(index));
246 if (withAttributes) {
249 if (!toFill.
add(poly, ignorePruning)) {
259 int index,
PCPolyContainer& toFill,
bool ignorePruning,
bool withAttributes) {
263 const std::string idSuffix = (index == 0 ?
"" :
"#" +
toString(index));
268 def.
color, pos,
false,
"", 0, 0, (
double)def.
layer);
269 if (withAttributes) {
272 if (!toFill.
add(poi, ignorePruning)) {
285 bool withAttributes,
MsgHandler& errorHandler) :
286 SUMOSAXHandler(
"osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
287 myToFill(toFill), myLastNodeID(-1) {}
353 myAdditionalWays(additionalWays),
354 myRelations(relations),
357 myCurrentRelation(0) {
373 if (action ==
"delete" || !ok) {
388 if (role ==
"outer" || role ==
"inner") {
390 if (memberType ==
"way") {
437 bool withAttributes,
MsgHandler& errorHandler) :
441 myOSMNodes(osmNodes),
std::string id
The new type id to use.
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
std::map< std::string, std::string > myAttributes
Additional attributes.
An internal definition of a loaded edge.
static int addPOI(const PCOSMNode *node, const Position &pos, const PCTypeMap::TypeDef &def, const std::string &fullType, int index, PCPolyContainer &toFill, bool ignorePruning, bool withAttributes)
try add the POI and return the next index on success
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored as OSM-XML.
void myEndElement(int element)
Called when a closing tag occurs.
EdgeMap & myEdgeMap
A map of built edges.
A single definition of values that shall be used for a given type.
PCOSMRelation * myCurrentRelation
The currently parsed relation.
bool isInStringVector(const std::string &optionName, const std::string &itemName)
Returns the named option is a list of string values containing the specified item.
static bool isReadable(std::string path)
Checks whether the given file is readable.
An internal definition of a loaded relation.
bool add(SUMOPolygon *poly, bool ignorePruning=false)
Adds a polygon to the storage.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
RelationsMap & myAdditionalWays
additional ways which are reference by relations
~EdgesHandler()
Destructor.
std::vector< long long int > myCurrentWays
the ways within the current relation
double layer
The layer to use.
long long int myLastNodeID
The id of the last parsed node.
Relations & myRelations
the loaded relations
long long int id
The node's id.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
RelationsHandler(RelationsMap &additionalWays, Relations &relations, bool withAttributes, MsgHandler &errorHandler)
Constructor.
static std::set< std::string > initMyKeysToInclude()
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.
NodesHandler(std::map< long long int, PCOSMNode *> &toFill, bool withAttributes, MsgHandler &errorHandler)
Contructor.
~RelationsHandler()
Destructor.
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)
bool discard
Information whether polygons of this type shall be discarded.
A storage for loaded polygons and pois.
static OptionsCont & getOptions()
Retrieves the options.
MsgHandler & myErrorHandler
The handler to report errors to (will be the WarningsHandler if –ignore-errors was set) ...
double lon
The longitude the node is located at.
RGBColor color
The color to use.
std::map< long long int, PCOSMEdge * > EdgeMap
long long int id
The edge's id.
A class which extracts relevant way-ids from relations in a parsed OSM-file.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static const std::set< std::string > MyKeysToInclude
double lat
The latitude the node is located at.
std::map< std::string, std::string > myAttributes
Additional attributes.
A storage for type mappings.
const TypeDef & get(const std::string &id)
Returns a type definition.
PCOSMEdge * myCurrentEdge
The currently built edge.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void myEndElement(int element)
Called when a closing tag occurs.
MsgHandler & myErrorHandler
The handler to report errors to (will be the WarningsHandler if –ignore-errors was set) ...
void updateParameter(const std::map< std::string, std::string > &mapArg)
Adds or updates all given parameters from the map.
void myEndElement(int element)
Called when a closing tag occurs.
std::string name
The relation's name (if any)
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.
A point in 2D or 3D with translation and scaling methods.
std::map< std::string, std::string > myAttributes
Additional attributes.
bool has(const std::string &id)
Returns the information whether the named type is known.
bool myIsClosed
Information whether this area is closed.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
#define PROGRESS_BEGIN_MESSAGE(msg)
MsgHandler & myErrorHandler
The handler to report errors to (will be the WarningsHandler if –ignore-errors was set) ...
A class which extracts OSM-edges from a parsed OSM-file.
std::map< long long int, PCOSMRelation * > RelationsMap
long long int id
The relation's id.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
bool myKeep
whether the last edge (way) should be kept because it had a key from the inclusion list ...
std::vector< int > myParentElements
Current path in order to know to what occuring values belong.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
A class which extracts OSM-nodes from a parsed OSM-file.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
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.
std::string prefix
The prefix to use.
std::vector< long long int > myParentElements
Current path in order to know to what occuring values belong.
std::vector< int > myParentElements
Current path in order to know to what occuring values belong.
std::vector< PCOSMRelation * > Relations
std::vector< long long int > myCurrentNodes
The list of nodes this edge is made of.
static int addPolygon(const PCOSMEdge *edge, const PositionVector &vec, const PCTypeMap::TypeDef &def, const std::string &fullType, int index, bool useName, PCPolyContainer &toFill, bool ignorePruning, bool withAttributes)
try add the polygon and return the next index on success
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
alternative definition for junction
void inform(std::string msg, bool addType=true)
adds a new error to the list
A storage for options typed value containers)
std::string name
The edge's name (if any)
const TypeDef & getDefault()
get the default type according to the given options
bool myWithAttributes
Whether all attributes shall be stored.
void push_back_noDoublePos(const Position &p)
insert in back a non double position
~NodesHandler()
Destructor.
bool myWithAttributes
Whether all attributes shall be stored.
#define PROGRESS_DONE_MESSAGE()
EdgesHandler(const std::map< long long int, PCOSMNode *> &osmNodes, EdgeMap &toFill, const RelationsMap &additionalWays, bool withAttributes, MsgHandler &errorHandler)
Constructor.
const std::map< long long int, PCOSMNode * > & myOSMNodes
The previously parsed nodes.
std::map< long long int, PCOSMNode * > & myToFill
The nodes container to fill.
const RelationsMap & myAdditionalWays
additional ways which are reference by relations
bool allowFill
Information whether polygons of this type can be filled.
An internal representation of an OSM-node.