Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-11-07 11:12:10 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-11-10 18:58:21 +0300
commit39a135b2c72c485c6ebaf39f1a911248724cd32d (patch)
tree573fa7e1566218c123ed0568a7f7ab2e78ad2685 /generator
parent6209cee4684b48429617920016f69f087c48ea1a (diff)
Reorganization code to remote FeaturesCollector::GetNextFeatureId at all.
Diffstat (limited to 'generator')
-rw-r--r--generator/feature_generator.hpp6
-rw-r--r--generator/feature_sorter.cpp13
-rw-r--r--generator/polygonizer.hpp5
-rw-r--r--generator/restriction_generator.cpp2
4 files changed, 14 insertions, 12 deletions
diff --git a/generator/feature_generator.hpp b/generator/feature_generator.hpp
index 1a4bcc4ce7..4a5a941f9f 100644
--- a/generator/feature_generator.hpp
+++ b/generator/feature_generator.hpp
@@ -22,7 +22,6 @@ protected:
FileWriter m_datFile;
m2::RectD m_bounds;
- uint32_t GetNextFeatureId() const { return m_featureID; }
private:
void Write(char const * src, size_t size);
void FlushBuffer();
@@ -41,7 +40,10 @@ public:
string const & GetFilePath() const { return m_datFile.GetName(); }
/// \brief Serializes |f|.
- /// \returns feature id of serialized feature.
+ /// \returns feature id of serialized feature if |f| is serialized after the call
+ /// and numeric_limits<uint32_t>::max() if not.
+ /// \note See implementation operator() in derived class for cases when |f| cannot be
+ /// serialized.
virtual uint32_t operator()(FeatureBuilder1 const & f);
};
diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp
index 43a0fc9a98..b82c81a389 100644
--- a/generator/feature_sorter.cpp
+++ b/generator/feature_sorter.cpp
@@ -27,6 +27,8 @@
#include "base/scope_guard.hpp"
#include "base/string_utils.hpp"
+#include "std/limits.hpp"
+
namespace
{
typedef pair<uint64_t, uint64_t> CellAndOffsetT;
@@ -520,11 +522,12 @@ namespace feature
}
}
+ uint32_t featureId = numeric_limits<uint32_t>::max();
if (fb.PreSerialize(holder.m_buffer))
{
fb.Serialize(holder.m_buffer, m_header.GetDefCodingParams());
- uint32_t const ftID = WriteFeatureBase(holder.m_buffer.m_buffer, fb);
+ featureId = WriteFeatureBase(holder.m_buffer.m_buffer, fb);
fb.GetAddressData().Serialize(*(m_helperFile[SEARCH_TOKENS]));
@@ -535,17 +538,15 @@ namespace feature
uint64_t const offset = w->Pos();
ASSERT_LESS_OR_EQUAL(offset, numeric_limits<uint32_t>::max(), ());
- m_metadataIndex.emplace_back(ftID, static_cast<uint32_t>(offset));
+ m_metadataIndex.emplace_back(featureId, static_cast<uint32_t>(offset));
fb.GetMetadata().Serialize(*w);
}
uint64_t const osmID = fb.GetWayIDForRouting();
if (osmID != 0)
- m_osm2ft.Add(make_pair(osmID, ftID));
+ m_osm2ft.Add(make_pair(osmID, featureId));
};
- // Note. GetNextFeatureId() returns 0 in the first call of
- // fb.PreSerialize(holder.m_buffer) returns false.
- return GetNextFeatureId() == 0 ? 0 : GetNextFeatureId();
+ return featureId;
}
};
diff --git a/generator/polygonizer.hpp b/generator/polygonizer.hpp
index 4e789d8000..48a4f1ab35 100644
--- a/generator/polygonizer.hpp
+++ b/generator/polygonizer.hpp
@@ -166,11 +166,10 @@ namespace feature
m_currentNames += country->m_name;
auto & bucket = *(m_Buckets[country->m_index]);
- uint32_t const nextFeatureId = bucket(fb);
+ uint32_t const featureId = bucket(fb);
- CHECK_LESS(0, nextFeatureId, ("GetNextFeatureId() is called before WriteFeatureBase(...)"));
if (fb.IsLine())
- featureId2osmIds.Write(nextFeatureId - 1 /* feature id of |fb| */, fb.GetOsmIds());
+ featureId2osmIds.Write(featureId /* feature id of |fb| */, fb.GetOsmIds());
}
vector<string> const & Names() const
diff --git a/generator/restriction_generator.cpp b/generator/restriction_generator.cpp
index 5f96f72a5e..bfb9979c65 100644
--- a/generator/restriction_generator.cpp
+++ b/generator/restriction_generator.cpp
@@ -63,7 +63,7 @@ bool BuildRoadRestrictions(string const & mwmPath, string const & restrictionPat
RoutingHeader header;
header.m_noRestrictionCount = distance(restrictions.cbegin(), firstOnlyIt);
header.m_onlyRestrictionCount = restrictions.size() - header.m_noRestrictionCount;
- LOG(LINFO, ("Header info. There are", header.m_noRestrictionCount, "and",
+ LOG(LINFO, ("Header info. There are", header.m_noRestrictionCount, "no restrictions and",
header.m_onlyRestrictionCount, "only restrictions"));
FilesContainerW cont(mwmPath, FileWriter::OP_WRITE_EXISTING);