@@ -46,6 +46,7 @@ namespace dsf::mobility {
4646 auto const streetId = csvReader.GetCell <Id>(" id" , i);
4747 auto const dLength = csvReader.GetCell <double >(" length" , i);
4848 auto const name = csvReader.GetCell <std::string>(" name" , i);
49+ auto strType = csvReader.GetCell <std::string>(" type" , i);
4950 geometry::PolyLine polyline;
5051 if (bHasGeometry) {
5152 polyline = geometry::PolyLine (csvReader.GetCell <std::string>(" geometry" , i));
@@ -81,6 +82,24 @@ namespace dsf::mobility {
8182 name,
8283 polyline));
8384
85+ if (!strType.empty ()) {
86+ std::transform (
87+ strType.begin (), strType.end (), strType.begin (), [](unsigned char c) {
88+ return std::tolower (c);
89+ });
90+ if (strType.find (" motorway" ) != std::string::npos) {
91+ edge (streetId)->setRoadType (RoadType::HIGHWAY);
92+ } else if (strType.find (" primary" ) != std::string::npos) {
93+ edge (streetId)->setRoadType (RoadType::PRIMARY);
94+ } else if (strType.find (" secondary" ) != std::string::npos) {
95+ edge (streetId)->setRoadType (RoadType::SECONDARY);
96+ } else if (strType.find (" tertiary" ) != std::string::npos) {
97+ edge (streetId)->setRoadType (RoadType::TERTIARY);
98+ } else if (strType.find (" residential" ) != std::string::npos) {
99+ edge (streetId)->setRoadType (RoadType::RESIDENTIAL);
100+ }
101+ }
102+
84103 if (bHasCoilcode) {
85104 auto strCoilCode = csvReader.GetCell <std::string>(" coilcode" , i);
86105 // Make this lowercase
@@ -175,7 +194,7 @@ namespace dsf::mobility {
175194 std::istreambuf_iterator<char >());
176195 simdjson::dom::parser parser;
177196 simdjson::dom::element root;
178- auto error = parser.parse (json_str).get (root);
197+ auto error = parser.parse (simdjson::padded_string ( json_str) ).get (root);
179198 if (error) {
180199 throw std::runtime_error (" Failed to parse JSON: " +
181200 std::string (simdjson::error_message (error)));
@@ -201,6 +220,31 @@ namespace dsf::mobility {
201220 auto const & edge_length =
202221 static_cast <double >(edge_properties[" length" ].get_double ());
203222
223+ std::string strType{" " };
224+ switch (edge_properties[" type" ].type ()) {
225+ case simdjson::dom::element_type::STRING:
226+ strType =
227+ static_cast <std::string>(edge_properties[" type" ].get_string ().value ());
228+ break ;
229+ case simdjson::dom::element_type::ARRAY: {
230+ auto type_array = edge_properties[" type" ].get_array ().value ();
231+ for (auto const & type_elem : type_array) {
232+ if (!type_elem.is_string ()) {
233+ spdlog::warn (" Edge {} type array contains non-string element" , edge_id);
234+ continue ;
235+ }
236+ strType += static_cast <std::string>(type_elem.get_string ().value ()) + ' |' ;
237+ }
238+ if (!strType.empty ()) {
239+ strType.pop_back (); // Remove last '|'
240+ }
241+ break ;
242+ }
243+ default :
244+ spdlog::warn (" Edge {} type is of unexpected type" , edge_id);
245+ break ;
246+ }
247+
204248 // Robust extraction for maxspeed
205249 double edge_maxspeed = 30.0 ;
206250 if (!edge_properties[" maxspeed" ].is_null ()) {
@@ -245,6 +289,23 @@ namespace dsf::mobility {
245289 edge_lanes,
246290 name,
247291 geometry));
292+ if (!strType.empty ()) {
293+ std::transform (
294+ strType.begin (), strType.end (), strType.begin (), [](unsigned char c) {
295+ return std::tolower (c);
296+ });
297+ if (strType.find (" motorway" ) != std::string::npos) {
298+ edge (edge_id)->setRoadType (RoadType::HIGHWAY);
299+ } else if (strType.find (" primary" ) != std::string::npos) {
300+ edge (edge_id)->setRoadType (RoadType::PRIMARY);
301+ } else if (strType.find (" secondary" ) != std::string::npos) {
302+ edge (edge_id)->setRoadType (RoadType::SECONDARY);
303+ } else if (strType.find (" tertiary" ) != std::string::npos) {
304+ edge (edge_id)->setRoadType (RoadType::TERTIARY);
305+ } else if (strType.find (" residential" ) != std::string::npos) {
306+ edge (edge_id)->setRoadType (RoadType::RESIDENTIAL);
307+ }
308+ }
248309 // Check if there is coilcode property
249310 if (!edge_properties.at_key (" coilcode" ).error ()) {
250311 auto const & epCoilCode = edge_properties[" coilcode" ];
0 commit comments