[indexer][editor] crash fix for FeatureType which were created from EditableMapObjects

This commit is contained in:
Arsentiy Milchakov 2019-04-16 20:56:30 +03:00 committed by Tatiana Yan
parent 4fd525adc6
commit b2aac0af7c
3 changed files with 13 additions and 5 deletions

View file

@ -196,21 +196,27 @@ FeatureType::FeatureType(SharedLoadInfo const * loadInfo, Buffer buffer)
FeatureType::FeatureType(osm::MapObject const & emo)
{
uint8_t const geomType = emo.GetGeomType();
EHeaderTypeMask geomType = HEADER_GEOM_POINT;
m_limitRect.MakeEmpty();
switch (geomType)
switch (emo.GetGeomType())
{
case feature::GEOM_UNDEFINED:
// It is not possible because of FeatureType::GetFeatureType() never returns GEOM_UNDEFINED.
UNREACHABLE();
case feature::GEOM_POINT:
geomType = HEADER_GEOM_POINT;
m_center = emo.GetMercator();
m_limitRect.Add(m_center);
break;
case feature::GEOM_LINE:
geomType = HEADER_GEOM_LINE;
m_points = Points(emo.GetPoints().begin(), emo.GetPoints().end());
for (auto const & p : m_points)
m_limitRect.Add(p);
break;
case feature::GEOM_AREA:
geomType = HEADER_GEOM_AREA;
m_triangles = Points(emo.GetTriangesAsPoints().begin(), emo.GetTriangesAsPoints().end());
for (auto const & p : m_triangles)
m_limitRect.Add(p);
@ -242,6 +248,8 @@ FeatureType::FeatureType(osm::MapObject const & emo)
feature::EGeomType FeatureType::GetFeatureType() const
{
// FeatureType::FeatureType(osm::MapObject const & emo) expects
// that GEOM_UNDEFINED is never be returned.
switch (m_header & HEADER_GEOTYPE_MASK)
{
case HEADER_GEOM_LINE: return GEOM_LINE;

View file

@ -131,7 +131,7 @@ private:
namespace feature
{
uint8_t CalculateHeader(size_t const typesCount, uint8_t const headerGeomType,
uint8_t CalculateHeader(size_t const typesCount, EHeaderTypeMask const headerGeomType,
FeatureParamsBase const & params)
{
ASSERT(typesCount != 0, ("Feature should have at least one type."));
@ -562,7 +562,7 @@ bool FeatureParams::CheckValid() const
uint8_t FeatureParams::GetHeader() const
{
return CalculateHeader(m_types.size(), GetTypeMask(), *this);
return CalculateHeader(m_types.size(), static_cast<EHeaderTypeMask>(GetTypeMask()), *this);
}
uint32_t FeatureParams::GetIndexForType(uint32_t t)

View file

@ -126,7 +126,7 @@ namespace feature
std::string DebugPrint(TypesHolder const & holder);
uint8_t CalculateHeader(size_t const typesCount, uint8_t const headerGeomType,
uint8_t CalculateHeader(size_t const typesCount, EHeaderTypeMask const headerGeomType,
FeatureParamsBase const & params);
} // namespace feature