Eclipse SUMO - Simulation of Urban MObility
NIImporter_ArcView.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
22 // Importer for networks stored in ArcView-shape format
23 /****************************************************************************/
24 #include <config.h>
25 
26 #include <string>
28 #include <utils/common/ToString.h>
32 #include <utils/geom/GeomHelper.h>
33 #include <netbuild/NBNetBuilder.h>
34 #include <netbuild/NBHelpers.h>
35 #include <netbuild/NBEdge.h>
36 #include <netbuild/NBEdgeCont.h>
37 #include <netbuild/NBTypeCont.h>
38 #include <netbuild/NBNode.h>
39 #include <netbuild/NBNodeCont.h>
43 #include "NILoader.h"
44 #include "NIImporter_ArcView.h"
45 
46 #ifdef HAVE_GDAL
47 #if __GNUC__ > 3
48 #pragma GCC diagnostic push
49 #pragma GCC diagnostic ignored "-Wpedantic"
50 #endif
51 #include <ogrsf_frmts.h>
52 #if __GNUC__ > 3
53 #pragma GCC diagnostic pop
54 #endif
55 #endif
56 
57 
58 // ===========================================================================
59 // method definitions
60 // ===========================================================================
61 // ---------------------------------------------------------------------------
62 // static methods (interface in this case)
63 // ---------------------------------------------------------------------------
64 void
66  if (!oc.isSet("shapefile-prefix")) {
67  return;
68  }
69  // check whether the correct set of entries is given
70  // and compute both file names
71  std::string dbf_file = oc.getString("shapefile-prefix") + ".dbf";
72  std::string shp_file = oc.getString("shapefile-prefix") + ".shp";
73  std::string shx_file = oc.getString("shapefile-prefix") + ".shx";
74  // check whether the files do exist
75  if (!FileHelpers::isReadable(dbf_file)) {
76  WRITE_ERROR("File not accessible: " + dbf_file);
77  }
78  if (!FileHelpers::isReadable(shp_file)) {
79  WRITE_ERROR("File not accessible: " + shp_file);
80  }
81  if (!FileHelpers::isReadable(shx_file)) {
82  WRITE_ERROR("File not accessible: " + shx_file);
83  }
84  if (MsgHandler::getErrorInstance()->wasInformed()) {
85  return;
86  }
87  // load the arcview files
88  NIImporter_ArcView loader(oc,
89  nb.getNodeCont(), nb.getEdgeCont(), nb.getTypeCont(),
90  dbf_file, shp_file, oc.getBool("speed-in-kmh"));
91  loader.load();
92 }
93 
94 
95 
96 // ---------------------------------------------------------------------------
97 // loader methods
98 // ---------------------------------------------------------------------------
100  NBNodeCont& nc,
101  NBEdgeCont& ec,
102  NBTypeCont& tc,
103  const std::string& dbf_name,
104  const std::string& shp_name,
105  bool speedInKMH)
106  : myOptions(oc), mySHPName(shp_name),
107  myNameAddition(0),
108  myNodeCont(nc), myEdgeCont(ec), myTypeCont(tc),
109  mySpeedInKMH(speedInKMH),
110  myRunningEdgeID(0),
111  myRunningNodeID(0) {
112  UNUSED_PARAMETER(dbf_name);
113 }
114 
115 
117 
118 
119 void
121 #ifdef HAVE_GDAL
122  PROGRESS_BEGIN_MESSAGE("Loading data from '" + mySHPName + "'");
123 #if GDAL_VERSION_MAJOR < 2
124  OGRRegisterAll();
125  OGRDataSource* poDS = OGRSFDriverRegistrar::Open(mySHPName.c_str(), FALSE);
126 #else
127  GDALAllRegister();
128  GDALDataset* poDS = (GDALDataset*)GDALOpenEx(mySHPName.c_str(), GDAL_OF_VECTOR | GA_ReadOnly, NULL, NULL, NULL);
129 #endif
130  if (poDS == NULL) {
131  WRITE_ERROR("Could not open shape description '" + mySHPName + "'.");
132  return;
133  }
134 
135  // begin file parsing
136  OGRLayer* poLayer = poDS->GetLayer(0);
137  poLayer->ResetReading();
138 
139  // build coordinate transformation
140  OGRSpatialReference* origTransf = poLayer->GetSpatialRef();
141  OGRSpatialReference destTransf;
142  // use wgs84 as destination
143  destTransf.SetWellKnownGeogCS("WGS84");
144 #if GDAL_VERSION_MAJOR > 2
145  if (myOptions.getBool("shapefile.traditional-axis-mapping")) {
146  destTransf.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
147  }
148 #endif
149  OGRCoordinateTransformation* poCT = OGRCreateCoordinateTransformation(origTransf, &destTransf);
150  if (poCT == nullptr) {
151  if (myOptions.isSet("shapefile.guess-projection")) {
152  OGRSpatialReference origTransf2;
153  origTransf2.SetWellKnownGeogCS("WGS84");
154  poCT = OGRCreateCoordinateTransformation(&origTransf2, &destTransf);
155  }
156  if (poCT == nullptr) {
157  WRITE_WARNING("Could not create geocoordinates converter; check whether proj.4 is installed.");
158  }
159  }
160 
161  const bool saveOrigIDs = OptionsCont::getOptions().getBool("output.original-names");
162  OGRFeature* poFeature;
163  poLayer->ResetReading();
164 
165  const double nodeJoinDist = myOptions.getFloat("shapefile.node-join-dist");
166  const std::vector<std::string> params = myOptions.getStringVector("shapefile.add-params");
167 
168  int featureIndex = 0;
169  bool warnNotUnique = true;
170  std::string idPrefix = ""; // prefix for non-unique street-id values
171  std::map<std::string, int> idIndex; // running index to make street-id unique
172  while ((poFeature = poLayer->GetNextFeature()) != NULL) {
173  // read in edge attributes
174  if (featureIndex == 0) {
175  WRITE_MESSAGE("Available fields: " + toString(getFieldNames(poFeature)));
176  }
177  std::string id;
178  std::string name;
179  std::string from_node;
180  std::string to_node;
181  if (!getStringEntry(poFeature, "shapefile.street-id", "LINK_ID", true, id)) {
182  WRITE_ERROR("Needed field '" + id + "' (street-id) is missing.");
183  id = "";
184  }
185  if (id == "") {
186  id = toString(myRunningEdgeID++);
187  }
188 
189  getStringEntry(poFeature, "shapefile.name", "ST_NAME", true, name);
190  name = StringUtils::replace(name, "&", "&amp;");
191 
192  if (!getStringEntry(poFeature, "shapefile.from-id", "REF_IN_ID", true, from_node)) {
193  WRITE_ERROR("Needed field '" + from_node + "' (from node id) is missing.");
194  from_node = "";
195  }
196  if (!getStringEntry(poFeature, "shapefile.to-id", "NREF_IN_ID", true, to_node)) {
197  WRITE_ERROR("Needed field '" + to_node + "' (to node id) is missing.");
198  to_node = "";
199  }
200 
201  if (from_node == "" || to_node == "") {
202  from_node = toString(myRunningNodeID++);
203  to_node = toString(myRunningNodeID++);
204  }
205 
206  std::string type;
207  if (myOptions.isSet("shapefile.type-id") && poFeature->GetFieldIndex(myOptions.getString("shapefile.type-id").c_str()) >= 0) {
208  type = poFeature->GetFieldAsString(myOptions.getString("shapefile.type-id").c_str());
209  } else if (poFeature->GetFieldIndex("ST_TYP_AFT") >= 0) {
210  type = poFeature->GetFieldAsString("ST_TYP_AFT");
211  }
212  if ((type != "" || myOptions.isSet("shapefile.type-id")) && !myTypeCont.knows(type)) {
213  WRITE_WARNINGF("Unknown type '%' for edge '%'", type, id);
214  }
215  double width = myTypeCont.getEdgeTypeWidth(type);
216  bool oneway = myTypeCont.knows(type) ? myTypeCont.getEdgeTypeIsOneWay(type) : false;
217  double speed = getSpeed(*poFeature, id);
218  int nolanes = getLaneNo(*poFeature, id, speed);
219  int priority = getPriority(*poFeature, id);
220  if (nolanes <= 0 || speed <= 0) {
221  if (myOptions.getBool("shapefile.use-defaults-on-failure")) {
222  nolanes = nolanes <= 0 ? myTypeCont.getEdgeTypeNumLanes(type) : nolanes;
223  speed = speed <= 0 ? myTypeCont.getEdgeTypeSpeed(type) : speed;
224  } else {
225  const std::string lanesField = myOptions.isSet("shapefile.laneNumber") ? myOptions.getString("shapefile.laneNumber") : "nolanes";
226  const std::string speedField = myOptions.isSet("shapefile.speed") ? myOptions.getString("shapefile.speed") : "speed";
227  WRITE_ERROR("Required field '" + lanesField + "' or '" + speedField + "' is missing (add fields or set option --shapefile.use-defaults-on-failure).");
228  WRITE_ERROR("Available fields: " + toString(getFieldNames(poFeature)));
229  OGRFeature::DestroyFeature(poFeature);
230  return;
231  }
232  }
233  if (mySpeedInKMH) {
234  speed = speed / (double) 3.6;
235  }
236 
237 
238  // read in the geometry
239  OGRGeometry* poGeometry = poFeature->GetGeometryRef();
240  OGRwkbGeometryType gtype = poGeometry->getGeometryType();
241  if (gtype != wkbLineString && gtype != wkbLineString25D) {
242  OGRFeature::DestroyFeature(poFeature);
243  WRITE_ERROR("Road geometry must be of type 'linestring' or 'linestring25D' (found '" + toString(gtype) + "')");
244  return;
245  }
246  OGRLineString* cgeom = (OGRLineString*) poGeometry;
247  if (poCT != nullptr) {
248  // try transform to wgs84
249  cgeom->transform(poCT);
250  }
251 
252  PositionVector shape;
253  for (int j = 0; j < cgeom->getNumPoints(); j++) {
254  Position pos((double) cgeom->getX(j), (double) cgeom->getY(j), (double) cgeom->getZ(j));
256  WRITE_WARNINGF("Unable to project coordinates for edge '%'.", id);
257  }
258  shape.push_back_noDoublePos(pos);
259  }
260 
261  // build from-node
262  NBNode* from = myNodeCont.retrieve(from_node);
263  if (from == 0) {
264  Position from_pos = shape[0];
265  from = myNodeCont.retrieve(from_pos, nodeJoinDist);
266  if (from == 0) {
267  from = new NBNode(from_node, from_pos);
268  if (!myNodeCont.insert(from)) {
269  WRITE_ERROR("Node '" + from_node + "' could not be added");
270  delete from;
271  continue;
272  }
273  }
274  }
275  // build to-node
276  NBNode* to = myNodeCont.retrieve(to_node);
277  if (to == 0) {
278  Position to_pos = shape[-1];
279  to = myNodeCont.retrieve(to_pos, nodeJoinDist);
280  if (to == 0) {
281  to = new NBNode(to_node, to_pos);
282  if (!myNodeCont.insert(to)) {
283  WRITE_ERROR("Node '" + to_node + "' could not be added");
284  delete to;
285  continue;
286  }
287  }
288  }
289 
290  if (from == to) {
291  WRITE_WARNINGF("Edge '%' connects identical nodes, skipping.", id);
292  continue;
293  }
294 
295  // retrieve the information whether the street is bi-directional
296  std::string dir;
297  int index = poFeature->GetDefnRef()->GetFieldIndex("DIR_TRAVEL");
298  if (index >= 0 && poFeature->IsFieldSet(index)) {
299  dir = poFeature->GetFieldAsString(index);
300  }
301  const std::string origID = saveOrigIDs ? id : "";
302  // check for duplicate ids
303  NBEdge* existing = myEdgeCont.retrieve(id);
304  NBEdge* existingReverse = myEdgeCont.retrieve("-" + id);
305  if (existing != nullptr || existingReverse != nullptr) {
306  std::string duplicateID = existing != nullptr ? id : existingReverse->getID();
307  if ((existing != 0 && existing->getGeometry() == shape)
308  || (existingReverse != 0 && existingReverse->getGeometry() == shape.reverse())) {
309  WRITE_ERROR("Edge '" + duplicateID + " is not unique");
310  } else {
311  if (idIndex.count(id) == 0) {
312  idIndex[id] = 0;
313  }
314  idIndex[id]++;
315  idPrefix = id;
316  id += "#" + toString(idIndex[id]);
317  if (warnNotUnique) {
318  WRITE_WARNING("street-id '" + idPrefix + "' is not unique. Renaming subsequent edge to '" + id + "'");
319  warnNotUnique = false;
320  }
321  }
322  }
323  // add positive direction if wanted
324  if (dir == "B" || dir == "F" || dir == "" || myOptions.getBool("shapefile.all-bidirectional")) {
325  if (myEdgeCont.retrieve(id) == 0) {
326  LaneSpreadFunction spread = dir == "B" || dir == "FALSE" ? LaneSpreadFunction::RIGHT : LaneSpreadFunction::CENTER;
327  NBEdge* edge = new NBEdge(id, from, to, type, speed, nolanes, priority, width, NBEdge::UNSPECIFIED_OFFSET, shape, name, origID, spread);
329  myEdgeCont.insert(edge);
330  checkSpread(edge);
331  addParams(edge, poFeature, params);
332  } else {
333  WRITE_ERROR("Could not create edge '" + id + "'. An edge with the same id already exists");
334  }
335  }
336  // add negative direction if wanted
337  if ((dir == "B" || dir == "T" || myOptions.getBool("shapefile.all-bidirectional")) && !oneway) {
338  if (myEdgeCont.retrieve("-" + id) == 0) {
339  LaneSpreadFunction spread = dir == "B" || dir == "FALSE" ? LaneSpreadFunction::RIGHT : LaneSpreadFunction::CENTER;
340  NBEdge* edge = new NBEdge("-" + id, to, from, type, speed, nolanes, priority, width, NBEdge::UNSPECIFIED_OFFSET, shape.reverse(), name, origID, spread);
342  myEdgeCont.insert(edge);
343  checkSpread(edge);
344  addParams(edge, poFeature, params);
345  } else {
346  WRITE_ERROR("Could not create edge '-" + id + "'. An edge with the same id already exists");
347  }
348  }
349  //
350  OGRFeature::DestroyFeature(poFeature);
351  featureIndex++;
352  }
353 #if GDAL_VERSION_MAJOR < 2
354  OGRDataSource::DestroyDataSource(poDS);
355 #else
356  GDALClose(poDS);
357 #endif
359 #else
360  WRITE_ERROR("SUMO was compiled without GDAL support.");
361 #endif
362 }
363 
364 #ifdef HAVE_GDAL
365 double
366 NIImporter_ArcView::getSpeed(OGRFeature& poFeature, const std::string& edgeid) {
367  if (myOptions.isSet("shapefile.speed")) {
368  int index = poFeature.GetDefnRef()->GetFieldIndex(myOptions.getString("shapefile.speed").c_str());
369  if (index >= 0 && poFeature.IsFieldSet(index)) {
370  const double speed = poFeature.GetFieldAsDouble(index);
371  if (speed <= 0) {
372  WRITE_WARNING("invalid value for field: '"
373  + myOptions.getString("shapefile.laneNumber")
374  + "': '" + std::string(poFeature.GetFieldAsString(index)) + "'");
375  } else {
376  return speed;
377  }
378  }
379  }
380  if (myOptions.isSet("shapefile.type-id")) {
381  return myTypeCont.getEdgeTypeSpeed(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
382  }
383  // try to get definitions as to be found in SUMO-XML-definitions
384  // idea by John Michael Calandrino
385  int index = poFeature.GetDefnRef()->GetFieldIndex("speed");
386  if (index >= 0 && poFeature.IsFieldSet(index)) {
387  return (double) poFeature.GetFieldAsDouble(index);
388  }
389  index = poFeature.GetDefnRef()->GetFieldIndex("SPEED");
390  if (index >= 0 && poFeature.IsFieldSet(index)) {
391  return (double) poFeature.GetFieldAsDouble(index);
392  }
393  // try to get the NavTech-information
394  index = poFeature.GetDefnRef()->GetFieldIndex("SPEED_CAT");
395  if (index >= 0 && poFeature.IsFieldSet(index)) {
396  std::string def = poFeature.GetFieldAsString(index);
397  return NINavTeqHelper::getSpeed(edgeid, def);
398  }
399  return -1;
400 }
401 
402 
403 int
404 NIImporter_ArcView::getLaneNo(OGRFeature& poFeature, const std::string& edgeid,
405  double speed) {
406  if (myOptions.isSet("shapefile.laneNumber")) {
407  int index = poFeature.GetDefnRef()->GetFieldIndex(myOptions.getString("shapefile.laneNumber").c_str());
408  if (index >= 0 && poFeature.IsFieldSet(index)) {
409  const int laneNumber = poFeature.GetFieldAsInteger(index);
410  if (laneNumber <= 0) {
411  WRITE_WARNING("invalid value for field '"
412  + myOptions.getString("shapefile.laneNumber")
413  + "': '" + std::string(poFeature.GetFieldAsString(index)) + "'");
414  } else {
415  return laneNumber;
416  }
417  }
418  }
419  if (myOptions.isSet("shapefile.type-id")) {
420  return (int) myTypeCont.getEdgeTypeNumLanes(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
421  }
422  // try to get definitions as to be found in SUMO-XML-definitions
423  // idea by John Michael Calandrino
424  int index = poFeature.GetDefnRef()->GetFieldIndex("nolanes");
425  if (index >= 0 && poFeature.IsFieldSet(index)) {
426  return (int) poFeature.GetFieldAsInteger(index);
427  }
428  index = poFeature.GetDefnRef()->GetFieldIndex("NOLANES");
429  if (index >= 0 && poFeature.IsFieldSet(index)) {
430  return (int) poFeature.GetFieldAsInteger(index);
431  }
432  index = poFeature.GetDefnRef()->GetFieldIndex("rnol");
433  if (index >= 0 && poFeature.IsFieldSet(index)) {
434  return (int) poFeature.GetFieldAsInteger(index);
435  }
436  index = poFeature.GetDefnRef()->GetFieldIndex("LANE_CAT");
437  if (index >= 0 && poFeature.IsFieldSet(index)) {
438  std::string def = poFeature.GetFieldAsString(index);
439  return NINavTeqHelper::getLaneNumber(edgeid, def, speed);
440  }
441  return 0;
442 }
443 
444 
445 int
446 NIImporter_ArcView::getPriority(OGRFeature& poFeature, const std::string& /*edgeid*/) {
447  if (myOptions.isSet("shapefile.type-id")) {
448  return myTypeCont.getEdgeTypePriority(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
449  }
450  // try to get definitions as to be found in SUMO-XML-definitions
451  // idea by John Michael Calandrino
452  int index = poFeature.GetDefnRef()->GetFieldIndex("priority");
453  if (index >= 0 && poFeature.IsFieldSet(index)) {
454  return poFeature.GetFieldAsInteger(index);
455  }
456  index = poFeature.GetDefnRef()->GetFieldIndex("PRIORITY");
457  if (index >= 0 && poFeature.IsFieldSet(index)) {
458  return poFeature.GetFieldAsInteger(index);
459  }
460  // try to determine priority from NavTechs FUNC_CLASS attribute
461  index = poFeature.GetDefnRef()->GetFieldIndex("FUNC_CLASS");
462  if (index >= 0 && poFeature.IsFieldSet(index)) {
463  return poFeature.GetFieldAsInteger(index);
464  }
465  return 0;
466 }
467 
468 void
469 NIImporter_ArcView::checkSpread(NBEdge* e) {
470  NBEdge* ret = e->getToNode()->getConnectionTo(e->getFromNode());
471  if (ret != 0) {
474  }
475 }
476 
477 bool
478 NIImporter_ArcView::getStringEntry(OGRFeature* poFeature, const std::string& optionName, const char* defaultName, bool prune, std::string& into) {
479  std::string v(defaultName);
480  if (myOptions.isSet(optionName)) {
481  v = myOptions.getString(optionName);
482  }
483  if (poFeature->GetFieldIndex(v.c_str()) < 0) {
484  if (myOptions.isSet(optionName)) {
485  into = v;
486  return false;
487  }
488  into = "";
489  return true;
490  }
491  into = poFeature->GetFieldAsString((char*)v.c_str());
492  if (prune) {
493  into = StringUtils::prune(into);
494  }
495  return true;
496 }
497 
498 std::vector<std::string>
499 NIImporter_ArcView::getFieldNames(OGRFeature* poFeature) const {
500  std::vector<std::string> fields;
501  for (int i = 0; i < poFeature->GetFieldCount(); i++) {
502  fields.push_back(poFeature->GetFieldDefnRef(i)->GetNameRef());
503  }
504  return fields;
505 }
506 
507 void
508 NIImporter_ArcView::addParams(NBEdge* edge, OGRFeature* poFeature, const std::vector<std::string>& params) const {
509  for (const std::string& p : params) {
510  int index = poFeature->GetDefnRef()->GetFieldIndex(p.c_str());
511  if (index >= 0 && poFeature->IsFieldSet(index)) {
512  edge->setParameter(p, poFeature->GetFieldAsString(index));
513  }
514  }
515 }
516 
517 #endif
518 
519 
520 /****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:277
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:276
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:280
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:279
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:48
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:80
Storage for edges, including some functionality operating on multiple edges.
Definition: NBEdgeCont.h:59
NBEdge * retrieve(const std::string &id, bool retrieveExtracted=false) const
Returns the edge that has the given id.
Definition: NBEdgeCont.cpp:275
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:178
The representation of a single edge during network building.
Definition: NBEdge.h:91
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given
Definition: NBEdge.cpp:3627
const std::string & getID() const
Definition: NBEdge.h:1423
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:516
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
Definition: NBEdge.cpp:907
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:716
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:327
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:509
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
NBTypeCont & getTypeCont()
Returns a reference to the type container.
Definition: NBNetBuilder.h:158
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:148
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:153
Container for nodes during the netbuilding process.
Definition: NBNodeCont.h:58
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
Definition: NBNodeCont.cpp:90
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:119
Represents a single node (junction) during network building.
Definition: NBNode.h:66
NBEdge * getConnectionTo(NBNode *n) const
get connection to certain node
Definition: NBNode.cpp:2303
A storage for available edgeTypes of edges.
Definition: NBTypeCont.h:52
double getEdgeTypeSpeed(const std::string &edgeType) const
Returns the maximal velocity for the given edgeType [m/s].
Definition: NBTypeCont.cpp:451
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
Definition: NBTypeCont.cpp:457
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
Definition: NBTypeCont.cpp:445
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
Definition: NBTypeCont.cpp:501
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
Definition: NBTypeCont.cpp:495
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
Definition: NBTypeCont.cpp:270
bool getEdgeTypeIsOneWay(const std::string &edgeType) const
Returns whether edges are one-way per default for the given edgeType.
Definition: NBTypeCont.cpp:463
Importer for networks stored in ArcView-shape format.
const OptionsCont & myOptions
The options to use.
void load()
Loads the shape files.
int myRunningEdgeID
A running number to assure unique ids (as fallback)
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given ArcView Shape files.
std::string mySHPName
The name of the shape file.
NBTypeCont & myTypeCont
The container to get the types from.
NBNodeCont & myNodeCont
The container to add nodes to.
bool mySpeedInKMH
Whether the speed is given in km/h.
~NIImporter_ArcView()
Destructor.
NBEdgeCont & myEdgeCont
The container to add edges to.
NIImporter_ArcView(const OptionsCont &oc, NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, const std::string &dbf_name, const std::string &shp_name, bool speedInKMH)
Constructor.
static int getLaneNumber(const std::string &id, const std::string &laneNoS, double speed)
Returns the lane number evaluating the given Navteq-description.
static double getSpeed(const std::string &id, const std::string &speedClassS)
Returns the speed evaluating the given Navteq-description.
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
double getFloat(const std::string &name) const
Returns the double-value of the named option (only for Option_Float)
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
const StringVector & getStringVector(const std::string &name) const
Returns the list of string-value of the named option (only for Option_StringVector)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
A list of positions.
void push_back_noDoublePos(const Position &p)
insert in back a non double position
PositionVector reverse() const
reverse position vector
static std::string replace(std::string str, const char *what, const char *by)
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
Definition: StringUtils.cpp:47