From c8d53fa85cc413f6a1c3dfbdb1bf15a71792f265 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Fri, 29 Jul 2016 10:59:18 +0300 Subject: [PATCH 1/5] Separating preparing altitudes for saving and writing them. Using bit writer to save them. --- indexer/feature_altitude.cpp | 58 ++++++++++++++++++++++++++++++++++++ indexer/feature_altitude.hpp | 44 +++++++++++---------------- indexer/indexer.pro | 1 + 3 files changed, 76 insertions(+), 27 deletions(-) create mode 100644 indexer/feature_altitude.cpp diff --git a/indexer/feature_altitude.cpp b/indexer/feature_altitude.cpp new file mode 100644 index 0000000000..2cff07fc39 --- /dev/null +++ b/indexer/feature_altitude.cpp @@ -0,0 +1,58 @@ +#include "indexer/feature_altitude.hpp" + +#include "base/bits.hpp" + +namespace feature +{ +void Altitudes::PrepareSerializationData(TAltitude minAltitude, vector & deviations) const +{ + CHECK(!m_altitudes.empty(), ()); + + deviations.clear(); + uint32_t const firstPntDeviation = + bits::ZigZagEncode(static_cast(m_altitudes[0]) - + static_cast(minAltitude)) + 1 /* making it more than zero */; + CHECK_LESS(0, firstPntDeviation, ()); + deviations.push_back(firstPntDeviation); + for (size_t i = 1; i < m_altitudes.size(); ++i) + { + uint32_t const nextPntDeviation = bits::ZigZagEncode(static_cast(m_altitudes[i]) - + static_cast(m_altitudes[i - 1])) + 1 /* making it more than zero */; + CHECK_LESS(0, nextPntDeviation, ()); + deviations.push_back(nextPntDeviation); + } +} + +bool Altitudes::FillAltitudesByDeserializedDate(TAltitude minAltitude, vector const & deviations) +{ + m_altitudes.clear(); + if (deviations.size() == 0) + { + ASSERT(false, ()); + return false; + } + + m_altitudes.resize(deviations.size()); + TAltitude prevAltitude = minAltitude; + for (size_t i = 0; i < deviations.size(); ++i) + { + if (deviations[i] == 0) + { + ASSERT(false, (i)); + m_altitudes.clear(); + return false; + } + + m_altitudes[i] = static_cast(bits::ZigZagDecode(deviations[i] - + 1 /* Recovering value */) + prevAltitude); + if (m_altitudes[i] < minAltitude) + { + ASSERT(false, (i)); + m_altitudes.clear(); + return false; + } + prevAltitude = m_altitudes[i]; + } + return true; +} +} // namespace feature diff --git a/indexer/feature_altitude.hpp b/indexer/feature_altitude.hpp index 81b0c918ed..755ecb0be3 100644 --- a/indexer/feature_altitude.hpp +++ b/indexer/feature_altitude.hpp @@ -1,4 +1,6 @@ #pragma once +#include "coding/bit_streams.hpp" +#include "coding/elias_coder.hpp" #include "coding/reader.hpp" #include "coding/varint.hpp" #include "coding/write_to_sink.hpp" @@ -51,7 +53,7 @@ struct AltitudeHeader size_t GetFeatureTableSize() const { return m_altitudesOffset - m_featureTableOffset; } - size_t GetAltitudeInfo() const { return m_endOffset - m_altitudesOffset; } + size_t GetAltitudeInfoSize() const { return m_endOffset - m_altitudesOffset; } void Reset() { @@ -81,40 +83,24 @@ public: template void Serialize(TAltitude minAltitude, TSink & sink) const { - CHECK(!m_altitudes.empty(), ()); + vector deviations; + PrepareSerializationData(minAltitude, deviations); - WriteVarInt(sink, static_cast(m_altitudes[0]) - static_cast(minAltitude)); - for (size_t i = 1; i < m_altitudes.size(); ++i) - { - WriteVarInt(sink, - static_cast(m_altitudes[i]) - static_cast(m_altitudes[i - 1])); - } + BitWriter bits(sink); + for (auto const d : deviations) + coding::DeltaCoder::Encode(bits, d); } template bool Deserialize(TAltitude minAltitude, size_t pointCount, TSource & src) { - m_altitudes.clear(); - if (pointCount == 0) - { - ASSERT(false, ()); - return false; - } + vector deviations(pointCount); + BitReader bits(src); - m_altitudes.resize(pointCount); - TAltitude prevAltitude = minAltitude; for (size_t i = 0; i < pointCount; ++i) - { - m_altitudes[i] = static_cast(ReadVarInt(src) + prevAltitude); - if (m_altitudes[i] < minAltitude) - { - ASSERT(false, ()); - m_altitudes.clear(); - return false; - } - prevAltitude = m_altitudes[i]; - } - return true; + deviations[i] = coding::DeltaCoder::Decode(bits); + + return FillAltitudesByDeserializedDate(minAltitude, deviations); } /// \note |m_altitudes| is a vector of feature point altitudes. There's two possibilities: @@ -122,5 +108,9 @@ public: /// * size of |m_pointAlt| is equal to the number of this feature's points. If so /// all items of |m_altitudes| have valid value. TAltitudes m_altitudes; + +private: + void PrepareSerializationData(TAltitude minAltitude, vector & deviations) const; + bool FillAltitudesByDeserializedDate(TAltitude minAltitude, vector const & deviations); }; } // namespace feature diff --git a/indexer/indexer.pro b/indexer/indexer.pro index f5b6d8e255..905a1f3c0c 100644 --- a/indexer/indexer.pro +++ b/indexer/indexer.pro @@ -29,6 +29,7 @@ SOURCES += \ edits_migration.cpp \ feature.cpp \ feature_algo.cpp \ + feature_altitude.cpp \ feature_covering.cpp \ feature_data.cpp \ feature_decl.cpp \ From 6cf3bf60339f91c133755e0b1a46b69583ae9091 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 3 Aug 2016 10:14:29 +0300 Subject: [PATCH 2/5] Review fixes. --- indexer/feature_altitude.cpp | 42 +++++++++++++++--------------------- indexer/feature_altitude.hpp | 27 +++++++++++++++-------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/indexer/feature_altitude.cpp b/indexer/feature_altitude.cpp index 2cff07fc39..c8b5182136 100644 --- a/indexer/feature_altitude.cpp +++ b/indexer/feature_altitude.cpp @@ -4,50 +4,42 @@ namespace feature { -void Altitudes::PrepareSerializationData(TAltitude minAltitude, vector & deviations) const +void Altitudes::PrepareSerializationDate(TAltitude minAltitude, vector & deltas) const { CHECK(!m_altitudes.empty(), ()); + CHECK_LESS_OR_EQUAL(minAltitude, m_altitudes[0], ()); - deviations.clear(); + deltas.resize(m_altitudes.size()); uint32_t const firstPntDeviation = bits::ZigZagEncode(static_cast(m_altitudes[0]) - - static_cast(minAltitude)) + 1 /* making it more than zero */; - CHECK_LESS(0, firstPntDeviation, ()); - deviations.push_back(firstPntDeviation); + static_cast(minAltitude)); + + deltas[0] = firstPntDeviation; for (size_t i = 1; i < m_altitudes.size(); ++i) { - uint32_t const nextPntDeviation = bits::ZigZagEncode(static_cast(m_altitudes[i]) - - static_cast(m_altitudes[i - 1])) + 1 /* making it more than zero */; - CHECK_LESS(0, nextPntDeviation, ()); - deviations.push_back(nextPntDeviation); + CHECK_LESS_OR_EQUAL(minAltitude, m_altitudes[i], (i)); + deltas[i] = bits::ZigZagEncode(static_cast(m_altitudes[i]) - + static_cast(m_altitudes[i - 1])); } } -bool Altitudes::FillAltitudesByDeserializedDate(TAltitude minAltitude, vector const & deviations) +bool Altitudes::FillAltitudesByDeserializedDate(TAltitude minAltitude, vector const & deltas) { - m_altitudes.clear(); - if (deviations.size() == 0) + m_altitudes.resize(deltas.size()); + if (deltas.size() == 0) { - ASSERT(false, ()); + ASSERT(false, ("A vector of delta altitudes readed from mwm are empty.")); + m_altitudes.clear(); return false; } - m_altitudes.resize(deviations.size()); TAltitude prevAltitude = minAltitude; - for (size_t i = 0; i < deviations.size(); ++i) + for (size_t i = 0; i < deltas.size(); ++i) { - if (deviations[i] == 0) - { - ASSERT(false, (i)); - m_altitudes.clear(); - return false; - } - - m_altitudes[i] = static_cast(bits::ZigZagDecode(deviations[i] - - 1 /* Recovering value */) + prevAltitude); + m_altitudes[i] = static_cast(bits::ZigZagDecode(deltas[i]) + prevAltitude); if (m_altitudes[i] < minAltitude) { - ASSERT(false, (i)); + ASSERT(false, ("A point altitude readed from file is less then min mwm altitude. Point number in its feature is", i)); m_altitudes.clear(); return false; } diff --git a/indexer/feature_altitude.hpp b/indexer/feature_altitude.hpp index 755ecb0be3..ceca72aa9f 100644 --- a/indexer/feature_altitude.hpp +++ b/indexer/feature_altitude.hpp @@ -83,24 +83,33 @@ public: template void Serialize(TAltitude minAltitude, TSink & sink) const { - vector deviations; - PrepareSerializationData(minAltitude, deviations); + vector deltas; + PrepareSerializationDate(minAltitude, deltas); BitWriter bits(sink); - for (auto const d : deviations) - coding::DeltaCoder::Encode(bits, d); + for (auto const d : deltas) + coding::DeltaCoder::Encode(bits, d + 1 /* making it greater than zero */); } template bool Deserialize(TAltitude minAltitude, size_t pointCount, TSource & src) { - vector deviations(pointCount); + vector deltas(pointCount); BitReader bits(src); for (size_t i = 0; i < pointCount; ++i) - deviations[i] = coding::DeltaCoder::Decode(bits); + { + uint32_t const decoded = coding::DeltaCoder::Decode(bits); + if (decoded == 0) + { + ASSERT(false, (i)); + m_altitudes.clear(); + return false; + } + deltas[i] = decoded - 1 /* recovering value */; + } - return FillAltitudesByDeserializedDate(minAltitude, deviations); + return FillAltitudesByDeserializedDate(minAltitude, deltas); } /// \note |m_altitudes| is a vector of feature point altitudes. There's two possibilities: @@ -110,7 +119,7 @@ public: TAltitudes m_altitudes; private: - void PrepareSerializationData(TAltitude minAltitude, vector & deviations) const; - bool FillAltitudesByDeserializedDate(TAltitude minAltitude, vector const & deviations); + void PrepareSerializationDate(TAltitude minAltitude, vector & deltas) const; + bool FillAltitudesByDeserializedDate(TAltitude minAltitude, vector const & deltas); }; } // namespace feature From f6fb8db5ba00ad635d71ac86c27e2455db0fcb73 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 3 Aug 2016 10:57:52 +0300 Subject: [PATCH 3/5] Altitudes. Getting rid of deltas. --- indexer/feature_altitude.cpp | 50 ------------------------------------ indexer/feature_altitude.hpp | 40 +++++++++++++++++++---------- indexer/indexer.pro | 1 - 3 files changed, 27 insertions(+), 64 deletions(-) delete mode 100644 indexer/feature_altitude.cpp diff --git a/indexer/feature_altitude.cpp b/indexer/feature_altitude.cpp deleted file mode 100644 index c8b5182136..0000000000 --- a/indexer/feature_altitude.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "indexer/feature_altitude.hpp" - -#include "base/bits.hpp" - -namespace feature -{ -void Altitudes::PrepareSerializationDate(TAltitude minAltitude, vector & deltas) const -{ - CHECK(!m_altitudes.empty(), ()); - CHECK_LESS_OR_EQUAL(minAltitude, m_altitudes[0], ()); - - deltas.resize(m_altitudes.size()); - uint32_t const firstPntDeviation = - bits::ZigZagEncode(static_cast(m_altitudes[0]) - - static_cast(minAltitude)); - - deltas[0] = firstPntDeviation; - for (size_t i = 1; i < m_altitudes.size(); ++i) - { - CHECK_LESS_OR_EQUAL(minAltitude, m_altitudes[i], (i)); - deltas[i] = bits::ZigZagEncode(static_cast(m_altitudes[i]) - - static_cast(m_altitudes[i - 1])); - } -} - -bool Altitudes::FillAltitudesByDeserializedDate(TAltitude minAltitude, vector const & deltas) -{ - m_altitudes.resize(deltas.size()); - if (deltas.size() == 0) - { - ASSERT(false, ("A vector of delta altitudes readed from mwm are empty.")); - m_altitudes.clear(); - return false; - } - - TAltitude prevAltitude = minAltitude; - for (size_t i = 0; i < deltas.size(); ++i) - { - m_altitudes[i] = static_cast(bits::ZigZagDecode(deltas[i]) + prevAltitude); - if (m_altitudes[i] < minAltitude) - { - ASSERT(false, ("A point altitude readed from file is less then min mwm altitude. Point number in its feature is", i)); - m_altitudes.clear(); - return false; - } - prevAltitude = m_altitudes[i]; - } - return true; -} -} // namespace feature diff --git a/indexer/feature_altitude.hpp b/indexer/feature_altitude.hpp index ceca72aa9f..67a10d8cef 100644 --- a/indexer/feature_altitude.hpp +++ b/indexer/feature_altitude.hpp @@ -6,6 +6,7 @@ #include "coding/write_to_sink.hpp" #include "base/assert.hpp" +#include "base/bits.hpp" #include "std/cstdint.hpp" #include "std/limits.hpp" @@ -83,33 +84,50 @@ public: template void Serialize(TAltitude minAltitude, TSink & sink) const { - vector deltas; - PrepareSerializationDate(minAltitude, deltas); + CHECK(!m_altitudes.empty(), ()); BitWriter bits(sink); - for (auto const d : deltas) - coding::DeltaCoder::Encode(bits, d + 1 /* making it greater than zero */); + TAltitude prevAltitude = minAltitude; + for (auto const a : m_altitudes) + { + CHECK_LESS_OR_EQUAL(minAltitude, a, ("A point altitude is less then min mwm altitude")); + uint32_t const delta = bits::ZigZagEncode(static_cast(a) - + static_cast(prevAltitude)); + coding::DeltaCoder::Encode(bits, delta + 1 /* making it greater than zero */); + prevAltitude = a; + } } template bool Deserialize(TAltitude minAltitude, size_t pointCount, TSource & src) { - vector deltas(pointCount); + ASSERT_NOT_EQUAL(pointCount, 0, ()); + BitReader bits(src); + TAltitude prevAltitude = minAltitude; + m_altitudes.resize(pointCount); for (size_t i = 0; i < pointCount; ++i) { uint32_t const decoded = coding::DeltaCoder::Decode(bits); if (decoded == 0) { - ASSERT(false, (i)); + ASSERT(false, ("Decoded altitude delta is zero. Point number in its feature is", i)); m_altitudes.clear(); return false; } - deltas[i] = decoded - 1 /* recovering value */; - } + uint32_t const delta = decoded - 1 /* recovering value */; - return FillAltitudesByDeserializedDate(minAltitude, deltas); + m_altitudes[i] = static_cast(bits::ZigZagDecode(delta) + prevAltitude); + if (m_altitudes[i] < minAltitude) + { + ASSERT(false, ("A point altitude readed from file is less then min mwm altitude. Point number in its feature is", i)); + m_altitudes.clear(); + return false; + } + prevAltitude = m_altitudes[i]; + } + return true; } /// \note |m_altitudes| is a vector of feature point altitudes. There's two possibilities: @@ -117,9 +135,5 @@ public: /// * size of |m_pointAlt| is equal to the number of this feature's points. If so /// all items of |m_altitudes| have valid value. TAltitudes m_altitudes; - -private: - void PrepareSerializationDate(TAltitude minAltitude, vector & deltas) const; - bool FillAltitudesByDeserializedDate(TAltitude minAltitude, vector const & deltas); }; } // namespace feature diff --git a/indexer/indexer.pro b/indexer/indexer.pro index 905a1f3c0c..f5b6d8e255 100644 --- a/indexer/indexer.pro +++ b/indexer/indexer.pro @@ -29,7 +29,6 @@ SOURCES += \ edits_migration.cpp \ feature.cpp \ feature_algo.cpp \ - feature_altitude.cpp \ feature_covering.cpp \ feature_data.cpp \ feature_decl.cpp \ From d90fbb6c9fe7a1ea3afcdb976f48d4f4316fcde3 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Wed, 3 Aug 2016 12:41:42 +0300 Subject: [PATCH 4/5] Adding padding at the end of altitude section and review fixes. --- generator/altitude_generator.cpp | 4 ++-- indexer/feature_altitude.hpp | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/generator/altitude_generator.cpp b/generator/altitude_generator.cpp index 4b3d0e7088..d90a6d008f 100644 --- a/generator/altitude_generator.cpp +++ b/generator/altitude_generator.cpp @@ -213,6 +213,7 @@ void BuildRoadAltitudes(string const & mwmPath, AltitudeGetter & altitudeGetter) // Writing altitude info. header.m_altitudesOffset = w.Pos() - startOffset; w.Write(deltas.data(), deltas.size()); + w.WritePaddingByEnd(8); header.m_endOffset = w.Pos() - startOffset; // Rewriting header info. @@ -220,8 +221,7 @@ void BuildRoadAltitudes(string const & mwmPath, AltitudeGetter & altitudeGetter) w.Seek(startOffset); header.Serialize(w); w.Seek(endOffset); - LOG(LINFO, (ALTITUDES_FILE_TAG, "section is ready. The size is", endOffset - startOffset, - "min altitude is", processor.GetMinAltitude())); + LOG(LINFO, (ALTITUDES_FILE_TAG, "section is ready. The size is", header.m_endOffset)); if (processor.HasAltitudeInfo()) LOG(LINFO, ("Min altitude is", processor.GetMinAltitude())); else diff --git a/indexer/feature_altitude.hpp b/indexer/feature_altitude.hpp index 67a10d8cef..8d4071e231 100644 --- a/indexer/feature_altitude.hpp +++ b/indexer/feature_altitude.hpp @@ -1,4 +1,5 @@ #pragma once + #include "coding/bit_streams.hpp" #include "coding/elias_coder.hpp" #include "coding/reader.hpp" @@ -88,13 +89,13 @@ public: BitWriter bits(sink); TAltitude prevAltitude = minAltitude; - for (auto const a : m_altitudes) + for (auto const altitude : m_altitudes) { - CHECK_LESS_OR_EQUAL(minAltitude, a, ("A point altitude is less then min mwm altitude")); - uint32_t const delta = bits::ZigZagEncode(static_cast(a) - + CHECK_LESS_OR_EQUAL(minAltitude, altitude, ("A point altitude is less than min mwm altitude")); + uint32_t const delta = bits::ZigZagEncode(static_cast(altitude) - static_cast(prevAltitude)); coding::DeltaCoder::Encode(bits, delta + 1 /* making it greater than zero */); - prevAltitude = a; + prevAltitude = altitude; } } @@ -109,19 +110,20 @@ public: for (size_t i = 0; i < pointCount; ++i) { - uint32_t const decoded = coding::DeltaCoder::Decode(bits); - if (decoded == 0) + uint32_t const biasedDelta = coding::DeltaCoder::Decode(bits); + if (biasedDelta == 0) { ASSERT(false, ("Decoded altitude delta is zero. Point number in its feature is", i)); m_altitudes.clear(); return false; } - uint32_t const delta = decoded - 1 /* recovering value */; + uint32_t const delta = biasedDelta - 1; m_altitudes[i] = static_cast(bits::ZigZagDecode(delta) + prevAltitude); if (m_altitudes[i] < minAltitude) { - ASSERT(false, ("A point altitude readed from file is less then min mwm altitude. Point number in its feature is", i)); + ASSERT(false, ("A point altitude read from file(", m_altitudes[i], + ") is less than min mwm altitude(", minAltitude, "). Point number in its feature is", i)); m_altitudes.clear(); return false; } From 021a94715c3e9dd343fef8248b46e7448aa2d7de Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Thu, 4 Aug 2016 09:09:54 +0300 Subject: [PATCH 5/5] Implementing better logging in case of errors. --- indexer/altitude_loader.cpp | 21 +++++++++++++-------- indexer/altitude_loader.hpp | 2 ++ indexer/feature_altitude.hpp | 11 +++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/indexer/altitude_loader.cpp b/indexer/altitude_loader.cpp index a794c96537..cb05bc4cf6 100644 --- a/indexer/altitude_loader.cpp +++ b/indexer/altitude_loader.cpp @@ -31,6 +31,8 @@ namespace feature { AltitudeLoader::AltitudeLoader(MwmValue const & mwmValue) { + m_countryFileName = mwmValue.GetCountryFileName(); + if (mwmValue.GetHeader().GetFormat() < version::Format::v8) return; @@ -50,7 +52,7 @@ AltitudeLoader::AltitudeLoader(MwmValue const & mwmValue) catch (Reader::OpenException const & e) { m_header.Reset(); - LOG(LERROR, ("Error while reading", ALTITUDES_FILE_TAG, "section.", e.Msg())); + LOG(LERROR, ("File", m_countryFileName, "Error while reading", ALTITUDES_FILE_TAG, "section.", e.Msg())); } } @@ -73,31 +75,34 @@ TAltitudes const & AltitudeLoader::GetAltitudes(uint32_t featureId, size_t point if (!m_altitudeAvailability[featureId]) { - LOG(LINFO, ("Feature featureId =", featureId, "does not contain any altitude information.")); + LOG(LDEBUG, ("Feature Id", featureId, "of", m_countryFileName, + "does not contain any altitude information.")); return m_cache.insert(make_pair(featureId, TAltitudes(pointCount, m_header.m_minAltitude))).first->second; } uint64_t const r = m_altitudeAvailability.rank(featureId); - CHECK_LESS(r, m_altitudeAvailability.size(), (featureId)); + CHECK_LESS(r, m_altitudeAvailability.size(), ("Feature Id", featureId, "of", m_countryFileName)); uint64_t const offset = m_featureTable.select(r); - CHECK_LESS_OR_EQUAL(offset, m_featureTable.size(), (featureId)); + CHECK_LESS_OR_EQUAL(offset, m_featureTable.size(), ("Feature Id", featureId, "of", m_countryFileName)); uint64_t const altitudeInfoOffsetInSection = m_header.m_altitudesOffset + offset; - CHECK_LESS(altitudeInfoOffsetInSection, m_reader->Size(), ()); + CHECK_LESS(altitudeInfoOffsetInSection, m_reader->Size(), ("Feature Id", featureId, "of", m_countryFileName)); try { Altitudes altitudes; ReaderSource src(*m_reader); src.Skip(altitudeInfoOffsetInSection); - bool const isDeserialized = altitudes.Deserialize(m_header.m_minAltitude, pointCount, src); + bool const isDeserialized = altitudes.Deserialize(m_header.m_minAltitude, pointCount, + m_countryFileName, featureId, src); bool const allValid = isDeserialized && none_of(altitudes.m_altitudes.begin(), altitudes.m_altitudes.end(), [](TAltitude a) { return a == kInvalidAltitude; }); if (!allValid) { - ASSERT(false, (altitudes.m_altitudes)); + LOG(LERROR, ("Only a part point of a feature has a valid altitdue. Altitudes: ", altitudes.m_altitudes, + ". Feature Id", featureId, "of", m_countryFileName)); return m_cache.insert(make_pair(featureId, TAltitudes(pointCount, m_header.m_minAltitude))).first->second; } @@ -105,7 +110,7 @@ TAltitudes const & AltitudeLoader::GetAltitudes(uint32_t featureId, size_t point } catch (Reader::OpenException const & e) { - LOG(LERROR, ("Error while getting altitude data", e.Msg())); + LOG(LERROR, ("Feature Id", featureId, "of", m_countryFileName, ". Error while getting altitude data:", e.Msg())); return m_cache.insert(make_pair(featureId, TAltitudes(pointCount, m_header.m_minAltitude))).first->second; } } diff --git a/indexer/altitude_loader.hpp b/indexer/altitude_loader.hpp index ff76fd9ba9..0586fa2d33 100644 --- a/indexer/altitude_loader.hpp +++ b/indexer/altitude_loader.hpp @@ -4,6 +4,7 @@ #include "coding/memory_region.hpp" +#include "std/string.hpp" #include "std/unique_ptr.hpp" #include "std/vector.hpp" @@ -32,5 +33,6 @@ private: unique_ptr m_reader; map m_cache; AltitudeHeader m_header; + string m_countryFileName; }; } // namespace feature diff --git a/indexer/feature_altitude.hpp b/indexer/feature_altitude.hpp index 8d4071e231..41f1f3a7da 100644 --- a/indexer/feature_altitude.hpp +++ b/indexer/feature_altitude.hpp @@ -100,7 +100,8 @@ public: } template - bool Deserialize(TAltitude minAltitude, size_t pointCount, TSource & src) + bool Deserialize(TAltitude minAltitude, size_t pointCount, string const & countryFileName, + uint32_t featureId, TSource & src) { ASSERT_NOT_EQUAL(pointCount, 0, ()); @@ -113,7 +114,8 @@ public: uint32_t const biasedDelta = coding::DeltaCoder::Decode(bits); if (biasedDelta == 0) { - ASSERT(false, ("Decoded altitude delta is zero. Point number in its feature is", i)); + LOG(LERROR, ("Decoded altitude delta is zero. File", countryFileName, + ". Feature Id", featureId, ". Point number in the feature", i, ".")); m_altitudes.clear(); return false; } @@ -122,8 +124,9 @@ public: m_altitudes[i] = static_cast(bits::ZigZagDecode(delta) + prevAltitude); if (m_altitudes[i] < minAltitude) { - ASSERT(false, ("A point altitude read from file(", m_altitudes[i], - ") is less than min mwm altitude(", minAltitude, "). Point number in its feature is", i)); + LOG(LERROR, ("A point altitude read from file(", m_altitudes[i], + ") is less than min mwm altitude(", minAltitude, "). File ", + countryFileName, ". Feature Id", featureId, ". Point number in the feature", i, ".")); m_altitudes.clear(); return false; }