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-08-05 17:55:54 +0300
committerVladimir Byko-Ianko <v.bykoianko@corp.mail.ru>2016-08-19 13:54:05 +0300
commitae4521e95661f4dd823bf6e28204513521935b8b (patch)
tree044a286e2898e814c294867910e4accb0f8e6220 /routing
parentcb69e41338dc48cb0fcfaf84352f3aeb098bfcee (diff)
Get altitude integration test for all mwm features.
Diffstat (limited to 'routing')
-rw-r--r--routing/routing_integration_tests/get_altitude_test.cpp75
-rw-r--r--routing/routing_integration_tests/routing_integration_tests.pro1
2 files changed, 76 insertions, 0 deletions
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<MwmSet::MwmId, MwmSet::RegResult> 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<MwmValue>();
+ TEST(mwmValue != nullptr, ());
+ unique_ptr<AltitudeLoader> altitudeLoader = make_unique<AltitudeLoader>(*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 \