diff --git a/generator/feature_sorter.cpp b/generator/feature_sorter.cpp
index 8659b4d91e..0e04109076 100644
--- a/generator/feature_sorter.cpp
+++ b/generator/feature_sorter.cpp
@@ -540,9 +540,11 @@ namespace feature
fb.GetMetadata().Serialize(*w);
}
- uint64_t const osmID = fb.GetWayIDForRouting();
- if (osmID != 0)
- m_osm2ft.Add(make_pair(osmID, featureId));
+ if (!fb.GetOsmIds().empty())
+ {
+ osm::Id const osmId = fb.GetMostGenericOsmId();
+ m_osm2ft.Add(make_pair(osmId, featureId));
+ }
};
return featureId;
}
diff --git a/generator/gen_mwm_info.hpp b/generator/gen_mwm_info.hpp
index 9a36814a7b..296bec6e34 100644
--- a/generator/gen_mwm_info.hpp
+++ b/generator/gen_mwm_info.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "generator/osm_id.hpp"
+
#include "coding/read_write_utils.hpp"
#include "base/assert.hpp"
@@ -31,35 +33,32 @@ public:
}
};
-class OsmID2FeatureID : public Accumulator>
+class OsmID2FeatureID : public Accumulator>
{
typedef Accumulator BaseT;
struct LessID
{
bool operator() (ValueT const & r1, ValueT const & r2) const { return r1.first < r2.first; }
- bool operator() (uint64_t const & r1, ValueT const & r2) const { return r1 < r2.first; }
- bool operator() (ValueT const & r1, uint64_t const & r2) const { return r1.first < r2; }
+ bool operator() (osm::Id const & r1, ValueT const & r2) const { return r1 < r2.first; }
+ bool operator() (ValueT const & r1, osm::Id const & r2) const { return r1.first < r2; }
};
public:
template void Flush(TSink & sink)
{
sort(m_data.begin(), m_data.end());
-
- for (size_t i = 1; i < m_data.size(); ++i)
- CHECK_NOT_EQUAL(m_data[i-1].first, m_data[i].first, ());
-
BaseT::Flush(sink);
}
- uint32_t GetFeatureID(uint64_t osmID) const
+ /// Find a feature id for an OSM way id. Returns 0 if the feature was not found.
+ uint32_t GetRoadFeatureID(uint64_t wayId) const
{
- vector::const_iterator i = lower_bound(m_data.begin(), m_data.end(), osmID, LessID());
- if (i != m_data.end() && i->first == osmID)
- return i->second;
- else
- return 0;
+ osm::Id id = osm::Id::Way(wayId);
+ auto const it = lower_bound(m_data.begin(), m_data.end(), id, LessID());
+ if (it != m_data.end() && it->first == id)
+ return it->second;
+ return 0;
}
template
diff --git a/generator/generator_tests_support/routing_helpers.cpp b/generator/generator_tests_support/routing_helpers.cpp
index 8516fec728..dacb57a333 100644
--- a/generator/generator_tests_support/routing_helpers.cpp
+++ b/generator/generator_tests_support/routing_helpers.cpp
@@ -3,6 +3,7 @@
#include "testing/testing.hpp"
#include "generator/gen_mwm_info.hpp"
+#include "generator/osm_id.hpp"
#include "coding/file_writer.hpp"
@@ -16,7 +17,7 @@ void ReEncodeOsmIdsToFeatureIdsMapping(string const & mappingContent, string con
{
strings::SimpleTokenizer lineIter(mappingContent, "\n\r" /* line delimiters */);
- gen::Accumulator> osmIdsToFeatureIds;
+ gen::Accumulator> osmIdsToFeatureIds;
for (; lineIter; ++lineIter)
{
strings::SimpleTokenizer idIter(*lineIter, ", \t" /* id delimiters */);
@@ -29,7 +30,7 @@ void ReEncodeOsmIdsToFeatureIdsMapping(string const & mappingContent, string con
uint32_t featureId = 0;
TEST(idIter, ());
TEST(strings::to_uint(*idIter, featureId), ("Cannot convert to uint:", *idIter));
- osmIdsToFeatureIds.Add(make_pair(osmId, featureId));
+ osmIdsToFeatureIds.Add(make_pair(osm::Id::Way(osmId), featureId));
++idIter;
TEST(!idIter, ());
}
diff --git a/generator/osm_id.hpp b/generator/osm_id.hpp
index 1b7815401e..11aebc6ee4 100644
--- a/generator/osm_id.hpp
+++ b/generator/osm_id.hpp
@@ -28,8 +28,9 @@ public:
/// For debug output
string Type() const;
- bool operator<(Id const & other) const { return m_encodedId < other.m_encodedId; }
- bool operator==(Id const & other) const { return m_encodedId == other.m_encodedId; }
+ inline bool operator<(Id const & other) const { return m_encodedId < other.m_encodedId; }
+ inline bool operator==(Id const & other) const { return m_encodedId == other.m_encodedId; }
+ inline bool operator!=(Id const & other) const { return !(*this == other); }
bool operator==(uint64_t other) const { return OsmId() == other; }
};
diff --git a/generator/routing_generator.cpp b/generator/routing_generator.cpp
index 477934197f..e4148f3df7 100644
--- a/generator/routing_generator.cpp
+++ b/generator/routing_generator.cpp
@@ -120,7 +120,7 @@ void FindCrossNodes(osrm::NodeDataVectorT const & nodeData, gen::OsmID2FeatureID
auto const & startSeg = data.m_segments.front();
auto const & endSeg = data.m_segments.back();
// Check if we have geometry for our candidate.
- if (osm2ft.GetFeatureID(startSeg.wayId) || osm2ft.GetFeatureID(endSeg.wayId))
+ if (osm2ft.GetRoadFeatureID(startSeg.wayId) || osm2ft.GetRoadFeatureID(endSeg.wayId))
{
// Check mwm borders crossing.
for (m2::RegionD const & border: regionBorders)
@@ -177,7 +177,7 @@ void FindCrossNodes(osrm::NodeDataVectorT const & nodeData, gen::OsmID2FeatureID
{
FeatureType ft;
Index::FeaturesLoaderGuard loader(index, mwmId);
- if (loader.GetFeatureByIndex(osm2ft.GetFeatureID(startSeg.wayId), ft))
+ if (loader.GetFeatureByIndex(osm2ft.GetRoadFeatureID(startSeg.wayId), ft))
{
LOG(LINFO,
("Double border intersection", wgsIntersection, "rank:", GetWarningRank(ft)));
@@ -313,7 +313,7 @@ void BuildRoutingIndex(string const & baseDir, string const & countryName, strin
++all;
// now need to determine feature id and segments in it
- uint32_t const fID = osm2ft.GetFeatureID(seg.wayId);
+ uint32_t const fID = osm2ft.GetRoadFeatureID(seg.wayId);
if (fID == 0)
{
LOG(LWARNING, ("No feature id for way:", seg.wayId));
diff --git a/generator/routing_helpers.cpp b/generator/routing_helpers.cpp
index fa03c47676..7434c4283f 100644
--- a/generator/routing_helpers.cpp
+++ b/generator/routing_helpers.cpp
@@ -39,7 +39,10 @@ bool ParseOsmIdToFeatureIdMapping(string const & osmIdsToFeatureIdPath,
}
osmIdsToFeatureIds.ForEach([&](gen::OsmID2FeatureID::ValueT const & p) {
- AddFeatureId(osmIdToFeatureId, p.second /* feature id */, p.first /* osm id */);
+ if (p.first.IsWay())
+ {
+ AddFeatureId(osmIdToFeatureId, p.second /* feature id */, p.first.OsmId() /* osm id */);
+ }
});
return true;
diff --git a/omim.pro b/omim.pro
index fc038f9d9c..64afa443e1 100644
--- a/omim.pro
+++ b/omim.pro
@@ -199,7 +199,7 @@ SUBDIRS = 3party base coding geometry editor indexer routing routing_common sear
SUBDIRS *= routing_integration_tests
routing_consistency_tests.subdir = routing/routing_consistency_tests
- routing_consistency_tests.depends = $$MapDepLibs routing
+ routing_consistency_tests.depends = $$MapDepLibs routing generator
SUBDIRS *= routing_consistency_tests
srtm_coverage_checker.subdir = generator/srtm_coverage_checker