diff --git a/routing/osrm2feature_map.cpp b/routing/osrm2feature_map.cpp index f9eac00054..8924a57ec1 100644 --- a/routing/osrm2feature_map.cpp +++ b/routing/osrm2feature_map.cpp @@ -153,6 +153,8 @@ void OsrmFtSegMapping::Load(FilesMappingContainer & cont, platform::LocalCountry { ReaderSource src(cont.GetReader(ROUTING_NODEIND_TO_FTSEGIND_FILE_TAG)); uint32_t const count = ReadVarUint(src); + if (count == 0) + return; m_offsets.resize(count); for (uint32_t i = 0; i < count; ++i) { diff --git a/routing/routing_integration_tests/cross_section_tests.cpp b/routing/routing_integration_tests/cross_section_tests.cpp index 6396469f21..b248ed583a 100644 --- a/routing/routing_integration_tests/cross_section_tests.cpp +++ b/routing/routing_integration_tests/cross_section_tests.cpp @@ -1,6 +1,8 @@ #include "testing/testing.hpp" #include "routing/cross_routing_context.hpp" +#include "routing/osrm2feature_map.hpp" +#include "routing/routing_mapping.hpp" #include "platform/local_country_file.hpp" #include "platform/local_country_file_utils.hpp" @@ -8,6 +10,7 @@ #include "geometry/point2d.hpp" +#include "base/buffer_vector.hpp" #include "base/logging.hpp" #include "std/limits.hpp" @@ -70,4 +73,54 @@ UNIT_TEST(CheckCrossSections) LOG(LINFO, ("Found", localFiles.size(), "countries.", noRouting, "countries are without routing file.")); } + +UNIT_TEST(CheckOsrmToFeatureMapping) +{ + vector localFiles; + platform::FindAllLocalMapsAndCleanup(numeric_limits::max() /* latestVersion */, + localFiles); + + size_t errors = 0; + size_t checked = 0; + for (auto & file : localFiles) + { + LOG(LINFO, ("Checking nodes for country:", file.GetCountryName())); + + file.SyncWithDisk(); + if (file.GetFiles() != MapOptions::MapWithCarRouting) + { + LOG(LINFO, ("Warning! Routing file not found for:", file.GetCountryName())); + continue; + } + + FilesMappingContainer container(file.GetPath(MapOptions::CarRouting)); + if (!container.IsExist(ROUTING_FTSEG_FILE_TAG)) + { + LOG(LINFO, ("Warning! Mwm file has not routing ftseg section:", file.GetCountryName())); + continue; + } + ++checked; + + routing::TDataFacade dataFacade; + dataFacade.Load(container); + + OsrmFtSegMapping segMapping; + segMapping.Load(container, file); + segMapping.Map(container); + + for (size_t i = 0; i < dataFacade.GetNumberOfNodes(); ++i) + { + buffer_vector buffer; + segMapping.ForEachFtSeg(i, MakeBackInsertFunctor(buffer)); + if (buffer.empty()) + { + LOG(LINFO, ("Error found in ", file.GetCountryName())); + errors++; + break; + } + } + } + LOG(LINFO, ("Found", localFiles.size(), "countries. In", checked, "maps with routing have", errors, "with errors.")); + TEST_EQUAL(errors, 0, ("Some countries have osrm and features mismatch.")); +} } // namespace