void NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& eID, const std::string& lID, SUMOReal speed, SVCPermissions permissions, SVCPermissions preferred, SUMOReal endOffset, SUMOReal width, PositionVector shape, const std::string& origID, SUMOReal length, unsigned int index, bool origNames, const NBNode* node) { // output the lane's attributes into.openTag(SUMO_TAG_LANE).writeAttr(SUMO_ATTR_ID, lID); // the first lane of an edge will be the depart lane into.writeAttr(SUMO_ATTR_INDEX, index); // write the list of allowed/disallowed vehicle classes if (permissions != SVC_UNSPECIFIED) { writePermissions(into, permissions); } writePreferences(into, preferred); // some further information if (speed == 0) { WRITE_WARNING("Lane #" + toString(index) + " of edge '" + eID + "' has a maximum velocity of 0."); } else if (speed < 0) { throw ProcessError("Negative velocity (" + toString(speed) + " on edge '" + eID + "' lane#" + toString(index) + "."); } if (endOffset > 0) { length = length - endOffset; } into.writeAttr(SUMO_ATTR_SPEED, speed); into.writeAttr(SUMO_ATTR_LENGTH, length); if (endOffset != NBEdge::UNSPECIFIED_OFFSET) { into.writeAttr(SUMO_ATTR_ENDOFFSET, endOffset); } if (width != NBEdge::UNSPECIFIED_WIDTH) { into.writeAttr(SUMO_ATTR_WIDTH, width); } if (node != 0) { const NBNode::CustomShapeMap& cs = node->getCustomLaneShapes(); NBNode::CustomShapeMap::const_iterator it = cs.find(lID); if (it != cs.end()) { shape = it->second; into.writeAttr(SUMO_ATTR_CUSTOMSHAPE, true); } } into.writeAttr(SUMO_ATTR_SHAPE, endOffset > 0 ? shape.getSubpart(0, shape.length() - endOffset) : shape); if (origNames && origID != "") { into.openTag(SUMO_TAG_PARAM); into.writeAttr(SUMO_ATTR_KEY, "origId"); into.writeAttr(SUMO_ATTR_VALUE, origID); into.closeTag(); into.closeTag(); } else { into.closeTag(); } }
void NBTypeCont::writeTypes(OutputDevice& into) const { for (TypesCont::const_iterator i = myTypes.begin(); i != myTypes.end(); ++i) { into.openTag(SUMO_TAG_TYPE); into.writeAttr(SUMO_ATTR_ID, i->first); const NBTypeCont::TypeDefinition& type = i->second; if (type.attrs.count(SUMO_ATTR_PRIORITY) > 0) { into.writeAttr(SUMO_ATTR_PRIORITY, type.priority); } if (type.attrs.count(SUMO_ATTR_NUMLANES) > 0) { into.writeAttr(SUMO_ATTR_NUMLANES, type.numLanes); } if (type.attrs.count(SUMO_ATTR_SPEED) > 0) { into.writeAttr(SUMO_ATTR_SPEED, type.speed); } if (type.attrs.count(SUMO_ATTR_DISALLOW) > 0 || type.attrs.count(SUMO_ATTR_ALLOW) > 0) { writePermissions(into, type.permissions); } if (type.attrs.count(SUMO_ATTR_ONEWAY) > 0) { into.writeAttr(SUMO_ATTR_ONEWAY, type.oneWay); } if (type.attrs.count(SUMO_ATTR_DISCARD) > 0) { into.writeAttr(SUMO_ATTR_DISCARD, type.discard); } if (type.attrs.count(SUMO_ATTR_WIDTH) > 0) { into.writeAttr(SUMO_ATTR_WIDTH, type.width); } if (type.attrs.count(SUMO_ATTR_SIDEWALKWIDTH) > 0) { into.writeAttr(SUMO_ATTR_SIDEWALKWIDTH, type.sidewalkWidth); } if (type.attrs.count(SUMO_ATTR_BIKELANEWIDTH) > 0) { into.writeAttr(SUMO_ATTR_BIKELANEWIDTH, type.bikeLaneWidth); } for (std::map<SUMOVehicleClass, SUMOReal>::const_iterator j = type.restrictions.begin(); j != type.restrictions.end(); ++j) { into.openTag(SUMO_TAG_RESTRICTION); into.writeAttr(SUMO_ATTR_VCLASS, getVehicleClassNames(j->first)); into.writeAttr(SUMO_ATTR_SPEED, j->second); into.closeTag(); } into.closeTag(); } if (!myTypes.empty()) { into.lf(); } }
void NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& eID, const std::string& lID, const NBEdge::Lane& lane, SUMOReal length, unsigned int index, bool origNames) { // output the lane's attributes into.openTag(SUMO_TAG_LANE).writeAttr(SUMO_ATTR_ID, lID); // the first lane of an edge will be the depart lane into.writeAttr(SUMO_ATTR_INDEX, index); // write the list of allowed/disallowed vehicle classes writePermissions(into, lane.permissions); writePreferences(into, lane.preferred); // some further information if (lane.speed == 0) { WRITE_WARNING("Lane #" + toString(index) + " of edge '" + eID + "' has a maximum velocity of 0."); } else if (lane.speed < 0) { throw ProcessError("Negative velocity (" + toString(lane.speed) + " on edge '" + eID + "' lane#" + toString(index) + "."); } if (lane.offset > 0) { length = length - lane.offset; } into.writeAttr(SUMO_ATTR_SPEED, lane.speed); into.writeAttr(SUMO_ATTR_LENGTH, length); if (lane.offset != NBEdge::UNSPECIFIED_OFFSET) { into.writeAttr(SUMO_ATTR_ENDOFFSET, lane.offset); } if (lane.width != NBEdge::UNSPECIFIED_WIDTH) { into.writeAttr(SUMO_ATTR_WIDTH, lane.width); } PositionVector shape = lane.shape; if (lane.offset > 0) { shape = shape.getSubpart(0, shape.length() - lane.offset); } into.writeAttr(SUMO_ATTR_SHAPE, shape); if (origNames && lane.origID != "") { into.openTag(SUMO_TAG_PARAM); into.writeAttr(SUMO_ATTR_KEY, "origId"); into.writeAttr(SUMO_ATTR_VALUE, lane.origID); into.closeTag(); into.closeTag(); } else { into.closeTag(); } }