Line data Source code
1 : #include <rapidxml.hpp> 2 : #include <rapidxml_utils.hpp> 3 : 4 : #include "data/SUMO/Additionals/Location.hpp" 5 : 6 : using namespace std; 7 : using namespace rapidxml; 8 : using namespace SUMO::Additionals; 9 : using namespace utils::stringify; 10 : 11 0 : SUMO::Coord Location::center() const { 12 0 : return Coord( 13 0 : (convBoundary.first.X + convBoundary.second.X) / 2, 14 0 : (convBoundary.first.Y + convBoundary.second.Y) / 2 15 0 : ); 16 : } 17 : 18 0 : SUMO::Coord Location::size() const { 19 0 : return Coord( 20 0 : convBoundary.second.X - convBoundary.first.X, 21 0 : convBoundary.second.Y - convBoundary.first.Y 22 0 : ); 23 : } 24 : 25 4 : void Location::loadFromXMLNode(const rapidxml::xml_node<> &node) { 26 4 : xml_attribute<> *netOffsetAttr = node.first_attribute("netOffset"); 27 4 : assert(netOffsetAttr != nullptr); 28 4 : netOffset = stringify<SUMO::Coord>::fromString(netOffsetAttr->value()); 29 : 30 4 : xml_attribute<> *convBoundaryAttr = node.first_attribute("convBoundary"); 31 4 : assert(convBoundaryAttr != nullptr); 32 4 : convBoundary = stringify<pair<Coord, Coord>>::fromString(convBoundaryAttr->value()); 33 : 34 4 : xml_attribute<> *origBoundaryAttr = node.first_attribute("origBoundary"); 35 4 : assert(origBoundaryAttr != nullptr); 36 4 : origBoundary = stringify<pair<Coord, Coord>>::fromString(origBoundaryAttr->value()); 37 : 38 4 : xml_attribute<> *projParameterAttr = node.first_attribute("projParameter"); 39 4 : assert(projParameterAttr != nullptr); 40 4 : projParameter = projParameterAttr->value(); 41 4 : }