diff --git a/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp b/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp index 78231591b37b14452fbaaa1d970e0316c13d626a..f76d2e0504dd0d727dad636efe926d2f508839b6 100644 --- a/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp +++ b/OpenRoadEd/OpenDrive/OpenDriveXmlParser.cpp @@ -191,9 +191,22 @@ bool OpenDriveXmlParser::ReadRoadLink (Road* road, TiXmlElement *node, short in if (checker!=TIXML_SUCCESS) { - cout<<"Error parsing Predecessor attributes"<<endl; + cout<<"Error parsing Predecessor attributes for road " << road->GetRoadName() << ": missing element"<<endl; return false; } + else + { + if(elementType!="road" && elementType!="junction") + { + cout<<"Error parsing Predecessor attributes for road " << road->GetRoadName() << ": invalid element type: " << elementType << endl; + return false; + } + if(contactPoint!="start" && contactPoint!="end") + { + cout<<"Error parsing Predecessor attributes for road " << road->GetRoadName() << ": invalid contact point: " << contactPoint << endl; + return false; + } + } road->SetPredecessor(elementType,elementId,contactPoint); return true; @@ -211,9 +224,22 @@ bool OpenDriveXmlParser::ReadRoadLink (Road* road, TiXmlElement *node, short in if (checker!=TIXML_SUCCESS) { - cout<<"Error parsing Successor attributes"<<endl; + cout<<"Error parsing Successor attributes for road " << road->GetRoadName() << ": missing element"<<endl; return false; } + else + { + if(elementType!="road" && elementType!="junction") + { + cout<<"Error parsing Successor attributes for road " << road->GetRoadName() << ": invalid element type: " << elementType << endl; + return false; + } + if(contactPoint!="start" && contactPoint!="end") + { + cout<<"Error parsing Successor attributes for road " << road->GetRoadName() << ": invalid contact point: " << contactPoint << endl; + return false; + } + } road->SetSuccessor(elementType,elementId,contactPoint); return true; } @@ -231,9 +257,22 @@ bool OpenDriveXmlParser::ReadRoadLink (Road* road, TiXmlElement *node, short in if (checker!=TIXML_SUCCESS) { - cout<<"Error parsing Neighbor attributes"<<endl; + cout<<"Error parsing Neighbor attributes for road " << road->GetRoadName() << ": missing element" << endl; return false; } + else + { + if(side!="left" && side!="right") + { + cout<<"Error parsing Neightbor attributes for road " << road->GetRoadName() << ": invalid side: " << side << endl; + return false; + } + if(direction!="same" && direction!="opposite") + { + cout<<"Error parsing Neightbor attributes for road " << road->GetRoadName() << ": invalid direction: " << direction << endl; + return false; + } + } road->SetNeighbor(side,elementId,direction); return true; } @@ -257,6 +296,15 @@ bool OpenDriveXmlParser::ReadRoadType (Road* road, TiXmlElement *node) cout<<"Error parsing Road Type attributes"<<endl; return false; } + else + { + if(type!="unknown" && type!="rural" && type!="motorway" && type!="town" && type!="lowSpeed" && type!="pedestrian" && type!="bicycle" && type!="townExpressway" && type!="townCollector" && + type!="townArterial" && type!="townPrivate" && type!="townLocal" && type!="townPlayStreet") + { + cout<<"Error parsing road type attributes for road " << road->GetRoadName() << ": invalid type: " << type << endl; + return false; + } + } road->AddRoadType(s,type); return true; @@ -285,6 +333,8 @@ bool OpenDriveXmlParser::ReadPlanView(Road* road, TiXmlElement *node) { ReadGeometryBlock(road, subNode,2); //load a polynom spline block } + else + cout<<"Unsupported geometry type for road " << road->GetRoadName() << ": " << subNodeType->ValueStr() << endl; subNode=subNode->NextSiblingElement("geometry"); @@ -579,6 +629,16 @@ bool OpenDriveXmlParser::ReadLane (LaneSection* laneSection, TiXmlElement *node, cout<<"Error parsing Lane attributes"<<endl; return false; } + else + { + if(type!="none" && type!="driving" && type!="stop" && type!="shoulder" && type!="biking" && type!="sidewalk" && type!="border" && type!="restricted" && type!="parking" && type!="bidirectional" && + type!="median" && type!="special1" && type!="special2" && type!="special3" && type!="roadWorks" && type!="tram" && type!="rail" && type!="entry" && type!="exit" && type!="offRamp" && + type!="onRamp" && type!="connectingRamp" && type!="bus" && type!="taxi" && type!="HOV") + { + cout<<"Error parsing lane section attributes: invalid type: " << type << endl; + return false; + } + } //in case "level" is missing, apply default value checker=node->QueryStringAttribute("level",&level); if (checker!=TIXML_SUCCESS) @@ -724,6 +784,15 @@ bool OpenDriveXmlParser::ReadLaneRoadMark(Lane* lane, TiXmlElement *node) cout<<"Error parsing Lane Weight attributes"<<endl; return false; } + else + { + if(type!="none" && type!="solid" && type!="broken" && type!="solid solid" && type!="solid broken" && type!="broken solid" && type!="broken broken" && type!="botts dots" && type!="grass" && + type!="curb" && type!="custom" && type!="edge") + { + cout<<"Error parsing road Mark attributes: invalid type: " << type << endl; + return false; + } + } checker+=node->QueryDoubleAttribute("width",&width); if (checker!=TIXML_SUCCESS) @@ -884,8 +953,26 @@ bool OpenDriveXmlParser::ReadObjects (Road* road, TiXmlElement *node) cout<<"Error parsing road object attributes"<<endl; return false; } + else + { + if(type!="none" && type!="obstacle" && type!="pole" && type!="tree" && type!="vegetation" && type!="barrier" && type!="building" && type!="parkingSpace" && type!="patch" && type!="railing" && + type!="trafficIsland" && type!="crosswalk" && type!="streetLamp" && type!="gantry" && type!="soundBarrier") + { + cout<<"Error parsing road object attributes for road " << road->GetRoadName() << ": invalid type: " << type << endl; + return false; + } + if(dynamic!="yes" && dynamic!="no") + { + cout<<"Error parsing road object attributes for road " << road->GetRoadName() << ": invalid dynamic value: " << type << endl; + return false; + } + if(orientation!="+" && orientation!="-" && orientation!="none") + { + cout<<"Error parsing road object attributes for road " << road->GetRoadName() << ": invalid orientation: " << type << endl; + return false; + } + } - std::cout << "read object " << name << " with id: " << id << std::endl; road->AddObject(); object=road->GetLastObject(); object->SetS(s); @@ -962,8 +1049,20 @@ bool OpenDriveXmlParser::ReadSignals (Road* road, TiXmlElement *node) cout<<"Error parsing road signal attributes"<<endl; return false; } + else + { + if(dynamic!="yes" && dynamic!="no") + { + cout<<"Error parsing road object attributes for road " << road->GetRoadName() << ": invalid dynamic value: " << type << endl; + return false; + } + if(orientation!="+" && orientation!="-" && orientation!="none") + { + cout<<"Error parsing road object attributes for road " << road->GetRoadName() << ": invalid orientation: " << type << endl; + return false; + } + } - std::cout << "read signal " << name << " with id: " << id << std::endl; road->AddSignal(); signal=road->GetLastSignal(); signal->SetS(s); @@ -1074,7 +1173,15 @@ bool OpenDriveXmlParser::ReadJunctionConnection (Junction* junction, TiXmlElemen cout<<"Error parsing Junction Connection attributes"<<endl; return false; } - + else + { + if(contactPoint!="start" && contactPoint!="end") + { + cout<<"Error parsing junction connection attributes for junction " << junction->GetName() << ": invalid contact point: " << contactPoint << endl; + return false; + } + } + junction->AddJunctionConnection(id,incomingRoad,connectingRoad,contactPoint); JunctionConnection* junctionConnetion = junction->GetLastJunctionConnection();