[generator] Do not mix natural-coastline with natural-land and place-island:

- "natural-land" - fills area with background color
- "place-island" - draws only name
- "natural-coastline" - doesn't duplicate "natural-land".
This commit is contained in:
vng 2013-12-06 02:03:11 +01:00 committed by Alex Zolotarev
parent 050a6c2406
commit 4c1cab5faf
7 changed files with 65 additions and 50 deletions

View file

@ -1,8 +1,6 @@
area[landuse],
area[natural],
area[leisure],
area[place=island],
area[place=islet]
area[leisure]
{
fill-position: background;
}
@ -13,18 +11,14 @@ area[natural=coastline]
z-index: -10;
}
area|z6-11[natural=land],
area|z6-11[place=island],
area|z6-11[place=islet]
area|z6-11[natural=land]
{
fill-color: #f1eee8;
fill-color: #EEEEDD;
z-index: -9;
}
area|z12-[natural=land],
area|z12-[place=island],
area|z12-[place=islet]
area|z12-[natural=land]
{
fill-color: #f8f8f8;
fill-color: #EEEEDD;
z-index: -9;
}

View file

@ -3869,8 +3869,6 @@ line[boundary=administrative][admin_level!=2][admin_level!=3][admin_level!=4]
}
area|z6-[natural=land]
area|z6-[place=island]
area|z6-[place=islet]
{
fill-color: #ffffff;
z-index: -5;

View file

@ -106,6 +106,9 @@ void FeatureBuilder1::DoCorrectForType(EGeomType type)
bool FeatureBuilder1::DoCorrect()
{
if (!m_Params.FinishAddingTypes())
return false;
DoCorrectForType(GEOM_AREA);
DoCorrectForType(GEOM_LINE);

View file

@ -263,21 +263,6 @@ class MainFeaturesEmitter
scoped_ptr<FeaturesCollector> m_coastsHolder;
string m_srcCoastsFile;
uint32_t m_coastType;
vector<uint32_t> m_islandTypes;
// Treat islands as coastlines, because they don't have fill area draw style.
bool IsIsland(FeatureBuilder1 const & fb) const
{
if (!fb.IsGeometryClosed())
return false;
for (size_t i = 0; i < m_islandTypes.size(); ++i)
if (fb.HasType(m_islandTypes[i]))
return true;
return false;
}
template <class T1, class T2> class CombinedEmitter
{
@ -292,14 +277,40 @@ class MainFeaturesEmitter
}
};
enum TypeIndex
{
NATURAL_COASTLINE,
NATURAL_LAND,
PLACE_ISLAND,
PLACE_ISLET,
TYPES_COUNT
};
uint32_t m_types[TYPES_COUNT];
inline uint32_t Type(TypeIndex i) const { return m_types[i]; }
public:
MainFeaturesEmitter(GenerateInfo const & info)
{
Classificator const & c = classif();
m_coastType = c.GetCoastType();
char const * arr[][2] = {
{ "natural", "coastline" },
{ "natural", "land" },
{ "place", "island" },
{ "place", "islet" }
};
STATIC_ASSERT(ARRAY_SIZE(arr) == TYPES_COUNT);
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
m_types[i] = c.GetTypeByPath(vector<string>(arr[i], arr[i] + 2));
m_srcCoastsFile = info.m_tmpDir + WORLD_COASTS_FILE_NAME + info.m_datFileSuffix;
CHECK(!info.m_makeCoasts || !info.m_createWorld,
("We can't do make_coasts and generate_world at the same time"));
if (!info.m_makeCoasts)
{
m_countries.reset(new Polygonizer<FeaturesCollector>(info));
@ -312,17 +323,9 @@ public:
}
else
{
char const * arr[][2] = {
{ "place", "island" },
{ "place", "islet" }
};
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
m_islandTypes.push_back(c.GetTypeByPath(vector<string>(arr[i], arr[i] + 2)));
// 4-10 - level range for cells
// 20000 - max points count per feature
m_coasts.reset(new CoastlineFeaturesGenerator(m_coastType, 4, 10, 20000));
m_coasts.reset(new CoastlineFeaturesGenerator(Type(NATURAL_COASTLINE), 4, 10, 20000));
m_coastsHolder.reset(new FeaturesCollector(m_srcCoastsFile));
}
@ -335,28 +338,41 @@ public:
void operator() (FeatureBuilder1 fb)
{
uint32_t const coastType = Type(NATURAL_COASTLINE);
bool const hasCoast = fb.HasType(coastType);
if (m_coasts)
{
if (fb.HasType(m_coastType) || IsIsland(fb))
if (hasCoast)
{
CHECK ( fb.GetGeomType() != feature::GEOM_POINT, () );
// leave only coastline type
fb.SetType(m_coastType);
fb.SetType(coastType);
(*m_coasts)(fb);
}
}
// remove coastline type
if (!fb.PopExactType(m_coastType) && fb.DoCorrect())
else
{
if (m_world)
(*m_world)(fb);
if (hasCoast)
{
fb.PopExactType(Type(NATURAL_LAND));
fb.PopExactType(coastType);
}
else if (fb.HasType(Type(PLACE_ISLAND)) || fb.HasType(Type(PLACE_ISLET)))
fb.AddType(Type(NATURAL_LAND));
if (m_countries)
(*m_countries)(fb);
if (fb.DoCorrect())
{
if (m_world)
(*m_world)(fb);
if (m_countries)
(*m_countries)(fb);
}
}
}
/// @return false if coasts are not merged and FLAG_fail_on_coasts is set
bool Finish()
{

View file

@ -253,7 +253,8 @@ void FeatureMergeProcessor::DoMerge(FeatureEmitterIFace & emitter)
if (m_last.NotEmpty() && m_last.EqualGeometry(curr))
{
// curr is equal with m_last by geometry - just add new type to m_last
m_last.AddType(type);
if (!m_last.HasType(type))
m_last.AddType(type);
}
else
{

View file

@ -163,12 +163,15 @@ void FeatureParams::AddTypes(FeatureParams const & rhs, uint32_t skipType2)
}
}
void FeatureParams::FinishAddingTypes()
bool FeatureParams::FinishAddingTypes()
{
sort(m_Types.begin(), m_Types.end());
m_Types.erase(unique(m_Types.begin(), m_Types.end()), m_Types.end());
if (m_Types.size() > max_types_count)
m_Types.resize(max_types_count);
return !m_Types.empty();
}
void FeatureParams::SetType(uint32_t t)

View file

@ -223,7 +223,7 @@ public:
m_Types.assign(b, e);
}
void FinishAddingTypes();
bool FinishAddingTypes();
void SetType(uint32_t t);
bool PopAnyType(uint32_t & t);