Merge branch 'organicmaps:master' into gtfs-source-fix

This commit is contained in:
Fardeen Faisal 2022-05-29 15:38:14 -06:00 committed by GitHub
commit 3fc70d190d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 254 additions and 269 deletions

View file

@ -53,7 +53,9 @@ public class Metadata implements Parcelable
FMD_CONTACT_INSTAGRAM(33),
FMD_CONTACT_TWITTER(34),
FMD_CONTACT_VK(35),
FMD_CONTACT_LINE(36);
FMD_CONTACT_LINE(36),
FMD_DESTINATION(37),
FMD_DESTINATION_REF(38);
private final int mMetaType;
MetadataType(int metadataType)

View file

@ -114,45 +114,45 @@ void SortUnique(Cont & c)
c.erase(std::unique(c.begin(), c.end()), c.end());
}
// Sorts according to |less| and removes duplicate entries according to |equals| from |c|.
// Note. If several entries are equal according to |less| an arbitrary entry of them
// is left in |c| after a call of this function.
/// @name Use std::ref to pass functors into std, since all algorithm functions here get forwarding reference.
/// @{
template <typename Cont, typename Less, typename Equals>
void SortUnique(Cont & c, Less && less, Equals && equals)
{
std::sort(c.begin(), c.end(), std::forward<Less>(less));
c.erase(std::unique(c.begin(), c.end(), std::forward<Equals>(equals)), c.end());
std::sort(c.begin(), c.end(), std::ref(less));
c.erase(std::unique(c.begin(), c.end(), std::ref(equals)), c.end());
}
template <typename Cont, typename Fn>
void EraseIf(Cont & c, Fn && fn)
{
c.erase(std::remove_if(c.begin(), c.end(), std::forward<Fn>(fn)), c.end());
c.erase(std::remove_if(c.begin(), c.end(), std::ref(fn)), c.end());
}
template <typename Cont, typename Fn>
bool AllOf(Cont && c, Fn && fn)
bool AllOf(Cont const & c, Fn && fn)
{
return std::all_of(c.cbegin(), c.cend(), std::forward<Fn>(fn));
return std::all_of(std::cbegin(c), std::cend(c), std::ref(fn));
}
template <typename Cont, typename Fn>
bool AnyOf(Cont && c, Fn && fn)
bool AnyOf(Cont const & c, Fn && fn)
{
return std::any_of(c.cbegin(), c.cend(), std::forward<Fn>(fn));
return std::any_of(std::cbegin(c), std::cend(c), std::ref(fn));
}
template <typename Cont, typename OutIt, typename Fn>
decltype(auto) Transform(Cont && c, OutIt && it, Fn && fn)
decltype(auto) Transform(Cont const & c, OutIt it, Fn && fn)
{
return std::transform(std::cbegin(c), std::cend(c), std::forward<OutIt>(it), std::forward<Fn>(fn));
return std::transform(std::cbegin(c), std::cend(c), it, std::ref(fn));
}
template <typename Cont, typename Fn>
decltype(auto) FindIf(Cont && c, Fn && fn)
decltype(auto) FindIf(Cont const & c, Fn && fn)
{
return std::find_if(c.begin(), c.end(), std::forward<Fn>(fn));
return std::find_if(std::cbegin(c), std::cend(c), std::ref(fn));
}
/// @}
template <typename Cont, typename T>
bool IsExist(Cont const & c, T const & t)

Binary file not shown.

View file

@ -51432,29 +51432,6 @@ cont {
}
}
}
cont {
name: "place-region"
element {
scale: 8
caption {
primary {
height: 12
color: 8355711
}
priority: 15000
}
}
element {
scale: 9
caption {
primary {
height: 12
color: 8355711
}
priority: 15000
}
}
}
cont {
name: "place-sea"
element {

Binary file not shown.

View file

@ -51094,29 +51094,6 @@ cont {
}
}
}
cont {
name: "place-region"
element {
scale: 8
caption {
primary {
height: 12
color: 8355711
}
priority: 15000
}
}
element {
scale: 9
caption {
primary {
height: 12
color: 8355711
}
priority: 15000
}
}
}
cont {
name: "place-sea"
element {

Binary file not shown.

View file

@ -51179,29 +51179,6 @@ cont {
}
}
}
cont {
name: "place-region"
element {
scale: 8
caption {
primary {
height: 12
color: 5592405
}
priority: 15000
}
}
element {
scale: 9
caption {
primary {
height: 12
color: 5592405
}
priority: 15000
}
}
}
cont {
name: "place-sea"
element {

Binary file not shown.

View file

@ -33263,29 +33263,6 @@ cont {
}
}
}
cont {
name: "place-region"
element {
scale: 8
caption {
primary {
height: 10
color: 8355711
}
priority: 15000
}
}
element {
scale: 9
caption {
primary {
height: 10
color: 8355711
}
priority: 15000
}
}
}
cont {
name: "place-sea"
element {

Binary file not shown.

View file

@ -33587,29 +33587,6 @@ cont {
}
}
}
cont {
name: "place-region"
element {
scale: 8
caption {
primary {
height: 10
color: 5592405
}
priority: 15000
}
}
element {
scale: 9
caption {
primary {
height: 10
color: 5592405
}
priority: 15000
}
}
}
cont {
name: "place-sea"
element {

View file

@ -404,7 +404,6 @@ node|z13-[place=hamlet]
/* 4.4 Districts & Small localities */
node|z8-9[place=region],
node|z10-14[place=suburb],
node|z13-[place=locality],
node|z13-[place=neighbourhood],
@ -433,7 +432,6 @@ node|z13-14[place=suburb]
node|z13-14[place=suburb]::int_name
{font-size: 10;}
node|z8-9[place=region],
node|z13-[place=locality],
node|z13-[place=neighbourhood],
node|z14-[place=farm],

View file

@ -373,7 +373,6 @@ node|z13-[place=hamlet]
/* 4.4 Districts & Small localities */
node|z8-9[place=region],
node|z13-[place=locality],
node|z14-[place=farm],
node|z14-[place=isolated_dwelling],
@ -383,16 +382,15 @@ node|z14-[place=farm]::int_name,
node|z14-[place=isolated_dwelling]::int_name,
{text: int_name;text-color: @district_label;}
/*node|z10[place=suburb]
/*
node|z10[place=suburb]
{font-size: 8;}
node|z11[place=suburb]
{font-size: 9;}
node|z12[place=suburb]
{font-size: 10;}*/
{font-size: 10;}
*/
node|z8-9[place=region],
node|z13-[place=locality],
node|z14-[place=farm],
node|z14-[place=isolated_dwelling],

View file

@ -701,7 +701,7 @@ world 00000000000000000000 +
locality 00000000000001111111 -
neighbourhood 00000000000000000000 -
ocean 01111111111111111111 -
region 00000000110000000000 -
region 00000000000000000000 -
sea 00001111111111111111 -
square 00000000000000000000 -
state 00000011111000000000 +

View file

@ -10,37 +10,38 @@
#include <vector>
using namespace feature;
namespace check_model
{
void ReadFeatures(std::string const & fName)
using namespace feature;
void ReadFeatures(std::string const & fName)
{
Classificator const & c = classif();
FeaturesVectorTest(fName).GetVector().ForEach([&](FeatureType & ft, uint32_t)
{
Classificator const & c = classif();
TypesHolder types(ft);
FeaturesVectorTest(fName).GetVector().ForEach([&](FeatureType & ft, uint32_t) {
TypesHolder types(ft);
std::vector<uint32_t> vTypes;
for (uint32_t t : types)
{
CHECK_EQUAL(c.GetTypeForIndex(c.GetIndexForType(t)), t, ());
vTypes.push_back(t);
}
std::vector<uint32_t> vTypes;
for (uint32_t t : types)
{
CHECK_EQUAL(c.GetTypeForIndex(c.GetIndexForType(t)), t, ());
vTypes.push_back(t);
}
sort(vTypes.begin(), vTypes.end());
CHECK(unique(vTypes.begin(), vTypes.end()) == vTypes.end(), ());
sort(vTypes.begin(), vTypes.end());
CHECK(unique(vTypes.begin(), vTypes.end()) == vTypes.end(), ());
m2::RectD const r = ft.GetLimitRect(FeatureType::BEST_GEOMETRY);
CHECK(r.IsValid(), ());
m2::RectD const r = ft.GetLimitRect(FeatureType::BEST_GEOMETRY);
CHECK(r.IsValid(), ());
GeomType const type = ft.GetGeomType();
if (type == GeomType::Line)
CHECK_GREATER(ft.GetPointsCount(), 1, ());
GeomType const type = ft.GetGeomType();
if (type == GeomType::Line)
CHECK_GREATER(ft.GetPointsCount(), 1, ());
CHECK(CanGenerateLike(vTypes, ft.GetGeomType()), ());
});
IsDrawableLike(vTypes, ft.GetGeomType());
});
LOG(LINFO, ("OK"));
}
LOG(LINFO, ("OK"));
}
} // namespace check_model

View file

@ -194,8 +194,7 @@ bool FeatureBuilder::RemoveInvalidTypes()
if (!m_params.FinishAddingTypes())
return false;
return RemoveUselessTypes(m_params.m_types, m_params.GetGeomType(),
m_params.IsEmptyNames());
return RemoveUselessTypes(m_params.m_types, m_params.GetGeomType(), m_params.IsEmptyNames());
}
TypesHolder FeatureBuilder::GetTypesHolder() const

View file

@ -323,64 +323,101 @@ MergedFeatureBuilder * FeatureTypesProcessor::operator() (FeatureBuilder const &
return p;
}
namespace feature
class TypeCheckBase
{
class RemoveSolver
{
int m_lowScale, m_upScale;
bool m_doNotRemoveSpecialTypes;
protected:
static uint32_t GetRegionType()
{
static uint32_t regionType = classif().GetTypeByPath({"place", "region"});
return regionType;
}
public:
RemoveSolver(int lowScale, int upScale, bool doNotRemoveSpecialTypes)
: m_lowScale(lowScale)
, m_upScale(upScale)
, m_doNotRemoveSpecialTypes(doNotRemoveSpecialTypes)
int m_lowScale, m_upScale;
TypeCheckBase(int lowScale, int upScale)
: m_lowScale(lowScale), m_upScale(upScale)
{
}
bool operator() (uint32_t type) const
using RangeT = std::pair<int, int>;
static RangeT GetScaleRange(uint32_t type)
{
std::pair<int, int> const range = feature::GetDrawableScaleRange(type);
return feature::GetDrawableScaleRange(type);
}
// Don't remove non-drawable types here, since this case is processed before
// feature::TypeAlwaysExists or FeatureBuilder::RemoveInvalidTypes.
if (m_doNotRemoveSpecialTypes && range.first == -1)
{
ASSERT(range.second == -1, ());
return false;
}
// Remove when |type| is invisible.
return (range.first == -1 || (range.first > m_upScale || range.second < m_lowScale));
static bool IsEmptyRange(RangeT const & range) { return range.first == -1; }
bool IsBadRange(RangeT const & range) const
{
return (range.first > m_upScale || range.second < m_lowScale);
}
};
bool PreprocessForWorldMap(FeatureBuilder & fb)
class TypeCheckWorld : public TypeCheckBase
{
int const upperScale = scales::GetUpperWorldScale();
public:
bool m_isRegion = false;
if (fb.RemoveTypesIf(RemoveSolver(0, upperScale, false /* doNotRemoveSpecialTypes */)))
TypeCheckWorld() : TypeCheckBase(0, scales::GetUpperWorldScale())
{
return false;
}
fb.RemoveNameIfInvisible(0, upperScale);
/// @return true If |type| should be removed.
bool operator() (uint32_t type)
{
// Keep place=region types in World.mwm for search, even when they are not visible.
if (type == GetRegionType())
{
m_isRegion = true;
return false;
}
auto const range = GetScaleRange(type);
return IsEmptyRange(range) || IsBadRange(range);
}
};
class TypeCheckCountry : public TypeCheckBase
{
public:
TypeCheckCountry() : TypeCheckBase(scales::GetUpperWorldScale() + 1, scales::GetUpperStyleScale())
{
}
/// @return true If |type| should be removed.
bool operator() (uint32_t type) const
{
// Do not keep place=region in countries.
if (type == GetRegionType())
return true;
auto const range = GetScaleRange(type);
// Don't remove non-drawable types here, since this case is processed before
// feature::TypeAlwaysExists or FeatureBuilder::RemoveInvalidTypes.
if (IsEmptyRange(range))
return false;
return IsBadRange(range);
}
};
namespace feature
{
bool PreprocessForWorldMap(FeatureBuilder & fb)
{
TypeCheckWorld checker;
if (fb.RemoveTypesIf(checker))
return false;
if (!checker.m_isRegion)
fb.RemoveNameIfInvisible(checker.m_lowScale, checker.m_upScale);
return true;
}
bool PreprocessForCountryMap(FeatureBuilder & fb)
{
using namespace scales;
if (fb.RemoveTypesIf(RemoveSolver(GetUpperWorldScale() + 1, GetUpperStyleScale(),
true /* doNotRemoveSpecialTypes */)))
{
return false;
}
return true;
}
return !fb.RemoveTypesIf(TypeCheckCountry());
}
} // namespace feature

View file

@ -14,10 +14,10 @@
#include "base/assert.hpp"
#include "base/geo_object_id.hpp"
using namespace feature;
namespace generator
{
using namespace feature;
namespace
{
void FixLandType(FeatureBuilder & fb)
@ -158,30 +158,29 @@ void RepresentationLayer::HandleArea(FeatureBuilder & fb, FeatureBuilderParams c
// static
bool RepresentationLayer::CanBeArea(FeatureParams const & params)
{
return feature::IsDrawableLike(params.m_types, feature::GeomType::Area);
return CanGenerateLike(params.m_types, feature::GeomType::Area);
}
// static
bool RepresentationLayer::CanBePoint(FeatureParams const & params)
{
return feature::IsDrawableLike(params.m_types, feature::GeomType::Point);
return CanGenerateLike(params.m_types, feature::GeomType::Point);
}
// static
bool RepresentationLayer::CanBeLine(FeatureParams const & params)
{
return feature::IsDrawableLike(params.m_types, feature::GeomType::Line);
return CanGenerateLike(params.m_types, feature::GeomType::Line);
}
void PrepareFeatureLayer::Handle(FeatureBuilder & fb)
{
auto const type = fb.GetGeomType();
auto & params = fb.GetParams();
feature::RemoveUselessTypes(params.m_types, type);
fb.PreSerializeAndRemoveUselessNamesForIntermediate();
FixLandType(fb);
if (feature::HasUsefulType(params.m_types, type))
if (feature::RemoveUselessTypes(fb.GetParams().m_types, fb.GetGeomType()))
{
fb.PreSerializeAndRemoveUselessNamesForIntermediate();
FixLandType(fb);
LayerBase::Handle(fb);
}
}
void RepresentationCoastlineLayer::Handle(FeatureBuilder & fb)

View file

@ -4,6 +4,7 @@
#include "generator/cities_ids_builder.hpp"
#include "generator/feature_builder.hpp"
#include "generator/feature_generator.hpp"
#include "generator/feature_merger.hpp"
#include "generator/feature_sorter.hpp"
#include "generator/generator_tests_support/test_feature.hpp"
#include "generator/postcode_points_builder.hpp"
@ -31,6 +32,10 @@
#include <memory>
namespace generator
{
namespace tests_support
{
using namespace std;
using namespace feature;
@ -55,10 +60,6 @@ bool WriteRegionDataForTests(string const & path, vector<string> const & languag
}
} // namespace
namespace generator
{
namespace tests_support
{
TestMwmBuilder::TestMwmBuilder(platform::LocalCountryFile & file, DataHeader::MapType type,
uint32_t version)
: m_file(file)
@ -82,10 +83,29 @@ void TestMwmBuilder::Add(TestFeature const & feature)
CHECK(Add(fb), (fb));
}
void TestMwmBuilder::AddSafe(TestFeature const & feature)
{
FeatureBuilder fb;
feature.Serialize(fb);
(void)Add(fb);
}
bool TestMwmBuilder::Add(FeatureBuilder & fb)
{
CHECK(m_collector, ("It's not possible to add features after call to Finish()."));
switch (m_type)
{
case DataHeader::MapType::Country:
if (!feature::PreprocessForCountryMap(fb))
return false;
break;
case DataHeader::MapType::World:
if (!feature::PreprocessForWorldMap(fb))
return false;
break;
}
auto const & isCityTownOrVillage = ftypes::IsCityTownOrVillageChecker::Instance();
if (isCityTownOrVillage(fb.GetTypes()) && fb.GetGeomType() == GeomType::Area)
{

View file

@ -38,7 +38,9 @@ public:
~TestMwmBuilder();
void Add(TestFeature const & feature);
void AddSafe(TestFeature const & feature);
bool Add(feature::FeatureBuilder & fb);
void SetUKPostcodesData(std::string const & postcodesPath,
std::shared_ptr<storage::CountryInfoGetter> const & countryInfoGetter);
void SetMwmLanguages(std::vector<std::string> const & languages);

View file

@ -14,6 +14,8 @@
#include <limits>
#include <unordered_map>
namespace generator
{
namespace
{
double constexpr kDefaultRadiusMeters = 5.0;
@ -52,14 +54,13 @@ void UpdateFeatureGeometry(feature::FeatureBuilder::PointSeq const & seq,
feature::FeatureBuilder::PointSeq::iterator GetIterOnRoad(m2::PointD const & point,
feature::FeatureBuilder::PointSeq & road)
{
return base::FindIf(road, [&point](m2::PointD const & pointOnRoad) {
return std::find_if(road.begin(), road.end(), [&point](m2::PointD const & pointOnRoad)
{
return m2::AlmostEqualAbs(pointOnRoad, point, kMwmPointAccuracy);
});
}
}
} // namespace
namespace generator
{
MiniRoundaboutData::MiniRoundaboutData(std::vector<MiniRoundaboutInfo> && data)
: m_data(std::move(data))
{

View file

@ -146,6 +146,16 @@ string MetadataTagProcessorImpl::ValidateAndFormat_ele(string const & v) const
return measurement_utils::OSMDistanceToMetersString(v);
}
string MetadataTagProcessorImpl::ValidateAndFormat_destination(string const & v) const
{
return v;
}
string MetadataTagProcessorImpl::ValidateAndFormat_destination_ref(string const & v) const
{
return v;
}
string MetadataTagProcessorImpl::ValidateAndFormat_turn_lanes(string const & v) const
{
return v;
@ -446,6 +456,8 @@ void MetadataTagProcessor::operator()(std::string const & k, std::string const &
case Metadata::FMD_CONTACT_LINE: valid = osm::ValidateAndFormat_contactLine(v); break;
case Metadata::FMD_INTERNET: valid = ValidateAndFormat_internet(v); break;
case Metadata::FMD_ELE: valid = ValidateAndFormat_ele(v); break;
case Metadata::FMD_DESTINATION: valid = ValidateAndFormat_destination(v); break;
case Metadata::FMD_DESTINATION_REF: valid = ValidateAndFormat_destination_ref(v); break;
case Metadata::FMD_TURN_LANES: valid = ValidateAndFormat_turn_lanes(v); break;
case Metadata::FMD_TURN_LANES_FORWARD: valid = ValidateAndFormat_turn_lanes_forward(v); break;
case Metadata::FMD_TURN_LANES_BACKWARD: valid = ValidateAndFormat_turn_lanes_backward(v); break;

View file

@ -16,6 +16,8 @@ struct MetadataTagProcessorImpl
std::string ValidateAndFormat_phone(std::string const & v) const;
std::string ValidateAndFormat_opening_hours(std::string const & v) const;
std::string ValidateAndFormat_ele(std::string const & v) const;
std::string ValidateAndFormat_destination(std::string const & v) const;
std::string ValidateAndFormat_destination_ref(std::string const & v) const;
std::string ValidateAndFormat_turn_lanes(std::string const & v) const;
std::string ValidateAndFormat_turn_lanes_forward(std::string const & v) const;
std::string ValidateAndFormat_turn_lanes_backward(std::string const & v) const;

View file

@ -72,6 +72,10 @@ bool Metadata::TypeFromString(string const & k, Metadata::EType & outType)
outType = Metadata::FMD_INTERNET;
else if (k == "ele")
outType = Metadata::FMD_ELE;
else if (k == "destination")
outType = Metadata::FMD_DESTINATION;
else if (k == "destination:ref")
outType = Metadata::FMD_DESTINATION_REF;
else if (k == "turn:lanes")
outType = Metadata::FMD_TURN_LANES;
else if (k == "turn:lanes:forward")
@ -169,6 +173,8 @@ string ToString(Metadata::EType type)
case Metadata::FMD_CONTACT_LINE: return "contact:line";
case Metadata::FMD_INTERNET: return "internet_access";
case Metadata::FMD_ELE: return "ele";
case Metadata::FMD_DESTINATION: return "desination";
case Metadata::FMD_DESTINATION_REF: return "desination:ref";
case Metadata::FMD_TURN_LANES: return "turn:lanes";
case Metadata::FMD_TURN_LANES_FORWARD: return "turn:lanes:forward";
case Metadata::FMD_TURN_LANES_BACKWARD: return "turn:lanes:backward";

View file

@ -153,6 +153,8 @@ public:
FMD_CONTACT_TWITTER = 34,
FMD_CONTACT_VK = 35,
FMD_CONTACT_LINE = 36,
FMD_DESTINATION = 37,
FMD_DESTINATION_REF = 38,
FMD_COUNT
};

View file

@ -99,6 +99,21 @@ namespace
/// The functions names and set of types looks strange now and definitely should be revised.
/// @{
bool IsUsefulStandaloneType(uint32_t type, GeomType g = GeomType::Undefined)
{
auto const & cl = classif();
static uint32_t const shuttle = cl.GetTypeByPath({"route", "shuttle_train"});
if ((g == GeomType::Line || g == GeomType::Undefined) && type == shuttle)
return true;
static uint32_t const region = cl.GetTypeByPath({"place", "region"});
if ((g == GeomType::Point || g == GeomType::Undefined) && type == region)
return true;
return false;
}
/// Warning: Geometry of features with always existing types will be indexed in mwm on all
/// zoom levels. If you add an always existing type to drawing types, the displacement of icons
/// may work not correctly.
@ -108,13 +123,12 @@ namespace
if (!cl.IsTypeValid(type))
return false;
static uint32_t const shuttle = cl.GetTypeByPath({"route", "shuttle_train"});
if (IsUsefulStandaloneType(type, g))
return true;
static uint32_t const internet = cl.GetTypeByPath({"internet_access"});
static uint32_t const complexEntry = cl.GetTypeByPath({"complex_entry"});
if ((g == GeomType::Line || g == GeomType::Undefined) && type == shuttle)
return true;
uint8_t const typeLevel = ftype::GetLevel(type);
ftype::TruncValue(type, 1);
@ -128,7 +142,7 @@ namespace
{
static uint32_t const arrTypes[] = {
cl.GetTypeByPath({"organic"}),
cl.GetTypeByPath({"recycling"})
cl.GetTypeByPath({"recycling"}),
};
if (base::IsExist(arrTypes, type))
return true;
@ -155,6 +169,7 @@ namespace
static uint32_t const roundabout = cl.GetTypeByPath({"junction", "roundabout"});
static uint32_t const psurface = cl.GetTypeByPath({"psurface"});
/// @todo "roundabout" type itself has caption drawing rules (for point junctions?).
if ((g == GeomType::Line || g == GeomType::Undefined) && type == roundabout)
return true;
@ -179,13 +194,13 @@ bool IsUsefulType(uint32_t type)
return IsUsefulNondrawableType(type) || classif().GetObject(type)->IsDrawableAny();
}
bool IsDrawableLike(vector<uint32_t> const & types, GeomType geomType)
bool CanGenerateLike(vector<uint32_t> const & types, GeomType geomType)
{
Classificator const & c = classif();
for (uint32_t t : types)
{
if (c.GetObject(t)->IsDrawableLike(geomType, false /* emptyName */))
if (IsUsefulStandaloneType(t, geomType) || c.GetObject(t)->IsDrawableLike(geomType, false /* emptyName */))
return true;
}
return false;
@ -235,12 +250,10 @@ bool IsDrawableForIndexClassifOnly(TypesHolder const & types, int level)
bool IsUsefulType(uint32_t t, GeomType geomType, bool emptyName)
{
Classificator const & c = classif();
if (IsUsefulNondrawableType(t, geomType))
return true;
ClassifObject const * obj = c.GetObject(t);
ClassifObject const * obj = classif().GetObject(t);
CHECK(obj, ());
if (obj->IsDrawableLike(geomType, emptyName))
@ -256,14 +269,6 @@ bool IsUsefulType(uint32_t t, GeomType geomType, bool emptyName)
return false;
}
bool HasUsefulType(vector<uint32_t> const & types, GeomType geomType, bool emptyName)
{
return any_of(types.begin(), types.end(), [&](uint32_t t)
{
return IsUsefulType(t, geomType, emptyName);
});
}
bool RemoveUselessTypes(vector<uint32_t> & types, GeomType geomType, bool emptyName)
{
base::EraseIf(types, [&] (uint32_t t)

View file

@ -30,15 +30,16 @@ namespace feature
bool IsDrawableForIndexGeometryOnly(FeatureType & ft, int level);
bool IsDrawableForIndexGeometryOnly(TypesHolder const & types, m2::RectD limitRect, int level);
/// For FEATURE_TYPE_AREA need to have at least one area-filling type.
bool IsDrawableLike(std::vector<uint32_t> const & types, GeomType geomType);
/// For FEATURE_TYPE_AREA removes line-drawing only types.
bool RemoveUselessTypes(std::vector<uint32_t> & types, GeomType geomType, bool emptyName = false);
/// @name Generator check functions.
/// @{
// Returns true, if there is at least one type that is needed for the application.
// This can be specified either by the drawing rule or by other rules.
bool HasUsefulType(std::vector<uint32_t> const & types, GeomType geomType,
bool emptyName = false);
/// Can object with \a types can be generated as \a geomType Feature.
/// Should have appropriate drawing rules or satisfy "IsUsefulStandaloneType".
bool CanGenerateLike(std::vector<uint32_t> const & types, GeomType geomType);
/// @return true, if at least one valid type remains.
bool RemoveUselessTypes(std::vector<uint32_t> & types, GeomType geomType, bool emptyName = false);
/// @}
int GetMinDrawableScale(FeatureType & ft);
int GetMinDrawableScale(TypesHolder const & types, m2::RectD limitRect);

View file

@ -179,6 +179,8 @@ std::vector<Props> MetadataToProps(std::vector<T> const & metadata)
case Metadata::FMD_BUILDING_LEVELS: res.push_back(Props::BuildingLevels); break;
case Metadata::FMD_LEVEL: res.push_back(Props::Level); break;
case Metadata::FMD_DESTINATION:
case Metadata::FMD_DESTINATION_REF:
case Metadata::FMD_TURN_LANES:
case Metadata::FMD_TURN_LANES_FORWARD:
case Metadata::FMD_TURN_LANES_BACKWARD:

View file

@ -472,14 +472,16 @@ void DrawWidget::SubmitFakeLocationPoint(m2::PointD const & pt)
if (m_framework.GetRoutingManager().GetCurrentRouterType() == routing::RouterType::Pedestrian)
{
LOG(LDEBUG, ("Distance:", loc.m_distToTarget, loc.m_targetUnitsSuffix, "Time:", loc.m_time,
"Pedestrian turn:", DebugPrint(loc.m_pedestrianTurn),
"Distance to turn:", loc.m_distToTurn, loc.m_turnUnitsSuffix));
DebugPrint(loc.m_pedestrianTurn),
"in", loc.m_distToTurn, loc.m_turnUnitsSuffix,
"to", loc.m_targetName));
}
else
{
LOG(LDEBUG, ("Distance:", loc.m_distToTarget, loc.m_targetUnitsSuffix, "Time:", loc.m_time,
"Turn:", routing::turns::GetTurnString(loc.m_turn), "(", loc.m_distToTurn,
loc.m_turnUnitsSuffix, ") Roundabout exit number:", loc.m_exitNum));
GetTurnString(loc.m_turn), (loc.m_exitNum != 0 ? ":" + std::to_string(loc.m_exitNum) : ""),
"in", loc.m_distToTurn, loc.m_turnUnitsSuffix,
"to", loc.m_targetName));
}
}
}

View file

@ -66,7 +66,18 @@ void DirectionsEngine::LoadPathAttributes(FeatureID const & featureId,
pathSegment.m_onRoundabout = ftypes::IsRoundAboutChecker::Instance()(*ft);
pathSegment.m_isOneWay = ftypes::IsOneWayChecker::Instance()(*ft);
pathSegment.m_name = ft->GetName(StringUtf8Multilang::kDefaultCode);
if (pathSegment.m_isLink)
{
if (auto const & dst_number = ft->GetMetadata(feature::Metadata::FMD_DESTINATION_REF); !dst_number.empty())
pathSegment.m_name = "[" + string(dst_number) + "] ";
pathSegment.m_name += ft->GetMetadata(feature::Metadata::FMD_DESTINATION);
}
else
{
if (auto const & road_number = ft->GetRoadNumber(); !road_number.empty())
pathSegment.m_name = "[" + road_number + "] ";
pathSegment.m_name += ft->GetName(StringUtf8Multilang::kDefaultCode);
}
}
void DirectionsEngine::GetSegmentRangeAndAdjacentEdges(IRoadGraph::EdgeListT const & outgoingEdges,

View file

@ -36,15 +36,14 @@
#include <tuple>
#include <vector>
namespace processor_test
{
using namespace feature;
using namespace generator::tests_support;
using namespace search;
using namespace search::tests_support;
using namespace std;
namespace search
{
namespace
{
class TestAirport : public TestPOI
{
public:
@ -2743,7 +2742,7 @@ UNIT_CLASS_TEST(ProcessorTest, AvoidMatchAroundPivotInMwmWithCity)
TestCity minsk({-10.0, -10.0}, "Minsk", "en", 10 /* rank */);
// World.mwm should intersect viewport.
TestPOI dummy({10.0, 10.0}, "", "en");
TestCity dummy({10.0, 10.0}, "Dummy", "en", 1 /* rank */);
auto worldId = BuildWorld([&](TestMwmBuilder & builder) {
builder.Add(minsk);
@ -3028,5 +3027,4 @@ UNIT_CLASS_TEST(ProcessorTest, TestRankingInfo_MultipleOldNames)
checkResult("Ленинград", "Санкт-Петербург (Ленинград)");
checkResult("Петроград", "Санкт-Петербург (Петроград)");
}
} // namespace
} // namespace search
} // namespace processor_test

View file

@ -9,13 +9,13 @@
#include <utility>
#include <vector>
namespace ranker_test
{
using namespace generator::tests_support;
using namespace search::tests_support;
using namespace search;
using namespace std;
namespace
{
class RankerTest : public SearchTest
{
};
@ -105,6 +105,8 @@ UNIT_CLASS_TEST(RankerTest, UniteSameResults)
}
}
/// @todo This test doesn't make sense because we don't have POIs in World.
/*
UNIT_CLASS_TEST(RankerTest, PreferCountry)
{
TestCountry wonderland(m2::PointD(10.0, 10.0), "Wonderland", "en");
@ -141,4 +143,5 @@ UNIT_CLASS_TEST(RankerTest, PreferCountry)
TEST(ResultsMatch({results[1]}, {rules[0]}), ());
}
}
} // namespace
*/
} // namespace ranker_test

View file

@ -20,14 +20,14 @@
#include <string>
namespace smoke_test
{
using namespace feature;
using namespace generator::tests_support;
using namespace search;
using namespace search::tests_support;
using namespace std;
namespace search
{
class IncorrectCountry : public TestCountry
{
public:
@ -245,7 +245,7 @@ UNIT_CLASS_TEST(SmokeTest, CategoriesTest)
poi.SetTypes({strings::Tokenize<std::string>(classif().GetFullObjectName(type), "|")});
auto id = BuildMwm(countryName, DataHeader::MapType::Country,
[&](TestMwmBuilder & builder) { builder.Add(poi); });
[&](TestMwmBuilder & builder) { builder.AddSafe(poi); });
SetViewport(m2::RectD(m2::PointD(0.0, 0.0), m2::PointD(2.0, 2.0)));
{
@ -326,5 +326,4 @@ UNIT_CLASS_TEST(SmokeTest, PoiWithAddress)
TEST(ResultsMatch("Starbucks Main street 27 ", rules), ());
}
}
} // namespace search
} // namespace smoke_test