forked from organicmaps/organicmaps
[generator] Skip features with helper types only ("oneway").
This commit is contained in:
parent
24c2f1a09a
commit
867425921b
2 changed files with 33 additions and 44 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "ways_merger.hpp"
|
||||
|
||||
#include "../indexer/feature_visibility.hpp"
|
||||
#include "../indexer/classificator.hpp"
|
||||
|
||||
#include "../base/string_utils.hpp"
|
||||
#include "../base/logging.hpp"
|
||||
|
@ -238,6 +239,36 @@ protected:
|
|||
ft.SetAreaAddHoles(processor.GetHoles());
|
||||
}
|
||||
|
||||
class UselessSingleTypes
|
||||
{
|
||||
vector<uint32_t> m_types;
|
||||
|
||||
bool IsUseless(uint32_t t) const
|
||||
{
|
||||
return (find(m_types.begin(), m_types.end(), t) != m_types.end());
|
||||
}
|
||||
|
||||
public:
|
||||
UselessSingleTypes()
|
||||
{
|
||||
Classificator const & c = classif();
|
||||
|
||||
char const * arr[][1] = { { "oneway" }, { "lit" } };
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
|
||||
m_types.push_back(c.GetTypeByPath(vector<string>(arr[i], arr[i] + 1)));
|
||||
}
|
||||
|
||||
bool IsValid(vector<uint32_t> const & types) const
|
||||
{
|
||||
size_t const count = types.size();
|
||||
size_t uselessCount = 0;
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
if (IsUseless(types[i]))
|
||||
++uselessCount;
|
||||
return (count > uselessCount);
|
||||
}
|
||||
};
|
||||
|
||||
bool ParseType(XMLElement * p, uint64_t & id, FeatureParams & fValue)
|
||||
{
|
||||
CHECK ( strings::to_uint64(p->attrs["id"], id), (p->attrs["id"]) );
|
||||
|
@ -262,7 +293,8 @@ protected:
|
|||
fValue.FinishAddingTypes();
|
||||
|
||||
// unrecognized feature by classificator
|
||||
return fValue.IsValid();
|
||||
static UselessSingleTypes checker;
|
||||
return fValue.IsValid() && checker.IsValid(fValue.m_Types);
|
||||
}
|
||||
|
||||
class multipolygons_emitter
|
||||
|
|
|
@ -138,34 +138,6 @@ namespace
|
|||
};
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class UselessCheckPatch
|
||||
{
|
||||
uint32_t m_oneway, m_highway;
|
||||
|
||||
public:
|
||||
UselessCheckPatch(Classificator const & c)
|
||||
{
|
||||
vector<string> v;
|
||||
v.push_back("oneway");
|
||||
m_oneway = c.GetTypeByPath(v);
|
||||
|
||||
v.clear();
|
||||
v.push_back("highway");
|
||||
m_highway = c.GetTypeByPath(v);
|
||||
}
|
||||
|
||||
bool IsHighway(uint32_t t) const
|
||||
{
|
||||
ftype::TruncValue(t, 1);
|
||||
return (t == m_highway);
|
||||
}
|
||||
|
||||
bool IsOneway(uint32_t t) const { return (t == m_oneway); }
|
||||
};
|
||||
}
|
||||
|
||||
pair<int, bool> GetDrawRule(FeatureBase const & f, int level,
|
||||
drule::KeysT & keys, string & names)
|
||||
{
|
||||
|
@ -174,28 +146,13 @@ pair<int, bool> GetDrawRule(FeatureBase const & f, int level,
|
|||
ASSERT ( keys.empty(), () );
|
||||
Classificator const & c = classif();
|
||||
|
||||
static UselessCheckPatch patch(c);
|
||||
|
||||
bool hasHighway = false;
|
||||
for (size_t i = 0; i < types.Size(); ++i)
|
||||
if (patch.IsHighway(types[i]))
|
||||
{
|
||||
hasHighway = true;
|
||||
break;
|
||||
}
|
||||
|
||||
DrawRuleGetter doRules(level, types.GetGeoType(), keys
|
||||
#ifdef DEBUG
|
||||
, names
|
||||
#endif
|
||||
);
|
||||
for (size_t i = 0; i < types.Size(); ++i)
|
||||
{
|
||||
if (!hasHighway && patch.IsOneway(types[i]))
|
||||
continue;
|
||||
|
||||
(void)c.ProcessObjects(types[i], doRules);
|
||||
}
|
||||
|
||||
return make_pair(types.GetGeoType(), types.Has(c.GetCoastType()));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue