[generator] Generate clockwise roundabouts in countries with left-hand traffic.

This commit is contained in:
Olga Khlopkova 2020-08-27 13:42:13 +03:00 committed by Maksim Andrianov
parent 74bda26eea
commit 9272688394
3 changed files with 29 additions and 7 deletions

View file

@ -9,18 +9,17 @@
#include "generator/node_mixer.hpp"
#include "generator/osm2type.hpp"
#include "generator/promo_catalog_cities.hpp"
#include "generator/region_meta.hpp"
#include "generator/routing_city_boundaries_processor.hpp"
#include "routing/routing_helpers.hpp"
#include "routing/speed_camera_prohibition.hpp"
#include "indexer/classificator.hpp"
#include "indexer/feature_algo.hpp"
#include "base/file_name_utils.hpp"
#include "base/thread_pool_computational.hpp"
#include <mutex>
#include <utility>
#include <vector>
@ -150,6 +149,11 @@ void CountryFinalProcessor::ProcessRoundabouts()
MiniRoundaboutTransformer transformer(roundabouts.GetData(), *m_affiliations);
RegionData data;
if (ReadRegionData(name, data))
transformer.SetLeftHandTraffic(data.Get(RegionData::Type::RD_DRIVING) == "l");
FeatureBuilderWriter<serialization_policy::MaxAccuracy> writer(path, true /* mangleName */);
ForEachFeatureRawFormat<serialization_policy::MaxAccuracy>(path, [&](auto && fb, auto /* pos */) {
if (routing::IsRoad(fb.GetTypes()) && roundabouts.RoadExists(fb))

View file

@ -137,18 +137,32 @@ void MiniRoundaboutTransformer::UpdateRoadType(FeatureParams::Types const & foun
}
feature::FeatureBuilder CreateFb(std::vector<m2::PointD> const & way, uint64_t id,
uint32_t roadType, bool isRoundabout = true)
uint32_t roadType, bool isRoundabout = true,
bool isLeftHandTraffic = false)
{
feature::FeatureBuilder fb;
fb.SetOsmId(base::MakeOsmWay(id));
fb.SetLinear();
UpdateFeatureGeometry(way, fb);
if (!isRoundabout)
{
UpdateFeatureGeometry(way, fb);
return fb;
}
fb.AddPoint(way[0]);
if (isLeftHandTraffic)
{
std::vector<m2::PointD> wayRev = way;
std::reverse(wayRev.begin(), wayRev.end());
UpdateFeatureGeometry(wayRev, fb);
fb.AddPoint(wayRev[0]);
}
else
{
UpdateFeatureGeometry(way, fb);
fb.AddPoint(way[0]);
}
static uint32_t const roundaboutType = classif().GetTypeByPath({"junction", "roundabout"});
fb.AddType(roundaboutType);
@ -313,7 +327,8 @@ std::vector<feature::FeatureBuilder> MiniRoundaboutTransformer::ProcessRoundabou
if (!allRoadsInOneMwm || !foundRoad)
continue;
fbsRoundabouts.push_back(CreateFb(circlePlain, rb.m_id, roadType));
fbsRoundabouts.push_back(
CreateFb(circlePlain, rb.m_id, roadType, true /* isRoundabout */, m_leftHandTraffic));
}
LOG(LINFO, ("Transformed", fbsRoundabouts.size(), "mini_roundabouts to roundabouts.", "Added",

View file

@ -56,6 +56,8 @@ public:
/// These features are obtained from points with highway=mini_roundabout.
std::vector<feature::FeatureBuilder> ProcessRoundabouts();
void SetLeftHandTraffic(bool isLeftHand) { m_leftHandTraffic = isLeftHand; }
private:
/// \brief Sets |road_type| to |found_type| if it is a more important road type.
void UpdateRoadType(FeatureParams::Types const & foundTypes, uint32_t & roadType);
@ -78,6 +80,7 @@ private:
double const m_radiusMercator = 0.0;
feature::AffiliationInterface const * m_affiliation = nullptr;
std::vector<feature::FeatureBuilder> m_roads;
bool m_leftHandTraffic = false;
};
/// \brief Calculates Euclidean distance between 2 points on plane.