SUMO - Simulation of Urban MObility
NWWriter_DlrNavteq.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // Exporter writing networks using DlrNavteq (Elmar) format
17 /****************************************************************************/
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 #include <algorithm>
25 #include <ctime>
26 #include <cmath>
28 #include <netbuild/NBEdge.h>
29 #include <netbuild/NBEdgeCont.h>
30 #include <netbuild/NBNode.h>
31 #include <netbuild/NBNodeCont.h>
32 #include <netbuild/NBNetBuilder.h>
33 #include <utils/common/ToString.h>
40 #include "NWFrame.h"
41 #include "NWWriter_DlrNavteq.h"
42 
43 
44 // ---------------------------------------------------------------------------
45 // static members
46 // ---------------------------------------------------------------------------
47 const std::string NWWriter_DlrNavteq::UNDEFINED("-1");
48 
49 // ---------------------------------------------------------------------------
50 // static methods
51 // ---------------------------------------------------------------------------
52 void
54  // check whether a matsim-file shall be generated
55  if (!oc.isSet("dlr-navteq-output")) {
56  return;
57  }
58  std::map<NBEdge*, std::string> internalNodes;
59  writeNodesUnsplitted(oc, nb.getNodeCont(), nb.getEdgeCont(), internalNodes);
60  writeLinksUnsplitted(oc, nb.getEdgeCont(), internalNodes);
64 }
65 
66 
68  device << "# Format matches Extraction version: V6.5 \n";
69  std::stringstream tmp;
70  oc.writeConfiguration(tmp, true, false, false);
71  tmp.seekg(std::ios_base::beg);
72  std::string line;
73  while (!tmp.eof()) {
74  std::getline(tmp, line);
75  device << "# " << line << "\n";
76  }
77  device << "#\n";
78 }
79 
80 void
81 NWWriter_DlrNavteq::writeNodesUnsplitted(const OptionsCont& oc, NBNodeCont& nc, NBEdgeCont& ec, std::map<NBEdge*, std::string>& internalNodes) {
82  // For "real" nodes we simply use the node id.
83  // For internal nodes (geometry vectors describing edge geometry in the parlance of this format)
84  // we use the id of the edge and do not bother with
85  // compression (each direction gets its own internal node).
86  OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_nodes_unsplitted.txt");
87  writeHeader(device, oc);
89  const bool haveGeo = gch.usingGeoProjection();
90  const double geoScale = pow(10.0f, haveGeo ? 5 : 2); // see NIImporter_DlrNavteq::GEO_SCALE
91  device.setPrecision(oc.getInt("dlr-navteq.precision"));
92  if (!haveGeo) {
93  WRITE_WARNING("DlrNavteq node data will be written in (floating point) cartesian coordinates");
94  }
95  // write format specifier
96  device << "# NODE_ID\tIS_BETWEEN_NODE\tamount_of_geocoordinates\tx1\ty1\t[x2 y2 ... xn yn]\n";
97  // write header
98  Boundary boundary = gch.getConvBoundary();
99  Position min(boundary.xmin(), boundary.ymin());
100  Position max(boundary.xmax(), boundary.ymax());
101  gch.cartesian2geo(min);
102  min.mul(geoScale);
103  gch.cartesian2geo(max);
104  max.mul(geoScale);
105  int multinodes = 0;
106  for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
107  if ((*i).second->getGeometry().size() > 2) {
108  multinodes++;
109  }
110  }
111  device << "# [xmin_region] " << min.x() << "\n";
112  device << "# [xmax_region] " << max.x() << "\n";
113  device << "# [ymin_region] " << min.y() << "\n";
114  device << "# [ymax_region] " << max.y() << "\n";
115  device << "# [elements_multinode] " << multinodes << "\n";
116  device << "# [elements_normalnode] " << nc.size() << "\n";
117  device << "# [xmin] " << min.x() << "\n";
118  device << "# [xmax] " << max.x() << "\n";
119  device << "# [ymin] " << min.y() << "\n";
120  device << "# [ymax] " << max.y() << "\n";
121  // write normal nodes
122  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
123  NBNode* n = (*i).second;
124  Position pos = n->getPosition();
125  gch.cartesian2geo(pos);
126  pos.mul(geoScale);
127  device << n->getID() << "\t0\t1\t" << pos.x() << "\t" << pos.y() << "\n";
128  }
129  // write "internal" nodes
130  std::vector<std::string> avoid;
131  std::set<std::string> reservedNodeIDs;
132  const bool numericalIDs = oc.getBool("numerical-ids");
133  if (oc.isSet("reserved-ids")) {
134  NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "node:", reservedNodeIDs);
135  }
136  if (numericalIDs) {
137  avoid = nc.getAllNames();
138  std::vector<std::string> avoid2 = ec.getAllNames();
139  avoid.insert(avoid.end(), avoid2.begin(), avoid2.end());
140  avoid.insert(avoid.end(), reservedNodeIDs.begin(), reservedNodeIDs.end());
141  }
142  IDSupplier idSupplier("", avoid);
143  for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
144  NBEdge* e = (*i).second;
145  PositionVector geom = e->getGeometry();
146  if (geom.size() > 2) {
147  // the import NIImporter_DlrNavteq checks for the presence of a
148  // negated edge id to determine spread type. We may need to do some
149  // shifting to make this consistent
150  const bool hasOppositeID = ec.getOppositeByID(e->getID()) != nullptr;
151  if (e->getLaneSpreadFunction() == LANESPREAD_RIGHT && !hasOppositeID) {
152  // need to write center-line geometry instead
153  try {
154  geom.move2side(e->getTotalWidth() / 2);
155  } catch (InvalidArgument& exception) {
156  WRITE_WARNING("Could not reconstruct shape for edge:'" + e->getID() + "' (" + exception.what() + ").");
157  }
158  } else if (e->getLaneSpreadFunction() == LANESPREAD_CENTER && hasOppositeID) {
159  // need to write left-border geometry instead
160  try {
161  geom.move2side(-e->getTotalWidth() / 2);
162  } catch (InvalidArgument& exception) {
163  WRITE_WARNING("Could not reconstruct shape for edge:'" + e->getID() + "' (" + exception.what() + ").");
164  }
165  }
166 
167  std::string internalNodeID = e->getID();
168  if (internalNodeID == UNDEFINED
169  || (nc.retrieve(internalNodeID) != nullptr)
170  || reservedNodeIDs.count(internalNodeID) > 0
171  ) {
172  // need to invent a new name to avoid clashing with the id of a 'real' node or a reserved name
173  if (numericalIDs) {
174  internalNodeID = idSupplier.getNext();
175  } else {
176  internalNodeID += "_geometry";
177  }
178  }
179  internalNodes[e] = internalNodeID;
180  device << internalNodeID << "\t1\t" << geom.size() - 2;
181  for (int ii = 1; ii < (int)geom.size() - 1; ++ii) {
182  Position pos = geom[(int)ii];
183  gch.cartesian2geo(pos);
184  pos.mul(geoScale);
185  device << "\t" << pos.x() << "\t" << pos.y();
186  }
187  device << "\n";
188  }
189  }
190  device.close();
191 }
192 
193 
194 void
195 NWWriter_DlrNavteq::writeLinksUnsplitted(const OptionsCont& oc, NBEdgeCont& ec, std::map<NBEdge*, std::string>& internalNodes) {
196  std::map<const std::string, std::string> nameIDs;
197  OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_links_unsplitted.txt");
198  writeHeader(device, oc);
199  // write format specifier
200  device << "# LINK_ID\tNODE_ID_FROM\tNODE_ID_TO\tBETWEEN_NODE_ID\tLENGTH\tVEHICLE_TYPE\tFORM_OF_WAY\tBRUNNEL_TYPE\tFUNCTIONAL_ROAD_CLASS\tSPEED_CATEGORY\tNUMBER_OF_LANES\tSPEED_LIMIT\tSPEED_RESTRICTION\tNAME_ID1_REGIONAL\tNAME_ID2_LOCAL\tHOUSENUMBERS_RIGHT\tHOUSENUMBERS_LEFT\tZIP_CODE\tAREA_ID\tSUBAREA_ID\tTHROUGH_TRAFFIC\tSPECIAL_RESTRICTIONS\tEXTENDED_NUMBER_OF_LANES\tISRAMP\tCONNECTION\n";
201  // write edges
202  for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
203  NBEdge* e = (*i).second;
204  const int kph = speedInKph(e->getSpeed());
205  const std::string& betweenNodeID = (e->getGeometry().size() > 2) ? internalNodes[e] : UNDEFINED;
206  std::string nameID = UNDEFINED;
207  if (oc.getBool("output.street-names")) {
208  const std::string& name = i->second->getStreetName();
209  if (name != "" && nameIDs.count(name) == 0) {
210  nameID = toString(nameIDs.size());
211  nameIDs[name] = nameID;
212  }
213  }
214  device << e->getID() << "\t"
215  << e->getFromNode()->getID() << "\t"
216  << e->getToNode()->getID() << "\t"
217  << betweenNodeID << "\t"
218  << getGraphLength(e) << "\t"
219  << getAllowedTypes(e->getPermissions()) << "\t"
220  << getFormOfWay(e) << "\t"
221  << getBrunnelType(e) << "\t"
222  << getRoadClass(e) << "\t"
223  << getSpeedCategory(kph) << "\t"
224  << getNavteqLaneCode(e->getNumLanes()) << "\t"
225  << getSpeedCategoryUpperBound(kph) << "\t"
226  << kph << "\t"
227  << nameID << "\t" // NAME_ID1_REGIONAL XXX
228  << UNDEFINED << "\t" // NAME_ID2_LOCAL XXX
229  << UNDEFINED << "\t" // housenumbers_right
230  << UNDEFINED << "\t" // housenumbers_left
231  << getSinglePostalCode(e->getParameter("postal_code", UNDEFINED), e->getID()) << "\t" // ZIP_CODE
232  << UNDEFINED << "\t" // AREA_ID
233  << UNDEFINED << "\t" // SUBAREA_ID
234  << "1\t" // through_traffic (allowed)
235  << UNDEFINED << "\t" // special_restrictions
236  << UNDEFINED << "\t" // extended_number_of_lanes
237  << UNDEFINED << "\t" // isRamp
238  << "0\t" // connection (between nodes always in order)
239  << "\n";
240  }
241  if (oc.getBool("output.street-names")) {
242  OutputDevice& namesDevice = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_names.txt");
243  writeHeader(namesDevice, oc);
244  // write format specifier
245  namesDevice << "# NAME_ID\tPERMANENT_ID_INFO\tName\n";
246  namesDevice << "# [elements] " << nameIDs.size() << "\n";
247  for (std::map<const std::string, std::string>::const_iterator i = nameIDs.begin(); i != nameIDs.end(); ++i) {
248  namesDevice
249  << i->second << "\t"
250  << 0 << "\t"
251  << i->first << "\n";
252  }
253  namesDevice.close();
254  }
255  device.close();
256 }
257 
258 
259 std::string
261  if (permissions == SVCAll) {
262  return "100000000000";
263  }
264  std::ostringstream oss;
265  oss << "0";
266  oss << ((permissions & SVC_PASSENGER) > 0 ? 1 : 0);
267  oss << ((permissions & SVC_PASSENGER) > 0 ? 1 : 0); // residential
268  oss << ((permissions & SVC_HOV) > 0 ? 1 : 0);
269  oss << ((permissions & SVC_EMERGENCY) > 0 ? 1 : 0);
270  oss << ((permissions & SVC_TAXI) > 0 ? 1 : 0);
271  oss << ((permissions & (SVC_BUS | SVC_COACH)) > 0 ? 1 : 0);
272  oss << ((permissions & SVC_DELIVERY) > 0 ? 1 : 0);
273  oss << ((permissions & (SVC_TRUCK | SVC_TRAILER)) > 0 ? 1 : 0);
274  oss << ((permissions & SVC_MOTORCYCLE) > 0 ? 1 : 0);
275  oss << ((permissions & SVC_BICYCLE) > 0 ? 1 : 0);
276  oss << ((permissions & SVC_PEDESTRIAN) > 0 ? 1 : 0);
277  return oss.str();
278 }
279 
280 
281 int
283  // quoting the navteq manual:
284  // As a general rule, Functional Road Class assignments have no direct
285  // correlation with other road attributes like speed, controlled access, route type, etc.
286  // if the network is based on OSM, we can use the highway types for determining FRC
287  std::string type = edge->getTypeID();
288  if (StringUtils::startsWith(type, "highway.")) {
289  type = type.substr(8);
290  }
291  if (StringUtils::startsWith(type, "motorway")) {
292  return 0;
293  } else if (StringUtils::startsWith(type, "trunk")) {
294  return 1;
295  } else if (StringUtils::startsWith(type, "primary")) {
296  return 1;
297  } else if (StringUtils::startsWith(type, "secondary")) {
298  return 2;
299  } else if (StringUtils::startsWith(type, "tertiary")) {
300  return 3;
301  } else if (type == "unclassified") {
302  return 3;
303  } else if (type == "living_street" || type == "residential" || type == "road" || type == "service" || type == "track" || type == "cycleway" || type == "path" || type == "footway") {
304  return 4;
305  }
306  // as a fallback we do a simple speed / lane-count mapping anyway
307  // the resulting functional road class layers probably won't be connected as required
308  const int kph = speedInKph(edge->getSpeed());
309  if ((kph) > 100) {
310  return 0;
311  }
312  if ((kph) > 70) {
313  return 1;
314  }
315  if ((kph) > 50) {
316  return (edge->getNumLanes() > 1 ? 2 : 3);
317  }
318  if ((kph) > 30) {
319  return 3;
320  }
321  return 4;
322 }
323 
324 
325 int
327  if ((kph) > 130) {
328  return 1;
329  }
330  if ((kph) > 100) {
331  return 2;
332  }
333  if ((kph) > 90) {
334  return 3;
335  }
336  if ((kph) > 70) {
337  return 4;
338  }
339  if ((kph) > 50) {
340  return 5;
341  }
342  if ((kph) > 30) {
343  return 6;
344  }
345  if ((kph) > 10) {
346  return 7;
347  }
348  return 8;
349 }
350 
351 
352 int
354  if ((kph) > 130) {
355  return 131;
356  }
357  if ((kph) > 100) {
358  return 130;
359  }
360  if ((kph) > 90) {
361  return 100;
362  }
363  if ((kph) > 70) {
364  return 90;
365  }
366  if ((kph) > 50) {
367  return 70;
368  }
369  if ((kph) > 30) {
370  return 50;
371  }
372  if ((kph) > 10) {
373  return 30;
374  }
375  return 10;
376 }
377 
378 
379 int
381  const int code = (numLanes == 1 ? 1 :
382  (numLanes < 4 ? 2 : 3));
383  return numLanes * 10 + code;
384 }
385 
386 
387 int
389  if (edge->knowsParameter("bridge")) {
390  return 1;
391  } else if (edge->knowsParameter("tunnel")) {
392  return 4;
393  } else if (edge->getTypeID() == "route.ferry") {
394  return 10;
395  }
396  return -1; // UNDEFINED
397 }
398 
399 
400 int
402  if (edge->getPermissions() == SVC_PEDESTRIAN) {
403  return 15;
404  } else if (edge->getJunctionPriority(edge->getToNode()) == NBEdge::ROUNDABOUT) {
405  return 4;
406  } else if (edge->getTypeID() == "highway.service") {
407  return 14;
408  } else if (edge->getTypeID().find("_link") != std::string::npos) {
409  return 10;
410  }
411  return 3; // speed category 1-8;
412 }
413 
414 
415 double
417  PositionVector geom = edge->getGeometry();
420  return geom.length();
421 }
422 
423 
424 std::string
425 NWWriter_DlrNavteq::getSinglePostalCode(const std::string& zipCode, const std::string edgeID) {
426  // might be multiple codes
427  if (zipCode.find_first_of(" ,;") != std::string::npos) {
428  WRITE_WARNING("ambiguous zip code '" + zipCode + "' for edge '" + edgeID + "'. (using first value)");
429  StringTokenizer st(zipCode, " ,;", true);
430  std::vector<std::string> ret = st.getVector();
431  return ret[0];
432  } else if (zipCode.size() > 16) {
433  WRITE_WARNING("long zip code '" + zipCode + "' for edge '" + edgeID + "'");
434  }
435  return zipCode;
436 }
437 
438 void
440  OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_traffic_signals.txt");
441  writeHeader(device, oc);
442  const GeoConvHelper& gch = GeoConvHelper::getFinal();
443  const bool haveGeo = gch.usingGeoProjection();
444  const double geoScale = pow(10.0f, haveGeo ? 5 : 2); // see NIImporter_DlrNavteq::GEO_SCALE
445  device.setPrecision(oc.getInt("dlr-navteq.precision"));
446  // write format specifier
447  device << "#Traffic signal related to LINK_ID and NODE_ID with location relative to driving direction.\n#column format like pointcollection.\n#DESCRIPTION->LOCATION: 1-rechts von LINK; 2-links von LINK; 3-oberhalb LINK -1-keineAngabe\n#RELATREC_ID\tPOICOL_TYPE\tDESCRIPTION\tLONGITUDE\tLATITUDE\tLINK_ID\n";
448  // write record for every edge incoming to a tls controlled node
449  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
450  NBNode* n = (*i).second;
451  if (n->isTLControlled()) {
452  Position pos = n->getPosition();
453  gch.cartesian2geo(pos);
454  pos.mul(geoScale);
455  const EdgeVector& incoming = n->getIncomingEdges();
456  for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); ++it) {
457  NBEdge* e = *it;
458  device << e->getID() << "\t"
459  << "12\t" // POICOL_TYPE
460  << "LSA;NODEIDS#" << n->getID() << "#;LOCATION#-1#;\t"
461  << pos.x() << "\t"
462  << pos.y() << "\t"
463  << e->getID() << "\n";
464  }
465  }
466  }
467  device.close();
468 }
469 
470 
471 void
473  OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_prohibited_manoeuvres.txt");
474  writeHeader(device, oc);
475  // need to invent id for relation
476  std::set<std::string> reservedRelIDs;
477  if (oc.isSet("reserved-ids")) {
478  NBHelpers::loadPrefixedIDsFomFile(oc.getString("reserved-ids"), "rel:", reservedRelIDs);
479  }
480  std::vector<std::string> avoid = ec.getAllNames(); // already used for tls RELATREC_ID
481  avoid.insert(avoid.end(), reservedRelIDs.begin(), reservedRelIDs.end());
482  IDSupplier idSupplier("", avoid); // @note: use a global relRecIDsupplier if this is used more often
483  // write format specifier
484  device << "#No driving allowed from ID1 to ID2 or the complete chain from ID1 to IDn\n";
485  device << "#RELATREC_ID\tPERMANENT_ID_INFO\tVALIDITY_PERIOD\tTHROUGH_TRAFFIC\tVEHICLE_TYPE\tNAVTEQ_LINK_ID1\t[NAVTEQ_LINK_ID2 ...]\n";
486  // write record for every pair of incoming/outgoing edge that are not connected despite having common permissions
487  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
488  NBNode* n = (*i).second;
489  const EdgeVector& incoming = n->getIncomingEdges();
490  const EdgeVector& outgoing = n->getOutgoingEdges();
491  for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
492  NBEdge* inEdge = *j;
493  const SVCPermissions inPerm = inEdge->getPermissions();
494  for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); ++k) {
495  NBEdge* outEdge = *k;
496  const SVCPermissions outPerm = outEdge->getPermissions();
497  const SVCPermissions commonPerm = inPerm & outPerm;
498  if (commonPerm != 0 && commonPerm != SVC_PEDESTRIAN && !inEdge->isConnectedTo(outEdge)) {
499  device
500  << idSupplier.getNext() << "\t"
501  << 1 << "\t" // permanent id
502  << UNDEFINED << "\t"
503  << 1 << "\t"
504  << getAllowedTypes(SVCAll) << "\t"
505  << inEdge->getID() << "\t" << outEdge->getID() << "\n";
506  }
507  }
508  }
509  }
510  device.close();
511 }
512 
513 
514 void
516  OutputDevice& device = OutputDevice::getDevice(oc.getString("dlr-navteq-output") + "_connected_lanes.txt");
517  writeHeader(device, oc);
518  // write format specifier
519  device << "#Lane connections related to LINK-IDs and NODE-ID.\n";
520  device << "#column format like pointcollection.\n";
521  device << "#NODE-ID\tVEHICLE-TYPE\tFROM_LANE\tTO_LANE\tTHROUGH_TRAFFIC\tLINK_IDs[2..*]\n";
522  // write record for every connection
523  for (std::map<std::string, NBNode*>::const_iterator i = nc.begin(); i != nc.end(); ++i) {
524  NBNode* n = (*i).second;
525  const EdgeVector& incoming = n->getIncomingEdges();
526  for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
527  NBEdge* from = *j;
528  const SVCPermissions fromPerm = from->getPermissions();
529  const std::vector<NBEdge::Connection>& connections = from->getConnections();
530  for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
531  const NBEdge::Connection& c = *it_c;
532  device
533  << n->getID() << "\t"
534  << getAllowedTypes(fromPerm & c.toEdge->getPermissions()) << "\t"
535  << c.fromLane + 1 << "\t" // one-based
536  << c.toLane + 1 << "\t" // one-based
537  << 1 << "\t" // no information regarding permissibility of through traffic
538  << from->getID() << "\t"
539  << c.toEdge->getID() << "\t"
540  << "\n";
541  }
542  }
543  }
544  device.close();
545 }
546 
547 /****************************************************************************/
548 
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge&#39;s lanes&#39; lateral offset is computed.
Definition: NBEdge.h:704
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:108
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:131
void close()
Closes the device and removes it from the dictionary.
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:125
A structure which describes a connection between edges or lanes.
Definition: NBEdge.h:160
int toLane
The lane the connections yields in.
Definition: NBEdge.h:188
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
is a pedestrian
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
Definition: NBNodeCont.h:116
NBEdge * toEdge
The edge the connections yields in.
Definition: NBEdge.h:185
const Boundary & getConvBoundary() const
Returns the converted boundary.
static void loadPrefixedIDsFomFile(const std::string &file, const std::string prefix, std::set< std::string > &into)
Add prefixed ids defined in file.
Definition: NBHelpers.cpp:106
static double getGraphLength(NBEdge *edge)
get the length of the edge when measured up to the junction center
bool isConnectedTo(const NBEdge *e) const
Returns the information whethe a connection to the given edge has been added (or computed) ...
Definition: NBEdge.cpp:1164
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
Definition: NBNodeCont.h:121
static void writeHeader(OutputDevice &device, const OptionsCont &oc)
write header comments (input paramters, date, etc...)
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
Definition: NBEdge.cpp:1781
static int getRoadClass(NBEdge *edge)
get the navteq road class
NBEdge * getOppositeByID(const std::string &edgeID) const
Returns the edge with negated id if it exists.
static int speedInKph(double metersPerSecond)
get edge speed rounded to kmh
const std::string & getTypeID() const
get ID of type
Definition: NBEdge.h:1004
double y() const
Returns the y-position.
Definition: Position.h:62
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
static int getSpeedCategory(int kph)
get the navteq speed class based on the speed in km/h
The representation of a single edge during network building.
Definition: NBEdge.h:65
static void writeLinksUnsplitted(const OptionsCont &oc, NBEdgeCont &ec, std::map< NBEdge *, std::string > &internalNodes)
Writes the links_unsplitted file.
double x() const
Returns the x-position.
Definition: Position.h:57
static void writeProhibitedManoeuvres(const OptionsCont &oc, const NBNodeCont &nc, const NBEdgeCont &ec)
Writes the prohibited_manoeuvres file.
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
std::map< std::string, NBEdge * >::const_iterator end() const
Returns the pointer to the end of the stored edges.
Definition: NBEdgeCont.h:193
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const std::string & getID() const
Returns the id.
Definition: Named.h:78
const SVCPermissions SVCAll
all VClasses are allowed
static int getSpeedCategoryUpperBound(int kph)
get the SPEED_LIMIT as defined by elmar (upper bound of speed category)
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:241
void writeConfiguration(std::ostream &os, const bool filled, const bool complete, const bool addComments, const bool inComment=false) const
Writes the configuration.
const EdgeVector & getOutgoingEdges() const
Returns this node&#39;s outgoing edges (The edges which start at this node)
Definition: NBNode.h:255
static const std::string UNDEFINED
magic value for undefined stuff
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
bool isTLControlled() const
Returns whether this node is controlled by any tls.
Definition: NBNode.h:303
static int getNavteqLaneCode(const int numLanes)
get the lane number encoding
void push_front_noDoublePos(const Position &p)
insert in front a non double position
static void writeConnectedLanes(const OptionsCont &oc, NBNodeCont &nc)
Writes the connected_lanes file.
static bool startsWith(const std::string &str, const std::string prefix)
Checks whether a given string starts with the prefix.
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
Definition: NBEdgeCont.h:185
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
std::string getNext()
Returns the next id.
Definition: IDSupplier.cpp:52
static methods for processing the coordinates conversion for the current net
Definition: GeoConvHelper.h:53
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
int size() const
Returns the number of nodes stored in this container.
Definition: NBNodeCont.h:257
int getNumLanes() const
Returns the number of lanes.
Definition: NBEdge.h:420
int fromLane
The lane the connections starts at.
Definition: NBEdge.h:182
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:150
A list of positions.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
static std::string getSinglePostalCode(const std::string &zipCode, const std::string edgeID)
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:61
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:119
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into XML-files (nodes, edges, connections, traffic lights)
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
Definition: NBEdge.cpp:3331
void move2side(double amount)
move position vector to side using certain ammount
double getSpeed() const
Returns the speed allowed on this edge.
Definition: NBEdge.h:514
std::vector< std::string > getVector()
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:622
static std::string getAllowedTypes(SVCPermissions permissions)
build the ascii-bit-vector for column vehicle_type
std::vector< std::string > getAllNames() const
get all node names
double length() const
Returns the length.
const EdgeVector & getIncomingEdges() const
Returns this node&#39;s incoming edges (The edges which yield in this node)
Definition: NBNode.h:250
const std::vector< Connection > & getConnections() const
Returns the connections.
Definition: NBEdge.h:867
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:155
Instance responsible for building networks.
Definition: NBNetBuilder.h:109
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
Definition: NBCont.h:34
double getTotalWidth() const
Returns the combined width of all lanes of this edge.
Definition: NBEdge.cpp:3198
A storage for options typed value containers)
Definition: OptionsCont.h:92
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
const Position & getPosition() const
Definition: NBNode.h:242
Represents a single node (junction) during network building.
Definition: NBNode.h:68
static int getBrunnelType(NBEdge *edge)
get the navteq brunnel type
static int getFormOfWay(NBEdge *edge)
get the form of way
static void writeTrafficSignals(const OptionsCont &oc, NBNodeCont &nc)
Writes the traffic_signals file.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
void push_back_noDoublePos(const Position &p)
insert in back a non double position
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:434
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:60
void mul(double val)
Multiplies both positions with the given value.
Definition: Position.h:107
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:137
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
Definition: NBEdgeCont.cpp:691
static void writeNodesUnsplitted(const OptionsCont &oc, NBNodeCont &nc, NBEdgeCont &ec, std::map< NBEdge *, std::string > &internalNodes)
Writes the nodes_unsplitted file.
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:441