#pragma once #include "generator/collector_interface.hpp" #include "generator/feature_builder.hpp" #include "generator/osm_element.hpp" #include "generator/way_nodes_mapper.hpp" #include "routing/road_penalty.hpp" #include "routing/vehicle_mask.hpp" #include #include #include #include #include #include #include namespace routing { class OsmWay2FeaturePoint; template void Save(Sink & sink, RoadPenalty::Type const & type) { WriteToSink(sink, static_cast(type)); } template void Load(Source & src, RoadPenalty::Type & type) { uint8_t const res = ReadPrimitiveFromSource(src); CHECK_LESS(res, static_cast(RoadPenalty::Type::Count), ()); type = static_cast(res); } } // namespace routing namespace routing_builder { using RoadPenalty = routing::RoadPenalty; using VehicleType = routing::VehicleType; using RoadPenaltyByVehicleType = std::array(VehicleType::Count)>; class RoadPenaltyCollector : public generator::CollectorInterface { public: RoadPenaltyCollector(std::string const & filename, IDRInterfacePtr cache); std::shared_ptr Clone(IDRInterfacePtr const & cache = {}) const override; void CollectFeature(feature::FeatureBuilder const & fb, OsmElement const & elem) override; IMPLEMENT_COLLECTOR_IFACE(RoadPenaltyCollector); void MergeInto(RoadPenaltyCollector & collector) const; protected: void Save() override; private: IDRInterfacePtr m_cache; // Store only penalty types during collection phase generator::WayNodesMapper m_nodesWithType; generator::WaysIDHolder m_roads; }; bool BuildRoadPenalty(std::string const & dataFilePath, std::string const & roadPenaltyPath, routing::OsmWay2FeaturePoint & way2feature); } // namespace routing_builder