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  throw ProcessError();
119  }
121  }
122  // load relations to see which additional ways may be relevant
123  Relations relations;
124  RelationsMap additionalWays;
125  RelationsHandler relationsHandler(additionalWays, relations, withAttributes, *m);
126  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
127  // edges
128  PROGRESS_BEGIN_MESSAGE("Parsing relations from osm-file '" + *file + "'");
129  XMLSubSys::runParser(relationsHandler, *file);
131  }
132 
133  // load ways
134  EdgeMap edges;
135  EdgesHandler edgesHandler(nodes, edges, additionalWays, withAttributes, *m);
136  for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
137  // edges
138  PROGRESS_BEGIN_MESSAGE("Parsing edges from osm-file '" + *file + "'");
139  XMLSubSys::runParser(edgesHandler, *file);
141  }
142 
143  // build all
144  const bool useName = oc.getBool("osm.use-name");
145  // instatiate polygons
146  for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
147  PCOSMEdge* e = (*i).second;
148  if (e->myAttributes.size() == 0) {
149  // cannot be relevant as a polygon
150  continue;
151  }
152  if (e->myCurrentNodes.size() == 0) {
153  WRITE_ERROR("Polygon '" + toString(e->id) + "' has no shape.");
154  continue;
155  }
156  // compute shape
157  PositionVector vec;
158  for (std::vector<long long int>::iterator j = e->myCurrentNodes.begin(); j != e->myCurrentNodes.end(); ++j) {
159  PCOSMNode* n = nodes.find(*j)->second;
160  Position pos(n->lon, n->lat);
161  if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
162  WRITE_WARNING("Unable to project coordinates for polygon '" + toString(e->id) + "'.");
163  }
164  vec.push_back_noDoublePos(pos);
165  }
166  const bool ignorePruning = OptionsCont::getOptions().isInStringVector("prune.keep-list", toString(e->id));
167  // add as many polygons as keys match defined types
168  int index = 0;
169  std::string unknownPolyType = "";
170  for (std::map<std::string, std::string>::iterator it = e->myAttributes.begin(); it != e->myAttributes.end(); ++it) {
171  const std::string& key = it->first;
172  const std::string& value = it->second;
173  const std::string fullType = key + "." + value;
174  if (tm.has(key + "." + value)) {
175  index = addPolygon(e, vec, tm.get(fullType), fullType, index, useName, toFill, ignorePruning, withAttributes);
176  } else if (tm.has(key)) {
177  index = addPolygon(e, vec, tm.get(key), fullType, index, useName, toFill, ignorePruning, withAttributes);
178  } else if (MyKeysToInclude.count(key) > 0) {
179  unknownPolyType = fullType;
180  }
181  }
182  const PCTypeMap::TypeDef& def = tm.getDefault();
183  if (index == 0 && !def.discard && unknownPolyType != "") {
184  addPolygon(e, vec, def, unknownPolyType, index, useName, toFill, ignorePruning, withAttributes);
185  }
186  }
187 
188 
189  // instantiate pois
190  for (std::map<long long int, PCOSMNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i) {
191  PCOSMNode* n = (*i).second;
192  if (n->myAttributes.size() == 0) {
193  // cannot be relevant as a poi
194  continue;
195  }
196  Position pos(n->lon, n->lat);
197  if (!GeoConvHelper::getProcessing().x2cartesian(pos)) {
198  WRITE_WARNING("Unable to project coordinates for POI '" + toString(n->id) + "'.");
199  }
200  const bool ignorePruning = OptionsCont::getOptions().isInStringVector("prune.keep-list", toString(n->id));
201  // add as many POIs as keys match defined types
202  int index = 0;
203  std::string unKnownPOIType = "";
204  for (std::map<std::string, std::string>::iterator it = n->myAttributes.begin(); it != n->myAttributes.end(); ++it) {
205  const std::string& key = it->first;
206  const std::string& value = it->second;
207  const std::string fullType = key + "." + value;
208  if (tm.has(key + "." + value)) {
209  index = addPOI(n, pos, tm.get(fullType), fullType, index, toFill, ignorePruning, withAttributes);
210  } else if (tm.has(key)) {
211  index = addPOI(n, pos, tm.get(key), fullType, index, toFill, ignorePruning, withAttributes);
212  } else if (MyKeysToInclude.count(key) > 0) {
213  unKnownPOIType = fullType;
214  }
215  }
216  const PCTypeMap::TypeDef& def = tm.getDefault();
217  if (index == 0 && !def.discard && unKnownPOIType != "") {
218  addPOI(n, pos, def, unKnownPOIType, index, toFill, ignorePruning, withAttributes);
219  }
220  }
221  // delete nodes
222  for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
223  delete(*i).second;
224  }
225  // delete edges
226  for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
227  delete(*i).second;
228  }
229  // delete relations
230  for (Relations::iterator i = relations.begin(); i != relations.end(); ++i) {
231  delete(*i);
232  }
233 }
234 
235 
236 int
237 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) {
238  if (def.discard) {
239  return index;
240  } else {
241  const bool closedShape = vec.front() == vec.back();
242  const std::string idSuffix = (index == 0 ? "" : "#" + toString(index));
243  const std::string id = def.prefix + (useName && edge->name != "" ? edge->name : toString(edge->id)) + idSuffix;
244  Polygon* poly = new Polygon(
246  StringUtils::escapeXML(OptionsCont::getOptions().getBool("osm.keep-full-type") ? fullType : def.id),
247  def.color, vec, def.allowFill && closedShape, (SUMOReal)def.layer);
248  if (withAttributes) {
249  poly->addParameter(edge->myAttributes);
250  }
251  if (!toFill.insert(id, poly, def.layer, ignorePruning)) {
252  return index;
253  } else {
254  return index + 1;
255  }
256  }
257 }
258 
259 int
260 PCLoaderOSM::addPOI(const PCOSMNode* node, const Position& pos, const PCTypeMap::TypeDef& def, const std::string& fullType,
261  int index, PCPolyContainer& toFill, bool ignorePruning, bool withAttributes) {
262  if (def.discard) {
263  return index;
264  } else {
265  const std::string idSuffix = (index == 0 ? "" : "#" + toString(index));
266  const std::string id = def.prefix + toString(node->id) + idSuffix;
267  PointOfInterest* poi = new PointOfInterest(
269  StringUtils::escapeXML(OptionsCont::getOptions().getBool("osm.keep-full-type") ? fullType : def.id),
270  def.color, pos, (SUMOReal)def.layer);
271  if (withAttributes) {
272  poi->addParameter(node->myAttributes);
273  }
274  if (!toFill.insert(id, poi, def.layer, ignorePruning)) {
275  return index;
276  } else {
277  return index + 1;
278  }
279  }
280 }
281 
282 
283 // ---------------------------------------------------------------------------
284 // definitions of PCLoaderOSM::NodesHandler-methods
285 // ---------------------------------------------------------------------------
286 PCLoaderOSM::NodesHandler::NodesHandler(std::map<long long int, PCOSMNode*>& toFill,
287  bool withAttributes, MsgHandler& errorHandler) :
288  SUMOSAXHandler("osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
289  myToFill(toFill), myLastNodeID(-1) {}
290 
291 
293 
294 
295 void
297  myParentElements.push_back(element);
298  if (element == SUMO_TAG_NODE) {
299  bool ok = true;
300  long long int id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
301  if (!ok) {
302  return;
303  }
304  myLastNodeID = -1;
305  if (myToFill.find(id) == myToFill.end()) {
306  myLastNodeID = id;
307  // assume we are loading multiple files...
308  // ... so we won't report duplicate nodes
309  PCOSMNode* toAdd = new PCOSMNode();
310  toAdd->id = id;
311  bool ok = true;
312  toAdd->lon = attrs.get<SUMOReal>(SUMO_ATTR_LON, toString(id).c_str(), ok);
313  toAdd->lat = attrs.get<SUMOReal>(SUMO_ATTR_LAT, toString(id).c_str(), ok);
314  if (!ok) {
315  delete toAdd;
316  return;
317  }
318  myToFill[toAdd->id] = toAdd;
319  }
320  }
321  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_NODE
322  && myLastNodeID != -1) {
323  bool ok = true;
324  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myLastNodeID).c_str(), ok, "", false);
325  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myLastNodeID).c_str(), ok, "", false);
326  if (key == "") {
327  myErrorHandler.inform("Empty key in a a tag while parsing node '" + toString(myLastNodeID) + "' occured.");
328  ok = false;
329  }
330  if (!ok) {
331  return;
332  }
333  myToFill[myLastNodeID]->myAttributes[key] = value;
334  }
335 }
336 
337 
338 void
340  if (element == SUMO_TAG_NODE) {
341  myLastNodeID = -1;
342  }
343  myParentElements.pop_back();
344 }
345 
346 
347 // ---------------------------------------------------------------------------
348 // definitions of PCLoaderOSM::RelationsHandler-methods
349 // ---------------------------------------------------------------------------
351  Relations& relations,
352  bool withAttributes,
353  MsgHandler& errorHandler) :
354  SUMOSAXHandler("osm - file"),
355  myAdditionalWays(additionalWays),
356  myRelations(relations),
357  myWithAttributes(withAttributes),
358  myErrorHandler(errorHandler),
359  myCurrentRelation(0) {
360 }
361 
362 
364 }
365 
366 
367 void
369  myParentElements.push_back(element);
370  // parse "relation" elements
371  if (element == SUMO_TAG_RELATION) {
372  bool ok = true;
373  myCurrentWays.clear();
374  std::string action = attrs.hasAttribute("action") ? attrs.getStringSecure("action", "") : "";
375  if (action == "delete" || !ok) {
376  myCurrentRelation = 0;
377  }
379  myCurrentRelation->id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
380  myRelations.push_back(myCurrentRelation);
381  return;
382  } else if (myCurrentRelation == 0) {
383  return;
384  }
385  // parse member elements
386  if (element == SUMO_TAG_MEMBER) {
387  bool ok = true;
388  std::string role = attrs.hasAttribute("role") ? attrs.getStringSecure("role", "") : "";
389  long long int ref = attrs.get<long long int>(SUMO_ATTR_REF, 0, ok);
390  if (role == "outer" || role == "inner") {
391  std::string memberType = attrs.get<std::string>(SUMO_ATTR_TYPE, 0, ok);
392  if (memberType == "way") {
393  myCurrentWays.push_back(ref);
394  }
395  }
396  return;
397  }
398  // parse values
399  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_RELATION
400  && myCurrentRelation != 0) {
401  bool ok = true;
402  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myCurrentRelation).c_str(), ok, "", false);
403  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myCurrentRelation).c_str(), ok, "", false);
404  if (key == "") {
405  myErrorHandler.inform("Empty key in a a tag while parsing way '" + toString(myCurrentRelation) + "' occured.");
406  ok = false;
407  }
408  if (!ok) {
409  return;
410  }
411  if (key == "name") {
412  myCurrentRelation->name = value;
413  } else if (MyKeysToInclude.count(key) > 0) {
414  for (std::vector<long long int>::iterator it = myCurrentWays.begin(); it != myCurrentWays.end(); ++it) {
416  }
417  }
418  myCurrentRelation->myAttributes[key] = value;
419  }
420 }
421 
422 
423 void
425  myParentElements.pop_back();
426  if (element == SUMO_TAG_RELATION) {
427  myCurrentRelation = 0;
428  myCurrentWays.clear();
429  }
430 }
431 
432 
433 // ---------------------------------------------------------------------------
434 // definitions of PCLoaderOSM::EdgesHandler-methods
435 // ---------------------------------------------------------------------------
436 PCLoaderOSM::EdgesHandler::EdgesHandler(const std::map<long long int, PCOSMNode*>& osmNodes,
437  EdgeMap& toFill,
438  const RelationsMap& additionalWays,
439  bool withAttributes, MsgHandler& errorHandler) :
440  SUMOSAXHandler("osm - file"),
441  myWithAttributes(withAttributes),
442  myErrorHandler(errorHandler),
443  myOSMNodes(osmNodes),
444  myEdgeMap(toFill),
445  myAdditionalWays(additionalWays) {
446 }
447 
448 
450 }
451 
452 
453 void
455  myParentElements.push_back(element);
456  // parse "way" elements
457  if (element == SUMO_TAG_WAY) {
458  bool ok = true;
459  long long int id = attrs.get<long long int>(SUMO_ATTR_ID, 0, ok);
460  if (!ok) {
461  return;
462  }
463  myCurrentEdge = new PCOSMEdge();
464  myCurrentEdge->id = id;
465  myCurrentEdge->myIsClosed = false;
466  myKeep = (myAdditionalWays.find(id) != myAdditionalWays.end());
467  }
468  // parse "nd" (node) elements
469  if (element == SUMO_TAG_ND) {
470  bool ok = true;
471  long long int ref = attrs.get<long long int>(SUMO_ATTR_REF, 0, ok);
472  if (ok) {
473  if (myOSMNodes.find(ref) == myOSMNodes.end()) {
474  WRITE_WARNING("The referenced geometry information (ref='" + toString(ref) + "') is not known");
475  return;
476  }
477  myCurrentEdge->myCurrentNodes.push_back(ref);
478  }
479  }
480  // parse values
481  if (element == SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] == SUMO_TAG_WAY
482  && myCurrentEdge != 0) {
483  bool ok = true;
484  std::string key = attrs.getOpt<std::string>(SUMO_ATTR_K, toString(myCurrentEdge->id).c_str(), ok, "", false);
485  std::string value = attrs.getOpt<std::string>(SUMO_ATTR_V, toString(myCurrentEdge->id).c_str(), ok, "", false);
486  if (key == "") {
487  myErrorHandler.inform("Empty key in a a tag while parsing way '" + toString(myCurrentEdge->id) + "' occured.");
488  ok = false;
489  }
490  if (!ok) {
491  return;
492  }
493  if (key == "name") {
494  myCurrentEdge->name = value;
495  } else if (MyKeysToInclude.count(key) > 0) {
496  myKeep = true;
497  }
498  myCurrentEdge->myAttributes[key] = value;
499  }
500 }
501 
502 
503 void
505  myParentElements.pop_back();
506  if (element == SUMO_TAG_WAY) {
507  if (myKeep) {
508  RelationsMap::const_iterator it = myAdditionalWays.find(myCurrentEdge->id);
509  if (it != myAdditionalWays.end()) {
510  myCurrentEdge->myAttributes.insert((*it).second->myAttributes.begin(), (*it).second->myAttributes.end());
511  }
513  } else {
514  delete myCurrentEdge;
515  }
516  myCurrentEdge = 0;
517  }
518 }
519 
520 
521 /****************************************************************************/
522 
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
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) ...
NodesHandler(std::map< long long int, PCOSMNode * > &toFill, bool withAttributes, MsgHandler &errorHandler)
Contructor.
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
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
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
bool insert(const std::string &id, Polygon *poly, int layer, bool ignorePruning=false)
Adds a polygon to the storage.
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;.
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
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:52
A class which extracts relevant way-ids from relations in a parsed OSM-file.
Definition: PCLoaderOSM.h:211
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.
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
#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:54
bool myKeep
whether the last edge (way) should be kept because it had a key from the inclusion list ...
Definition: PCLoaderOSM.h:361
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;.
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:108
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)
A point-of-interest.
int layer
The layer to use.
Definition: PCTypeMap.h:74
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.
bool myWithAttributes
Whether all attributes shall be stored.
Definition: PCLoaderOSM.h:184
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:203
const std::map< long long int, PCOSMNode * > & myOSMNodes
The previously parsed nodes.
Definition: PCLoaderOSM.h:346
EdgesHandler(const std::map< long long int, PCOSMNode * > &osmNodes, EdgeMap &toFill, const RelationsMap &additionalWays, bool withAttributes, MsgHandler &errorHandler)
Constructor.
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
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.