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