Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NIImporter_ArcView.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2023 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_ERRORF(TL("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_ERRORF(TL("Needed field '%' (street-id) is missing."), id);
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_ERRORF(TL("Needed field '%' (from node id) is missing."), from_node);
199 from_node = "";
200 }
201 if (!getStringEntry(poFeature, "shapefile.to-id", "NREF_IN_ID", true, to_node)) {
202 WRITE_ERRORF(TL("Needed field '%' (to node id) is missing."), to_node);
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 bool oneway = myTypeCont.knows(type) ? myTypeCont.getEdgeTypeIsOneWay(type) : false;
221 double speed = getSpeed(*poFeature, id);
222 int nolanes = getLaneNo(*poFeature, id, speed);
223 int priority = getPriority(*poFeature, id);
224 double width = getLaneWidth(*poFeature, id, nolanes);
225 double length = getLength(*poFeature, id);
226 if (nolanes <= 0 || speed <= 0) {
227 if (myOptions.getBool("shapefile.use-defaults-on-failure")) {
228 nolanes = nolanes <= 0 ? myTypeCont.getEdgeTypeNumLanes(type) : nolanes;
229 speed = speed <= 0 ? myTypeCont.getEdgeTypeSpeed(type) : speed;
230 } else {
231 const std::string lanesField = myOptions.isSet("shapefile.laneNumber") ? myOptions.getString("shapefile.laneNumber") : "nolanes";
232 const std::string speedField = myOptions.isSet("shapefile.speed") ? myOptions.getString("shapefile.speed") : "speed";
233 WRITE_ERRORF(TL("Required field '%' or '%' is missing (add fields or set option --shapefile.use-defaults-on-failure)."), lanesField, speedField);
234 WRITE_ERROR("Available fields: " + toString(getFieldNames(poFeature)));
235 OGRFeature::DestroyFeature(poFeature);
236 return;
237 }
238 }
239 if (mySpeedInKMH) {
240 speed /= 3.6;
241 }
242
243
244 // read in the geometry
245 OGRGeometry* poGeometry = poFeature->GetGeometryRef();
246 OGRwkbGeometryType gtype = poGeometry->getGeometryType();
247 if (gtype != wkbLineString && gtype != wkbLineString25D) {
248 OGRFeature::DestroyFeature(poFeature);
249 WRITE_ERRORF(TL("Road geometry must be of type 'linestring' or 'linestring25D' (found '%')"), toString(gtype));
250 return;
251 }
252 OGRLineString* cgeom = (OGRLineString*) poGeometry;
253 if (poCT == nullptr && warnMissingProjection) {
254 int outOfRange = 0;
255 for (int j = 0; j < cgeom->getNumPoints(); j++) {
256 if (fabs(cgeom->getX(j)) > 180 || fabs(cgeom->getY(j)) > 90) {
257 outOfRange++;
258 }
259 }
260 if (2 * outOfRange > cgeom->getNumPoints()) {
261 WRITE_WARNING(TL("No coordinate system found and coordinates look already projected."));
262 GeoConvHelper::init("!", GeoConvHelper::getProcessing().getOffset(), GeoConvHelper::getProcessing().getOrigBoundary(), GeoConvHelper::getProcessing().getConvBoundary());
263 } else {
264 WRITE_WARNING(TL("Could not find geo coordinate system, assuming WGS84."));
265 }
266 warnMissingProjection = false;
267 }
268 if (poCT != nullptr) {
269 // try transform to wgs84
270 cgeom->transform(poCT);
271 }
272
273 PositionVector shape;
274 for (int j = 0; j < cgeom->getNumPoints(); j++) {
275 Position pos(cgeom->getX(j), cgeom->getY(j), cgeom->getZ(j));
277 WRITE_WARNINGF(TL("Unable to project coordinates for edge '%'."), id);
278 }
279 shape.push_back_noDoublePos(pos);
280 }
281
282 // build from-node
283 NBNode* from = myNodeCont.retrieve(from_node);
284 if (from == nullptr) {
285 Position from_pos = shape[0];
286 from = myNodeCont.retrieve(from_pos, nodeJoinDist);
287 if (from == nullptr) {
288 from = new NBNode(from_node, from_pos);
289 if (!myNodeCont.insert(from)) {
290 WRITE_ERRORF(TL("Node '%' could not be added"), from_node);
291 delete from;
292 continue;
293 }
294 }
295 }
296 // build to-node
297 NBNode* to = myNodeCont.retrieve(to_node);
298 if (to == nullptr) {
299 Position to_pos = shape[-1];
300 to = myNodeCont.retrieve(to_pos, nodeJoinDist);
301 if (to == nullptr) {
302 to = new NBNode(to_node, to_pos);
303 if (!myNodeCont.insert(to)) {
304 WRITE_ERRORF(TL("Node '%' could not be added"), to_node);
305 delete to;
306 continue;
307 }
308 }
309 }
310
311 if (from == to) {
312 WRITE_WARNINGF(TL("Edge '%' connects identical nodes, skipping."), id);
313 continue;
314 }
315
316 // retrieve the information whether the street is bi-directional
317 std::string dir;
318 int index = poFeature->GetDefnRef()->GetFieldIndex("DIR_TRAVEL");
319 if (index >= 0 && poFeature->IsFieldSet(index)) {
320 dir = poFeature->GetFieldAsString(index);
321 }
322 const std::string origID = saveOrigIDs ? id : "";
323 // check for duplicate ids
324 NBEdge* const existing = myEdgeCont.retrieve(id);
325 NBEdge* const existingReverse = myEdgeCont.retrieve("-" + id);
326 if (existing != nullptr || existingReverse != nullptr) {
327 if ((existing != nullptr && existing->getGeometry() == shape)
328 || (existingReverse != nullptr && existingReverse->getGeometry() == shape.reverse())) {
329 WRITE_ERRORF(TL("Edge '%' is not unique."), (existing != nullptr ? id : existingReverse->getID()));
330 } else {
331 if (idIndex.count(id) == 0) {
332 idIndex[id] = 0;
333 }
334 idIndex[id]++;
335 idPrefix = id;
336 id += "#" + toString(idIndex[id]);
337 if (warnNotUnique) {
338 WRITE_WARNINGF(TL("Edge '%' is not unique. Renaming subsequent edge to '%'."), idPrefix, id);
339 warnNotUnique = false;
340 }
341 }
342 }
343 // add positive direction if wanted
344 if (dir == "B" || dir == "F" || dir == "" || myOptions.getBool("shapefile.all-bidirectional")) {
345 if (myEdgeCont.retrieve(id) == 0) {
346 LaneSpreadFunction spread = dir == "B" || dir == "FALSE" ? LaneSpreadFunction::RIGHT : LaneSpreadFunction::CENTER;
347 NBEdge* edge = new NBEdge(id, from, to, type, speed, NBEdge::UNSPECIFIED_FRICTION, nolanes, priority, width, NBEdge::UNSPECIFIED_OFFSET, shape, spread, name, origID);
349 edge->setLoadedLength(length);
350 myEdgeCont.insert(edge);
351 checkSpread(edge);
352 addParams(edge, poFeature, params);
353 } else {
354 WRITE_ERRORF(TL("Could not create edge '%'. An edge with the same id already exists."), id);
355 }
356 }
357 // add negative direction if wanted
358 if ((dir == "B" || dir == "T" || myOptions.getBool("shapefile.all-bidirectional")) && !oneway) {
359 if (myEdgeCont.retrieve("-" + id) == 0) {
360 LaneSpreadFunction spread = dir == "B" || dir == "FALSE" ? LaneSpreadFunction::RIGHT : LaneSpreadFunction::CENTER;
361 NBEdge* edge = new NBEdge("-" + id, to, from, type, speed, NBEdge::UNSPECIFIED_FRICTION, nolanes, priority, width, NBEdge::UNSPECIFIED_OFFSET, shape.reverse(), spread, name, origID);
363 edge->setLoadedLength(length);
364 myEdgeCont.insert(edge);
365 checkSpread(edge);
366 addParams(edge, poFeature, params);
367 } else {
368 WRITE_ERRORF(TL("Could not create edge '-%'. An edge with the same id already exists."), id);
369 }
370 }
371 //
372 OGRFeature::DestroyFeature(poFeature);
373 featureIndex++;
374 }
375#if GDAL_VERSION_MAJOR < 2
376 OGRDataSource::DestroyDataSource(poDS);
377#else
378 GDALClose(poDS);
379#endif
381#else
382 WRITE_ERROR(TL("SUMO was compiled without GDAL support."));
383#endif
384}
385
386#ifdef HAVE_GDAL
387double
388NIImporter_ArcView::getSpeed(OGRFeature& poFeature, const std::string& edgeid) {
389 if (myOptions.isSet("shapefile.speed")) {
390 int index = poFeature.GetDefnRef()->GetFieldIndex(myOptions.getString("shapefile.speed").c_str());
391 if (index >= 0 && poFeature.IsFieldSet(index)) {
392 const double speed = poFeature.GetFieldAsDouble(index);
393 if (speed <= 0) {
394 WRITE_WARNING("invalid value for field: '"
395 + myOptions.getString("shapefile.speed")
396 + "': '" + std::string(poFeature.GetFieldAsString(index)) + "'");
397 } else {
398 return speed;
399 }
400 }
401 }
402 if (myOptions.isSet("shapefile.type-id")) {
403 return myTypeCont.getEdgeTypeSpeed(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
404 }
405 // try to get definitions as to be found in SUMO-XML-definitions
406 // idea by John Michael Calandrino
407 int index = poFeature.GetDefnRef()->GetFieldIndex("speed");
408 if (index >= 0 && poFeature.IsFieldSet(index)) {
409 return (double) poFeature.GetFieldAsDouble(index);
410 }
411 index = poFeature.GetDefnRef()->GetFieldIndex("SPEED");
412 if (index >= 0 && poFeature.IsFieldSet(index)) {
413 return (double) poFeature.GetFieldAsDouble(index);
414 }
415 // try to get the NavTech-information
416 index = poFeature.GetDefnRef()->GetFieldIndex("SPEED_CAT");
417 if (index >= 0 && poFeature.IsFieldSet(index)) {
418 std::string def = poFeature.GetFieldAsString(index);
419 return NINavTeqHelper::getSpeed(edgeid, def);
420 }
421 return -1;
422}
423
424
425double
426NIImporter_ArcView::getLaneWidth(OGRFeature& poFeature, const std::string& edgeid, int laneNumber) {
427 if (myOptions.isSet("shapefile.width")) {
428 int index = poFeature.GetDefnRef()->GetFieldIndex(myOptions.getString("shapefile.width").c_str());
429 if (index >= 0 && poFeature.IsFieldSet(index)) {
430 const double width = poFeature.GetFieldAsDouble(index);
431 if (width <= 0) {
432 WRITE_WARNING("invalid value for field: '"
433 + myOptions.getString("shapefile.width")
434 + "' of edge '" + edgeid
435 + "': '" + std::string(poFeature.GetFieldAsString(index)) + "'");
436 } else {
437 return width / laneNumber;
438 }
439 }
440 }
441 if (myOptions.isSet("shapefile.type-id")) {
442 return myTypeCont.getEdgeTypeWidth(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
443 }
445}
446
447
448
449double
450NIImporter_ArcView::getLength(OGRFeature& poFeature, const std::string& edgeid) {
451 if (myOptions.isSet("shapefile.length")) {
452 int index = poFeature.GetDefnRef()->GetFieldIndex(myOptions.getString("shapefile.length").c_str());
453 if (index >= 0 && poFeature.IsFieldSet(index)) {
454 const double length = poFeature.GetFieldAsDouble(index);
455 if (length <= 0) {
456 WRITE_WARNING("invalid value for field: '"
457 + myOptions.getString("shapefile.length")
458 + "' of edge '" + edgeid
459 + "': '" + std::string(poFeature.GetFieldAsString(index)) + "'");
460 } else {
461 return length;
462 }
463 }
464 }
466}
467
468
469int
470NIImporter_ArcView::getLaneNo(OGRFeature& poFeature, const std::string& edgeid,
471 double speed) {
472 if (myOptions.isSet("shapefile.laneNumber")) {
473 int index = poFeature.GetDefnRef()->GetFieldIndex(myOptions.getString("shapefile.laneNumber").c_str());
474 if (index >= 0 && poFeature.IsFieldSet(index)) {
475 const int laneNumber = poFeature.GetFieldAsInteger(index);
476 if (laneNumber <= 0) {
477 WRITE_WARNING("invalid value for field '"
478 + myOptions.getString("shapefile.laneNumber")
479 + "': '" + std::string(poFeature.GetFieldAsString(index)) + "'");
480 } else {
481 return laneNumber;
482 }
483 }
484 }
485 if (myOptions.isSet("shapefile.type-id")) {
486 return (int) myTypeCont.getEdgeTypeNumLanes(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
487 }
488 // try to get definitions as to be found in SUMO-XML-definitions
489 // idea by John Michael Calandrino
490 int index = poFeature.GetDefnRef()->GetFieldIndex("nolanes");
491 if (index >= 0 && poFeature.IsFieldSet(index)) {
492 return (int) poFeature.GetFieldAsInteger(index);
493 }
494 index = poFeature.GetDefnRef()->GetFieldIndex("NOLANES");
495 if (index >= 0 && poFeature.IsFieldSet(index)) {
496 return (int) poFeature.GetFieldAsInteger(index);
497 }
498 index = poFeature.GetDefnRef()->GetFieldIndex("rnol");
499 if (index >= 0 && poFeature.IsFieldSet(index)) {
500 return (int) poFeature.GetFieldAsInteger(index);
501 }
502 index = poFeature.GetDefnRef()->GetFieldIndex("LANE_CAT");
503 if (index >= 0 && poFeature.IsFieldSet(index)) {
504 std::string def = poFeature.GetFieldAsString(index);
505 return NINavTeqHelper::getLaneNumber(edgeid, def, speed);
506 }
507 return 0;
508}
509
510
511int
512NIImporter_ArcView::getPriority(OGRFeature& poFeature, const std::string& /*edgeid*/) {
513 if (myOptions.isSet("shapefile.type-id")) {
514 return myTypeCont.getEdgeTypePriority(poFeature.GetFieldAsString((char*)(myOptions.getString("shapefile.type-id").c_str())));
515 }
516 // try to get definitions as to be found in SUMO-XML-definitions
517 // idea by John Michael Calandrino
518 int index = poFeature.GetDefnRef()->GetFieldIndex("priority");
519 if (index >= 0 && poFeature.IsFieldSet(index)) {
520 return poFeature.GetFieldAsInteger(index);
521 }
522 index = poFeature.GetDefnRef()->GetFieldIndex("PRIORITY");
523 if (index >= 0 && poFeature.IsFieldSet(index)) {
524 return poFeature.GetFieldAsInteger(index);
525 }
526 // try to determine priority from NavTechs FUNC_CLASS attribute
527 index = poFeature.GetDefnRef()->GetFieldIndex("FUNC_CLASS");
528 if (index >= 0 && poFeature.IsFieldSet(index)) {
529 return poFeature.GetFieldAsInteger(index);
530 }
531 return 0;
532}
533
534void
535NIImporter_ArcView::checkSpread(NBEdge* e) {
536 NBEdge* ret = e->getToNode()->getConnectionTo(e->getFromNode());
537 if (ret != 0) {
540 }
541}
542
543bool
544NIImporter_ArcView::getStringEntry(OGRFeature* poFeature, const std::string& optionName, const char* defaultName, bool prune, std::string& into) {
545 std::string v(defaultName);
546 if (myOptions.isSet(optionName)) {
547 v = myOptions.getString(optionName);
548 }
549 if (poFeature->GetFieldIndex(v.c_str()) < 0) {
550 if (myOptions.isSet(optionName)) {
551 into = v;
552 return false;
553 }
554 into = "";
555 return true;
556 }
557 into = poFeature->GetFieldAsString((char*)v.c_str());
558 if (prune) {
559 into = StringUtils::prune(into);
560 }
561 return true;
562}
563
564std::vector<std::string>
565NIImporter_ArcView::getFieldNames(OGRFeature* poFeature) const {
566 std::vector<std::string> fields;
567 for (int i = 0; i < poFeature->GetFieldCount(); i++) {
568 fields.push_back(poFeature->GetFieldDefnRef(i)->GetNameRef());
569 }
570 return fields;
571}
572
573void
574NIImporter_ArcView::addParams(NBEdge* edge, OGRFeature* poFeature, const std::vector<std::string>& params) const {
575 for (const std::string& p : params) {
576 int index = poFeature->GetDefnRef()->GetFieldIndex(p.c_str());
577 if (index >= 0 && poFeature->IsFieldSet(index)) {
578 edge->setParameter(p, poFeature->GetFieldAsString(index));
579 }
580 }
581}
582
583#endif
584
585
586/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:271
#define WRITE_ERRORF(...)
Definition MsgHandler.h:280
#define WRITE_MESSAGE(msg)
Definition MsgHandler.h:272
#define WRITE_ERROR(msg)
Definition MsgHandler.h:279
#define WRITE_WARNING(msg)
Definition MsgHandler.h:270
#define TL(string)
Definition MsgHandler.h:287
#define PROGRESS_DONE_MESSAGE()
Definition MsgHandler.h:275
#define PROGRESS_BEGIN_MESSAGE(msg)
Definition MsgHandler.h:274
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.
static GeoConvHelper & getProcessing()
the coordinate transformation to use for input conversion and processing
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.
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.
bool insert(NBEdge *edge, bool ignorePrunning=false)
Adds an edge to the dictionary.
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:4195
NBNode * getToNode() const
Returns the destination node of the edge.
Definition NBEdge.h:536
static const double UNSPECIFIED_FRICTION
unspecified lane friction
Definition NBEdge.h:350
const PositionVector & getGeometry() const
Returns the geometry of the edge.
Definition NBEdge.h:771
const std::string & getID() const
Definition NBEdge.h:1515
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
Definition NBEdge.h:359
void setLaneSpreadFunction(LaneSpreadFunction spread)
(Re)sets how the lanes lateral offset shall be computed
Definition NBEdge.cpp:942
NBNode * getFromNode() const
Returns the origin node of the edge.
Definition NBEdge.h:529
static const double UNSPECIFIED_WIDTH
unspecified lane width
Definition NBEdge.h:341
static const double UNSPECIFIED_OFFSET
unspecified lane offset
Definition NBEdge.h:344
void setLoadedLength(double val)
set loaded length
Definition NBEdge.cpp:4247
Instance responsible for building networks.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBEdgeCont & getEdgeCont()
NBTypeCont & getTypeCont()
Returns a reference to the type container.
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:57
bool insert(const std::string &id, const Position &position, NBDistrict *district=0)
Inserts a node into the map.
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
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:2589
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].
int getEdgeTypePriority(const std::string &edgeType) const
Returns the priority for the given edgeType.
int getEdgeTypeNumLanes(const std::string &edgeType) const
Returns the number of lanes for the given edgeType.
double getEdgeTypeWidth(const std::string &edgeType) const
Returns the lane width for the given edgeType [m].
SVCPermissions getEdgeTypePermissions(const std::string &edgeType) const
Returns allowed vehicle classes for the given edgeType.
bool knows(const std::string &edgeType) const
Returns whether the named edgeType is in the container.
bool getEdgeTypeIsOneWay(const std::string &edgeType) const
Returns whether edges are one-way per default for the given edgeType.
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.
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.
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)
Replaces all occurrences of the second string by the third string within the first string.
static std::string prune(const std::string &str)
Removes trailing and leading whitechars.