Do not render building feature if it is not a building part but has building parts.

This commit is contained in:
Daria Volvenkova 2016-07-20 11:44:14 +03:00
parent e88138cc15
commit 2a54f6221e
7 changed files with 60 additions and 29 deletions

View file

@ -516,18 +516,20 @@ void ApplyPointFeature::Finish(CustomSymbolsContextPtr const & customSymbolsCont
}
ApplyAreaFeature::ApplyAreaFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureID const & id,
bool isBuilding, float minPosZ, float posZ, int minVisibleScale,
bool isBuilding, bool skipAreaGeometry, float minPosZ, float posZ, int minVisibleScale,
uint8_t rank, CaptionDescription const & captions)
: TBase(tileKey, insertShape, id, minVisibleScale, rank, captions, posZ)
, m_minPosZ(minPosZ)
, m_isBuilding(isBuilding)
, m_skipAreaGeometry(skipAreaGeometry)
{}
void ApplyAreaFeature::operator()(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3)
{
if (m_isBuilding)
{
ProcessBuildingPolygon(p1, p2, p3);
if (!m_skipAreaGeometry)
ProcessBuildingPolygon(p1, p2, p3);
return;
}

View file

@ -103,7 +103,7 @@ class ApplyAreaFeature : public ApplyPointFeature
public:
ApplyAreaFeature(TileKey const & tileKey, TInsertShapeFn const & insertShape, FeatureID const & id,
bool isBuilding, float minPosZ, float posZ, int minVisibleScale,
bool isBuilding, bool skipAreaGeometry, float minPosZ, float posZ, int minVisibleScale,
uint8_t rank, CaptionDescription const & captions);
using TBase::operator ();
@ -129,6 +129,7 @@ private:
float const m_minPosZ;
bool const m_isBuilding;
bool const m_skipAreaGeometry;
};
class ApplyLineFeature : public BaseApplyFeature

View file

@ -235,16 +235,22 @@ void RuleDrawer::operator()(FeatureType const & f)
if (s.AreaStyleExists())
{
bool isBuilding = false;
bool is3dBuilding = false;
bool isBuildingOutline = false;
if (f.GetLayer() >= 0)
{
bool const hasParts = IsBuildingHasPartsChecker::Instance()(f);
bool const isPart = IsBuildingPartChecker::Instance()(f);
// Looks like nonsense, but there are some osm objects with types
// highway-path-bridge and building (sic!) at the same time (pedestrian crossing).
isBuilding = (ftypes::IsBuildingChecker::Instance()(f) ||
ftypes::IsBuildingPartChecker::Instance()(f)) &&
!ftypes::IsBridgeChecker::Instance()(f) &&
!ftypes::IsTunnelChecker::Instance()(f);
isBuilding = (isPart || ftypes::IsBuildingChecker::Instance()(f)) &&
!ftypes::IsBridgeChecker::Instance()(f) &&
!ftypes::IsTunnelChecker::Instance()(f);
isBuildingOutline = isBuilding && hasParts && !isPart;
is3dBuilding = m_is3dBuildings && (isBuilding && !isBuildingOutline);
}
bool const is3dBuilding = m_is3dBuildings && isBuilding;
m2::PointD featureCenter;
@ -301,7 +307,8 @@ void RuleDrawer::operator()(FeatureType const & f)
minVisibleScale = feature::GetMinDrawableScale(f);
ApplyAreaFeature apply(m_context->GetTileKey(), insertShape, f.GetID(),
isBuilding, areaMinHeight, areaHeight, minVisibleScale,
isBuilding, m_is3dBuildings && isBuildingOutline,
areaMinHeight, areaHeight, minVisibleScale,
f.GetRank(), s.GetCaptionDescription());
f.ForEachTriangle(apply, zoomLevel);
apply.SetHotelData(ExtractHotelData(f));

View file

@ -1,8 +1,8 @@
#include "drape_frontend/stylist.hpp"
#include "indexer/classificator.hpp"
#include "indexer/feature.hpp"
#include "indexer/feature_visibility.hpp"
#include "indexer/ftypes_matcher.hpp"
#include "indexer/drawing_rules.hpp"
#include "indexer/drules_include.hpp"
#include "indexer/scales.hpp"
@ -181,6 +181,30 @@ const uint8_t PointStyleFlag = 1 << 3;
} // namespace
IsBuildingHasPartsChecker::IsBuildingHasPartsChecker()
{
m_types.push_back(classif().GetTypeByPath({"building", "has_parts"}));
}
// static
IsBuildingHasPartsChecker const & IsBuildingHasPartsChecker::Instance()
{
static const IsBuildingHasPartsChecker inst;
return inst;
}
IsBuildingPartChecker::IsBuildingPartChecker() : BaseChecker(1 /* level */)
{
m_types.push_back(classif().GetTypeByPath({"building:part"}));
}
// static
IsBuildingPartChecker const & IsBuildingPartChecker::Instance()
{
static IsBuildingPartChecker const inst;
return inst;
}
// ==================================== //
void CaptionDescription::Init(FeatureType const & f,
@ -331,7 +355,7 @@ bool InitStylist(FeatureType const & f, int const zoomLevel, bool buildings3d, S
{
feature::TypesHolder const types(f);
if (!buildings3d && ftypes::IsBuildingPartChecker::Instance()(types) &&
if (!buildings3d && IsBuildingPartChecker::Instance()(types) &&
!ftypes::IsBuildingChecker::Instance()(types))
return false;

View file

@ -1,6 +1,7 @@
#pragma once
#include "indexer/feature_data.hpp"
#include "indexer/ftypes_matcher.hpp"
#include "indexer/drawing_rule_def.hpp"
#include "base/buffer_vector.hpp"
@ -15,6 +16,20 @@ namespace drule { class BaseRule; }
namespace df
{
class IsBuildingHasPartsChecker : public ftypes::BaseChecker
{
IsBuildingHasPartsChecker();
public:
static IsBuildingHasPartsChecker const & Instance();
};
class IsBuildingPartChecker : public ftypes::BaseChecker
{
IsBuildingPartChecker();
public:
static IsBuildingPartChecker const & Instance();
};
struct CaptionDescription
{
void Init(FeatureType const & f,

View file

@ -326,17 +326,6 @@ IsBuildingChecker const & IsBuildingChecker::Instance()
return inst;
}
IsBuildingPartChecker::IsBuildingPartChecker() : BaseChecker(1 /* level */)
{
m_types.push_back(classif().GetTypeByPath({"building:part"}));
}
IsBuildingPartChecker const & IsBuildingPartChecker::Instance()
{
static IsBuildingPartChecker const inst;
return inst;
}
IsBridgeChecker::IsBridgeChecker() : BaseChecker(3 /* level */) {}
IsBridgeChecker const & IsBridgeChecker::Instance()
{

View file

@ -128,13 +128,6 @@ public:
uint32_t GetMainType() const { return m_types[0]; }
};
class IsBuildingPartChecker : public BaseChecker
{
IsBuildingPartChecker();
public:
static IsBuildingPartChecker const & Instance();
};
class IsBridgeChecker : public BaseChecker
{
virtual bool IsMatched(uint32_t type) const override;