forked from organicmaps/organicmaps
[search] Added basic code to extract addresses for search unit tests
This commit is contained in:
parent
dcf0e87bde
commit
8e6b39e091
4 changed files with 32 additions and 1 deletions
|
@ -194,6 +194,8 @@ namespace ftype
|
|||
m_params.AddHouseNumber(v);
|
||||
if (k == "addr:housename")
|
||||
m_params.AddHouseName(v);
|
||||
if (k == "addr:street")
|
||||
m_params.AddStreetAddress(v);
|
||||
if (k == "addr:flats")
|
||||
m_params.flats = v;
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include "../base/logging.hpp"
|
||||
#include "../base/stl_add.hpp"
|
||||
|
||||
#include "../platform/platform.hpp"
|
||||
|
||||
#include "../std/unordered_map.hpp"
|
||||
#include "../std/list.hpp"
|
||||
|
||||
|
@ -395,7 +397,6 @@ protected:
|
|||
return;
|
||||
|
||||
bool const isClosed = (count > 2 && ft.IsGeometryClosed());
|
||||
|
||||
// Try to set area feature (point and linear types are also suitable for this)
|
||||
if (isClosed && feature::IsDrawableLike(fValue.m_Types, FEATURE_TYPE_AREA))
|
||||
base_type::FinishAreaFeature(id, ft);
|
||||
|
@ -411,7 +412,18 @@ protected:
|
|||
f.SetParams(params);
|
||||
f.SetCenter(ft.GetGeometryCenter());
|
||||
if (f.PreSerialize())
|
||||
{
|
||||
if (!params.m_streetAddress.empty() && !params.house.IsEmpty())
|
||||
{
|
||||
m2::PointD p = ft.GetLimitRect().Center();
|
||||
string const s = params.m_streetAddress + "|" + params.house.Get() + "|"
|
||||
+ strings::to_string(MercatorBounds::YToLat(p.y)) + "|"
|
||||
+ strings::to_string(MercatorBounds::XToLon(p.x)) + '\n';
|
||||
FileWriter writer = FileWriter(GetPlatform().WritableDir() + "/adresses.txt", FileWriter::OP_APPEND, false);
|
||||
writer.Write(s.c_str(), s.size());
|
||||
}
|
||||
base_type::m_emitter(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -478,6 +490,15 @@ protected:
|
|||
ft.SetParams(fValue);
|
||||
if (ft.PreSerialize())
|
||||
{
|
||||
if (!fValue.m_streetAddress.empty() && !fValue.house.IsEmpty())
|
||||
{
|
||||
m2::PointD p = ft.GetLimitRect().Center();
|
||||
string const s = fValue.m_streetAddress + "|" + fValue.house.Get() + "|"
|
||||
+ strings::to_string(MercatorBounds::YToLat(p.y)) + "|"
|
||||
+ strings::to_string(MercatorBounds::XToLon(p.x)) + '\n';
|
||||
FileWriter writer = FileWriter(GetPlatform().WritableDir() + "/adresses.txt", FileWriter::OP_APPEND, false);
|
||||
writer.Write(s.c_str(), s.size());
|
||||
}
|
||||
// add osm id for debugging
|
||||
ft.AddOsmId(p->name, id);
|
||||
base_type::m_emitter(ft);
|
||||
|
|
|
@ -125,6 +125,11 @@ void FeatureParamsBase::AddHouseNumber(string const & ss)
|
|||
house.Set(house.IsEmpty() ? s : s + ", " + house.Get());
|
||||
}
|
||||
|
||||
void FeatureParamsBase::AddStreetAddress(string const & s)
|
||||
{
|
||||
m_streetAddress = s;
|
||||
}
|
||||
|
||||
void FeatureParams::SetGeomType(feature::EGeomType t)
|
||||
{
|
||||
switch (t)
|
||||
|
|
|
@ -112,6 +112,8 @@ struct FeatureParamsBase
|
|||
string flats;
|
||||
int8_t layer;
|
||||
uint8_t rank;
|
||||
/// We use it now only for search unit tests
|
||||
string m_streetAddress;
|
||||
|
||||
FeatureParamsBase() : layer(0), rank(0) {}
|
||||
|
||||
|
@ -125,6 +127,7 @@ struct FeatureParamsBase
|
|||
|
||||
void AddHouseName(string const & s);
|
||||
void AddHouseNumber(string const & s);
|
||||
void AddStreetAddress(string const & s);
|
||||
|
||||
template <class TSink>
|
||||
void Write(TSink & sink, uint8_t header) const
|
||||
|
|
Loading…
Add table
Reference in a new issue