50 #ifdef CHECK_MEMORY_LEAKS 52 #endif // CHECK_MEMORY_LEAKS 54 #define OUTPUT_VERSION "6.5" 68 if (!oc.
isSet(
"dlr-navteq-output")) {
71 std::map<NBEdge*, std::string> internalNodes;
84 strftime(buffer, 80,
"on %c", localtime(&rawtime));
85 device <<
"# Generated " << buffer <<
" by " << oc.
getFullName() <<
"\n";
86 device <<
"# Format matches Extraction version: V" <<
OUTPUT_VERSION <<
" \n";
87 std::stringstream tmp;
89 tmp.seekg(std::ios_base::beg);
92 std::getline(tmp, line);
93 device <<
"# " << line <<
"\n";
108 const SUMOReal geoScale = pow(10.0f, haveGeo ? 5 : 2);
111 WRITE_WARNING(
"DlrNavteq node data will be written in (floating point) cartesian coordinates");
114 device <<
"# NODE_ID\tIS_BETWEEN_NODE\tamount_of_geocoordinates\tx1\ty1\t[x2 y2 ... xn yn]\n";
124 for (std::map<std::string, NBEdge*>::const_iterator i = ec.
begin(); i != ec.
end(); ++i) {
125 if ((*i).second->getGeometry().size() > 2) {
129 device <<
"# [xmin_region] " <<
min.x() <<
"\n";
130 device <<
"# [xmax_region] " <<
max.x() <<
"\n";
131 device <<
"# [ymin_region] " <<
min.y() <<
"\n";
132 device <<
"# [ymax_region] " <<
max.y() <<
"\n";
133 device <<
"# [elements_multinode] " << multinodes <<
"\n";
134 device <<
"# [elements_normalnode] " << nc.
size() <<
"\n";
135 device <<
"# [xmin] " <<
min.x() <<
"\n";
136 device <<
"# [xmax] " <<
max.x() <<
"\n";
137 device <<
"# [ymin] " <<
min.y() <<
"\n";
138 device <<
"# [ymax] " <<
max.y() <<
"\n";
140 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
145 device << n->
getID() <<
"\t0\t1\t" << pos.
x() <<
"\t" << pos.
y() <<
"\n";
148 std::vector<std::string> avoid;
149 std::set<std::string> reservedNodeIDs;
150 const bool numericalIDs = oc.
getBool(
"numerical-ids");
151 if (oc.
isSet(
"reserved-ids")) {
156 std::vector<std::string> avoid2 = ec.
getAllNames();
157 avoid.insert(avoid.end(), avoid2.begin(), avoid2.end());
158 avoid.insert(avoid.end(), reservedNodeIDs.begin(), reservedNodeIDs.end());
161 for (std::map<std::string, NBEdge*>::const_iterator i = ec.
begin(); i != ec.
end(); ++i) {
164 if (geom.size() > 2) {
174 WRITE_WARNING(
"Could not reconstruct shape for edge:'" + e->
getID() +
"' (" + exception.what() +
").");
181 WRITE_WARNING(
"Could not reconstruct shape for edge:'" + e->
getID() +
"' (" + exception.what() +
").");
185 std::string internalNodeID = e->
getID();
187 || (nc.
retrieve(internalNodeID) != 0)
188 || reservedNodeIDs.count(internalNodeID) > 0
192 internalNodeID = idSupplier.
getNext();
194 internalNodeID +=
"_geometry";
197 internalNodes[e] = internalNodeID;
198 device << internalNodeID <<
"\t1\t" << geom.size() - 2;
199 for (
int ii = 1; ii < (int)geom.size() - 1; ++ii) {
203 device <<
"\t" << pos.
x() <<
"\t" << pos.
y();
214 std::map<const std::string, std::string> nameIDs;
218 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";
220 for (std::map<std::string, NBEdge*>::const_iterator i = ec.
begin(); i != ec.
end(); ++i) {
223 const std::string& betweenNodeID = (e->
getGeometry().size() > 2) ? internalNodes[e] :
UNDEFINED;
225 if (oc.
getBool(
"output.street-names")) {
226 const std::string& name = i->second->getStreetName();
227 if (name !=
"" && nameIDs.count(name) == 0) {
229 nameIDs[name] = nameID;
232 device << e->
getID() <<
"\t" 235 << betweenNodeID <<
"\t" 259 if (oc.
getBool(
"output.street-names")) {
263 namesDevice <<
"# NAME_ID\tPERMANENT_ID_INFO\tName\n";
264 namesDevice <<
"# [elements] " << nameIDs.size() <<
"\n";
265 for (std::map<const std::string, std::string>::const_iterator i = nameIDs.begin(); i != nameIDs.end(); ++i) {
279 if (permissions ==
SVCAll) {
280 return "100000000000";
282 std::ostringstream oss;
284 oss << ((permissions & SVC_PASSENGER) > 0 ? 1 : 0);
285 oss << ((permissions & SVC_PASSENGER) > 0 ? 1 : 0);
286 oss << ((permissions & SVC_HOV) > 0 ? 1 : 0);
287 oss << ((permissions & SVC_EMERGENCY) > 0 ? 1 : 0);
288 oss << ((permissions & SVC_TAXI) > 0 ? 1 : 0);
289 oss << ((permissions & (SVC_BUS | SVC_COACH)) > 0 ? 1 : 0);
290 oss << ((permissions & SVC_DELIVERY) > 0 ? 1 : 0);
291 oss << ((permissions & (SVC_TRUCK | SVC_TRAILER)) > 0 ? 1 : 0);
292 oss << ((permissions & SVC_MOTORCYCLE) > 0 ? 1 : 0);
293 oss << ((permissions & SVC_BICYCLE) > 0 ? 1 : 0);
294 oss << ((permissions & SVC_PEDESTRIAN) > 0 ? 1 : 0);
307 type = type.substr(8);
319 }
else if (type ==
"unclassified") {
321 }
else if (type ==
"living_street" || type ==
"residential" || type ==
"road" || type ==
"service" || type ==
"track" || type ==
"cycleway" || type ==
"path" || type ==
"footway") {
399 const int code = (numLanes == 1 ? 1 :
400 (numLanes < 4 ? 2 : 3));
401 return numLanes * 10 + code;
411 }
else if (edge->
getTypeID() ==
"route.ferry") {
424 }
else if (edge->
getTypeID() ==
"highway.service") {
426 }
else if (edge->
getTypeID().find(
"_link") != std::string::npos) {
445 if (zipCode.find_first_of(
" ,;") != std::string::npos) {
446 WRITE_WARNING(
"ambiguous zip code '" + zipCode +
"' for edge '" + edgeID +
"'. (using first value)");
448 std::vector<std::string> ret = st.
getVector();
450 }
else if (zipCode.size() > 16) {
451 WRITE_WARNING(
"long zip code '" + zipCode +
"' for edge '" + edgeID +
"'");
462 const SUMOReal geoScale = pow(10.0f, haveGeo ? 5 : 2);
465 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";
467 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
474 for (EdgeVector::const_iterator it = incoming.begin(); it != incoming.end(); ++it) {
476 device << e->
getID() <<
"\t" 478 <<
"LSA;NODEIDS#" << n->
getID() <<
"#;LOCATION#-1#;\t" 481 << e->
getID() <<
"\n";
494 std::set<std::string> reservedRelIDs;
495 if (oc.
isSet(
"reserved-ids")) {
499 avoid.insert(avoid.end(), reservedRelIDs.begin(), reservedRelIDs.end());
502 device <<
"#No driving allowed from ID1 to ID2 or the complete chain from ID1 to IDn\n";
503 device <<
"#RELATREC_ID\tPERMANENT_ID_INFO\tVALIDITY_PERIOD\tTHROUGH_TRAFFIC\tVEHICLE_TYPE\tNAVTEQ_LINK_ID1\t[NAVTEQ_LINK_ID2 ...]\n";
505 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
509 for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
512 for (EdgeVector::const_iterator k = outgoing.begin(); k != outgoing.end(); ++k) {
518 << idSupplier.
getNext() <<
"\t" 523 << inEdge->
getID() <<
"\t" << outEdge->
getID() <<
"\n";
537 device <<
"#Lane connections related to LINK-IDs and NODE-ID.\n";
538 device <<
"#column format like pointcollection.\n";
539 device <<
"#NODE-ID\tVEHICLE-TYPE\tFROM_LANE\tTO_LANE\tTHROUGH_TRAFFIC\tLINK_IDs[2..*]\n";
541 for (std::map<std::string, NBNode*>::const_iterator i = nc.
begin(); i != nc.
end(); ++i) {
544 for (EdgeVector::const_iterator j = incoming.begin(); j != incoming.end(); ++j) {
547 const std::vector<NBEdge::Connection>& connections = from->
getConnections();
548 for (std::vector<NBEdge::Connection>::const_iterator it_c = connections.begin(); it_c != connections.end(); it_c++) {
551 << n->
getID() <<
"\t" 556 << from->
getID() <<
"\t"
const EdgeVector & getIncomingEdges() const
Returns this node's incoming edges (The edges which yield in this node)
void close()
Closes the device and removes it from the dictionary.
const std::string & getTypeID() const
get ID of type
A structure which describes a connection between edges or lanes.
void cartesian2geo(Position &cartesian) const
Converts the given cartesian (shifted) position to its geo (lat/long) representation.
int toLane
The lane the connections yields in.
std::vector< std::string > getAllNames() const
Returns all ids of known edges.
static int speedInKph(SUMOReal metersPerSecond)
get edge speed rounded to kmh
NBEdge * toEdge
The edge the connections yields in.
static void loadPrefixedIDsFomFile(const std::string &file, const std::string prefix, std::set< std::string > &into)
Add prefixed ids defined in file.
static void writeHeader(OutputDevice &device, const OptionsCont &oc)
write header comments (input paramters, date, etc...)
bool isTLControlled() const
Returns whether this node is controlled by any tls.
SUMOReal ymin() const
Returns minimum y-coordinate.
static int getRoadClass(NBEdge *edge)
get the navteq road class
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
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.
static void writeLinksUnsplitted(const OptionsCont &oc, NBEdgeCont &ec, std::map< NBEdge *, std::string > &internalNodes)
Writes the links_unsplitted file.
SUMOReal xmin() const
Returns minimum x-coordinate.
static void writeProhibitedManoeuvres(const OptionsCont &oc, const NBNodeCont &nc, const NBEdgeCont &ec)
Writes the prohibited_manoeuvres file.
SUMOReal getTotalWidth() const
Returns the combined width of all lanes of this edge.
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
const std::string & getFullName() const
const SVCPermissions SVCAll
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
SUMOReal x() const
Returns the x-position.
static int getSpeedCategoryUpperBound(int kph)
get the SPEED_LIMIT as defined by elmar (upper bound of speed category)
SUMOReal xmax() const
Returns maximum x-coordinate.
A class that stores a 2D geometrical boundary.
#define WRITE_WARNING(msg)
bool isConnectedTo(const NBEdge *e) const
Returns the information whethe a connection to the given edge has been added (or computed) ...
void writeConfiguration(std::ostream &os, const bool filled, const bool complete, const bool addComments, const bool maskDoubleHyphen=false) const
Writes the configuration.
static const std::string UNDEFINED
magic value for undefined stuff
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
const EdgeVector & getOutgoingEdges() const
Returns this node's outgoing edges (The edges which start at this node)
const std::string & getID() const
Returns the id.
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
const Position & getPosition() const
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 end() const
Returns the pointer to the end of the stored edges.
std::string getNext()
Returns the next id.
bool usingGeoProjection() const
Returns whether a transformation from geo to metric coordinates will be performed.
static methods for processing the coordinates conversion for the current net
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
int fromLane
The lane the connections starts at.
A point in 2D or 3D with translation and scaling methods.
NBEdgeCont & getEdgeCont()
int getNumLanes() const
Returns the number of lanes.
static std::string getSinglePostalCode(const std::string &zipCode, const std::string edgeID)
Storage for edges, including some functionality operating on multiple edges.
std::vector< std::string > getAllNames() const
get all node names
std::map< std::string, NBNode * >::const_iterator end() const
Returns the pointer to the end of the stored nodes.
const Boundary & getConvBoundary() const
Returns the converted boundary.
static void writeNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Writes the network into XML-files (nodes, edges, connections, traffic lights)
int getJunctionPriority(const NBNode *const node) const
Returns the junction priority (normalised for the node currently build)
std::vector< std::string > getVector()
std::map< std::string, NBEdge * >::const_iterator begin() const
Returns the pointer to the begin of the stored edges.
SVCPermissions getPermissions(int lane=-1) const
get the union of allowed classes over all lanes or for a specific lane
static std::string getAllowedTypes(SVCPermissions permissions)
build the ascii-bit-vector for column vehicle_type
SUMOReal length() const
Returns the length.
NBNode * getToNode() const
Returns the destination node of the edge.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
Instance responsible for building networks.
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
std::vector< NBEdge * > EdgeVector
container for (sorted) edges
const PositionVector & getGeometry() const
Returns the geometry of the edge.
SUMOReal y() const
Returns the y-position.
A storage for options typed value containers)
void mul(SUMOReal val)
Multiplies both positions with the given value.
static const GeoConvHelper & getFinal()
the coordinate transformation for writing the location element and for tracking the original coordina...
static SUMOReal getGraphLength(NBEdge *edge)
get the length of the edge when measured up to the junction center
NBEdge * getOppositeByID(const std::string &edgeID) const
Returns the edge with negated id if it exists.
LaneSpreadFunction getLaneSpreadFunction() const
Returns how this edge's lanes' lateral offset is computed.
Represents a single node (junction) during network building.
static int getBrunnelType(NBEdge *edge)
get the navteq brunnel type
void move2side(SUMOReal amount)
move position vector to side using certain ammount
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.
SUMOReal ymax() const
Returns maximum y-coordinate.
int size() const
Returns the number of nodes stored in this container.
void push_back_noDoublePos(const Position &p)
insert in back a non double position
NBNode * retrieve(const std::string &id) const
Returns the node with the given name.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Container for nodes during the netbuilding process.
int getInt(const std::string &name) const
Returns the int-value of the named option (only for Option_Integer)
const std::vector< Connection > & getConnections() const
Returns the connections.
static void writeNodesUnsplitted(const OptionsCont &oc, NBNodeCont &nc, NBEdgeCont &ec, std::map< NBEdge *, std::string > &internalNodes)
Writes the nodes_unsplitted file.
std::map< std::string, NBNode * >::const_iterator begin() const
Returns the pointer to the begin of the stored nodes.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
NBNode * getFromNode() const
Returns the origin node of the edge.