SUMO - Simulation of Urban MObility
PCLoaderOSM.cpp
Go to the documentation of this file.
1 /****************************************************************************/
11 // A reader of pois and polygons stored in OSM-format
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2008-2016 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <map>
37 #include <fstream>
40 #include <utils/common/ToString.h>
43 #include <utils/options/Option.h>
44 #include <utils/common/StdDefs.h>
46 #include "PCLoaderOSM.h"
47 #include <utils/common/RGBColor.h>
48 #include <utils/geom/GeomHelper.h>
49 #include <utils/geom/Position.h>
51 #include <utils/xml/XMLSubSys.h>
54 
55 #ifdef CHECK_MEMORY_LEAKS
56 #include <foreign/nvwa/debug_new.h>
57 #endif // CHECK_MEMORY_LEAKS
58 // ---------------------------------------------------------------------------
59 // static members
60 // ---------------------------------------------------------------------------
62 
63 // ===========================================================================
64 // method definitions
65 // ===========================================================================
66 // ---------------------------------------------------------------------------
67 // static interface
68 // ---------------------------------------------------------------------------
69 std::set<std::string> PCLoaderOSM::initMyKeysToInclude() {
70  std::set<std::string> result;
71  result.insert("highway");
72  result.insert("waterway");
73  result.insert("aeroway");
74  result.insert("aerialway");
75  result.insert("power");
76  result.insert("man_made");
77  result.insert("building");
78  result.insert("leisure");
79  result.insert("amenity");
80  result.insert("shop");
81  result.insert("tourism");
82  result.insert("historic");
83  result.insert("landuse");
84  result.insert("natural");
85  result.insert("military");
86  result.insert("boundary");
87  result.insert("admin_level");
88  result.insert("sport");
89  result.insert("polygon");
90  result.insert("place");
91  result.insert("population");
92  result.insert("openGeoDB:population");
93  result.insert("openGeoDB:name");
94  return result;
95 }
96 
97 void
99  PCTypeMap& tm) {
100  if (!oc.isSet("osm-files")) {
101  return;
102  }
103  // parse file(s)
104  std::vector<std::string> files = oc.getStringVector("osm-files");
105  // load nodes, first
106  std::map<long long int, PCOSMNode*> nodes;
107  bool withAttributes = oc.getBool("all-attributes");
109  NodesHandler nodesHandler(nodes, withAttributes, *m);
110  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
111  // nodes
112  if (!FileHelpers::isReadable(*file)) {
113  WRITE_ERROR("Could not open osm-file '" + *file + "'.");
114  return;
115  }
116  PROGRESS_BEGIN_MESSAGE("Parsing nodes from osm-file '" + *file + "'");
117  if (!XMLSubSys::runParser(nodesHandler, *file)) {
118  for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
119  delete(*i).second;
120  }
121  throw ProcessError();
122  }
124  }
125  // load relations to see which additional ways may be relevant
126  Relations relations;
127  RelationsMap additionalWays;
128  RelationsHandler relationsHandler(additionalWays, relations, withAttributes, *m);
129  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
130  // edges
131  PROGRESS_BEGIN_MESSAGE("Parsing relations from osm-file '" + *file + "'");
132  XMLSubSys::runParser(relationsHandler, *file);
134  }
135 
136  // load ways
137  EdgeMap edges;
138  EdgesHandler edgesHandler(nodes, edges, additionalWays, withAttributes, *m);
139  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
140  // edges
141  PROGRESS_BEGIN_MESSAGE("Parsing edges from osm-file '" + *file + "'");
142  XMLSubSys::runParser(edgesHandler, *file);
144  }
145 
146  // build all
147  const bool useName = oc.getBool("osm.use-name");
148  // instatiate polygons
149  for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
150  PCOSMEdge* e = (*i).second;
151  if (e->myAttributes.size() == 0) {
152  // cannot be relevant as a polygon
153  continue;
154  }
155  if (e->myCurrentNodes.size() == 0) {
156  WRITE_ERROR("Polygon '" + toString(e->id) + "' has no shape.");
157  continue;
158  }
159  // compute shape
160  PositionVector vec;
161  for (std::vector<long long int>::iterator j = e->myCurrentNodes.begin(); j != e->myCurrentNodes.end(); ++j) {
162  PCOSMNode* n = nodes.find(*j)->second;
163  Position pos(n->lon, n->lat);
164  if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
165  WRITE_WARNING("Unable to project coordinates for polygon '" + toString(e->id) + "'.");
166  }
167  vec.push_back_noDoublePos(pos);
168  }
169  const bool ignorePruning = OptionsCont::getOptions().isInStringVector("prune.keep-list", toString(e->id));
170  // add as many polygons as keys match defined types
171  int index = 0;
172  std::string unknownPolyType = "";
173  for (std::map<std::string, std::string>::iterator it = e->myAttributes.begin(); it != e->myAttributes.end(); ++it) {
174  const std::string& key = it->first;
175  const std::string& value = it->second;
176  const std::string fullType = key + "." + value;
177  if (tm.has(key + "." + value)) {
178  index = addPolygon(e, vec, tm.get(fullType), fullType, index, useName, toFill, ignorePruning, withAttributes);
179  } else if (tm.has(key)) {
180  index = addPolygon(e, vec, tm.get(key), fullType, index, useName, toFill, ignorePruning, withAttributes);
181  } else if (MyKeysToInclude.count(key) > 0) {
182  unknownPolyType = fullType;
183  }
184  }
185  const PCTypeMap::TypeDef& def = tm.getDefault();
186  if (index == 0 && !def.discard && unknownPolyType != "") {
187  addPolygon(e, vec, def, unknownPolyType, index, useName, toFill, ignorePruning, withAttributes);
188  }
189  }
190 
191 
192  // instantiate pois
193  for (std::map<long long int, PCOSMNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i) {
194  PCOSMNode* n = (*i).second;
195  if (n->myAttributes.size() == 0) {
196  // cannot be relevant as a poi
197  continue;
198  }
199  Position pos(n->lon, n->lat);
200  if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
201  WRITE_WARNING("Unable to project coordinates for POI '" + toString(n->id) + "'.");
202  }
203  const bool ignorePruning = OptionsCont::getOptions().isInStringVector("prune.keep-list", toString(n->id));
204  // add as many POIs as keys match defined types
205  int index = 0;
206  std::string unKnownPOIType = "";
207  for (std::map<std::string, std::string>::iterator it = n->myAttributes.begin(); it != n->myAttributes.end(); ++it) {
208  const std::string& key = it->first;
209  const std::string& value = it->second;
210  const std::string fullType = key + "." + value;
211  if (tm.has(key + "." + value)) {
212  index = addPOI(n, pos, tm.get(fullType), fullType, index, toFill, ignorePruning, withAttributes);
213  } else if (tm.has(key)) {
214  index = addPOI(n, pos, tm.get(key), fullType, index, toFill, ignorePruning, withAttributes);
215  } else if (MyKeysToInclude.count(key) > 0) {
216  unKnownPOIType = fullType;
217  }
218  }
219  const PCTypeMap::TypeDef& def = tm.getDefault();
220  if (index == 0 && !def.discard && unKnownPOIType != "") {
221  addPOI(n, pos, def, unKnownPOIType, index, toFill, ignorePruning, withAttributes);
222  }
223  }
224  // delete nodes
225  for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
226  delete(*i).second;
227  }
228  // delete edges
229  for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
230  delete(*i).second;
231  }
232  // delete relations
233  for (Relations::iterator i = relations.begin(); i != relations.end(); ++i) {
234  delete(*i);
235  }
236 }
237 
238 
239 int
240 PCLoaderOSM::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) {
241  if (def.discard) {
242  return index;
243  } else {
244  const bool closedShape = vec.front() == vec.back();
245  const std::string idSuffix = (index == 0 ? "" : "#" + toString(index));
246  const std::string id = def.prefix + (useName && edge->name != "" ? edge->name : toString(edge->id)) + idSuffix;
247  SUMO::Polygon* poly = new SUMO::Polygon(
249  StringUtils::escapeXML(OptionsCont::getOptions().getBool("osm.keep-full-type") ? fullType : def.id),
250  def.color, vec, def.allowFill && closedShape, (SUMOReal)def.layer);
251  if (withAttributes) {
252  poly->addParameter(edge->myAttributes);
253  }
254  if (!toFill.add(poly, ignorePruning)) {
255  return index;
256  } else {
257  return index + 1;
258  }
259  }
260 }
261 
262 int
263 PCLoaderOSM::addPOI(const PCOSMNode* node, const Position& pos, const PCTypeMap::TypeDef& def, const std::string& fullType,
264  int index, PCPolyContainer& toFill, bool ignorePruning, bool withAttributes) {
265  if (def.discard) {
266  return index;
267  } else {
268  const std::string idSuffix = (index == 0 ? "" : "#" + toString(index));
269  const std::string id = def.prefix + toString(node->id) + idSuffix;
270  PointOfInterest* poi = new PointOfInterest(
272  StringUtils::escapeXML(OptionsCont::getOptions().getBool("osm.keep-full-type") ? fullType : def.id),
273  def.color, pos, (SUMOReal)def.layer);
274  if (withAttributes) {
275  poi->addParameter(node->myAttributes);
276  }
277  if (!toFill.add(poi, ignorePruning)) {
278  return index;
279  } else {
280  return index + 1;
281  }
282  }
283 }
284 
285 
286 // ---------------------------------------------------------------------------
287 // definitions of PCLoaderOSM::NodesHandler-methods
288 // ---------------------------------------------------------------------------
289 PCLoaderOSM::NodesHandler::NodesHandler(std::map<long long int, PCOSMNode*>& toFill,
290  bool withAttributes, MsgHandler& errorHandler) :
291  SUMOSAXHandler("osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
292  myToFill(toFill), myLastNodeID(-1) {}
293 
294 
296 
297 
298 void
300  myParentElements.push_back(element);
301  if (element == SUMO_TAG_NODE) {
302  bool ok = true;
303  long long int id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
304  if (!ok) {
305  return;
306  }
307  myLastNodeID = -1;
308  if (myToFill.find(id) == myToFill.end()) {
309  myLastNodeID = id;
310  // assume we are loading multiple files...
311  // ... so we won't report duplicate nodes
312  PCOSMNode* toAdd = new PCOSMNode();
313  toAdd->id = id;
314  bool ok = true;
315  toAdd->lon = attrs.get<SUMOReal>(SUMO_ATTR_LON, toString(id).c_str(), ok);
316  toAdd->lat = attrs.get<SUMOReal>(SUMO_ATTR_LAT, toString(id).c_str(), ok);
317  if (!ok) {
318  delete toAdd;
319  return;
320  }
321  myToFill[toAdd->id] = toAdd;
322  }
323  }
324  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_NODE
325  && myLastNodeID != -1) {
326  bool ok = true;
327  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myLastNodeID).c_str(), ok, "", false);
328  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myLastNodeID).c_str(), ok, "", false);
329  if (key == "") {
330  myErrorHandler.inform("Empty key in a a tag while parsing node '" + toString(myLastNodeID) + "' occured.");
331  ok = false;
332  }
333  if (!ok) {
334  return;
335  }
336  myToFill[myLastNodeID]->myAttributes[key] = value;
337  }
338 }
339 
340 
341 void
343  if (element == SUMO_TAG_NODE) {
344  myLastNodeID = -1;
345  }
346  myParentElements.pop_back();
347 }
348 
349 
350 // ---------------------------------------------------------------------------
351 // definitions of PCLoaderOSM::RelationsHandler-methods
352 // ---------------------------------------------------------------------------
354  Relations& relations,
355  bool withAttributes,
356  MsgHandler& errorHandler) :
357  SUMOSAXHandler("osm - file"),
358  myAdditionalWays(additionalWays),
359  myRelations(relations),
360  myWithAttributes(withAttributes),
361  myErrorHandler(errorHandler),
362  myCurrentRelation(0) {
363 }
364 
365 
367 }
368 
369 
370 void
372  myParentElements.push_back(element);
373  // parse "relation" elements
374  if (element == SUMO_TAG_RELATION) {
375  bool ok = true;
376  myCurrentWays.clear();
377  std::string action = attrs.hasAttribute("action") ? attrs.getStringSecure("action", "") : "";
378  if (action == "delete" || !ok) {
379  myCurrentRelation = 0;
380  }
382  myCurrentRelation->id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
383  myRelations.push_back(myCurrentRelation);
384  return;
385  } else if (myCurrentRelation == 0) {
386  return;
387  }
388  // parse member elements
389  if (element == SUMO_TAG_MEMBER) {
390  bool ok = true;
391  std::string role = attrs.hasAttribute("role") ? attrs.getStringSecure("role", "") : "";
392  long long int ref = attrs.get<long long int>(SUMO_ATTR_REF, 0, ok);
393  if (role == "outer" || role == "inner") {
394  std::string memberType = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
395  if (memberType == "way") {
396  myCurrentWays.push_back(ref);
397  }
398  }
399  return;
400  }
401  // parse values
402  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_RELATION
403  && myCurrentRelation != 0) {
404  bool ok = true;
405  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myCurrentRelation).c_str(), ok, "", false);
406  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myCurrentRelation).c_str(), ok, "", false);
407  if (key == "") {
408  myErrorHandler.inform("Empty key in a a tag while parsing way '" + toString(myCurrentRelation) + "' occured.");
409  ok = false;
410  }
411  if (!ok) {
412  return;
413  }
414  if (key == "name") {
415  myCurrentRelation->name = value;
416  } else if (MyKeysToInclude.count(key) > 0) {
417  for (std::vector<long long int>::iterator it = myCurrentWays.begin(); it != myCurrentWays.end(); ++it) {
419  }
420  }
421  myCurrentRelation->myAttributes[key] = value;
422  }
423 }
424 
425 
426 void
428  myParentElements.pop_back();
429  if (element == SUMO_TAG_RELATION) {
430  myCurrentRelation = 0;
431  myCurrentWays.clear();
432  }
433 }
434 
435 
436 // ---------------------------------------------------------------------------
437 // definitions of PCLoaderOSM::EdgesHandler-methods
438 // ---------------------------------------------------------------------------
439 PCLoaderOSM::EdgesHandler::EdgesHandler(const std::map<long long int, PCOSMNode*>& osmNodes,
440  EdgeMap& toFill,
441  const RelationsMap& additionalWays,
442  bool withAttributes, MsgHandler& errorHandler) :
443  SUMOSAXHandler("osm - file"),
444  myWithAttributes(withAttributes),
445  myErrorHandler(errorHandler),
446  myOSMNodes(osmNodes),
447  myEdgeMap(toFill),
448  myAdditionalWays(additionalWays) {
449 }
450 
451 
453 }
454 
455 
456 void
458  myParentElements.push_back(element);
459  // parse "way" elements
460  if (element == SUMO_TAG_WAY) {
461  bool ok = true;
462  long long int id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
463  if (!ok) {
464  return;
465  }
466  myCurrentEdge = new PCOSMEdge();
467  myCurrentEdge->id = id;
468  myCurrentEdge->myIsClosed = false;
469  myKeep = (myAdditionalWays.find(id) != myAdditionalWays.end());
470  }
471  // parse "nd" (node) elements
472  if (element == SUMO_TAG_ND) {
473  bool ok = true;
474  long long int ref = attrs.get<long long int>(SUMO_ATTR_REF, 0, ok);
475  if (ok) {
476  if (myOSMNodes.find(ref) == myOSMNodes.end()) {
477  WRITE_WARNING("The referenced geometry information (ref='" + toString(ref) + "') is not known");
478  return;
479  }
480  myCurrentEdge->myCurrentNodes.push_back(ref);
481  }
482  }
483  // parse values
484  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_WAY
485  && myCurrentEdge != 0) {
486  bool ok = true;
487  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myCurrentEdge->id).c_str(), ok, "", false);
488  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myCurrentEdge->id).c_str(), ok, "", false);
489  if (key == "") {
490  myErrorHandler.inform("Empty key in a a tag while parsing way '" + toString(myCurrentEdge->id) + "' occured.");
491  ok = false;
492  }
493  if (!ok) {
494  return;
495  }
496  if (key == "name") {
497  myCurrentEdge->name = value;
498  } else if (MyKeysToInclude.count(key) > 0) {
499  myKeep = true;
500  }
501  myCurrentEdge->myAttributes[key] = value;
502  }
503 }
504 
505 
506 void
508  myParentElements.pop_back();
509  if (element == SUMO_TAG_WAY) {
510  if (myKeep) {
511  RelationsMap::const_iterator it = myAdditionalWays.find(myCurrentEdge->id);
512  if (it != myAdditionalWays.end()) {
513  myCurrentEdge->myAttributes.insert((*it).second->myAttributes.begin(), (*it).second->myAttributes.end());
514  }
516  } else {
517  delete myCurrentEdge;
518  }
519  myCurrentEdge = 0;
520  }
521 }
522 
523 
524 /****************************************************************************/
525 
std::string id
The new type id to use.
Definition: PCTypeMap.h:68
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:71
std::map< std::string, std::string > myAttributes
Additional attributes.
Definition: PCLoaderOSM.h:98
SUMOReal lat
The latitude the node is located at.
Definition: PCLoaderOSM.h:84
An internal definition of a loaded edge.
Definition: PCLoaderOSM.h:104
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.
Definition: MsgHandler.cpp:80
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored as OSM-XML.
Definition: PCLoaderOSM.cpp:98
void myEndElement(int element)
Called when a closing tag occurs.
EdgeMap & myEdgeMap
A map of built edges.
Definition: PCLoaderOSM.h:349
A single definition of values that shall be used for a given type.
Definition: PCTypeMap.h:66
PCOSMRelation * myCurrentRelation
The currently parsed relation.
Definition: PCLoaderOSM.h:268
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.
Definition: FileHelpers.cpp:58
An internal definition of a loaded relation.
Definition: PCLoaderOSM.h:92
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:98
RelationsMap & myAdditionalWays
additional ways which are reference by relations
Definition: PCLoaderOSM.h:256
static std::string escapeXML(const std::string &orig)
Replaces the standard escapes by their XML entities.
std::vector< long long int > myCurrentWays
the ways within the current relation
Definition: PCLoaderOSM.h:271
long long int myLastNodeID
The id of the last parsed node.
Definition: PCLoaderOSM.h:196
SUMOReal layer
The layer to use.
Definition: PCTypeMap.h:74
Relations & myRelations
the loaded relations
Definition: PCLoaderOSM.h:259
long long int id
The node&#39;s id.
Definition: PCLoaderOSM.h:80
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()
Definition: PCLoaderOSM.cpp:69
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&#39;s ok.
Definition: XMLSubSys.cpp:114
NodesHandler(std::map< long long int, PCOSMNode *> &toFill, bool withAttributes, MsgHandler &errorHandler)
Contructor.
SUMOReal lon
The longitude the node is located at.
Definition: PCLoaderOSM.h:82
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)
Definition: MsgHandler.h:200
bool discard
Information whether polygons of this type shall be discarded.
Definition: PCTypeMap.h:76
A storage for loaded polygons and pois.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
MsgHandler & myErrorHandler
The handler to report errors to (will be the WarningsHandler if –ignore-errors was set) ...
Definition: PCLoaderOSM.h:343
RGBColor color
The color to use.
Definition: PCTypeMap.h:70
std::map< long long int, PCOSMEdge * > EdgeMap
Definition: PCLoaderOSM.h:119
long long int id
The edge&#39;s id.
Definition: PCLoaderOSM.h:106
A 2D- or 3D-polygon.
Definition: Polygon.h:57
A class which extracts relevant way-ids from relations in a parsed OSM-file.
Definition: PCLoaderOSM.h:211
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
Definition: PCLoaderOSM.h:132
std::map< std::string, std::string > myAttributes
Additional attributes.
Definition: PCLoaderOSM.h:114
A storage for type mappings.
Definition: PCTypeMap.h:52
const TypeDef & get(const std::string &id)
Returns a type definition.
Definition: PCTypeMap.cpp:79
PCOSMEdge * myCurrentEdge
The currently built edge.
Definition: PCLoaderOSM.h:355
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) ...
Definition: PCLoaderOSM.h:187
void myEndElement(int element)
Called when a closing tag occurs.
std::string name
The relation&#39;s name (if any)
Definition: PCLoaderOSM.h:96
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.
Definition: Position.h:46
A list of positions.
std::map< std::string, std::string > myAttributes
Additional attributes.
Definition: PCLoaderOSM.h:86
bool has(const std::string &id)
Returns the information whether the named type is known.
Definition: PCTypeMap.cpp:85
bool myIsClosed
Information whether this area is closed.
Definition: PCLoaderOSM.h:110
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)
Definition: MsgHandler.h:202
MsgHandler & myErrorHandler
The handler to report errors to (will be the WarningsHandler if –ignore-errors was set) ...
Definition: PCLoaderOSM.h:265
A class which extracts OSM-edges from a parsed OSM-file.
Definition: PCLoaderOSM.h:293
std::map< long long int, PCOSMRelation * > RelationsMap
Definition: PCLoaderOSM.h:118
long long int id
The relation&#39;s id.
Definition: PCLoaderOSM.h:94
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
bool myKeep
whether the last edge (way) should be kept because it had a key from the inclusion list ...
Definition: PCLoaderOSM.h:361
bool add(SUMO::Polygon *poly, bool ignorePruning=false)
Adds a polygon to the storage.
std::vector< int > myParentElements
Current path in order to know to what occuring values belong.
Definition: PCLoaderOSM.h:358
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.
Definition: PCLoaderOSM.h:143
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
void addParameter(const std::string &key, const std::string &value)
Adds a parameter.
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.
Definition: PCTypeMap.h:72
std::vector< long long int > myParentElements
Current path in order to know to what occuring values belong.
Definition: PCLoaderOSM.h:274
std::vector< int > myParentElements
Current path in order to know to what occuring values belong.
Definition: PCLoaderOSM.h:193
std::vector< PCOSMRelation * > Relations
Definition: PCLoaderOSM.h:117
std::vector< long long int > myCurrentNodes
The list of nodes this edge is made of.
Definition: PCLoaderOSM.h:112
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.
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:89
A storage for options typed value containers)
Definition: OptionsCont.h:99
std::string name
The edge&#39;s name (if any)
Definition: PCLoaderOSM.h:108
const TypeDef & getDefault()
get the default type according to the given options
Definition: PCTypeMap.h:115
bool myWithAttributes
Whether all attributes shall be stored.
Definition: PCLoaderOSM.h:262
#define SUMOReal
Definition: config.h:213
void push_back_noDoublePos(const Position &p)
insert in back a non double position
A point-of-interest.
bool myWithAttributes
Whether all attributes shall be stored.
Definition: PCLoaderOSM.h:184
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:203
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.
Definition: PCLoaderOSM.h:346
std::map< long long int, PCOSMNode * > & myToFill
The nodes container to fill.
Definition: PCLoaderOSM.h:190
const RelationsMap & myAdditionalWays
additional ways which are reference by relations
Definition: PCLoaderOSM.h:352
bool allowFill
Information whether polygons of this type can be filled.
Definition: PCTypeMap.h:78
An internal representation of an OSM-node.
Definition: PCLoaderOSM.h:78