Line data Source code
1 : #include "data/SUMO/Additionals/Poly.hpp" 2 : 3 : #include <spdlog/spdlog.h> 4 : 5 : #include <rapidxml.hpp> 6 : #include <rapidxml_utils.hpp> 7 : 8 : #include "utils/stringify.hpp" 9 : 10 : using namespace std; 11 : using namespace rapidxml; 12 : using namespace SUMO::Additionals; 13 : using namespace utils::stringify; 14 : 15 0 : Poly::Poly(const string &id_, const SUMO::Shape &shape_): 16 0 : id(id_), shape(shape_) {} 17 : 18 0 : void Poly::loadFromXMLNode(const rapidxml::xml_node<> &node) { 19 0 : xml_attribute<> *typeEl = node.first_attribute("type"); 20 0 : if(typeEl) type = typeEl->value(); 21 : 22 0 : xml_attribute<> *colorEl = node.first_attribute("color"); 23 0 : if(colorEl) 24 0 : color = stringify<color::rgb<float>>::fromString(colorEl->value()); 25 : else 26 0 : spdlog::warn("No color specified for poly '{}'", id); 27 : 28 0 : xml_attribute<> *fillEl = node.first_attribute("fill"); 29 0 : if(fillEl) fill = stringify<bool>::fromString(fillEl->value()); 30 : 31 0 : xml_attribute<> *geoEl = node.first_attribute("geo"); 32 0 : if(geoEl) geo = stringify<bool>::fromString(geoEl->value()); 33 : 34 0 : xml_attribute<> *layerEl = node.first_attribute("layer"); 35 0 : if(layerEl) layer = stringify<float>::fromString(layerEl->value()); 36 : 37 0 : xml_attribute<> *angleEl = node.first_attribute("angle"); 38 0 : if(angleEl) angle = stringify<float>::fromString(angleEl->value()); 39 : 40 0 : xml_attribute<> *imgFileEl = node.first_attribute("imgFile"); 41 0 : if(imgFileEl) imgFile = imgFileEl->value(); 42 : 43 0 : xml_attribute<> *lineWidthEl = node.first_attribute("lineWidth"); 44 0 : if(lineWidthEl) lineWidth = stringify<float>::fromString(lineWidthEl->value()); 45 0 : }