diff --git a/routing/routing_integration_tests/get_altitude_test.cpp b/routing/routing_integration_tests/get_altitude_test.cpp new file mode 100644 index 0000000000..04bdff4df9 --- /dev/null +++ b/routing/routing_integration_tests/get_altitude_test.cpp @@ -0,0 +1,75 @@ +#include "testing/testing.hpp" + +#include "indexer/altitude_loader.hpp" +#include "indexer/classificator.hpp" +#include "indexer/classificator_loader.hpp" +#include "indexer/feature_altitude.hpp" +#include "indexer/feature_data.hpp" +#include "indexer/feature_processor.hpp" +#include "indexer/index.hpp" + +#include "routing/routing_helpers.hpp" + +#include "geometry/mercator.hpp" + +#include "platform/local_country_file.hpp" + +#include "base/math.hpp" + +#include "std/string.hpp" +#include "std/unique_ptr.hpp" +#include "std/utility.hpp" + +namespace +{ +using namespace feature; + +void TestAltitudeOfAllMwmFeatures(string const & countryId, TAltitude const minAltitudeMeters, + TAltitude const maxAltitudeMeters) +{ + Index index; + platform::LocalCountryFile const country = platform::LocalCountryFile::MakeForTesting(countryId); + pair const regResult = index.RegisterMap(country); + + TEST_EQUAL(regResult.second, MwmSet::RegResult::Success, ()); + TEST(regResult.first.IsAlive(), ()); + + MwmSet::MwmHandle handle = index.GetMwmHandleById(regResult.first); + TEST(handle.IsAlive(), ()); + + MwmValue * mwmValue = handle.GetValue(); + TEST(mwmValue != nullptr, ()); + unique_ptr altitudeLoader = make_unique(*mwmValue); + + classificator::Load(); + classif().SortClassificator(); + + ForEachFromDat(country.GetPath(MapOptions::Map), [&](FeatureType const & f, uint32_t const & id) + { + if (!routing::IsRoad(TypesHolder(f))) + return; + + f.ParseGeometry(FeatureType::BEST_GEOMETRY); + size_t const pointsCount = f.GetPointsCount(); + if (pointsCount == 0) + return; + + TAltitudes altitudes = altitudeLoader->GetAltitudes(id, pointsCount); + TEST(!altitudes.empty(), + ("Empty altidude vector. MWM:", countryId, ", feature id:", id, ", altitudes:", altitudes)); + + for (auto const alitude : altitudes) + { + TEST_EQUAL(my::clamp(alitude, minAltitudeMeters, maxAltitudeMeters), alitude, + ("Unexpected altidude. MWM:", countryId, ", feature id:", id, ", altitudes:", altitudes)); + } + }); +} + +UNIT_TEST(AllMwmFeaturesGetAltitudeTest) +{ + TestAltitudeOfAllMwmFeatures("Russia_Moscow", 50 /* minAltitudeMeters */, 300 /* maxAltitudeMeters */); + TestAltitudeOfAllMwmFeatures("Nepal_Kathmandu", 250 /* minAltitudeMeters */, 6000 /* maxAltitudeMeters */); + TestAltitudeOfAllMwmFeatures("Netherlands_North Holland_Amsterdam", -25 /* minAltitudeMeters */, 50 /* maxAltitudeMeters */); +} +} // namespace diff --git a/routing/routing_integration_tests/routing_integration_tests.pro b/routing/routing_integration_tests/routing_integration_tests.pro index 4ecd20ebeb..43c0ffa377 100644 --- a/routing/routing_integration_tests/routing_integration_tests.pro +++ b/routing/routing_integration_tests/routing_integration_tests.pro @@ -27,6 +27,7 @@ SOURCES += \ bicycle_route_test.cpp \ bicycle_turn_test.cpp \ cross_section_tests.cpp \ + get_altitude_test.cpp \ online_cross_tests.cpp \ osrm_route_test.cpp \ osrm_street_names_test.cpp \