Skip to content

Commit

Permalink
reverting code changes. refs #14625
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Apr 2, 2024
1 parent ac1b8d1 commit 0db8a97
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 89 deletions.
2 changes: 1 addition & 1 deletion src/netbuild/NBTypeCont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ NBTypeCont::LaneTypeDefinition::LaneTypeDefinition(const LaneTypeDefinition* lan

NBTypeCont::EdgeTypeDefinition::EdgeTypeDefinition() :
speed(13.89), friction(NBEdge::UNSPECIFIED_FRICTION), priority(-1),
permissions(SVCAll),
permissions(SVC_UNSPECIFIED),
spreadType(LaneSpreadFunction::RIGHT),
oneWay(true), discard(false),
width(NBEdge::UNSPECIFIED_WIDTH),
Expand Down
5 changes: 0 additions & 5 deletions src/netimport/NIImporter_SUMO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ NIImporter_SUMO::_loadNetwork(OptionsCont& oc) {
// assign further lane attributes (edges are built)
EdgeVector toRemove;
const bool dismissVclasses = oc.getBool("dismiss-vclasses");
const bool edgeTypePermissions = myNetworkVersion >= MMVersion(1, 20);
const NBTypeCont& tc = myTypesHandler.getTypeCont();
for (std::map<std::string, EdgeAttrs*>::const_iterator i = myEdges.begin(); i != myEdges.end(); ++i) {
EdgeAttrs* ed = (*i).second;
NBEdge* nbe = ed->builtEdge;
Expand Down Expand Up @@ -239,9 +237,6 @@ NIImporter_SUMO::_loadNetwork(OptionsCont& oc) {
// allow/disallow XXX preferred
if (!dismissVclasses) {
nbe->setPermissions(parseVehicleClasses(lane->allow, lane->disallow, myNetworkVersion), fromLaneIndex);
if (lane->allow == "" && lane->disallow == "" && edgeTypePermissions) {
nbe->setPermissions(tc.getEdgeTypePermissions(nbe->getTypeID()));
}
}
nbe->setPermittedChanging(fromLaneIndex, parseVehicleClasses(lane->changeLeft, ""), parseVehicleClasses(lane->changeRight, ""));
// width, offset
Expand Down
4 changes: 0 additions & 4 deletions src/netimport/NIXMLTypesHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ class NIXMLTypesHandler : public SUMOSAXHandler {

//@}

const NBTypeCont& getTypeCont() {
return myTypeCont;
}

private:
/// @brief The type container to fill
NBTypeCont& myTypeCont;
Expand Down
24 changes: 5 additions & 19 deletions src/netload/NLHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ NLHandler::myStartElement(int element,
addRoundabout(attrs);
break;
case SUMO_TAG_TYPE: {
addEdgeType(attrs);
bool ok = true;
myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
break;
}
case SUMO_TAG_RESTRICTION: {
Expand Down Expand Up @@ -450,7 +451,7 @@ NLHandler::beginEdgeParsing(const SUMOSAXAttributes& attrs) {
// get the street name
const std::string streetName = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
// get the edge type
myCurrentEdgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
const std::string edgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, id.c_str(), ok, "");
// get the edge priority (only for visualization)
const int priority = attrs.getOpt<int>(SUMO_ATTR_PRIORITY, id.c_str(), ok, -1); // default taken from netbuild/NBFrame option 'default.priority'
// get the bidi-edge
Expand All @@ -464,7 +465,7 @@ NLHandler::beginEdgeParsing(const SUMOSAXAttributes& attrs) {
}
//
try {
myEdgeControlBuilder.beginEdgeParsing(id, func, streetName, myCurrentEdgeType, priority, bidi, distance);
myEdgeControlBuilder.beginEdgeParsing(id, func, streetName, edgeType, priority, bidi, distance);
} catch (InvalidArgument& e) {
WRITE_ERROR(e.what());
myCurrentIsBroken = true;
Expand Down Expand Up @@ -535,13 +536,7 @@ NLHandler::addLane(const SUMOSAXAttributes& attrs) {
myCurrentIsBroken = true;
return;
}
SVCPermissions permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
if (allow == "" && disallow == "" && myNetworkVersion >= MMVersion(1, 20)) {
auto it = myEdgeTypePermissions.find(myCurrentEdgeType);
if (it != myEdgeTypePermissions.end()) {
permissions = it->second;
}
}
const SVCPermissions permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
SVCPermissions changeLeft = parseVehicleClasses(changeLeftS, "", myNetworkVersion);
SVCPermissions changeRight = parseVehicleClasses(changeRightS, "", myNetworkVersion);
if (MSGlobals::gLefthand) {
Expand Down Expand Up @@ -1825,14 +1820,5 @@ NLHandler::addPredecessorConstraint(int element, const SUMOSAXAttributes& attrs,
return result;
}

void
NLHandler::addEdgeType(const SUMOSAXAttributes& attrs) {
bool ok = true;
myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, myCurrentTypeID.c_str(), ok, "", false);
const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, myCurrentTypeID.c_str(), ok, "");
SVCPermissions permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
myEdgeTypePermissions[myCurrentTypeID] = permissions;
}

/****************************************************************************/
9 changes: 0 additions & 9 deletions src/netload/NLHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,6 @@ class NLHandler : public MSRouteHandler {
/// adds a phase to the traffic lights logic currently build
void addPhase(const SUMOSAXAttributes& attrs);

/// adds an edge type
void addEdgeType(const SUMOSAXAttributes& attrs);

/// adds a switching condition to the traffic lights logic currently build
void addCondition(const SUMOSAXAttributes& attrs);

Expand Down Expand Up @@ -341,9 +338,6 @@ class NLHandler : public MSRouteHandler {
/// The id of the currently processed edge type
std::string myCurrentTypeID;

/// The type id of the currently processed edge
std::string myCurrentEdgeType;

/// The network offset
Position myNetworkOffset;

Expand Down Expand Up @@ -393,9 +387,6 @@ class NLHandler : public MSRouteHandler {

int myPreviousEdgeIdx = 0;

/// @brief the permissions for each loaded edge type
std::map<std::string, SVCPermissions> myEdgeTypePermissions;

private:
/** invalid copy constructor */
NLHandler(const NLHandler& s);
Expand Down
19 changes: 6 additions & 13 deletions src/netwrite/NWWriter_SUMO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ NWWriter_SUMO::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) {
const NBNodeCont& nc = nb.getNodeCont();
const NBEdgeCont& ec = nb.getEdgeCont();
const NBDistrictCont& dc = nb.getDistrictCont();
const NBTypeCont& tc = nb.getTypeCont();

// write network offsets and projection
GeoConvHelper::writeLocation(device);
Expand All @@ -142,7 +141,7 @@ NWWriter_SUMO::writeNetwork(const OptionsCont& oc, NBNetBuilder& nb) {
// write edges with lanes and connected edges
bool noNames = !oc.getBool("output.street-names");
for (std::map<std::string, NBEdge*>::const_iterator i = ec.begin(); i != ec.end(); ++i) {
writeEdge(device, *(*i).second, noNames, tc);
writeEdge(device, *(*i).second, noNames);
}
device.lf();

Expand Down Expand Up @@ -472,7 +471,7 @@ NWWriter_SUMO::getInternalBidi(const NBEdge* e, const NBEdge::Connection& k, dou
}

void
NWWriter_SUMO::writeEdge(OutputDevice& into, const NBEdge& e, bool noNames, const NBTypeCont& tc) {
NWWriter_SUMO::writeEdge(OutputDevice& into, const NBEdge& e, bool noNames) {
// write the edge's begin
into.openTag(SUMO_TAG_EDGE).writeAttr(SUMO_ATTR_ID, e.getID());
into.writeAttr(SUMO_ATTR_FROM, e.getFromNode()->getID());
Expand Down Expand Up @@ -515,23 +514,18 @@ NWWriter_SUMO::writeEdge(OutputDevice& into, const NBEdge& e, bool noNames, cons
length = (length + e.getBidiEdge()->getFinalLength()) / 2;
}
double startOffset = e.isBidiRail() ? e.getTurnDestination(true)->getEndOffset() : 0;
SVCPermissions edgeTypePermissions = tc.getEdgeTypePermissions(e.getTypeID());
for (int i = 0; i < (int) lanes.size(); i++) {
const NBEdge::Lane& l = lanes[i];
StopOffset stopOffset;
if (l.laneStopOffset != e.getEdgeStopOffset()) {
stopOffset = l.laneStopOffset;
}
const bool defaultPermissions = l.permissions == edgeTypePermissions;
const bool explicitAll = !defaultPermissions && l.permissions == SVCAll;
writeLane(into, e.getLaneID(i), l.speed, l.friction,
defaultPermissions ? SVC_UNSPECIFIED : l.permissions,
l.preferred,
l.permissions, l.preferred,
l.changeLeft, l.changeRight,
startOffset, l.endOffset,
stopOffset, l.width, l.shape, &l,
length, i, l.oppositeID, l.type, l.accelRamp, l.customShape.size() > 0,
explicitAll);
length, i, l.oppositeID, l.type, l.accelRamp, l.customShape.size() > 0);
}
// close the edge
e.writeParams(into);
Expand All @@ -549,15 +543,14 @@ NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& lID,
const Parameterised* params, double length, int index,
const std::string& oppositeID,
const std::string& type,
bool accelRamp, bool customShape,
bool explicitAll) {
bool accelRamp, bool customShape) {
// 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, explicitAll);
writePermissions(into, permissions);
}
writePreferences(into, preferred);
// some further information
Expand Down
5 changes: 2 additions & 3 deletions src/netwrite/NWWriter_SUMO.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class NWWriter_SUMO {
* @param[in] noNames Whether names shall be ignored
* @see writeLane()
*/
static void writeEdge(OutputDevice& into, const NBEdge& e, bool noNames, const NBTypeCont& tc);
static void writeEdge(OutputDevice& into, const NBEdge& e, bool noNames);


/** @brief Writes a lane (<lane ...) of an edge
Expand All @@ -151,8 +151,7 @@ class NWWriter_SUMO {
const Parameterised* params, double length, int index,
const std::string& oppositeID, const std::string& type,
bool accelRamp = false,
bool customShape = false,
bool explicitAll = false);
bool customShape = false);


/** @brief Writes a junction (<junction ...)
Expand Down
6 changes: 3 additions & 3 deletions src/netwrite/NWWriter_XML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ NWWriter_XML::writeNetwork(const OptionsCont& oc, const std::string& prefix, NBN
if (nb.getTypeCont().size() > 0) {
writeTypes(prefix, nb.getEdgeCont(), nb.getTypeCont());
}
writeEdgesAndConnections(oc, prefix, nb.getNodeCont(), nb.getEdgeCont(), nb.getTypeCont());
writeEdgesAndConnections(oc, prefix, nb.getNodeCont(), nb.getEdgeCont());
writeTrafficLights(prefix, nb.getTLLogicCont(), nb.getEdgeCont());
}
if (oc.isSet("junctions.join-output")) {
Expand Down Expand Up @@ -184,7 +184,7 @@ NWWriter_XML::writeTypes(const std::string& prefix, NBEdgeCont& ec, NBTypeCont&


void
NWWriter_XML::writeEdgesAndConnections(const OptionsCont& oc, const std::string& prefix, NBNodeCont& nc, NBEdgeCont& ec, const NBTypeCont& tc) {
NWWriter_XML::writeEdgesAndConnections(const OptionsCont& oc, const std::string& prefix, NBNodeCont& nc, NBEdgeCont& ec) {
const GeoConvHelper& gch = GeoConvHelper::getFinal();
bool useGeo = oc.exists("proj.plain-geo") && oc.getBool("proj.plain-geo");
const bool geoAccuracy = useGeo || gch.usingInverseGeoProjection();
Expand Down Expand Up @@ -247,7 +247,6 @@ NWWriter_XML::writeEdgesAndConnections(const OptionsCont& oc, const std::string&
edevice.writeAttr(SUMO_ATTR_ENDOFFSET, e->getEndOffset());
}
if (!e->hasLaneSpecificPermissions()) {
// always write permissions because we don't know whether the types file will be available
writePermissions(edevice, e->getPermissions(0));
}
if (!e->hasLaneSpecificStopOffsets() && e->getEdgeStopOffset().isDefined()) {
Expand Down Expand Up @@ -510,4 +509,5 @@ NWWriter_XML::writeShape(OutputDevice& out, const GeoConvHelper& gch, PositionVe
}
}


/****************************************************************************/
2 changes: 1 addition & 1 deletion src/netwrite/NWWriter_XML.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class NWWriter_XML {
* @param[in] oc The options to use
* @param[in] nb The network build from which to read data
*/
static void writeEdgesAndConnections(const OptionsCont& oc, const std::string& prefix, NBNodeCont& nc, NBEdgeCont& ec, const NBTypeCont& tc);
static void writeEdgesAndConnections(const OptionsCont& oc, const std::string& prefix, NBNodeCont& nc, NBEdgeCont& ec);


/** @brief Writes the traffic lights file
Expand Down
19 changes: 2 additions & 17 deletions src/router/RONetHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ RONetHandler::myStartElement(int element,
parseDistrictEdge(attrs, false);
break;
case SUMO_TAG_TYPE: {
parseEdgeType(attrs);
bool ok = true;
myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
break;
}
case SUMO_TAG_RESTRICTION: {
Expand Down Expand Up @@ -203,7 +204,6 @@ RONetHandler::parseEdge(const SUMOSAXAttributes& attrs) {
// set the type
myCurrentEdge->setRestrictions(myNet.getRestrictions(attrs.getOpt<std::string>(SUMO_ATTR_TYPE, myCurrentName.c_str(), ok, "")));
myCurrentEdge->setFunction(func);
myCurrentEdgeType = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, myCurrentName.c_str(), ok, "");

if (myNet.addEdge(myCurrentEdge)) {
fromNode->addOutgoing(myCurrentEdge);
Expand Down Expand Up @@ -246,12 +246,6 @@ RONetHandler::parseLane(const SUMOSAXAttributes& attrs) {
// get the length
// get the vehicle classes
SVCPermissions permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
if (allow == "" && disallow == "" && myNetworkVersion >= MMVersion(1, 20)) {
auto it = myEdgeTypePermissions.find(myCurrentEdgeType);
if (it != myEdgeTypePermissions.end()) {
permissions = it->second;
}
}
if (permissions != SVCAll) {
myNet.setPermissionsFound();
}
Expand Down Expand Up @@ -435,14 +429,5 @@ RONetHandler::setLocation(const SUMOSAXAttributes& attrs) {
}
}

void
RONetHandler::parseEdgeType(const SUMOSAXAttributes& attrs) {
bool ok = true;
myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, myCurrentTypeID.c_str(), ok, "", false);
const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, myCurrentTypeID.c_str(), ok, "");
SVCPermissions permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
myEdgeTypePermissions[myCurrentTypeID] = permissions;
}

/****************************************************************************/
8 changes: 0 additions & 8 deletions src/router/RONetHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ class RONetHandler : public SUMOSAXHandler {
*/
virtual void parseLane(const SUMOSAXAttributes& attrs);

/// adds an edge type
void parseEdgeType(const SUMOSAXAttributes& attrs);

/** @brief Parses a junction's position
*
Expand Down Expand Up @@ -206,9 +204,6 @@ class RONetHandler : public SUMOSAXHandler {
/// @brief The currently built edge
ROEdge* myCurrentEdge;

/// The type id of the currently processed edge
std::string myCurrentEdgeType;

/// @brief The currently built stopping place
SUMOVehicleParameter::Stop* myCurrentStoppingPlace;

Expand All @@ -221,9 +216,6 @@ class RONetHandler : public SUMOSAXHandler {
/// @brief temporary storage for bidi attributes (to be resolved after loading all edges)
std::map<ROEdge*, std::string> myBidiEdges;

/// @brief the permissions for each loaded edge type
std::map<std::string, SVCPermissions> myEdgeTypePermissions;

private:
/// @brief Invalidated copy constructor
RONetHandler(const RONetHandler& src);
Expand Down
5 changes: 1 addition & 4 deletions src/utils/common/SUMOVehicleClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,8 @@ parseVehicleClasses(const std::vector<std::string>& allowedS) {


void
writePermissions(OutputDevice& into, SVCPermissions permissions, bool explicitAll) {
writePermissions(OutputDevice& into, SVCPermissions permissions) {
if (permissions == SVCAll) {
if (explicitAll) {
into.writeAttr(SUMO_ATTR_ALLOW, VehicleClassNameAll);
}
return;
} else if (permissions == 0) {
into.writeAttr(SUMO_ATTR_DISALLOW, VehicleClassNameAll);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/common/SUMOVehicleClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ extern SVCPermissions parseVehicleClasses(const std::vector<std::string>& allowe
extern SVCPermissions invertPermissions(SVCPermissions permissions);

/// @brief writes allowed disallowed attributes if needed;
extern void writePermissions(OutputDevice& into, SVCPermissions permissions, bool explicitAll = false);
extern void writePermissions(OutputDevice& into, SVCPermissions permissions);

/// @brief writes allowed disallowed attributes if needed;
extern void writePreferences(OutputDevice& into, SVCPermissions preferred);
Expand Down
1 change: 0 additions & 1 deletion src/utils/common/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ StringUtils::toBool(const std::string& sData) {
MMVersion
StringUtils::toVersion(const std::string& sData) {
std::vector<std::string> parts = StringTokenizer(sData, ".").getVector();
assert(parts.size() == 2);
return MMVersion(toInt(parts.front()), toDouble(parts.back()));
}

Expand Down

0 comments on commit 0db8a97

Please sign in to comment.