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-2017 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 // static members
56 // ---------------------------------------------------------------------------
58 
59 // ===========================================================================
60 // method definitions
61 // ===========================================================================
62 // ---------------------------------------------------------------------------
63 // static interface
64 // ---------------------------------------------------------------------------
65 std::set<std::string> PCLoaderOSM::initMyKeysToInclude() {
66  std::set<std::string> result;
67  result.insert("highway");
68  result.insert("waterway");
69  result.insert("aeroway");
70  result.insert("aerialway");
71  result.insert("power");
72  result.insert("man_made");
73  result.insert("building");
74  result.insert("leisure");
75  result.insert("amenity");
76  result.insert("shop");
77  result.insert("tourism");
78  result.insert("historic");
79  result.insert("landuse");
80  result.insert("natural");
81  result.insert("military");
82  result.insert("boundary");
83  result.insert("admin_level");
84  result.insert("sport");
85  result.insert("polygon");
86  result.insert("place");
87  result.insert("population");
88  result.insert("openGeoDB:population");
89  result.insert("openGeoDB:name");
90  return result;
91 }
92 
93 void
95  PCTypeMap& tm) {
96  if (!oc.isSet("osm-files")) {
97  return;
98  }
99  // parse file(s)
100  std::vector<std::string> files = oc.getStringVector("osm-files");
101  // load nodes, first
102  std::map<long long int, PCOSMNode*> nodes;
103  bool withAttributes = oc.getBool("all-attributes");
105  NodesHandler nodesHandler(nodes, withAttributes, *m);
106  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
107  // nodes
108  if (!FileHelpers::isReadable(*file)) {
109  WRITE_ERROR("Could not open osm-file '" + *file + "'.");
110  return;
111  }
112  PROGRESS_BEGIN_MESSAGE("Parsing nodes from osm-file '" + *file + "'");
113  if (!XMLSubSys::runParser(nodesHandler, *file)) {
114  for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
115  delete(*i).second;
116  }
117  throw ProcessError();
118  }
120  }
121  // load relations to see which additional ways may be relevant
122  Relations relations;
123  RelationsMap additionalWays;
124  RelationsHandler relationsHandler(additionalWays, relations, withAttributes, *m);
125  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
126  // edges
127  PROGRESS_BEGIN_MESSAGE("Parsing relations from osm-file '" + *file + "'");
128  XMLSubSys::runParser(relationsHandler, *file);
130  }
131 
132  // load ways
133  EdgeMap edges;
134  EdgesHandler edgesHandler(nodes, edges, additionalWays, withAttributes, *m);
135  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
136  // edges
137  PROGRESS_BEGIN_MESSAGE("Parsing edges from osm-file '" + *file + "'");
138  XMLSubSys::runParser(edgesHandler, *file);
140  }
141 
142  // build all
143  const bool useName = oc.getBool("osm.use-name");
144  // instatiate polygons
145  for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
146  PCOSMEdge* e = (*i).second;
147  if (e->myAttributes.size() == 0) {
148  // cannot be relevant as a polygon
149  continue;
150  }
151  if (e->myCurrentNodes.size() == 0) {
152  WRITE_ERROR("Polygon '" + toString(e->id) + "' has no shape.");
153  continue;
154  }
155  // compute shape
156  PositionVector vec;
157  for (std::vector<long long int>::iterator j = e->myCurrentNodes.begin(); j != e->myCurrentNodes.end(); ++j) {
158  PCOSMNode* n = nodes.find(*j)->second;
159  Position pos(n->lon, n->lat);
160  if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
161  WRITE_WARNING("Unable to project coordinates for polygon '" + toString(e->id) + "'.");
162  }
163  vec.push_back_noDoublePos(pos);
164  }
165  const bool ignorePruning = OptionsCont::getOptions().isInStringVector("prune.keep-list", toString(e->id));
166  // add as many polygons as keys match defined types
167  int index = 0;
168  std::string unknownPolyType = "";
169  for (std::map<std::string, std::string>::iterator it = e->myAttributes.begin(); it != e->myAttributes.end(); ++it) {
170  const std::string& key = it->first;
171  const std::string& value = it->second;
172  const std::string fullType = key + "." + value;
173  if (tm.has(key + "." + value)) {
174  index = addPolygon(e, vec, tm.get(fullType), fullType, index, useName, toFill, ignorePruning, withAttributes);
175  } else if (tm.has(key)) {
176  index = addPolygon(e, vec, tm.get(key), fullType, index, useName, toFill, ignorePruning, withAttributes);
177  } else if (MyKeysToInclude.count(key) > 0) {
178  unknownPolyType = fullType;
179  }
180  }
181  const PCTypeMap::TypeDef& def = tm.getDefault();
182  if (index == 0 && !def.discard && unknownPolyType != "") {
183  addPolygon(e, vec, def, unknownPolyType, index, useName, toFill, ignorePruning, withAttributes);
184  }
185  }
186 
187 
188  // instantiate pois
189  for (std::map<long long int, PCOSMNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i) {
190  PCOSMNode* n = (*i).second;
191  if (n->myAttributes.size() == 0) {
192  // cannot be relevant as a poi
193  continue;
194  }
195  Position pos(n->lon, n->lat);
196  if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
197  WRITE_WARNING("Unable to project coordinates for POI '" + toString(n->id) + "'.");
198  }
199  const bool ignorePruning = OptionsCont::getOptions().isInStringVector("prune.keep-list", toString(n->id));
200  // add as many POIs as keys match defined types
201  int index = 0;
202  std::string unKnownPOIType = "";
203  for (std::map<std::string, std::string>::iterator it = n->myAttributes.begin(); it != n->myAttributes.end(); ++it) {
204  const std::string& key = it->first;
205  const std::string& value = it->second;
206  const std::string fullType = key + "." + value;
207  if (tm.has(key + "." + value)) {
208  index = addPOI(n, pos, tm.get(fullType), fullType, index, toFill, ignorePruning, withAttributes);
209  } else if (tm.has(key)) {
210  index = addPOI(n, pos, tm.get(key), fullType, index, toFill, ignorePruning, withAttributes);
211  } else if (MyKeysToInclude.count(key) > 0) {
212  unKnownPOIType = fullType;
213  }
214  }
215  const PCTypeMap::TypeDef& def = tm.getDefault();
216  if (index == 0 && !def.discard && unKnownPOIType != "") {
217  addPOI(n, pos, def, unKnownPOIType, index, toFill, ignorePruning, withAttributes);
218  }
219  }
220  // delete nodes
221  for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
222  delete(*i).second;
223  }
224  // delete edges
225  for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
226  delete(*i).second;
227  }
228  // delete relations
229  for (Relations::iterator i = relations.begin(); i != relations.end(); ++i) {
230  delete(*i);
231  }
232 }
233 
234 
235 int
236 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) {
237  if (def.discard) {
238  return index;
239  } else {
240  const bool closedShape = vec.front() == vec.back();
241  const std::string idSuffix = (index == 0 ? "" : "#" + toString(index));
242  const std::string id = def.prefix + (useName && edge->name != "" ? edge->name : toString(edge->id)) + idSuffix;
243  SUMO::Polygon* poly = new SUMO::Polygon(
245  StringUtils::escapeXML(OptionsCont::getOptions().getBool("osm.keep-full-type") ? fullType : def.id),
246  def.color, vec, def.allowFill && closedShape, (double)def.layer);
247  if (withAttributes) {
248  poly->addParameter(edge->myAttributes);
249  }
250  if (!toFill.add(poly, ignorePruning)) {
251  return index;
252  } else {
253  return index + 1;
254  }
255  }
256 }
257 
258 int
259 PCLoaderOSM::addPOI(const PCOSMNode* node, const Position& pos, const PCTypeMap::TypeDef& def, const std::string& fullType,
260  int index, PCPolyContainer& toFill, bool ignorePruning, bool withAttributes) {
261  if (def.discard) {
262  return index;
263  } else {
264  const std::string idSuffix = (index == 0 ? "" : "#" + toString(index));
265  const std::string id = def.prefix + toString(node->id) + idSuffix;
266  PointOfInterest* poi = new PointOfInterest(
268  StringUtils::escapeXML(OptionsCont::getOptions().getBool("osm.keep-full-type") ? fullType : def.id),
269  def.color, pos, (double)def.layer);
270  if (withAttributes) {
271  poi->addParameter(node->myAttributes);
272  }
273  if (!toFill.add(poi, ignorePruning)) {
274  return index;
275  } else {
276  return index + 1;
277  }
278  }
279 }
280 
281 
282 // ---------------------------------------------------------------------------
283 // definitions of PCLoaderOSM::NodesHandler-methods
284 // ---------------------------------------------------------------------------
285 PCLoaderOSM::NodesHandler::NodesHandler(std::map<long long int, PCOSMNode*>& toFill,
286  bool withAttributes, MsgHandler& errorHandler) :
287  SUMOSAXHandler("osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
288  myToFill(toFill), myLastNodeID(-1) {}
289 
290 
292 
293 
294 void
296  myParentElements.push_back(element);
297  if (element == SUMO_TAG_NODE) {
298  bool ok = true;
299  long long int id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
300  if (!ok) {
301  return;
302  }
303  myLastNodeID = -1;
304  if (myToFill.find(id) == myToFill.end()) {
305  myLastNodeID = id;
306  // assume we are loading multiple files...
307  // ... so we won't report duplicate nodes
308  PCOSMNode* toAdd = new PCOSMNode();
309  toAdd->id = id;
310  bool ok = true;
311  toAdd->lon = attrs.get<double>(SUMO_ATTR_LON, toString(id).c_str(), ok);
312  toAdd->lat = attrs.get<double>(SUMO_ATTR_LAT, toString(id).c_str(), ok);
313  if (!ok) {
314  delete toAdd;
315  return;
316  }
317  myToFill[toAdd->id] = toAdd;
318  }
319  }
320  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_NODE
321  && myLastNodeID != -1) {
322  bool ok = true;
323  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myLastNodeID).c_str(), ok, "", false);
324  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myLastNodeID).c_str(), ok, "", false);
325  if (key == "") {
326  myErrorHandler.inform("Empty key in a a tag while parsing node '" + toString(myLastNodeID) + "' occured.");
327  ok = false;
328  }
329  if (!ok) {
330  return;
331  }
332  myToFill[myLastNodeID]->myAttributes[key] = value;
333  }
334 }
335 
336 
337 void
339  if (element == SUMO_TAG_NODE) {
340  myLastNodeID = -1;
341  }
342  myParentElements.pop_back();
343 }
344 
345 
346 // ---------------------------------------------------------------------------
347 // definitions of PCLoaderOSM::RelationsHandler-methods
348 // ---------------------------------------------------------------------------
350  Relations& relations,
351  bool withAttributes,
352  MsgHandler& errorHandler) :
353  SUMOSAXHandler("osm - file"),
354  myAdditionalWays(additionalWays),
355  myRelations(relations),
356  myWithAttributes(withAttributes),
357  myErrorHandler(errorHandler),
358  myCurrentRelation(0) {
359 }
360 
361 
363 }
364 
365 
366 void
368  myParentElements.push_back(element);
369  // parse "relation" elements
370  if (element == SUMO_TAG_RELATION) {
371  bool ok = true;
372  myCurrentWays.clear();
373  std::string action = attrs.hasAttribute("action") ? attrs.getStringSecure("action", "") : "";
374  if (action == "delete" || !ok) {
375  myCurrentRelation = 0;
376  }
378  myCurrentRelation->id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
379  myRelations.push_back(myCurrentRelation);
380  return;
381  } else if (myCurrentRelation == 0) {
382  return;
383  }
384  // parse member elements
385  if (element == SUMO_TAG_MEMBER) {
386  bool ok = true;
387  std::string role = attrs.hasAttribute("role") ? attrs.getStringSecure("role", "") : "";
388  long long int ref = attrs.get<long long int>(SUMO_ATTR_REF, 0, ok);
389  if (role == "outer" || role == "inner") {
390  std::string memberType = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
391  if (memberType == "way") {
392  myCurrentWays.push_back(ref);
393  }
394  }
395  return;
396  }
397  // parse values
398  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_RELATION
399  && myCurrentRelation != 0) {
400  bool ok = true;
401  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myCurrentRelation).c_str(), ok, "", false);
402  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myCurrentRelation).c_str(), ok, "", false);
403  if (key == "") {
404  myErrorHandler.inform("Empty key in a a tag while parsing way '" + toString(myCurrentRelation) + "' occured.");
405  ok = false;
406  }
407  if (!ok) {
408  return;
409  }
410  if (key == "name") {
411  myCurrentRelation->name = value;
412  } else if (MyKeysToInclude.count(key) > 0) {
413  for (std::vector<long long int>::iterator it = myCurrentWays.begin(); it != myCurrentWays.end(); ++it) {
415  }
416  }
417  myCurrentRelation->myAttributes[key] = value;
418  }
419 }
420 
421 
422 void
424  myParentElements.pop_back();
425  if (element == SUMO_TAG_RELATION) {
426  myCurrentRelation = 0;
427  myCurrentWays.clear();
428  }
429 }
430 
431 
432 // ---------------------------------------------------------------------------
433 // definitions of PCLoaderOSM::EdgesHandler-methods
434 // ---------------------------------------------------------------------------
435 PCLoaderOSM::EdgesHandler::EdgesHandler(const std::map<long long int, PCOSMNode*>& osmNodes,
436  EdgeMap& toFill,
437  const RelationsMap& additionalWays,
438  bool withAttributes, MsgHandler& errorHandler) :
439  SUMOSAXHandler("osm - file"),
440  myWithAttributes(withAttributes),
441  myErrorHandler(errorHandler),
442  myOSMNodes(osmNodes),
443  myEdgeMap(toFill),
444  myAdditionalWays(additionalWays) {
445 }
446 
447 
449 }
450 
451 
452 void
454  myParentElements.push_back(element);
455  // parse "way" elements
456  if (element == SUMO_TAG_WAY) {
457  bool ok = true;
458  long long int id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
459  if (!ok) {
460  return;
461  }
462  myCurrentEdge = new PCOSMEdge();
463  myCurrentEdge->id = id;
464  myCurrentEdge->myIsClosed = false;
465  myKeep = (myAdditionalWays.find(id) != myAdditionalWays.end());
466  }
467  // parse "nd" (node) elements
468  if (element == SUMO_TAG_ND) {
469  bool ok = true;
470  long long int ref = attrs.get<long long int>(SUMO_ATTR_REF, 0, ok);
471  if (ok) {
472  if (myOSMNodes.find(ref) == myOSMNodes.end()) {
473  WRITE_WARNING("The referenced geometry information (ref='" + toString(ref) + "') is not known");
474  return;
475  }
476  myCurrentEdge->myCurrentNodes.push_back(ref);
477  }
478  }
479  // parse values
480  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_WAY
481  && myCurrentEdge != 0) {
482  bool ok = true;
483  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myCurrentEdge->id).c_str(), ok, "", false);
484  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myCurrentEdge->id).c_str(), ok, "", false);
485  if (key == "") {
486  myErrorHandler.inform("Empty key in a a tag while parsing way '" + toString(myCurrentEdge->id) + "' occured.");
487  ok = false;
488  }
489  if (!ok) {
490  return;
491  }
492  if (key == "name") {
493  myCurrentEdge->name = value;
494  } else if (MyKeysToInclude.count(key) > 0) {
495  myKeep = true;
496  }
497  myCurrentEdge->myAttributes[key] = value;
498  }
499 }
500 
501 
502 void
504  myParentElements.pop_back();
505  if (element == SUMO_TAG_WAY) {
506  if (myKeep) {
507  RelationsMap::const_iterator it = myAdditionalWays.find(myCurrentEdge->id);
508  if (it != myAdditionalWays.end()) {
509  myCurrentEdge->myAttributes.insert((*it).second->myAttributes.begin(), (*it).second->myAttributes.end());
510  }
512  } else {
513  delete myCurrentEdge;
514  }
515  myCurrentEdge = 0;
516  }
517 }
518 
519 
520 /****************************************************************************/
521 
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:67
std::map< std::string, std::string > myAttributes
Additional attributes.
Definition: PCLoaderOSM.h:98
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:76
static void loadIfSet(OptionsCont &oc, PCPolyContainer &toFill, PCTypeMap &tm)
Loads pois/polygons assumed to be stored as OSM-XML.
Definition: PCLoaderOSM.cpp:94
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:54
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
std::vector< long long int > myCurrentWays
the ways within the current relation
Definition: PCLoaderOSM.h:271
double layer
The layer to use.
Definition: PCTypeMap.h:74
long long int myLastNodeID
The id of the last parsed node.
Definition: PCLoaderOSM.h:196
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:65
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:110
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: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:65
MsgHandler & myErrorHandler
The handler to report errors to (will be the WarningsHandler if –ignore-errors was set) ...
Definition: PCLoaderOSM.h:343
double lon
The longitude the node is located at.
Definition: PCLoaderOSM.h:82
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
double lat
The latitude the node is located at.
Definition: PCLoaderOSM.h:84
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:75
PCOSMEdge * myCurrentEdge
The currently built edge.
Definition: PCLoaderOSM.h:355
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
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:81
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
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: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.
alternative definition for junction
void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:85
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
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