forked from organicmaps/organicmaps
[search] Fixed address data generation - take objects with the "building" type only.
This commit is contained in:
parent
b2be62c804
commit
1f9d3d7f12
6 changed files with 51 additions and 34 deletions
|
@ -1,8 +1,8 @@
|
|||
# Generator binary
|
||||
|
||||
ROOT_DIR = ../..
|
||||
DEPENDENCIES = generator storage indexer platform geometry coding base gflags expat sgitess \
|
||||
jansson protobuf tomcrypt
|
||||
DEPENDENCIES = generator storage search indexer platform geometry coding base \
|
||||
gflags expat sgitess jansson protobuf tomcrypt
|
||||
|
||||
include($$ROOT_DIR/common.pri)
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "feature_builder.hpp"
|
||||
#include "ways_merger.hpp"
|
||||
|
||||
#include "../search/ftypes_matcher.hpp"
|
||||
|
||||
#include "../indexer/feature_visibility.hpp"
|
||||
#include "../indexer/classificator.hpp"
|
||||
|
||||
|
@ -345,7 +347,13 @@ class SecondPassParserUsual : public SecondPassParserBase<TEmitter, THolder>
|
|||
typedef typename base_type::feature_builder_t feature_t;
|
||||
|
||||
uint32_t m_coastType;
|
||||
|
||||
scoped_ptr<FileWriter> m_addrWriter;
|
||||
bool NeedWriteAddress(FeatureParams const & params) const
|
||||
{
|
||||
static ftypes::IsBuildingChecker checker;
|
||||
return m_addrWriter && checker(params.m_Types);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void EmitElement(XMLElement * p)
|
||||
|
@ -413,7 +421,7 @@ protected:
|
|||
if (f.PreSerialize())
|
||||
{
|
||||
string addr;
|
||||
if (m_addrWriter && f.FormatFullAddress(addr))
|
||||
if (NeedWriteAddress(params) && f.FormatFullAddress(addr))
|
||||
m_addrWriter->Write(addr.c_str(), addr.size());
|
||||
|
||||
base_type::m_emitter(f);
|
||||
|
@ -485,7 +493,7 @@ protected:
|
|||
if (ft.PreSerialize())
|
||||
{
|
||||
string addr;
|
||||
if (m_addrWriter && ft.FormatFullAddress(addr))
|
||||
if (NeedWriteAddress(fValue) && ft.FormatFullAddress(addr))
|
||||
m_addrWriter->Write(addr.c_str(), addr.size());
|
||||
|
||||
// add osm id for debugging
|
||||
|
|
|
@ -8,14 +8,17 @@
|
|||
namespace ftypes
|
||||
{
|
||||
|
||||
bool BaseChecker::IsMatched(uint32_t t) const
|
||||
{
|
||||
ftype::TruncValue(t, 2);
|
||||
return (find(m_types.begin(), m_types.end(), t) != m_types.end());
|
||||
}
|
||||
|
||||
bool BaseChecker::operator() (feature::TypesHolder const & types) const
|
||||
{
|
||||
for (size_t i = 0; i < types.Size(); ++i)
|
||||
{
|
||||
uint32_t t = types[i];
|
||||
ftype::TruncValue(t, 2);
|
||||
|
||||
if (find(m_types.begin(), m_types.end(), t) != m_types.end())
|
||||
if (IsMatched(types[i]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -26,6 +29,16 @@ bool BaseChecker::operator() (FeatureType const & ft) const
|
|||
return this->operator() (feature::TypesHolder(ft));
|
||||
}
|
||||
|
||||
bool BaseChecker::operator() (vector<uint32_t> const & types) const
|
||||
{
|
||||
for (size_t i = 0; i < types.size(); ++i)
|
||||
{
|
||||
if (IsMatched(types[i]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IsStreetChecker::IsStreetChecker()
|
||||
{
|
||||
Classificator const & c = classif();
|
||||
|
@ -44,4 +57,14 @@ IsStreetChecker::IsStreetChecker()
|
|||
m_types.push_back(c.GetTypeByPath(vector<string>(arr[i], arr[i] + 2)));
|
||||
}
|
||||
|
||||
IsBuildingChecker::IsBuildingChecker()
|
||||
{
|
||||
Classificator const & c = classif();
|
||||
|
||||
char const * arr0[] = { "building" };
|
||||
m_types.push_back(c.GetTypeByPath(vector<string>(arr0, arr0 + 1)));
|
||||
char const * arr1[] = { "building", "address" };
|
||||
m_types.push_back(c.GetTypeByPath(vector<string>(arr1, arr1 + 2)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,15 @@ namespace ftypes
|
|||
|
||||
class BaseChecker
|
||||
{
|
||||
bool IsMatched(uint32_t t) const;
|
||||
|
||||
protected:
|
||||
vector<uint32_t> m_types;
|
||||
|
||||
public:
|
||||
bool operator() (feature::TypesHolder const & types) const;
|
||||
bool operator() (FeatureType const & ft) const;
|
||||
bool operator() (vector<uint32_t> const & types) const;
|
||||
};
|
||||
|
||||
class IsStreetChecker : public BaseChecker
|
||||
|
@ -27,4 +30,10 @@ public:
|
|||
IsStreetChecker();
|
||||
};
|
||||
|
||||
class IsBuildingChecker : public BaseChecker
|
||||
{
|
||||
public:
|
||||
IsBuildingChecker();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -490,29 +490,6 @@ int HouseDetector::MergeStreets()
|
|||
namespace
|
||||
{
|
||||
|
||||
class HouseChecker
|
||||
{
|
||||
uint32_t m_types[2];
|
||||
public:
|
||||
HouseChecker()
|
||||
{
|
||||
Classificator const & c = classif();
|
||||
|
||||
char const * arr0[] = { "building" };
|
||||
m_types[0] = c.GetTypeByPath(vector<string>(arr0, arr0 + 1));
|
||||
char const * arr1[] = { "building", "address" };
|
||||
m_types[1] = c.GetTypeByPath(vector<string>(arr1, arr1 + 2));
|
||||
}
|
||||
|
||||
bool IsHouse(feature::TypesHolder const & types)
|
||||
{
|
||||
for (size_t i = 0; i < ARRAY_SIZE(m_types); ++i)
|
||||
if (types.Has(m_types[i]))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class ProjectionCalcToStreet
|
||||
{
|
||||
vector<m2::PointD> const & m_points;
|
||||
|
@ -721,10 +698,10 @@ HouseProjection const * MergedStreet::GetHousePivot(bool & odd, bool & sign) con
|
|||
template <class ProjectionCalcT>
|
||||
void HouseDetector::ReadHouse(FeatureType const & f, Street * st, ProjectionCalcT & calc)
|
||||
{
|
||||
static HouseChecker checker;
|
||||
static ftypes::IsBuildingChecker checker;
|
||||
|
||||
string const houseNumber = f.GetHouseNumber();
|
||||
if (checker.IsHouse(feature::TypesHolder(f)) && feature::IsHouseNumber(houseNumber))
|
||||
if (checker(f) && feature::IsHouseNumber(houseNumber))
|
||||
{
|
||||
map<FeatureID, House *>::iterator const it = m_id2house.find(f.GetID());
|
||||
|
||||
|
|
|
@ -391,7 +391,7 @@ UNIT_TEST(HS_MWMSearch)
|
|||
p.x = MercatorBounds::XToLon(p.x);
|
||||
p.y = MercatorBounds::YToLat(p.y);
|
||||
|
||||
double const eps = 1.0E-4;
|
||||
double const eps = 3.0E-4;
|
||||
if (fabs(p.x - a.m_lon) < eps && fabs(p.y - a.m_lat) < eps)
|
||||
{
|
||||
++matched;
|
||||
|
|
Loading…
Add table
Reference in a new issue