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-2022 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>
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#ifdef _MSC_VER
48#pragma warning(push)
49#pragma warning(disable: 4435 5219 5220)
50#endif
51#if __GNUC__ > 3
52#pragma GCC diagnostic push
53#pragma GCC diagnostic ignored "-Wpedantic"
54#endif
55#include <ogrsf_frmts.h>
56#if __GNUC__ > 3
57#pragma GCC diagnostic pop
58#endif
59#ifdef _MSC_VER
60#pragma warning(pop)
61#endif
62#endif
63
64
65// ===========================================================================
66// method definitions
67// ===========================================================================
68// ---------------------------------------------------------------------------
69// static methods (interface in this case)
70// ---------------------------------------------------------------------------
71void
73 if (!oc.isSet("shapefile-prefix")) {
74 return;
75 }
76 // check whether the correct set of entries is given
77 // and compute both file names
78 std::string dbf_file = oc.getString("shapefile-prefix") + ".dbf";
79 std::string shp_file = oc.getString("shapefile-prefix") + ".shp";
80 std::string shx_file = oc.getString("shapefile-prefix") + ".shx";
81 // check whether the files do exist
82 if (!FileHelpers::isReadable(dbf_file)) {
83 WRITE_ERROR("File not accessible: " + dbf_file);
84 }
85 if (!FileHelpers::isReadable(shp_file)) {
86 WRITE_ERROR("File not accessible: " + shp_file);
87 }
88 if (!FileHelpers::isReadable(shx_file)) {
89 WRITE_ERROR("File not accessible: " + shx_file);
90 }
91 if (MsgHandler::getErrorInstance()->wasInformed()) {
92 return;
93 }
94 // load the arcview files
95 NIImporter_ArcView loader(oc,
96 nb.getNodeCont(), nb.getEdgeCont(), nb.getTypeCont(),
97 dbf_file, shp_file, oc.getBool("speed-in-kmh"));
98 loader.load();
99}
100
101
102
103// ---------------------------------------------------------------------------
104// loader methods
105// ---------------------------------------------------------------------------
107 NBNodeCont& nc,
108 NBEdgeCont& ec,
109 NBTypeCont& tc,
110 const std::string& dbf_name,
111 const std::string& shp_name,
112 bool speedInKMH)
113 : myOptions(oc), mySHPName(shp_name),
114 myNameAddition(0),
115 myNodeCont(nc), myEdgeCont(ec), myTypeCont(tc),
116 mySpeedInKMH(speedInKMH),
117 myRunningEdgeID(0),
118 myRunningNodeID(0) {
119 UNUSED_PARAMETER(dbf_name);
120}
121
122
124
125
126void
128#ifdef HAVE_GDAL
129 PROGRESS_BEGIN_MESSAGE("Loading data from '" + mySHPName + "'");
130#if GDAL_VERSION_MAJOR < 2
131 OGRRegisterAll();
132 OGRDataSource* poDS = OGRSFDriverRegistrar::Open(mySHPName.c_str(), FALSE);
133#else
134 GDALAllRegister();
135 GDALDataset* poDS = (GDALDataset*)GDALOpenEx(mySHPName.c_str(), GDAL_OF_VECTOR | GA_ReadOnly, NULL, NULL, NULL);
136#endif
137 if (poDS == NULL) {
138 WRITE_ERROR("Could not open shape description '" + mySHPName + "'.");
139 return;
140 }
141
142 // begin file parsing
143 OGRLayer* poLayer = poDS->GetLayer(0);
144 poLayer->ResetReading();
145
146 // build coordinate transformation
147 OGRSpatialReference* origTransf = poLayer->GetSpatialRef();
148 OGRSpatialReference destTransf;
149 // use wgs84 as destination
150 destTransf.SetWellKnownGeogCS("WGS84");
151#if GDAL_VERSION_MAJOR > 2
152 if (myOptions.getBool("shapefile.traditional-axis-mapping")) {
153 destTransf.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
154 }
155#endif
156 OGRCoordinateTransformation* poCT = origTransf == nullptr ? nullptr : OGRCreateCoordinateTransformation(origTransf, &destTransf);
157 if (poCT == nullptr) {
158 if (myOptions.getBool("shapefile.guess-projection")) {
159 OGRSpatialReference origTransf2;
160 origTransf2.SetWellKnownGeogCS("WGS84");
161 poCT = OGRCreateCoordinateTransformation(&origTransf2, &destTransf);
162 }
163 }
164
165 const bool saveOrigIDs = OptionsCont::getOptions().getBool("output.original-names");
166 OGRFeature* poFeature;
167 poLayer->ResetReading();
168
169 const double nodeJoinDist = myOptions.getFloat("shapefile.node-join-dist");
170 const std::vector<std::string> params = myOptions.getStringVector("shapefile.add-params");
171
172 int featureIndex = 0;
173 bool warnNotUnique = true;
174 bool warnMissingProjection = true;
175 std::string idPrefix = ""; // prefix for non-unique street-id values
176 std::map<std::string, int> idIndex; // running index to make street-id unique
177 while ((poFeature = poLayer->GetNextFeature()) != NULL) {
178 // read in edge attributes
179 if (featureIndex == 0) {
180 WRITE_MESSAGE("Available fields: " + toString(getFieldNames(poFeature)));
181 }
182 std::string id;
183 std::string name;
184 std::string from_node;
185 std::string to_node;
186 if (!getStringEntry(poFeature, "shapefile.street-id", "LINK_ID", true, id)) {
187 WRITE_ERROR("Needed field '" + id + "' (street-id) is missing.");
188 id = "";
189 }
190 if (id == "") {
192 }
193
194 getStringEntry(poFeature, "shapefile.name", "ST_NAME", true, name);
195 name = StringUtils::replace(name, "&", "&amp;");
196
197 if (!getStringEntry(poFeature, "shapefile.from-id", "REF_IN_ID", true, from_node)) {
198 WRITE_ERROR("Needed field '" + from_node + "' (from node id) is missing.");
199 from_node = "";
200 }
201 if (!getStringEntry(poFeature, "shapefile.to-id", "NREF_IN_ID", true, to_node)) {
202 WRITE_ERROR("Needed field '" + to_node + "' (to node id) is missing.");
203 to_node = "";
204 }
205
206 if (from_node == "" || to_node == "") {
207 from_node = toString(myRunningNodeID++);
208 to_node = toString(myRunningNodeID++);
209 }
210
211 std::string type;
212 if (myOptions.isSet("shapefile.type-id") && poFeature->GetFieldIndex(myOptions.getString("shapefile.type-id").c_str()) >= 0) {
213 type = poFeature->GetFieldAsString(myOptions.getString("shapefile.type-id").c_str());
214 } else if (poFeature->GetFieldIndex("ST_TYP_AFT") >= 0) {
215 type = poFeature->GetFieldAsString("ST_TYP_AFT");
216 }
217 if ((type != "" || myOptions.isSet("shapefile.type-id")) && !myTypeCont.knows(type)) {
218 WRITE_WARNINGF(TL("Unknown type '%' for edge '%'"), type, id);
219 }
220 double width = myTypeCont.getEdgeTypeWidth(type);
221 bool oneway = myTypeCont.knows(type) ? myTypeCont.getEdgeTypeIsOneWay(type) : false;
222 double speed = getSpeed(*poFeature, id);
223 int nolanes = getLaneNo(*poFeature, id, speed);
224 int priority = getPriority(*poFeature, id);
225 if (nolanes <= 0 || speed <= 0) {
226 if (myOptions.getBool("shapefile.use-defaults-on-failure")) {
227 nolanes = nolanes <= 0 ? myTypeCont.getEdgeTypeNumLanes(type) : nolanes;
228 speed = speed <= 0 ? myTypeCont.getEdgeTypeSpeed(type) : speed;
229 } else {
230 const std::string lanesField = myOptions.isSet("shapefile.laneNumber") ? myOptions.getString("shapefile.laneNumber") : "nolanes";
231 const std::string speedField = myOptions.isSet("shapefile.speed") ? myOptions.getString("shapefile.speed") : "speed";
232 WRITE_ERROR("Required field '" + lanesField + "' or '" + speedField + "' is missing (add fields or set option --shapefile.use-defaults-on-failure).");
233 WRITE_ERROR("Available fields: " + toString(getFieldNames(poFeature)));
234 OGRFeature::DestroyFeature(poFeature);
235 return;
236 }
237 }
238 if (mySpeedInKMH) {
239 speed /= 3.6;
240 }
241
242
243 // read in the geometry
244 OGRGeometry* poGeometry = poFeature->GetGeometryRef();
245 OGRwkbGeometryType gtype = poGeometry->getGeometryType();
246 if (gtype != wkbLineString && gtype != wkbLineString25D) {
247 OGRFeature::DestroyFeature(poFeature);
248 WRITE_ERROR("Road geometry must be of type 'linestring' or 'linestring25D' (found '" + toString(gtype) + "')");
249 return;
250 }
251 OGRLineString* cgeom = (OGRLineString*) poGeometry;
252 if (poCT == nullptr && warnMissingProjection) {
253 int outOfRange = 0;
254 for (int j = 0; j < cgeom->getNumPoints(); j++) {
255 if (fabs(cgeom->getX(j)) > 180 || fabs(cgeom->getY(j)) > 90) {
256 outOfRange++;
257 }
258 }
259 if (2 * outOfRange > cgeom->getNumPoints()) {
260 WRITE_WARNING(TL("No coordinate system found and coordinates look already projected."));
261 GeoConvHelper::init("!", GeoConvHelper::getProcessing().getOffset(), GeoConvHelper::getProcessing().getOrigBoundary(), GeoConvHelper::getProcessing().getConvBoundary());
262 } else {
263 WRITE_WARNING(TL("Could not find geo coordinate system, assuming WGS84."));
264 }
265 warnMissingProjection = false;
266 }
267 if (poCT != nullptr) {
268 // try transform to wgs84
269 cgeom->transform(poCT);
270 }
271
272 PositionVector shape;
273 for (int j = 0; j < cgeom->getNumPoints(); j++) {
274 Position pos(cgeom->getX(j), cgeom->getY(j), cgeom->getZ(j));
276 WRITE_WARNINGF(TL("Unable to project coordinates for edge '%'."), id);
277 }
278 shape.push_back_noDoublePos(pos);
279 }
280
281 // build from-node
282 NBNode* from = myNodeCont.retrieve(from_node);
283 if (from == nullptr) {
284 Position from_pos = shape[0];
285 from = myNodeCont.retrieve(from_pos, nodeJoinDist);
286 if (from == nullptr) {
287 from = new NBNode(from_node, from_pos);
288 if (!myNodeCont.insert(from)) {
289 WRITE_ERROR("Node '" + from_node + "' could not be added");
290 delete from;
291 continue;
292 }
293 }
294 }
295 // build to-node
296 NBNode* to = myNodeCont.retrieve(to_node);
297 if (to == nullptr) {
298 Position to_pos = shape[-1];
299 to = myNodeCont.retrieve(to_pos, nodeJoinDist);
300 if (to == nullptr) {
301 to = new NBNode(to_node, to_pos);
302 if (!myNodeCont.insert(to)) {
303 WRITE_ERROR("Node '" + to_node + "' could not be added");
304 delete to;
305 continue;
306 }
307 }
308 }
309
310 if (from == to) {
311 WRITE_WARNINGF(TL("Edge '%' connects identical nodes, skipping."), id);
312 continue;
313 }
314
315 // retrieve the information whether the street is bi-directional
316 std::string dir;
317 int index = poFeature->GetDefnRef()->GetFieldIndex("DIR_TRAVEL");
318 if (index >= 0 && poFeature->IsFieldSet(index)) {
319 dir = poFeature->GetFieldAsString(index);
320 }
321 const std::string origID = saveOrigIDs ? id : "";
322 // check for duplicate ids
323 NBEdge* const existing = myEdgeCont.retrieve(id);
324 NBEdge* const existingReverse = myEdgeCont.retrieve("-" + id);
325 if (existing != nullptr || existingReverse != nullptr) {
326 if ((existing != nullptr && existing->getGeometry() == shape)
327 || (existingReverse != nullptr && existingReverse->getGeometry() == shape.reverse())) {
328 WRITE_ERROR("Edge '" + (existing != nullptr ? id : existingReverse->getID()) + " is not unique.");
329 } else {
330 if (idIndex.count(id) == 0) {
331 idIndex[id] = 0;
332 }
333 idIndex[id]++;
334 idPrefix = id;
335 id += "#" + toString(idIndex[id]);
336 if (warnNotUnique) {
337 WRITE_WARNINGF(TL("Edge '%' is not unique. Renaming subsequent edge to '%'."), idPrefix, id);
338 warnNotUnique = false;
339 }
340 }
341 }
342 // add positive direction if wanted
343 if (dir == "B" || dir == "F" || dir == "" || myOptions.getBool("shapefile.all-bidirectional")) {
344 if (myEdgeCont.retrieve(id) == 0) {
345 LaneSpreadFunction spread = dir == "B" || dir == "FALSE" ? LaneSpreadFunction::RIGHT : LaneSpreadFunction::CENTER;
346 NBEdge* edge = new NBEdge(id, from, to, type, speed, NBEdge::UNSPECIFIED_FRICTION, nolanes, priority, width, NBEdge::UNSPECIFIED_OFFSET, shape, spread, name, origID);
348 myEdgeCont.insert(edge);
349 checkSpread(edge);
350 addParams(edge, poFeature, params);
351 } else {
352 WRITE_ERROR("Could not create edge '" + id + "'. An edge with the same id already exists.");
353 }
354 }
355 // add negative direction if wanted
356 if ((dir == "B" || dir == "T" || myOptions.getBool("shapefile.all-bidirectional")) && !oneway) {
357 if (myEdgeCont.retrieve("-" + id) == 0) {
358 LaneSpreadFunction spread = dir == "B" || dir == "FALSE" ? LaneSpreadFunction::RIGHT : LaneSpreadFunction::CENTER;
359 NBEdge* edge = new NBEdge("-" + id, to, from, type, speed, NBEdge::UNSPECIFIED_FRICTION, nolanes, priority, width, NBEdge::UNSPECIFIED_OFFSET, shape.reverse(), spread, name, origID);
361 myEdgeCont.insert(edge);
362 checkSpread(edge);
363 addParams(edge, poFeature, params);
364 } else {
365 WRITE_ERROR("Could not create edge '-" + id + "'. An edge with the same id already exists.");
366 }
367 }
368 //
369 OGRFeature::DestroyFeature(poFeature);
370 featureIndex++;
371 }
372#if GDAL_VERSION_MAJOR < 2
373 OGRDataSource::DestroyDataSource(poDS);
374#else
375 GDALClose(poDS);
376#endif
378#else
379 WRITE_ERROR(TL("SUMO was compiled without GDAL support."));
380#endif
381}
382
383#ifdef HAVE_GDAL
384double
385NIImporter_ArcView::getSpeed(OGRFeature& poFeature, const std::string& edgeid) {
386 if (myOptions.isSet("shapefile.speed")) {
387 int index = poFeature.GetDefnRef()->GetFieldIndex(myOptions.getString("shapefile.speed").c_str());
388 if (index >= 0 && poFeature.IsFieldSet(index)) {
389 const double speed = poFeature.GetFieldAsDouble(index);
390 if (speed <= 0) {
391 WRITE_WARNING("invalid value for field: '"
392 + myOptions.getString("shapefile.laneNumber")
393 + "': '" + std::string(poFeature.GetFieldAsString(index)) + "'");
394 } else {
395 return speed;
396 }
397 }
398 }
399 if (myOptions.isSet("shapefile.type-id")) {
400 return myTypeCont.getEdgeTypeSpeed(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
401 }
402 // try to get definitions as to be found in SUMO-XML-definitions
403 // idea by John Michael Calandrino
404 int index = poFeature.GetDefnRef()->GetFieldIndex("speed");
405 if (index >= 0 && poFeature.IsFieldSet(index)) {
406 return (double) poFeature.GetFieldAsDouble(index);
407 }
408 index = poFeature.GetDefnRef()->GetFieldIndex("SPEED");
409 if (index >= 0 && poFeature.IsFieldSet(index)) {
410 return (double) poFeature.GetFieldAsDouble(index);
411 }
412 // try to get the NavTech-information
413 index = poFeature.GetDefnRef()->GetFieldIndex("SPEED_CAT");
414 if (index >= 0 && poFeature.IsFieldSet(index)) {
415 std::string def = poFeature.GetFieldAsString(index);
416 return NINavTeqHelper::getSpeed(edgeid, def);
417 }
418 return -1;
419}
420
421
422int
423NIImporter_ArcView::getLaneNo(OGRFeature& poFeature, const std::string& edgeid,
424 double speed) {
425 if (myOptions.isSet("shapefile.laneNumber")) {
426 int index = poFeature.GetDefnRef()->GetFieldIndex(myOptions.getString("shapefile.laneNumber").c_str());
427 if (index >= 0 && poFeature.IsFieldSet(index)) {
428 const int laneNumber = poFeature.GetFieldAsInteger(index);
429 if (laneNumber <= 0) {
430 WRITE_WARNING("invalid value for field '"
431 + myOptions.getString("shapefile.laneNumber")
432 + "': '" + std::string(poFeature.GetFieldAsString(index)) + "'");
433 } else {
434 return laneNumber;
435 }
436 }
437 }
438 if (myOptions.isSet("shapefile.type-id")) {
439 return (int) myTypeCont.getEdgeTypeNumLanes(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
440 }
441 // try to get definitions as to be found in SUMO-XML-definitions
442 // idea by John Michael Calandrino
443 int index = poFeature.GetDefnRef()->GetFieldIndex("nolanes");
444 if (index >= 0 && poFeature.IsFieldSet(index)) {
445 return (int) poFeature.GetFieldAsInteger(index);
446 }
447 index = poFeature.GetDefnRef()->GetFieldIndex("NOLANES");
448 if (index >= 0 && poFeature.IsFieldSet(index)) {
449 return (int) poFeature.GetFieldAsInteger(index);
450 }
451 index = poFeature.GetDefnRef()->GetFieldIndex("rnol");
452 if (index >= 0 && poFeature.IsFieldSet(index)) {
453 return (int) poFeature.GetFieldAsInteger(index);
454 }
455 index = poFeature.GetDefnRef()->GetFieldIndex("LANE_CAT");
456 if (index >= 0 && poFeature.IsFieldSet(index)) {
457 std::string def = poFeature.GetFieldAsString(index);
458 return NINavTeqHelper::getLaneNumber(edgeid, def, speed);
459 }
460 return 0;
461}
462
463
464int
465NIImporter_ArcView::getPriority(OGRFeature& poFeature, const std::string& /*edgeid*/) {
466 if (myOptions.isSet("shapefile.type-id")) {
467 return myTypeCont.getEdgeTypePriority(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
468 }
469 // try to get definitions as to be found in SUMO-XML-definitions
470 // idea by John Michael Calandrino
471 int index = poFeature.GetDefnRef()->GetFieldIndex("priority");
472 if (index >= 0 && poFeature.IsFieldSet(index)) {
473 return poFeature.GetFieldAsInteger(index);
474 }
475 index = poFeature.GetDefnRef()->GetFieldIndex("PRIORITY");
476 if (index >= 0 && poFeature.IsFieldSet(index)) {
477 return poFeature.GetFieldAsInteger(index);
478 }
479 // try to determine priority from NavTechs FUNC_CLASS attribute
480 index = poFeature.GetDefnRef()->GetFieldIndex("FUNC_CLASS");
481 if (index >= 0 && poFeature.IsFieldSet(index)) {
482 return poFeature.GetFieldAsInteger(index);
483 }
484 return 0;
485}
486
487void
488NIImporter_ArcView::checkSpread(NBEdge* e) {
489 NBEdge* ret = e->getToNode()->getConnectionTo(e->getFromNode());
490 if (ret != 0) {
493 }
494}
495
496bool
497NIImporter_ArcView::getStringEntry(OGRFeature* poFeature, const std::string& optionName, const char* defaultName, bool prune, std::string& into) {
498 std::string v(defaultName);
499 if (myOptions.isSet(optionName)) {
500 v = myOptions.getString(optionName);
501 }
502 if (poFeature->GetFieldIndex(v.c_str()) < 0) {
503 if (myOptions.isSet(optionName)) {
504 into = v;
505 return false;
506 }
507 into = "";
508 return true;
509 }
510 into = poFeature->GetFieldAsString((char*)v.c_str());
511 if (prune) {
512 into = StringUtils::prune(into);
513 }
514 return true;
515}
516
517std::vector<std::string>
518NIImporter_ArcView::getFieldNames(OGRFeature* poFeature) const {
519 std::vector<std::string> fields;
520 for (int i = 0; i < poFeature->GetFieldCount(); i++) {
521 fields.push_back(poFeature->GetFieldDefnRef(i)->GetNameRef());
522 }
523 return fields;
524}
525
526void
527NIImporter_ArcView::addParams(NBEdge* edge, OGRFeature* poFeature, const std::vector<std::string>& params) const {
528 for (const std::string& p : params) {
529 int index = poFeature->GetDefnRef()->GetFieldIndex(p.c_str());
530 if (index >= 0 && poFeature->IsFieldSet(index)) {
531 edge->setParameter(p, poFeature->GetFieldAsString(index));
532 }
533 }
534}
535
536#endif
537
538
539/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition: MsgHandler.h:266
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:267
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:274
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TL(string)
Definition: MsgHandler.h:282
#define PROGRESS_DONE_MESSAGE()
Definition: MsgHandler.h:270
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition: MsgHandler.h:269
LaneSpreadFunction
Numbers representing special SUMO-XML-attribute values Information how the edge's lateral offset shal...
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
static bool isReadable(std::string path)
Checks whether the given file is readable.
Definition: FileHelpers.cpp:51
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
Definition: GeoConvHelper.h:84
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
Definition: MsgHandler.cpp:79
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:274
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
Definition: NBEdgeCont.cpp:177
The representation of a single edge during network building.
Definition: NBEdge.h:92
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:4100
NBNode * getToNode() const
Returns the destination node of the edge.
Definition: NBEdge.h:552
static const double UNSPECIFIED_FRICTION
unspecified lane friction
Definition: NBEdge.h:366
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition: NBEdge.h:787
const std::string & getID() const
Definition: NBEdge.h:1526
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
Definition: NBEdge.cpp:968
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition: NBEdge.h:545
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition: NBEdge.h:360
Instance responsible for building networks.
Definition: NBNetBuilder.h:107
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Definition: NBNetBuilder.h:144
NBEdgeCont & getEdgeCont()
Definition: NBNetBuilder.h:139
NBTypeCont & getTypeCont()
Returns a reference to the type container.
Definition: NBNetBuilder.h:149
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
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:91
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
Definition: NBNodeCont.cpp:120
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:2465
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:500
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
Definition: NBTypeCont.cpp:511
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
Definition: NBTypeCont.cpp:494
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
Definition: NBTypeCont.cpp:561
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
Definition: NBTypeCont.cpp:549
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
Definition: NBTypeCont.cpp:303
bool getEdgeTypeIsOneWay(const std::string &edgeType) const
Returns whether edges are one-way per default for the given edgeType.
Definition: NBTypeCont.cpp:517
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:59
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:37
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 std::string &what, const std::string &by)
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.
Definition: StringUtils.cpp:55