From 70643a9e4821bd11c3f363f1708fe420965467d1 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Fri, 28 Aug 2026 22:17:10 +0200 Subject: Format again --- server/src/datex2.cppm | 142 ++++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 71 deletions(-) (limited to 'server/src/datex2.cppm') diff --git a/server/src/datex2.cppm b/server/src/datex2.cppm index b4c795f..7c20347 100644 --- a/server/src/datex2.cppm +++ b/server/src/datex2.cppm @@ -31,7 +31,7 @@ export struct situation { std::string id; std::optional location = - std::nullopt; // as shown on the map, not used for querying + std::nullopt; // as shown on the map, not used for querying std::vector comments = {}; std::vector> road_closures = {}; }; @@ -54,13 +54,13 @@ export class loader { // ETRS 89 (EPSG:4258) -> WGS 84 (EPSG:4326) bgeo::srs::transformation< - bgeo::srs::static_epsg<4258>, bgeo::srs::static_epsg<4326>> - etrs89_to_wgs84_{}; + bgeo::srs::static_epsg<4258>, bgeo::srs::static_epsg<4326>> + etrs89_to_wgs84_{}; std::multiset warnings_; auto add_location_from_xml(road_closure& rc, pugi::xml_node const& loc_xml) - -> void + -> void { auto loc_xml_type = std::string_view{loc_xml.attribute("xsi:type").value()}; if (loc_xml_type == "loc:ItineraryByIndexedLocations") @@ -79,15 +79,15 @@ export class loader return; auto const srs_name = - std::string_view{loc_gml_xml.attribute("srsName").value()}; + std::string_view{loc_gml_xml.attribute("srsName").value()}; if (srs_name != "WGS 84"sv) { warnings_.insert( - std::format("don't now how to handle the CRS {}", srs_name)); + std::format("don't now how to handle the CRS {}", srs_name)); return; } auto const pos_list_str = - std::string_view{loc_gml_xml.child_value("loc:posList")}; + std::string_view{loc_gml_xml.child_value("loc:posList")}; // lat1 long1 lat2 long2 ... lat(n-1) long(n-1) latn longn auto ls = std::make_shared(); @@ -97,13 +97,13 @@ export class loader for (auto const lat_or_long_str : std::views::split(pos_list_str, " "sv)) { auto mlat_or_long = - util::parse_double(std::string_view{lat_or_long_str}); + util::parse_double(std::string_view{lat_or_long_str}); if (!mlat_or_long) { warnings_.insert( - std::format( - "failed to parse coordinate {:?}", - std::string_view{lat_or_long_str})); + std::format( + "failed to parse coordinate {:?}", + std::string_view{lat_or_long_str})); return; } @@ -131,7 +131,7 @@ export class loader else if (loc_xml_type == "loc:PointLocation") { auto const& coords_xml = - loc_xml.child("loc:pointByCoordinates").child("loc:pointCoordinates"); + loc_xml.child("loc:pointByCoordinates").child("loc:pointCoordinates"); if (!coords_xml) return; @@ -157,28 +157,28 @@ export class loader else { warnings_.insert( - std::format( - "don't know how to hande location of type {}, ignoring", - loc_xml.attribute("xsi:type").value())); + std::format( + "don't know how to hande location of type {}, ignoring", + loc_xml.attribute("xsi:type").value())); return; } } auto handle_road_or_carriageway_or_lane_management( - pugi::xml_node const& record_xml, std::weak_ptr parent) - -> std::optional> + pugi::xml_node const& record_xml, std::weak_ptr parent) + -> std::optional> { auto const type = - std::string_view{record_xml - .child("sit:roadOrCarriagewayOrLaneManagementType") - .child_value()}; + std::string_view{record_xml + .child("sit:roadOrCarriagewayOrLaneManagementType") + .child_value()}; if (type != "carriagewayClosures" && type != "roadClosed") // TODO: checken of er nog andere types fietsers de doorgang zouden // kunnen blokkeren? return std::nullopt; auto const& restricted_vehicle_types_xml = - record_xml.child("sit:forVehiclesWithCharacteristicsOf"); + record_xml.child("sit:forVehiclesWithCharacteristicsOf"); bool likely_restriction_for_bikes = restricted_vehicle_types_xml.empty(); for (auto const vehicle_type_xml : restricted_vehicle_types_xml.children("com:vehicleType")) @@ -199,20 +199,20 @@ export class loader auto const& validity_xml = record_xml.child("sit:validity"); if (validity_xml && validity_xml.child_value("com:validityStatus") - == "definedByValidityTimeSpec"sv) + == "definedByValidityTimeSpec"sv) { auto const& validity_spec_xml = - validity_xml.child("com:validityTimeSpecification"); + validity_xml.child("com:validityTimeSpecification"); auto valid_periods = std::vector{}; auto exception_periods = std::vector{}; // TODO: com:overallEndTime may be missing (according to the DATEX // II v3 data model) - auto const overall_start_time = parse_timestamp( - validity_spec_xml.child_value("com:overallStartTime")); + auto const overall_start_time = + parse_timestamp(validity_spec_xml.child_value("com:overallStartTime")); auto const overall_end_time = - parse_timestamp(validity_spec_xml.child_value("com:overallEndTime")); + parse_timestamp(validity_spec_xml.child_value("com:overallEndTime")); if (overall_start_time && overall_end_time && *overall_start_time < *overall_end_time) { @@ -221,10 +221,10 @@ export class loader for (auto const valid_period_xml : validity_xml.children("com:validPeriod")) { - auto const start_of_period = parse_timestamp( - valid_period_xml.child_value("com:startOfPeriod")); + auto const start_of_period = + parse_timestamp(valid_period_xml.child_value("com:startOfPeriod")); auto const end_of_period = - parse_timestamp(valid_period_xml.child_value("com:endOfPeriod")); + parse_timestamp(valid_period_xml.child_value("com:endOfPeriod")); if (start_of_period && end_of_period && *start_of_period < *end_of_period) { @@ -235,9 +235,9 @@ export class loader validity_xml.children("com:exceptionPeriod")) { auto const start_of_period = parse_timestamp( - exception_period_xml.child_value("com:startOfPeriod")); + exception_period_xml.child_value("com:startOfPeriod")); auto const end_of_period = parse_timestamp( - exception_period_xml.child_value("com:endOfPeriod")); + exception_period_xml.child_value("com:endOfPeriod")); if (start_of_period && end_of_period && *start_of_period < *end_of_period) { @@ -246,19 +246,19 @@ export class loader } validity = - time::period_seq{valid_periods.begin(), valid_periods.end()}.except( - time::period_seq{ - exception_periods.begin(), exception_periods.end() - }); + time::period_seq{valid_periods.begin(), valid_periods.end()}.except( + time::period_seq{ + exception_periods.begin(), exception_periods.end() + }); } else { warnings_.insert( - std::format( - "invalid overall start / end time (start time: {}, end " - "time: {})", - validity_spec_xml.child_value("com:overallStartTime"), - validity_spec_xml.child_value("com:overallEndTime"))); + std::format( + "invalid overall start / end time (start time: {}, end " + "time: {})", + validity_spec_xml.child_value("com:overallStartTime"), + validity_spec_xml.child_value("com:overallEndTime"))); return std::nullopt; } } @@ -272,7 +272,7 @@ export class loader public: [[nodiscard]] auto load_situation_publication(std::string const& filename) - -> situation_publication + -> situation_publication { auto doc = pugi::xml_document{}; if (auto result = doc.load_file(filename.c_str()); !result) @@ -281,10 +281,10 @@ public: } auto payload_xml = doc.child("mc:messageContainer").child("mc:payload"); auto mpublication_time = - parse_timestamp(payload_xml.child_value("com:publicationTime")); + parse_timestamp(payload_xml.child_value("com:publicationTime")); if (!mpublication_time) throw std::runtime_error{ - "provided publication does not name publication time" + "provided publication does not name publication time" }; auto situations = std::vector>{}; @@ -302,26 +302,26 @@ public: for (auto const record_xml : sit_xml.children("sit:situationRecord")) { auto const record_type = - std::string_view{record_xml.attribute("xsi:type").value()}; + std::string_view{record_xml.attribute("xsi:type").value()}; auto const primary_record_types = std::unordered_set{ - "sit:Roadworks", - /* { */ "sit:MaintenanceWorks", - /* | */ "sit:ConstructionWorks", - /* } */ - "sit:Obstruction", - /* { */ "sit:EnvironmentalObstruction", - /* | */ "sit:GeneralObstruction", - /* | */ "sit:InfrastructureDamageObstruction", - /* } */ - "sit:Activity", - /* { */ "sit:PublicEvent", - /* } */ + "sit:Roadworks", + /* { */ "sit:MaintenanceWorks", + /* | */ "sit:ConstructionWorks", + /* } */ + "sit:Obstruction", + /* { */ "sit:EnvironmentalObstruction", + /* | */ "sit:GeneralObstruction", + /* | */ "sit:InfrastructureDamageObstruction", + /* } */ + "sit:Activity", + /* { */ "sit:PublicEvent", + /* } */ }; if (record_type == "sit:RoadOrCarriagewayOrLaneManagement") { - if (auto rc = handle_road_or_carriageway_or_lane_management( - record_xml, sit)) + if (auto rc = + handle_road_or_carriageway_or_lane_management(record_xml, sit)) { sit->road_closures.push_back(*rc); } @@ -335,10 +335,10 @@ public: // (comment_xml.child_value("sit:commentType") // == "internalNote"sv) { auto candidate = std::optional>{}; // (text, language) + std::string_view, std::string_view>>{}; // (text, language) for (auto const comment_value_xml : comment_xml.child("sit:comment") - .child("com:values") - .children("com:value")) + .child("com:values") + .children("com:value")) { if (!candidate || comment_value_xml.attribute("lang").value() == "nl"sv @@ -346,8 +346,8 @@ public: && comment_value_xml.attribute("lang").value() == "nl"sv)) { candidate = std::make_pair( - comment_value_xml.child_value(), - comment_value_xml.attribute("lang").value()); + comment_value_xml.child_value(), + comment_value_xml.attribute("lang").value()); } } if (candidate) @@ -355,7 +355,7 @@ public: auto already_present = false; for (auto const& comment : sit->comments) already_present = - already_present || comment == candidate->first; + already_present || comment == candidate->first; if (!already_present) { sit->comments.emplace_back(candidate->first); @@ -365,19 +365,19 @@ public: } if (auto const location_ref_xml = - record_xml.child("sit:locationReference")) + record_xml.child("sit:locationReference")) { if (location_ref_xml.attribute("xsi:type").value() == "loc:PointLocation"sv) { if (auto const coords_xml = - location_ref_xml.child("loc:pointByCoordinates") - .child("loc:pointCoordinates")) + location_ref_xml.child("loc:pointByCoordinates") + .child("loc:pointCoordinates")) { auto const mlat = - util::parse_double(coords_xml.child_value("loc:latitude")); + util::parse_double(coords_xml.child_value("loc:latitude")); auto const mlon = - util::parse_double(coords_xml.child_value("loc:longitude")); + util::parse_double(coords_xml.child_value("loc:longitude")); if (mlat && mlon) { // Vaag genoeg zegt NDW dat het hier om WGS @@ -404,8 +404,8 @@ public: } return { - .publication_time = *mpublication_time, - .situations = situations, + .publication_time = *mpublication_time, + .situations = situations, }; } -- cgit v1.3